function __construct() { parent::__construct(); Jetpack::init(); // In WP 4.2 WP_List_Table will be sanitizing which values are __set() global $wp_version; if (version_compare($wp_version, '4.2-z', '>=') && $this->compat_fields && is_array($this->compat_fields)) { array_push($this->compat_fields, 'all_items'); } $this->items = $this->all_items = Jetpack_Admin::init()->get_modules(); $this->items = $this->filter_displayed_table_items($this->items); /** * Filters the list of modules available to be displayed in the Jetpack Settings screen. * * @since 3.0.0 * * @param array $this->items Array of Jetpack modules. */ $this->items = apply_filters('jetpack_modules_list_table_items', $this->items); $this->_column_headers = array($this->get_columns(), array(), array(), 'name'); $modal_info = isset($_GET['info']) ? $_GET['info'] : false; wp_register_script('models.jetpack-modules', plugins_url('_inc/jetpack-modules.models.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore'), JETPACK__VERSION); wp_register_script('views.jetpack-modules', plugins_url('_inc/jetpack-modules.views.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore', 'wp-util'), JETPACK__VERSION); wp_register_script('jetpack-modules-list-table', plugins_url('_inc/jetpack-modules.js', JETPACK__PLUGIN_FILE), array('views.jetpack-modules', 'models.jetpack-modules', 'jquery'), JETPACK__VERSION, true); wp_localize_script('jetpack-modules-list-table', 'jetpackModulesData', array('modules' => Jetpack::get_translated_modules($this->all_items), 'i18n' => array('search_placeholder' => __('Search Modules…', 'jetpack')), 'modalinfo' => $this->module_info_check($modal_info, $this->all_items), 'nonces' => array('bulk' => wp_create_nonce('bulk-jetpack_page_jetpack_modules')), 'coreIconAvailable' => Jetpack::jetpack_site_icon_available_in_core())); wp_enqueue_script('jetpack-modules-list-table'); /** * Filters the js_templates callback value. * * @since 3.6.0 * * @param array array( $this, 'js_templates' ) js_templates callback. */ add_action('admin_footer', apply_filters('jetpack_modules_list_table_js_template_callback', array($this, 'js_templates')), 9); }
function __construct() { $this->jetpack = Jetpack::init(); // Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite. // @see: https://twitter.com/nacin/status/378246957451333632 self::$hash = md5(get_option('siteurl')); add_filter('jetpack_xmlrpc_methods', array($this, 'xmlrpc_methods')); // @todo remove sync from subscriptions and move elsewhere... // Add Configuration Page add_action('admin_init', array($this, 'configure')); // Set up the subscription widget. add_action('widgets_init', array($this, 'widget_init')); // Catch subscription widget submits if (isset($_REQUEST['jetpack_subscriptions_widget'])) { add_action('template_redirect', array($this, 'widget_submit')); } // Set up the comment subscription checkboxes add_action('comment_form', array($this, 'comment_subscribe_init')); // Catch comment posts and check for subscriptions. add_action('comment_post', array($this, 'comment_subscribe_submit'), 50, 2); // Adds post meta checkbox in the post submit metabox if (apply_filters('jetpack_allow_per_post_subscriptions', false)) { add_action('post_submitbox_misc_actions', array($this, 'subscription_post_page_metabox')); } add_action('transition_post_status', array($this, 'maybe_send_subscription_email'), 10, 3); }
/** * Method that gets executed on the wp-cron call * * @since 2.3.3 * @global string $wp_version */ public function cron_exec() { $jetpack = Jetpack::init(); /* * This should run daily. Figuring in for variances in * WP_CRON, don't let it run more than every 23 hours at most. * * i.e. if it ran less than 23 hours ago, fail out. */ $last = (int) Jetpack_Options::get_option('last_heartbeat'); if ($last && $last + DAY_IN_SECONDS - HOUR_IN_SECONDS > time()) { return; } /* * Check for an identity crisis * * If one exists: * - Bump stat for ID crisis * - Email site admin about potential ID crisis */ // Coming Soon! foreach (self::generate_stats_array('v2-') as $key => $value) { $jetpack->stat($key, $value); } Jetpack_Options::update_option('last_heartbeat', time()); $jetpack->do_stats('server_side'); }
function photon_msg() { if (current_user_can('jetpack_manage_modules')) { ?> <div class="jp-jitm"> <a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a> <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> <p> <?php _e('Deliver super-fast images to your visitors that are automatically optimized for any device.', 'jetpack'); ?> </p> <p> <a href="#" data-module="photon" class="activate button button-jetpack"> <?php esc_html_e('Activate Photon', 'jetpack'); ?> </a> </p> </div> <?php //jitm is being viewed, track it $jetpack = Jetpack::init(); $jetpack->stat('jitm', 'photon-viewed'); $jetpack->do_stats('server_side'); } }
function admin_page_warning() { $jetpack = Jetpack::init(); $blog_name = get_bloginfo('blogname'); if (empty($blog_name)) { $blog_name = home_url('/'); } ?> <div id="message" class="updated jetpack-message jp-connect"> <div class="jetpack-wrap-container"> <div class="jetpack-text-container"> <p><?php printf(esc_html(wptexturize(__("To use Publicize, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack'))), '<strong>' . esc_html($blog_name) . '</strong>'); ?> </p> <p><?php echo esc_html(wptexturize(__("If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack'))); ?> </p> </div> <div class="jetpack-install-container"> <p class="submit"><a href="<?php echo $jetpack->build_connect_url(false, menu_page_url('sharing', false)); ?> " class="button-connector" id="wpcom-connect"><?php esc_html_e('Link account with WordPress.com', 'jetpack'); ?> </a></p> </div> </div> </div> <?php }
private function __construct() { $this->jetpack = Jetpack::init(); jetpack_require_lib('admin-pages/class.jetpack-react-page'); $this->jetpack_react = new Jetpack_React_Page(); // TODO: reactify require_once JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-dashboard.php'; $this->sync_dashboard = new Jetpack_Sync_Dashboard(); $this->sync_dashboard->init(); // jetpack_require_lib( 'admin-pages/class.jetpack-landing-page' ); // $this->landing_page = new Jetpack_Landing_Page; // // jetpack_require_lib( 'admin-pages/class.jetpack-settings-page' ); // $this->settings_page = new Jetpack_Settings_Page; // // jetpack_require_lib( 'admin-pages/class.jetpack-my-jetpack-page' ); // $this->my_jetpack_page = new Jetpack_My_Jetpack_Page; // if ( isset( $_POST['jetpack-set-master-user'] ) ) { // add_action( 'init', array( $this->my_jetpack_page, 'jetpack_my_jetpack_change_user' ) ); // } // Add hooks for admin menus // add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'add_actions' ) ); add_action('admin_menu', array($this->jetpack_react, 'add_actions'), 998); add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger')); add_action('jetpack_admin_menu', array($this->sync_dashboard, 'add_actions')); // Add redirect to current page for activation/deactivation of modules add_action('jetpack_pre_activate_module', array($this, 'fix_redirect'), 10, 2); add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect')); // Add module bulk actions handler add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action')); }
protected function result() { Jetpack::init(); do_action('jetpack_sync_all_registered_options'); $result['scheduled'] = true; return $result; }
function Jetpack_Subscriptions() { $this->jetpack = Jetpack::init(); add_filter('jetpack_xmlrpc_methods', array($this, 'xmlrpc_methods')); // @todo remove sync from subscriptions and move elsewhere... // Add Configuration Page add_action('admin_init', array($this, 'configure')); // Handle Posts add_action('transition_post_status', array($this, 'transition_post_status'), 10, 3); add_action('trashed_post', array($this, 'delete_post')); add_action('delete_post', array($this, 'delete_post')); // Handle Taxonomy add_action('created_term', array($this, 'save_taxonomy'), 10, 3); add_action('edited_term', array($this, 'save_taxonomy'), 10, 3); add_action('delete_term', array($this, 'delete_taxonomy'), 10, 3); // Handle Comments add_action('wp_insert_comment', array($this, 'save_comment'), 10, 2); add_action('transition_comment_status', array($this, 'transition_comment_status'), 10, 3); add_action('trashed_comment', array($this, 'delete_comment')); add_action('delete_comment', array($this, 'delete_comment')); // Set up the subscription widget. add_action('widgets_init', array($this, 'widget_init')); // Catch subscription widget submits if (isset($_REQUEST['jetpack_subscriptions_widget'])) { add_action('template_redirect', array($this, 'widget_submit')); } // Set up the comment subscription checkboxes add_action('comment_form', array($this, 'comment_subscribe_init')); // Catch comment posts and check for subscriptions. add_action('comment_post', array($this, 'comment_subscribe_submit'), 50, 2); }
protected function result() { Jetpack::init(); /** This action is documented in class.jetpack.php */ do_action('jetpack_sync_all_registered_options'); $result['scheduled'] = true; return $result; }
/** * Module Name: JSON API * Module Description: Allow applications to securely access your content through the cloud. * Sort Order: 100 * First Introduced: 1.9 * Requires Connection: Yes * Auto Activate: Public * Module Tags: Writing, Developers */ function jetpack_json_api_toggle() { $jetpack = Jetpack::init(); $jetpack->sync->register('noop'); if (false !== strpos(current_filter(), 'jetpack_activate_module_')) { Jetpack::check_privacy(__FILE__); } }
function module_state_toggle() { // extra check that we are on the JP blog, just incase if (class_exists('Jetpack') && $this->in_jetpack) { $jetpack = Jetpack::init(); $jetpack->sync->register('noop'); } }
function __construct() { $this->jetpack = Jetpack::init(); self::$block_page_rendering_for_idc = Jetpack::validate_sync_error_idc_option() && !Jetpack_Options::get_option('safe_mode_confirmed'); if (!self::$block_page_rendering_for_idc) { add_action('admin_enqueue_scripts', array($this, 'additional_styles')); } }
/** * @param string $file __FILE__ * @param string $option, Option name to sync * @param string $option ... */ static function sync_options($file, $option) { if (is_network_admin()) { return; } $jetpack = Jetpack::init(); $args = func_get_args(); return call_user_func_array(array($jetpack->sync, 'options'), $args); }
private function __construct() { $this->jetpack = Jetpack::init(); add_action('admin_menu', array($this, 'admin_menu'), 998); add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger')); add_action('jetpack_admin_menu', array($this, 'admin_menu_modules')); add_action('jetpack_pre_activate_module', array($this, 'fix_redirect')); add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect')); add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action')); }
private function _get_post_count_cloud() { $blog_id = Jetpack::init()->get_option('id'); $body = array('size' => 1); $response = wp_remote_post("https://public-api.wordpress.com/rest/v1/sites/{$blog_id}/search", array('timeout' => 10, 'user-agent' => 'jetpack_related_posts', 'sslverify' => true, 'body' => $body)); if (is_wp_error($response)) { return 0; } $results = json_decode(wp_remote_retrieve_body($response), true); return (int) $results['results']['total']; }
/** * Constructor for singleton * * @since 2.3.3 * @return Jetpack_Heartbeat */ private function __construct() { $this->jetpack = Jetpack::init(); // Add weekly interval for wp-cron add_filter('cron_schedules', array($this, 'add_cron_intervals')); // Schedule the task add_action($this->cron_name, array($this, 'cron_exec')); if (!wp_next_scheduled($this->cron_name)) { wp_schedule_event(time(), 'jetpack_weekly', $this->cron_name); } }
function Jetpack_Notifications() { $this->jetpack = Jetpack::init(); add_action('init', array(&$this, 'action_init')); //post types that support comments $filt_post_types = array(); foreach (get_post_types() as $post_type) { if (post_type_supports($post_type, 'comments')) { $filt_post_types[] = $post_type; } } Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'))); Jetpack_Sync::sync_comments(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'), 'comment_stati' => array('approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash'))); }
private function __construct() { $this->jetpack = Jetpack::init(); add_action('admin_menu', array($this, 'admin_menu'), 998); add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger')); add_action('jetpack_pre_activate_module', array($this, 'fix_redirect')); add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect')); add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action')); /** * Don't add in the modules page unless modules are available! */ if (Jetpack::is_active() || Jetpack::is_development_mode()) { add_action('jetpack_admin_menu', array($this, 'admin_menu_modules')); } }
function __construct() { parent::__construct(); Jetpack::init(); $this->items = $this->all_items = Jetpack_Admin::init()->get_modules(); $this->items = $this->filter_displayed_table_items($this->items); $this->items = apply_filters('jetpack_modules_list_table_items', $this->items); $this->_column_headers = array($this->get_columns(), array(), array()); wp_register_script('models.jetpack-modules', plugins_url('_inc/jetpack-modules.models.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore'), JETPACK__VERSION); wp_register_script('views.jetpack-modules', plugins_url('_inc/jetpack-modules.views.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore', 'wp-util'), JETPACK__VERSION); wp_register_script('jetpack-modules-list-table', plugins_url('_inc/jetpack-modules.js', JETPACK__PLUGIN_FILE), array('views.jetpack-modules', 'models.jetpack-modules', 'jquery'), JETPACK__VERSION, true); wp_localize_script('jetpack-modules-list-table', 'jetpackModulesData', array('modules' => $this->all_items, 'i18n' => array('search_placeholder' => __('Search Modules…', 'jetpack')), 'nonces' => array('bulk' => wp_create_nonce('bulk-jetpack_page_jetpack_modules')))); wp_enqueue_script('jetpack-modules-list-table'); add_action('admin_footer', array($this, 'js_templates'), 9); }
/** * 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'); }
public function column_connected($item) { $jpms = Jetpack_Network::init(); $jp = Jetpack::init(); switch_to_blog($item->blog_id); if ($jp->is_active()) { // Build url for disconnecting $url = $jpms->get_url(array('name' => 'subsitedisconnect', 'site_id' => $item->blog_id)); restore_current_blog(); return '<a href="' . $url . '">Disconnect</a>'; } restore_current_blog(); // Build URL for connecting $url = $jpms->get_url(array('name' => 'subsiteregister', 'site_id' => $item->blog_id)); return '<a href="' . $url . '">Connect</a>'; }
/** * 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__); } }
private function __construct() { $this->jetpack = Jetpack::init(); jetpack_require_lib('admin-pages/class.jetpack-landing-page'); $this->landing_page = new Jetpack_Landing_Page(); jetpack_require_lib('admin-pages/class.jetpack-settings-page'); $this->settings_page = new Jetpack_Settings_Page(); // Add hooks for admin menus add_action('admin_menu', array($this->landing_page, 'add_actions'), 998); add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger')); add_action('jetpack_admin_menu', array($this->settings_page, 'add_actions')); // Add redirect to current page for activation/deactivation of modules add_action('jetpack_pre_activate_module', array($this, 'fix_redirect'), 10, 2); add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect')); // Add module bulk actions handler add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action')); }
private function __construct() { $this->jetpack = Jetpack::init(); jetpack_require_lib('admin-pages/class.jetpack-react-page'); $this->jetpack_react = new Jetpack_React_Page(); jetpack_require_lib('admin-pages/class.jetpack-settings-page'); $this->fallback_page = new Jetpack_Settings_Page(); add_action('admin_menu', array($this->jetpack_react, 'add_actions'), 998); add_action('jetpack_admin_menu', array($this->jetpack_react, 'jetpack_add_dashboard_sub_nav_item')); add_action('jetpack_admin_menu', array($this->jetpack_react, 'jetpack_add_settings_sub_nav_item')); add_action('jetpack_admin_menu', array($this, 'admin_menu_debugger')); add_action('jetpack_admin_menu', array($this->fallback_page, 'add_actions')); // Add redirect to current page for activation/deactivation of modules add_action('jetpack_pre_activate_module', array($this, 'fix_redirect'), 10, 2); add_action('jetpack_pre_deactivate_module', array($this, 'fix_redirect')); // Add module bulk actions handler add_action('jetpack_unrecognized_action', array($this, 'handle_unrecognized_action')); }
function Jetpack_Subscriptions() { $this->jetpack = Jetpack::init(); add_filter('jetpack_xmlrpc_methods', array($this, 'xmlrpc_methods')); // @todo remove sync from subscriptions and move elsewhere... // Add Configuration Page add_action('admin_init', array($this, 'configure')); // Set up the subscription widget. add_action('widgets_init', array($this, 'widget_init')); // Catch subscription widget submits if (isset($_REQUEST['jetpack_subscriptions_widget'])) { add_action('template_redirect', array($this, 'widget_submit')); } // Set up the comment subscription checkboxes add_action('comment_form', array($this, 'comment_subscribe_init')); // Catch comment posts and check for subscriptions. add_action('comment_post', array($this, 'comment_subscribe_submit'), 50, 2); }
function __construct() { parent::__construct(); Jetpack::init(); // In WP 4.2 WP_List_Table will be sanitizing which values are __set() global $wp_version; if (version_compare($wp_version, '4.2-z', '>=') && $this->compat_fields && is_array($this->compat_fields)) { array_push($this->compat_fields, 'all_items'); } $this->items = $this->all_items = Jetpack_Admin::init()->get_modules(); $this->items = $this->filter_displayed_table_items($this->items); $this->items = apply_filters('jetpack_modules_list_table_items', $this->items); $this->_column_headers = array($this->get_columns(), array(), array()); wp_register_script('models.jetpack-modules', plugins_url('_inc/jetpack-modules.models.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore'), JETPACK__VERSION); wp_register_script('views.jetpack-modules', plugins_url('_inc/jetpack-modules.views.js', JETPACK__PLUGIN_FILE), array('backbone', 'underscore', 'wp-util'), JETPACK__VERSION); wp_register_script('jetpack-modules-list-table', plugins_url('_inc/jetpack-modules.js', JETPACK__PLUGIN_FILE), array('views.jetpack-modules', 'models.jetpack-modules', 'jquery'), JETPACK__VERSION, true); wp_localize_script('jetpack-modules-list-table', 'jetpackModulesData', array('modules' => $this->all_items, 'i18n' => array('search_placeholder' => __('Search Modules…', 'jetpack')), 'nonces' => array('bulk' => wp_create_nonce('bulk-jetpack_page_jetpack_modules')))); wp_enqueue_script('jetpack-modules-list-table'); add_action('admin_footer', array($this, 'js_templates'), 9); }
function page_render() { // Handle redirects to configuration pages if (!empty($_GET['configure'])) { return $this->render_nojs_configurable(); } global $current_user; $is_connected = Jetpack::is_active(); $user_token = Jetpack_Data::get_access_token($current_user->ID); $is_user_connected = $user_token && !is_wp_error($user_token); $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user'); if (Jetpack::is_development_mode()) { $is_connected = true; $is_user_connected = true; $is_master_user = false; } // Set template data for the admin page template $data = array('is_connected' => $is_connected, 'is_user_connected' => $is_user_connected, 'is_master_user' => $is_master_user); Jetpack::init()->load_view('admin/admin-page.php', $data); }
protected function result() { Jetpack::init(); $client = Jetpack_Sync_Client::getInstance(); $sync_queue = $client->get_sync_queue(); // lock sending from the queue while we compare checksums with the server $result = $sync_queue->lock(30); // tries to acquire the lock for up to 30 seconds if (!$result) { $sync_queue->unlock(); return new WP_Error('unknown_error', 'Unknown error trying to lock the sync queue'); } if (is_wp_error($result)) { $sync_queue->unlock(); return $result; } $store = new Jetpack_Sync_WP_Replicastore(); $result = $store->checksum_all(); $sync_queue->unlock(); return $result; }
public function column_connected($item) { $jpms = Jetpack_Network::init(); $jp = Jetpack::init(); switch_to_blog($item->blog_id); if (!is_plugin_active('jetpack/jetpack.php')) { $title = __('Jetpack is not active on this site.', 'jetpack'); $action = array('manage-plugins' => '<a href="' . get_admin_url($item->blog_id, 'plugins.php', 'admin') . '">' . __('Manage Plugins', 'jetpack') . '</a>'); restore_current_blog(); return sprintf('%1$s %2$s', $title, $this->row_actions($action)); } if ($jp->is_active()) { // Build url for disconnecting $url = $jpms->get_url(array('name' => 'subsitedisconnect', 'site_id' => $item->blog_id)); restore_current_blog(); return '<a href="' . $url . '">Disconnect</a>'; } restore_current_blog(); // Build URL for connecting $url = $jpms->get_url(array('name' => 'subsiteregister', 'site_id' => $item->blog_id)); return '<a href="' . $url . '">Connect</a>'; }
function jetpack_my_jetpack_change_user() { if (!isset($_POST['_my_jetpack_nonce']) || !wp_verify_nonce($_POST['_my_jetpack_nonce'], 'jetpack_change_primary_user')) { wp_die(__('Failed permissions, please try again.', 'jetpack')); exit; } if (isset($_POST['jetpack-new-master'])) { $old_master_user = Jetpack_Options::get_option('master_user'); $new_master_user = $_POST['jetpack-new-master']; $user_token = Jetpack_Data::get_access_token($new_master_user); $is_user_connected = $user_token && !is_wp_error($user_token); if (current_user_can('manage_options') && $is_user_connected) { Jetpack::log('switch_master_user', array('old_master' => $old_master_user, 'new_master' => $new_master_user)); Jetpack_Options::update_option('master_user', $new_master_user); Jetpack::state('message', 'switch_master'); //My Jetpack primary user successfully changed, send to MC Stats Jetpack::init()->stat('admin', 'change-primary-successful'); Jetpack::init()->do_stats('server_side'); // Change the blog owner dotcom side $this->wpcom_switch_blog_owner($new_master_user); } } }