1. Go to this page and download the library: Download wpsmith/plugin 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/ */
wpsmith / plugin example snippets
new \WPS\WP\Plugin\PreventUpdate( plugin_basename( __FILE__ ) );
new \WPS\WP\Plugin\PreventUpdate( 'advanced-custom-fields-pro/acf.php' );
new \WPS\WP\Plugin\HidePlugin( plugin_basename( __FILE__ ) );
new \WPS\WP\Plugin\HidePlugin( 'advanced-custom-fields-pro/acf.php' );
new \WPS\WP\Plugin\ExtendPlugin( 'advanced-custom-fields-pro/acf.php', __FILE__, '5.8.7', 'plugin-text-domain' );
global $my_plugin_uninstaller;
$my_plugin_uninstaller = new \WPS\WP\Plugin\UninstallManager( __FILE__ );
// Register activation stuffs.
register_activation_hook( __FILE__, function() {
global $my_plugin_uninstaller;
UninstallManager::on_activation( $my_plugin_uninstaller );
} );
// Register deactivation stuffs.
register_deactivation_hook( __FILE__, function() {
global $my_plugin_uninstaller;
UninstallManager::on_deactivation( $my_plugin_uninstaller );
} );
// If not using an uninstall.php, you need to register uninstall stuffs.
register_uninstall_hook( __FILE__, function() {
global $my_plugin_uninstaller;
$wps_codeable_delete_action = $my_plugin_uninstaller->get_uninstall_action();
// Bail if not deleting everything.
if ( 'everything' !== $wps_codeable_delete_action ) {
return;
}
// Delete Options.
$my_plugin_uninstaller->uninstall();
} );
/**
* Gets uninstall manager.
*
* This function can be placed anywhere. Alternatively, you can use a global variable to hold the uninstaller.
*
* @param string $plugin_file Absolute path to plugin base file.
*
* @return \WPS\WP\Plugin\UninstallManager
*/
function get_uninstall_manager( $plugin_file ) {
static $mgr;
if ( null === $mgr ) {
$mgr = new \WPS\WP\Plugin\UninstallManager( $plugin_file );
}
return $mgr;
}
// Setup Uninstall Manager at base of the plugin.
get_uninstall_manager( __FILE__ );
register_activation_hook( __FILE__, function() {
UninstallManager::on_activation( get_uninstall_manager() );
} );
register_deactivation_hook( __FILE__, function() {
UninstallManager::on_deactivation( get_uninstall_manager() );
} );
// Require the main plugin file.
do on deletion/uninstall.
$uninstall_manager = get_uninstall_manager();
$wps_codeable_delete_action = $uninstall_manager->get_uninstall_action();
// Bail if not deleting everything.
if ( 'everything' !== $wps_codeable_delete_action ) {
return;
}
// Delete Options.
$uninstall_manager->uninstall();