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


PHP get_plugins函数代码示例

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


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

示例1: cs_get_path_locate

 function cs_get_path_locate()
 {
     if (!function_exists('get_plugins') || !function_exists('is_plugin_active')) {
         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     foreach (get_plugins() as $key => $value) {
         if (strpos($key, 'cs-framework.php') !== false) {
             if (is_plugin_active($key)) {
                 $basename = '/' . str_replace('/cs-framework.php', '', $key);
                 $dir = WP_PLUGIN_DIR . $basename;
                 $uri = WP_PLUGIN_URL . $basename;
             }
         }
     }
     if (!isset($basename)) {
         $dirname = wp_normalize_path(dirname(__FILE__));
         $plugin_dir = wp_normalize_path(WP_PLUGIN_DIR);
         $located_plugin = preg_match('#' . $plugin_dir . '#', $dirname) ? true : false;
         $directory = $located_plugin ? $plugin_dir : get_template_directory();
         $directory_uri = $located_plugin ? WP_PLUGIN_URL : get_template_directory_uri();
         $basename = str_replace(wp_normalize_path($directory), '', $dirname);
         $dir = $directory . $basename;
         $uri = $directory_uri . $basename;
     }
     return apply_filters('cs_get_path_locate', array('basename' => wp_normalize_path($basename), 'dir' => wp_normalize_path($dir), 'uri' => $uri));
 }
开发者ID:xmandxx,项目名称:Teahouse-Wordpress-Theme,代码行数:26,代码来源:cs-framework-path.php

示例2: get_plugin_version

function get_plugin_version($author)
{
    require_once ABSPATH . '/wp-admin/includes/plugin.php';
    if ($author !== '') {
        $plugin_author = $author;
    } else {
        $plugin_author = '*';
    }
    $plugins = get_plugins();
    $plugins_allowedtags1 = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array());
    foreach ($plugins as $plugin_file => $plugin_data) {
        $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags1);
        $plugin_data['Title'] = $plugin_data['PluginURI'] ? '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Title'] . '</a>' : $plugin_data['Title'];
        $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags1);
        $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags1);
        $plugin_data['Author'] = empty($plugin_data['Author']) ? '' : ' <cite>' . sprintf(__('%s', 'wp-list-plugins'), $plugin_data['AuthorURI'] ? '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>' : $plugin_data['Author']) . '.</cite>';
        $local_version = $plugin_data['Version'];
        //    $local_version='0.5';
        if (strpos($plugin_data['Author'], $plugin_author) == true || strpos($plugin_data['Name'], 'Rob') == true || $author == '') {
            $var_sHtml .= "<li>{$plugin_data['Title']} (v. {$plugin_data['Version']} ) By {$plugin_data['Author']}.</li>";
            $p_arr = explode("/", $plugin_file);
            $p_file = $p_arr[0];
            compare_versions($p_file, $local_version);
        }
        $var_iPlugInNumber++;
    }
    if (is_admin()) {
        echo $var_sHtml;
    }
    return $var_sHtml;
}
开发者ID:roblandry,项目名称:check-my-version,代码行数:31,代码来源:check-plugin.php

示例3: pl_get_plugins

 /**
  * Get plugins and optionally filter out WP plugins
  */
 static function pl_get_plugins($filter = false, $pro = false)
 {
     $default_headers = array('Version' => 'Version', 'PageLines' => 'PageLines', 'Plugin Name' => 'Plugin Name', 'Description' => 'Description', 'Version' => 'Version', 'Category' => 'Category');
     include_once ABSPATH . 'wp-admin/includes/plugin.php';
     $plugins = get_plugins();
     if (!$filter) {
         return $plugins;
     }
     // get the headers for each plugin file
     foreach ($plugins as $path => $data) {
         $fullpath = sprintf('%s%s', trailingslashit(WP_PLUGIN_DIR), $path);
         $plugins[$path] = get_file_data($fullpath, $default_headers);
     }
     // if the headers do not contain 'PageLines' then unset from the array and let WP handle them
     foreach ($plugins as $path => $data) {
         if (!$data['PageLines']) {
             unset($plugins[$path]);
         }
     }
     // only look for pro plugins
     if ($pro) {
         foreach ($plugins as $path => $data) {
             $cats = array_map('trim', explode(',', $data['Category']));
             if (!array_search('pro', $cats)) {
                 unset($plugins[$path]);
             }
         }
         return $plugins;
     }
     return $plugins;
 }
