PHP code example of pcfreak30 / composepress

1. Go to this page and download the library: Download pcfreak30/composepress library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pcfreak30 / composepress example snippets


use ComposePress\Core\Plugin;
use ComposePress\Core\PluginContext;
use ComposePress\Core\WordPressHooks;

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    subscribers: [new RegisterContentTypes()],
    hooks: new WordPressHooks(),
);

$plugin->boot();

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    activator: new InstallPlugin($migrator),
    deactivator: new DisablePlugin($scheduler),
    uninstaller: UninstallPlugin::class,
);

use ComposePress\Core\Testing\RecordingActivator;
use ComposePress\Core\Testing\RecordingDeactivator;
use ComposePress\Core\Testing\RecordingHooks;
use ComposePress\Core\Testing\RecordingSubscriber;
use ComposePress\Core\Testing\SpyingUninstall;

$hooks = new RecordingHooks();
$subscriber = new RecordingSubscriber(['init', 'save_post']);

$plugin = new Plugin(
    context: new PluginContext(__FILE__, 'example-plugin', '1.0.0'),
    subscribers: [$subscriber],
    hooks: $hooks,
);

$plugin->boot();

self::assertSame(['init', 'save_post'], $hooks->actionNames());
self::assertCount(1, $hooks->actionsFor('save_post'));
self::assertSame(1, $subscriber->invocations());