is_active() public static method

Is Jetpack active?
public static is_active ( )
コード例 #1
0
 /**
  * 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
0
 private function __construct()
 {
     if (!Jetpack::is_active() || self::is_jitm_dismissed()) {
         return;
     }
     add_action('current_screen', array($this, 'prepare_jitms'));
 }
コード例 #3
0
 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'));
     }
 }
 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;
 }
 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
0
ファイル: polldaddy.php プロジェクト: KimcoBlogSC/Blog
 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
0
 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
0
 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
0
 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
0
 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
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 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'));
         }
     }
 }
コード例 #16
0
 function add_actions()
 {
     /**
      * 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'));
     // Attach page specific actions in addition to the above
     $this->add_page_actions($hook);
 }
コード例 #17
0
 function page_render()
 {
     // Handle redirects to configuration pages
     if (!empty($_GET['configure'])) {
         return $this->render_nojs_configurable();
     }
     global $current_user;
     $is_connected = Jetpack::is_active();
     $user_token = Jetpack_Data::get_access_token($current_user->ID);
     $is_user_connected = $user_token && !is_wp_error($user_token);
     $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
     if (Jetpack::is_development_mode()) {
         $is_connected = true;
         $is_user_connected = true;
         $is_master_user = false;
     }
     // Set template data for the admin page template
     $data = array('is_connected' => $is_connected, 'is_user_connected' => $is_user_connected, 'is_master_user' => $is_master_user);
     Jetpack::init()->load_view('admin/admin-page.php', $data);
 }
コード例 #18
0
/**
 * Get the number of pageviews for a given post ID (defaults to the current post)
 *
 * Note that it is not currently possible to retrieve the post views for
 * the homepage using this function
 *
 * @param int          $post_id   Optional. The post ID to fetch stats for. Defaults to the $post global's value.
 * @param int          $num_days  Optional. How many days to go back to include in the stats. Default is 1. Maximum 90 days.
 * @param string|bool  $end_data  Optional. The last day of the desired time frame. Format is 'Y-m-d' (e.g. 2007-05-01) and default is today's UTC date.
 * @return int|false Number of pageviews or false on error.
 */
function wpcom_vip_get_post_pageviews($post_id = null, $num_days = 1, $end_date = false)
{
    // Check Jetpack is present and active
    if (class_exists('Jetpack') && Jetpack::is_active()) {
        $args = array('post_id' => $post_id, 'num_days' => $num_days, 'end_date' => $end_date);
        // Default post_id to the current post ID, and check it's an int
        if (is_null($args['post_id'])) {
            $args['post_id'] = get_the_ID();
        }
        $args['post_id'] = absint($args['post_id']);
        if (empty($args['post_id'])) {
            return false;
        }
        // Ensure num_days is least 1, but no more than 90
        $args['num_days'] = max(1, min(90, absint($args['num_days'])));
        $posts = stats_get_csv('postviews', $args);
        $views = $posts[0];
    } else {
        // If Jetpack is not present or not active, fake the data returned
        $views = mt_rand(0, 20000);
    }
    return absint($views);
}
コード例 #19
0
 static function sync_allowed()
 {
     return !Jetpack_Sync_Settings::get_setting('disable') && Jetpack::is_active() && !(Jetpack::is_development_mode() || Jetpack::is_staging_site()) || defined('PHPUNIT_JETPACK_TESTSUITE');
 }
コード例 #20
0
    public function dashboard_widget_connect_to_wpcom()
    {
        if (Jetpack::is_active() || Jetpack::is_development_mode() || !current_user_can('jetpack_connect')) {
            return;
        }
        ?>
		<div class="wpcom-connect">
			<div class="jp-emblem">
			<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve">
				<path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/>
			</svg>
			</div>
			<h3><?php 
        esc_html_e('Please Connect Jetpack', 'jetpack');
        ?>
</h3>
			<p><?php 
        echo wp_kses(__('Connecting Jetpack will show you <strong>stats</strong> about your traffic, <strong>protect</strong> you from brute force attacks, <strong>speed up</strong> your images and photos, and enable other <strong>traffic and security</strong> features.', 'jetpack'), 'jetpack');
        ?>
</p>

			<div class="actions">
				<a href="<?php 
        echo $this->build_connect_url(false, false, 'widget-btn');
        ?>
" class="button button-primary">
					<?php 
        esc_html_e('Connect Jetpack', 'jetpack');
        ?>
				</a>
			</div>
		</div>
		<?php 
    }
