PHP code example of alledia / wordpress-plugin-framework

1. Go to this page and download the library: Download alledia/wordpress-plugin-framework 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/ */

    

alledia / wordpress-plugin-framework example snippets




// Call the autoloader.
$pluginBaseName = plugin_basename('you-plugin/your-plugin.php');
$eddApiUrl      = 'https://your-plugin-site.com';
$pluginAuthor   = 'Your Company/Plugin';

$framework = new Allex\Core($pluginBaseName, $eddApiUrl, $pluginAuthor);
$famrwork->init();


add_filter('allex_addons', 'filter_allex_addons', 10, 2);

// Initialize the module.
$framework->get_service('module_addons')->init();

/**
 * @param $addons
 * @param $plugin_name
 *
 * @return array
 */
function filter_allex_addons($addons, $plugin_name)
{
    if ('you-plugin' === $plugin_name) {
        $addons = [
            'addon-1' => [
                'slug'        => 'addon-1',
                'title'       => __('Add-on 1', 'your-plugin'),
                'description' => __('The first Add-on', 'your-plugin'),
                'icon_class'  => 'fa fa-check-circle',
                'edd_id'      => 6323,
            ],
            'addon-2' => [
                'slug'        => 'addon-2',
                'title'       => __('Add-on 2', 'your-plugin'),
                'description' => __('The second Add-on', 'your-plugin'),
                'icon_class'  => 'fab fa-bell',
                'edd_id'      => 8217,
            ],
        ];
    }
    
    return $addons;
}


add_action('allex_addon_update_license', 'action_allex_addon_update_license', 10, 4);
add_filter('allex_addons_get_license_key', 'filter_allex_addons_get_license_key', 10, 2);
add_filter('allex_addons_get_license_status', 'filter_allex_addons_get_license_status', 10, 2);

/**
 * @param $plugin_name
 * @param $addon_slug
 * @param $license_key
 * @param $license_status
 */
function action_allex_addon_update_license($plugin_name, $addon_slug, $license_key, $license_status)
{
    // ...
}

/**
 * @param $license_key
 * @param $addon_slug
 *
 * @return string
 */
function filter_allex_addons_get_license_key($license_key, $addon_slug)
{
    return $license_key;
}

/**
 * @param $license_status
 * @param $addon_slug
 *
 * @return string
 */
function filter_allex_addons_get_license_status($license_status, $addon_slug)
{
    return $license_status;
}