### Basic Singleton Instance Call Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/singleton/README.md A typical usage example for getting a singleton instance, passing the class name and the calling object. ```php Singleton::get_instance( 'MyClass', $this ); ``` -------------------------------- ### Start wp-env Docker Environment Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Starts the Docker environment for WordPress testing using wp-env. The 'afterStart' lifecycle script installs Xdebug into the tests-cli container. ```sh npm run wp-env start ``` -------------------------------- ### Install Singleton via Composer Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/singleton/README.md Install the singleton library using Composer. This command fetches the dev-master branch. ```bash composer require afragen/singleton:dev-master ``` -------------------------------- ### Install Private GitHub or GitLab Repository Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install a private repository from GitHub or GitLab by providing an access token. ```bash wp plugin install-git --token=my_super_secret_token ``` -------------------------------- ### Install PHP Dependencies Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Use this command to install PHP dependencies required for the project. ```sh composer install ``` -------------------------------- ### Injecting Install::$install for Remote Install Path Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Use ReflectionProperty to set the protected static Install::$install property to simulate the conditions required for the remote install source path in upgrader_source_selection(). ```php ReflectionProperty::setValue(null, [...]); ``` -------------------------------- ### Install Plugin or Theme via Git URL Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install a plugin or theme from a Git repository URI. Supports specifying branch, access token for private repos, and repository host. ```bash wp plugin install-git [--branch=] [--github] [--bitbucket] [--gitlab] wp theme install-git [--branch=] [--github] [--bitbucket] [--gitlab] ``` -------------------------------- ### Install Theme from Private Bitbucket Repo via WP-CLI Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install a theme from a private Bitbucket repository using the install-git subcommand with token credentials. ```bash wp theme install-git https://bitbucket.org/my-username/my-theme --token=username:password ``` -------------------------------- ### Install WP Readme Parser via Composer Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-readme-parser/README.md Use Composer to install the library. This is the recommended method for adding the parser to your project. ```bash composer require fragen/wp-readme-parser ``` -------------------------------- ### Install Specific Branch Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install a plugin or theme from a specific branch by using the --branch option. Defaults to 'master'. ```bash wp plugin install-git --branch=develop ``` -------------------------------- ### Install and Activate Git Updater Plugin Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install the Git Updater plugin from a zip archive and activate it using WP-CLI. ```bash wp plugin install https://github.com/afragen/git-updater/archive/master.zip --activate ``` -------------------------------- ### Specify Self-Hosted Git Installation Type Source: https://github.com/afragen/git-updater/wiki/WP-CLI Use flags like --github, --bitbucket, --gitlab, --gitea, or --gist to specify the type of self-hosted Git installation. ```bash --github --bitbucket --gitlab --gitea --gist ``` -------------------------------- ### Plugin Header Example Source: https://github.com/afragen/git-updater/wiki/Usage This is an example of the required plugin header for Git Updater. Ensure the 'GitHub Plugin URI' or equivalent is present. ```php /** * Plugin Name: Git Updater * Plugin URI: https://github.com/afragen/git-updater * Description: A plugin to automatically update GitHub, Bitbucket or GitLab hosted plugins and themes. It also allows for remote installation of plugins or themes into WordPress. * Version: 10.0.0 * Author: Andy Fragen * License: MIT * Domain Path: /languages * Text Domain: git-updater * GitHub Plugin URI: https://github.com/afragen/git-updater * GitHub Languages: https://github.com/afragen/git-updater-translations */ ``` -------------------------------- ### Install Private Bitbucket Repository Source: https://github.com/afragen/git-updater/wiki/WP-CLI Install a private Bitbucket repository using your Bitbucket username and an app password, separated by a colon. ```bash wp plugin install-git --token=username:password ``` -------------------------------- ### Install JS Dependencies Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Installs JavaScript dependencies, which are necessary for using wp-env. ```sh npm install ``` -------------------------------- ### Install Git Updater using WP-CLI Source: https://github.com/afragen/git-updater/wiki/Installation Use the WP-CLI command to install and activate the Git Updater plugin directly from its master archive. This is a quick method for command-line users. ```bash wp plugin install --activate https://github.com/afragen/git-updater/archive/master.zip ``` -------------------------------- ### Theme Header Example Source: https://github.com/afragen/git-updater/wiki/Usage This is an example of the required theme header for Git Updater. Ensure the 'GitHub Theme URI' or equivalent is present. The directory name must match the repository name. ```php /** * Theme Name: Test * Theme URI: http://thefragens.net/ * Version: 0.1.0 * Description: Child theme of TwentyTwelve. * Author: Andy Fragen * Template: twentytwelve * Template Version: 1.0.0 * GitHub Theme URI: https://github.com/afragen/test-child */ ``` -------------------------------- ### Run All PHPUnit Tests Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-readme-parser/README.md Execute all tests using Composer and PHPUnit. This command installs dependencies and then runs the test suite. ```bash composer install ./vendor/bin/phpunit ``` -------------------------------- ### Switch Plugin or Theme Branch Source: https://github.com/afragen/git-updater/wiki/WP-CLI Switch an installed plugin or theme to a different branch using its slug and the desired branch name. ```bash wp plugin branch-switch wp theme branch-switch ``` -------------------------------- ### Install Parsedown with Composer Source: https://github.com/afragen/git-updater/blob/develop/vendor/erusev/parsedown/README.md Use Composer to install the Parsedown package. This is the recommended method for managing dependencies. ```sh composer require erusev/parsedown ``` -------------------------------- ### Get Upgrade URL Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md Call the SDK method to get the upgrade URL for a plugin or theme. ```php get_upgrade_url(); ?> ``` -------------------------------- ### Testing get_remote_repo_meta() Null API Return Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Exercise the null API early return path in get_remote_repo_meta() by calling get_repo_api('bitbucket', $repo) when the Bitbucket add-on is not installed, causing the API class to be null. ```php $repo->git = 'bitbucket'; ``` -------------------------------- ### Get Help for Git Updater WP-CLI Commands Source: https://github.com/afragen/git-updater/wiki/WP-CLI View help information for Git Updater's plugin and theme subcommands. ```bash wp plugin install-git --help wp theme install-git --help wp plugin branch-switch --help wp theme branch-switch --help ``` -------------------------------- ### Composer Installation Configuration Source: https://github.com/afragen/git-updater/wiki/Installation Add this JSON configuration to your project's composer.json file to manage Git Updater installation via Composer. Ensure correct paths for plugins and themes. ```json { "require": { "afragen/git-updater": "^9", "composer/installers": "^1" }, "minimum-stability": "dev", "repositories": [ { "type": "vcs", "url": "https://github.com/afragen/git-updater" } ], "extra": { "installer-paths": { "wp-content/plugins/{$name}/": [ "type:wordpress-plugin" ], "wp-content/themes/{$name}/": [ "type:wordpress-theme" ] } } } ``` -------------------------------- ### Simulate Network Admin for Plugin Meta Tests Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md When testing `get_remote_plugin_meta()` in a multisite setup on a single-site run, simulate being in the network admin by setting the current screen. Remember to reset it in `tear_down()`. ```php $GLOBALS['current_screen'] = set_current_screen('plugins-network'); // ... test code ... $GLOBALS['current_screen'] = null; ``` -------------------------------- ### Get Singleton Instance Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/singleton/README.md Retrieve a singleton instance of a class. Pass the class name, the calling object, and optional constructor options. ```php Singleton::get_instance( $class_name, $calling_class, $options ); ``` -------------------------------- ### WordPress REST API Permission Callback Example Source: https://github.com/afragen/git-updater/blob/develop/docs/security-review-2026-06.md Demonstrates how to implement a permission callback for WordPress REST API routes. This snippet shows the recommended approach for handling authenticated requests by returning a WP_Error for invalid credentials. ```php return new WP_Error( 'gu_bad_key', 'Bad API key.', [ 'status' => 401 ] ); ``` -------------------------------- ### Initialize Freemius SDK in WordPress Plugin Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md This snippet should be placed at the top of your main plugin's PHP file after the header comment. It includes the SDK and initializes it with your product details. Ensure to remove the secret key before deployment. ```php if ( ! function_exists( 'my_prefix_fs' ) ) { // Create a helper function for easy SDK access. function my_prefix_fs() { global $my_prefix_fs; if ( ! isset( $my_prefix_fs ) ) { // Include Freemius SDK. require_once dirname(__FILE__) . '/freemius/start.php'; $my_prefix_fs = fs_dynamic_init( array( 'id' => '1234', 'slug' => 'my-new-plugin', 'premium_slug' => 'my-new-plugin-premium', 'type' => 'plugin', 'public_key' => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y', 'is_premium' => true, // If your plugin is a serviceware, set this option to false. 'has_premium_version' => true, 'has_paid_plans' => true, 'is_org_compliant' => true, 'menu' => array( 'slug' => 'my-new-plugin', 'parent' => array( 'slug' => 'options-general.php', ), ), // Set the SDK to work in a sandbox mode (for development & testing). // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT. 'secret_key' => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE', ) ); } return $my_prefix_fs; } // Init Freemius. my_prefix_fs(); // Signal that SDK was initiated. do_action( 'my_prefix_fs_loaded' ); } ``` -------------------------------- ### Run PHPUnit Tests with Code Coverage Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Generates code coverage reports for PHPUnit tests. Requires Xdebug, which is automatically installed when wp-env starts. ```sh npm run test:coverage ``` -------------------------------- ### Instantiate WP Readme Parser Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-readme-parser/README.md Create a new instance of the Parser class. You can provide the readme content from a file path, a URL, or a raw string. ```php use Fragen\WP_Readme_Parser\Parser; // From a file path $parser = new Parser('/path/to/readme.txt'); // From a URL $parser = new Parser('https://plugins.svn.wordpress.org/my-plugin/trunk/readme.txt'); // From a raw string $parser = new Parser($readmeContents); ``` -------------------------------- ### Save and Restore Singleton Config in Setup/Teardown Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Always save singleton configuration in set_up() and restore it in tear_down() to prevent state leakage between tests. This is crucial for singletons like Plugin, Theme, or API configurations. ```php /** @var array */ private array $saved_plugin_config = []; public function set_up(): void { parent::set_up(); // ... other setup ... $singleton = Fragen\Singleton::get_instance( 'Fragen\Git_Updater\Plugin', $caller ); $rp = new ReflectionProperty( Plugin::class, 'config' ); $rp->setAccessible( true ); $this->saved_plugin_config = $rp->getValue( $singleton ) ?? []; } public function tear_down(): void { $singleton = Fragen\Singleton::get_instance( 'Fragen\Git_Updater\Plugin', $caller ); $rp = new ReflectionProperty( Plugin::class, 'config' ); $rp->setAccessible( true ); $rp->setValue( $singleton, $this->saved_plugin_config ); parent::tear_down(); } ``` -------------------------------- ### Specimen Bitbucket Pipeline for Theme Releases Source: https://github.com/afragen/git-updater/wiki/User-Build-Processes This pipeline automates the creation of release assets for themes on Bitbucket. It triggers when a new tag is pushed, builds the theme assets, and uploads a zip file as a release. Ensure required environment variables like GITHUB_ACCESS_TOKEN, APP_USERNAME, and APP_PASSWORD are set. ```yaml # This is a sample build configuration for PHP. # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: php:7.1.29 pipelines: branches: # Execute change detection only on master branch 'master': - step: image: atlassian/default-image:2 # Run change detection script (requires git command) script: - ./changedetected.sh tags: # Build and upload release asset each time a new tag is pushed '*.*.*': - step: caches: - composer - node script: # Setup Environment - apt-get update && apt-get install -y unzip zip - curl -sL https://deb.nodesource.com/setup_13.x | bash - - apt-get install -y nodejs - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Install node and composer dependencies - composer config -g github-oauth.github.com $GITHUB_ACCESS_TOKEN - composer install --prefer-dist - npm install # Build all script and style assets (if you use a node based build toolchain) - npm run build # Zip and upload new release (replace directories to zip with your own) - zip -r -q release/$BITBUCKET_REPO_SLUG-$BITBUCKET_TAG.zip *.php assets/ fonts/ languages/ inc/ page-templates/ views/ vendor/ style.css screenshot.jpg - pipe: atlassian/bitbucket-upload-file:0.1.2 variables: BITBUCKET_USERNAME: $APP_USERNAME BITBUCKET_APP_PASSWORD: $APP_PASSWORD FILENAME: 'release/$BITBUCKET_REPO_SLUG-$BITBUCKET_TAG.zip' ``` -------------------------------- ### Run PHPUnit Tests (Single Site) Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Executes PHPUnit tests using wp-env for a single-site WordPress environment. This command delegates to 'npm test'. ```sh composer test # delegates to: npm test npm test ``` -------------------------------- ### Test Basic_Auth_Loader::add_accept_header() with Git-Server Header Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Exercise the git-server header branch by passing ['headers' => ['github' => $slug]] and pre-seeding the repo cache. This triggers the Accept: application/octet-stream merge. Without the cache entry, no Accept header is added. ```php update_site_option('ghu-' . md5($slug), ['release_asset_download' => 'https://...']) // ... later ... $this->add_accept_header($slug, ['headers' => ['github' => $slug]]) ``` -------------------------------- ### WordPress REST API Public Read-Only Route Source: https://github.com/afragen/git-updater/blob/develop/docs/security-review-2026-06.md Example of a public read-only endpoint in WordPress REST API. It uses `__return_true` for the permission callback, indicating that no authentication is required. ```php // Intentionally public read-only. __return_true ``` -------------------------------- ### Seed Main Cache with Future Timeout for Testing Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Use `update_site_option()` with `array_merge()` to pre-populate the main site option for cache-hit testing. Merging with a future timeout (`strtotime('+12 hours')`) prevents `get_repo_cache()` from rejecting the entry. ```php update_site_option( $this->api->get_cache_key( 'test-plugin' ), array_merge( [ 'timeout' => strtotime( '+12 hours' ) ], $data ) ); ``` -------------------------------- ### Admin Notice HTML Structure Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-dismiss-notice/README.md Example of an HTML structure for a WordPress admin notice that is dismissible for 14 days. The `data-dismissible` attribute specifies a unique identifier and the timeout period. ```html
...
``` -------------------------------- ### Logic for Professional Plan and Higher Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md Execute logic for customers on the 'professional' plan or any higher-tier plans. ```php is_plan('professional') ) { // ... logic related to Professional plan and higher plans ... } ?> ``` -------------------------------- ### Assert `ajax-activate` Script Registration Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md When testing `Add_Ons::add_admin_page()`, assert the registration of the `ajax-activate` script instead of `plugin-install`. The `ajax-activate` script is reliably registered by the method, whereas `plugin-install` might already be in a 'done' state from prior tests. ```php wp_script_is('ajax-activate', 'registered') ``` -------------------------------- ### Example Git Updater REST API Endpoint URL Source: https://github.com/afragen/git-updater/wiki/Remote-Management---RESTful-Endpoints This is the base URL for the Git Updater REST API, including a sample authentication key. The exact URL will vary based on your system configuration. ```bash http://localhost/wp-json/git-updater/v1/update/?key=76bb2b7c819c36ee37292b6978a4ad61 ``` -------------------------------- ### Curl Request: No Plugin or Theme Specified Source: https://github.com/afragen/git-updater/wiki/Remote-Management---RESTful-Endpoints Demonstrates a curl request to the Git Updater API without specifying a plugin or theme, resulting in an error message. ```bash $ curl "http://localhost/wp-json/git-updater/v1/update/?key=76bb2b7c819c36ee37292b6978a4ad61" { "message": "No plugin or theme specified for update.", "success": false } ``` -------------------------------- ### Handle OAuth Callback Without State Verification Source: https://github.com/afragen/git-updater/blob/develop/docs/security-review-2026-06.md This snippet shows the original implementation of the OAuth callback handler, which lacks state verification. It accepts provider and exchange code from GET parameters and fetches an access token. ```php public function handle_callback(): void { if ( ! current_user_can( is_multisite() ? 'manage_network_options' : 'manage_options' ) ) { wp_die( esc_html__( 'Forbidden', 'git-updater' ) ); } $provider = sanitize_key( $_GET['provider'] ?? '' ); $exchange_code = sanitize_text_field( wp_unslash( $_GET['gu_exchange_code'] ?? '' ) ); // ... } ``` -------------------------------- ### Display Marketing Content for Upgrades Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md Add marketing content that encourages users to upgrade to a paid version of the product. ```php is_not_paying() ) { echo '

' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '

'; echo '' . esc_html__('Upgrade Now!', 'my-plugin-slug') . ''; echo '
'; } ?> ``` -------------------------------- ### Snapshot and Clean Up Block Bindings in Tests Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md To prevent duplicate registration notices during tests, snapshot block bindings in `set_up()` and unregister any newly registered ones in `tear_down()` that were not present initially. ```php private array $pre_registered_bindings = []; public function set_up(): void { parent::set_up(); if ( class_exists( 'WP_Block_Bindings_Registry' ) ) { $this->pre_registered_bindings = array_keys( WP_Block_Bindings_Registry::get_instance()->get_all_registered() ); } } // In tear_down(), before parent::tear_down(): if ( class_exists( 'WP_Block_Bindings_Registry' ) ) { foreach ( array_keys( WP_Block_Bindings_Registry::get_instance()->get_all_registered() ) as $name ) { if ( ! in_array( $name, $this->pre_registered_bindings, true ) ) { unregister_block_bindings_source( $name ); } } } ``` -------------------------------- ### Fire `gu_add_admin_page` Action with Two Arguments Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md When testing `Add_Ons::add_settings_tabs()`, ensure the `gu_add_admin_page` action is fired with two arguments: the slug and the admin URL. This is necessary because other components also hook into this action with `accepted_args=2`. ```php do_action('gu_add_admin_page', 'git_updater_addons', admin_url()) ``` -------------------------------- ### Singleton Pattern Usage Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-architecture.md Demonstrates how to access shared class instances using the Singleton pattern. The second argument is passed to the constructor on first instantiation. ```php Fragen\Singleton::get_instance('ClassName', $this) ``` -------------------------------- ### Control Basic_Auth_Loader::add_auth_header() Credentials via Site Option Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Test the Bearer-token path by updating the site option with 'github_access_token'. Test the no-token path by leaving the site option absent. This directly controls how get_credentials() resolves the token. ```php update_site_option('git_updater', ['github_access_token' => 'test-token']) // To test no-token path: // delete_site_option('git_updater') ``` -------------------------------- ### Test Basic_Auth_Loader::get_credentials() with Language_Pack_API Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Instantiate Language_Pack_API directly to cover the $this instanceof Language_Pack_API branch in get_credentials(). This ensures proper handling of its specific constructor logic and parent::__construct() calls. ```php $language_pack_api = new Language_Pack_API($type); ``` -------------------------------- ### Logic for Users in Trial Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md Implement specific logic that should only run for users who are currently in a trial period. ```php is_trial() ) { // ... logic for users in trial ... } ?> ``` -------------------------------- ### Run PHPUnit Tests (Multisite) Source: https://github.com/afragen/git-updater/blob/develop/CLAUDE.md Executes PHPUnit tests using wp-env for a multisite WordPress environment. This command delegates to 'npm run test:multisite'. ```sh composer test-ms # delegates to: npm run test:multisite npm run test:multisite ``` -------------------------------- ### Populating API Data with Meta Case Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Passes $this->api->type as the $repo argument to populate_api_data() to ensure that the meta data is correctly assigned to $repo_api->type->repo_meta. This allows testing the assignment logic within add_meta_repo_object(). ```php $this->api->populate_api_data( $this->api->type, $this->api ); $this->assertSame( '2024-01-01T00:00:00Z', $this->api->type->last_updated ); ``` -------------------------------- ### Testing fix_misnamed_directory() with Empty Source Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Directly test the specific code path in fix_misnamed_directory() that is only reachable when $new_source is an empty string, by using ReflectionMethod. ```php ReflectionMethod::invokeArgs($fix_misnamed_directory_method, [ '', $slug ]); ``` -------------------------------- ### Set Custom Options and Access Tokens Source: https://github.com/afragen/git-updater/wiki/Developer-Hooks Use the 'gu_set_options' hook to distribute custom options and access tokens for private themes/plugins. The anonymous function must return key/value pairs. ```php add_filter( 'gu_set_options', function () { return array( 'my-private-theme' => 'kjasdp984298asdvhaljsg984aljhgosrpfiu', 'github_access_token' => 'iorgoaihrg[89930ews8dchujnasgp', ); } ); ``` -------------------------------- ### Testing maybe_extend_repo_cache Version Match Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md When directly testing `maybe_extend_repo_cache()` for the version-match path, explicitly pass the matching old version as the third argument. This ensures the version comparison logic is correctly exercised. ```PHP $this->api->maybe_extend_repo_cache( [ 'Version' => '1.0.0' ], $this->type, '1.0.0' ); ``` -------------------------------- ### Creating Skip_Updates Plugin Stub with eval() Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Creates a stub class for 'Fragen\Skip_Updates\Bootstrap' using eval() to satisfy class_exists checks in tests. The class_exists guard prevents redeclaration errors, and the site option 'skip_updates' should be deleted after tests. ```php private function ensure_skip_updates_stub(): void { if ( ! class_exists( '\Fragen\Skip_Updates\Bootstrap' ) ) { eval( 'namespace Fragen\Skip_Updates; class Bootstrap {}' ); } } ``` -------------------------------- ### Singleton Instance with Namespace Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/singleton/README.md When using PSR-4 autoloading, specify the class name with its namespace if it resides in a subdirectory like 'src/MySubDir/MyClass'. ```php Singleton::get_instance( 'MySubDir\MyClass', $this ); ``` -------------------------------- ### Set Base Options Before Theme Construction Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md To ensure `self::$options['current_branch_X']` is available during Theme object construction, set `Base::$options['current_branch_X']` prior to calling `new Theme()`. This value is then copied to `Theme::$options`. ```php Base::$options['current_branch_X'] = $value; ``` -------------------------------- ### Invoking get_repo_slugs on Plugin Instance Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md Demonstrates how to invoke the get_repo_slugs method on a Plugin instance using ReflectionMethod to avoid TypeErrors that occur when invoked on a GitHub_API instance without a config. ```php $rm = $this->api->get_reflection_method( $this->plugin_obj, 'get_repo_slugs' ); $result = $rm->invoke( $this->plugin_obj, 'nonexistent-slug', null ); ``` -------------------------------- ### Bypass HTTP Mock for Theme/Plugin Meta with Cron Disabled Source: https://github.com/afragen/git-updater/blob/develop/docs/claude-testing-gotchas.md When `gu_disable_wpcron` is true and `can_update()` returns false (typical in test environments), the `get_remote_repo_meta()` method short-circuits before making HTTP calls. No HTTP mock is required in this scenario. ```php if ($disable_wp_cron && !can_update()) return false; ``` -------------------------------- ### Initialize WP Dismiss Notice Class Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-dismiss-notice/README.md Instantiate the WP_Dismiss_Notice class to enable dismissible notices in your WordPress project. ```php new \WP_Dismiss_Notice(); ``` -------------------------------- ### Running Specific PHPUnit Tests Source: https://github.com/afragen/git-updater/blob/develop/vendor/afragen/wp-readme-parser/CLAUDE.md Commands to execute specific test files, methods, or test suites using PHPUnit. ```bash # Run a single test file ./vendor/bin/phpunit tests/SectionParsingTest.php ``` ```bash # Run a specific test method ./vendor/bin/phpunit --filter testMethodName ``` ```bash # Run a test suite ./vendor/bin/phpunit --testsuite Unit ./vendor/bin/phpunit --testsuite Integration ``` -------------------------------- ### Premium Logic for Professional Plan and Higher Source: https://github.com/afragen/git-updater/blob/develop/vendor/freemius/wordpress-sdk/README.md Execute logic only for premium users on the 'professional' plan or higher. ```php is_plan__premium_only('professional') ) { // ... logic related to Professional plan and higher plans ... } ?> ```