コード例 #21
0
    function admin_screen_list_modules()
    {
        require_once dirname(__FILE__) . '/modules/module-info.php';
        $jetpack_connected = true;
        if (!Jetpack::is_active()) {
            $jetpack_connected = false;
        }
        ?>
		<div class="module-container">
		<?php 
        $avail_raw = Jetpack::get_available_modules();
        $available = array();
        $active = Jetpack::get_active_modules();
        $counter = 0;
        foreach ((array) $avail_raw as $module) {
            if ($plugin = Jetpack::get_module($module)) {
                $plugin['module'] = $module;
                $available[] = $plugin;
            }
        }
        unset($avail_raw);
        usort($available, array('Jetpack', 'sort_modules'));
        $jetpack_version = Jetpack::get_option('version');
        if ($jetpack_version) {
            list($jetpack_version, $jetpack_version_time) = explode(':', $jetpack_version);
        } else {
            $jetpack_version = 0;
            $jetpack_version_time = 0;
        }
        $jetpack_old_version = Jetpack::get_option('old_version');
        if ($jetpack_old_version) {
            list($jetpack_old_version) = explode(':', $jetpack_old_version);
        } else {
            $jetpack_old_version = 0;
        }
        $now = time();
        foreach ((array) $available as $module_data) {
            $module = $module_data['module'];
            $activated = in_array($module, $active);
            if ($activated) {
                $css = 'active';
                $toggle = __('Deactivate', 'jetpack');
                $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'deactivate', 'module' => $module)), "jetpack_deactivate-{$module}");
            } else {
                $css = 'inactive';
                $toggle = __('Activate', 'jetpack');
                $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => $module)), "jetpack_activate-{$module}");
            }
            $file = Jetpack::get_module_path($module);
            $png = str_replace('.php', '.png', $file);
            if (is_readable(dirname(__FILE__) . '/_inc/images/icons/' . basename($png))) {
                $module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/icons/' . basename($png));
            } else {
                $module_img = plugins_url(basename(dirname(__FILE__)) . '/_inc/images/module-blank.png');
            }
            if ($counter % 4 == 0) {
                $classes = $css . ' jetpack-newline';
                $counter = 0;
            } else {
                $classes = $css;
            }
            $free_text = esc_html($module_data['free'] ? __('Free', 'jetpack') : __('Purchase', 'jetpack'));
            $free_text = apply_filters('jetpack_module_free_text_' . $module, $free_text);
            $badge_text = $free_text;
            if (!$jetpack_connected) {
                $classes = 'x disabled';
            } else {
                if ($jetpack_version_time + 604800 > $now) {
                    // 1 week
                    if (version_compare($module_data['introduced'], $jetpack_old_version, '>')) {
                        $badge_text = esc_html__('New', 'jetpack');
                        $classes .= ' jetpack-new-module';
                    } elseif (isset($module_data['changed']) && version_compare($module_data['changed'], $jetpack_old_version, '>')) {
                        $badge_text = esc_html__('Updated', 'jetpack');
                        $classes .= ' jetpack-updated-module';
                    } else {
                        $badge_text = $free_text;
                    }
                }
            }
            ?>
			<div class="jetpack-module jetpack-<?php 
            echo $classes;
            ?>
" id="<?php 
            echo $module;
            ?>
">
				<h3><?php 
            echo $module_data['name'];
            ?>
</h3>
				<div class="jetpack-module-description">
						<div class="module-image">
							<img src="<?php 
            echo esc_url($module_img);
            ?>
" align="right" width="71" height="45" />
							<p><span class="module-image-badge"><?php 
            echo $badge_text;
            ?>
</span><span class="module-image-free" style="display: none"><?php 
            echo $free_text;
            ?>
</span></p>
						</div>

						<p><?php 
            echo apply_filters('jetpack_short_module_description', $module_data['description'], $module);
            ?>
</p>
				</div>

				<div class="jetpack-module-actions">
				<?php 
            if ($jetpack_connected) {
                ?>
					<?php 
                if (!$activated) {
                    ?>
						<a href="<?php 
                    echo esc_url($toggle_url);
                    ?>
" class="jetpack-toggle-button<?php 
                    echo 'inactive' == $css ? ' button-primary' : ' button';
                    ?>
"><?php 
                    echo $toggle;
                    ?>
</a>&nbsp;
					<?php 
                }
                ?>

					<?php 
                do_action('jetpack_learn_more_button_' . $module);
                ?>

					<?php 
                if (apply_filters('jetpack_module_configurable_' . $module, false)) {
                    echo '<a href="' . esc_attr(Jetpack::module_configuration_url($module)) . '" class="jetpack-configure-button button">' . __('Configure', 'jetpack') . '</a>';
                }
                if ($activated && $module_data['deactivate']) {
                    ?>
<a style="display: none;" href="<?php 
                    echo esc_url($toggle_url);
                    ?>
" class="jetpack-deactivate-button button"><?php 
                    echo $toggle;
                    ?>
</a>&nbsp;<?php 
                }
                ?>

				<?php 
            } else {
                ?>
					<?php 
                do_action('jetpack_learn_more_button_' . $module);
                ?>
				<?php 
            }
            ?>
				</div>
			</div>
			<?php 
            if ('inactive' == $css && $jetpack_connected) {
                ?>
			<script type="text/javascript">
			jQuery( '#<?php 
                echo esc_js($module);
                ?>
' ).bind( 'click', function(e){
				if ( !jQuery(e.target).hasClass('more-info-link') )
					document.location.href = '<?php 
                echo str_replace('&amp;', '&', esc_js(esc_url($toggle_url)));
                ?>
';
			} );
			</script>
			<?php 
            }
            ?>

			<div id="jp-more-info-<?php 
            echo esc_attr($module);
            ?>
" style="display:none;">
				<?php 
            if ($jetpack_connected && has_action('jetpack_module_more_info_connected_' . $module)) {
                do_action('jetpack_module_more_info_connected_' . $module);
            } else {
                do_action('jetpack_module_more_info_' . $module);
            }
            ?>
			</div>

			<?php 
            $counter++;
        }
        // Add in some "Coming soon..." placeholders to fill up the current row and one more
        for ($i = 0; $i < 3; $i++) {
            ?>
			<div class="jetpack-module placeholder"<?php 
            if ($i > 8 - $counter) {
                echo ' style="display: none;"';
            }
            ?>
>
				<h3><?php 
            _e('Coming soon&#8230;', 'jetpack');
            ?>
</h3>
			</div>
		<?php 
        }
        echo '</div><!-- .module-container -->';
    }