开发者ID:voomco,项目名称:WordPress,代码行数:34,代码来源:functions.connect.php

示例4: register

 /**
  * Main plugin Instance
  *
  * @param $plugin_slug | string The plugin slug
  * @param $plugin_init | string The plugin init file
  *
  * @return void
  *
  * @since  1.0
  * @author Andrea Grillo <andrea.grillo@yithemes.com>
  */
 public function register($plugin_slug, $plugin_init)
 {
     if (!function_exists('get_plugins')) {
         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $plugins = get_plugins();
     $plugin_info = $plugins[$plugin_init];
     $this->_plugins[$plugin_init] = array('info' => $plugin_info, 'slug' => $plugin_slug);
     /* === HOOKS === */
     if (!is_multisite() || is_plugin_active_for_network($plugin_init)) {
         add_action('admin_init', array($this, 'remove_wp_plugin_update_row'), 15);
         add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
     } else {
         if (is_multisite() && current_user_can('update_plugins')) {
             $xml = str_replace('%plugin_slug%', $plugin_slug, $this->_xml);
             $remote_xml = wp_remote_get($xml);
             if (!is_wp_error($remote_xml) && isset($remote_xml['response']['code']) && '200' == $remote_xml['response']['code']) {
                 $plugin_remote_info = new SimpleXmlElement($remote_xml['body']);
                 $this->_plugins[$plugin_init]['info']['Latest'] = (string) $plugin_remote_info->latest;
                 $this->_plugins[$plugin_init]['info']['changelog'] = (string) $plugin_remote_info->changelog;
                 add_action('admin_enqueue_scripts', array($this, 'multisite_updater_script'));
             }
         }
     }
 }
开发者ID:lieison,项目名称:IndustriasFenix,代码行数:36,代码来源:yit-upgrade.php

示例5: get_modules

 /**
  * Retrieve a list of all installed BLC modules.
  * 
  * This is essentially a slightly modified copy of get_plugins().
  * 
  * @return array An associative array of module headers indexed by module ID.
  */
 function get_modules()
 {
     if (!isset($this->_module_cache)) {
         //Refresh the module cache.
         $relative_path = '/' . plugin_basename($this->module_dir);
         if (!function_exists('get_plugins')) {
             //BUG: Potentional security flaw/bug. plugin.php is not meant to be loaded outside admin panel.
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
         }
         $modules = get_plugins($relative_path);
         $this->_module_cache = array();
         foreach ($modules as $module_filename => $module_header) {
             //Figure out the module ID. If not specified, it is equal to module's filename (sans the .php)
             if (!empty($module_header['ModuleID'])) {
                 $module_id = strtolower(trim($module_header['ModuleID']));
             } else {
                 $module_id = strtolower(basename($module_filename, '.php'));
             }
             $module_header = $this->normalize_module_header($module_header, $module_id, $module_filename);
             $this->_module_cache[$module_id] = $module_header;
         }
         $this->_category_cache = null;
     }
     return array_merge($this->_module_cache, $this->_virtual_modules);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:32,代码来源:module-manager.php

示例6: incompatible_plugins

 /**
  * @param	array	list of names of incompatible plugins
  * @return	null	CCTM::$warnings gets populated if errors are detected.
  */
 public static function incompatible_plugins($incompatible_plugins)
 {
     require_once ABSPATH . '/wp-admin/includes/admin.php';
     $all_plugins = get_plugins();
     $active_plugins = get_option('active_plugins');
     $plugin_list = array();
     foreach ($incompatible_plugins as $bad_plugin) {
         foreach ($active_plugins as $plugin) {
             if ($all_plugins[$plugin]['Name'] == $bad_plugin) {
                 $plugin_list[] = $bad_plugin;
             }
         }
     }
     if (!empty($plugin_list)) {
         $exit_msg = sprintf(__('%1$s has detected that there are some active plugins that may be incompatible with it. We recommend disabling the following plugins:', CCTM_TXTDOMAIN), '<strong>' . CCTM::name . '</strong>');
         $exit_msg .= '<ul>';
         foreach ($plugin_list as $p) {
             $exit_msg .= '<li><strong>' . $p . '</strong></li>';
         }
         $exit_msg .= '</ul>';
         $exit_msg .= sprintf(__('Continued use of these plugins may cause erratic behavior and certain functionality on your site may break entirely. See the <a href="http://code.google.com/p/wordpress-custom-content-type-manager/wiki/IncompatiblePlugins">wiki</a> for more information.', CCTM_TXTDOMAIN));
     }
     if (!empty($exit_msg)) {
         CCTM::$warnings[] = $exit_msg;
     }
 }
开发者ID:ethaizone,项目名称:custom-content-type-manager,代码行数:30,代码来源:CCTMtests.php

示例7: req_notices

 private function req_notices()
 {
     // check that ngfb pro has an authentication id
     $lca = $this->p->cf['lca'];
     if ($this->p->is_avail['aop'] === true && empty($this->p->options['plugin_' . $lca . '_tid']) && (empty($this->p->options['plugin_' . $lca . '_tid:is']) || $this->p->options['plugin_' . $lca . '_tid:is'] !== 'disabled')) {
         $this->p->notice->nag($this->p->msgs->get('pro-activate-msg'));
     }
     // check all *active* plugins / extensions to make sure pro version is installed
     $has_tid = false;
     foreach ($this->p->cf['plugin'] as $lca => $info) {
         if (!empty($this->p->options['plugin_' . $lca . '_tid']) && isset($info['base']) && NgfbUtil::active_plugins($info['base'])) {
             $has_tid = true;
             if (!$this->p->check->aop($lca, false)) {
                 $this->p->notice->inf($this->p->msgs->get('pro-not-installed', array('lca' => $lca)), true);
             }
         }
     }
     // if we have at least one tid, make sure the update manager is installed
     if ($has_tid === true && !$this->p->is_avail['util']['um']) {
         if (!function_exists('get_plugins')) {
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
         }
         $installed_plugins = get_plugins();
         if (!empty($this->p->cf['plugin']['ngfbum']['base']) && is_array($installed_plugins[$this->p->cf['plugin']['ngfbum']['base']])) {
             $this->p->notice->nag($this->p->msgs->get('pro-um-activate-extension'), true);
         } else {
             $this->p->notice->nag($this->p->msgs->get('pro-um-extension-required'), true);
         }
     }
 }
开发者ID:jamesvillarrubia,项目名称:uniken-web,代码行数:30,代码来源:admin.php

示例8: status

 public function status()
 {
     if ($this->_status) {
         return $this->_status;
     }
     $info = get_plugins();
     $installed = array_flip(wp_list_pluck($info, 'PluginURI'));
     foreach ($this->plugins as $plugin) {
         $slug = $plugin->slug;
         $stat["link"] = false;
         if (isset($installed[$slug])) {
             $file = $installed[$slug];
             $this->installed[$file] = true;
             $stat["file"] = $file;
             $stat["version"] = $info[$file]["Version"];
             if (is_plugin_active($file)) {
                 // active
                 $stat["status"] = "active";
             } else {
                 // installed
                 $stat["status"] = "installed";
                 $stat["link"] = wp_nonce_url(self_admin_url("plugins.php?action=activate&peredirect=1&plugin={$file}"), "activate-plugin_{$file}");
             }
         } else {
             // not installed
             $stat["status"] = "not-installed";
             $stat["link"] = wp_nonce_url(self_admin_url("update.php?action=install-plugin&peredirect=1&plugin={$slug}"), "install-plugin_{$slug}");
         }
         $res[$slug] = (object) $stat;
     }
     // cache result
     $this->_status = $res;
     return $res;
 }
开发者ID:JeffreyBue,项目名称:jb,代码行数:34,代码来源:class-pixelentity-theme-bundled-plugins.php

示例9: wp_required_plugins

 public static function wp_required_plugins($required_plugins)
 {
     require_once ABSPATH . '/wp-admin/includes/admin.php';
     $all_plugins = get_plugins();
     $active_plugins = get_option('active_plugins');
     // Re-index the $all_plugins array for easier testing.
     // We want to index it off of the name; it's not guaranteed to be unique, so this
     // test could throw some illigitimate errors if 2 plugins shared the same name.
     $all_plugins_reindexed = array();
     foreach ($all_plugins as $path => $data) {
         $new_index = $data['Name'];
         $all_plugins_reindexed[$new_index] = $data;
     }
     foreach ($required_plugins as $name => $version) {
         if (isset($all_plugins_reindexed[$name])) {
             if (!empty($all_plugins_reindexed[$name]['Version'])) {
                 if (version_compare($all_plugins_reindexed[$name]['Version'], $version, '<')) {
                     self::$errors[] = sprintf(__('%1$s requires version %$2% of the %3$s plugin.', CCTM::txtdomain), CCTM::name, $version, $name);
                 }
             }
         } else {
             $msg = sprintf(__('%1$s requires version %$2% of the %3$s plugin.', CCTM::txtdomain), CCTM::name, $version, $name);
             $msg .= ' ';
             $msg .= sprintf(__('The %1$s plugin is not installed.', CCTM::txtdomain), $name);
             self::$errors[] = $msg;
         }
     }
 }
开发者ID:feardax,项目名称:wordpress-custom-content-type-manager,代码行数:28,代码来源:CCTMtests.php

示例10: get_available_plugins

 /**
  * Query for our available plugins
  *
  * @since 1.0.0
  */
 public function get_available_plugins()
 {
     if (empty($this->available_plugins)) {
         $this->available_plugins = get_plugins();
     }
     return $this->available_plugins;
 }
开发者ID:nicoladj77,项目名称:WDS-Active-Plugin-Data,代码行数:12,代码来源:wds-active-plugin-data.php

示例11: external_plugins

 function external_plugins($plugins)
 {
     $default_headers = array('Demo' => 'Demo', 'External' => 'External', 'Long' => 'Long', 'PageLines' => 'PageLines', 'Depends' => 'Depends');
     if (is_multisite()) {
         return $plugins;
     }
     $ext_plugins = (array) get_plugins();
     foreach ($ext_plugins as $ext => $data) {
         $new_key = rtrim(str_replace(basename($ext), '', $ext), '/');
         unset($ext_plugins[$ext]);
         if (isset($plugins[$new_key]['plus_product']) && $plugins[$new_key]['plus_product'] && VPLUS) {
             $plugins[$new_key]['purchased'] = 'purchased';
         }
         if (!array_key_exists($new_key, $plugins)) {
             $a = get_file_data(WP_PLUGIN_DIR . '/' . $ext, $default_headers);
             if (!empty($a['PageLines']) && !empty($new_key)) {
                 $plugins[$new_key]['name'] = $data['Name'];
                 $plugins[$new_key]['slug'] = $new_key;
                 $plugins[$new_key]['text'] = $data['Description'];
                 $plugins[$new_key]['version'] = $data['Version'];
                 $plugins[$new_key]['author_url'] = $data['AuthorURI'];
                 $plugins[$new_key]['author'] = $data['Author'];
                 $plugins[$new_key]['count'] = 0;
                 $plugins[$new_key]['screen'] = false;
                 $plugins[$new_key]['extended'] = false;
                 $plugins[$new_key]['demo'] = $a['Demo'];
                 $plugins[$new_key]['external'] = $a['External'];
                 $plugins[$new_key]['long'] = $a['Long'];
                 $plugins[$new_key]['depends'] = $a['Depends'];
             }
         }
     }
     return $plugins;
 }
开发者ID:climo,项目名称:PageLines-Framework,代码行数:34,代码来源:class.extend.plugins.php

示例12: run

 public function run()
 {
     if (!function_exists('get_plugins')) {
         require_once \WP_CLI::get_config('path') . '/wp-admin/includes/plugin.php';
     }
     $all_plugins = get_plugins();
     $update = get_plugin_updates();
     $report = array();
     foreach ($all_plugins as $plugin_path => $data) {
         $slug = $plugin_path;
         if (stripos($plugin_path, '/')) {
             $slug = substr($plugin_path, 0, stripos($plugin_path, '/'));
         }
         $vulnerable = $this->is_vulnerable($slug, $data['Version']);
         $needs_update = 0;
         $available = '-';
         if (isset($update[$plugin_path])) {
             $needs_update = 1;
             $available = $update[$plugin_path]->update->new_version;
         }
         if (false === $vulnerable) {
             $vulnerable = "None";
         } else {
             $vulnerable = sprintf('<a href="https://wpvulndb.com/plugins/%s" target="_blank" >more info</a>', $slug);
         }
         $report[$slug] = array('slug' => $slug, 'installed' => (string) $data['Version'], 'available' => (string) $available, 'needs_update' => (string) $needs_update, 'vulnerable' => $vulnerable);
     }
     $this->alerts = $report;
 }
开发者ID:zepner,项目名称:wp_launch_check,代码行数:29,代码来源:plugins.php

示例13: __construct

 /**
  * Setup the activation class
  *
  * @param 		string $plugin_path The absolute path to the plugin's directory.
  * @param 		string $plugin_file The absolute path to the main plugin file.
  * @access      public
  * @since       1.0.0
  * @return      void
  */
 public function __construct($plugin_path, $plugin_file)
 {
     // We need plugin.php!
     require_once ABSPATH . 'wp-admin/includes/plugin.php';
     $plugins = get_plugins();
     // Set plugin directory
     $plugin_path = array_filter(explode('/', $plugin_path));
     $this->plugin_path = end($plugin_path);
     // Set plugin file
     $this->plugin_file = $plugin_file;
     // Set plugin name
     $plugin_file_path = $this->plugin_path . '/' . $this->plugin_file;
     if (isset($plugins[$plugin_file_path]['Name'])) {
         $this->plugin_name = str_replace('Charitable - ', '', $plugins[$plugin_file_path]['Name']);
     } else {
         $this->plugin_name = __('This plugin', 'charitable-extension-boilerplate');
     }
     // Is Charitable installed?
     foreach ($plugins as $plugin_path => $plugin) {
         if ('Charitable' == $plugin['Name']) {
             $this->has_charitable = true;
             $this->charitable_base = $plugin_path;
             break;
         }
     }
 }
开发者ID:Charitable,项目名称:Charitable-Extension-Boilerplate,代码行数:35,代码来源:class-charitable-extension-activation.php

示例14: plugin_activity_checker

/**
* function to check the status of the plugins
* @return array
*/
function plugin_activity_checker()
{
    // Check if get_plugins() function exists. This is required on the front end of the
    // site, since it is in a file that is normally only loaded in the admin.
    if (!function_exists('get_plugins')) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    // possible seo plugins
    $seo_plugins = array("wordpress-seo/wp-seo.php" => "Yoast");
    $active_plugins = get_option("active_plugins");
    $all_plugins = array_keys(get_plugins());
    // enabled, uploaded
    $plugin_status = [];
    foreach ($seo_plugins as $name => $title) {
        $plugin_enabled = false;
        $plugin_uploaded = false;
        if (in_array($name, $active_plugins)) {
            $plugin_enabled = true;
            $plugin_uploaded = true;
        } elseif (in_array($name, $all_plugins)) {
            $plugin_uploaded = true;
        }
        $plugin_status[$title] = array('plugin_enabled' => $plugin_enabled, 'plugin_uploaded' => $plugin_uploaded);
    }
    return $plugin_status;
}
开发者ID:tacowordpress,项目名称:taco-2016-boilerplate,代码行数:30,代码来源:functions-generic.php

示例15: check_for_updates

 /**
  * Modify update_plugins transient to notify WordPress
  * about which custom plugins should be updated.
  * 
  * @param stdClass $transient
  * @return stdClass
  */
 public static function check_for_updates($transient)
 {
     if (empty($transient)) {
         $transient = new stdClass();
     }
     if (!isset($transient->response)) {
         $transient->response = array();
     }
     $installed_plugins = get_plugins();
     foreach (self::$plugins as $plugin) {
         // Update only custom plugins.
         if (!isset($plugin['plugin_type']) || 'bundled' != $plugin['plugin_type']) {
             continue;
         }
         // If plugin is not installed, it can't updated.
         if (!isset($installed_plugins[$plugin['file_path']])) {
             continue;
         }
         // Check if there is a new version of this plugin available.
         if (!isset($plugin['version']) || version_compare($installed_plugins[$plugin['file_path']]['Version'], $plugin['version'], '>=')) {
             continue;
         }
         $transient->response[$plugin['file_path']] = new stdClass();
         $transient->response[$plugin['file_path']]->slug = $plugin['slug'];
         $transient->response[$plugin['file_path']]->new_version = $plugin['version'];
         $transient->response[$plugin['file_path']]->package = $plugin['source'];
     }
     return $transient;
 }
开发者ID:jeffreycai,项目名称:ct21,代码行数:36,代码来源:ib-bundled-plugins.php


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