__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Automattic\WooCommerce\Blueprint;
trait UsePluginHelpers {
use UseWPFunctions;
/**
* Activate a plugin by its slug.
*
* Searches for the plugin with the specified slug in the installed plugins
* and activates it.
*
* @param string $slug The slug of the plugin to activate.
*
* @return false|null|WP_Error Null on success, WP_Error on invalid file, false if not found.
*/
public function activate_plugin_by_slug( $slug ) {
// Get all installed plugins.
$all_plugins = $this->wp_get_plugins();
// Loop through all plugins to find the one with the specified slug.
foreach ( $all_plugins as $plugin_path => $plugin_info ) {
// Check if the plugin path contains the slug.
if ( strpos( $plugin_path, $slug . '/' ) === 0 ) {
// Deactivate the plugin.
return $this->wp_activate_plugin( $plugin_path );
}
}
return false;
}
/**
* Check if a plugin with the specified slug is installed.
*
* @param string $slug The slug of the plugin to check.
*
* @return bool
*/
public function is_plugin_dir( $slug ) {
$all_plugins = $this->wp_get_plugins();
foreach ( $all_plugins as $plugin_file => $plugin_data ) {
// Extract the directory name from the plugin file path.
$plugin_dir = explode( '/', $plugin_file )[0];
// Check for an exact match with the slug.
if ( $plugin_dir === $slug ) {
return true;
}
}
return false;
}
/**
* Deactivate and delete a plugin by its slug.
*
* Searches for the plugin with the specified slug in the installed plugins,
* deactivates it if active, and then deletes it.
*
* @param string $slug The slug of the plugin to delete.
*
* @return bool|WP_Error True if the plugin was deleted, false otherwise.
*/
public function delete_plugin_by_slug( $slug ) {
// Get all installed plugins.
$all_plugins = $this->wp_get_plugins();
// Loop through all plugins to find the one with the specified slug.
foreach ( $all_plugins as $plugin_path => $plugin_info ) {
// Check if the plugin path contains the slug.
if ( strpos( $plugin_path, $slug . '/' ) === 0 ) {
// Deactivate the plugin.
if ( $this->deactivate_plugin_by_slug( $slug ) ) {
// Delete the plugin.
return $this->wp_delete_plugins( array( $plugin_path ) );
}
}
}
return false;
}
/**
* Deactivate a plugin by its slug.
*
* Searches for the plugin with the specified slug in the installed plugins
* and deactivates it.
*
* @param string $slug The slug of the plugin to deactivate.
*
* @return bool True if the plugin was deactivated, false otherwise.
*/
public function deactivate_plugin_by_slug( $slug ) {
// Get all installed plugins.
$all_plugins = $this->wp_get_plugins();
// Loop through all plugins to find the one with the specified slug.
foreach ( $all_plugins as $plugin_path => $plugin_info ) {
// Check if the plugin path contains the slug.
if ( strpos( $plugin_path, $slug . '/' ) === 0 ) {
// Deactivate the plugin.
deactivate_plugins( $plugin_path );
// Check if the plugin has been deactivated.
if ( ! is_plugin_active( $plugin_path ) ) {
return true;
}
}
}
return false;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Cli | Folder | 0775 |
|
|
| Exporters | Folder | 0775 |
|
|
| Importers | Folder | 0775 |
|
|
| ResourceStorages | Folder | 0775 |
|
|
| ResultFormatters | Folder | 0775 |
|
|
| Schemas | Folder | 0775 |
|
|
| Steps | Folder | 0775 |
|
|
| docs | Folder | 0775 |
|
|
| BuiltInExporters.php | File | 474 B | 0664 |
|
| BuiltInStepProcessors.php | File | 1.81 KB | 0664 |
|
| ClassExtractor.php | File | 6.05 KB | 0664 |
|
| Cli.php | File | 1.78 KB | 0664 |
|
| ExportSchema.php | File | 4.3 KB | 0664 |
|
| ImportSchema.php | File | 2.34 KB | 0664 |
|
| ImportStep.php | File | 4.46 KB | 0664 |
|
| Logger.php | File | 4.07 KB | 0664 |
|
| ResourceStorages.php | File | 1.45 KB | 0664 |
|
| StepProcessor.php | File | 680 B | 0664 |
|
| StepProcessorResult.php | File | 3.56 KB | 0664 |
|
| UsePluginHelpers.php | File | 3.13 KB | 0664 |
|
| UsePubSub.php | File | 1.51 KB | 0664 |
|
| UseWPFunctions.php | File | 9.72 KB | 0664 |
|
| Util.php | File | 4.39 KB | 0664 |
|