admin_url() public static method

public static admin_url ( $args = null )
 /**
  * Authorizations
  */
 function client_authorize()
 {
     $data = stripslashes_deep($_GET);
     $data['auth_type'] = 'client';
     $role = Jetpack::translate_current_user_to_role();
     $redirect = isset($data['redirect']) ? esc_url_raw((string) $data['redirect']) : '';
     $this->check_admin_referer("jetpack-authorize_{$role}_{$redirect}");
     $result = $this->authorize($data);
     if (is_wp_error($result)) {
         Jetpack::state('error', $result->get_error_code());
     }
     if (wp_validate_redirect($redirect)) {
         $this->wp_safe_redirect($redirect);
     } else {
         $this->wp_safe_redirect(Jetpack::admin_url());
     }
     /**
      * Fires after the Jetpack client is authorized to communicate with WordPress.com.
      *
      * @since 4.2.0
      *
      * @param int Jetpack Blog ID.
      */
     do_action('jetpack_client_authorized', Jetpack_Options::get_option('id'));
     $this->do_exit();
 }
 /**
  * If user is allowed to see the Jetpack Admin, add Settings sub-link.
  *
  * @since 4.3.0
  */
 function jetpack_add_settings_sub_nav_item()
 {
     if ((Jetpack::is_development_mode() || Jetpack::is_active()) && current_user_can('jetpack_admin_page')) {
         global $submenu;
         $submenu['jetpack'][] = array(__('Settings', 'jetpack'), 'jetpack_admin_page', Jetpack::admin_url('page=jetpack#/settings'));
     }
 }
Example #3
0
 public function jetpack_configuration_load()
 {
     if (Jetpack::is_user_connected() && !self::is_active()) {
         Jetpack::deactivate_module($this->module);
         Jetpack::state('message', 'module_deactivated');
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
         die;
     }
     if (!empty($_POST['action']) && $_POST['action'] == 'monitor-save') {
         check_admin_referer('monitor-settings');
         $this->update_option_receive_jetpack_monitor_notification(isset($_POST['receive_jetpack_monitor_notification']));
         Jetpack::state('message', 'module_configured');
         wp_safe_redirect(Jetpack::module_configuration_url($this->module));
     }
 }
Example #4
0
/**
 * Module Name: Monitor
 * Module Description: Jetpack Monitor will keep tabs on your site, and alert you the moment that downtime is detected.
 * Sort Order: 55
 * First Introduced: 2.6
 * Requires Connection: Yes
 * Auto Activate: No
 */
function jetpack_monitor_toggle()
{
    $jetpack = Jetpack::init();
    if (!$jetpack->current_user_is_connection_owner()) {
        Jetpack::state('module', 'monitor');
        Jetpack::state('error', 'master_user_required');
        // Technically this call to `wp_safe_redirect` is not required because
        // `Jetpack::activate_module` already sets up a redirect. However, this
        // might not stay the case forever so it's clearer to do it here as well.
        wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
        die;
    }
    $jetpack->sync->register('noop');
    if (false !== strpos(current_filter(), 'jetpack_activate_module_')) {
        Jetpack::check_privacy(__FILE__);
    }
}
 /**
  * Authorizations
  */
 function client_authorize()
 {
     $data = stripslashes_deep($_GET);
     $data['auth_type'] = 'client';
     $jetpack = $this->get_jetpack();
     $role = $jetpack->translate_current_user_to_role();
     $redirect = isset($data['redirect']) ? esc_url_raw((string) $data['redirect']) : '';
     $this->check_admin_referer("jetpack-authorize_{$role}_{$redirect}");
     $result = $this->authorize($data);
     if (is_wp_error($result)) {
         Jetpack::state('error', $result->get_error_code());
     }
     if (wp_validate_redirect($redirect)) {
         $this->wp_safe_redirect($redirect);
     } else {
         $this->wp_safe_redirect(Jetpack::admin_url());
     }
     $this->do_exit();
 }
    function no_credentials_admin_notice()
    {
        $disable_url = wp_nonce_url(Jetpack::admin_url('action=deactivate&module=wpcc'), 'jetpack_deactivate-wpcc');
        ?>
		<div id="wpcc-needs-config" class="updated">
			<p class="alignright"><a href="<?php 
        echo esc_url($disable_url);
        ?>
"><?php 
        _e('Close', 'jetpack');
        ?>
</a></p>
			<p><?php 
        printf(__('<strong>Almost done.</strong> Before WordPress.com Connect can finish activating, you\'ll need to <a href="%s">register your website as an application on WordPress.com</a>', 'jetpack'), esc_url(admin_url('options-general.php#wpcc-sign-on-section')));
        ?>
</p>
		</div>
		<?php 
    }
