PHP code example of meumouse / mds-php-sdk

1. Go to this page and download the library: Download meumouse/mds-php-sdk 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/ */

    

meumouse / mds-php-sdk example snippets




add_action( 'mds_sdk_loaded', function () {
    \MeuMouse\MDS\SDK\SDK::register( array(
        'product_slug'    => 'my-plugin',           // matches the MDS product slug
        'type'            => 'plugin',              // 'plugin' | 'theme'
        'file'            => plugin_basename( __FILE__ ),
        'current_version' => '1.0.0',
        'api_base_url'    => 'https://api.meumouse.com',
        'api_key'         => 'mds_live_xxx',        // public, low-privilege product key
        'public_key'      => 'BASE64_ED25519_PUBLIC_KEY',
        'item_name'       => 'My Plugin',
        'settings_parent' => 'options-general.php', // optional auto License submenu
    ) );
} );

register_deactivation_hook( __FILE__, function () {
    $integration = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' );

    if ( $integration ) {
        $integration->shutdown();
    }
} );

SDK::register( array(
    // …',        // preset
    'features' => array(                 // per-flag override on top of it
        'update_details' => false,
    ),
) );

// All products, once, before boot.
add_filter( 'mds_sdk_features', function ( array $features, $slug ) {
    if ( 'my-plugin' === $slug ) {
        $features['notices'] = false;
    }

    return $features;
}, 10, 2 );

// One flag of one product.
add_filter( 'mds_my_plugin_feature_rollback', '__return_false' );

// wp-config.php — the site owner's kill switch. Constants are the final word:
// no filter can turn them back on.
define( 'MDS_MY_PLUGIN_FEATURE_NOTICES', false );  // one product
define( 'MDS_SDK_FEATURE_LOGGING', true );         // every product

$features = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' )->features();

$features->enabled( 'rollback' );  // bool, dependencies included
$features->mode();                 // "full" | "license_only" | "updates_only"
$features->active();               // names of the currently active flags
$features->conflicts();            // rows of { feature, 

$integration->is_licensed();          // true
$integration->license()->is_enabled();// false
$integration->license()->status()->status();      // "not_

$license = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' )->license();

$license->activate( 'MDS-XXXX-XXXX' );  // returns LicenseStatus, throws ApiException on transport failure
$license->deactivate();                 // releases this site and clears local state
$license->validate();                   // heartbeat: re-checks against the server
$license->status();                     // last persisted LicenseStatus, no network call
$license->is_active();                  // effective validity (honours expiry)
$license->has_key();
$license->get_key();
$license->is_enabled();                 // false when the `license` feature is off

$status = $license->status();

$status->is_valid();        // the server's last verdict
$status->status();          // one of the constants above
$status->expires_at();      // ISO-8601 string, or null for lifetime
$status->is_expired();
$status->is_signed();       // whether the last verdict came from a verified response
$status->is_

if ( \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' )->is_licensed() ) {
    // unlock premium behaviour
}

$bundle = $license->status()->get( 'bundle' );

if ( is_array( $bundle ) ) {
    // $bundle = array( 'id' => …, 'name' => 'Clube M', 'slug' => …, 'products' => array( … ) )
    printf( 'Licensed via %s', esc_html( $bundle['name'] ) );
}

$rollback = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' )->rollback();

$versions = $rollback->list_versions();        // cached; pass true to force a refresh
$result   = $rollback->rollback( '1.4.2' );    // true|WP_Error
$rollback->clear_cache();

$integration = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' );

$integration->settings()->render();        // license activation panel
$integration->rollback_page()->render();   // available versions / rollback

// Show it on your own settings screen too.
add_filter( 'mds_my_plugin_notice_screens', function ( array $screens ) {
    $screens[] = 'settings_page_my-plugin';

    return $screens;
} );

// Reword it, and make it dismissible.
add_filter( 'mds_my_plugin_notice_message', fn() => 'Ative sua licença para receber atualizações.' );
add_filter( 'mds_my_plugin_notice_args', function ( array $args ) {
    $args['dismissible'] = true;

    return $args;
} );

add_filter( 'mds_sdk_template', function ( $path, $name, $product ) {
    if ( 'license-settings' === $name && 'my-plugin' === $product->slug() ) {
        return plugin_dir_path( __FILE__ ) . 'templates/my-license-panel.php';
    }

    return $path;
}, 10, 3 );

$scheduler = \MeuMouse\MDS\SDK\SDK::get( 'my-plugin' )->scheduler();

$scheduler->hook();        // the per-product cron hook name
$scheduler->schedule();
$scheduler->unschedule();  // also called by Integration::shutdown()
$scheduler->run();         // run the heartbeat now
$scheduler->recurrence();  // the filtered cron schedule, "daily" by default
$scheduler->is_enabled();  // whether the heartbeat feature is on
bash
composer 

preset (mode)  →  features array  →  filters  →  constants
json
{
  "extra": {
    "strauss": {
      "target_directory": "vendor-prefixed",
      "namespace_prefix": "MyVendor\\Vendor\\",
      "packages": [ "meumouse/mds-php-sdk" ]
    }
  }
}
bash
php bin/generate-keys.php