当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_plugins函数代码示例

本文整理汇总了PHP中delete_plugins函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_plugins函数的具体用法?PHP delete_plugins怎么用?PHP delete_plugins使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_plugins函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wphp_remove_wp_low_profiler

/**
 *
 * @return unknown_type
 */
function wphp_remove_wp_low_profiler()
{
    wphp_log("called: wphp_remove_wp_low_profiler");
    $plugin_list = get_plugins('/wp-low-profiler');
    if (isset($plugin_list['wp-low-profiler.php'])) {
        wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
        $plugins = array('wp-low-profiler/wp-low-profiler.php');
        if (is_plugin_active('wp-low-profiler/wp-low-profiler.php')) {
            wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
            deactivate_plugins($plugins, true);
            // silent deactivate
        }
        wphp_log("Deleting plugin 'WP low Profiler'...");
        delete_plugins($plugins, '');
    } else {
        wphp_log("The 'WP low Profiler' plugin does not exist.");
    }
}
开发者ID:nikolaskarica,项目名称:plastika-magazine,代码行数:22,代码来源:upgrade.php

示例2: delete

 protected function delete()
 {
     foreach ($this->plugins as $plugin) {
         if (Jetpack::is_plugin_active($plugin)) {
             $error = $this->log[$plugin][] = 'You cannot delete a plugin while it is active on the main site.';
             continue;
         }
         $result = delete_plugins(array($plugin));
         if (is_wp_error($result)) {
             $error = $this->log[$plugin][] = $result->get_error_message();
         } else {
             $this->log[$plugin][] = 'Plugin deleted';
         }
     }
     if (!$this->bulk && isset($error)) {
         return new WP_Error('delete_plugin_error', $error, 400);
     }
     return true;
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:19,代码来源:class.jetpack-json-api-plugins-delete-endpoint.php

示例3: do_activate

 /**
  * Activate handle
  */
 function do_activate()
 {
     // get current version of plugin
     $latest_version = IG_Pb_Helper_Functions::get_plugin_info(IG_PB_FILE, 'Version');
     // get previous version of plugin
     $old_version = get_transient('ig_pb_version');
     // compare version
     if (!$old_version || version_compare($old_version, $latest_version, '<')) {
         // update plugin version
         set_transient('ig_pb_version', $latest_version);
         // remove cache folder if plugin is installed before
         if ($old_version) {
             IG_Pb_Utils_Common::remove_cache_folder();
         }
     }
     // remove free shortcode directory
     if (is_dir(WP_PLUGIN_DIR . '/ig-shortcodes-free')) {
         delete_plugins(array('ig-shortcodes-free/main.php'));
     }
 }
开发者ID:WaitButWhy,项目名称:www,代码行数:23,代码来源:plugin.php

示例4: updateAddon

 /**
  * @usage Single click add-on update
  */
 function updateAddon()
 {
     if (isset($_POST['updateurl']) && current_user_can(WPDM_ADMIN_CAP)) {
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
         $upgrader = new \Plugin_Upgrader(new \Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
         $downloadlink = $_POST['updateurl'] . '&preact=login&user=' . get_option('__wpdm_suname') . '&pass=' . get_option('__wpdm_supass') . '&__wpdmnocache=' . uniqid();
         $update = new \stdClass();
         $plugininfo = wpdm_plugin_data($_POST['plugin']);
         deactivate_plugins($plugininfo['plugin_index_file'], true);
         delete_plugins(array($plugininfo['plugin_index_file']));
         $upgrader->install($downloadlink);
         if (file_exists(dirname(WPDM_BASE_DIR) . '/' . $plugininfo['plugin_index_file'])) {
             activate_plugin($plugininfo['plugin_index_file']);
         }
         die("Updated Successfully");
     } else {
         die("Only site admin is authorized to install add-on");
     }
 }
开发者ID:WildCodeSchool,项目名称:projet-maison_ados_dreux,代码行数:23,代码来源:class.WordPressDownloadManagerAdmin.php

示例5: wp_ajax_delete_plugin

/**
 * Ajax handler for deleting a plugin.
 *
 * @since 4.6.0
 *
 * @see delete_plugins()
 */
function wp_ajax_delete_plugin()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug']) || empty($_POST['plugin'])) {
        wp_send_json_error(array('slug' => '', 'errorCode' => 'no_plugin_specified', 'errorMessage' => __('No plugin specified.')));
    }
    $plugin = plugin_basename(sanitize_text_field(wp_unslash($_POST['plugin'])));
    $status = array('delete' => 'plugin', 'slug' => sanitize_key(wp_unslash($_POST['slug'])));
    if (!current_user_can('delete_plugins') || 0 !== validate_file($plugin)) {
        $status['errorMessage'] = __('Sorry, you are not allowed to delete plugins for this site.');
        wp_send_json_error($status);
    }
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    $status['plugin'] = $plugin;
    $status['pluginName'] = $plugin_data['Name'];
    if (is_plugin_active($plugin)) {
        $status['errorMessage'] = __('You cannot delete a plugin while it is active on the main site.');
        wp_send_json_error($status);
    }
    // Check filesystem credentials. `delete_plugins()` will bail otherwise.
    $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins');
    ob_start();
    $credentials = request_filesystem_credentials($url);
    ob_end_clean();
    if (false === $credentials || !WP_Filesystem($credentials)) {
        global $wp_filesystem;
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['errorMessage'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if ($wp_filesystem instanceof WP_Filesystem_Base && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['errorMessage'] = esc_html($wp_filesystem->errors->get_error_message());
        }
        wp_send_json_error($status);
    }
    $result = delete_plugins(array($plugin));
    if (is_wp_error($result)) {
        $status['errorMessage'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (false === $result) {
        $status['errorMessage'] = __('Plugin could not be deleted.');
        wp_send_json_error($status);
    }
    wp_send_json_success($status);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:51,代码来源:ajax-actions.php

示例6: delete_default_content

 function delete_default_content()
 {
     delete_theme('twentysixteen');
     delete_theme('twentyfifteen');
     delete_theme('twentyfourteen');
     delete_theme('twentythirteen');
     delete_theme('twentytwelve');
     delete_theme('twentyeleven');
     delete_theme('twentyten');
     delete_plugins(array('hello.php', 'akismet/akismet.php'));
 }
开发者ID:pravdomil,项目名称:WP-Quick-Install,代码行数:11,代码来源:wp-quick-install.php

示例7: plugin_delete

 /**
  *
  * @TODO document
  *
  */
 function plugin_delete($type, $file, $path, $uploader, $checked)
 {
     $this->wp_libs();
     if (!$checked) {
         $this->check_creds('extend', WP_PLUGIN_DIR);
     }
     global $wp_filesystem;
     delete_plugins(array(ltrim($file, '/')));
     $message = __('Plugin Deleted.', 'pagelines');
     $text = '&extend_text=plugin_delete#your_plugins';
     $this->page_reload(PL_ADMIN_STORE_SLUG . $text, null, $message);
 }
开发者ID:climo,项目名称:PageLines-Framework,代码行数:17,代码来源:class.extend.actions.php

示例8: delete_plugin_action

 /**
  * Delete plugin action.
  *
  * @return  void
  */
 protected function delete_plugin_action()
 {
     // Get plugin index
     $index = isset($_GET['plugin']) ? $_GET['plugin'] : null;
     if (is_null($index)) {
         throw new Exception(__('Missing plugin to delete.', 'ferado'));
     }
     // Get details about upload directory
     $path = wp_upload_dir();
     $path = $path['basedir'] . '/' . $this->id . '/installed_plugins.json';
     if (!$this->wp_filesystem->exists($path)) {
         return;
     }
     // Load the list of demo assets to be downloaded
     $installed_plugins = array_values(json_decode($this->wp_filesystem->get_contents($path), true));
     if (isset($installed_plugins[$index])) {
         // Find plugin
         if ($plugin = $this->_get_plugin_path($installed_plugins[$index]['name'])) {
             $result = delete_plugins(array($plugin));
             if (is_wp_error($result)) {
                 throw new Exception($result->get_error_message());
             }
         }
     }
     if ($index + 1 == count($installed_plugins)) {
         // Delete sample data installation results
         $this->wp_filesystem->delete($path);
     }
 }
开发者ID:JaneJieYing,项目名称:HiFridays,代码行数:34,代码来源:sample-data-installer.php

示例9: wp_ajax_delete_plugin

/**
 * AJAX handler for deleting a plugin.
 *
 * @since 4.X.0
 */
function wp_ajax_delete_plugin()
{
    check_ajax_referer('updates');
    if (empty($_POST['slug']) || empty($_POST['plugin'])) {
        wp_send_json_error(array('errorCode' => 'no_plugin_specified'));
    }
    $plugin = filter_var(wp_unslash($_POST['plugin']), FILTER_SANITIZE_STRING);
    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    $status = array('delete' => 'plugin', 'slug' => sanitize_key($_POST['slug']), 'plugin' => $plugin, 'pluginName' => $plugin_data['Name']);
    if (!current_user_can('delete_plugins')) {
        $status['error'] = __('You do not have sufficient permissions to delete plugins for this site.');
        wp_send_json_error($status);
    }
    if (!is_plugin_inactive($plugin)) {
        $status['error'] = __('You cannot delete a plugin while it is active on the main site.');
        wp_send_json_error($status);
    }
    // Check filesystem credentials. `delete_plugins()` will bail otherwise.
    ob_start();
    $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&checked[]=' . $plugin, 'bulk-plugins');
    if (false === ($credentials = request_filesystem_credentials($url)) || !WP_Filesystem($credentials)) {
        global $wp_filesystem;
        ob_end_clean();
        $status['errorCode'] = 'unable_to_connect_to_filesystem';
        $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
        // Pass through the error from WP_Filesystem if one was raised.
        if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
            $status['error'] = $wp_filesystem->errors->get_error_message();
        }
        wp_send_json_error($status);
    }
    $result = delete_plugins(array($plugin));
    if (is_wp_error($result)) {
        $status['error'] = $result->get_error_message();
        wp_send_json_error($status);
    } elseif (false === $result) {
        $status['error'] = __('Plugin could not be deleted.');
        wp_send_json_error($status);
    }
    wp_send_json_success($status);
}
开发者ID:afragen,项目名称:shiny-updates,代码行数:46,代码来源:ajax-actions.php

示例10: download_plugin_ajax_handler

 public function download_plugin_ajax_handler()
 {
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
     if (isset($_POST['data'])) {
         $data = json_decode(base64_decode($_POST['data']), true);
     }
     $ret = false;
     $plugin_id = false;
     $message = '';
     //validate subscription
     $site_key = $this->get_repository_site_key($data['repository_id']);
     $subscription_data = $this->fetch_subscription_data($data['repository_id'], $site_key, self::SITE_KEY_VALIDATION_SOURCE_DOWNLOAD_REPORT);
     if ($subscription_data && !is_wp_error($subscription_data) && $this->repository_has_valid_subscription($data['repository_id'])) {
         if ($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])) {
             $upgrader_skins = new Installer_Upgrader_Skins();
             //use our custom (mute) Skin
             $upgrader = new Plugin_Upgrader($upgrader_skins);
             remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
             $plugins = get_plugins();
             //upgrade or install?
             foreach ($plugins as $id => $plugin) {
                 $wp_plugin_slug = dirname($id);
                 $is_embedded = $this->plugin_is_embedded_version(preg_replace('/ Embedded$/', '', $plugin['Name']), preg_replace('/-embedded$/', '', $wp_plugin_slug));
                 if ($wp_plugin_slug == $data['slug'] || $is_embedded && preg_replace('/-embedded$/', '', $wp_plugin_slug) == $data['slug']) {
                     $plugin_id = $id;
                     break;
                 }
             }
             if ($plugin_id && empty($is_embedded)) {
                 //upgrade
                 $response['upgrade'] = 1;
                 $plugin_is_active = is_plugin_active($plugin_id);
                 $ret = $upgrader->upgrade($plugin_id);
                 if (!$ret && !empty($upgrader->skin->installer_error)) {
                     if (is_wp_error($upgrader->skin->installer_error)) {
                         $message = $upgrader->skin->installer_error->get_error_message() . ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
                     }
                 }
                 if ($plugin_is_active) {
                     //prevent redirects
                     add_filter('wp_redirect', '__return_false');
                     activate_plugin($plugin_id);
                 }
             } else {
                 //install
                 if ($is_embedded) {
                     delete_plugins(array($plugin_id));
                 }
                 $response['install'] = 1;
                 $ret = $upgrader->install($data['url']);
                 if (!$ret && !empty($upgrader->skin->installer_error)) {
                     if (is_wp_error($upgrader->skin->installer_error)) {
                         $message = $upgrader->skin->installer_error->get_error_message() . ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
                     }
                 }
             }
             $plugins = get_plugins();
             //read again
             if ($ret && !empty($_POST['activate'])) {
                 foreach ($plugins as $id => $plugin) {
                     $wp_plugin_slug = dirname($id);
                     if ($wp_plugin_slug == $data['slug']) {
                         $plugin_version = $plugin['Version'];
                         $plugin_id = $id;
                         break;
                     }
                 }
             }
         }
     } else {
         //subscription not valid
         $ret = false;
         $message = __('Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer');
     }
     $response['version'] = isset($plugin_version) ? $plugin_version : 0;
     $response['plugin_id'] = $plugin_id;
     $response['nonce'] = wp_create_nonce('activate_' . $plugin_id);
     $response['success'] = $ret;
     $response['message'] = $message;
     echo json_encode($response);
     exit;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:83,代码来源:installer.class.php

示例11: nebula_initialization_delete_plugins

function nebula_initialization_delete_plugins()
{
    //Remove Hello Dolly plugin if it exists
    if (file_exists(WP_PLUGIN_DIR . '/hello.php')) {
        delete_plugins(array('hello.php'));
    }
}
开发者ID:CloouCom,项目名称:Nebula,代码行数:7,代码来源:nebula_automation.php

示例12: do_uninstall

 function do_uninstall()
 {
     if (!$this->current_user_can_uninstall()) {
         wp_die(__('You do not have sufficient permissions to delete plugins on this site.', 'seo-ultimate'));
     }
     echo "<script type='text/javascript'>jQuery('#adminmenu .current').hide(); jQuery('#toplevel_page_seo').hide();</script>";
     echo "<div class=\"wrap\">\n";
     echo "\n<h2>" . __('Uninstall SEO Ultimate', 'seo-ultimate') . "</h2>\n";
     //Delete settings and do miscellaneous clean up
     $this->plugin->uninstall();
     $this->print_mini_message('success', __('Deleted settings.', 'seo-ultimate'));
     //Deactivate the plugin
     deactivate_plugins(array($this->plugin->plugin_basename), true);
     //Attempt to delete the plugin's files and output result
     if (is_wp_error($error = delete_plugins(array($this->plugin->plugin_basename)))) {
         $this->print_mini_message('error', __('An error occurred while deleting files.', 'seo-ultimate') . '<br />' . $error->get_error_message());
     } else {
         $this->print_mini_message('success', __('Deleted files.', 'seo-ultimate'));
         $this->print_mini_message('success', __('Uninstallation complete. Thanks for trying SEO Ultimate.', 'seo-ultimate'));
     }
     echo "\n</div>\n";
     return true;
 }
开发者ID:quinntron,项目名称:greendot,代码行数:23,代码来源:uninstall.php

示例13: activate_plugins

    $result = activate_plugins($plugin_ID);
    if (!is_wp_error($result)) {
        if ($update !== False) {
            $update .= __(' and Activated', 'amazon-link');
        } else {
            $update = __('Plugin ' . $installed_plugins[$plugin_ID]['Name'] . ' - has been Activated', 'amazon-link');
        }
        $installed_plugins[$plugin_ID]['Activated'] = True;
    } else {
        $error = $result->get_error_message();
    }
    // **********************************************************
    // Uninstall the selected plugin
} else {
    if ($action == __('Uninstall', 'amazon-link')) {
        $result = delete_plugins((array) $plugin_ID);
        if (!is_wp_error($result)) {
            $update = __('Plugin ' . $installed_plugins[$plugin_ID]['Name'] . ' - has been Uninstalled', 'amazon-link');
            unset($installed_plugins[$plugin_ID]);
            $action = __('Deactivate', 'amazon-link');
        } else {
            $error = $result->get_error_message();
        }
    }
}
// **********************************************************
// Deactivate the selected plugin
if ($action == __('Deactivate', 'amazon-link')) {
    $result = deactivate_plugins($plugin_ID);
    if (!is_wp_error($result)) {
        if ($update !== False) {
开发者ID:uniquegel,项目名称:Feminnova,代码行数:31,代码来源:showExtras.php

示例14: wp_install_defaults

function wp_install_defaults($user_id)
{
    global $wpdb, $wp_rewrite, $current_site, $table_prefix;
    // Let's customize our default WordPress options
    // @link http://codex.wordpress.org/Option_Reference
    // My preferred permalink structure
    update_option('permalink_structure', '/%category%/%postname%');
    // Changed from 'posts' to 'page'
    update_option('show_on_front', 'page');
    // Make our home page be the front page
    update_option('page_on_front', 1);
    // Turned this on so you can create content from apps
    update_option('enable_app', 1);
    update_option('enable_xmlrpc', 1);
    // Disable comments by default
    update_option('default_comment_status', 'closed');
    // Hide the Toolbar on the front-end
    show_admin_bar(false);
    // Make our theme the default one
    switch_theme('orbit', 'orbit');
    // Remove Hello Dolly and Akismet plugins
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    if (file_exists(WP_PLUGIN_DIR . '/hello.php') || file_exists(WP_PLUGIN_DIR . 'akismet/akismet.php')) {
        delete_plugins(array('hello.php', 'akismet/akismet.php'));
    }
    // Default category (we rename it from 'Uncategorized' to 'General')
    $cat_name = __('General');
    // translators: Default category slug
    $cat_slug = sanitize_title(_x('General', 'Default category slug'));
    if (global_terms_enabled()) {
        $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
        if ($cat_id == null) {
            $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
            $cat_id = $wpdb->insert_id;
        }
        update_option('default_category', $cat_id);
    } else {
        $cat_id = 1;
    }
    $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
    $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
    $cat_tt_id = $wpdb->insert_id;
    // Default link category (commented out)
    /*
    $cat_name = __('Blogroll');
    // translators: Default link category slug
    $cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
    
    if ( global_terms_enabled() ) {
    	$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
    	if ( $blogroll_id == null ) {
    		$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
    		$blogroll_id = $wpdb->insert_id;
    	}
    	update_option('default_link_category', $blogroll_id);
    } else {
    	$blogroll_id = 2;
    }
    
    $wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
    $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
    $blogroll_tt_id = $wpdb->insert_id;
    
    // Now drop in some default links
    $default_links = array();
    $default_links[] = array(	'link_url' => 'http://codex.wordpress.org/',
    							'link_name' => 'Documentation',
    							'link_rss' => '',
    							'link_notes' => '');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/news/',
    							'link_name' => 'WordPress Blog',
    							'link_rss' => 'http://wordpress.org/news/feed/',
    							'link_notes' => '');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/ideas/',
    							'link_name' => 'Suggest Ideas',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/support/',
    							'link_name' => 'Support Forum',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/plugins/',
    							'link_name' => 'Plugins',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://wordpress.org/extend/themes/',
    							'link_name' => 'Themes',
    							'link_rss' => '',
    							'link_notes' =>'');
    
    $default_links[] = array(	'link_url' => 'http://planet.wordpress.org/',
    							'link_name' => 'WordPress Planet',
    							'link_rss' => '',
    							'link_notes' =>'');
//.........这里部分代码省略.........
开发者ID:ryanurban,项目名称:Orbit,代码行数:101,代码来源:install.php

示例15: execute

 /**
  * Manipulate addon.
  *
  * @param   string  $addon   Addon to manipulate.
  * @param   string  $action  Action to execute.
  *
  * @return  array
  */
 protected static function execute($addon, $action)
 {
     // Check capabilities
     foreach (self::$actions as $do => $capability) {
         if ($action == $do && !empty($capability) && !current_user_can($capability)) {
             throw new Exception(__('You do not have sufficient permissions to either add or delete plugins for this site.'));
         }
     }
     // Check if addon should be updated or removed
     if ('update' == $action || 'uninstall' == $action) {
         // Get plugin slug
         $plugin = self::check($addon, false);
         if (empty($plugin)) {
             throw new Exception(__('update' == $action ? 'Cannot detect plugin to be updated.' : 'Cannot detect plugin to be removed.', IG_LIBRARY_TEXTDOMAIN));
         }
     }
     // Check if addon should be removed
     if ('uninstall' == $action) {
         $result = delete_plugins(array($plugin));
         // Verify uninstallation result
         if (is_wp_error($result)) {
             throw new Exception($result->get_error_message());
         }
     } else {
         // Verify authentication data
         $authentication = (bool) $_GET['authentication'];
         $username = isset($_POST['username']) ? $_POST['username'] : '';
         $password = isset($_POST['password']) ? $_POST['password'] : '';
         if ($authentication && (empty($username) || empty($password))) {
             // Check if user has customer account saved
             $customer_account = get_option('ig_customer_account', null);
             if (is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password'])) {
                 $username = $customer_account['username'];
                 $password = $customer_account['password'];
             } else {
                 throw new Exception(null);
             }
         }
         // Try to authenticate or download addon installation package
         try {
             $package = self::download($addon, $authentication, $username, $password, 'authenticate' == $action);
         } catch (Exception $e) {
             throw $e;
         }
         // Get WordPress's WordPress Filesystem Abstraction object
         $wp_filesystem = IG_Init_File_System::get_instance();
         // Check if addon should be installed or updated
         if ('authenticate' != $action) {
             // Verify core and add-on compatibility
             if (isset($_GET['core']) && ($core = self::get($_GET['core']))) {
                 // Extract downloaded add-on package
                 $tmp_dir = substr($package, 0, -4);
                 $result = unzip_file($package, $tmp_dir);
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
                 // Find constant definition file
                 if (@is_file("{$tmp_dir}/defines.php")) {
                     include "{$tmp_dir}/defines.php";
                 } elseif (count($defines = glob("{$tmp_dir}/*/defines.php"))) {
                     include current($defines);
                 }
                 // Get minimum core version required for this add-on
                 if (defined($core_version = strtoupper($addon) . '_CORE_VERSION')) {
                     eval('$core_version = ' . $core_version . ';');
                 }
                 if ($core_version && version_compare($core_version, $core['Version'], '>')) {
                     // Delete downloaded add-on package and clean-up temporary directory
                     $wp_filesystem->delete($package);
                     $wp_filesystem->delete($tmp_dir, true);
                     // Skip add-on installation
                     throw new Exception(sprintf(__("Cannot install %1\$s v%2\$s.\nThis version requires %3\$s v%4\$s while you are using %5\$s v%6\$s.", IG_LIBRARY_TEXTDOMAIN), $core['Addons'][$addon]->name, $core['Addons'][$addon]->version, $core['Name'], $core_version, $core['Name'], $core['Version']));
                 }
                 // Verification done, clean-up temporary directory
                 $wp_filesystem->delete($tmp_dir, true);
             }
             // Init WordPress Plugin Upgrader
             class_exists('Plugin_Upgrader') || (include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
             function_exists('screen_icon') || (include_once ABSPATH . 'wp-admin/includes/screen.php');
             function_exists('show_message') || (include_once ABSPATH . 'wp-admin/includes/misc.php');
             function_exists('get_plugin_data') || (include_once ABSPATH . 'wp-admin/includes/plugin.php');
             // Either install or update add-on
             $upgrader = new Plugin_Upgrader();
             if ('install' == $action) {
                 // Install plugin
                 $result = $upgrader->install($package);
                 // Verify installation result
                 if (is_wp_error($result)) {
                     throw new Exception($result->get_error_message());
                 }
             } else {
                 // Update plugin
//.........这里部分代码省略.........
开发者ID:WaitButWhy,项目名称:www,代码行数:101,代码来源:addons.php


注:本文中的delete_plugins函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。