コード例 #22
0
    public static function jetpack_debug_display_handler()
    {
        if (!current_user_can('manage_options')) {
            wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'jetpack'));
        }
        $current_user = wp_get_current_user();
        $user_id = get_current_user_id();
        $user_tokens = Jetpack_Options::get_option('user_tokens');
        if (is_array($user_tokens) && array_key_exists($user_id, $user_tokens)) {
            $user_token = $user_tokens[$user_id];
        } else {
            $user_token = '[this user has no token]';
        }
        unset($user_tokens);
        $debug_info = "\r\n";
        foreach (array('CLIENT_ID' => 'id', 'BLOG_TOKEN' => 'blog_token', 'MASTER_USER' => 'master_user', 'CERT' => 'fallback_no_verify_ssl_certs', 'TIME_DIFF' => 'time_diff', 'VERSION' => 'version', 'OLD_VERSION' => 'old_version', 'PUBLIC' => 'public') as $label => $option_name) {
            $debug_info .= "\r\n" . esc_html($label . ": " . Jetpack_Options::get_option($option_name));
        }
        $debug_info .= "\r\n" . esc_html("USER_ID: " . $user_id);
        $debug_info .= "\r\n" . esc_html("USER_TOKEN: " . $user_token);
        $debug_info .= "\r\n" . esc_html("PHP_VERSION: " . PHP_VERSION);
        $debug_info .= "\r\n" . esc_html("WORDPRESS_VERSION: " . $GLOBALS['wp_version']);
        $debug_info .= "\r\n" . esc_html("JETPACK__VERSION: " . JETPACK__VERSION);
        $debug_info .= "\r\n" . esc_html("JETPACK__PLUGIN_DIR: " . JETPACK__PLUGIN_DIR);
        $debug_info .= "\r\n" . esc_html("SITE_URL: " . site_url());
        $debug_info .= "\r\n" . esc_html("HOME_URL: " . home_url());
        $debug_info .= "\r\n";
        require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-modules.php';
        $sync_module = Jetpack_Sync_Modules::get_module('full-sync');
        $sync_statuses = $sync_module->get_status();
        $human_readable_sync_status = array();
        foreach ($sync_statuses as $sync_status => $sync_status_value) {
            $human_readable_sync_status[$sync_status] = in_array($sync_status, array('started', 'queue_finished', 'send_started', 'finished')) ? date('r', $sync_status_value) : $sync_status_value;
        }
        $debug_info .= "\r\n" . sprintf(esc_html__('Jetpack Sync Full Status: `%1$s`', 'jetpack'), print_r($human_readable_sync_status, 1));
        require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-sender.php';
        $queue = Jetpack_Sync_Sender::get_instance()->get_sync_queue();
        $debug_info .= "\r\n" . sprintf(esc_html__('Sync Queue size: %1$s', 'jetpack'), $queue->size());
        $debug_info .= "\r\n" . sprintf(esc_html__('Sync Queue lag: %1$s', 'jetpack'), self::seconds_to_time($queue->lag()));
        $full_sync_queue = Jetpack_Sync_Sender::get_instance()->get_full_sync_queue();
        $debug_info .= "\r\n" . sprintf(esc_html__('Full Sync Queue size: %1$s', 'jetpack'), $full_sync_queue->size());
        $debug_info .= "\r\n" . sprintf(esc_html__('Full Sync Queue lag: %1$s', 'jetpack'), self::seconds_to_time($full_sync_queue->lag()));
        $debug_info .= "\r\n";
        foreach (array('HTTP_HOST', 'SERVER_PORT', 'HTTPS', 'GD_PHP_HANDLER', 'HTTP_AKAMAI_ORIGIN_HOP', 'HTTP_CF_CONNECTING_IP', 'HTTP_CLIENT_IP', 'HTTP_FASTLY_CLIENT_IP', 'HTTP_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_INCAP_CLIENT_IP', 'HTTP_TRUE_CLIENT_IP', 'HTTP_X_CLIENTIP', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_X_FORWARDED', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_IP_TRAIL', 'HTTP_X_REAL_IP', 'HTTP_X_VARNISH', 'REMOTE_ADDR') as $header) {
            if (isset($_SERVER[$header])) {
                $debug_info .= "\r\n" . esc_html($header . ": " . $_SERVER[$header]);
            }
        }
        $debug_info .= "\r\n" . esc_html("PROTECT_TRUSTED_HEADER: " . json_encode(get_site_option('trusted_ip_header')));
        $debug_info .= "\r\n\r\nTEST RESULTS:\r\n\r\n";
        $debug_raw_info = '';
        $tests = array();
        $tests['HTTP']['result'] = wp_remote_get(preg_replace('/^https:/', 'http:', JETPACK__API_BASE) . 'test/1/');
        $tests['HTTP']['fail_message'] = esc_html__('Your site isn’t reaching the Jetpack servers.', 'jetpack');
        $tests['HTTPS']['result'] = wp_remote_get(preg_replace('/^http:/', 'https:', JETPACK__API_BASE) . 'test/1/');
        $tests['HTTPS']['fail_message'] = esc_html__('Your site isn’t securely reaching the Jetpack servers.', 'jetpack');
        $identity_crisis_message = '';
        if ($identity_crisis = Jetpack::check_identity_crisis(true)) {
            foreach ($identity_crisis as $key => $value) {
                $identity_crisis_message .= sprintf(__('Your `%1$s` option is set up as `%2$s`, but your WordPress.com connection lists it as `%3$s`!', 'jetpack'), $key, (string) get_option($key), $value) . "\r\n";
            }
            $identity_crisis = new WP_Error('identity-crisis', $identity_crisis_message, $identity_crisis);
        } else {
            $identity_crisis = 'PASS';
        }
        $tests['IDENTITY_CRISIS']['result'] = $identity_crisis;
        $tests['IDENTITY_CRISIS']['fail_message'] = esc_html__('Something has gotten mixed up in your Jetpack Connection!', 'jetpack');
        $self_xml_rpc_url = home_url('xmlrpc.php');
        $testsite_url = Jetpack::fix_url_for_bad_hosts(JETPACK__API_BASE . 'testsite/1/?url=');
        add_filter('http_request_timeout', array('Jetpack_Debugger', 'jetpack_increase_timeout'));
        $tests['SELF']['result'] = wp_remote_get($testsite_url . $self_xml_rpc_url);
        if (is_wp_error($tests['SELF']['result']) && 0 == strpos($tests['SELF']['result']->get_error_message(), 'Operation timed out')) {
            $tests['SELF']['fail_message'] = esc_html__('Your site did not get a response from our debugging service in the expected timeframe. If you are not experiencing other issues, this could be due to a slow connection between your site and our server.', 'jetpack');
        } else {
            $tests['SELF']['fail_message'] = esc_html__('It looks like your site can not communicate properly with Jetpack.', 'jetpack');
        }
        remove_filter('http_request_timeout', array('Jetpack_Debugger', 'jetpack_increase_timeout'));
        ?>
		<div class="wrap">
			<h2><?php 
        esc_html_e('Jetpack Debugging Center', 'jetpack');
        ?>
