示例#1
0
/**
 * Parse the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 * <code>
 * /*
 * Plugin Name: Name of Plugin
 * Plugin URI: Link to plugin information
 * Description: Plugin Description
 * Author: Plugin author's name
 * Author URI: Link to the author's web site
 * Version: Must be set in the plugin for WordPress 2.3+
 * Text Domain: Optional. Unique identifier, should be same as the one used in
 *		plugin_text_domain()
 * Domain Path: Optional. Only useful if the translations are located in a
 *		folder above the plugin's base path. For example, if .mo files are
 *		located in the locale folder then Domain Path will be "/locale/" and
 *		must have the first slash. Defaults to the base folder the plugin is
 *		located in.
 *  * / # Remove the space to close comment
 * </code>
 *
 * Plugin data returned array contains the following:
 *		'Name' - Name of the plugin, must be unique.
 *		'Title' - Title of the plugin and the link to the plugin's web site.
 *		'Description' - Description of what the plugin does and/or notes
 *		from the author.
 *		'Author' - The author's name
 *		'AuthorURI' - The authors web site address.
 *		'Version' - The plugin version number.
 *		'PluginURI' - Plugin web site address.
 *		'TextDomain' - Plugin's text domain for localization.
 *		'DomainPath' - Plugin's relative directory path to .mo files.
 *
 * Some users have issues with opening large files and manipulating the contents
 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
 * the plugin contents when it has all of the required plugin data.
 *
 * The first 8kiB of the file will be pulled in and if the plugin data is not
 * within that first 8kiB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
 * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool $markup If the returned data should have HTML markup applied
 * @param bool $translate If the returned data should be translated
 * @return array See above for description.
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path');
    $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
    //For backward compatibility by default Title is the same as Name.
    $plugin_data['Title'] = $plugin_data['Name'];
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    }
    return $plugin_data;
}
示例#2
0
/**
 * Parse the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 * <code>
 * /*
 * Plugin Name: Name of Plugin
 * Plugin URI: Link to plugin information
 * Description: Plugin Description
 * Author: Plugin author's name
 * Author URI: Link to the author's web site
 * Version: Must be set in the plugin for WordPress 2.3+
 * Text Domain: Optional. Unique identifier, should be same as the one used in
 *		plugin_text_domain()
 * Domain Path: Optional. Only useful if the translations are located in a
 *		folder above the plugin's base path. For example, if .mo files are
 *		located in the locale folder then Domain Path will be "/locale/" and
 *		must have the first slash. Defaults to the base folder the plugin is
 *		located in.
 * Network: Optional. Specify "Network: true" to require that a plugin is activated
 *		across all sites in an installation. This will prevent a plugin from being
 *		activated on a single site when Multisite is enabled.
 *  * / # Remove the space to close comment
 * </code>
 *
 * Plugin data returned array contains the following:
 *		'Name' - Name of the plugin, must be unique.
 *		'Title' - Title of the plugin and the link to the plugin's web site.
 *		'Description' - Description of what the plugin does and/or notes
 *		from the author.
 *		'Author' - The author's name
 *		'AuthorURI' - The authors web site address.
 *		'Version' - The plugin version number.
 *		'PluginURI' - Plugin web site address.
 *		'TextDomain' - Plugin's text domain for localization.
 *		'DomainPath' - Plugin's relative directory path to .mo files.
 *		'Network' - Boolean. Whether the plugin can only be activated network wide.
 *
 * Some users have issues with opening large files and manipulating the contents
 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
 * the plugin contents when it has all of the required plugin data.
 *
 * The first 8kiB of the file will be pulled in and if the plugin data is not
 * within that first 8kiB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
 * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool $markup If the returned data should have HTML markup applied
 * @param bool $translate If the returned data should be translated
 * @return array See above for description.
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
    $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
    // Site Wide Only is the old header for Network
    if (empty($plugin_data['Network']) && !empty($plugin_data['_sitewide'])) {
        _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.'), 'Site Wide Only: true', 'Network: true'));
        $plugin_data['Network'] = $plugin_data['_sitewide'];
    }
    $plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']);
    unset($plugin_data['_sitewide']);
    //For backward compatibility by default Title is the same as Name.
    $plugin_data['Title'] = $plugin_data['Name'];
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    }
    return $plugin_data;
}
 function plugins_nav()
 {
     if (!current_user_can('manage_network_options')) {
         return;
     }
     global $totals, $status, $plugins;
     $visible_plugins_array = $this->get_plugin_array(is_network_admin() ? 'sitewide' : 'both');
     $totals['visible'] = count($visible_plugins_array);
     $totals['hidden'] = $totals['all'] - $totals['visible'];
     //echo "<pre>"; print_r($totals); echo "</pre>";
     if (isset($_REQUEST['plugin_status']) && $status != 'search' && ($_REQUEST['plugin_status'] == 'visible' || $_REQUEST['plugin_status'] == 'hidden')) {
         $status = $_REQUEST['plugin_status'];
         $screen = get_current_screen();
         if ($screen->is_network && $screen->base == 'plugins-network' && $status == 'hidden') {
             $options = $this->get_site_option();
             if (isset($_REQUEST['pvm-action']) && $_REQUEST['pvm-action'] == 'dismiss') {
                 $options['dismiss-netword-vis'] = 1;
                 update_site_option('pvm-options', $options);
             } else {
                 if (!isset($options['dismiss-netword-vis']) || $options['dismiss-netword-vis'] != 1) {
                     $url = $_SERVER['REQUEST_URI'] . '&pvm-action=dismiss';
                     printf('<div id="pvm-message" class="updated"><p><strong>Note:</strong> For an individual site, Super Admins can make plugins that are not visible to the network available on a site\'s plugin page.<span style="float:right"><a href="%s">Dismiss</a></span></p></div>', $url);
                 }
             }
         }
         $plugins['visible'] = array();
         $plugins['hidden'] = array();
         //echo "<pre>"; print_r($visible_network_plugins); echo "</pre>";
         foreach ($plugins['all'] as $plugin_file => $plugin_data) {
             if (in_array($plugin_file, $visible_plugins_array)) {
                 $plugins['visible'][$plugin_file] = $plugin_data;
             } else {
                 $plugins['hidden'][$plugin_file] = $plugin_data;
             }
         }
         global $wp_list_table;
         $wp_list_table->items = array();
         foreach ($plugins[$status] as $plugin_file => $plugin_data) {
             // Translate, Don't Apply Markup, Sanitize HTML
             $wp_list_table->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
         }
     }
 }
 /**
  * Fetch the list of VIP plugins to display in the list table.
  */
 public function prepare_items()
 {
     $active = $inactive = array();
     $vip_plugins = WPCOM_VIP_Plugins_UI::instance();
     $shared_plugins = $vip_plugins->get_shared_plugins();
     foreach ($shared_plugins as $plugin_file => $plugin_data) {
         $plugin_folder = basename(dirname($plugin_file));
         if (isset(WPCOM_VIP_Plugins_UI()->fpp_plugins[$plugin_folder])) {
             continue;
         }
         $plugin_file = WPCOM_VIP_Plugins_UI::SHARED_PLUGINS_RELATIVE_PATH . '/' . $plugin_file;
         $status = WPCOM_VIP_Plugins_UI()->is_plugin_active($plugin_folder) ? 'active' : 'inactive';
         if ('inactive' === $status && in_array($plugin_folder, WPCOM_VIP_Plugins_UI()->hidden_plugins, true)) {
             continue;
         }
         ${$status}[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $this->items = array_merge($active, $inactive);
 }
示例#5
0
/**
 * Parse the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 *     /*
 *     Plugin Name: Name of Plugin
 *     Plugin URI: Link to plugin information
 *     Description: Plugin Description
 *     Author: Plugin author's name
 *     Author URI: Link to the author's web site
 *     Version: Must be set in the plugin for WordPress 2.3+
 *     Text Domain: Optional. Unique identifier, should be same as the one used in
 *    		load_plugin_textdomain()
 *     Domain Path: Optional. Only useful if the translations are located in a
 *    		folder above the plugin's base path. For example, if .mo files are
 *    		located in the locale folder then Domain Path will be "/locale/" and
 *    		must have the first slash. Defaults to the base folder the plugin is
 *    		located in.
 *     Network: Optional. Specify "Network: true" to require that a plugin is activated
 *    		across all sites in an installation. This will prevent a plugin from being
 *    		activated on a single site when Multisite is enabled.
 *      * / # Remove the space to close comment
 *
 * Plugin data returned array contains the following:
 *
 * - 'Name' - Name of the plugin, must be unique.
 * - 'Title' - Title of the plugin and the link to the plugin's web site.
 * - 'Description' - Description of what the plugin does and/or notes
 * - from the author.
 * - 'Author' - The author's name
 * - 'AuthorURI' - The authors web site address.
 * - 'Version' - The plugin version number.
 * - 'PluginURI' - Plugin web site address.
 * - 'TextDomain' - Plugin's text domain for localization.
 * - 'DomainPath' - Plugin's relative directory path to .mo files.
 * - 'Network' - Boolean. Whether the plugin can only be activated network wide.
 *
 * Some users have issues with opening large files and manipulating the contents
 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
 * the plugin contents when it has all of the required plugin data.
 *
 * The first 8kiB of the file will be pulled in and if the plugin data is not
 * within that first 8kiB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @link https://core.trac.wordpress.org/ticket/5651 Previous Optimizations.
 * @link https://core.trac.wordpress.org/ticket/7372 Further and better Optimizations.
 *
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true.
 * @param bool $translate Optional. If the returned data should be translated. Defaults to true.
 * @return array See above for description.
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
    $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
    // Site Wide Only is the old header for Network
    if (!$plugin_data['Network'] && $plugin_data['_sitewide']) {
        /* translators: 1: Site Wide Only: true, 2: Network: true */
        _deprecated_argument(__FUNCTION__, '3.0', sprintf(__('The %1$s plugin header is deprecated. Use %2$s instead.'), '<code>Site Wide Only: true</code>', '<code>Network: true</code>'));
        $plugin_data['Network'] = $plugin_data['_sitewide'];
    }
    $plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']);
    unset($plugin_data['_sitewide']);
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    } else {
        $plugin_data['Title'] = $plugin_data['Name'];
        $plugin_data['AuthorName'] = $plugin_data['Author'];
    }
    return $plugin_data;
}
 /**
  * Fetch the list of VIP plugins to display in the list table.
  */
 public function prepare_items()
 {
     $active = $inactive = array();
     // The path has to be
     foreach (get_plugins('/../themes/vip/plugins') as $plugin_file => $plugin_data) {
         $plugin_folder = basename(dirname($plugin_file));
         // FPP is listed separately
         if (isset(WPcom_VIP_Plugins_UI()->fpp_plugins[$plugin_folder])) {
             continue;
         }
         $plugin_file = 'plugins/' . $plugin_file;
         $status = WPcom_VIP_Plugins_UI()->is_plugin_active($plugin_folder) ? 'active' : 'inactive';
         // Don't want some plugins showing up in the list
         if ('inactive' == $status && in_array($plugin_folder, WPcom_VIP_Plugins_UI()->hidden_plugins)) {
             continue;
         }
         // Translate, Don't Apply Markup, Sanitize HTML
         ${$status}[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $this->items = array_merge($active, $inactive);
 }
 /**
  * Pretty much the same as WP-core get_plugin_data(),
  * but with a few adaptions that sadly weren't possible with the original function
  *
  * @param      $prefix
  * @param      $plugin_file
  * @param bool $markup
  * @param bool $translate
  *
  * @return array|bool|mixed
  */
 function biont_get_plugin_data($prefix, $plugin_file, $markup = TRUE, $translate = TRUE)
 {
     if (!function_exists('_get_plugin_data_markup_translate')) {
         include ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $plugin_data = wp_cache_get($prefix . $plugin_file, $prefix . '_subplugins');
     if ($plugin_data === FALSE) {
         $default_headers = array('Name' => strtoupper($prefix) . '-Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
         $default_headers = apply_filters($prefix . '_plugin_data_headers', $default_headers);
         $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
         $plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']);
         if ($markup || $translate) {
             $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
         } else {
             $plugin_data['Title'] = $plugin_data['Name'];
             $plugin_data['AuthorName'] = $plugin_data['Author'];
         }
         wp_cache_set($prefix . $plugin_file, $plugin_data, $prefix . '_subplugins');
     }
     return $plugin_data;
 }
 /**
  * Fetch the list of VIP plugins to display in the list table.
  */
 public function prepare_items()
 {
     $active = $inactive = array();
     $vip_plugins = WPCOM_VIP_Plugins_UI::instance();
     $shared_plugins = $vip_plugins->get_shared_plugins();
     // The path has to be
     foreach ($shared_plugins as $plugin_file => $plugin_data) {
         $plugin_folder = basename(dirname($plugin_file));
         // FPP is listed separately
         if (isset(WPCOM_VIP_Plugins_UI()->fpp_plugins[$plugin_folder])) {
             continue;
         }
         $plugin_file = WPCOM_VIP_Plugins_UI::SHARED_PLUGINS_RELATIVE_PATH . '/' . $plugin_file;
         $status = WPCOM_VIP_Plugins_UI()->is_plugin_active($plugin_folder) ? 'active' : 'inactive';
         // Don't want some plugins showing up in the list
         if ('inactive' == $status && in_array($plugin_folder, WPCOM_VIP_Plugins_UI()->hidden_plugins)) {
             continue;
         }
         // Translate, Don't Apply Markup, Sanitize HTML
         ${$status}[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $this->items = array_merge($active, $inactive);
 }
 /**
  * Overrides {@link WP_Plugins_List_Table::prepare_items()}
  */
 function prepare_items()
 {
     global $status, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order'));
     $plugins = array('all' => ray_get_network_plugins_only(), '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')) {
         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);
     $recently_activated = get_site_option('recently_activated', array());
     foreach ($recently_activated as $key => $time) {
         if ($time + WEEK_IN_SECONDS < time()) {
             unset($recently_activated[$key]);
         }
     }
     update_site_option('recently_activated', $recently_activated);
     if (strlen($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 = 'Name';
     } else {
         $orderby = ucfirst($orderby);
     }
     $order = strtoupper($order);
     uasort($this->items, array($this, '_order_callback'));
 }
示例#10
0
 function get_upgradable_plugins()
 {
     $all_plugins = get_plugins();
     $upgrade_plugins = array();
     $this->refresh_transient();
     $current = $this->wpr_get_transient('update_plugins');
     foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
         $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
         if (isset($current->response[$plugin_file])) {
             $current->response[$plugin_file]->name = $plugin_data['Name'];
             $current->response[$plugin_file]->old_version = $plugin_data['Version'];
             $current->response[$plugin_file]->file = $plugin_file;
             $upgrade_plugins[] = $current->response[$plugin_file];
         }
     }
     return $upgrade_plugins;
 }
 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));
 }
示例#12
0
$recent_plugins = array();
$recently_activated = (array) get_option('recently_activated');
//Clean out any plugins which were deactivated over a week ago.
foreach ($recently_activated as $key => $time) {
    if ($time + 7 * 24 * 60 * 60 < time()) {
        //1 week
        unset($recently_activated[$key]);
    }
}
if ($recently_activated != get_option('recently_activated')) {
    //If array changed, update it.
    update_option('recently_activated', $recently_activated);
}
foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
    //Translate, Apply Markup, Sanitize HTML
    $plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true);
    //Filter into individual sections
    if (is_plugin_active($plugin_file)) {
        $active_plugins[$plugin_file] = $plugin_data;
    } else {
        if (isset($recently_activated[$plugin_file])) {
            //Was the plugin recently activated?
            $recent_plugins[$plugin_file] = $plugin_data;
        } else {
            $inactive_plugins[$plugin_file] = $plugin_data;
        }
    }
}
?>

