本文整理汇总了PHP中Jetpack::is_development_mode方法的典型用法代码示例。如果您正苦于以下问题:PHP Jetpack::is_development_mode方法的具体用法?PHP Jetpack::is_development_mode怎么用?PHP Jetpack::is_development_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jetpack
的用法示例。
在下文中一共展示了Jetpack::is_development_mode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_render
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);
}
示例2: add_actions
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);
}
示例3: sync_allowed
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');
}
示例4: elseif
<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 {
?>
示例5: jetpack_photon_url
/**
* 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
*
//.........这里部分代码省略.........
示例6: network_admin_page
/**
* 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();
}
示例7: should_cron_be_running
/**
* 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;
}
示例8: sync
/**
* 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);
}
示例9: admin_screen_list_modules
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>
//.........这里部分代码省略.........
示例10: do_action
<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');
示例11: gallery_shortcode
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 '';
}
示例12: get_module
/**
* 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));
}
示例13: check_plan_deactivate_modules
/**
* 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);
}
示例14: esc_html_e
<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>
示例15: get_health_items
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;
}