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


PHP is_network_only_plugin函数代码示例

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


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

示例1: 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

示例2: prepare_items

 function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $plugins = array('all' => apply_filters('all_plugins', get_plugins()), 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array());
     $screen = get_current_screen();
     if (!is_multisite() || $screen->is_network && current_user_can('manage_network_plugins')) {
         if (apply_filters('show_advanced_plugins', true, 'mustuse')) {
             $plugins['mustuse'] = get_mu_plugins();
         }
         if (apply_filters('show_advanced_plugins', true, 'dropins')) {
             $plugins['dropins'] = get_dropins();
         }
         $current = get_site_transient('update_plugins');
         foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
             if (isset($current->response[$plugin_file])) {
                 $plugins['upgrade'][$plugin_file] = $plugin_data;
             }
         }
     }
     set_transient('plugin_slugs', array_keys($plugins['all']), 86400);
     $recently_activated = get_option('recently_activated', array());
     $one_week = 7 * 24 * 60 * 60;
     foreach ($recently_activated as $key => $time) {
         if ($time + $one_week < time()) {
             unset($recently_activated[$key]);
         }
     }
     update_option('recently_activated', $recently_activated);
     foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
         // Filter into individual sections
         if (is_multisite() && is_network_only_plugin($plugin_file) && !$screen->is_network) {
             unset($plugins['all'][$plugin_file]);
         } elseif (is_plugin_active_for_network($plugin_file) && !$screen->is_network) {
             unset($plugins['all'][$plugin_file]);
         } elseif (is_multisite() && is_network_only_plugin($plugin_file) && !current_user_can('manage_network_plugins')) {
             $plugins['network'][$plugin_file] = $plugin_data;
         } elseif (!$screen->is_network && is_plugin_active($plugin_file) || $screen->is_network && is_plugin_active_for_network($plugin_file)) {
             $plugins['active'][$plugin_file] = $plugin_data;
         } else {
             if (!$screen->is_network && isset($recently_activated[$plugin_file])) {
                 // Was the plugin recently activated?
                 $plugins['recently_activated'][$plugin_file] = $plugin_data;
             }
             $plugins['inactive'][$plugin_file] = $plugin_data;
         }
     }
     if (!current_user_can('update_plugins')) {
         $plugins['upgrade'] = array();
     }
     if ($s) {
         $status = 'search';
         $plugins['search'] = array_filter($plugins['all'], array(&$this, '_search_callback'));
     }
     $totals = array();
     foreach ($plugins as $type => $list) {
         $totals[$type] = count($list);
     }
     if (empty($plugins[$status]) && !in_array($status, array('all', 'search'))) {
         $status = 'all';
     }
     $this->items = array();
     foreach ($plugins[$status] as $plugin_file => $plugin_data) {
         // Translate, Don't Apply Markup, Sanitize HTML
         $this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $total_this_page = $totals[$status];
     if ($orderby) {
         $orderby = ucfirst($orderby);
         $order = strtoupper($order);
         uasort($this->items, array(&$this, '_order_callback'));
     }
     $plugins_per_page = $this->get_items_per_page(str_replace('-', '_', $screen->id . '_per_page'));
     $start = ($page - 1) * $plugins_per_page;
     if ($total_this_page > $plugins_per_page) {
         $this->items = array_slice($this->items, $start, $plugins_per_page);
     }
     $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $plugins_per_page));
 }
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:79,代码来源:class-wp-plugins-list-table.php

示例3: activate_plugin

