本文整理汇总了PHP中Jetpack::get_active_plugins方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::get_active_plugins方法的具体用法?PHP Jetpack::get_active_plugins怎么用?PHP Jetpack::get_active_plugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::get_active_plugins方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_protect_key
/**
* Request an api key from wordpress.com
*
* @return bool | string
*/
public function get_protect_key()
{
$protect_blog_id = Jetpack_Protect_Module::get_main_blog_jetpack_id();
// If we can't find the the blog id, that means we are on multisite, and the main site never connected
// the protect api key is linked to the main blog id - instruct the user to connect their main blog
if (!$protect_blog_id) {
$this->api_key_error = __('Your main blog is not connected to WordPress.com. Please connect to get an API key.', 'jetpack');
return false;
}
$request = array('jetpack_blog_id' => $protect_blog_id, 'bruteprotect_api_key' => get_site_option('bruteprotect_api_key'), 'multisite' => '0');
// Send the number of blogs on the network if we are on multisite
if (is_multisite()) {
$request['multisite'] = get_blog_count();
if (!$request['multisite']) {
global $wpdb;
$request['multisite'] = $wpdb->get_var("SELECT COUNT(blog_id) as c FROM {$wpdb->blogs} WHERE spam = '0' AND deleted = '0' and archived = '0'");
}
}
// Request the key
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client(array('user_id' => get_current_user_id()));
$xml->query('jetpack.protect.requestKey', $request);
// Hmm, can't talk to wordpress.com
if ($xml->isError()) {
$code = $xml->getErrorCode();
$message = $xml->getErrorMessage();
$this->api_key_error = sprintf(__('Error connecting to WordPress.com. Code: %1$s, %2$s', 'jetpack'), $code, $message);
return false;
}
$response = $xml->getResponse();
// Hmm. Can't talk to the protect servers ( api.bruteprotect.com )
if (!isset($response['data'])) {
$this->api_key_error = __('No reply from Jetpack servers', 'jetpack');
return false;
}
// There was an issue generating the key
if (empty($response['success'])) {
$this->api_key_error = $response['data'];
return false;
}
// Key generation successful!
$active_plugins = Jetpack::get_active_plugins();
// We only want to deactivate BruteProtect if we successfully get a key
if (in_array('bruteprotect/bruteprotect.php', $active_plugins)) {
Jetpack_Client_Server::deactivate_plugin('bruteprotect/bruteprotect.php', 'BruteProtect');
}
$key = $response['data'];
update_site_option('jetpack_protect_key', $key);
return $key;
}
示例2: get_parsed_plugin_data
/**
* Gets and parses additional plugin data to send with the heartbeat data
*
* @since 3.8.1
*
* @return array Array of plugin data
*/
public static function get_parsed_plugin_data()
{
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
/** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
$all_plugins = apply_filters('all_plugins', get_plugins());
$active_plugins = Jetpack::get_active_plugins();
$plugins = array();
foreach ($all_plugins as $path => $plugin_data) {
$plugins[$path] = array('is_active' => in_array($path, $active_plugins), 'file' => $path, 'name' => $plugin_data['Name'], 'version' => $plugin_data['Version'], 'author' => $plugin_data['Author']);
}
return $plugins;
}
示例3: get_parsed_plugin_data
/**
* Gets and parses additional plugin data to send with the heartbeat data
*
* @since 3.8.1
*
* @return array Array of plugin data
*/
public static function get_parsed_plugin_data()
{
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = get_plugins();
$active_plugins = Jetpack::get_active_plugins();
$plugins = array();
foreach ($all_plugins as $path => $plugin_data) {
$plugins[$path] = array('is_active' => in_array($path, $active_plugins), 'file' => $path, 'name' => $plugin_data['Name'], 'version' => $plugin_data['Version'], 'author' => $plugin_data['Author']);
}
return $plugins;
}
示例4: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == sizeof($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
$return["{$prefix}ip-3-octets"] = implode('.', array_slice($ip_arr, 0, 3));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例5: deactivate_plugin
public static function deactivate_plugin($probable_file, $probable_title)
{
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if (is_plugin_active($probable_file)) {
deactivate_plugins($probable_file);
return 1;
} else {
// If the plugin is not in the usual place, try looking through all active plugins.
$active_plugins = Jetpack::get_active_plugins();
foreach ($active_plugins as $plugin) {
$data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
if ($data['Name'] == $probable_title) {
deactivate_plugins($plugin);
return 1;
}
}
}
return 0;
}
示例6: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}public"] = Jetpack_Options::get_option('public');
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}is-https"] = is_ssl() ? 'https' : 'http';
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
$return["{$prefix}single-user-site"] = Jetpack::is_single_user_site();
$return["{$prefix}manage-enabled"] = Jetpack::is_module_active('manage');
// is-multi-network can have three values, `single-site`, `single-network`, and `multi-network`
$return["{$prefix}is-multi-network"] = 'single-site';
if (is_multisite()) {
$return["{$prefix}is-multi-network"] = Jetpack::is_multi_network() ? 'multi-network' : 'single-network';
}
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == count($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例7: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}public"] = Jetpack_Options::get_option('public');
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
switch (Jetpack_Options::get_option('json_api_full_management', null)) {
case null:
$return["{$prefix}full_manage"] = 'unset';
break;
case false:
$return["{$prefix}full_manage"] = 'false';
break;
case true:
$return["{$prefix}full_manage"] = 'true';
break;
default:
$return["{$prefix}full_manage"] = Jetpack_Options::get_option('json_api_full_management', null);
}
if (!Jetpack_Options::get_option('public')) {
// Also flag things as private since we don't provide the user with option to easy opt into if the site is private
$return["{$prefix}full_manage"] = 'private-' . $return["{$prefix}full_manage"];
}
// is-multi-network can have three values, `single-site`, `single-network`, and `multi-network`
$return["{$prefix}is-multi-network"] = 'single-site';
if (is_multisite()) {
$return["{$prefix}is-multi-network"] = Jetpack::is_multi_network() ? 'multi-network' : 'single-network';
}
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == count($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
$return["{$prefix}ip-3-octets"] = implode('.', array_slice($ip_arr, 0, 3));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例8: get_parsed_plugin_data
/**
* Gets and parses additional plugin data to send with the heartbeat data
*
* @since 3.8.1
*
* @return array Array of plugin data
*/
public static function get_parsed_plugin_data()
{
$all_plugins = get_plugins();
$active_plugins = Jetpack::get_active_plugins();
$plugins = array();
foreach ($all_plugins as $path => $plugin_data) {
$plugins[$path] = array('is_active' => in_array($path, $active_plugins), 'file' => $path, 'name' => $plugin_data['Name'], 'version' => $plugin_data['Version'], 'author' => $plugin_data['Author']);
}
return $plugins;
}