本文整理汇总了PHP中Jetpack::check_identity_crisis方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::check_identity_crisis方法的具体用法?PHP Jetpack::check_identity_crisis怎么用?PHP Jetpack::check_identity_crisis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::check_identity_crisis方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
add_action('jetpack_sync_processed_actions', array($this, 'maybe_clear_migrate_option'));
if (false === ($urls_in_crisis = Jetpack::check_identity_crisis())) {
return;
}
self::$wpcom_home_url = $urls_in_crisis['wpcom_home'];
add_action('init', array($this, 'wordpress_init'));
}
示例2: login_init
function login_init()
{
add_action('login_form', array($this, 'login_form'));
add_action('login_footer', array($this, 'login_footer'));
wp_enqueue_script('jquery');
wp_enqueue_style('genericons');
if (isset($_GET['action']) && 'jetpack-sso' == $_GET['action']) {
if (isset($_GET['result'], $_GET['user_id'], $_GET['sso_nonce']) && 'success' == $_GET['result']) {
$this->handle_login();
} else {
if (Jetpack::check_identity_crisis()) {
wp_die(__("Error: This site's Jetpack connection is currently experiencing problems.", 'jetpack'));
} else {
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
wp_safe_redirect($this->build_sso_url());
}
}
}
}
示例3: cron_exec
/**
* Method that gets executed on the wp-cron call
*
* @since 2.3.3
* @global string $wp_version
*/
public function cron_exec()
{
/*
* Check for an identity crisis
*
* If one exists:
* - Bump stat for ID crisis
* - Email site admin about potential ID crisis
*/
/**
* Setup an array of items that will eventually be stringified
* and sent off to the Jetpack API
*
* Associative array with format group => values
* - values should be an array that will be imploded to a string
*/
$jetpack = Jetpack::init();
$jetpack->stat('active-modules', implode(',', $jetpack->get_active_modules()));
$jetpack->stat('active', JETPACK__VERSION);
$jetpack->stat('wp-version', get_bloginfo('version'));
$jetpack->stat('php-version', PHP_VERSION);
$jetpack->stat('ssl', $jetpack->permit_ssl());
$jetpack->stat('language', get_bloginfo('language'));
$jetpack->stat('charset', get_bloginfo('charset'));
$jetpack->stat('qty-posts', wp_count_posts()->publish);
$jetpack->stat('qty-pages', wp_count_posts('page')->publish);
$jetpack->stat('qty-comments', wp_count_comments()->approved);
$jetpack->stat('is-multisite', is_multisite() ? 'multisite' : 'singlesite');
$jetpack->stat('identitycrisis', Jetpack::check_identity_crisis(1) ? 'yes' : 'no');
// Only check a few plugins, to see if they're currently active.
$plugins_to_check = array('vaultpress/vaultpress.php', 'akismet/akismet.php', 'wp-super-cache/wp-cache.php');
$plugins = array_intersect($plugins_to_check, get_option('active_plugins', array()));
foreach ($plugins as $plugin) {
$jetpack->stat('plugins', $plugin);
}
$jetpack->do_stats('server_side');
}
示例4: login_init
function login_init()
{
global $action;
/**
* If the user is attempting to logout AND the auto-forward to WordPress.com
* login is set then we need to ensure we do not auto-forward the user and get
* them stuck in an infinite logout loop.
*/
if (isset($_GET['loggedout']) && $this->bypass_login_forward_wpcom()) {
add_filter('jetpack_remove_login_form', '__return_true');
add_filter('gettext', array($this, 'remove_lost_password_text'));
}
/**
* Check to see if the site admin wants to automagically forward the user
* to the WordPress.com login page AND that the request to wp-login.php
* is not something other than login (Like logout!)
*/
if ($this->wants_to_login() && $this->bypass_login_forward_wpcom()) {
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
$this->maybe_save_cookie_redirect();
wp_safe_redirect($this->build_sso_url());
}
if ('login' === $action) {
add_action('login_footer', array($this, 'login_form'));
/*
if ( get_option( 'jetpack_sso_remove_login_form' ) ) {
// Check to see if the user is attempting to login via the default login form.
// If so we need to deny it and forward elsewhere.
if( isset( $_REQUEST['wp-submit'] ) && 'Log In' == $_REQUEST['wp-submit'] ) {
wp_die( 'Login not permitted by this method. ');
}
add_filter( 'gettext', array( $this, 'remove_lost_password_text' ) );
}
*/
} elseif ('jetpack-sso' === $action) {
if (isset($_GET['result'], $_GET['user_id'], $_GET['sso_nonce']) && 'success' == $_GET['result']) {
$this->handle_login();
add_action('login_footer', array($this, 'login_form'));
} else {
if (Jetpack::check_identity_crisis()) {
wp_die(__("Error: This site's Jetpack connection is currently experiencing problems.", 'jetpack'));
} else {
$this->maybe_save_cookie_redirect();
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
wp_safe_redirect($this->build_sso_url());
}
}
}
}
示例5: jetpack_debug_display_handler
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>
//.........这里部分代码省略.........
示例6: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == sizeof($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
$return["{$prefix}ip-3-octets"] = implode('.', array_slice($ip_arr, 0, 3));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例7: jetpack_debug_display_handler
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) . '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');
$args = array();
$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 compatibily 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;
}
//.........这里部分代码省略.........
示例8: login_init
function login_init()
{
global $action;
if (Jetpack_SSO_Helpers::should_hide_login_form()) {
/**
* Since the default authenticate filters fire at priority 20 for checking username and password,
* let's fire at priority 30. wp_authenticate_spam_check is fired at priority 99, but since we return a
* WP_Error in disable_default_login_form, then we won't trigger spam processing logic.
*/
add_filter('authenticate', array($this, 'disable_default_login_form'), 30);
/**
* Filter the display of the disclaimer message appearing when default WordPress login form is disabled.
*
* @module sso
*
* @since 2.8.0
*
* @param bool true Should the disclaimer be displayed. Default to true.
*/
$display_sso_disclaimer = apply_filters('jetpack_sso_display_disclaimer', true);
if ($display_sso_disclaimer) {
add_filter('login_message', array($this, 'msg_login_by_jetpack'));
}
}
/**
* If the user is attempting to logout AND the auto-forward to WordPress.com
* login is set then we need to ensure we do not auto-forward the user and get
* them stuck in an infinite logout loop.
*/
if (isset($_GET['loggedout']) && Jetpack_SSO_Helpers::bypass_login_forward_wpcom()) {
add_filter('jetpack_remove_login_form', '__return_true');
}
/**
* Check to see if the site admin wants to automagically forward the user
* to the WordPress.com login page AND that the request to wp-login.php
* is not something other than login (Like logout!)
*/
if ($this->wants_to_login() && Jetpack_SSO_Helpers::bypass_login_forward_wpcom()) {
add_filter('allowed_redirect_hosts', array('Jetpack_SSO_Helpers', 'allowed_redirect_hosts'));
$this->maybe_save_cookie_redirect();
$reauth = !empty($_GET['force_reauth']);
$sso_url = $this->get_sso_url_or_die($reauth);
JetpackTracking::record_user_event('sso_login_redirect_bypass_success');
wp_safe_redirect($sso_url);
exit;
}
if ('login' === $action) {
$this->display_sso_login_form();
} elseif ('jetpack-sso' === $action) {
if (isset($_GET['result'], $_GET['user_id'], $_GET['sso_nonce']) && 'success' == $_GET['result']) {
$this->handle_login();
$this->display_sso_login_form();
} else {
if (Jetpack::check_identity_crisis()) {
JetpackTracking::record_user_event('sso_login_redirect_failed', array('error_message' => 'identity_crisis'));
wp_die(__("Error: This site's Jetpack connection is currently experiencing problems.", 'jetpack'));
} else {
$this->maybe_save_cookie_redirect();
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter('allowed_redirect_hosts', array('Jetpack_SSO_Helpers', 'allowed_redirect_hosts'));
$reauth = !empty($_GET['force_reauth']);
$sso_url = $this->get_sso_url_or_die($reauth);
JetpackTracking::record_user_event('sso_login_redirect_success');
wp_safe_redirect($sso_url);
exit;
}
}
}
}
示例9: login_init
function login_init()
{
global $action;
/**
* If the user is attempting to logout AND the auto-forward to WordPress.com
* login is set then we need to ensure we do not auto-forward the user and get
* them stuck in an infinite logout loop.
*/
if (isset($_GET['loggedout']) && Jetpack_SSO_Helpers::bypass_login_forward_wpcom()) {
add_filter('jetpack_remove_login_form', '__return_true');
}
/**
* Check to see if the site admin wants to automagically forward the user
* to the WordPress.com login page AND that the request to wp-login.php
* is not something other than login (Like logout!)
*/
if ($this->wants_to_login() && Jetpack_SSO_Helpers::bypass_login_forward_wpcom()) {
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
$this->maybe_save_cookie_redirect();
$reauth = !empty($_GET['force_reauth']);
$sso_url = $this->get_sso_url_or_die($reauth);
JetpackTracking::record_user_event('sso_login_redirect_bypass_success');
wp_safe_redirect($sso_url);
exit;
}
if ('login' === $action) {
$this->display_sso_login_form();
} elseif ('jetpack-sso' === $action) {
if (isset($_GET['result'], $_GET['user_id'], $_GET['sso_nonce']) && 'success' == $_GET['result']) {
$this->handle_login();
$this->display_sso_login_form();
} else {
if (Jetpack::check_identity_crisis()) {
JetpackTracking::record_user_event('sso_login_redirect_failed', array('error_message' => 'identity_crisis'));
wp_die(__("Error: This site's Jetpack connection is currently experiencing problems.", 'jetpack'));
} else {
$this->maybe_save_cookie_redirect();
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
$reauth = !empty($_GET['force_reauth']);
$sso_url = $this->get_sso_url_or_die($reauth);
JetpackTracking::record_user_event('sso_login_redirect_success');
wp_safe_redirect($sso_url);
exit;
}
}
}
}
示例10: login_init
function login_init()
{
/*
* Check to see if the site admin wants to automagically forward the user
* to the WordPress.com login page AND that the request to wp-login.php
* is not something other than login (Like logout!)
*/
if ($this->wants_to_login() && apply_filters('jetpack_sso_bypass_login_forward_wpcom', false)) {
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
wp_safe_redirect($this->build_sso_url());
}
add_action('login_footer', array($this, 'login_form'));
add_action('login_footer', array($this, 'login_footer'));
/*
if( get_option( 'jetpack_sso_remove_login_form' ) ) {
// Check to see if the user is attempting to login via the default login form.
// If so we need to deny it and forward elsewhere.
if( isset( $_REQUEST['wp-submit'] ) && 'Log In' == $_REQUEST['wp-submit'] ) {
wp_die( 'Login not permitted by this method. ');
}
add_filter( 'gettext', array( $this, 'remove_lost_password_text' ) );
}
*/
wp_enqueue_script('jquery');
wp_enqueue_style('genericons');
if (isset($_GET['action']) && 'jetpack-sso' == $_GET['action']) {
if (isset($_GET['result'], $_GET['user_id'], $_GET['sso_nonce']) && 'success' == $_GET['result']) {
$this->handle_login();
} else {
if (Jetpack::check_identity_crisis()) {
wp_die(__("Error: This site's Jetpack connection is currently experiencing problems.", 'jetpack'));
} else {
$this->maybe_save_cookie_redirect();
// Is it wiser to just use wp_redirect than do this runaround to wp_safe_redirect?
add_filter('allowed_redirect_hosts', array($this, 'allowed_redirect_hosts'));
wp_safe_redirect($this->build_sso_url());
}
}
}
}
示例11: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}public"] = Jetpack_Options::get_option('public');
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}is-https"] = is_ssl() ? 'https' : 'http';
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
$return["{$prefix}single-user-site"] = Jetpack::is_single_user_site();
$return["{$prefix}manage-enabled"] = Jetpack::is_module_active('manage');
// is-multi-network can have three values, `single-site`, `single-network`, and `multi-network`
$return["{$prefix}is-multi-network"] = 'single-site';
if (is_multisite()) {
$return["{$prefix}is-multi-network"] = Jetpack::is_multi_network() ? 'multi-network' : 'single-network';
}
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == count($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例12: cron_exec
/**
* Method that gets executed on the wp-cron call
*
* @since 2.3.3
* @global string $wp_version
*/
public function cron_exec()
{
/*
* This should run weekly. Figuring in for variances in
* WP_CRON, don't let it run more than every six days at most.
*
* i.e. if it ran less than six days ago, fail out.
*/
$last = (int) Jetpack_Options::get_option('last_heartbeat');
if ($last && $last + WEEK_IN_SECONDS - DAY_IN_SECONDS > time()) {
return;
}
/*
* Check for an identity crisis
*
* If one exists:
* - Bump stat for ID crisis
* - Email site admin about potential ID crisis
*/
/**
* Setup an array of items that will eventually be stringified
* and sent off to the Jetpack API
*
* Associative array with format group => values
* - values should be an array that will be imploded to a string
*/
$jetpack = Jetpack::init();
$jetpack->stat('active-modules', implode(',', $jetpack->get_active_modules()));
$jetpack->stat('active', JETPACK__VERSION);
$jetpack->stat('wp-version', get_bloginfo('version'));
$jetpack->stat('php-version', PHP_VERSION);
$jetpack->stat('ssl', $jetpack->permit_ssl());
$jetpack->stat('language', get_bloginfo('language'));
$jetpack->stat('charset', get_bloginfo('charset'));
$jetpack->stat('qty-posts', wp_count_posts()->publish);
$jetpack->stat('qty-pages', wp_count_posts('page')->publish);
$jetpack->stat('qty-comments', wp_count_comments()->approved);
$jetpack->stat('is-multisite', is_multisite() ? 'multisite' : 'singlesite');
$jetpack->stat('identitycrisis', Jetpack::check_identity_crisis(1) ? 'yes' : 'no');
// Only check a few plugins, to see if they're currently active.
$plugins_to_check = array('vaultpress/vaultpress.php', 'akismet/akismet.php', 'wp-super-cache/wp-cache.php');
$plugins = array_intersect($plugins_to_check, get_option('active_plugins', array()));
foreach ($plugins as $plugin) {
$jetpack->stat('plugins', $plugin);
}
Jetpack_Options::update_option('last_heartbeat', time());
$jetpack->do_stats('server_side');
}
示例13: generate_stats_array
public static function generate_stats_array($prefix = '')
{
$return = array();
$return["{$prefix}version"] = JETPACK__VERSION;
$return["{$prefix}wp-version"] = get_bloginfo('version');
$return["{$prefix}php-version"] = PHP_VERSION;
$return["{$prefix}branch"] = floatval(JETPACK__VERSION);
$return["{$prefix}wp-branch"] = floatval(get_bloginfo('version'));
$return["{$prefix}php-branch"] = floatval(PHP_VERSION);
$return["{$prefix}public"] = Jetpack_Options::get_option('public');
$return["{$prefix}ssl"] = Jetpack::permit_ssl();
$return["{$prefix}language"] = get_bloginfo('language');
$return["{$prefix}charset"] = get_bloginfo('charset');
$return["{$prefix}is-multisite"] = is_multisite() ? 'multisite' : 'singlesite';
$return["{$prefix}identitycrisis"] = Jetpack::check_identity_crisis(1) ? 'yes' : 'no';
$return["{$prefix}plugins"] = implode(',', Jetpack::get_active_plugins());
switch (Jetpack_Options::get_option('json_api_full_management', null)) {
case null:
$return["{$prefix}full_manage"] = 'unset';
break;
case false:
$return["{$prefix}full_manage"] = 'false';
break;
case true:
$return["{$prefix}full_manage"] = 'true';
break;
default:
$return["{$prefix}full_manage"] = Jetpack_Options::get_option('json_api_full_management', null);
}
if (!Jetpack_Options::get_option('public')) {
// Also flag things as private since we don't provide the user with option to easy opt into if the site is private
$return["{$prefix}full_manage"] = 'private-' . $return["{$prefix}full_manage"];
}
// is-multi-network can have three values, `single-site`, `single-network`, and `multi-network`
$return["{$prefix}is-multi-network"] = 'single-site';
if (is_multisite()) {
$return["{$prefix}is-multi-network"] = Jetpack::is_multi_network() ? 'multi-network' : 'single-network';
}
if (!empty($_SERVER['SERVER_ADDR']) || !empty($_SERVER['LOCAL_ADDR'])) {
$ip = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
$ip_arr = array_map('intval', explode('.', $ip));
if (4 == count($ip_arr)) {
$return["{$prefix}ip-2-octets"] = implode('.', array_slice($ip_arr, 0, 2));
$return["{$prefix}ip-3-octets"] = implode('.', array_slice($ip_arr, 0, 3));
}
}
foreach (Jetpack::get_available_modules() as $slug) {
$return["{$prefix}module-{$slug}"] = Jetpack::is_module_active($slug) ? 'on' : 'off';
}
return $return;
}
示例14: display_sso_login_form
/**
* Ensures that we can get a nonce from WordPress.com via XML-RPC before setting
* up the hooks required to display the SSO form.
*/
public function display_sso_login_form()
{
if (Jetpack::check_identity_crisis()) {
add_filter('login_message', array($this, 'error_msg_identity_crisis'));
return;
}
$sso_nonce = self::request_initial_nonce();
if (is_wp_error($sso_nonce)) {
return;
}
add_action('login_form', array($this, 'login_form'));
add_filter('login_body_class', array($this, 'login_body_class'));
add_action('login_enqueue_scripts', array($this, 'login_enqueue_scripts'));
}