本文整理汇总了PHP中Jetpack::is_active方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::is_active方法的具体用法?PHP Jetpack::is_active怎么用?PHP Jetpack::is_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::is_active方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_role_change
/**
* Synchronize connected user role changes
*/
static function user_role_change($user_id)
{
if (Jetpack::is_active() && Jetpack::is_user_connected($user_id)) {
$current_user_id = get_current_user_id();
wp_set_current_user($user_id);
$role = Jetpack::translate_current_user_to_role();
$signed_role = Jetpack::sign_role($role);
wp_set_current_user($current_user_id);
$master_token = Jetpack_Data::get_access_token(JETPACK_MASTER_USER);
$master_user_id = absint($master_token->external_user_id);
if (!$master_user_id) {
return;
}
// this shouldn't happen
Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role);
//@todo retry on failure
//try to choose a new master if we're demoting the current one
if ($user_id == $master_user_id && 'administrator' != $role) {
$query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id)));
$new_master = false;
foreach ($query->results as $result) {
$uid = absint($result->id);
if ($uid && Jetpack::is_user_connected($uid)) {
$new_master = $uid;
break;
}
}
if ($new_master) {
Jetpack_Options::update_option('master_user', $new_master);
}
// else disconnect..?
}
}
}
示例2: __construct
private function __construct()
{
if (!Jetpack::is_active() || self::is_jitm_dismissed()) {
return;
}
add_action('current_screen', array($this, 'prepare_jitms'));
}
示例3: init
static function init()
{
if (Jetpack::is_active()) {
// Kick off synchronization of user role when it changes
add_action('set_user_role', array(__CLASS__, 'user_role_change'));
}
}
示例4: format_module
protected static function format_module($module_slug)
{
$module_data = Jetpack::get_module($module_slug);
$module = array();
$module['id'] = $module_slug;
$module['active'] = Jetpack::is_module_active($module_slug);
$module['name'] = $module_data['name'];
$module['short_description'] = $module_data['description'];
$module['sort'] = $module_data['sort'];
$module['introduced'] = $module_data['introduced'];
$module['changed'] = $module_data['changed'];
$module['free'] = $module_data['free'];
$module['module_tags'] = $module_data['module_tags'];
// Fetch the HTML formatted long description
ob_start();
if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module_slug)) {
/** This action is documented in class.jetpack-modules-list-table.php */
do_action('jetpack_module_more_info_connected_' . $module_slug);
} else {
/** This action is documented in class.jetpack-modules-list-table.php */
do_action('jetpack_module_more_info_' . $module_slug);
}
$module['description'] = ob_get_clean();
return $module;
}
示例5: remote_authorize
function remote_authorize($request)
{
foreach (array('secret', 'state', 'redirect_uri', 'code') as $required) {
if (!isset($request[$required]) || empty($request[$required])) {
return $this->error(new Jetpack_Error('missing_parameter', 'One or more parameters is missing from the request.', 400));
}
}
if (!get_user_by('id', $request['state'])) {
return $this->error(new Jetpack_Error('user_unknown', 'User not found.', 404));
}
if (Jetpack::is_active() && Jetpack::is_user_connected($request['state'])) {
return $this->error(new Jetpack_Error('already_connected', 'User already connected.', 400));
}
$verified = $this->verify_action(array('authorize', $request['secret'], $request['state']));
if (is_a($verified, 'IXR_Error')) {
return $verified;
}
wp_set_current_user($request['state']);
$client_server = new Jetpack_Client_Server();
$result = $client_server->authorize($request);
if (is_wp_error($result)) {
return $this->error($result);
}
// Creates a new secret, allowing someone to activate the manage module for up to 1 day after authorization.
$secrets = Jetpack::init()->generate_secrets('activate_manage', DAY_IN_SECONDS);
@(list($secret) = explode(':', $secrets));
$response = array('result' => $result, 'activate_manage' => $secret);
return $response;
}
示例6: __construct
function __construct()
{
global $current_user;
$this->log('Created WP_Polldaddy Object: constructor');
$this->errors = new WP_Error();
$this->scheme = 'https';
$this->version = '2.0.22';
$this->multiple_accounts = true;
$this->polldaddy_client_class = 'api_client';
$this->polldaddy_clients = array();
$this->is_admin = (bool) current_user_can('manage_options');
$this->is_author = (bool) current_user_can('edit_posts');
$this->is_editor = (bool) current_user_can('delete_others_pages');
$this->user_code = null;
$this->rating_user_code = null;
$this->id = $current_user instanceof WP_User ? intval($current_user->ID) : 0;
$this->has_feedback_menu = false;
if (class_exists('Jetpack')) {
if (method_exists('Jetpack', 'is_active') && Jetpack::is_active()) {
$jetpack_active_modules = get_option('jetpack_active_modules');
if ($jetpack_active_modules && in_array('contact-form', $jetpack_active_modules)) {
$this->has_feedback_menu = true;
}
}
}
}
示例7: add_actions
function add_actions()
{
// If user is not an admin and site is in Dev Mode, don't do anything
if (!current_user_can('manage_options') && Jetpack::is_development_mode()) {
return;
}
// Don't add in the modules page unless modules are available!
if ($this->dont_show_if_not_active && !Jetpack::is_active() && !Jetpack::is_development_mode()) {
return;
}
// Initialize menu item for the page in the admin
$hook = $this->get_page_hook();
// Attach hooks common to all Jetpack admin pages based on the created
// hook
add_action("load-{$hook}", array($this, 'admin_help'));
add_action("load-{$hook}", array($this, 'admin_page_load'));
add_action("admin_head-{$hook}", array($this, 'admin_head'));
add_action("admin_print_styles-{$hook}", array($this, 'admin_styles'));
add_action("admin_print_scripts-{$hook}", array($this, 'admin_scripts'));
if (!self::$block_page_rendering_for_idc) {
add_action("admin_print_styles-{$hook}", array($this, 'additional_styles'));
}
// Check if the site plan changed and deactivate modules accordingly.
add_action('current_screen', array($this, 'check_plan_deactivate_modules'));
// Attach page specific actions in addition to the above
$this->add_page_actions($hook);
}
示例8: remote_authorize
function remote_authorize($request)
{
foreach (array('secret', 'state', 'redirect_uri', 'code') as $required) {
if (!isset($request[$required]) || empty($request[$required])) {
return $this->error(new Jetpack_Error('missing_parameter', 'One or more parameters is missing from the request.', 400));
}
}
if (!get_user_by('id', $request['state'])) {
return $this->error(new Jetpack_Error('user_unknown', 'User not found.', 404));
}
if (Jetpack::is_active() && Jetpack::is_user_connected($request['state'])) {
return $this->error(new Jetpack_Error('already_connected', 'User already connected.', 400));
}
$verified = $this->verify_action(array('authorize', $request['secret'], $request['state']));
if (is_a($verified, 'IXR_Error')) {
return $verified;
}
wp_set_current_user($request['state']);
$client_server = new Jetpack_Client_Server();
$result = $client_server->authorize($request);
if (is_wp_error($result)) {
return $this->error($result);
}
return $result;
}
示例9: __construct
function __construct()
{
if (class_exists('Jetpack') && Jetpack::is_active()) {
add_action('jetpack-start_step-connect-social', array($this, 'render'));
add_filter('jetpack_start_js_globals', array($this, 'jetpack_start_js_globals'));
}
}
示例10: track_jetpack_usage
static function track_jetpack_usage()
{
if (!Jetpack::is_active()) {
return;
}
add_action('jetpack_pre_activate_module', array(__CLASS__, 'track_activate_module'), 1, 1);
add_action('jetpack_pre_deactivate_module', array(__CLASS__, 'track_deactivate_module'), 1, 1);
add_action('jetpack_user_authorized', array(__CLASS__, 'track_user_linked'));
}
示例11: track_jetpack_usage
static function track_jetpack_usage()
{
if (!Jetpack::is_active()) {
return;
}
// For tracking stuff via js/ajax
add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue_tracks_scripts'));
add_action('jetpack_pre_activate_module', array(__CLASS__, 'track_activate_module'), 1, 1);
add_action('jetpack_pre_deactivate_module', array(__CLASS__, 'track_deactivate_module'), 1, 1);
add_action('jetpack_user_authorized', array(__CLASS__, 'track_user_linked'));
}
示例12: __construct
/**
* Constructor for singleton
*
* @since 2.3.3
* @return Jetpack_Heartbeat
*/
private function __construct()
{
if (!Jetpack::is_active()) {
return;
}
// Add weekly interval for wp-cron
add_filter('cron_schedules', array($this, 'add_cron_intervals'));
// Schedule the task
add_action($this->cron_name, array($this, 'cron_exec'));
if (!wp_next_scheduled($this->cron_name)) {
wp_schedule_event(time(), 'jetpack_weekly', $this->cron_name);
}
}
示例13: disconnect
/**
* Disconnect Jetpack Blogs or Users
*
* ## OPTIONS
*
* blog: Disconnect the entire blog.
*
* user <user_identifier>: Disconnect a specific user from WordPress.com.
*
* Please note, the primary account that the blog is connected
* to WordPress.com with cannot be disconnected without
* disconnecting the entire blog.
*
* ## EXAMPLES
*
* wp jetpack disconnect blog
* wp jetpack disconnect user 13
* wp jetpack disconnect user username
* wp jetpack disconnect user email@domain.com
*
* @synopsis blog|[user <user_id>]
*/
public function disconnect($args, $assoc_args)
{
if (!Jetpack::is_active()) {
WP_CLI::error(__('You cannot disconnect, without having first connected.', 'jetpack'));
}
$action = isset($args[0]) ? $args[0] : 'prompt';
if (!in_array($action, array('blog', 'user', 'prompt'))) {
WP_CLI::error(sprintf(__('%s is not a valid command.', 'jetpack'), $action));
}
if (in_array($action, array('user'))) {
if (isset($args[1])) {
$user_id = $args[1];
if (ctype_digit($user_id)) {
$field = 'id';
$user_id = (int) $user_id;
} elseif (is_email($user_id)) {
$field = 'email';
$user_id = sanitize_user($user_id, true);
} else {
$field = 'login';
$user_id = sanitize_user($user_id, true);
}
if (!($user = get_user_by($field, $user_id))) {
WP_CLI::error(__('Please specify a valid user.', 'jetpack'));
}
} else {
WP_CLI::error(__('Please specify a user.', 'jetpack'));
}
}
switch ($action) {
case 'blog':
Jetpack::log('disconnect');
Jetpack::disconnect();
WP_CLI::success(__('Jetpack has been successfully disconnected.', 'jetpack'));
break;
case 'user':
if (Jetpack::unlink_user($user->ID)) {
Jetpack::log('unlink', $user->ID);
WP_CLI::success(sprintf(__('%s has been successfully disconnected.', 'jetpack'), $action));
} else {
WP_CLI::error(sprintf(__('%s could not be disconnected. Are you sure they\'re connected currently?', 'jetpack'), "{$user->login} <{$user->email}>"));
}
break;
case 'prompt':
WP_CLI::error(__('Please specify if you would like to disconnect a blog or user.', 'jetpack'));
break;
}
}
示例14: __construct
/**
* Constructor for singleton
*
* @since 2.3.3
* @return Jetpack_Heartbeat
*/
private function __construct()
{
if (!Jetpack::is_active()) {
return;
}
// Schedule the task
add_action($this->cron_name, array($this, 'cron_exec'));
if (!wp_next_scheduled($this->cron_name)) {
// Deal with the old pre-3.0 weekly one.
if ($timestamp = wp_next_scheduled('jetpack_heartbeat')) {
wp_unschedule_event($timestamp, 'jetpack_heartbeat');
}
wp_schedule_event(time(), 'daily', $this->cron_name);
}
add_filter('jetpack_xmlrpc_methods', array(__CLASS__, 'jetpack_xmlrpc_methods'));
}
示例15: __construct
private function __construct()
{
if (!Jetpack::is_active()) {
return;
}
global $pagenow;
$jetpack_hide_jitm = Jetpack_Options::get_option('hide_jitm');
$showphoton = empty($jetpack_hide_jitm['photon']) ? 'show' : $jetpack_hide_jitm['photon'];
$showmanage = empty($jetpack_hide_jitm['manage']) ? 'show' : $jetpack_hide_jitm['manage'];
if ('media-new.php' == $pagenow && !Jetpack::is_module_active('photon') && 'hide' != $showphoton) {
add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
add_action('post-plupload-upload-ui', array($this, 'photon_msg'));
} else {
if ('update-core.php' == $pagenow && 'hide' != $showmanage) {
add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files'));
add_action('admin_notices', array($this, 'manage_msg'));
}
}
}