</h2>
			<h3><?php 
        _e("Testing your site's compatibility with Jetpack...", 'jetpack');
        ?>
</h3>
			<div class="jetpack-debug-test-container">
			<?php 
        ob_start();
        foreach ($tests as $test_name => $test_info) {
            if ('PASS' !== $test_info['result'] && (is_wp_error($test_info['result']) || false == ($response_code = wp_remote_retrieve_response_code($test_info['result'])) || '200' != $response_code)) {
                $debug_info .= $test_name . ": FAIL\r\n";
                ?>
					<div class="jetpack-test-error">
						<p>
							<a class="jetpack-test-heading" href="#"><?php 
                echo $test_info['fail_message'];
                ?>
							<span class="noticon noticon-collapse"></span>
							</a>
						</p>
						<pre class="jetpack-test-details"><?php 
                echo esc_html($test_name);
                ?>
:
	<?php 
                echo esc_html(is_wp_error($test_info['result']) ? $test_info['result']->get_error_message() : print_r($test_info['result'], 1));
                ?>
</pre>
					</div><?php 
            } else {
                $debug_info .= $test_name . ": PASS\r\n";
            }
            $debug_raw_info .= "\r\n\r\n" . $test_name . "\r\n" . esc_html(is_wp_error($test_info['result']) ? $test_info['result']->get_error_message() : print_r($test_info['result'], 1));
            ?>
			<?php 
        }
        $html = ob_get_clean();
        if ('' == trim($html)) {
            echo '<div class="jetpack-tests-succed">' . esc_html__('Your Jetpack setup looks a-okay!', 'jetpack') . '</div>';
        } else {
            echo '<h3>' . esc_html__('There seems to be a problem with your site’s ability to communicate with Jetpack!', 'jetpack') . '</h3>';
            echo $html;
        }
        $debug_info .= "\r\n\r\nRAW TEST RESULTS:" . $debug_raw_info . "\r\n";
        ?>
			</div>
			<div class="entry-content">
				<h3><?php 
        esc_html_e('Trouble with Jetpack?', 'jetpack');
        ?>
</h3>
				<h4><?php 
        esc_html_e('It may be caused by one of these issues, which you can diagnose yourself:', 'jetpack');
        ?>
</h4>
				<ol>
					<li><b><em><?php 
        esc_html_e('A known issue.', 'jetpack');
        ?>
</em></b>  <?php 
        echo sprintf(__('Some themes and plugins have <a href="%1$s" target="_blank">known conflicts</a> with Jetpack – check the <a href="%2$s" target="_blank">list</a>. (You can also browse the <a href="%3$s" target="_blank">Jetpack support pages</a> or <a href="%4$s" target="_blank">Jetpack support forum</a> to see if others have experienced and solved the problem.)', 'jetpack'), 'http://jetpack.com/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.com/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.com/support/', 'https://wordpress.org/support/plugin/jetpack');
        ?>
</li>
					<li><b><em><?php 
        esc_html_e('An incompatible plugin.', 'jetpack');
        ?>
</em></b>  <?php 
        esc_html_e("Find out by disabling all plugins except Jetpack. If the problem persists, it's not a plugin issue. If the problem is solved, turn your plugins on one by one until the problem pops up again – there's the culprit! Let us know, and we'll try to help.", 'jetpack');
        ?>
</li>
					<li>
						<b><em><?php 
        esc_html_e('A theme conflict.', 'jetpack');
        ?>
