PHP code example of automattic / wp-feature-api

1. Go to this page and download the library: Download automattic/wp-feature-api 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/ */

    

automattic / wp-feature-api example snippets


// Plugin bootstrap code
function my_plugin_init() {
    // Just include the main plugin file - it automatically registers itself with the version manager
    loaded - the Feature API will resolve which version to use
add_action( 'plugins_loaded', 'my_plugin_init' );

/**
 * Register features provided by this plugin
 */
function my_plugin_register_features() {
    // Register your features here
    wp_register_feature( 'my-plugin/example-feature', array(
        'name' => 'Example Feature',
        'description' => 'An example feature from my plugin',
        'callback' => 'my_plugin_example_feature_callback',
        'type' => 'tool',
        'input_schema' => array(
            'type' => 'object',
            'properties' => array(
                'example_param' => array(
                    'type' => 'string',
                    'description' => 'An example parameter',
                ),
            ),
        ),
    ) );
}