Example #7
0
    public function dashboard_widget_connect_to_wpcom()
    {
        ?>
		<div class="wpcom-connect">
			<h3><?php 
        esc_html_e('Boost traffic, enhance security, and improve performance.', 'jetpack');
        ?>
</h3>
			<p><?php 
        esc_html_e('Jetpack connects your site to WordPress.com to give you traffic and customization tools, enhanced security, speed boosts, and more.', 'jetpack');
        ?>
</p>

			<div class="actions">
				<a href="<?php 
        echo $this->build_connect_url();
        ?>
" class="button button-jetpack">
					<?php 
        esc_html_e('Connect to WordPress.com', 'jetpack');
        ?>
				</a>
				<?php 
        if (current_user_can('activate_plugins')) {
            ?>
				<small><a href="<?php 
            echo esc_url(wp_nonce_url(Jetpack::admin_url('jetpack-notice=dismiss'), 'jetpack-deactivate'));
            ?>
">
					<?php 
            esc_html_e('or, deactivate Jetpack', 'jetpack');
            ?>
				</a></small>
				<?php 
        }
        ?>
			</div>
		</div>
		<?php 
    }
 /**
  * State is passed via cookies from one request to the next, but never to subsequent requests.
  * SET: state( $key, $value );
  * GET: $value = state( $key );
  *
  * @param string $key
  * @param string $value
  * @param bool $restate private
  */
 public static function state($key = null, $value = null, $restate = false)
 {
     static $state = array();
     static $path, $domain;
     if (!isset($path)) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
         $admin_url = Jetpack::admin_url();
         $bits = parse_url($admin_url);
         if (is_array($bits)) {
             $path = isset($bits['path']) ? dirname($bits['path']) : null;
             $domain = isset($bits['host']) ? $bits['host'] : null;
         } else {
             $path = $domain = null;
         }
     }
     // Extract state from cookies and delete cookies
     if (isset($_COOKIE['jetpackState']) && is_array($_COOKIE['jetpackState'])) {
         $yum = $_COOKIE['jetpackState'];
         unset($_COOKIE['jetpackState']);
         foreach ($yum as $k => $v) {
             if (strlen($v)) {
                 $state[$k] = $v;
             }
             setcookie("jetpackState[{$k}]", false, 0, $path, $domain);
         }
     }
     if ($restate) {
         foreach ($state as $k => $v) {
             setcookie("jetpackState[{$k}]", $v, 0, $path, $domain);
         }
         return;
     }
     // Get a state variable
     if (isset($key) && !isset($value)) {
         if (array_key_exists($key, $state)) {
             return $state[$key];
         }
         return null;
     }
     // Set a state variable
     if (isset($key) && isset($value)) {
         if (is_array($value) && isset($value[0])) {
             $value = $value[0];
         }
         $state[$key] = $value;
         setcookie("jetpackState[{$key}]", $value, 0, $path, $domain);
     }
 }
    public static function dashboard_widget_footer()
    {
        ?>
		<footer>

		<div class="protect">
			<?php 
        if (Jetpack::is_module_active('protect')) {
            ?>
				<h3><?php 
            echo number_format_i18n(get_site_option('jetpack_protect_blocked_attempts', 0));
            ?>
</h3>
				<p><?php 
            echo esc_html_x('Blocked malicious login attempts', '{#} Blocked malicious login attempts -- number is on a prior line, text is a caption.', 'jetpack');
            ?>
</p>
			<?php 
        } elseif (current_user_can('jetpack_activate_modules') && !self::is_development_mode()) {
            ?>
				<a href="<?php 
            echo esc_url(wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => 'protect')), 'jetpack_activate-protect'));
            ?>
" class="button button-jetpack" title="<?php 
            esc_attr_e('Protect helps to keep you secure from brute-force login attacks.', 'jetpack');
            ?>
">
					<?php 
            esc_html_e('Activate Protect', 'jetpack');
            ?>
				</a>
			<?php 
        } else {
            ?>
				<?php 
            esc_html_e('Protect is inactive.', 'jetpack');
            ?>
			<?php 
        }
        ?>
		</div>

		<div class="akismet">
			<?php 
        if (is_plugin_active('akismet/akismet.php')) {
            ?>
				<h3><?php 
            echo number_format_i18n(get_option('akismet_spam_count', 0));
            ?>
</h3>
				<p><?php 
            echo esc_html_x('Spam comments blocked by Akismet.', '{#} Spam comments blocked by Akismet -- number is on a prior line, text is a caption.', 'jetpack');
            ?>
</p>
			<?php 
        } elseif (current_user_can('activate_plugins') && !is_wp_error(validate_plugin('akismet/akismet.php'))) {
            ?>
				<a href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'activate', 'plugin' => 'akismet/akismet.php'), admin_url('plugins.php')), 'activate-plugin_akismet/akismet.php'));
            ?>
