當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Plugin_Upgrader::delete_old_plugin方法代碼示例

本文整理匯總了PHP中Plugin_Upgrader::delete_old_plugin方法的典型用法代碼示例。如果您正苦於以下問題:PHP Plugin_Upgrader::delete_old_plugin方法的具體用法?PHP Plugin_Upgrader::delete_old_plugin怎麽用?PHP Plugin_Upgrader::delete_old_plugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Plugin_Upgrader的用法示例。


在下文中一共展示了Plugin_Upgrader::delete_old_plugin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: trashExtension

 public static function trashExtension()
 {
     ob_start();
     $slug = $_POST['slug'];
     include_once ABSPATH . '/wp-admin/includes/plugin.php';
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         deactivate_plugins($slug);
     }
     if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
         include_once ABSPATH . '/wp-admin/includes/screen.php';
     }
     include_once ABSPATH . '/wp-admin/includes/file.php';
     include_once ABSPATH . '/wp-admin/includes/template.php';
     include_once ABSPATH . '/wp-admin/includes/misc.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
     include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
     MainWP_Utility::getWPFilesystem();
     /** @global WP_Filesystem_Base $wp_filesystem */
     global $wp_filesystem;
     if (empty($wp_filesystem)) {
         $wp_filesystem = new WP_Filesystem_Direct(null);
     }
     $pluginUpgrader = new Plugin_Upgrader();
     $thePlugin = get_plugin_data($slug);
     if ($thePlugin != null && $thePlugin != '') {
         $pluginUpgrader->delete_old_plugin(null, null, null, array('plugin' => $slug));
     }
     ob_end_clean();
     die(json_encode(array('result' => 'SUCCESS')));
 }
開發者ID:jexmex,項目名稱:mainwp,代碼行數:32,代碼來源:page-mainwp-extensions.php

示例2: explode

 function plugin_action()
 {
     //Read form data
     $action = $_POST['action'];
     $plugins = explode('||', $_POST['plugin']);
     if ('activate' === $action) {
         include_once ABSPATH . '/wp-admin/includes/plugin.php';
         foreach ($plugins as $idx => $plugin) {
             if ($plugin !== $this->plugin_slug) {
                 $thePlugin = get_plugin_data($plugin);
                 if (null !== $thePlugin && '' !== $thePlugin) {
                     activate_plugin($plugin);
                 }
             }
         }
     } else {
         if ('deactivate' === $action) {
             include_once ABSPATH . '/wp-admin/includes/plugin.php';
             foreach ($plugins as $idx => $plugin) {
                 if ($plugin !== $this->plugin_slug) {
                     $thePlugin = get_plugin_data($plugin);
                     if (null !== $thePlugin && '' !== $thePlugin) {
                         deactivate_plugins($plugin);
                     }
                 }
             }
         } else {
             if ('delete' === $action) {
                 include_once ABSPATH . '/wp-admin/includes/plugin.php';
                 //            if (file_exists(ABSPATH . '/wp-admin/includes/deprecated.php')) include_once(ABSPATH . '/wp-admin/includes/deprecated.php');
                 if (file_exists(ABSPATH . '/wp-admin/includes/screen.php')) {
                     include_once ABSPATH . '/wp-admin/includes/screen.php';
                 }
                 include_once ABSPATH . '/wp-admin/includes/file.php';
                 include_once ABSPATH . '/wp-admin/includes/template.php';
                 include_once ABSPATH . '/wp-admin/includes/misc.php';
                 include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
                 include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
                 include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
                 $wp_filesystem = $this->getWPFilesystem();
                 if (null === $wp_filesystem) {
                     $wp_filesystem = new WP_Filesystem_Direct(null);
                 }
                 $pluginUpgrader = new Plugin_Upgrader();
                 $all_plugins = get_plugins();
                 foreach ($plugins as $idx => $plugin) {
                     if ($plugin !== $this->plugin_slug) {
                         if (isset($all_plugins[$plugin])) {
                             $tmp['plugin'] = $plugin;
                             if (true === $pluginUpgrader->delete_old_plugin(null, null, null, $tmp)) {
                                 $args = array('action' => 'delete', 'Name' => $all_plugins[$plugin]['Name']);
                                 do_action('mainwp_child_plugin_action', $args);
                             }
                         }
                     }
                 }
             } else {
                 $information['status'] = 'FAIL';
             }
         }
     }
     if (!isset($information['status'])) {
         $information['status'] = 'SUCCESS';
     }
     $information['sync'] = $this->getSiteStats(array(), false);
     MainWP_Helper::write($information);
 }
開發者ID:jexmex,項目名稱:mainwp-child,代碼行數:67,代碼來源:class-mainwp-child.php


注:本文中的Plugin_Upgrader::delete_old_plugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。