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); }
function add_actions() { /** * Don't add in the modules page unless modules are available! */ if ($this->dont_show_if_not_active && !Jetpack::is_active() && !Jetpack::is_development_mode()) { return; } // Initialize menu item for the page in the admin $hook = $this->get_page_hook(); // Attach hooks common to all Jetpack admin pages based on the created // hook add_action("load-{$hook}", array($this, 'admin_help')); add_action("load-{$hook}", array($this, 'admin_page_load')); add_action("admin_head-{$hook}", array($this, 'admin_head')); add_action("admin_print_styles-{$hook}", array($this, 'admin_styles')); add_action("admin_print_scripts-{$hook}", array($this, 'admin_scripts')); // Attach page specific actions in addition to the above $this->add_page_actions($hook); }
static function sync_allowed() { require_once dirname(__FILE__) . '/class.jetpack-sync-settings.php'; return !Jetpack_Sync_Settings::get_setting('disable') && Jetpack::is_active() && !(Jetpack::is_development_mode() || Jetpack::is_staging_site()) || defined('PHPUNIT_JETPACK_TESTSUITE'); }
<svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306"/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> <svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306 "/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> <svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306 "/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> </div> <div class="subhead"> <?php if (Jetpack::is_development_mode()) { ?> <h2><?php _e('Jetpack is in local development mode.', 'jetpack'); ?> </h2> <?php } elseif ($data['is_connected']) { ?> <h2><?php _e("You're successfully connected to Jetpack!", 'jetpack'); ?> </h2> <?php } else { ?>
/** * Generates a Photon URL. * * @see http://developer.wordpress.com/docs/photon/ * * @param string $image_url URL to the publicly accessible image you want to manipulate * @param array|string $args An array of arguments, i.e. array( 'w' => '300', 'resize' => array( 123, 456 ) ), or in string form (w=123&h=456) * @return string The raw final URL. You should run this through esc_url() before displaying it. */ function jetpack_photon_url($image_url, $args = array(), $scheme = null) { $image_url = trim($image_url); if (class_exists('Jetpack')) { /** * Disables Photon URL processing for local development * * @module photon * * @since 4.1.0 * * @param bool false Result of Jetpack::is_development_mode. */ if (true === apply_filters('jetpack_photon_development_mode', Jetpack::is_development_mode())) { return $image_url; } } /** * Allow specific image URls to avoid going through Photon. * * @module photon * * @since 3.2.0 * * @param bool false Should the image be returned as is, without going through Photon. Default to false. * @param string $image_url Image URL. * @param array|string $args Array of Photon arguments. * @param string|null $scheme Image scheme. Default to null. */ if (false !== apply_filters('jetpack_photon_skip_for_url', false, $image_url, $args, $scheme)) { return $image_url; } /** * Filter the original image URL before it goes through Photon. * * @module photon * * @since 1.9.0 * * @param string $image_url Image URL. * @param array|string $args Array of Photon arguments. * @param string|null $scheme Image scheme. Default to null. */ $image_url = apply_filters('jetpack_photon_pre_image_url', $image_url, $args, $scheme); /** * Filter the original Photon image parameters before Photon is applied to an image. * * @module photon * * @since 1.9.0 * * @param array|string $args Array of Photon arguments. * @param string $image_url Image URL. * @param string|null $scheme Image scheme. Default to null. */ $args = apply_filters('jetpack_photon_pre_args', $args, $image_url, $scheme); if (empty($image_url)) { return $image_url; } $image_url_parts = @parse_url($image_url); // Unable to parse if (!is_array($image_url_parts) || empty($image_url_parts['host']) || empty($image_url_parts['path'])) { return $image_url; } if (is_array($args)) { // Convert values that are arrays into strings foreach ($args as $arg => $value) { if (is_array($value)) { $args[$arg] = implode(',', $value); } } // Encode values // See http://core.trac.wordpress.org/ticket/17923 $args = rawurlencode_deep($args); } /** This filter is documented below. */ $custom_photon_url = apply_filters('jetpack_photon_domain', '', $image_url); $custom_photon_url = esc_url($custom_photon_url); // You can't run a Photon URL through Photon again because query strings are stripped. // So if the image is already a Photon URL, append the new arguments to the existing URL. if (in_array($image_url_parts['host'], array('i0.wp.com', 'i1.wp.com', 'i2.wp.com')) || $image_url_parts['host'] === parse_url($custom_photon_url, PHP_URL_HOST)) { $photon_url = add_query_arg($args, $image_url); return jetpack_photon_url_scheme($photon_url, $scheme); } /** * Allow Photon to use query strings as well. * By default, Photon doesn't support query strings so we ignore them and look only at the path. * This setting is Photon Server dependent. * * @module photon * * @since 1.9.0 * * @param bool false Should images using query strings go through Photon. Default is false. * @param string $image_url_parts['host'] Image URL's host. */ if (!apply_filters('jetpack_photon_any_extension_for_domain', false, $image_url_parts['host'])) { // Photon doesn't support query strings so we ignore them and look only at the path. // However some source images are served via PHP so check the no-query-string extension. // For future proofing, this is a blacklist of common issues rather than a whitelist. $extension = pathinfo($image_url_parts['path'], PATHINFO_EXTENSION); if (empty($extension) || in_array($extension, array('php'))) { return $image_url; } } $image_host_path = $image_url_parts['host'] . $image_url_parts['path']; // Figure out which CDN subdomain to use srand(crc32($image_host_path)); $subdomain = rand(0, 2); srand(); /** * Filters the domain used by the Photon module. * * @module photon * * @since 3.4.2 * * @param string https://i{$subdomain}.wp.com Domain used by Photon. $subdomain is a random number between 0 and 2. * @param string $image_url URL of the image to be photonized. */ $photon_domain = apply_filters('jetpack_photon_domain', "https://i{$subdomain}.wp.com", $image_url); $photon_domain = trailingslashit(esc_url($photon_domain)); $photon_url = $photon_domain . $image_host_path; /** * Add query strings to Photon URL. * By default, Photon doesn't support query strings so we ignore them. * This setting is Photon Server dependent. * * @module photon * * @since 1.9.0 * * @param bool false Should query strings be added to the image URL. Default is false. * @param string $image_url_parts['host'] Image URL's host. */ if (isset($image_url_parts['query']) && apply_filters('jetpack_photon_add_query_string_to_domain', false, $image_url_parts['host'])) { $photon_url .= '?q=' . rawurlencode($image_url_parts['query']); } if ($args) { if (is_array($args)) { $photon_url = add_query_arg($args, $photon_url); } else { // You can pass a query string for complicated requests but where you still want CDN subdomain help, etc. $photon_url .= '?' . $args; } } if (isset($image_url_parts['scheme']) && 'https' == $image_url_parts['scheme']) { $photon_url = add_query_arg(array('ssl' => 1), $photon_url); } return jetpack_photon_url_scheme($photon_url, $scheme); }
/** * Handles the displaying of all sites on the network that are * dis/connected to Jetpack * * @since 2.9 * @see Jetpack_Network::jetpack_sites_list() */ function network_admin_page() { global $current_site; $this->network_admin_page_header(); $jp = Jetpack::init(); // We should be, but ensure we are on the main blog switch_to_blog($current_site->blog_id); $main_active = $jp->is_active(); restore_current_blog(); // If we are in dev mode, just show the notice and bail if (Jetpack::is_development_mode()) { Jetpack::show_development_mode_notice(); return; } /* * Ensure the main blog is connected as all other subsite blog * connections will feed off this one */ if (!$main_active) { $url = $this->get_url(array('name' => 'subsiteregister', 'site_id' => 1)); $data = array('url' => $jp->build_connect_url()); Jetpack::init()->load_view('admin/must-connect-main-blog.php', $data); return; } require_once 'class.jetpack-network-sites-list-table.php'; $myListTable = new Jetpack_Network_Sites_List_Table(); echo '<div class="wrap"><h2>' . __('Sites', 'jetpack') . '</h2>'; echo '<form method="post">'; $myListTable->prepare_items(); $myListTable->display(); echo '</form></div>'; $this->network_admin_page_footer(); }
/** * Checks if the update cron should be running and returns appropriate result. * * @return bool If the cron should be running or not. */ public function should_cron_be_running() { /** * The cron doesn't need to run empty loops. */ $widget_instances = $this->get_instances_sites(); if (empty($widget_instances) || !is_array($widget_instances)) { return false; } if (!defined('IS_WPCOM') || !IS_WPCOM) { /** * If Jetpack is not active or in development mode, we don't want to update widget data. */ if (!Jetpack::is_active() && !Jetpack::is_development_mode()) { return false; } /** * If Extra Sidebar Widgets module is not active, we don't need to update widget data. */ if (!Jetpack::is_module_active('widgets')) { return false; } } /** * If none of the above checks failed, then we definitely want to update widget data. */ return true; }
/** * Set up all the data and queue it for the outgoing XML-RPC request */ function sync() { if (!$this->sync) { return false; } // Don't sync anything from a staging site. if (Jetpack::is_development_mode() || Jetpack::is_staging_site()) { return false; } $sync_data = $this->get_common_sync_data(); $wp_importing = defined('WP_IMPORTING') && WP_IMPORTING; foreach ($this->sync as $sync_operation_type => $sync_operations) { switch ($sync_operation_type) { case 'post': if ($wp_importing) { break; } $global_post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null; $GLOBALS['post'] = null; foreach ($sync_operations as $post_id => $settings) { $sync_data['post'][$post_id] = $this->get_post($post_id); if (isset($this->post_transitions[$post_id])) { $sync_data['post'][$post_id]['transitions'] = $this->post_transitions[$post_id]; } else { $sync_data['post'][$post_id]['transitions'] = array(false, false); } $sync_data['post'][$post_id]['on_behalf_of'] = $settings['on_behalf_of']; } $GLOBALS['post'] = $global_post; unset($global_post); break; case 'comment': if ($wp_importing) { break; } $global_comment = isset($GLOBALS['comment']) ? $GLOBALS['comment'] : null; unset($GLOBALS['comment']); foreach ($sync_operations as $comment_id => $settings) { $sync_data['comment'][$comment_id] = $this->get_comment($comment_id); if (isset($this->comment_transitions[$comment_id])) { $sync_data['comment'][$comment_id]['transitions'] = $this->comment_transitions[$comment_id]; } else { $sync_data['comment'][$comment_id]['transitions'] = array(false, false); } $sync_data['comment'][$comment_id]['on_behalf_of'] = $settings['on_behalf_of']; } $GLOBALS['comment'] = $global_comment; unset($global_comment); break; case 'option': foreach ($sync_operations as $option => $settings) { $sync_data['option'][$option] = array('value' => get_option($option)); } break; case 'constant': foreach ($sync_operations as $constant => $settings) { $sync_data['constant'][$constant] = array('value' => $this->get_constant($constant)); } break; case 'delete_post': case 'delete_comment': foreach ($sync_operations as $object_id => $settings) { $sync_data[$sync_operation_type][$object_id] = array('on_behalf_of' => $settings['on_behalf_of']); } break; case 'delete_option': foreach ($sync_operations as $object_id => $settings) { $sync_data[$sync_operation_type][$object_id] = true; } break; } } Jetpack::xmlrpc_async_call('jetpack.syncContent', $sync_data); }
function admin_screen_list_modules() { require_once dirname(__FILE__) . '/modules/module-info.php'; $jetpack_connected = true; if (!Jetpack::is_active()) { $jetpack_connected = false; } ?> <div class="module-container"> <?php $avail_raw = Jetpack::get_available_modules(); $available = array(); $active = Jetpack::get_active_modules(); $counter = 0; foreach ((array) $avail_raw as $module) { if ($plugin = Jetpack::get_module($module)) { $plugin['module'] = $module; $available[] = $plugin; } } unset($avail_raw); usort($available, array('Jetpack', 'sort_modules')); $jetpack_version = Jetpack::get_option('version'); if ($jetpack_version) { list($jetpack_version, $jetpack_version_time) = explode(':', $jetpack_version); } else { $jetpack_version = 0; $jetpack_version_time = 0; } $jetpack_old_version = Jetpack::get_option('old_version'); if ($jetpack_old_version) { list($jetpack_old_version) = explode(':', $jetpack_old_version); } else { $jetpack_old_version = 0; } $now = time(); foreach ((array) $available as $module_data) { $module = $module_data['module']; $activated = in_array($module, $active); if ($activated) { $css = 'active'; $toggle = __('Deactivate', 'jetpack'); $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'deactivate', 'module' => $module)), "jetpack_deactivate-{$module}"); } else { $css = 'inactive'; $toggle = __('Activate', 'jetpack'); $toggle_url = wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => $module)), "jetpack_activate-{$module}"); } if ($counter % 4 == 0) { $classes = $css . ' jetpack-newline'; $counter = 0; } else { $classes = $css; } $free_text = esc_html($module_data['free'] ? __('Free', 'jetpack') : __('Purchase', 'jetpack')); $free_text = apply_filters('jetpack_module_free_text_' . $module, $free_text); $badge_text = $free_text; if (!$jetpack_connected && !Jetpack::is_development_mode()) { $classes = 'x disabled'; } else { if ($jetpack_version_time + 604800 > $now) { // 1 week if (version_compare($module_data['introduced'], $jetpack_old_version, '>')) { $badge_text = esc_html__('New', 'jetpack'); $classes .= ' jetpack-new-module'; } elseif (isset($module_data['changed']) && version_compare($module_data['changed'], $jetpack_old_version, '>')) { $badge_text = esc_html__('Updated', 'jetpack'); $classes .= ' jetpack-updated-module'; } else { $badge_text = $free_text; } } } ?> <div class="jetpack-module jetpack-<?php echo $classes; ?> " id="<?php echo $module; ?> "> <h3><?php echo $module_data['name']; ?> </h3> <div class="jetpack-module-description"> <div class="module-image"> <p><span class="module-image-badge"><?php echo $badge_text; ?> </span><span class="module-image-free" style="display: none"><?php echo $free_text; ?> </span></p> </div> <p><?php echo apply_filters('jetpack_short_module_description', $module_data['description'], $module); ?> </p> </div> <div class="jetpack-module-actions"> <?php if ($jetpack_connected || Jetpack::is_development_mode() && !$module_data['requires_connection'] || !$module_data['requires_dev_mode']) { ?> <?php if (!$activated && current_user_can('manage_options') && apply_filters('jetpack_can_activate_' . $module, true)) { ?> <a href="<?php echo esc_url($toggle_url); ?> " class="<?php echo 'inactive' == $css ? ' button-primary' : ' button-secondary'; ?> "><?php echo $toggle; ?> </a> <?php } ?> <?php do_action('jetpack_learn_more_button_' . $module); ?> <?php if (current_user_can('manage_options') && apply_filters('jetpack_module_configurable_' . $module, false)) { echo '<a href="' . esc_attr(Jetpack::module_configuration_url($module)) . '" class="jetpack-configure-button button-secondary">' . __('Configure', 'jetpack') . '</a>'; } if ($activated && $module_data['deactivate'] && current_user_can('manage_options')) { ?> <a style="display: none;" href="<?php echo esc_url($toggle_url); ?> " class="jetpack-deactivate-button button-secondary"><?php echo $toggle; ?> </a> <?php } ?> <?php } else { ?> <?php do_action('jetpack_learn_more_button_' . $module); ?> <?php } ?> </div> </div> <?php if ('inactive' == $css && $jetpack_connected) { ?> <script type="text/javascript"> jQuery( '#<?php echo esc_js($module); ?> ' ).bind( 'click', function(e){ if ( !jQuery(e.target).hasClass('more-info-link') ) document.location.href = '<?php echo str_replace('&', '&', esc_js(esc_url($toggle_url))); ?> '; } ); </script> <?php } ?> <div id="jp-more-info-<?php echo esc_attr($module); ?> " style="display:none;"> <?php if ($jetpack_connected && has_action('jetpack_module_more_info_connected_' . $module)) { do_action('jetpack_module_more_info_connected_' . $module); } else { do_action('jetpack_module_more_info_' . $module); } ?> </div> <?php $counter++; } // Add in some "Coming soon..." placeholders to fill up the current row and one more for ($i = 0; $i < 4; $i++) { ?> <div class="jetpack-module placeholder"<?php if ($i > 8 - $counter) { echo ' style="display: none;"'; } ?> > <h3><?php _e('Coming soon…', 'jetpack'); ?> </h3> </div> <?php } echo '</div><!-- .module-container -->'; }
<div class="page-content landing"> <?php Jetpack::init()->load_view('admin/network-activated-notice.php'); ?> <?php do_action('jetpack_notices'); ?> <?php if ($data['is_connected']) { ?> <?php if ($data['show_jumpstart'] && 'new_connection' === Jetpack_Options::get_option('jumpstart') && current_user_can('jetpack_manage_modules') && !Jetpack::is_development_mode()) { ?> <div id="jump-start-success"></div> <div id="jump-start-area" class="j-row"> <h1 title="Jump Start your site by activating these components" class="jstart"><?php _e('Jump Start your site', 'jetpack'); ?> </h1> <div class="jumpstart-desc j-col j-sm-12 j-md-12 j-lrg-8"> <div class="jumpstart-message"> <p id="jumpstart-paragraph-before"><?php echo sprintf(__('To immediately boost performance, security, and engagement, we recommend activating <strong>%s</strong> and a few others. Click <strong>Jump Start</strong> to activate these modules.', 'jetpack'), $data['jumpstart_list']); ?> <a class="pointer jp-config-list-btn"><?php _e('Learn more about Jump Start and what it adds to your site.', 'jetpack');
public function gallery_shortcode($val, $atts) { if (!empty($val)) { // something else is overriding post_gallery, like a custom VIP shortcode return $val; } global $post; $this->set_atts($atts); $attachments = $this->get_attachments(); if (empty($attachments)) { return ''; } if (is_feed() || defined('IS_HTML_EMAIL')) { return ''; } if (method_exists($this, $this->atts['type'] . '_talavera')) { // Enqueue styles and scripts self::default_scripts_and_styles(); $gallery_html = call_user_func_array(array($this, $this->atts['type'] . '_talavera'), array($attachments)); if ($gallery_html && class_exists('Jetpack') && class_exists('Jetpack_Photon')) { // Tiled Galleries in Jetpack require that Photon be active. // If it's not active, run it just on the gallery output. if (!in_array('photon', Jetpack::get_active_modules()) && !Jetpack::is_development_mode()) { $gallery_html = Jetpack_Photon::filter_the_content($gallery_html); } } return $gallery_html; } return ''; }
/** * Get information about a specific and valid Jetpack module. * * @since 4.3.0 * * @param WP_REST_Request $data { * Array of parameters received by request. * * @type string $slug Module slug. * } * * @return mixed|void|WP_Error */ public function get_module($data) { if (Jetpack::is_module($data['slug'])) { $module = Jetpack::get_module($data['slug']); $module['options'] = Jetpack_Core_Json_Api_Endpoints::prepare_options_for_response($data['slug']); if (isset($module['requires_connection']) && $module['requires_connection'] && Jetpack::is_development_mode()) { $module['activated'] = false; } $i18n = jetpack_get_module_i18n($data['slug']); if (isset($module['name'])) { $module['name'] = $i18n['name']; } if (isset($module['description'])) { $module['description'] = $i18n['description']; $module['short_description'] = $i18n['description']; } return Jetpack_Core_Json_Api_Endpoints::prepare_modules_for_response($module); } return new WP_Error('not_found', esc_html__('The requested Jetpack module was not found.', 'jetpack'), array('status' => 404)); }
/** * Checks the site plan and deactivates modules that were active but are no longer included in the plan. * * @since 4.4.0 * * @param $page * * @return bool|array */ function check_plan_deactivate_modules($page) { if (Jetpack::is_development_mode() || !in_array($page->base, array('toplevel_page_jetpack', 'admin_page_jetpack_modules', 'jetpack_page_vaultpress', 'jetpack_page_stats', 'jetpack_page_akismet-key-config')) || true === self::$plan_checked) { return false; } self::$plan_checked = true; $previous = get_option('jetpack_active_plan', ''); $response = rest_do_request(new WP_REST_Request('GET', '/jetpack/v4/site')); if (!is_object($response) || $response->is_error()) { // If we can't get information about the current plan we don't do anything self::$plan_checked = true; return; } $current = $response->get_data(); $current = json_decode($current['data']); $to_deactivate = array(); if (isset($current->plan->product_slug)) { if (empty($previous) || !isset($previous['product_slug']) || $previous['product_slug'] !== $current->plan->product_slug) { $active = Jetpack::get_active_modules(); switch ($current->plan->product_slug) { case 'jetpack_free': $to_deactivate = array('seo-tools', 'videopress'); break; case 'jetpack_personal': case 'jetpack_personal_monthly': $to_deactivate = array('seo-tools', 'videopress'); break; case 'jetpack_premium': case 'jetpack_premium_monthly': $to_deactivate = array('seo-tools'); break; } $to_deactivate = array_intersect($active, $to_deactivate); if (!empty($to_deactivate)) { Jetpack::update_active_modules(array_filter(array_diff($active, $to_deactivate))); } } } return array('previous' => $previous, 'current' => $current, 'deactivate' => $to_deactivate); }
<li class="jetpack-page"> <a href="<?php echo Jetpack::admin_url(); ?> " <?php if ('jetpack' == $current) { echo 'class="current"'; } ?> ><?php esc_html_e('Home', 'jetpack'); ?> </a> </li> <?php if (Jetpack::is_active() || Jetpack::is_development_mode()) { ?> <li class="jetpack-modules"> <a href="<?php echo Jetpack::admin_url('page=jetpack_modules'); ?> " <?php if ('jetpack_modules' == $current) { echo 'class="current"'; } ?> ><?php esc_html_e('Settings', 'jetpack'); ?> </a> </li>
protected function get_health_items() { $health_items = array(); // WooCommerce // Only one of the following should present // Check that WooCommerce is at least 2.6 or higher (feature-plugin only) // Check that WooCommerce base_country is set $base_country = WC()->countries->get_base_country(); if (version_compare(WC()->version, WOOCOMMERCE_CONNECT_MINIMUM_WOOCOMMERCE_VERSION, "<")) { $health_item = $this->build_indicator('woocommerce_indicator', 'notice', 'indicator-error', sprintf(__('WooCommerce %s or higher is required (You are running %s)', 'connectforwoocommerce'), WOOCOMMERCE_CONNECT_MINIMUM_WOOCOMMERCE_VERSION, WC()->version), ''); } else { if (empty($base_country)) { $health_item = $this->build_indicator('woocommerce_indicator', 'notice', 'indicator-error', __('Please set Base Location in WooCommerce Settings > General', 'connectforwoocommerce'), ''); } else { $health_item = $this->build_indicator('woocommerce_indicator', 'checkmark-circle', 'indicator-success', sprintf(__('WooCommerce %s is configured correctly', 'connectforwoocommerce'), WC()->version), ''); } } $health_items[] = (object) array('key' => 'woocommerce_health_items', 'title' => __('WooCommerce', 'connectforwoocommerce'), 'type' => 'indicators', 'items' => array('woocommerce_indicator' => $health_item)); // Jetpack // Only one of the following should present // Check that Jetpack is active // Check that Jetpack is connected include_once ABSPATH . 'wp-admin/includes/plugin.php'; // required for is_plugin_active if (method_exists('Jetpack', 'is_development_mode') && method_exists('Jetpack', 'is_active')) { $is_connected = Jetpack::is_development_mode() ? true : Jetpack::is_active(); } else { $is_connected = false; } if (!is_plugin_active('jetpack/jetpack.php')) { $health_item = $this->build_indicator('jetpack_indicator', 'notice', 'indicator-error', sprintf(__('Please install and activate the Jetpack plugin, version %s or higher', 'connectforwoocommerce'), WOOCOMMERCE_CONNECT_MINIMUM_JETPACK_VERSION), ''); } else { if (version_compare(JETPACK__VERSION, WOOCOMMERCE_CONNECT_MINIMUM_JETPACK_VERSION, "<")) { $health_item = $this->build_indicator('jetpack_indicator', 'notice', 'indicator-error', sprintf(__('Jetpack %s or higher is required (You are running %s)', 'connectforwoocommerce'), WOOCOMMERCE_CONNECT_MINIMUM_JETPACK_VERSION, JETPACK__VERSION), ''); } else { if (!$is_connected) { $health_item = $this->build_indicator('jetpack_indicator', 'notice', 'indicator-error', __('Jetpack is not connected to WordPress.com. Make sure the Jetpack plugin is installed, activated, and connected.', 'connectforwoocommerce'), ''); } else { if (Jetpack::is_staging_site()) { $health_item = $this->build_indicator('jetpack_indicator', 'notice', 'indicator-warning', __('This is a Jetpack staging site', 'connectforwoocommerce'), ''); } else { $health_item = $this->build_indicator('jetpack_indicator', 'checkmark-circle', 'indicator-success', sprintf(__('Jetpack %s is connected and working correctly', 'connectforwoocommerce'), JETPACK__VERSION), ''); } } } } $health_items[] = (object) array('key' => 'jetpack_health_items', 'title' => __('Jetpack', 'connectforwoocommerce'), 'type' => 'indicators', 'items' => array('jetpack_indicator' => $health_item)); // Lastly, do the Connect for WooCommerce health check // Check that we have schema // Check that we are able to talk to the Connect for WooCommerce server $schemas = $this->service_schemas_store->get_service_schemas(); $last_fetch_timestamp = $this->service_schemas_store->get_last_fetch_timestamp(); if (!is_null($last_fetch_timestamp)) { $last_fetch_timestamp_formatted = sprintf(_x('Last updated %s ago', '%s = human-readable time difference', 'connectforwoocommerce'), human_time_diff($last_fetch_timestamp)); } else { $last_fetch_timestamp = ''; } if (is_null($schemas)) { $health_item = $this->build_indicator('wcc_indicator', 'notice', 'indicator-error', __('No service data available', 'connectforwoocommerce'), ''); } else { if (is_null($last_fetch_timestamp)) { $health_item = $this->build_indicator('wcc_indicator', 'notice', 'indicator-warning', __('Service data was found, but may be out of date', 'connectforwoocommerce'), ''); } else { if ($last_fetch_timestamp < time() - WOOCOMMERCE_CONNECT_SCHEMA_AGE_ERROR_THRESHOLD) { $health_item = $this->build_indicator('wcc_indicator', 'notice', 'indicator-error', __('Service data was found, but is more than three days old', 'connectforwoocommerce'), $last_fetch_timestamp_formatted); } else { if ($last_fetch_timestamp < time() - WOOCOMMERCE_CONNECT_SCHEMA_AGE_WARNING_THRESHOLD) { $health_item = $this->build_indicator('wcc_indicator', 'notice', 'indicator-warning', __('Service data was found, but is more than one day old', 'connectforwoocommerce'), $last_fetch_timestamp_formatted); } else { $health_item = $this->build_indicator('wcc_indicator', 'checkmark-circle', 'indicator-success', __('Service data is up-to-date', 'connectforwoocommerce'), $last_fetch_timestamp_formatted); } } } } $health_items[] = (object) array('key' => 'wcc_health_items', 'title' => __('Connect for WooCommerce Service Data', 'connectforwoocommerce'), 'type' => 'indicators', 'items' => array('wcc_indicator' => $health_item)); return $health_items; }
/** * This methods removes all of the registered css files on the frontend * from Jetpack in favor of using a single file. In effect "imploding" * all the files into one file. * * Pros: * - Uses only ONE css asset connection instead of 15 * - Saves a minimum of 56k * - Reduces server load * - Reduces time to first painted byte * * Cons: * - Loads css for ALL modules. However all selectors are prefixed so it * should not cause any issues with themes. * - Plugins/themes dequeuing styles no longer do anything. See * jetpack_implode_frontend_css filter for a workaround * * For some situations developers may wish to disable css imploding and * instead operate in legacy mode where each file loads seperately and * can be edited individually or dequeued. This can be accomplished with * the following line: * * add_filter( 'jetpack_implode_frontend_css', '__return_false' ); * * @since 3.2 **/ public function implode_frontend_css($travis_test = false) { $do_implode = true; if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { $do_implode = false; } $do_implode = apply_filters('jetpack_implode_frontend_css', $do_implode); // Do not use the imploded file when default behaviour was altered through the filter if (!$do_implode) { return; } // We do not want to use the imploded file in dev mode, or if not connected if (Jetpack::is_development_mode() || !self::is_active()) { if (!$travis_test) { return; } } // Do not use the imploded file if sharing css was dequeued via the sharing settings screen if (get_option('sharedaddy_disable_resources')) { return; } /* * Now we assume Jetpack is connected and able to serve the single * file. * * In the future there will be a check here to serve the file locally * or potentially from the Jetpack CDN * * For now: * - Enqueue a single imploded css file * - Zero out the style_loader_tag for the bundled ones * - Be happy, drink scotch */ add_filter('style_loader_tag', array($this, 'concat_remove_style_loader_tag'), 10, 2); $version = Jetpack::is_development_version() ? filemtime(JETPACK__PLUGIN_DIR . 'css/jetpack.css') : JETPACK__VERSION; wp_enqueue_style('jetpack_css', plugins_url('css/jetpack.css', __FILE__), array(), $version); wp_style_add_data('jetpack_css', 'rtl', 'replace'); }
public static function check_identity_crisis($force_recheck = false) { if (!current_user_can('manage_options')) { return false; } if (!Jetpack::is_active() || Jetpack::is_development_mode()) { return false; } if (isset($_GET['spoof_identity_crisis'])) { $force_recheck = true; } if ($force_recheck || false === ($errors = get_transient('jetpack_has_identity_crisis'))) { $options_to_check = array('siteurl', 'home'); $cloud_options = self::get_cloud_site_options($options_to_check); $errors = array(); foreach ($cloud_options as $cloud_key => $cloud_value) { if ($cloud_value !== get_option($cloud_key)) { $errors[$cloud_key] = $cloud_value; } } // Make sure if we're spoofing it, that we don't let the spoof spill over. if (!isset($_GET['spoof_identity_crisis'])) { set_transient('jetpack_has_identity_crisis', $errors, DAY_IN_SECONDS); } } return apply_filters('jetpack_has_identity_crisis', $errors, $force_recheck); }
?> "><?php _e('Enhanced site stats and insights.', 'jetpack'); ?> </p> </div> </div><?php // j-row ?> <?php $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); $manage_active = Jetpack::is_module_active('manage'); ?> <?php if (current_user_can('jetpack_manage_modules') && $data['is_user_connected'] && !Jetpack::is_development_mode()) { ?> <div id="manage-row" class="j-row goto <?php echo $manage_active ? 'activated' : ''; ?> "> <div class="feat j-col j-lrg-7 j-md-8 j-sm-7"> <a href="<?php echo esc_url('https://wordpress.com/plugins/' . $normalized_site_url . '?from=jpnux'); ?> " class="button button-primary manage-cta-active" target="_blank" style="display: <?php echo $manage_active ? 'inline-block' : 'none'; ?> ;" title="<?php esc_attr_e('Go to WordPress.com to try these features', 'jetpack'); ?>
static function sync_allowed() { return !Jetpack_Sync_Settings::get_setting('disable') && Jetpack::is_active() && !(Jetpack::is_development_mode() || Jetpack::is_staging_site()) || defined('PHPUNIT_JETPACK_TESTSUITE'); }
static function is_module_available($module) { if (!is_array($module) || empty($module)) { return false; } if (Jetpack::is_development_mode()) { return !$module['requires_connection']; } else { return Jetpack::is_active(); } }
function admin_page() { global $current_user; $is_connected = Jetpack::is_active(); $user_token = Jetpack_Data::get_access_token($current_user->ID); $is_user_connected = $user_token && !is_wp_error($user_token); $is_master_user = $current_user->ID == Jetpack_Options::get_option('master_user'); if (Jetpack::is_development_mode()) { $is_connected = true; $is_user_connected = true; $is_master_user = false; } $this->admin_page_top(); ?> <div class="masthead <?php if (!$is_connected) { echo 'hasbutton'; } ?> "> <?php if (isset($_GET['jetpack-notice']) && 'dismiss' == $_GET['jetpack-notice']) { ?> <div id="message" class="error"> <p><?php esc_html_e('Jetpack is network activated and notices can not be dismissed.', 'jetpack'); ?> </p> </div> <?php } ?> <?php do_action('jetpack_notices'); ?> <h1><?php esc_html_e('Supercharge your self-hosted site with a suite of the most powerful WordPress.com features.', 'jetpack'); ?> </h1> <?php if (!$is_connected && current_user_can('jetpack_connect')) { ?> <a href="<?php echo $this->jetpack->build_connect_url(); ?> " class="download-jetpack"><?php esc_html_e('Connect to Get Started', 'jetpack'); ?> </a> <?php } elseif (!$is_user_connected && current_user_can('jetpack_connect_user')) { ?> <a href="<?php echo $this->jetpack->build_connect_url(); ?> " class="download-jetpack"><?php esc_html_e('Link your account to WordPress.com', 'jetpack'); ?> </a> <?php } ?> <div class="flyby"> <svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306"/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> <svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306 "/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> <svg class="flyer" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="80px" height="87px" viewBox="0 0 80 87" enable-background="new 0 0 80 87" xml:space="preserve"> <polygon class="eye" fill="#518d2a" points="41.187,17.081 46.769,11.292 50.984,15.306 "/> <path class="body" fill="#518d2a" d="M38.032,47.3l4.973-5.157l7.597,1.996l0.878-0.91l0.761-0.789l-0.688-2.838l-0.972-0.926l-1.858,1.926 l-2.206-2.1l3.803-3.944l0.09-3.872L80,0L61.201,10.382L60.2,15.976l-5.674,1.145l-8.09-7.702L34.282,22.024l8.828-1.109 l2.068,2.929l-4.996,0.655l-3.467,3.595l0.166-4.469l-4.486,0.355L21.248,35.539l-0.441,4.206l-2.282,2.366l-2.04,6.961 L27.69,37.453l4.693,1.442l-2.223,2.306l-4.912,0.095l-7.39,22.292l-8.06,3.848l-2.408,9.811l-3.343-0.739L0,86.739l30.601-31.733 l8.867,2.507l-7.782,8.07l-1.496-0.616l-0.317-2.623l-7.197,7.463l11.445-2.604l16.413-7.999L38.032,47.3z M42.774,16.143 l3.774-3.914l2.85,2.713L42.774,16.143z"/> </svg> </div> <div class="subhead"> <?php if (Jetpack::is_development_mode()) { ?> <h2><?php _e('Jetpack is in local development mode.', 'jetpack'); ?> </h2> <?php } elseif ($is_connected) { ?> <h2><?php _e("You're successfully connected to Jetpack!", 'jetpack'); ?> </h2> <?php } else { ?> <h2><?php _e('Once you’ve connected Jetpack, you’ll get access to all the delightful features below.', 'jetpack'); ?> </h2> <?php } ?> </div> </div><!-- .masthead --> <div class="featured"> <h2><?php _e('Jetpack team favorites', 'jetpack'); ?> </h2> <div class="features"> <div class="feature"> <a href="http://jetpack.me/support/custom-css/" data-name="Custom CSS" class="f-img"><div class="feature-img custom-css"></div></a> <a href="http://jetpack.me/support/custom-css/" data-name="Custom CSS" class="feature-description"> <h3><?php _e('Custom CSS', 'jetpack'); ?> </h3> <p><?php _e('Customize the look of your site, without modifying your theme.', 'jetpack'); ?> </p> </a> </div> <div class="feature"> <a href="http://jetpack.me/support/sso/" data-name="Jetpack Single Sign On" class="f-img"><div class="feature-img wordpress-connect no-border"></div></a> <a href="http://jetpack.me/support/sso/" data-name="Jetpack Single Sign On" class="feature-description"> <h3><?php _e('Single Sign On', 'jetpack'); ?> </h3> <p><?php _e('Let users log in through WordPress.com with one click.', 'jetpack'); ?> </p> </a> </div> <div class="feature"> <a href="http://jetpack.me/support/wordpress-com-stats/" data-name="WordPress.com Stats" class="f-img"><div class="feature-img wordpress-stats"></div></a> <a href="http://jetpack.me/support/wordpress-com-stats/" data-name="WordPress.com Stats" class="feature-description"> <h3><?php _e('WordPress.com Stats', 'jetpack'); ?> </h3> <p><?php _e('Simple, concise site stats with no additional load on your server.', 'jetpack'); ?> </p> </a> </div> </div> </div><!-- .featured --> <div class="page-content about"> <div class="module-grid"> <h2><?php esc_html_e('Jetpack features', 'jetpack'); ?> </h2> <!-- form with search and filters --> <form id="module-search"> <input type="text" id="jetpack-search" class="module-search" placeholder="<?php esc_attr_e('Search the Jetpack features', 'jetpack'); ?> " /><label for="jetpack-search"><?php esc_html_e('Search', 'jetpack'); ?> </label> </form> <div class="jp-filter" id="jp-filters"> <a href="#" id="newest" data-filter="introduced" class="selected"><?php esc_html_e('Newest', 'jetpack'); ?> </a> <a href="#" id="category" data-filter="cat"><?php _e('Category', 'jetpack'); ?> </a> <a href="#" id="alphabetical" data-filter="name"><?php esc_html_e('Alphabetical', 'jetpack'); ?> </a> </div> <div class="modules"></div> <a href="#" class="load-more jp-button"><?php esc_html_e('Load more', 'jetpack'); ?> </a> </div><!-- .module-grid --></div><!-- .page --> <?php $this->admin_page_bottom(); }
public function dashboard_widget_connect_to_wpcom() { if (Jetpack::is_active() || Jetpack::is_development_mode() || !current_user_can('jetpack_connect')) { return; } ?> <div class="wpcom-connect"> <div class="jp-emblem"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve"> <path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/> </svg> </div> <h3><?php esc_html_e('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 }
function page_admin_scripts() { if ($this->is_redirecting) { return; // No need for scripts on a fallback page } $is_dev_mode = Jetpack::is_development_mode(); // Enqueue jp.js and localize it wp_enqueue_script('react-plugin', plugins_url('_inc/build/admin.js', JETPACK__PLUGIN_FILE), array(), JETPACK__VERSION, true); if (!$is_dev_mode) { // Required for Analytics wp_enqueue_script('jp-tracks', '//stats.wp.com/w.js', array(), gmdate('YW'), true); } $localeSlug = explode('_', get_locale()); $localeSlug = $localeSlug[0]; // Collecting roles that can view site stats $stats_roles = array(); $enabled_roles = function_exists('stats_get_option') ? stats_get_option('roles') : array('administrator'); foreach (get_editable_roles() as $slug => $role) { $stats_roles[$slug] = array('name' => translate_user_role($role['name']), 'canView' => is_array($enabled_roles) ? in_array($slug, $enabled_roles, true) : false); } $response = rest_do_request(new WP_REST_Request('GET', '/jetpack/v4/module/all')); $modules = $response->get_data(); // Preparing translated fields for JSON encoding by transforming all HTML entities to // respective characters. foreach ($modules as $slug => $data) { $modules[$slug]['name'] = html_entity_decode($data['name']); $modules[$slug]['description'] = html_entity_decode($data['description']); $modules[$slug]['short_description'] = html_entity_decode($data['short_description']); $modules[$slug]['long_description'] = html_entity_decode($data['long_description']); } // Add objects to be passed to the initial state of the app wp_localize_script('react-plugin', 'Initial_State', array('WP_API_root' => esc_url_raw(rest_url()), 'WP_API_nonce' => wp_create_nonce('wp_rest'), 'pluginBaseUrl' => plugins_url('', JETPACK__PLUGIN_FILE), 'connectionStatus' => array('isActive' => Jetpack::is_active(), 'isStaging' => Jetpack::is_staging_site(), 'devMode' => array('isActive' => $is_dev_mode, 'constant' => defined('JETPACK_DEV_DEBUG') && JETPACK_DEV_DEBUG, 'url' => site_url() && false === strpos(site_url(), '.'), 'filter' => apply_filters('jetpack_development_mode', false)), 'isPublic' => '1' == get_option('blog_public'), 'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option()), 'dismissedNotices' => $this->get_dismissed_jetpack_notices(), 'isDevVersion' => Jetpack::is_development_version(), 'currentVersion' => JETPACK__VERSION, 'happinessGravIds' => jetpack_get_happiness_gravatar_ids(), 'getModules' => $modules, 'showJumpstart' => jetpack_show_jumpstart(), 'rawUrl' => Jetpack::build_raw_urls(get_home_url()), 'adminUrl' => esc_url(admin_url()), 'stats' => array('data' => array('general' => false, 'day' => false, 'week' => false, 'month' => false), 'roles' => $stats_roles), 'settingNames' => array('jetpack_holiday_snow_enabled' => function_exists('jetpack_holiday_snow_option_name') ? jetpack_holiday_snow_option_name() : false), 'userData' => array('currentUser' => jetpack_current_user_data()), 'locale' => $this->get_i18n_data(), 'localeSlug' => $localeSlug, 'jetpackStateNotices' => array('messageCode' => Jetpack::state('message'), 'errorCode' => Jetpack::state('error'), 'errorDescription' => Jetpack::state('error_description')), 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(), 'currentIp' => function_exists('jetpack_protect_get_ip') ? jetpack_protect_get_ip() : false)); }
static function is_module_available($module) { if (!is_array($module) || empty($module)) { return false; } /** * We never want to show VaultPress as activate-able through Jetpack. */ if ('vaultpress' === $module['module']) { return false; } if (Jetpack::is_development_mode()) { return !($module['requires_connection'] && !Jetpack::is_active()); } else { return Jetpack::is_active(); } }
public function gallery_shortcode($val, $atts) { if (!empty($val)) { // something else is overriding post_gallery, like a custom VIP shortcode return $val; } global $post; $this->set_atts($atts); $attachments = $this->get_attachments(); if (empty($attachments)) { return ''; } if (is_feed() || defined('IS_HTML_EMAIL')) { return ''; } if (in_array($this->atts['type'], self::$talaveras)) { // Enqueue styles and scripts self::default_scripts_and_styles(); // Generate gallery HTML $gallery_class = 'Jetpack_Tiled_Gallery_Layout_' . ucfirst($this->atts['type']); $gallery = new $gallery_class($attachments, $this->atts['link'], $this->atts['grayscale'], (int) $this->atts['columns']); $gallery_html = $gallery->HTML(); if ($gallery_html && class_exists('Jetpack') && class_exists('Jetpack_Photon')) { // Tiled Galleries in Jetpack require that Photon be active. // If it's not active, run it just on the gallery output. if (!in_array('photon', Jetpack::get_active_modules()) && !Jetpack::is_development_mode()) { $gallery_html = Jetpack_Photon::filter_the_content($gallery_html); } } return trim(preg_replace('/\\s+/', ' ', $gallery_html)); // remove any new lines from the output so that the reader parses it better } return ''; }
/** * Returns an array of hosts that SSO will redirect to. * * Instead of accessing JETPACK__API_BASE within the method directly, we set it as the * default for $api_base due to restrictions with testing constants in our tests. * * @since 4.3.0 * * @param array $hosts * @param string $api_base * * @return array */ static function allowed_redirect_hosts($hosts, $api_base = JETPACK__API_BASE) { if (empty($hosts)) { $hosts = array(); } $hosts[] = 'wordpress.com'; $hosts[] = 'jetpack.wordpress.com'; if ((Jetpack::is_development_mode() || Jetpack::is_development_version()) && false === strpos($api_base, 'jetpack.wordpress.com/jetpack')) { $base_url_parts = parse_url(esc_url_raw($api_base)); if ($base_url_parts && !empty($base_url_parts['host'])) { $hosts[] = $base_url_parts['host']; } } return array_unique($hosts); }
public function dashboard_widget_connect_to_wpcom() { if (Jetpack::is_active() || Jetpack::is_development_mode() || !current_user_can('jetpack_connect')) { return; } ?> <div class="wpcom-connect"> <div class="jp-emblem"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve"> <path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/> </svg> </div> <h3><?php esc_html_e('Please Connect Jetpack', 'jetpack'); ?> </h3> <p><?php echo wp_kses(__('Connecting Jetpack will show you <strong>stats</strong> about your traffic, <strong>protect</strong> you from brute force attacks, <strong>speed up</strong> your images and photos, and enable other <strong>traffic and security</strong> features.', 'jetpack'), 'jetpack'); ?> </p> <div class="actions"> <a href="<?php echo $this->build_connect_url(false, false, 'widget-btn'); ?> " class="button button-primary"> <?php esc_html_e('Connect Jetpack', 'jetpack'); ?> </a> </div> </div> <?php }
/** * Get connection status for this Jetpack site. * * @since 4.3.0 * * @return bool True if site is connected */ public static function jetpack_connection_status() { return rest_ensure_response(array('isActive' => Jetpack::is_active(), 'isStaging' => Jetpack::is_staging_site(), 'devMode' => array('isActive' => Jetpack::is_development_mode(), 'constant' => defined('JETPACK_DEV_DEBUG') && JETPACK_DEV_DEBUG, 'url' => site_url() && false === strpos(site_url(), '.'), 'filter' => apply_filters('jetpack_development_mode', false)))); }
/** * Checks to make sure that local options have the same values as remote options. Will cache the results for up to 24 hours. * * @param bool $force_recheck Whether to ignore any cached transient and manually re-check. * * @return array An array of options that do not match. If everything is good, it will evaluate to false. */ public static function check_identity_crisis($force_recheck = false) { if (!Jetpack::is_active() || Jetpack::is_development_mode()) { return false; } if ($force_recheck || false === ($errors = get_transient('jetpack_has_identity_crisis'))) { $options_to_check = self::identity_crisis_options_to_check(); $cloud_options = self::get_cloud_site_options($options_to_check); $errors = array(); foreach ($cloud_options as $cloud_key => $cloud_value) { // If it's not the same as the local value... if ($cloud_value !== get_option($cloud_key)) { // And it's not been added to the whitelist... if (!self::is_identity_crisis_value_whitelisted($cloud_key, $cloud_value)) { // Then kick an error! $errors[$cloud_key] = $cloud_value; } } } } return apply_filters('jetpack_has_identity_crisis', $errors, $force_recheck); }
echo Jetpack::admin_url(); ?> " title="<?php esc_attr_e('Jetpack', 'jetpack'); ?> " <?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>