" class="button button-jetpack">
					<?php 
            esc_html_e('Activate Akismet', 'jetpack');
            ?>
				</a>
			<?php 
        } else {
            ?>
				<p><a href="<?php 
            echo esc_url('https://akismet.com/?utm_source=jetpack&utm_medium=link&utm_campaign=Jetpack%20Dashboard%20Widget%20Footer%20Link');
            ?>
"><?php 
            esc_html_e('Akismet can help to keep your blog safe from spam!', 'jetpack');
            ?>
</a></p>
			<?php 
        }
        ?>
		</div>


		<?php 
        if (!current_user_can('edit_posts') && self::is_user_connected()) {
            ?>
			<div style="width: 100%; text-align: center; padding-top: 20px; clear: both;"><a class="button" title="<?php 
            esc_attr_e('Unlink your account from WordPress.com', 'jetpack');
            ?>
" href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'unlink', 'redirect' => 'sub-unlink'), admin_url('index.php')), 'jetpack-unlink'));
            ?>
"><?php 
            esc_html_e('Unlink your account from WordPress.com', 'jetpack');
            ?>
</a></div>
		<?php 
        }
        ?>

		</footer>
		<?php 
    }
Example #10
0
    public function admin_jetpack_manage_notice()
    {
        $dismissed = get_site_option('jetpack_dismissed_protect_multisite_banner');
        if ($dismissed) {
            return;
        }
        $referer = '&_wp_http_referer=' . add_query_arg('_wp_http_referer', null);
        $opt_out_url = wp_nonce_url(Jetpack::admin_url('jetpack-notice=jetpack-protect-multisite-opt-out' . $referer), 'jetpack_protect_multisite_banner_opt_out');
        ?>
		<div id="message" class="updated jetpack-message jp-banner is-opt-in protect-error" style="display:block !important;">
			<a class="jp-banner__dismiss" href="<?php 
        echo esc_url($opt_out_url);
        ?>
" title="<?php 
        esc_attr_e('Dismiss this notice.', 'jetpack');
        ?>
"></a>
			<div class="jp-banner__content">
				<h4><?php 
        esc_html_e('Protect cannot keep your site secure.', 'jetpack');
        ?>
</h4>
				<p><?php 
        printf(__('Thanks for activating Protect! To start protecting your site, please network activate Jetpack on your Multisite installation and activate Protect on your primary site. Due to the way logins are handled on WordPress Multisite, Jetpack must be network-enabled in order for Protect to work properly. <a href="%s" target="_blank">Learn More</a>', 'jetpack'), 'http://jetpack.me/support/multisite-protect');
        ?>
</p>
			</div>
			<div class="jp-banner__action-container is-opt-in">
				<a href="<?php 
        echo network_admin_url('plugins.php');
        ?>
" class="jp-banner__button" id="wpcom-connect"><?php 
        _e('View Network Admin', 'jetpack');
        ?>
</a>
			</div>
		</div>
		<?php 
    }
