Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/tests export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/.gitignore export-ignore
/CLAUDE.md export-ignore
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Tests
on:
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- run: composer install --no-progress
- run: composer test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
vendor
/vendor/
/.phpunit.result.cache
/phpunit.xml
45 changes: 45 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

WordPress plugin updater library (`shazzad/plugin-updater`) that enables automatic updates, license verification, and remote plugin management for custom WordPress plugins. It hooks into WordPress core's update system to check a remote API for updates.

## Commands

```bash
# Run tests
composer test

# Lint (WordPress coding standards + PHP compatibility)
composer lint

# Lint with WordPress coding standards only
composer phpcs

# Auto-fix coding standard violations
composer fix
```

No phpunit.xml config exists yet — tests are fixture-based JSON files in `tests/fixtures/` representing API response shapes.

## Architecture

**Entry point:** `Integration` is the main class — consumer plugins instantiate it with API URL, product file, product ID, and optional license/menu config. The constructor wires up the three subsystems:

- **`Integration`** (`src/Integration.php`) — Holds all shared state (API URL, product info, license config). Provides `api_request()` for all remote API calls and license/transient management helpers.
- **`Updater`** (`src/Updater.php`) — Hooks into WordPress update system (`pre_set_site_transient_update_plugins`, `plugins_api`, `upgrader_package_options`, `upgrader_process_complete`) to inject update data from the remote API.
- **`Admin`** (`src/Admin.php`) — Renders the license management admin page. Only instantiated when `license_enabled` and `display_menu` are both true. Handles license save/verify via POST with nonce verification.
- **`Tracker`** (`src/Tracker.php`) — Handles plugin activation/deactivation hooks and hourly cron license sync via `sync_license_data()`.

All classes receive the `Integration` instance and use its public properties directly (no getters/setters pattern).

## Code Conventions

- **WordPress coding standards** enforced via PHPCS (`WordPress` standard)
- PHP 7.4+ with WordPress `ABSPATH` guard and `class_exists()` guard wrapping each class
- Namespace: `Shazzad\PluginUpdater` with PSR-4 autoloading from `src/`
- Uses tabs for indentation (WordPress standard)
- All API calls go through `Integration::api_request()` — returns associative array on success or `WP_Error` on failure
- WordPress capability required for admin: `delete_users`
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ A comprehensive WordPress plugin updater library that enables automatic updates,

## Installation

1. Copy the plugin updater files to your plugin directory
2. Include the Integration class in your main plugin file
3. Initialize the updater with your configuration
```bash
composer require shazzad/plugin-updater
```

## Quick Start

```php
<?php
// Include the Integration class
require_once plugin_dir_path( __FILE__ ) . 'updater/Integration.php';

// Initialize the updater
// Initialize the updater (autoloaded via Composer)
new \Shazzad\PluginUpdater\Integration(
'https://your-api-server.com/api', // API URL
plugin_basename( __FILE__ ), // Plugin file path
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"ext-curl": "*"
},
"require-dev": {
"brain/monkey": "^2.6",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"mockery/mockery": "^1.6",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^2.3",
"phpcompatibility/php-compatibility": "^9.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2"
"wp-coding-standards/wpcs": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -84,4 +86,4 @@
"dev-v2.x": "2.x-dev"
}
}
}
}
254 changes: 253 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading