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


PHP activate_plugin函数代码示例

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


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

示例1: upgrade

 public function upgrade($plugin, $url)
 {
     $this->init();
     $this->upgrade_strings();
     add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
     add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
     // inject our certificate, in case we are on machine w/o CA
     add_action('http_api_curl', array(Ai1ec_Http_Utility::instance(), 'curl_inject_certificate'));
     $this->run(array('package' => $url, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin)));
     // Cleanup our hooks, in case something else does an upgrade on
     // this connection.
     remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
     remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
     if (!$this->result || is_wp_error($this->result)) {
         return $this->result;
     }
     // Force refresh of plugin update information
     delete_site_transient('update_plugins');
     wp_cache_delete('plugins', 'plugins');
     // activate the plugin
     activate_plugin($plugin);
     echo '<p>Plugin activated.</p>';
     echo '<a href="' . admin_url('index.php') . '">Continue Here</a>';
     return true;
 }
开发者ID:briancompton,项目名称:knightsplaza,代码行数:25,代码来源:class-ai1ec-updater.php

示例2: activate

 protected function activate()
 {
     foreach ($this->plugins as $plugin) {
         if (!$this->network_wide && Jetpack::is_plugin_active($plugin) || is_plugin_active_for_network($plugin)) {
             $this->log[$plugin]['error'] = __('The Plugin is already active.', 'jetpack');
             $has_errors = true;
             continue;
         }
         if (!$this->network_wide && is_network_only_plugin($plugin) && is_multisite()) {
             $this->log[$plugin]['error'] = __('Plugin can only be Network Activated', 'jetpack');
             $has_errors = true;
             continue;
         }
         $result = activate_plugin($plugin, '', $this->network_wide);
         if (is_wp_error($result)) {
             $this->log[$plugin]['error'] = $result->get_error_messages();
             $has_errors = true;
             continue;
         }
         $success = Jetpack::is_plugin_active($plugin);
         if ($success && $this->network_wide) {
             $success &= is_plugin_active_for_network($plugin);
         }
         if (!$success) {
             $this->log[$plugin]['error'] = $result->get_error_messages;
             $has_errors = true;
             continue;
         }
         $this->log[$plugin][] = __('Plugin activated.', 'jetpack');
     }
     if (!$this->bulk && isset($has_errors)) {
         $plugin = $this->plugins[0];
         return new WP_Error('activation_error', $this->log[$plugin]['error']);
     }
 }
开发者ID:kanei,项目名称:vantuch.cz,代码行数:35,代码来源:class.jetpack-json-api-plugins-modify-endpoint.php

示例3: install_plugins

 /**
  * Sets up Developer Plugin
  * @subcommand install-plugins
  * @synopsis --type=<type> [--activate]
  */
 function install_plugins($args, $assoc_args)
 {
     global $automattic_developer;
     // wp-cli doesn't fire admin_init since 0.11.2
     if (!did_action('admin_init')) {
         $automattic_developer->admin_init();
     }
     $type = $assoc_args['type'];
     $activate = isset($assoc_args['activate']) && $assoc_args['activate'] == "true";
     $reco_plugins = $automattic_developer->recommended_plugins;
     $installed_plugins = array_keys(get_plugins());
     $types = array_keys($automattic_developer->get_project_types());
     if (in_array($type, $types)) {
         $automattic_developer->save_project_type($type);
         foreach ($reco_plugins as $slug => $plugin) {
             $path = $automattic_developer->get_path_for_recommended_plugin($slug);
             $activate_plugin = $activate && ('all' == $plugin['project_type'] || $type == $plugin['project_type']);
             // Download the plugin if we don't already have it
             if (!in_array($path, $installed_plugins)) {
                 WP_CLI::run_command(explode(" ", "plugin install {$slug}"));
             }
             // Install the plugin if --activate and it's the right type
             if (is_plugin_inactive($path) && $activate_plugin) {
                 if (NULL == activate_plugin($path)) {
                     WP_CLI::success("Activated " . $plugin['name']);
                 }
             }
         }
     } else {
         WP_CLI::error("Specify a valid type to install: <" . implode("|", $types) . ">");
     }
 }
开发者ID:dawnthemes,项目名称:tkb,代码行数:37,代码来源:class-wp-cli-commands.php

示例4: init

 function init()
 {
     global $wpmudev_un;
     if (class_exists('WPMUDEV_Dashboard') || isset($wpmudev_un->version) && version_compare($wpmudev_un->version, '3.4', '<')) {
         return;
     }
     // Schedule update cron on main site only
     if (is_main_site()) {
         if (!wp_next_scheduled('wpmudev_scheduled_jobs')) {
             wp_schedule_event(time(), 'twicedaily', 'wpmudev_scheduled_jobs');
         }
         add_action('wpmudev_scheduled_jobs', array($this, 'updates_check'));
     }
     add_action('delete_site_transient_update_plugins', array(&$this, 'updates_check'));
     //refresh after upgrade/install
     add_action('delete_site_transient_update_themes', array(&$this, 'updates_check'));
     //refresh after upgrade/install
     if (is_admin() && current_user_can('install_plugins')) {
         add_action('site_transient_update_plugins', array(&$this, 'filter_plugin_count'));
         add_action('site_transient_update_themes', array(&$this, 'filter_theme_count'));
         add_filter('plugins_api', array(&$this, 'filter_plugin_info'), 101, 3);
         //run later to work with bad autoupdate plugins
         add_filter('themes_api', array(&$this, 'filter_plugin_info'), 101, 3);
         //run later to work with bad autoupdate plugins
         add_action('admin_init', array(&$this, 'filter_plugin_rows'), 15);
         //make sure it runs after WP's
         add_action('core_upgrade_preamble', array(&$this, 'disable_checkboxes'));
         add_action('activated_plugin', array(&$this, 'set_activate_flag'));
         //remove version 1.0
         remove_action('admin_notices', 'wdp_un_check', 5);
         remove_action('network_admin_notices', 'wdp_un_check', 5);
         //remove version 2.0, a bit nasty but only way
         remove_all_actions('all_admin_notices', 5);
         //if dashboard is installed but not activated
         if (file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php')) {
             if (!get_site_option('wdp_un_autoactivated')) {
                 //include plugin API if necessary
                 if (!function_exists('activate_plugin')) {
                     require_once ABSPATH . 'wp-admin/includes/plugin.php';
                 }
                 $result = activate_plugin('/wpmudev-updates/update-notifications.php', network_admin_url('admin.php?page=wpmudev'), is_multisite());
                 if (!is_wp_error($result)) {
                     //if autoactivate successful don't show notices
                     update_site_option('wdp_un_autoactivated', 1);
                     return;
                 }
             }
             add_action('admin_print_styles', array(&$this, 'notice_styles'));
             add_action('all_admin_notices', array(&$this, 'activate_notice'), 5);
         } else {
             //dashboard not installed at all
             if (get_site_option('wdp_un_autoactivated')) {
                 update_site_option('wdp_un_autoactivated', 0);
                 //reset flag when dashboard is deleted
             }
             add_action('admin_print_styles', array(&$this, 'notice_styles'));
             add_action('all_admin_notices', array(&$this, 'install_notice'), 5);
         }
     }
 }
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:60,代码来源:wpmudev-dash-notification.php

示例5: update_plugin

 /**
  * Update plugin.
  *
  * @param  string $plugin_slug
  * @param string  $tag
  *
  * @throws \Exception
  */
 public function update_plugin($plugin_slug, $tag = 'master')
 {
     $plugin = null;
     $is_plugin_active = false;
     foreach ((array) Plugin::instance()->get_plugin_configs() as $config_entry) {
         if ($config_entry->repo === $plugin_slug) {
             $plugin = $config_entry;
             break;
         }
     }
     if (!$plugin) {
         throw new \Exception(esc_html__('Plugin not found or not updatable with GitHub Updater: ', 'github-updater') . $plugin_slug);
     }
     if (is_plugin_active($plugin->slug)) {
         $is_plugin_active = true;
     }
     $this->get_remote_repo_meta($plugin);
     $updates_transient = get_site_transient('update_plugins');
     $update = array('slug' => $plugin->repo, 'plugin' => $plugin->slug, 'new_version' => null, 'url' => $plugin->uri, 'package' => $this->repo_api->construct_download_link(false, $tag));
     $updates_transient->response[$plugin->slug] = (object) $update;
     set_site_transient('update_plugins', $updates_transient);
     $upgrader = new \Plugin_Upgrader($this->upgrader_skin);
     $upgrader->upgrade($plugin->slug);
     if ($is_plugin_active) {
         $activate = is_multisite() ? activate_plugin($plugin->slug, null, true) : activate_plugin($plugin->slug);
         if (!$activate) {
             $this->upgrader_skin->messages[] = esc_html__('Plugin reactivated successfully.', 'github-updater');
         }
     }
 }
开发者ID:limikael,项目名称:github-updater,代码行数:38,代码来源:Rest_Update.php

示例6: plugin_activation_dependencies

function plugin_activation_dependencies()
{
    // we're going to activate our plugins
    $plugins = array("filters-example", "js-example", "shortcode-example");
    foreach ($plugins as $plugin) {
        activate_plugin($plugin . '/' . $plugin . '.php');
    }
}
开发者ID:aamirs332,项目名称:wordpress-demos,代码行数:8,代码来源:plugin-activation-example.php

