本文整理汇总了PHP中activate_plugins函数的典型用法代码示例。如果您正苦于以下问题:PHP activate_plugins函数的具体用法?PHP activate_plugins怎么用?PHP activate_plugins使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了activate_plugins函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate_addon
/**
* Activate add-on.
*
* @access public
* @return void
*/
public function activate_addon()
{
//make sure we activated an add-on
if (empty($_POST['gmw_action']) || $_POST['gmw_action'] != 'activate_addon') {
return;
}
$active_addon = $_POST['gmw_addon_activated'];
$plugin_basename = $_POST['gmw_addon_basename'];
//look for nonce
if (empty($_POST[$active_addon . '_activate_addon_nonce'])) {
return;
}
//varify nonce
if (!wp_verify_nonce($_POST[$active_addon . '_activate_addon_nonce'], $active_addon . '_activate_addon_nonce')) {
return;
}
unset($this->addons[$active_addon]);
$this->addons[$active_addon] = 'active';
update_option('gmw_addons', $this->addons);
$plugins = get_plugins();
//activate the addon
if (array_key_exists($plugin_basename, $plugins) && is_plugin_inactive($plugin_basename)) {
activate_plugins($plugin_basename);
}
//reload the page to prevent resubmission
wp_safe_redirect(admin_url('admin.php?page=gmw-add-ons&gmw_notice=addon_activated&gmw_notice_status=updated'));
exit;
}
示例2: vimeography_check_if_just_updated
/**
* If Vimeography was just updated, make sure all the Vimeography plugins are activated.
*
* @return void
*/
public function vimeography_check_if_just_updated()
{
$plugins = get_option('vimeography_reactivate_plugins');
if ($plugins) {
activate_plugins($plugins);
delete_option('vimeography_reactivate_plugins');
}
}
示例3: testActivationAndDeactivation
public function testActivationAndDeactivation()
{
global $wp_rewrite;
include_once $this->getWpRoot() . '/wp-admin/includes/plugin.php';
if (!is_plugin_active('wprsrv/wprsrv.php')) {
activate_plugins('wprsrv/wprsrv.php');
}
deactivate_plugins('wprsrv/wprsrv.php');
activate_plugins('wprsrv/wprsrv.php');
$this->assertTrue(is_plugin_active('wprsrv/wprsrv.php'));
}
示例4: setUpBeforeClass
public static function setUpBeforeClass()
{
wp_set_current_user(1, 'Alexander Gruzov');
if (!is_plugin_active('social-community-popup/social-community-popup.php') || !isset($GLOBALS['social-community-popup'])) {
die("Plugin deactivated. Activate the plugin first before run this test.\n");
}
self::$plugin = $GLOBALS['social-community-popup'];
self::$plugin->set_scp_version('0.7.1');
self::cleanUp();
// Очищаем всю информацию о плагине во время тестирования
deactivate_plugins('social-community-popup/social-community-popup.php');
activate_plugins('social-community-popup/social-community-popup.php');
self::$plugin->set_scp_version('0.1');
}
示例5: execute
public static function execute( $params ) {
// Set shutdown handler
@register_shutdown_function( 'Ai1wm_Import_Done::shutdown' );
// Check multisite.json file
if ( true === is_file( ai1wm_multisite_path( $params ) ) ) {
// Read multisite.json file
$handle = fopen( ai1wm_multisite_path( $params ), 'r' );
if ( $handle === false ) {
throw new Ai1wm_Import_Exception( __( 'Unable to read multisite.json file', AI1WM_PLUGIN_NAME ) );
}
// Parse multisite.json file
$multisite = fread( $handle, filesize( ai1wm_multisite_path( $params ) ) );
$multisite = json_decode( $multisite );
// Close handle
fclose( $handle );
// Activate plugins
if ( isset( $multisite->Plugins ) && ( $active_sitewide_plugins = $multisite->Plugins ) ) {
activate_plugins( $active_sitewide_plugins, null, is_multisite() );
}
}
// Set the new MS files rewriting
if ( get_site_option( AI1WM_MS_FILES_REWRITING ) ) {
update_site_option( AI1WM_MS_FILES_REWRITING, 0 );
}
// Open the archive file for reading
$archive = new Ai1wm_Extractor( ai1wm_archive_path( $params ) );
// Unpack must-use plugins
$archive->extract_by_files_array( WP_CONTENT_DIR, array( AI1WM_MUPLUGINS_NAME ) );
// Close the archive file
$archive->close();
// Load must-use plugins
foreach ( wp_get_mu_plugins() as $mu_plugin ) {
include_once( $mu_plugin );
}
return $params;
}
示例6: options
/**
* Install options
*
* @param string $stylesheet
*
* @return bool
*/
private function options($stylesheet)
{
$response = wp_remote_get(Admin::demo_site_url(['theme' => urlencode($stylesheet), 'action' => 'get_options']));
if (is_wp_error($response)) {
return false;
}
$json = wp_remote_retrieve_body($response);
$options = json_decode($json, true);
if (!$options) {
return false;
}
if (isset($options['home'])) {
$this->strings[$options['home']] = get_option('home');
}
if (isset($options['admin_email'])) {
$this->strings[$options['admin_email']] = get_option('admin_email');
}
if ($this->strings) {
// Chicken/egg situation means we must replace strings and decode the JSON again
$json = str_replace(array_keys($this->strings), array_values($this->strings), $json);
$options = json_decode($json, true);
}
foreach ($options as $option => $value) {
switch ($option) {
case 'active_plugins':
activate_plugins($value);
update_option('wpem_plugins', $value);
break;
case 'stylesheet':
switch_theme($value);
update_option('wpem_theme', $value);
break;
case 'template':
if ($value !== $options['stylesheet']) {
update_option('wpem_parent_theme', $value);
}
break;
default:
update_option($option, $value);
}
}
return true;
}
示例7: execute
public static function execute($params)
{
// Check multisite.json file
if (true === is_file(ai1wm_multisite_path($params))) {
// Read multisite.json file
$handle = fopen(ai1wm_multisite_path($params), 'r');
if ($handle === false) {
throw new Ai1wm_Import_Exception(__('Unable to read multisite.json file', AI1WM_PLUGIN_NAME));
}
// Parse multisite.json file
$multisite = fread($handle, filesize(ai1wm_multisite_path($params)));
$multisite = json_decode($multisite, true);
// Close handle
fclose($handle);
// Activate plugins
if (isset($multisite['Plugins']) && ($active_sitewide_plugins = $multisite['Plugins'])) {
activate_plugins($active_sitewide_plugins, null, is_multisite(), true);
}
}
// Set progress
Ai1wm_Status::done(sprintf(__('You need to perform two more steps:<br />' . '<strong>1. You must save your permalinks structure twice. <a class="ai1wm-no-underline" href="%s" target="_blank">Permalinks Settings</a></strong> <small>(opens a new window)</small><br />' . '<strong>2. <a class="ai1wm-no-underline" href="https://wordpress.org/support/view/plugin-reviews/all-in-one-wp-migration?rate=5#postform" target="_blank">Optionally, review the plugin</a>.</strong> <small>(opens a new window)</small>', AI1WM_PLUGIN_NAME), admin_url('options-permalink.php#submit')), __('Your data has been imported successfuly!', AI1WM_PLUGIN_NAME));
return $params;
}
示例8: new_blog
function new_blog($blog_id)
{
require_once ABSPATH . 'wp-admin/includes/plugin.php';
global $psts;
$psts_plugins = (array) $psts->get_setting('pp_plugins');
$auto_activate = array();
switch_to_blog($blog_id);
//look for valid plugins with anyone access
foreach ($psts_plugins as $plugin_file => $data) {
if ($data['auto'] && is_numeric($data['level']) && (is_pro_site($blog_id, $data['level']) || $data['level'] == 0) && !is_plugin_active($plugin_file)) {
$auto_activate[] = $plugin_file;
}
}
//if any activate them
if (count($auto_activate)) {
activate_plugins($auto_activate, '', false);
//silently activate any plugins
}
restore_current_blog();
}
示例9: execute
//.........这里部分代码省略.........
if (!isset($config->NoEmailReplace)) {
if (!in_array(sprintf("@%s", $old_domain), $old_values)) {
$old_values[] = sprintf("@%s", $old_domain);
$new_values[] = sprintf("@%s", $new_domain);
}
}
}
}
// Get WordPress Content
if (isset($config->WordPress->Content) && $config->WordPress->Content !== WP_CONTENT_DIR) {
// Add plain WordPress Content
if (!in_array($config->WordPress->Content, $old_values)) {
$old_values[] = $config->WordPress->Content;
$new_values[] = WP_CONTENT_DIR;
}
// Add encoded WordPress Content
if (!in_array(urlencode($config->WordPress->Content), $old_values)) {
$old_values[] = urlencode($config->WordPress->Content);
$new_values[] = urlencode(WP_CONTENT_DIR);
}
// Add escaped WordPress Content
if (!in_array(addslashes(addcslashes($config->WordPress->Content, '\\/')), $old_values)) {
$old_values[] = addslashes(addcslashes($config->WordPress->Content, '\\/'));
$new_values[] = addslashes(addcslashes(WP_CONTENT_DIR, '\\/'));
}
}
// Get URL IP
$url_ip = get_option(AI1WM_URL_IP);
// Get URL adapter
$url_adapter = get_option(AI1WM_URL_ADAPTER);
// Get secret key
$secret_key = get_option(AI1WM_SECRET_KEY);
// Get HTTP user
$auth_user = get_option(AI1WM_AUTH_USER);
// Get HTTP password
$auth_password = get_option(AI1WM_AUTH_PASSWORD);
// Get active ServMask plugins
$active_servmask_plugins = ai1wm_active_servmask_plugins();
$old_prefixes = array();
$new_prefixes = array();
// Set main table prefixes
$old_prefixes[] = ai1wm_servmask_prefix('mainsite');
$new_prefixes[] = ai1wm_table_prefix();
// Set site table prefixes
foreach ($blogs as $blog) {
if (ai1wm_main_site($blog->Old->Id) === false) {
$old_prefixes[] = ai1wm_servmask_prefix($blog->Old->Id);
$new_prefixes[] = ai1wm_table_prefix($blog->New->Id);
}
}
// Set base table prefixes
foreach ($blogs as $blog) {
if (ai1wm_main_site($blog->Old->Id) === true) {
$old_prefixes[] = ai1wm_servmask_prefix('basesite');
$new_prefixes[] = ai1wm_table_prefix($blog->New->Id);
}
}
// Set site table prefixes
foreach ($blogs as $blog) {
if (ai1wm_main_site($blog->Old->Id) === true) {
$old_prefixes[] = ai1wm_servmask_prefix($blog->Old->Id);
$new_prefixes[] = ai1wm_table_prefix($blog->New->Id);
}
}
// Set table prefixes
$old_prefixes[] = ai1wm_servmask_prefix();
$new_prefixes[] = ai1wm_table_prefix();
// Get database client
if (empty($wpdb->use_mysqli)) {
$client = new Ai1wm_Database_Mysql($wpdb);
} else {
$client = new Ai1wm_Database_Mysqli($wpdb);
}
// Set database options
$client->set_old_table_prefixes($old_prefixes)->set_new_table_prefixes($new_prefixes)->set_old_replace_values($old_values)->set_new_replace_values($new_values);
// Flush database
if ($version = $config->Plugin->Version) {
if ($version !== 'develop' && version_compare($version, '4.10', '<')) {
$client->set_include_table_prefixes(array(ai1wm_table_prefix()));
$client->flush();
}
}
// Import database
$client->import(ai1wm_database_path($params));
// Flush WP cache
ai1wm_cache_flush();
// Activate plugins
activate_plugins($active_servmask_plugins, null, is_multisite());
// Set the new URL IP
update_option(AI1WM_URL_IP, $url_ip);
// Set the new URL adapter
update_option(AI1WM_URL_ADAPTER, $url_adapter);
// Set the new secret key value
update_option(AI1WM_SECRET_KEY, $secret_key);
// Set the new HTTP user
update_option(AI1WM_AUTH_USER, $auth_user);
// Set the new HTTP password
update_option(AI1WM_AUTH_PASSWORD, $auth_password);
return $params;
}
示例10: new_blog
function new_blog($blog_id)
{
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$auto_activate = (array) get_site_option('pm_auto_activate_list');
if (count($auto_activate)) {
switch_to_blog($blog_id);
activate_plugins($auto_activate, '', false);
//silently activate any plugins
restore_current_blog();
}
}
示例11: activate
function activate($args)
{
$this->_escape($args);
$username = $args[0];
$password = $args[1];
$plugin_files = $args[2];
if ($password != get_option('wpr_cron')) {
if (!($user = $this->login($username, $password))) {
return $this->error;
}
if (!current_user_can('activate_plugins')) {
return new IXR_Error(401, 'Sorry, you cannot manage plugins on the remote blog.');
}
}
$this->refresh_transient();
$success = activate_plugins($plugin_files, '', FALSE);
if (is_wp_error($success)) {
return false;
}
chdir(WP_PLUGIN_DIR);
if (is_array($plugin_files)) {
return true;
}
// get the plugin again
return $this->_get_plugin_data($plugin_files);
}
示例12: activate_plugin
$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
if (is_wp_error($result)) {
wp_die($result);
}
$recent = (array) get_option('recently_activated');
if (isset($recent[$plugin])) {
unset($recent[$plugin]);
update_option('recently_activated', $recent);
}
wp_redirect('plugins.php?activate=true');
// overrides the ?error=true one above
exit;
break;
case 'activate-selected':
check_admin_referer('bulk-manage-plugins');
activate_plugins($_POST['checked'], 'plugins.php?error=true');
$recent = (array) get_option('recently_activated');
foreach ((array) $_POST['checked'] as $plugin => $time) {
if (isset($recent[$plugin])) {
unset($recent[$plugin]);
}
}
if ($recent != get_option('recently_activated')) {
//If array changed, update it.
update_option('recently_activated', $recent);
}
wp_redirect('plugins.php?activate-multi=true');
exit;
break;
case 'error_scrape':
check_admin_referer('plugin-activation-error_' . $plugin);
示例13: Plugin_Upgrader
$plugin = $plugin_slug . "/" . 'yop_poll' . ".php";
$upgrader = new Plugin_Upgrader(new Plugin_Upgrader_Skin(array('title' => 'Yop Poll 2.0 Plugin', 'plugin' => $plugin_slug . '/yop_poll.php')));
$options = get_option('yop_poll_options');
$options['vote_permisions_facebook'] = "no";
$options['vote_permisions_google'] = "no";
$options['vote_permisions_facebook_label'] = __yop_poll('Vote as Facebook User');
$options['vote_permisions_google_label'] = __yop_poll('Vote as G+ User');
$options['facebook_share_description'] = __yop_poll('Just casted an YOP Poll vote on ') . get_bloginfo('name');
$options['show_google_share_button'] = "no";
$options['facebook_share_after_vote'] = "no";
$options['google_integration'] = "no";
$options['facebook_integration'] = "no";
$options['user_interface_type'] = "beginner";
$options['is_default_other_answer'] = "no";
$options['facebook_show_comments_widget'] = "no";
update_option('yop_poll_options', $options);
$upgrader->init();
if (is_plugin_active($plugin)) {
deactivate_plugins($plugin);
}
$result = @$upgrader->run(array('package' => $download_link, 'destination' => WP_PLUGIN_DIR . "/" . $plugin_slug . "/", 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array()));
if (!is_wp_error($result)) {
if (!is_plugin_active($plugin)) {
$pro_options = get_option("yop_poll_pro");
unset($pro_options['rand_number']);
update_option("yop_poll_pro", $pro_options);
activate_plugins($plugin);
}
}
Yop_Poll_DbSchema::add_defaults_to_database();
wp_die();
示例14: shareaholic_activate_primary_plugin
function shareaholic_activate_primary_plugin()
{
deactivate_plugins('sexybookmarks/shareaholic.php');
activate_plugins('shareaholic/shareaholic.php');
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'ShareaholicUtilities::admin_plugin_action_links', -10);
}
示例15: upgrade_pp_package
function upgrade_pp_package($plugin)
{
$is_active = is_plugin_active($plugin);
$this->init();
$this->upgrade_strings();
$current = get_site_transient('ppc_update_info');
if (!isset($current->response[$plugin])) {
$this->skin->set_result(false);
$this->skin->error('up_to_date');
$this->skin->after();
return false;
}
// Get the URL to the zip file
$r = $current->response[$plugin];
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);
$this->run(array('package' => $r->package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array('plugin' => $plugin, 'type' => 'plugin', 'action' => 'update')));
// Cleanup our hooks, incase something else does a 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)) {
delete_site_transient('update_plugins');
// force reload of plugin status in case this is due to a key expiration
pp_get_version_info(true, false, true);
return $this->result;
}
if (!is_multisite() && $is_active) {
activate_plugins($plugin);
}
// Force refresh of plugin update information
set_site_transient('ppc_update_info', false);
// Force refresh of plugin update information
delete_site_transient('update_plugins');
wp_cache_delete('plugins', 'plugins');
}