Example #11
0
							<?php 
    if (!Jetpack::is_staging_site()) {
        ?>
								<h2><?php 
        _e('Disconnecting Jetpack', 'jetpack');
        ?>
</h2>
								<p><?php 
        _e('Before you completely disconnect Jetpack is there anything we can do to help?', 'jetpack');
        ?>
</p>
								<a class="button" id="confirm-disconnect" title="<?php 
        esc_attr_e('Disconnect Jetpack', 'jetpack');
        ?>
" href="<?php 
        echo wp_nonce_url(Jetpack::admin_url('action=disconnect'), 'jetpack-disconnect');
        ?>
"><?php 
        _e('Confirm Disconnect', 'jetpack');
        ?>
</a>
								<a class="button primary" id="support-no-disconnect" target="_blank" title="<?php 
        esc_attr_e('Jetpack Support', 'jetpack');
        ?>
" href="http://jetpack.me/contact-support/"><?php 
        esc_html_e('I Need Support', 'jetpack');
        ?>
</a>
							<?php 
    } else {
        ?>
 function authorize()
 {
     $data = stripslashes_deep($_GET);
     $args = array();
     $redirect = isset($data['redirect']) ? esc_url_raw((string) $data['redirect']) : '';
     $jetpack_unique_connection = Jetpack_Options::get_option('unique_connection');
     // Checking if site has been active/connected previously before recording unique connection
     if (!$jetpack_unique_connection) {
         // jetpack_unique_connection option has never been set
         $jetpack_unique_connection = array('connected' => 0, 'disconnected' => 0);
         update_option('jetpack_unique_connection', $jetpack_unique_connection);
         //track unique connection
         $jetpack = Jetpack::init();
         $jetpack->stat('connections', 'unique-connection');
         $jetpack->do_stats('server_side');
     }
     // increment number of times connected
     $jetpack_unique_connection['connected'] += 1;
     Jetpack_Options::update_option('unique_connection', $jetpack_unique_connection);
     do {
         $jetpack = $this->get_jetpack();
         $role = $jetpack->translate_current_user_to_role();
         if (!$role) {
             Jetpack::state('error', 'no_role');
             break;
         }
         $cap = $jetpack->translate_role_to_cap($role);
         if (!$cap) {
             Jetpack::state('error', 'no_cap');
             break;
         }
         $this->check_admin_referer("jetpack-authorize_{$role}_{$redirect}");
         if (!empty($data['error'])) {
             Jetpack::state('error', $data['error']);
             break;
         }
         if (empty($data['state'])) {
             Jetpack::state('error', 'no_state');
             break;
         }
         if (!ctype_digit($data['state'])) {
             Jetpack::state('error', 'invalid_state');
             break;
         }
         $current_user_id = get_current_user_id();
         if ($current_user_id != $data['state']) {
             Jetpack::state('error', 'wrong_state');
             break;
         }
         if (empty($data['code'])) {
             Jetpack::state('error', 'no_code');
             break;
         }
         $token = $this->get_token($data);
         if (is_wp_error($token)) {
             if ($error = $token->get_error_code()) {
                 Jetpack::state('error', $error);
             } else {
                 Jetpack::state('error', 'invalid_token');
             }
             Jetpack::state('error_description', $token->get_error_message());
             break;
         }
         if (!$token) {
             Jetpack::state('error', 'no_token');
             break;
         }
         $is_master_user = !Jetpack::is_active();
         Jetpack::update_user_token($current_user_id, sprintf('%s.%d', $token, $current_user_id), $is_master_user);
         if ($is_master_user) {
             Jetpack::state('message', 'authorized');
         } else {
             Jetpack::state('message', 'linked');
             // Don't activate anything since we are just connecting a user.
             break;
         }
         if ($active_modules = Jetpack_Options::get_option('active_modules')) {
             Jetpack_Options::delete_option('active_modules');
             Jetpack::activate_default_modules(999, 1, $active_modules);
         } else {
             Jetpack::activate_default_modules();
         }
         // Sync all registers options and constants
         do_action('jetpack_sync_all_registered_options');
         // Start nonce cleaner
         wp_clear_scheduled_hook('jetpack_clean_nonces');
         wp_schedule_event(time(), 'hourly', 'jetpack_clean_nonces');
     } while (false);
     if (wp_validate_redirect($redirect)) {
         $this->wp_safe_redirect($redirect);
     } else {
         $this->wp_safe_redirect(Jetpack::admin_url());
     }
     $this->do_exit();
 }
Example #13
0
    ?>
" onclick="return confirm('<?php 
    echo htmlspecialchars(__('Are you sure you want to disconnect from WordPress.com?', 'jetpack'), ENT_QUOTES);
    ?>
');"><?php 
    esc_html_e('Disconnect from WordPress.com', 'jetpack');
    ?>
</a>
					<?php 
}
?>
					<?php 
if ($is_active && $is_user_connected && !$is_master_user) {
    ?>
						<a href="<?php 
    echo wp_nonce_url(Jetpack::admin_url('action=unlink'), 'jetpack-unlink');
    ?>
"><?php 
    esc_html_e('Unlink your user account', 'jetpack');
    ?>
</a>
					<?php 
}
?>

				</div>
			</nav><!-- .secondary -->
		</div><!-- .footer -->

		<div class="modal" aria-labelledby="modal-label">
			<header>
Example #14
0
			<nav class="secondary nav-horizontal">
				<div class="secondary-footer">
					<a href="http://jetpack.me">Jetpack <?php 
echo JETPACK__VERSION;
?>
</a>
					<a href="http://wordpress.com/tos/"><?php 
esc_html_e('Terms', 'jetpack');
?>
</a>
					<a href="http://automattic.com/privacy/"><?php 
esc_html_e('Privacy', 'jetpack');
?>
</a>
					<a href="<?php 
echo esc_url(Jetpack::admin_url('page=jetpack-debugger'));
?>
" title="<?php 
esc_attr_e('Test your site&#8217;s compatibility with Jetpack.', 'jetpack');
?>
"><?php 
_e('Debug', 'jetpack');
?>
</a>
					<a href="http://jetpack.me/contact-support/" title="<?php 
esc_attr_e('Contact the Jetpack Happiness Squad.', 'jetpack');
?>
"><?php 
_e('Support', 'jetpack');
?>
</a>
" target="_blank" class="jp-button--settings"><?php 
    esc_html_e('Feedback', 'jetpack');
    ?>
</a>
						</li>
					<?php 
}
// End if connected or dev mode and is admin
?>

					<?php 
if (Jetpack::is_active() && !Jetpack::is_development_mode()) {
    ?>
						<li class="jetpack-modules">
							<a href="<?php 
    echo Jetpack::admin_url('page=my_jetpack');
    ?>
" class="jp-button--settings <?php 
    if ('my_jetpack' == $current) {
        echo 'current';
    }
    ?>
"><?php 
    esc_html_e('My Jetpack', 'jetpack');
    ?>
</a>
						</li>
					<?php 
}
?>
				</ul>
 /**
  * Add action links to Stream drop row in admin list screen
  *
  * @filter wp_stream_action_links_{connector}
  *
  * @param array $links   Previous links registered
  * @param object $record Stream record
  *
  * @return array Action links
  */
 public function action_links($links, $record)
 {
     // @todo provide proper action links
     if ('jetpack' === $record->connector) {
         if ('modules' === $record->context) {
             $slug = $record->get_meta('module_slug', true);
             if (is_array($slug)) {
                 $slug = current($slug);
             }
             if (Jetpack::is_module_active($slug)) {
                 if (apply_filters('jetpack_module_configurable_' . $slug, false)) {
                     $links[esc_html__('Configure', 'stream')] = Jetpack::module_configuration_url($slug);
                 }
                 $links[esc_html__('Deactivate', 'stream')] = wp_nonce_url(add_query_arg(array('action' => 'deactivate', 'module' => $slug), Jetpack::admin_url()), 'jetpack_deactivate-' . sanitize_title($slug));
             } else {
                 $links[esc_html__('Activate', 'stream')] = wp_nonce_url(add_query_arg(array('action' => 'activate', 'module' => $slug), Jetpack::admin_url()), 'jetpack_activate-' . sanitize_title($slug));
             }
         } elseif (Jetpack::is_module_active(str_replace('jetpack-', '', $record->context))) {
             $slug = str_replace('jetpack-', '', $record->context);
             // handling jetpack-comment anomaly
             if (apply_filters('jetpack_module_configurable_' . $slug, false)) {
                 $links[esc_html__('Configure module', 'stream')] = Jetpack::module_configuration_url($slug);
             }
         }
     }
     return $links;
 }
Example #17
0
 function authorize()
 {
     $data = stripslashes_deep($_GET);
     $args = array();
     $redirect = isset($data['redirect']) ? esc_url_raw((string) $data['redirect']) : '';
     do {
         $jetpack = Jetpack::init();
         $role = $jetpack->translate_current_user_to_role();
         if (!$role) {
             Jetpack::state('error', 'no_role');
             break;
         }
         $cap = $jetpack->translate_role_to_cap($role);
         if (!$cap) {
             Jetpack::state('error', 'no_cap');
             break;
         }
         check_admin_referer("jetpack-authorize_{$role}_{$redirect}");
         if (!empty($data['error'])) {
             Jetpack::state('error', $data['error']);
             break;
         }
         if (empty($data['state'])) {
             Jetpack::state('error', 'no_state');
             break;
         }
         if (!ctype_digit($data['state'])) {
             Jetpack::state('error', 'invalid_state');
             break;
         }
         $current_user_id = get_current_user_id();
         if ($current_user_id != $data['state']) {
             Jetpack::state('error', 'wrong_state');
             break;
         }
         if (empty($data['code'])) {
             Jetpack::state('error', 'no_code');
             break;
         }
         $token = $this->get_token($data);
         if (is_wp_error($token)) {
             if ($error = $token->get_error_code()) {
                 Jetpack::state('error', $error);
             } else {
                 Jetpack::state('error', 'invalid_token');
             }
             Jetpack::state('error_description', $token->get_error_message());
             break;
         }
         if (!$token) {
             Jetpack::state('error', 'no_token');
             break;
         }
         $is_master_user = !Jetpack::is_active();
         Jetpack::update_user_token($current_user_id, sprintf('%s.%d', $token, $current_user_id), $is_master_user);
         if ($is_master_user) {
             Jetpack::state('message', 'authorized');
         } else {
             Jetpack::state('message', 'linked');
             // Don't activate anything since we are just connecting a user.
             break;
         }
         if ($active_modules = Jetpack::get_option('active_modules')) {
             Jetpack::delete_option('active_modules');
             Jetpack::activate_default_modules(999, 1, $active_modules);
         } else {
             Jetpack::activate_default_modules();
         }
         $jetpack->sync->register('noop');
         // Spawn a sync to make sure the Jetpack Servers know what modules are active.
         // Start nonce cleaner
         wp_clear_scheduled_hook('jetpack_clean_nonces');
         wp_schedule_event(time(), 'hourly', 'jetpack_clean_nonces');
     } while (false);
     if (wp_validate_redirect($redirect)) {
         wp_safe_redirect($redirect);
     } else {
         wp_safe_redirect(Jetpack::admin_url());
     }
     exit;
 }
Example #18
0
</a>
					<a href="http://jetpack.com/survey/?rel=<?php 
echo JETPACK__VERSION;
?>
" title="<?php 
esc_attr_e('Take a survey.  Tell us how we&#8217;re doing.', 'jetpack');
?>
"><?php 
_e('Give Us Feedback', 'jetpack');
?>
</a>
					<?php 
if (Jetpack::is_active() && current_user_can('jetpack_disconnect')) {
    ?>
						<a href="<?php 
    echo esc_url(Jetpack::admin_url('page=my_jetpack#disconnect'));
    ?>
"><?php 
    esc_html_e('Disconnect Jetpack', 'jetpack');
    ?>
</a>
					<?php 
}
?>
				</div>
			</nav><!-- .secondary -->
		</div><!-- .footer -->

		<div class="modal" aria-labelledby="modal-label">
			<header>
				<a href="#" class="close">&times;</a>
    function display_connection_error()
    {
        $code = false;
        if (isset($_GET['service'])) {
            $service_name = $_GET['service'];
            $error = sprintf(__('There was a problem connecting to %s to create an authorized connection. Please try again in a moment.', 'jetpack'), Publicize::get_service_label($service_name));
        } else {
            if (isset($_GET['publicize_error'])) {
                $code = strtolower($_GET['publicize_error']);
                switch ($code) {
                    case '400':
                        $error = __('An invalid request was made. This normally means that something intercepted or corrupted the request from your server to the Jetpack Server. Try again and see if it works this time.', 'jetpack');
                        break;
                    case 'secret_mismatch':
                        $error = __('We could not verify that your server is making an authorized request. Please try again, and make sure there is nothing interfering with requests from your server to the Jetpack Server.', 'jetpack');
                        break;
                    case 'empty_blog_id':
                        $error = __('No blog_id was included in your request. Please try disconnecting Jetpack from WordPress.com and then reconnecting it. Once you have done that, try connecting Publicize again.', 'jetpack');
                        break;
                    case 'empty_state':
                        $error = sprintf(__('No user information was included in your request. Please make sure that your user account has connected to Jetpack. Connect your user account by going to the <a href="%s">Jetpack page</a> within wp-admin.', 'jetpack'), Jetpack::admin_url());
                        break;
                    default:
                        $error = __('Something which should never happen, happened. Sorry about that. If you try again, maybe it will work.', 'jetpack');
                        break;
                }
            } else {
                $error = __('There was a problem connecting with Publicize. Please try again in a moment.', 'jetpack');
            }
        }
        // Using the same formatting/style as Jetpack::admin_notices() error
        ?>
		<div id="message" class="jetpack-message jetpack-err">
			<div class="squeezer">
				<h4><?php 
        echo wp_kses($error, array('a' => array('href' => true), 'code' => true, 'strong' => true, 'br' => true, 'b' => true));
        ?>
</h4>
				<?php 
        if ($code) {
            ?>
				<p><?php 
            printf(__('Error code: %s', 'jetpack'), esc_html(stripslashes($code)));
            ?>
</p>
				<?php 
        }
        ?>
			</div>
		</div>
		<?php 
    }
    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'));
        }
        global $current_user;
        get_currentuserinfo();
        $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\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) . 'gvn/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) . 'gvn/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);
        $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">known conflicts</a> with Jetpack – check the <a href="%2$s">list</a>. (You can also browse the <a href="%3$s">Jetpack support pages</a> or <a href="%4$s">Jetpack support forum</a> to see if others have experienced and solved the problem.)', 'jetpack'), 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/getting-started-with-jetpack/known-issues/', 'http://jetpack.me/support/', 'http://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 
        esc_html_e("If your problem isn't known or caused by a plugin, try activating Twenty Twelve (the default WordPress theme). 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>
					<hr />
					<div id="sync-related-posts">
						<p><?php 
            echo esc_html__('Some features of Jetpack uses the WordPress.com infrastructure and requires that your public content be mirrored there. If you see intermittent issues only affecting certain posts, please try requesting a reindex of your posts.', 'jetpack');
            ?>
</p>
						<?php 
            echo Jetpack::init()->sync->reindex_ui();
            ?>
					</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="http://jetpack.me/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());
            ?>
">
					<input type="hidden" name="subject" id="subject" value="from: <?php 
            echo esc_attr(site_url());
            ?>
 Jetpack contact form">
					<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_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_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_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>
		</div>
	<?php 
    }
 function column_name($item)
 {
     $actions = array('info' => sprintf('<a href="%s">%s</a>', esc_url('#'), esc_html__('Module Info', 'jetpack')));
     if (!empty($item['configurable'])) {
         $actions['configure'] = $item['configurable'];
     }
     if (empty($item['activated']) && $this->is_module_available($item)) {
         $url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'activate', 'module' => $item['module'])), 'jetpack_activate-' . $item['module']);
         $actions['activate'] = sprintf('<a href="%s">%s</a>', esc_url($url), esc_html__('Activate', 'jetpack'));
     } elseif (!empty($item['activated'])) {
         $url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'deactivate', 'module' => $item['module'])), 'jetpack_deactivate-' . $item['module']);
         $actions['delete'] = sprintf('<a href="%s">%s</a>', esc_url($url), esc_html__('Deactivate', 'jetpack'));
     }
     return $this->row_actions($actions) . wptexturize($item['name']);
 }
Example #22
0
    function print_js()
    {
        $link_accounts_url = is_user_logged_in() && !Jetpack::is_user_connected() ? Jetpack::admin_url() : false;
        ?>
<script type="text/javascript">
/* <![CDATA[ */
	var wpNotesIsJetpackClient = true;
<?php 
        if ($link_accounts_url) {
            ?>
	var wpNotesLinkAccountsURL = '<?php 
            print $link_accounts_url;
            ?>
';
<?php 
        }
        ?>
/* ]]> */
</script>
<?php 
    }
    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 
    }
Example #24
0
?>
" <?php 
if ('jetpack' == $current) {
    echo 'class="current"';
}
?>
><span><?php 
esc_html_e('Jetpack', 'jetpack');
?>
</span></a></li>
					<?php 
if ((Jetpack::is_active() || Jetpack::is_development_mode()) && current_user_can('jetpack_manage_modules')) {
    ?>
					<li class="jetpack-modules">
						<a href="<?php 
    echo Jetpack::admin_url('page=jetpack_modules');
    ?>
" class="jp-button--settings <?php 
    if ('jetpack_modules' == $current) {
        echo 'current';
    }
    ?>
"><?php 
    esc_html_e('Settings', 'jetpack');
    ?>
</a>
					</li>
					<li class="jetpack-modules">
						<a href="http://jetpack.me/survey/?rel=<?php 
    echo JETPACK__VERSION;
    ?>
 function authorize()
 {
     $data = stripslashes_deep($_GET);
     $args = array();
     do {
         $jetpack = Jetpack::init();
         $role = $jetpack->translate_current_user_to_role();
         if (!$role) {
             Jetpack::state('error', 'no_role');
             break;
         }
         $cap = $jetpack->translate_role_to_cap($role);
         if (!$cap) {
             Jetpack::state('error', 'no_cap');
             break;
         }
         check_admin_referer("jetpack-authorize_{$role}");
         if (!empty($data['error'])) {
             Jetpack::state('error', $data['error']);
             break;
         }
         if (empty($data['state'])) {
             Jetpack::state('error', 'no_state');
             break;
         }
         if (!ctype_digit($data['state'])) {
             Jetpack::state('error', 'invalid_state');
             break;
         }
         $current_user_id = get_current_user_id();
         if ($current_user_id != $data['state']) {
             Jetpack::state('error', 'wrong_state');
             break;
         }
         if (empty($data['code'])) {
             Jetpack::state('error', 'no_code');
             break;
         }
         $token = $this->get_token($data);
         if (is_wp_error($token)) {
             if ($error = $token->get_error_code()) {
                 Jetpack::state('error', $error);
             } else {
                 Jetpack::state('error', 'invalid_token');
             }
             Jetpack::state('error_description', $token->get_error_message());
             break;
         }
         if (!$token) {
             Jetpack::state('error', 'no_token');
             break;
         }
         Jetpack::update_option('user_token', sprintf('%s.%d', $token, $current_user_id), true);
         Jetpack::state('message', 'authorized');
         if ($active_modules = Jetpack::get_option('active_modules')) {
             Jetpack::delete_option('active_modules');
             Jetpack::activate_default_modules(999, 1, $active_modules);
         } else {
             Jetpack::activate_default_modules();
         }
         // Start nonce cleaner
         wp_clear_scheduled_hook('jetpack_clean_nonces');
         wp_schedule_event(time(), 'hourly', 'jetpack_clean_nonces');
     } while (false);
     wp_safe_redirect(Jetpack::admin_url());
     exit;
 }
    public function dashboard_widget_connect_to_wpcom()
    {
        ?>
		<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('Boost traffic, enhance security, and improve performance.', 'jetpack');
        ?>
</h3>
			<p><?php 
        esc_html_e('Jetpack connects your site to WordPress.com to give you traffic and customization tools, enhanced security, speed boosts, and more.', 'jetpack');
        ?>
</p>

			<div class="actions">
				<a href="<?php 
        echo $this->build_connect_url();
        ?>
" class="button button-primary">
					<?php 
        esc_html_e('Connect to WordPress.com', 'jetpack');
        ?>
				</a>
				<?php 
        if (current_user_can('activate_plugins')) {
            ?>
				<small><a href="<?php 
            echo esc_url(wp_nonce_url(Jetpack::admin_url('jetpack-notice=dismiss'), 'jetpack-deactivate'));
            ?>
" title="Deactivate Jetpack">
					<?php 
            esc_html_e('or, deactivate Jetpack', 'jetpack');
            ?>
				</a></small>
				<?php 
        }
        ?>
			</div>
		</div>
		<?php 
    }
Example #27
0
function jetpack_related_posts_more_info()
{
    $template = <<<EOT
\t\t<div class="jp-info-img">
\t\t\t<a href="http://jetpack.me/support/related-posts/">
\t\t\t\t<img class="jp-info-img" src="%s" alt="%s" width="300" height="98" />
\t\t\t</a>
\t\t</div>

\t\t<p>%s</p>
\t\t<p>&rarr; <a href="http://jetpack.me/support/related-posts/">%s</a></p>
\t\t<hr />
\t\t<p><a href="%s#sync-related-posts">%s</a></p>
EOT;
    printf($template, plugins_url(basename(dirname(dirname(__FILE__))) . '/images/screenshots/related-posts.jpg'), esc_attr__('Related Posts', 'jetpack'), esc_html__('"Related Posts" shows additional relevant links from your site under your posts. If the feature is enabled, links appear underneath your Sharing Buttons and WordPress.com Likes (if you’ve turned these on).', 'jetpack'), esc_html__('More information on using Related Posts.', 'jetpack'), esc_url(Jetpack::admin_url(array('page' => 'jetpack-debugger'))), esc_html__('This feature uses the WordPress.com infrastructure and requires that your public content be mirrored there. If you see intermittent issues only affecting certain posts, request a reindex of your posts.', 'jetpack'));
}
Example #28
0
<?php

$activate_url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'activate', 'module' => 'manage')), 'jetpack_activate-manage');
$section = isset($_GET['section']) ? $_GET['section'] : null;
$normalized_site_url = Jetpack::build_raw_urls(get_home_url());
$description = __('Well that was easy. You can now manage all of your sites in one convenient place on WordPress.com', 'jetpack');
switch ($section) {
    case 'plugins':
        $link = 'https://wordpress.com/plugins/' . $normalized_site_url;
        $link_title = __('Manage Your Plugins', 'jetpack');
        break;
    case 'themes':
        $link = 'https://wordpress.com/plugins/' . $normalized_site_url;
        $link_title = __('Manage Your Themes', 'jetpack');
        break;
    case 'security-settings':
        $link = 'https://wordpress.com/settings/security/' . $normalized_site_url;
        $link_title = __('Manage Your Security Settings', 'jetpack');
        break;
    case 'menus':
        $link = 'https://wordpress.com/menus/' . $normalized_site_url;
        $link_title = __('Manage Your Menus', 'jetpack');
        break;
    default:
        $link = 'https://wordpress.com/stats/day/' . $normalized_site_url;
        $link_title = __('Manage Your Site', 'jetpack');
        break;
}
?>
<div class="page-content landing manage-page">
	<div class="manage__icon">
echo esc_html(JETPACK__VERSION);
?>
</a> |
					<a href="http://automattic.com/privacy/" target="_blank"><?php 
_e('Privacy Policy', 'jetpack');
?>
</a> |
					<a href="http://wordpress.com/tos/" target="_blank"><?php 
_e('Terms of Service', 'jetpack');
?>
</a> |
<?php 
if (current_user_can('manage_options')) {
    ?>
					<a href="<?php 
    echo Jetpack::admin_url(array('page' => 'jetpack-debugger'));
    ?>
"><?php 
    _e('Debug', 'jetpack');
    ?>
</a> |
<?php 
}
?>
					<a href="http://jetpack.com/support/" target="_blank"><?php 
_e('Support', 'jetpack');
?>
</a>
				</p>
			</div>
		</div>
    /**
     * Renders the legacy connection banner.
     */
    function render_legacy_banner()
    {
        $legacy_banner_from = self::check_ab_test_not_expired() ? 'banner-legacy' : 'banner';
        ?>
		<div id="message" class="updated jp-banner">
			<a
				href="<?php 
        echo esc_url($this->get_dismiss_and_deactivate_url());
        ?>
"
				class="notice-dismiss" title="<?php 
        esc_attr_e('Dismiss this notice', 'jetpack');
        ?>
">

			</a>
			<div class="jp-banner__description-container">
				<h2 class="jp-banner__header"><?php 
        esc_html_e('Your Jetpack is almost ready!', 'jetpack');
        ?>
</h2>
				<p class="jp-banner__description">
					<?php 
        esc_html_e('Please connect to or create a WordPress.com account to enable Jetpack, including
								powerful security, traffic, and customization services.', 'jetpack');
        ?>
				</p>
				<p class="jp-banner__button-container">
					<a
						href="<?php 
        echo Jetpack::init()->build_connect_url(false, false, $legacy_banner_from);
        ?>
"
						class="button button-primary">
						<?php 
        esc_html_e('Connect to WordPress.com', 'jetpack');
        ?>
					</a>
					<a
						href="<?php 
        echo Jetpack::admin_url('admin.php?page=jetpack');
        ?>
"
						class="button"
						title="<?php 
        esc_attr_e('Learn about the benefits you receive when you connect Jetpack to WordPress.com', 'jetpack');
        ?>
 ">
						<?php 
        esc_html_e('Learn more', 'jetpack');
        ?>
					</a>
				</p>
			</div>
		</div>
	<?php 
    }