</em></b>
						<?php 
        $default_theme = wp_get_theme(WP_DEFAULT_THEME);
        if ($default_theme->exists()) {
            echo esc_html(sprintf(__("If your problem isn't known or caused by a plugin, try activating %s (the default WordPress theme).", 'jetpack'), $default_theme->get('Name')));
        } else {
            esc_html_e("If your problem isn't known or caused by a plugin, try activating the default WordPress theme.", 'jetpack');
        }
        ?>
						<?php 
        esc_html_e("If this solves the problem, something in your theme is probably broken – let the theme's author know.", 'jetpack');
        ?>
					</li>
					<li><b><em><?php 
        esc_html_e('A problem with your XMLRPC file.', 'jetpack');
        ?>
</em></b>  <?php 
        echo sprintf(__('Load your <a href="%s">XMLRPC file</a>. It should say “XML-RPC server accepts POST requests only.” on a line by itself.', 'jetpack'), site_url('xmlrpc.php'));
        ?>
						<ul>
							<li>- <?php 
        esc_html_e("If it's not by itself, a theme or plugin is displaying extra characters. Try steps 2 and 3.", 'jetpack');
        ?>
</li>
							<li>- <?php 
        esc_html_e("If you get a 404 message, contact your web host. Their security may block XMLRPC.", 'jetpack');
        ?>
</li>
						</ul>
					</li>
				</ol>
				<?php 
        if (self::is_jetpack_support_open()) {
            ?>
				<p class="jetpack-show-contact-form"><?php 
            echo sprintf(__('If none of these help you find a solution, <a href="%s">click here to contact Jetpack support</a>. Tell us as much as you can about the issue and what steps you\'ve tried to resolve it, and one of our Happiness Engineers will be in touch to help.', 'jetpack'), Jetpack::admin_url(array('page' => 'jetpack-debugger', 'contact' => true)));
            ?>
				</p>
				<?php 
        }
        ?>
				<?php 
        if (Jetpack::is_active()) {
            ?>
					<hr />
					<div id="connected-user-details">
						<p><?php 
            printf(__('The primary connection is owned by <strong>%s</strong>\'s WordPress.com account.', 'jetpack'), esc_html(Jetpack::get_master_user_email()));
            ?>
</p>
					</div>
				<?php 
        }
        ?>
			</div>
			<div id="contact-message" <?php 
        if (!isset($_GET['contact'])) {
            ?>
  style="display:none" <?php 
        }
        ?>
>
			<?php 
        if (self::is_jetpack_support_open()) {
            ?>
				<form id="contactme" method="post" action="https://jetpack.com/contact-support/">
					<input type="hidden" name="action" value="submit">
					<input type="hidden" name="jetpack" value="needs-service">

					<input type="hidden" name="contact_form" id="contact_form" value="1">
					<input type="hidden" name="blog_url" id="blog_url" value="<?php 
            echo esc_attr(site_url());
            ?>
">
					<?php 
            $subject_line = sprintf(_x('from: %s Jetpack contact form', 'Support request email subject line', 'jetpack'), esc_attr(site_url()));
            if (Jetpack::is_development_version()) {
                $subject_line = 'BETA ' . $subject_line;
            }
            $subject_line_input = printf('<input type="hidden" name="subject" id="subject" value="%s"">', $subject_line);
            ?>
					<div class="formbox">
						<label for="message" class="h"><?php 
            esc_html_e('Please describe the problem you are having.', 'jetpack');
            ?>
</label>
						<textarea name="message" cols="40" rows="7" id="did"></textarea>
					</div>

					<div id="name_div" class="formbox">
						<label class="h" for="your_name"><?php 
            esc_html_e('Name', 'jetpack');
            ?>
</label>
			  			<span class="errormsg"><?php 
            esc_html_e('Let us know your name.', 'jetpack');
            ?>
</span>
						<input name="your_name" type="text" id="your_name" value="<?php 
            esc_html_e($current_user->display_name, 'jetpack');
            ?>
" size="40">
					</div>

					<div id="email_div" class="formbox">
						<label class="h" for="your_email"><?php 
            esc_html_e('E-mail', 'jetpack');
            ?>
</label>
			  			<span class="errormsg"><?php 
            esc_html_e('Use a valid email address.', 'jetpack');
            ?>
</span>
						<input name="your_email" type="text" id="your_email" value="<?php 
            esc_html_e($current_user->user_email, 'jetpack');
            ?>
" size="40">
					</div>

					<div id="toggle_debug_form_info" class="formbox">
						<p><?php 
            _e('The test results and some other useful debug information will be sent to the support team. Please feel free to <a href="#">review/modify</a> this information.', 'jetpack');
            ?>
</p>
					</div>

					<div id="debug_info_form_div" class="formbox" style="display:none">
						<label class="h" for="debug_info"><?php 
            esc_html_e('Debug Info', 'jetpack');
            ?>
</label>
			  			<textarea name="debug_info" cols="40" rows="7" id="debug_form_info"><?php 
            echo esc_attr($debug_info);
            ?>
</textarea>
					</div>

					<div style="clear: both;"></div>

					<div id="blog_div" class="formbox">
						<div id="submit_div" class="contact-support">
						<input type="submit" name="submit" value="<?php 
            esc_html_e('Submit &#187;', 'jetpack');
            ?>
">
						</div>
					</div>
					<div style="clear: both;"></div>
				</form>
			<?php 
        }
        ?>
		</div> <!-- contact-message, hidden by default. -->
		<div id="toggle_debug_info"><a href="#"><?php 
        _e('View Advanced Debug Results', 'jetpack');
        ?>
</a></div>
			<div id="debug_info_div" style="display:none">
			<h4><?php 
        esc_html_e('Debug Info', 'jetpack');
        ?>
</h4>
			<div id="debug_info"><pre><?php 
        echo esc_html($debug_info);
        ?>