<?php 
示例#13
0
set_transient('plugin_slugs', array_keys($all_plugins), 86400);
// Clean out any plugins which were deactivated over a week ago.
foreach ($recently_activated as $key => $time) {
    if ($time + 7 * 24 * 60 * 60 < time()) {
        //1 week
        unset($recently_activated[$key]);
    }
}
if ($recently_activated != get_option('recently_activated')) {
    //If array changed, update it.
    update_option('recently_activated', $recently_activated);
}
$current = get_transient('update_plugins');
foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
    //Translate, Apply Markup, Sanitize HTML
    $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
    $all_plugins[$plugin_file] = $plugin_data;
    //Filter into individual sections
    if (is_plugin_active($plugin_file)) {
        $active_plugins[$plugin_file] = $plugin_data;
    } else {
        if (isset($recently_activated[$plugin_file])) {
            // Was the plugin recently activated?
            $recent_plugins[$plugin_file] = $plugin_data;
        }
        $inactive_plugins[$plugin_file] = $plugin_data;
    }
    if (isset($current->response[$plugin_file])) {
        $upgrade_plugins[$plugin_file] = $plugin_data;
    }
}
示例#14
0
/**
 * Parse the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 * <code>
 * /*
 * Plugin Name: Name of Plugin
 * Plugin URI: Link to plugin information
 * Description: Plugin Description
 * Author: Plugin author's name
 * Author URI: Link to the author's web site
 * Version: Must be set in the plugin for WordPress 2.3+
 * Text Domain: Optional. Unique identifier, should be same as the one used in
 *		plugin_text_domain()
 * Domain Path: Optional. Only useful if the translations are located in a
 *		folder above the plugin's base path. For example, if .mo files are
 *		located in the locale folder then Domain Path will be "/locale/" and
 *		must have the first slash. Defaults to the base folder the plugin is
 *		located in.
 *  * / # Remove the space to close comment
 * </code>
 *
 * Plugin data returned array contains the following:
 *		'Name' - Name of the plugin, must be unique.
 *		'Title' - Title of the plugin and the link to the plugin's web site.
 *		'Description' - Description of what the plugin does and/or notes
 *		from the author.
 *		'Author' - The author's name
 *		'AuthorURI' - The authors web site address.
 *		'Version' - The plugin version number.
 *		'PluginURI' - Plugin web site address.
 *		'TextDomain' - Plugin's text domain for localization.
 *		'DomainPath' - Plugin's relative directory path to .mo files.
 *
 * Some users have issues with opening large files and manipulating the contents
 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
 * the plugin contents when it has all of the required plugin data.
 *
 * The first 8kiB of the file will be pulled in and if the plugin data is not
 * within that first 8kiB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
 * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool $markup If the returned data should have HTML markup applied
 * @param bool $translate If the returned data should be translated
 * @return array See above for description.
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    // We don't need to write to the file, so just open for reading.
    $fp = fopen($plugin_file, 'r');
    // Pull only the first 8kiB of the file in.
    $plugin_data = fread($fp, 8192);
    // PHP will close file handle, but we are good citizens.
    fclose($fp);
    preg_match('|Plugin Name:(.*)$|mi', $plugin_data, $name);
    preg_match('|Plugin URI:(.*)$|mi', $plugin_data, $uri);
    preg_match('|Version:(.*)|i', $plugin_data, $version);
    preg_match('|Description:(.*)$|mi', $plugin_data, $description);
    preg_match('|Author:(.*)$|mi', $plugin_data, $author_name);
    preg_match('|Author URI:(.*)$|mi', $plugin_data, $author_uri);
    preg_match('|Text Domain:(.*)$|mi', $plugin_data, $text_domain);
    preg_match('|Domain Path:(.*)$|mi', $plugin_data, $domain_path);
    foreach (array('name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path') as $field) {
        if (!empty(${$field})) {
            ${$field} = _cleanup_header_comment(${$field}[1]);
        } else {
            ${$field} = '';
        }
    }
    $plugin_data = array('Name' => $name, 'Title' => $name, 'PluginURI' => $uri, 'Description' => $description, 'Author' => $author_name, 'AuthorURI' => $author_uri, 'Version' => $version, 'TextDomain' => $text_domain, 'DomainPath' => $domain_path);
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    }
    return $plugin_data;
}
示例#15
0
        //Do not apply markup/translate as it'll be cached.
        if (empty($plugin_data['Name'])) {
            $plugin_data['Name'] = $plugin_file;
        }
        $plugins['mustuse'][$plugin_file] = $plugin_data;
    }
    // Recount totals
    $GLOBALS['totals']['mustuse'] = count($plugins['mustuse']);
    // Only apply the rest if we're actually looking at the page
    if ($GLOBALS['status'] !== 'mustuse') {
        return;
    }
    // Reset the list table's data
    $wp_list_table->items = $plugins['mustuse'];
    foreach ($wp_list_table->items as $plugin_file => $plugin_data) {
        $wp_list_table->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
    }
    $total_this_page = $GLOBALS['totals']['mustuse'];
    if ($GLOBALS['orderby']) {
        uasort($wp_list_table->items, array($wp_list_table, '_order_callback'));
    }
    // Force showing all plugins
    // See https://core.trac.wordpress.org/ticket/27110
    $plugins_per_page = $total_this_page;
    $wp_list_table->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $plugins_per_page));
});
add_action('network_admin_plugin_action_links', function ($actions, $plugin_file, $plugin_data, $context) use($hm_mu_plugins) {
    if ($context !== 'mustuse' || !in_array($plugin_file, $hm_mu_plugins)) {
        return;
    }
    $actions[] = sprintf('<span style="color:#333">File: <code>%s</code></span>', $plugin_file);
 public function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $this->process_bulk_action();
     /**
      * 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.
      */
     $dir = false;
     if (isset($_REQUEST['archive_dir'])) {
         $dir = WP_CONTENT_DIR . '/' . $_REQUEST['archive_dir'];
         HackRepair_Plugin_Archiver::$options['archive_dir'] = $_REQUEST['archive_dir'];
         update_option('hackrepair-plugin-archiver_options', HackRepair_Plugin_Archiver::$options);
     }
     $all_plugins = HackRepair_Plugin_Archiver::get_archived_plugins($dir);
     $wprocket = isset($all_plugins['wp-rocket/wp-rocket.php']);
     $all_plugins = apply_filters('all_plugins', $all_plugins);
     if (!$wprocket) {
         unset($all_plugins['wp-rocket/wp-rocket.php']);
     }
     $plugins = array('all' => $all_plugins);
     $screen = $this->screen;
     // set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
     // 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 );
     // 		// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
     // 		if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
     // 			$plugins['upgrade'][ $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 );
     // 		// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
     // 		if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
     // 			$plugins['upgrade'][ $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
         $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'), 999);
     $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));
 }