/**
 * Attempts activation of plugin in a "sandbox" and redirects on success.
 *
 * A plugin that is already activated will not attempt to be activated again.
 *
 * The way it works is by setting the redirection to the error before trying to
 * include the plugin file. If the plugin fails, then the redirection will not
 * be overwritten with the success message. Also, the options will not be
 * updated and the activation hook will not be called on plugin error.
 *
 * It should be noted that in no way the below code will actually prevent errors
 * within the file. The code should not be used elsewhere to replicate the
 * "sandbox", which uses redirection to work.
 * {@source 13 1}
 *
 * If any errors are found or text is outputted, then it will be captured to
 * ensure that the success redirection will update the error redirection.
 *
 * @since 2.5.0
 *
 * @param string $plugin Plugin path to main plugin file with plugin data.
 * @param string $redirect Optional. URL to redirect to.
 * @param bool $network_wide Whether to enable the plugin for all sites in the
 *   network or just the current site. Multisite only. Default is false.
 * @param bool $silent Prevent calling activation hooks. Optional, default is false.
 * @return WP_Error|null WP_Error on invalid file or null on success.
 */
function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
	$plugin = plugin_basename( trim( $plugin ) );

	if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) {
		$network_wide = true;
		$current = get_site_option( 'active_sitewide_plugins', array() );
		$_GET['networkwide'] = 1; // Back compat for plugins looking for this value.
	} else {
		$current = get_option( 'active_plugins', array() );
	}

	$valid = validate_plugin($plugin);
	if ( is_wp_error($valid) )
		return $valid;

	if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
		if ( !empty($redirect) )
			wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
		ob_start();
		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
		$_wp_plugin_file = $plugin;
		include_once( WP_PLUGIN_DIR . '/' . $plugin );
		$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.

		if ( ! $silent ) {
			/**
			 * Fires before a plugin is activated.
			 *
			 * If a plugin is silently activated (such as during an update),
			 * this hook does not fire.
			 *
			 * @since 2.9.0
			 *
			 * @param string $plugin       Plugin path to main plugin file with plugin data.
			 * @param bool   $network_wide Whether to enable the plugin for all sites in the network
			 *                             or just the current site. Multisite only. Default is false.
			 */
			do_action( 'activate_plugin', $plugin, $network_wide );

			/**
			 * Fires as a specific plugin is being activated.
			 *
			 * This hook is the "activation" hook used internally by
			 * {@see register_activation_hook()}. The dynamic portion of the
			 * hook name, `$plugin`, refers to the plugin basename.
			 *
			 * If a plugin is silently activated (such as during an update),
			 * this hook does not fire.
			 *
			 * @since 2.0.0
			 *
			 * @param bool $network_wide Whether to enable the plugin for all sites in the network
			 *                           or just the current site. Multisite only. Default is false.
			 */
			do_action( 'activate_' . $plugin, $network_wide );
		}

		if ( $network_wide ) {
			$current = get_site_option( 'active_sitewide_plugins', array() );
			$current[$plugin] = time();
			update_site_option( 'active_sitewide_plugins', $current );
		} else {
			$current = get_option( 'active_plugins', array() );
			$current[] = $plugin;
			sort($current);
			update_option('active_plugins', $current);
		}

		if ( ! $silent ) {
			/**
			 * Fires after a plugin has been activated.
			 *
			 * If a plugin is silently activated (such as during an update),
//.........这里部分代码省略.........
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:101,代码来源:plugin.php

示例4: exclude_plugins_no_network

function exclude_plugins_no_network()
{
    $plugins = get_plugins();
    $network_plugins = array();
    foreach ((array) $plugins as $plugin => $plugin_data) {
        if (is_network_only_plugin($plugin)) {
            $network_plugins[$plugin] = $plugin_data;
        }
    }
    return array_diff_assoc($plugins, $network_plugins);
}
开发者ID:howardlei82,项目名称:IGSM-Website,代码行数:11,代码来源:exclude-plugins.php

示例5: is_wpmu_sitewide_plugin

/**
 * @deprecated 3.0.0
 * @see is_network_only_plugin()
 */
function is_wpmu_sitewide_plugin($file)
{
    _deprecated_function(__FUNCTION__, '3.0', 'is_network_only_plugin()');
    return is_network_only_plugin($file);
}
开发者ID:RA2WP,项目名称:RA2WP,代码行数:9,代码来源:ms-deprecated.php

示例6: prepare_items

 public function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     /**
      * Filter the full array of plugins to list in the Plugins list table.
      *
      * @since 3.0.0
      *
      * @see get_plugins()
      *
      * @param array $plugins An array of plugins to display in the list table.
      */
     $plugins = array('all' => apply_filters('all_plugins', get_plugins()), 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array());
     $screen = $this->screen;
     if (!is_multisite() || $screen->in_admin('network') && current_user_can('manage_network_plugins')) {
         /**
          * Filter whether to display the advanced plugins list table.
          *
          * There are two types of advanced plugins - must-use and drop-ins -
          * which can be used in a single site or Multisite network.
          *
          * The $type parameter allows you to differentiate between the type of advanced
          * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'.
          *
          * @since 3.0.0
          *
          * @param bool   $show Whether to show the advanced plugins for the specified
          *                     plugin type. Default true.
          * @param string $type The plugin type. Accepts 'mustuse', 'dropins'.
          */
         if (apply_filters('show_advanced_plugins', true, 'mustuse')) {
             $plugins['mustuse'] = get_mu_plugins();
         }
         /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
         if (apply_filters('show_advanced_plugins', true, 'dropins')) {
             $plugins['dropins'] = get_dropins();
         }
         if (current_user_can('update_plugins')) {
             $current = get_site_transient('update_plugins');
             foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
                 if (isset($current->response[$plugin_file])) {
                     $plugins['all'][$plugin_file]['update'] = true;
                     $plugins['upgrade'][$plugin_file] = $plugins['all'][$plugin_file];
                 }
             }
         }
     }
     set_transient('plugin_slugs', array_keys($plugins['all']), DAY_IN_SECONDS);
     if (!$screen->in_admin('network')) {
         $recently_activated = get_option('recently_activated', array());
         foreach ($recently_activated as $key => $time) {
             if ($time + WEEK_IN_SECONDS < time()) {
                 unset($recently_activated[$key]);
             }
         }
         update_option('recently_activated', $recently_activated);
     }
     $plugin_info = get_site_transient('update_plugins');
     foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
         // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
         if (isset($plugin_info->response[$plugin_file])) {
             $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data);
         } elseif (isset($plugin_info->no_update[$plugin_file])) {
             $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data);
         }
         // Filter into individual sections
         if (is_multisite() && !$screen->in_admin('network') && is_network_only_plugin($plugin_file) && !is_plugin_active($plugin_file)) {
             // On the non-network screen, filter out network-only plugins as long as they're not individually activated
             unset($plugins['all'][$plugin_file]);
         } elseif (!$screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) {
             // On the non-network screen, filter out network activated plugins
             unset($plugins['all'][$plugin_file]);
         } elseif (!$screen->in_admin('network') && is_plugin_active($plugin_file) || $screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) {
             // On the non-network screen, populate the active list with plugins that are individually activated
             // On the network-admin screen, populate the active list with plugins that are network activated
             $plugins['active'][$plugin_file] = $plugin_data;
         } else {
             if (!$screen->in_admin('network') && isset($recently_activated[$plugin_file])) {
                 // On the non-network screen, populate the recently activated list with plugins that have been recently activated
                 $plugins['recently_activated'][$plugin_file] = $plugin_data;
             }
             // Populate the inactive list with plugins that aren't activated
             $plugins['inactive'][$plugin_file] = $plugin_data;
         }
     }
     if ($s) {
         $status = 'search';
         $plugins['search'] = array_filter($plugins['all'], array($this, '_search_callback'));
     }
     $totals = array();
     foreach ($plugins as $type => $list) {
         $totals[$type] = count($list);
     }
     if (empty($plugins[$status]) && !in_array($status, array('all', 'search'))) {
         $status = 'all';
     }
     $this->items = array();
     foreach ($plugins[$status] as $plugin_file => $plugin_data) {
         // Translate, Don't Apply Markup, Sanitize HTML
//.........这里部分代码省略.........
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:101,代码来源:class-wp-plugins-list-table.php

示例7: isNetworkPlugin

 /**
  * Gets VC is activated as network plugin.
  *
  * @since  4.2
  * @access public
  *
  * @return bool
  */
 public function isNetworkPlugin()
 {
     if (is_null($this->is_network_plugin)) {
         // Check is VC as network plugin
         if (is_multisite() && (is_plugin_active_for_network($this->pluginName()) || is_network_only_plugin($this->pluginName()))) {
             $this->setAsNetworkPlugin(true);
         }
     }
     return $this->is_network_plugin ? true : false;
 }
开发者ID:pivotlearning,项目名称:wpsite,代码行数:18,代码来源:js_composer.php

示例8: admin_page

    function admin_page()
    {
        global $psts;
        if (isset($_POST['supporter_plugins'])) {
            $psts_plugins = array();
            if (is_array($_POST['plugins'])) {
                foreach ($_POST['plugins'] as $plugin => $value) {
                    $value['auto'] = $value['level'] == 'none' ? 0 : intval(@$value['auto']);
                    $psts_plugins[$plugin] = $value;
                }
                $psts->update_setting('pp_plugins', $psts_plugins);
                echo '<div id="message" class="updated fade"><p>' . __('Settings Saved!', 'psts') . '</p></div>';
            }
        }
        ?>
	  <div class="wrap">
    <div class="icon32" id="icon-plugins"></div>
    <h2><?php 
        _e('Premium Plugins', 'psts');
        ?>
</h2>
  	<p><?php 
        _e('Select the minimum Pro Site level for premium plugins that you want to enable for sites of that level or above. Checking Auto Activate will activate the plugin when they upgrade to that level. Network only and network activated plugins will not show in this list. Note you can also override plugin permissions on a per-site basis on the <a href="sites.php">edit sites</a> page.', 'psts');
        ?>
</p>

		<form method="post" action="">
		<table class="widefat">
  			<thead>
  				<tr>
  					<th style="width:25%;"><?php 
        _e('Minimum Level', 'psts');
        ?>
</th>
            <th style="width:20%;"><?php 
        _e('Plugin', 'psts');
        ?>
</th>
  					<th style="width:10%;"><?php 
        _e('Version', 'psts');
        ?>
</th>
  					<th><?php 
        _e('Description', 'psts');
        ?>
</th>
  				</tr>
  			</thead>
  			<tbody id="plugins">
  		  <?php 
        $plugins = get_plugins();
        $psts_plugins = (array) $psts->get_setting('pp_plugins');
        $levels = (array) get_site_option('psts_levels');
        foreach ($plugins as $file => $p) {
            //skip network only plugins
            if (is_network_only_plugin($file) || is_plugin_active_for_network($file)) {
                continue;
            }
            ?>
        	<tr>
        		<td>
        		<select name="plugins[<?php 
            echo $file;
            ?>
][level]">
             <option value="none"<?php 
            selected(@$psts_plugins[$file]['level'], 'none');
            ?>
><?php 
            _e('None', 'psts');
            ?>
</option>
             <option value="0"<?php 
            selected(@$psts_plugins[$file]['level'], 0);
            ?>
><?php 
            _e('Anyone', 'psts');
            ?>
</option>
             <?php 
            foreach ($levels as $level => $value) {
                ?>
<option value="<?php 
                echo $level;
                ?>
"<?php 
                selected(@$psts_plugins[$file]['level'], $level);
                ?>
><?php 
                echo $level . ': ' . esc_attr($value['name']);
                ?>
</option><?php 
            }
            ?>
            </select>
            <label><input type="checkbox" name="plugins[<?php 
            echo $file;
            ?>
][auto]" value="1"<?php 
            checked(@$psts_plugins[$file]['auto']);
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:premium-plugins.php

示例9: test_is_network_only_plugin

 /**
  * @covers ::is_network_only_plugin
  */
 public function test_is_network_only_plugin()
 {
     $p = $this->_create_plugin("<?php\n/*\nPlugin Name: test\nNetwork: true");
     $this->assertTrue(is_network_only_plugin($p[0]));
     unlink($p[1]);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:9,代码来源:includesPlugin.php

示例10: active_output

 private function active_output($name, $file, $network_wide, $action)
 {
     $network_wide = $network_wide || is_multisite() && is_network_only_plugin($file);
     $check = $this->check_active($file, $network_wide);
     if ($action == "activate" ? $check : !$check) {
         if ($network_wide) {
             WP_CLI::success("Plugin '{$name}' network {$action}d.");
         } else {
             WP_CLI::success("Plugin '{$name}' {$action}d.");
         }
     } else {
         WP_CLI::warning("Could not {$action} the '{$name}' plugin.");
     }
 }
开发者ID:kyeates,项目名称:wp-cli,代码行数:14,代码来源:plugin.php

示例11: wp_die

 case 'activate-selected':
     if (!current_user_can('activate_plugins')) {
         wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
     }
     check_admin_referer('bulk-plugins');
     $plugins = isset($_POST['checked']) ? (array) $_POST['checked'] : array();
     // Only activate plugins which are not already active.
     if (is_network_admin()) {
         foreach ($plugins as $i => $plugin) {
             if (is_plugin_active_for_network($plugin)) {
                 unset($plugins[$i]);
             }
         }
     } else {
         foreach ($plugins as $i => $plugin) {
             if (is_plugin_active($plugin) || is_network_only_plugin($plugin)) {
                 unset($plugins[$i]);
             }
         }
     }
     if (empty($plugins)) {
         wp_redirect(self_admin_url("plugins.php?plugin_status={$status}&paged={$page}&s={$s}"));
         exit;
     }
     activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin());
     if (!is_network_admin()) {
         $recent = (array) get_option('recently_activated');
         foreach ($plugins as $plugin) {
             unset($recent[$plugin]);
         }
         update_option('recently_activated', $recent);
开发者ID:phuluang,项目名称:rosewellmusic,代码行数:31,代码来源:plugins.php

示例12: single_row

 /**
  * @global string $status
  * @global int $page
  * @global string $s
  * @global array $totals
  *
  * @param array $item
  */
 public function single_row($item)
 {
     global $status, $page, $s, $totals;
     list($plugin_file, $plugin_data) = $item;
     $context = $status;
     $screen = $this->screen;
     // Pre-order.
     $actions = array('deactivate' => '', 'activate' => '', 'details' => '', 'edit' => '', 'delete' => '');
     // Do not restrict by default
     $restrict_network_active = false;
     $restrict_network_only = false;
     if ('mustuse' === $context) {
         $is_active = true;
     } elseif ('dropins' === $context) {
         $dropins = _get_dropins();
         $plugin_name = $plugin_file;
         if ($plugin_file != $plugin_data['Name']) {
             $plugin_name .= '<br/>' . $plugin_data['Name'];
         }
         if (true === $dropins[$plugin_file][1]) {
             // Doesn't require a constant
             $is_active = true;
             $description = '<p><strong>' . $dropins[$plugin_file][0] . '</strong></p>';
         } elseif (defined($dropins[$plugin_file][1]) && constant($dropins[$plugin_file][1])) {
             // Constant is true
             $is_active = true;
             $description = '<p><strong>' . $dropins[$plugin_file][0] . '</strong></p>';
         } else {
             $is_active = false;
             $description = '<p><strong>' . $dropins[$plugin_file][0] . ' <span class="error-message">' . __('Inactive:') . '</span></strong> ' . sprintf(__('Requires %1$s in %2$s file.'), "<code>define('" . $dropins[$plugin_file][1] . "', true);</code>", '<code>wp-config.php</code>') . '</p>';
         }
         if ($plugin_data['Description']) {
             $description .= '<p>' . $plugin_data['Description'] . '</p>';
         }
     } else {
         if ($screen->in_admin('network')) {
             $is_active = is_plugin_active_for_network($plugin_file);
         } else {
             $is_active = is_plugin_active($plugin_file);
             $restrict_network_active = is_multisite() && is_plugin_active_for_network($plugin_file);
             $restrict_network_only = is_multisite() && is_network_only_plugin($plugin_file) && !$is_active;
         }
         if ($screen->in_admin('network')) {
             if ($is_active) {
                 if (current_user_can('manage_network_plugins')) {
                     /* translators: %s: plugin name */
                     $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" aria-label="' . esc_attr(sprintf(__('Network deactivate %s'), $plugin_data['Name'])) . '">' . __('Network Deactivate') . '</a>';
                 }
             } else {
                 if (current_user_can('manage_network_plugins')) {
                     /* translators: %s: plugin name */
                     $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" class="edit" aria-label="' . esc_attr(sprintf(__('Network Activate %s'), $plugin_data['Name'])) . '">' . __('Network Activate') . '</a>';
                 }
                 if (current_user_can('delete_plugins') && !is_plugin_active($plugin_file)) {
                     /* translators: %s: plugin name */
                     $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" class="delete" aria-label="' . esc_attr(sprintf(__('Delete %s'), $plugin_data['Name'])) . '">' . __('Delete') . '</a>';
                 }
             }
         } else {
             if ($restrict_network_active) {
                 $actions = array('network_active' => __('Network Active'));
             } elseif ($restrict_network_only) {
                 $actions = array('network_only' => __('Network Only'));
             } elseif ($is_active) {
                 /* translators: %s: plugin name */
                 $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" aria-label="' . esc_attr(sprintf(__('Deactivate %s'), $plugin_data['Name'])) . '">' . __('Deactivate') . '</a>';
             } else {
                 /* translators: %s: plugin name */
                 $actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" class="edit" aria-label="' . esc_attr(sprintf(__('Activate %s'), $plugin_data['Name'])) . '">' . __('Activate') . '</a>';
                 if (!is_multisite() && current_user_can('delete_plugins')) {
                     /* translators: %s: plugin name */
                     $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" class="delete" aria-label="' . esc_attr(sprintf(__('Delete %s'), $plugin_data['Name'])) . '">' . __('Delete') . '</a>';
                 }
             }
             // end if $is_active
         }
         // end if $screen->in_admin( 'network' )
         if ((!is_multisite() || $screen->in_admin('network')) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file)) {
             /* translators: %s: plugin name */
             $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" class="edit" aria-label="' . esc_attr(sprintf(__('Edit %s'), $plugin_data['Name'])) . '">' . __('Edit') . '</a>';
         }
     }
     // end if $context
     $actions = array_filter($actions);
     if ($screen->in_admin('network')) {
         /**
          * Filter the action links displayed for each plugin in the Network Admin Plugins list table.
          *
          * The default action links for the Network plugins list table include
          * 'Network Activate', 'Network Deactivate', 'Edit', and 'Delete'.
          *
          * @since 3.1.0 As `{$prefix}_plugin_action_links`
//.........这里部分代码省略.........
开发者ID:andylow,项目名称:WordPress,代码行数:101,代码来源:class-wp-plugins-list-table.php

示例13: print_plugins_table

/**
 * @ignore
 *
 * @param array $plugins
 * @param string $context
 */
function print_plugins_table($plugins, $context = '')
{
    global $page;
    $checkbox = !in_array($context, array('mustuse', 'dropins')) ? '<input type="checkbox" />' : '';
    ?>
<table class="widefat" cellspacing="0" id="<?php 
    echo $context;
    ?>
-plugins-table">
	<thead>
	<tr>
		<th scope="col" class="manage-column check-column"><?php 
    echo $checkbox;
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e('Plugin');
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e('Description');
    ?>
</th>
	</tr>
	</thead>

	<tfoot>
	<tr>
		<th scope="col" class="manage-column check-column"><?php 
    echo $checkbox;
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e('Plugin');
    ?>
</th>
		<th scope="col" class="manage-column"><?php 
    _e('Description');
    ?>
</th>
	</tr>
	</tfoot>

	<tbody class="plugins">
<?php 
    if (empty($plugins)) {
        echo '<tr>
			<td colspan="3">' . __('No plugins to show') . '</td>
		</tr>';
    }
    foreach ((array) $plugins as $plugin_file => $plugin_data) {
        // preorder
        $actions = array('network_deactivate' => '', 'deactivate' => '', 'network_only' => '', 'activate' => '', 'network_activate' => '', 'edit' => '', 'delete' => '');
        if ('mustuse' == $context) {
            $is_active = true;
        } elseif ('dropins' == $context) {
            $dropins = _get_dropins();
            $plugin_name = $plugin_file;
            if ($plugin_file != $plugin_data['Name']) {
                $plugin_name .= '<br/>' . $plugin_data['Name'];
            }
            if (true === $dropins[$plugin_file][1]) {
                // Doesn't require a constant
                $is_active = true;
                $description = '<p><strong>' . $dropins[$plugin_file][0] . '</strong></p>';
            } elseif (constant($dropins[$plugin_file][1])) {
                // Constant is true
                $is_active = true;
                $description = '<p><strong>' . $dropins[$plugin_file][0] . '</strong></p>';
            } else {
                $is_active = false;
                $description = '<p><strong>' . $dropins[$plugin_file][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf(__('Requires <code>%s</code> in <code>wp-config.php</code>.'), "define('" . $dropins[$plugin_file][1] . "', true);") . '</p>';
            }
            if ($plugin_data['Description']) {
                $description .= '<p>' . $plugin_data['Description'] . '</p>';
            }
        } else {
            $is_active_for_network = is_plugin_active_for_network($plugin_file);
            $is_active = $is_active_for_network || is_plugin_active($plugin_file);
            if ($is_active_for_network && !is_super_admin()) {
                continue;
            }
            if ($is_active) {
                if ($is_active_for_network) {
                    if (is_super_admin()) {
                        $actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
                    }
                } else {
                    $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
                }
            } else {
                if (is_multisite() && is_network_only_plugin($plugin_file)) {
                    $actions['network_only'] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>';
                } else {
//.........这里部分代码省略.........
开发者ID:google-code-backups,项目名称:pumpmyvote,代码行数:101,代码来源:plugins.php

示例14: activate_plugin

/**
 * Attempts activation of plugin in a "sandbox" and redirects on success.
 *
 * A plugin that is already activated will not attempt to be activated again.
 *
 * The way it works is by setting the redirection to the error before trying to
 * include the plugin file. If the plugin fails, then the redirection will not
 * be overwritten with the success message. Also, the options will not be
 * updated and the activation hook will not be called on plugin error.
 *
 * It should be noted that in no way the below code will actually prevent errors
 * within the file. The code should not be used elsewhere to replicate the
 * "sandbox", which uses redirection to work.
 * {@source 13 1}
 *
 * If any errors are found or text is outputted, then it will be captured to
 * ensure that the success redirection will update the error redirection.
 *
 * @since 2.5.0
 *
 * @param string $plugin Plugin path to main plugin file with plugin data.
 * @param string $redirect Optional. URL to redirect to.
 * @param bool $network_wide Whether to enable the plugin for all sites in the
 *   network or just the current site. Multisite only. Default is false.
 * @param bool $silent Prevent calling activation hooks. Optional, default is false.
 * @return WP_Error|null WP_Error on invalid file or null on success.
 */
function activate_plugin($plugin, $redirect = '', $network_wide = false, $silent = false)
{
    $plugin = plugin_basename(trim($plugin));
    if (is_multisite() && ($network_wide || is_network_only_plugin($plugin))) {
        $network_wide = true;
        $current = get_site_option('active_sitewide_plugins', array());
        $_GET['networkwide'] = 1;
        // Back compat for plugins looking for this value.
    } else {
        $current = get_option('active_plugins', array());
    }
    $valid = validate_plugin($plugin);
    if (is_wp_error($valid)) {
        return $valid;
    }
    if (!in_array($plugin, $current)) {
        if (!empty($redirect)) {
            wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
        }
        // we'll override this later if the plugin can be included without fatal error
        ob_start();
        include_once WP_PLUGIN_DIR . '/' . $plugin;
        if (!$silent) {
            /**
             * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false.
             * 
             * @since 2.9.0
             *
             * @param string $plugin       Plugin path to main plugin file with plugin data.
             * @param bool   $network_wide Whether to enable the plugin for all sites in the network
             *                             or just the current site. Multisite only. Default is false.
             */
            do_action('activate_plugin', $plugin, $network_wide);
            /**
             * Fires before a plugin is activated in activate_plugin() when the $silent parameter is false.
             * 
             * The action concatenates the 'activate_' prefix with the $plugin value passed to
             * activate_plugin() to create a dynamically-named action.
             * 
             * @since 2.0.0
             *
             * @param bool $network_wide Whether to enable the plugin for all sites in the network
             *                           or just the current site. Multisite only. Default is false.
             */
            do_action('activate_' . $plugin, $network_wide);
        }
        if ($network_wide) {
            $current[$plugin] = time();
            update_site_option('active_sitewide_plugins', $current);
        } else {
            $current[] = $plugin;
            sort($current);
            update_option('active_plugins', $current);
        }
        if (!$silent) {
            /**
             * Fires after a plugin has been activated in activate_plugin() when the $silent parameter is false.
             * 
             * @since 2.9.0
             *
             * @param string $plugin       Plugin path to main plugin file with plugin data.
             * @param bool   $network_wide Whether to enable the plugin for all sites in the network
             *                             or just the current site. Multisite only. Default is false.
             */
            do_action('activated_plugin', $plugin, $network_wide);
        }
        if (ob_get_length() > 0) {
            $output = ob_get_clean();
            return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
        }
        ob_end_clean();
    }
    return null;
//.........这里部分代码省略.........
开发者ID:openify,项目名称:wordpress-composer,代码行数:101,代码来源:plugin.php

示例15: blog_options_form

    function blog_options_form($blog_id)
    {
        $plugins = get_plugins();
        $override_plugins = (array) get_blog_option($blog_id, 'pm_plugin_override_list');
        ?>
	  </table>
	  <h3><?php 
        _e('Plugin Override Options', 'pm');
        ?>
</h3>
	  <p style="padding:5px 10px 0 10px;margin:0;">
	  <?php 
        _e('Checked plugins here will be accessible to this site, overriding the sitewide <a href="plugins.php?page=plugin-management">Plugin Management</a> settings. Uncheck to return to sitewide settings.', 'pm');
        ?>
	  </p>
	  <table class="widefat" style="margin:10px;width:95%;">
	  <thead>
		<tr>
			<th title="<?php 
        _e('Blog users may activate/deactivate', 'pm');
        ?>
"><?php 
        _e('User Control', 'pm');
        ?>
</th>
	    <th><?php 
        _e('Name', 'pm');
        ?>
</th>
			<th><?php 
        _e('Version', 'pm');
        ?>
</th>
			<th><?php 
        _e('Author', 'pm');
        ?>
</th>
		</tr>
		</thead>
	  <?php 
        foreach ($plugins as $file => $p) {
            //skip network plugins or network activated plugins
            if (is_network_only_plugin($file) || is_plugin_active_for_network($file)) {
                continue;
            }
            ?>
			<tr>
				<td>
				<?php 
            $checked = in_array($file, $override_plugins) ? 'checked="checked"' : '';
            echo '<label><input name="plugins[' . $file . ']" type="checkbox" value="1" ' . $checked . '/> ' . __('Enable', 'mp') . '</label>';
            ?>
				</td>
		 		<td><?php 
            echo $p['Name'];
            ?>
</td>
		 		<td><?php 
            echo $p['Version'];
            ?>
</td>
		 		<td><?php 
            echo $p['Author'];
            ?>
</td>
			</tr>
			<?php 
        }
        echo '</table>';
    }
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:70,代码来源:plugin-manager.php


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