</pre></div>
		</div>
		</div>
	<?php 
    }
コード例 #23
0
 static function configure_jetpack()
 {
     check_ajax_referer(self::AJAX_NONCE, 'nonce');
     $return_to_step = $_REQUEST['return_to_step'];
     if (!is_plugin_active('jetpack')) {
         activate_plugin('jetpack');
     }
     if (!class_exists('Jetpack')) {
         wp_send_json_error('There was a problem activating Jetpack');
         die;
     }
     if (!Jetpack::is_active()) {
         if (!Jetpack_Options::get_option('blog_token') || !Jetpack_Options::get_option('id')) {
             $result = Jetpack::try_registration();
             if (is_wp_error($result)) {
                 $error = $result->get_error_code();
                 $message = $result->get_error_message();
                 wp_send_json_error($message . ' (code: ' . $error . ')');
                 die;
             }
         }
         $jp_landing_page = new Jetpack_Landing_Page();
         $jp_landing_page->add_actions();
         // redirect to activate link
         $connect_url = Jetpack::init()->build_connect_url(true, admin_url('index.php#welcome/steps/' . $return_to_step));
         if (JETPACK_STEP_AUTO_REDIRECT) {
             $connect_url = add_query_arg('src', JETPACK_STEP_AUTO_REDIRECT_SRC, $connect_url);
         }
         wp_send_json_success(array('next' => $connect_url));
     } else {
         wp_send_json_success('already_active');
     }
 }
コード例 #24
0
 /**
  * Stylized JP header formatting
  *
  * @since 2.9
  */
 function network_admin_page_header()
 {
     global $current_user;
     $is_connected = Jetpack::is_active();
     $data = array('is_connected' => $is_connected);
     Jetpack::init()->load_view('admin/network-admin-header.php', $data);
 }
コード例 #25
0
 function column_description($item)
 {
     ob_start();
     echo apply_filters('jetpack_short_module_description', $item['description'], $item['module']);
     do_action('jetpack_learn_more_button_' . $item['module']);
     echo '<div id="more-info-' . $item['module'] . '" class="more-info">';
     if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $item['module'])) {
         do_action('jetpack_module_more_info_connected_' . $item['module']);
     } else {
         do_action('jetpack_module_more_info_' . $item['module']);
     }
     echo '</div>';
     return ob_get_clean();
 }
