1. Go to this page and download the library: Download plugin-sdk/wp 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/ */
plugin-sdk / wp example snippets
use PluginSDK\WP\Plugin;
use Acme\Forms\REST\Submissions;
add_action('plugins_loaded', function () {
Plugin::fromManifest(__DIR__ . '/plugin-sdk.json', __FILE__)
->withRestHandler('Acme\\Forms\\REST\\Submissions::create', [Submissions::class, 'create'])
->boot();
});
use PluginSDK\WP\Settings;
use PluginSDK\WP\Settings\Field;
use PluginSDK\WP\REST;
use PluginSDK\WP\Migration;
use PluginSDK\WP\Migration\Table;
(new Settings('acme-forms', 'Acme Forms'))
->capability('manage_options')
->section('general', 'General')
->field('api_key', 'API Key', Field::TYPE_PASSWORD, ' => 'email']]])
->setHandler([Submissions::class, 'create']);
(new Migration('acme_forms_db_version', '0.1.0', 'acme_'))
->addTable(new Table('submissions', [
['name' => 'id', 'type' => 'BIGINT UNSIGNED', 'primary' => true, 'autoIncrement' => true],
['name' => 'email', 'type' => 'VARCHAR(255)', 'notNull' => true],
]));
use PluginSDK\WP\Components;
use PluginSDK\WP\Assets;
// Enqueue the stylesheet (from CDN, or pass a local URL)
add_action('admin_enqueue_scripts', [Assets::class, 'enqueue_cdn']);
// Render a settings page
function my_plugin_render_settings_page(): void {
echo Components::wrap(
Components::page_header('My Plugin Settings', [
'action' => ['label' => 'Add New', 'href' => '?page=add-new'],
]) .
Components::notice_success('Settings saved.', ['dismissible' => true]) .
Components::form_table(
Components::form_row('API Key',
Components::input(['name' => 'api_key', 'id' => 'api-key']),
['for' => 'api-key', 'description' => 'Find your key in the dashboard.']
) .
Components::form_row('Notifications',
Components::toggle([
'name' => 'notify',
'label' => 'Email me when events fire',
'checked' => true,
])
)
) .
Components::submit(
Components::button('Save Changes', ['variant' => 'primary', 'type' => 'submit'])
)
);
}
bash
composer test
# or directly:
php tests/run.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.