示例#17
0
 public function prepare_items()
 {
     global $orderby, $order, $totals, $status;
     $order = 'DESC';
     $page = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
     $orderby = 'Name';
     /**
      * 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()), 'update_enabled' => array(), 'update_disabled' => array(), 'automatic' => array());
     $screen = $this->screen;
     $plugin_info = get_site_transient('update_plugins');
     $plugin_options = MPSUM_Updates_Manager::get_options('plugins');
     $plugin_automatic_options = MPSUM_Updates_Manager::get_options('plugins_automatic');
     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);
         }
         if (false !== ($key = array_search($plugin_file, $plugin_options))) {
             $plugins['update_disabled'][$plugin_file] = $plugin_data;
         } else {
             $plugins['update_enabled'][$plugin_file] = $plugin_data;
             if (in_array($plugin_file, $plugin_automatic_options)) {
                 $plugins['automatic'][$plugin_file] = $plugin_data;
             }
         }
     }
     $totals = array();
     foreach ($plugins as $type => $list) {
         $totals[$type] = count($list);
     }
     //Disable the automatic updates view
     $core_options = MPSUM_Updates_Manager::get_options('core');
     if (isset($core_options['automatic_plugin_updates']) && 'individual' !== $core_options['automatic_plugin_updates']) {
         unset($totals['automatic']);
         $plugins['automatic'] = array();
     }
     if (empty($plugins[$status])) {
         $status = 'all';
     }
     $this->items = array();
     foreach ($plugins[$status] as $plugin_file => $plugin_data) {
         // Translate, Don't Apply Markup, Sanitize HTML
         remove_action("after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2);
         $this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $total_this_page = $totals[$status];
     $plugins_per_page = 999;
     $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));
 }
示例#18
0
 function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $page = $this->get_pagenum();
     $plugins = array('all' => apply_filters('all_plugins', get_plugins()), 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array());
     if (!is_multisite() || is_network_admin() && 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();
         }
     }
     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);
     $current = get_site_transient('update_plugins');
     foreach (array('all', 'mustuse', 'dropins') as $type) {
         foreach ((array) $plugins[$type] as $plugin_file => $plugin_data) {
             // Translate, Apply Markup, Sanitize HTML
             $plugins[$type][$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
         }
     }
     foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
         // Filter into individual sections
         if (is_plugin_active_for_network($plugin_file) && !is_network_admin()) {
             unset($plugins['all'][$plugin_file]);
             continue;
         } elseif (is_multisite() && is_network_only_plugin($plugin_file) && !current_user_can('manage_network_plugins')) {
             $plugins['network'][$plugin_file] = $plugin_data;
         } elseif (is_plugin_active($plugin_file)) {
             $plugins['active'][$plugin_file] = $plugin_data;
         } else {
             if (!is_network_admin() && isset($recently_activated[$plugin_file])) {
                 // Was the plugin recently activated?
                 $plugins['recently_activated'][$plugin_file] = $plugin_data;
             }
             $plugins['inactive'][$plugin_file] = $plugin_data;
         }
         if (isset($current->response[$plugin_file])) {
             $plugins['upgrade'][$plugin_file] = $plugin_data;
         }
     }
     if (!current_user_can('update_plugins')) {
         $plugins['upgrade'] = array();
     }
     if ($s) {
         function _search_plugins_filter_callback($plugin)
         {
             static $term;
             if (is_null($term)) {
                 $term = stripslashes($_REQUEST['s']);
             }
             foreach ($plugin as $value) {
                 if (stripos($value, $term) !== false) {
                     return true;
                 }
             }
             return false;
         }
         $status = 'search';
         $plugins['search'] = array_filter($plugins['all'], '_search_plugins_filter_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 = $plugins[$status];
     $total_this_page = $totals[$status];
     if ($orderby) {
         $orderby = ucfirst($orderby);
         $order = strtoupper($order);
         function _order_plugins_callback($plugin_a, $plugin_b)
         {
             global $orderby, $order;
             $a = $plugin_a[$orderby];
             $b = $plugin_b[$orderby];
             if ($a == $b) {
                 return 0;
             }
             if ('DESC' == $order) {
                 return $a < $b ? 1 : -1;
             } else {
                 return $a < $b ? -1 : 1;
             }
         }
         uasort($this->items, '_order_plugins_callback');
     }
     $plugins_per_page = (int) get_user_option('plugins_per_page');
     if (empty($plugins_per_page) || $plugins_per_page < 1) {
         $plugins_per_page = 999;
     }
     $plugins_per_page = apply_filters('plugins_per_page', $plugins_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));
 }
示例#19
0
/**
 * Parses the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 * /*
 * Plugin Name: Name of Plugin
 * Plugin URI: Link to plugin information
 * Description: Plugin Description
 * Author: Plugin author's name
 * Author URI: Link to the author's web site
 * Version: Plugin version value.
 * Text Domain: Optional. Unique identifier, should be same as the one used in
 * load_plugin_textdomain()
 *
 * The first 8kB of the file will be pulled in and if the plugin data is not
 * within that first 8kB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @since 6.2.3
 *       
 * @param string $plugin_file
 *            Path to the plugin file
 * @param bool $markup
 *            Optional. If the returned data should have HTML markup applied.
 *            Default true.
 * @param bool $translate
 *            Optional. If the returned data should be translated. Default true.
 * @return array {
 *         Plugin data. Values will be empty if not supplied by the plugin.
 *        
 *         @type string $Name Name of the plugin. Should be unique.
 *         @type string $Title Title of the plugin and link to the plugin's site (if set).
 *         @type string $Description Plugin description.
 *         @type string $Author Author's name.
 *         @type string $AuthorURI Author's website address (if set).
 *         @type string $Version Plugin version.
 *         @type string $TextDomain Plugin textdomain.
 *         @type string $DomainPath Plugins relative directory path to .mo files.
 *         @type bool $Network Whether the plugin can only be activated network-wide.
 *         }
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain');
    $plugin_data = etsis_get_file_data($plugin_file, $default_headers, 'plugin');
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    } else {
        $plugin_data['Title'] = $plugin_data['Name'];
        $plugin_data['AuthorName'] = $plugin_data['Author'];
    }
    return $plugin_data;
}
/**
 * Get all add-ons for LearnPress has installed
 * Identify a plugin is an add-on if it is already existing a tag 'learnpress' inside
 *
 * @param array $options
 *
 * @return mixed|string|void
 */
function learn_press_get_add_ons($options = array())
{
    $plugins = array();
    if (!function_exists('get_plugins')) {
        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    }
    /*
     * Delete cache so hook for extra plugin headers works
     */
    wp_cache_delete('plugins', 'plugins');
    $all_plugins = get_plugins();
    if ($all_plugins) {
        $wp_plugins = learn_press_get_add_ons_from_wp();
        foreach ($all_plugins as $plugin_file => $plugin_data) {
            if (!empty($plugin_data['Tags'])) {
                $tags = preg_split('/\\s*,\\s*/', $plugin_data['Tags']);
                if (!in_array('learnpress', $tags)) {
                    continue;
                }
                $plugin_slug = dirname($plugin_file);
                if (isset($wp_plugins[$plugin_slug])) {
                    $plugins[$plugin_file] = (array) $wp_plugins[$plugin_slug];
                    $plugins[$plugin_file]['source'] = 'wp';
                } else {
                    $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
                    $plugins[$plugin_file] = array('name' => $plugin_data['Name'], 'slug' => $plugin_slug, 'version' => $plugin_data['Version'], 'author' => sprintf('<a href="%s">%s</a>', $plugin_data['AuthorURI'], $plugin_data['Author']), 'author_profile' => '', 'contributors' => array(), 'homepage' => $plugin_data['PluginURI'], 'short_description' => $plugin_data['Description'], 'icons' => array('2x' => LP_PLUGIN_URL . '/assets/images/icon-128x128.png', '1x' => LP_PLUGIN_URL . '/assets/images/icon-128x128.png'));
                    if (!empty($plugin_data['Requires at least'])) {
                        $plugins[$plugin_file]['requires'] = $plugin_data['Requires at least'];
                    }
                    if (!empty($plugin_data['Tested up to'])) {
                        $plugins[$plugin_file]['tested'] = $plugin_data['Tested up to'];
                    }
                    if (!empty($plugin_data['Last updated'])) {
                        $plugins[$plugin_file]['last_updated'] = $plugin_data['Last updated'];
                    }
                }
            }
        }
    }
    return $plugins;
}
示例#21
0
function capa_sublevel_support()
{
    // Check if POST isnt empty
    $_POST ? capa_handle_action() : NULL;
    echo '<div class="wrap">';
    // For WP < 27
    echo function_exists('screen_icon') ? screen_icon('edit-comments') : NULL;
    echo '<h2 style="margin-bottom:15px;">' . __('CaPa &raquo; CaPa Support', 'capa') . '</h2>';
    echo '<h3>' . __('Information to provide a faster way to help you.', 'capa') . '</h3>';
    echo __('Information will be send per e-mail. A Copy goes to the Sender E-Mail.', 'capa');
    echo '<br><br>';
    $all_plugins = get_plugins();
    $active_plugins = array();
    $categorys = get_categories(array('sort_column' => 'menu_order', 'hide_empty' => 0, 'child_of' => 0, 'hierarchical' => 0));
    $pages =& get_pages(array('sort_column' => 'menu_order'));
    foreach ($categorys as $cat) {
        $lvl['cat'][$cat->category_parent][] = $cat->term_id;
    }
    $lvl['cat'] = serialize($lvl['cat']);
    foreach ($pages as $id => $pag) {
        $lvl['pag'][$pag->post_parent][] = $pag->ID;
    }
    $lvl['pag'] = serialize($lvl['pag']);
    foreach ((array) $all_plugins as $plugin_file => $plugin_data) {
        //Translate, Apply Markup, Sanitize HTML
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
        $all_plugins[$plugin_file] = $plugin_data;
        //Filter into individual sections
        if (is_plugin_active($plugin_file)) {
            $active_plugins[$plugin_file] = $plugin_data;
        }
    }
    echo '<form name="capa_protect" method="post">';
    echo '
				<table class="form-table capa-form-table">
				<tr valign="top">
					<th scope="row" style="font-size:11px;">';
    echo '<b>' . __('@Active Plugins', 'capa') . '</b><br>' . __('To avoid Problems between CaPa and others Plugins. All active plugins will be displayed.', 'capa');
    echo '<br><br>';
    echo '<b>' . __('@Serialize Categories ID&#39;s', 'capa') . '</b><br>' . __('Serialize Categories contains only the Categories ID&#39;s in menu order', 'capa');
    echo '<br><br>';
    echo '<b>' . __('@Serialize Pages ID&#39;s', 'capa') . '</b><br>' . __('Serialize Pages contains only the Pages ID&#39;s in menu order', 'capa');
    echo '<br><br>';
    echo '<b>' . __('@CaPa Settings', 'capa') . '</b><br>' . __('All CaPa Settings', 'capa');
    echo '<br><br>';
    echo __('In the case you don&#39;t want send all Information, just remove the part&#39;s.', 'capa');
    echo '</th>
					<td><textarea class="large-text code" rows="20" name="information">';
    echo __('@Wordpress', 'capa') . "\n\n";
    echo __('Version:', 'capa') . ' ' . get_bloginfo('version') . "\n";
    echo __('PHP Version:', 'capa') . ' ' . phpversion() . "\n";
    echo "\n\n";
    echo __('@Active Plugins', 'capa') . "\n\n";
    $i = 1;
    foreach ($active_plugins as $plugin) {
        echo '[' . $i . '] ' . $plugin['Name'] . " (" . $plugin['Version'] . ")\n" . $plugin['PluginURI'] . "\n\n";
        $i++;
    }
    echo "\n";
    echo __('@Serialize Categories ID&#39;s', 'capa') . "\n\n";
    echo $lvl['cat'];
    echo "\n\n\n";
    echo __('@Serialize Pages ID&#39;s', 'capa') . "\n\n";
    echo $lvl['pag'];
    echo "\n\n\n";
    echo __('@CaPa Settings', 'capa') . "\n\n";
    global $wpdb;
    $_capa_settings = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'capa%'");
    foreach ($_capa_settings as $setting) {
        echo $setting->option_name . ":\n '";
        echo $setting->option_value . "'\n\n";
    }
    echo '</textarea>
					</td>
				</tr>
				<tr>
					<th style="font-size:11px;">';
    echo '<b>' . __('Title', 'capa') . '</b>';
    echo '	</th>
					<td valign="top">';
    echo '<input type="text" name="titel" value="Help Info from ' . get_option('blogname') . '" class="regular-text">';
    echo '<span class="description"> ' . __('You can change the Title as you wish.', 'capa') . '</span>';
    echo '	</td>
				</tr>

				<tr>
					<th style="font-size:11px;">';
    echo '<b>' . __('Sender', 'capa') . '</b>';
    echo '	</th>
					<td valign="top">';
    echo '<input type="text" name="sender" value="' . get_option('admin_email') . '" class="regular-text">';
    echo '<span class="description"> ' . __('You can change the Sender E-Mail.', 'capa') . '</span>';
    echo '	</td>
				</tr>
				<tr>
					<th style="font-size:11px;">';
    echo '<b>' . __('Comment (Optional)', 'capa') . '</b>';
    echo '	</th>
					<td valign="top">';
    echo '<textarea class="large-text code" name="comment" rows="5"></textarea>';
    echo '	</td>
				</tr>
				</table>';
    echo '
				<p class="submit" style="float:left; margin-right:10px;">
					<button type="submit" name="submit" class="button-primary" value="Send Help">' . __('Send Help', 'capa') . '</button>
				</p>
				</form>';
    echo '</div>';
}
示例#22
0
 public function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $columns = $this->get_columns();
     $hidden = $this->get_hidden_columns();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     /**
      * 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' => learn_press_get_add_ons(), 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array());
     $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);
     }
     //$this->items = learn_press_get_add_ons();
     //$this->items = $plugins;// array_slice( $this->items, $start, $plugins_per_page );
 }
 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
         $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'), 999);
     $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));
 }
示例#24
0
文件: plugins.php 项目: Plego/toyoa
         $plugin_info[$plugin] = $data;
         $plugin_info[$plugin]['is_uninstallable'] = is_uninstallable_plugin($plugin);
         if (!$plugin_info[$plugin]['Network']) {
             $have_non_network_plugins = true;
         }
     }
 } else {
     // Locate all the files in that folder.
     $files = list_files(WP_PLUGIN_DIR . '/' . $plugin_slug);
     if ($files) {
         $files_to_delete = array_merge($files_to_delete, $files);
     }
     // Get plugins list from that folder.
     if ($folder_plugins = get_plugins('/' . $plugin_slug)) {
         foreach ($folder_plugins as $plugin_file => $data) {
             $plugin_info[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $data);
             $plugin_info[$plugin_file]['is_uninstallable'] = is_uninstallable_plugin($plugin);
             if (!$plugin_info[$plugin_file]['Network']) {
                 $have_non_network_plugins = true;
             }
         }
     }
     // Add translation files.
     if (!empty($plugin_translations[$plugin_slug])) {
         $translations = $plugin_translations[$plugin_slug];
         foreach ($translations as $translation => $data) {
             $files_to_delete[] = $plugin_slug . '-' . $translation . '.po';
             $files_to_delete[] = $plugin_slug . '-' . $translation . '.mo';
         }
     }
 }
示例#25
0
/**
 * @param array $options
 *
 * @return mixed|string|void
 */
function learn_press_get_add_ons($options = array())
{
    $plugins = array();
    if (!function_exists('get_plugins')) {
        require_once ABSPATH . '/wp-admin/includes/plugin.php';
    }
    /*
     * Delete cache so hook for extra plugin headers works
     * Do not know why it worked before but now is not
     */
    wp_cache_delete('plugins', 'plugins');
    $all_plugins = get_plugins();
    if ($all_plugins) {
        foreach ($all_plugins as $plugin_file => $plugin_data) {
            if (!empty($plugin_data['Tags']) && preg_match('!learnpress!', $plugin_data['Tags'])) {
                $plugins[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
                $plugins[$plugin_file]['Icons'] = array('2x' => LPR_PLUGIN_URL . '/assets/images/icon-128x128.png', '1x' => LPR_PLUGIN_URL . '/assets/images/icon-128x128.png');
                $plugins[$plugin_file]['rating'] = 0;
                $plugins[$plugin_file]['num_ratings'] = 0;
                $plugins[$plugin_file]['tested'] = null;
                $plugins[$plugin_file]['requires'] = null;
                $plugins[$plugin_file]['active_installs'] = 0;
                $plugins[$plugin_file]['last_updated'] = gmdate('Y-m-d h:iA', strtotime('last Friday', current_time('timestamp'))) . ' GMT';
            }
        }
    }
    return $plugins;
    $defaults = array('show_required' => true);
    $options = wp_parse_args($options, $defaults);
    if (empty($GLOBALS['learn_press']['add_ons']['registered'])) {
        return array();
    } else {
        $add_ons = $GLOBALS['learn_press']['add_ons']['registered'];
    }
    // Loop through addons and filter out required if not set to show.
    foreach ($add_ons as $key => $addon) {
        if (!$options['show_required'] && !empty($addon['options']['tag']) && 'required' === $addon['options']['tag']) {
            unset($add_ons[$key]);
        }
    }
    ksort($add_ons);
    return apply_filters('learn_press_get_addons', $add_ons, $options);
}