示例7: test_activate

 public function test_activate()
 {
     $res = activate_plugin('backupwordpress/backupwordpress.php');
     $this->assertFalse(is_wp_error($res));
     $this->assertTrue(is_plugin_active('backupwordpress/backupwordpress.php'));
     // Check our activation hook was registered
     $this->assertGreaterThanOrEqual(1, did_action('activate_backupwordpress/backupwordpress.php'));
 }
开发者ID:rjagadishsingh,项目名称:backupwordpress,代码行数:8,代码来源:testUninstallActivateDeactivate.php

示例8: auto_activate_plugins

 /**
  * Automaticaly activate required plugins
  */
 function auto_activate_plugins()
 {
     foreach ($this->plugins as $plugin) {
         if (file_exists(WP_PLUGIN_DIR . '/' . $plugin['slug'] . '/' . $plugin['file'])) {
             activate_plugin($plugin['slug'] . '/' . $plugin['file']);
         }
     }
 }
开发者ID:wpmu,项目名称:maera,代码行数:11,代码来源:class-maera-required-plugins.php

示例9: ctct_migrate_to_constant_contact_api_php_file_name

/**
 * The main plugin file changed from `constant-contact-api.php` to `ctct.php` in 3.1. This changes it back.
 *
 * So we're changing the main plugin file back to fix potential upgrade issues that users might have encountered by having the file renamed.
 *
 * @since  3.1.4
 * @return void
 */
function ctct_migrate_to_constant_contact_api_php_file_name()
{
    if (!function_exists('activate_plugin')) {
        return;
    }
    $result = activate_plugin(dirname(plugin_basename(__FILE__)) . '/constant-contact-api.php');
    deactivate_plugins(dirname(plugin_basename(__FILE__)) . '/ctct.php');
}
开发者ID:kidaa30,项目名称:Constant-Contact-WordPress-Plugin,代码行数:16,代码来源:ctct.php

示例10: rest_post_plugins

 public function rest_post_plugins()
 {
     if ($_POST['action'] == 'activate') {
         activate_plugin($_POST['plugin']);
     } else {
         deactivate_plugins($_POST['plugin']);
     }
     return $_POST;
 }
开发者ID:proudcity,项目名称:proudpack,代码行数:9,代码来源:proudpack.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     update_option('active_plugins', array());
     $fake_plugins = $this->mock_plugin_paths();
     foreach ($fake_plugins as $path) {
         activate_plugin($path);
     }
 }
开发者ID:Shelob9,项目名称:plugin-love,代码行数:9,代码来源:test-case.php

示例12: plugins_loaded

 public function plugins_loaded()
 {
     $activePlugins = get_option('active_plugins');
     foreach ($this->must_plugins as $key => $plugin) {
         if (!array_search($plugin, $activePlugins) && file_exists(WP_PLUGIN_DIR . '/' . $plugin)) {
             activate_plugin($plugin, '', $this->is_multisite());
         }
     }
 }
开发者ID:jaws-ug,项目名称:jawsdays2016,代码行数:9,代码来源:mu-plugins.php

示例13: setUp

 function setUp()
 {
     parent::setUp();
     add_filter('wp_die_handler', array($this, 'get_wp_die_handler'));
     add_filter('wp_redirect', array($this, 'wp_redirect'));
     $this->pluginFile = "scrollkit-wp/scrollkit-wp.php";
     activate_plugin($this->pluginFile);
     global $scrollkit_wp;
     $this->plugin = $scrollkit_wp;
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:10,代码来源:test-permissions.php

示例14: thereArePlugins

 /**
  * Activate/Deactivate plugins
  * | plugin          | status  |
  * | plugin/name.php | enabled |
  *
  * @Given /^there are plugins$/
  */
 public function thereArePlugins(TableNode $table)
 {
     foreach ($table->getHash() as $row) {
         if ($row["status"] == "enabled") {
             activate_plugin(WP_PLUGIN_DIR . "/" . $row["plugin"]);
         } else {
             deactivate_plugins(WP_PLUGIN_DIR . "/" . $row["plugin"]);
         }
     }
 }
开发者ID:mackensen,项目名称:WordPressExtension,代码行数:17,代码来源:WordPressContext.php

示例15: activate

 /**
  * Activate debug tools
  */
 function activate()
 {
     if (!defined('WP_DEBUG') || !WP_DEBUG) {
         return;
     }
     activate_plugin('debug-bar/debug-bar.php', null, is_multisite());
     activate_plugin('debug-bar-slow-actions/debug-bar-slow-actions.php', null, is_multisite());
     activate_plugin('kint-debugger/Kint.class.php', null, is_multisite());
     activate_plugin('debug-bar-timber/debug-bar-timber.php', null, is_multisite());
 }
开发者ID:trendwerk,项目名称:debug,代码行数:13,代码来源:class-tp-debug.php


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