コード例 #26
0
 function page_admin_scripts()
 {
     if ($this->is_redirecting) {
         return;
         // No need for scripts on a fallback page
     }
     $is_dev_mode = Jetpack::is_development_mode();
     // Enqueue jp.js and localize it
     wp_enqueue_script('react-plugin', plugins_url('_inc/build/admin.js', JETPACK__PLUGIN_FILE), array(), JETPACK__VERSION, true);
     if (!$is_dev_mode) {
         // Required for Analytics
         wp_enqueue_script('jp-tracks', '//stats.wp.com/w.js', array(), gmdate('YW'), true);
     }
     $localeSlug = explode('_', get_locale());
     $localeSlug = $localeSlug[0];
     // Collecting roles that can view site stats
     $stats_roles = array();
     $enabled_roles = function_exists('stats_get_option') ? stats_get_option('roles') : array('administrator');
     foreach (get_editable_roles() as $slug => $role) {
         $stats_roles[$slug] = array('name' => translate_user_role($role['name']), 'canView' => is_array($enabled_roles) ? in_array($slug, $enabled_roles, true) : false);
     }
     $response = rest_do_request(new WP_REST_Request('GET', '/jetpack/v4/module/all'));
     $modules = $response->get_data();
     // Preparing translated fields for JSON encoding by transforming all HTML entities to
     // respective characters.
     foreach ($modules as $slug => $data) {
         $modules[$slug]['name'] = html_entity_decode($data['name']);
         $modules[$slug]['description'] = html_entity_decode($data['description']);
         $modules[$slug]['short_description'] = html_entity_decode($data['short_description']);
         $modules[$slug]['long_description'] = html_entity_decode($data['long_description']);
     }
     // Add objects to be passed to the initial state of the app
     wp_localize_script('react-plugin', 'Initial_State', array('WP_API_root' => esc_url_raw(rest_url()), 'WP_API_nonce' => wp_create_nonce('wp_rest'), 'pluginBaseUrl' => plugins_url('', JETPACK__PLUGIN_FILE), 'connectionStatus' => array('isActive' => Jetpack::is_active(), 'isStaging' => Jetpack::is_staging_site(), 'devMode' => array('isActive' => $is_dev_mode, 'constant' => defined('JETPACK_DEV_DEBUG') && JETPACK_DEV_DEBUG, 'url' => site_url() && false === strpos(site_url(), '.'), 'filter' => apply_filters('jetpack_development_mode', false)), 'isPublic' => '1' == get_option('blog_public'), 'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option()), 'dismissedNotices' => $this->get_dismissed_jetpack_notices(), 'isDevVersion' => Jetpack::is_development_version(), 'currentVersion' => JETPACK__VERSION, 'happinessGravIds' => jetpack_get_happiness_gravatar_ids(), 'getModules' => $modules, 'showJumpstart' => jetpack_show_jumpstart(), 'rawUrl' => Jetpack::build_raw_urls(get_home_url()), 'adminUrl' => esc_url(admin_url()), 'stats' => array('data' => array('general' => false, 'day' => false, 'week' => false, 'month' => false), 'roles' => $stats_roles), 'settingNames' => array('jetpack_holiday_snow_enabled' => function_exists('jetpack_holiday_snow_option_name') ? jetpack_holiday_snow_option_name() : false), 'userData' => array('currentUser' => jetpack_current_user_data()), 'locale' => $this->get_i18n_data(), 'localeSlug' => $localeSlug, 'jetpackStateNotices' => array('messageCode' => Jetpack::state('message'), 'errorCode' => Jetpack::state('error'), 'errorDescription' => Jetpack::state('error_description')), 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(), 'currentIp' => function_exists('jetpack_protect_get_ip') ? jetpack_protect_get_ip() : false));
 }
コード例 #27
0
 /**
  * Checks if the update cron should be running and returns appropriate result.
  *
  * @return bool If the cron should be running or not.
  */
 public function should_cron_be_running()
 {
     /**
      * The cron doesn't need to run empty loops.
      */
     $widget_instances = $this->get_instances_sites();
     if (empty($widget_instances) || !is_array($widget_instances)) {
         return false;
     }
     if (!defined('IS_WPCOM') || !IS_WPCOM) {
         /**
          * If Jetpack is not active or in development mode, we don't want to update widget data.
          */
         if (!Jetpack::is_active() && !Jetpack::is_development_mode()) {
             return false;
         }
         /**
          * If Extra Sidebar Widgets module is not active, we don't need to update widget data.
          */
         if (!Jetpack::is_module_active('widgets')) {
             return false;
         }
     }
     /**
      * If none of the above checks failed, then we definitely want to update widget data.
      */
     return true;
 }
コード例 #28
0
function jetpack_infinite_scroll_more_info()
{
    $support_text = sprintf(__('If you are a theme author, you can learn about adding support for Infinite Scroll at <a href="%1$s">%1$s</a>.', 'jetpack'), 'http://jetpack.me/support/infinite-scroll/');
    ?>

	<?php 
    if (!Jetpack::is_active() || Jetpack::is_active() && current_theme_supports('infinite-scroll')) {
        ?>
		<p><?php 
        esc_html_e('When you write great content, all you really want is people to find it, right?', 'jetpack');
        ?>
</p>

		<p><?php 
        esc_html_e("With the Infinite Scroll module and a supported theme, that's exactly what happens. Instead of the old way of navigating down a page by scrolling and then clicking a link to get to the next page, waiting for a page refresh&mdash;the document model of the web&mdash;infinite scrolling pulls the next set of posts automatically into view when the reader approaches the bottom of the page, more like an application.", 'jetpack');
        ?>
</p>

	<?php 
    } else {
        ?>
		<p><?php 
        echo esc_html(sprintf(__("At this time, your theme, %s, doesn't support Infinite Scroll. Unlike other Jetpack modules, Infinite Scroll needs information from your theme to function properly.", 'jetpack'), function_exists('wp_get_theme') ? wp_get_theme()->Name : get_current_theme()));
        ?>
</p>

		<p><?php 
        esc_html_e("Until your theme supports Infinite Scroll, you won't be able to activate this module.", 'jetpack');
        ?>
</p>

		<?php 
        if (current_user_can('update_themes')) {
            ob_start();
            theme_update_available(function_exists('wp_get_theme') ? wp_get_theme() : (object) get_theme(get_current_theme()));
            $theme_update_available = ob_get_clean();
            if (!empty($theme_update_available)) {
                ?>
				<p><?php 
                printf(__('There is an update available for your theme. You may wish to check if this update adds Infinite Scroll support by visiting the <a href="%s">WordPress Updates</a> page.', 'jetpack'), esc_url(admin_url('update-core.php')));
                ?>
</p>
			<?php 
            } else {
                ?>
				<p><?php 
                echo $support_text;
                ?>
</p>
			<?php 
            }
            ?>
		<?php 
        } else {
            ?>
			<p><?php 
            echo $support_text;
            ?>
</p>
		<?php 
        }
        ?>
	<?php 
    }
}
コード例 #29
0
 /**
  * Checks to make sure that local options have the same values as remote options.  Will cache the results for up to 24 hours.
  *
  * @param bool $force_recheck Whether to ignore any cached transient and manually re-check.
  *
  * @return array An array of options that do not match.  If everything is good, it will evaluate to false.
  */
 public static function check_identity_crisis($force_recheck = false)
 {
     if (!Jetpack::is_active() || Jetpack::is_development_mode()) {
         return false;
     }
     if ($force_recheck || false === ($errors = get_transient('jetpack_has_identity_crisis'))) {
         $options_to_check = self::identity_crisis_options_to_check();
         $cloud_options = self::get_cloud_site_options($options_to_check);
         $errors = array();
         foreach ($cloud_options as $cloud_key => $cloud_value) {
             // If it's not the same as the local value...
             if ($cloud_value !== get_option($cloud_key)) {
                 // And it's not been added to the whitelist...
                 if (!self::is_identity_crisis_value_whitelisted($cloud_key, $cloud_value)) {
                     // Then kick an error!
                     $errors[$cloud_key] = $cloud_value;
                 }
             }
         }
     }
     return apply_filters('jetpack_has_identity_crisis', $errors, $force_recheck);
 }
コード例 #30
0
    function admin_page()
    {
        global $current_user;
        $is_connected = Jetpack::is_active();
        $user_token = Jetpack_Data::get_access_token($current_user->ID);
        $is_user_connected = $user_token && !is_wp_error($user_token);
        $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user');
        if (Jetpack::is_development_mode()) {
            $is_connected = true;
            $is_user_connected = true;
            $is_master_user = false;
        }
        $this->admin_page_top();
        ?>

		<div class="masthead <?php 
        if (!$is_connected) {
            echo 'hasbutton';
        }
        ?>
">

			<?php 
        if (isset($_GET['jetpack-notice']) && 'dismiss' == $_GET['jetpack-notice']) {
            ?>
				<div id="message" class="error">
					<p><?php 
            esc_html_e('Jetpack is network activated and notices can not be dismissed.', 'jetpack');
            ?>
</p>
				</div>
			<?php 
        }
        ?>

			<?php 
        do_action('jetpack_notices');
        ?>

			<h1><?php 
        esc_html_e('Supercharge your self-hosted site with a suite of the most powerful WordPress.com features.', 'jetpack');
        ?>
</h1>

			<?php 
        if (!$is_connected && current_user_can('jetpack_connect')) {
            ?>
				<a href="<?php 
            echo $this->jetpack->build_connect_url();
            ?>
" class="download-jetpack"><?php 
            esc_html_e('Connect to Get Started', 'jetpack');
            ?>
</a>
			<?php 
        } elseif (!$is_user_connected && current_user_can('jetpack_connect_user')) {
            ?>
				<a href="<?php 
            echo $this->jetpack->build_connect_url();
            ?>
" class="download-jetpack"><?php 
            esc_html_e('Link your account to WordPress.com', 'jetpack');
            ?>
</a>
			<?php 
        }
        ?>

			<div class="flyby">
				<svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve">
					<polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306"/>
					<path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/>
				</svg>
				<svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve">
					<polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306   "/>
					<path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/>
				</svg>
				<svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve">
					<polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306   "/>
					<path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/>
				</svg>
			</div>
			<div class="subhead">
				<?php 
        if (Jetpack::is_development_mode()) {
            ?>
				<h2><?php 
            _e('Jetpack is in local development mode.', 'jetpack');
            ?>
</h2>
				<?php 
        } elseif ($is_connected) {
            ?>
				<h2><?php 
            _e("You're successfully connected to Jetpack!", 'jetpack');
            ?>
</h2>
				<?php 
        } else {
            ?>
				<h2><?php 
            _e('Once you’ve connected Jetpack, you’ll get access to all the delightful features below.', 'jetpack');
            ?>
</h2>
				<?php 
        }
        ?>
			</div>
		</div><!-- .masthead -->
		<div class="featured">
			<h2><?php 
        _e('Jetpack team favorites', 'jetpack');
        ?>
</h2>

			<div class="features">
				<div class="feature">
					<a href="http://jetpack.me/support/custom-css/" data-name="Custom CSS" class="f-img"><div class="feature-img custom-css"></div></a>
					<a href="http://jetpack.me/support/custom-css/" data-name="Custom CSS" class="feature-description">
						<h3><?php 
        _e('Custom CSS', 'jetpack');
        ?>
</h3>
						<p><?php 
        _e('Customize the look of your site, without modifying your theme.', 'jetpack');
        ?>
</p>
					</a>
				</div>

				<div class="feature">
					<a href="http://jetpack.me/support/sso/" data-name="Jetpack Single Sign On" class="f-img"><div class="feature-img wordpress-connect no-border"></div></a>
					<a href="http://jetpack.me/support/sso/" data-name="Jetpack Single Sign On" class="feature-description">
						<h3><?php 
        _e('Single Sign On', 'jetpack');
        ?>
</h3>
						<p><?php 
        _e('Let users log in through WordPress.com with one click.', 'jetpack');
        ?>
</p>
					</a>
				</div>

				<div class="feature">
					<a href="http://jetpack.me/support/wordpress-com-stats/" data-name="WordPress.com Stats" class="f-img"><div class="feature-img wordpress-stats"></div></a>
					<a href="http://jetpack.me/support/wordpress-com-stats/" data-name="WordPress.com Stats" class="feature-description">
						<h3><?php 
        _e('WordPress.com Stats', 'jetpack');
        ?>
</h3>
						<p><?php 
        _e('Simple, concise site stats with no additional load on your server.', 'jetpack');
        ?>
</p>
					</a>
				</div>
			</div>
		</div><!-- .featured -->
		<div class="page-content about">
		<div class="module-grid">
			<h2><?php 
        esc_html_e('Jetpack features', 'jetpack');
        ?>
</h2>

			<!-- form with search and filters -->
			<form id="module-search">
				<input type="text" id="jetpack-search" class="module-search" placeholder="<?php 
        esc_attr_e('Search the Jetpack features', 'jetpack');
        ?>
" /><label for="jetpack-search"><?php 
        esc_html_e('Search', 'jetpack');
        ?>
</label>
			</form>

			<div class="jp-filter" id="jp-filters">
				<a href="#" id="newest" data-filter="introduced" class="selected"><?php 
        esc_html_e('Newest', 'jetpack');
        ?>
</a>
				<a href="#" id="category" data-filter="cat"><?php 
        _e('Category', 'jetpack');
        ?>
</a>
				<a href="#" id="alphabetical" data-filter="name"><?php 
        esc_html_e('Alphabetical', 'jetpack');
        ?>
</a>
			</div>

			<div class="modules"></div>

			<a href="#" class="load-more jp-button"><?php 
        esc_html_e('Load more', 'jetpack');
        ?>
</a>
		</div><!-- .module-grid --></div><!-- .page -->

		<?php 
        $this->admin_page_bottom();
    }