function manage_msg() { if (current_user_can('jetpack_manage_modules')) { $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); $manage_active = Jetpack::is_module_active('manage'); ?> <div class="jp-jitm"> <a href="#" data-module="manage" 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 class="msg"> <?php _e('Reduce security risks with automated plugin updates.', 'jetpack'); ?> </p> <p> <img class="jetpack-spinner hide" style="margin-top: 13px;" width="17" height="17" src="<?php echo esc_url(includes_url('images/spinner-2x.gif')); ?> " alt="Loading ..." /><a href="#" data-module="manage" class="activate button button-jetpack <?php if (Jetpack::is_module_active('manage')) { echo 'hide'; } ?> "><?php esc_html_e('Activate Now', 'jetpack'); ?> </a><a href="<?php echo esc_url('https://wordpress.com/plugins/' . $normalized_site_url); ?> " target="_blank" title="<?php esc_attr_e('Go to WordPress.com to try these features', 'jetpack'); ?> " id="jetpack-wordpressdotcom" class="button button-jetpack <?php if (!Jetpack::is_module_active('manage')) { echo 'hide'; } ?> "><?php esc_html_e('Go to WordPress.com', 'jetpack'); ?> </a> </p> </div> <?php //jitm is being viewed, track it $jetpack = Jetpack::init(); $jetpack->stat('jitm', 'manage-viewed-' . JETPACK__VERSION); $jetpack->do_stats('server_side'); } }
function stats_reports_page($main_chart_only = false) { if (isset($_GET['dashboard'])) { return stats_dashboard_widget_content(); } $blog_id = stats_get_option('blog_id'); $domain = Jetpack::build_raw_urls(get_home_url()); if (!$main_chart_only && !isset($_GET['noheader']) && empty($_GET['nojs']) && empty($_COOKIE['stnojs'])) { $nojs_url = add_query_arg('nojs', '1'); $http = is_ssl() ? 'https' : 'http'; // Loading message // No JS fallback message ?> <div class="wrap"> <h2><?php esc_html_e('Site Stats', 'jetpack'); ?> <?php if (current_user_can('jetpack_manage_modules')) { ?> <a style="font-size:13px;" href="<?php echo esc_url(admin_url('admin.php?page=jetpack&configure=stats')); ?> "><?php esc_html_e('Configure', 'jetpack'); ?> </a><?php } ?> </h2> </div> <div id="stats-loading-wrap" class="wrap"> <p class="hide-if-no-js"><img width="32" height="32" alt="<?php esc_attr_e('Loading…', 'jetpack'); ?> " src="<?php echo esc_url(apply_filters('jetpack_static_url', "{$http}://en.wordpress.com/i/loading/loading-64.gif")); ?> " /></p> <p style="font-size: 11pt; margin: 0;"><a href="https://wordpress.com/stats/<?php echo $domain; ?> " target="_blank"><?php esc_html_e('View stats on WordPress.com right now', 'jetpack'); ?> </a></p> <p class="hide-if-js"><?php esc_html_e('Your Site Stats work better with JavaScript enabled.', 'jetpack'); ?> <br /> <a href="<?php echo esc_url($nojs_url); ?> "><?php esc_html_e('View Site Stats without JavaScript', 'jetpack'); ?> </a>.</p> </div> <?php return; } $day = isset($_GET['day']) && preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_GET['day']) ? $_GET['day'] : false; $q = array('noheader' => 'true', 'proxy' => '', 'page' => 'stats', 'day' => $day, 'blog' => $blog_id, 'charset' => get_option('blog_charset'), 'color' => get_user_option('admin_color'), 'ssl' => is_ssl(), 'j' => sprintf('%s:%s', JETPACK__API_VERSION, JETPACK__VERSION)); if (get_locale() !== 'en_US') { $q['jp_lang'] = get_locale(); } // Only show the main chart, without extra header data, or metaboxes. $q['main_chart_only'] = $main_chart_only; $args = array('view' => array('referrers', 'postviews', 'searchterms', 'clicks', 'post', 'table'), 'numdays' => 'int', 'day' => 'date', 'unit' => array(1, 7, 31, 'human'), 'humanize' => array('true'), 'num' => 'int', 'summarize' => null, 'post' => 'int', 'width' => 'int', 'height' => 'int', 'data' => 'data', 'blog_subscribers' => 'int', 'comment_subscribers' => null, 'type' => array('wpcom', 'email', 'pending'), 'pagenum' => 'int'); foreach ($args as $var => $vals) { if (!isset($_REQUEST[$var])) { continue; } if (is_array($vals)) { if (in_array($_REQUEST[$var], $vals)) { $q[$var] = $_REQUEST[$var]; } } elseif ($vals == 'int') { $q[$var] = intval($_REQUEST[$var]); } elseif ($vals == 'date') { if (preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_REQUEST[$var])) { $q[$var] = $_REQUEST[$var]; } } elseif ($vals == null) { $q[$var] = ''; } elseif ($vals == 'data') { if (substr($_REQUEST[$var], 0, 9) == 'index.php') { $q[$var] = $_REQUEST[$var]; } } } if (isset($_GET['chart'])) { if (preg_match('/^[a-z0-9-]+$/', $_GET['chart'])) { $chart = sanitize_title($_GET['chart']); $url = 'https://' . STATS_DASHBOARD_SERVER . "/wp-includes/charts/{$chart}.php"; } } else { $url = 'https://' . STATS_DASHBOARD_SERVER . "/wp-admin/index.php"; } $url = add_query_arg($q, $url); $method = 'GET'; $timeout = 90; $user_id = JETPACK_MASTER_USER; // means send the wp.com user_id $get = Jetpack_Client::remote_request(compact('url', 'method', 'timeout', 'user_id')); $get_code = wp_remote_retrieve_response_code($get); if (is_wp_error($get) || 2 != intval($get_code / 100) && 304 != $get_code || empty($get['body'])) { stats_print_wp_remote_error($get, $url); } else { if (!empty($get['headers']['content-type'])) { $type = $get['headers']['content-type']; if (substr($type, 0, 5) == 'image') { $img = $get['body']; header('Content-Type: ' . $type); header('Content-Length: ' . strlen($img)); echo $img; die; } } $body = stats_convert_post_titles($get['body']); $body = stats_convert_chart_urls($body); $body = stats_convert_image_urls($body); $body = stats_convert_admin_urls($body); echo $body; } if (isset($_GET['page']) && 'stats' === $_GET['page'] && !isset($_GET['chart'])) { JetpackTracking::record_user_event('wpa_page_view', array('path' => 'old_stats')); } if (isset($_GET['noheader'])) { die; } }
<?php $activate_url = wp_nonce_url(Jetpack::admin_url(array('page' => 'jetpack', 'action' => 'activate', 'module' => 'manage')), 'jetpack_activate-manage'); $section = isset($_GET['section']) ? $_GET['section'] : null; $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); $description = __('Well that was easy. You can now manage all of your sites in one convenient place on WordPress.com', 'jetpack'); switch ($section) { case 'plugins': $link = 'https://wordpress.com/plugins/' . $normalized_site_url; $link_title = __('Manage Your Plugins', 'jetpack'); break; case 'themes': $link = 'https://wordpress.com/plugins/' . $normalized_site_url; $link_title = __('Manage Your Themes', 'jetpack'); break; case 'security-settings': $link = 'https://wordpress.com/settings/security/' . $normalized_site_url; $link_title = __('Manage Your Security Settings', 'jetpack'); break; case 'menus': $link = 'https://wordpress.com/menus/' . $normalized_site_url; $link_title = __('Manage Your Menus', 'jetpack'); break; default: $link = 'https://wordpress.com/stats/day/' . $normalized_site_url; $link_title = __('Manage Your Site', 'jetpack'); break; } ?> <div class="page-content landing manage-page"> <div class="manage__icon">
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)); }
/** * Display JITM after a post is published prompting user to enable Backups. * * @since 3.9.5 */ function backups_after_publish_msg() { $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); $url = 'https://wordpress.com/plans/' . $normalized_site_url; $jitm_stats_url = Jetpack::build_stats_url(array('x_jetpack-jitm' => 'vaultpress')); ?> <div class="jp-jitm" data-track="vaultpress-publish" data-stats_url="<?php echo esc_url($jitm_stats_url); ?> "> <a href="#" data-module="vaultpress" class="dismiss"><span class="genericon genericon-close"></span></a> <div class="jp-emblem"> <?php echo self::get_jp_emblem(); ?> </div> <p class="msg"> <?php esc_html_e("Great job! Now let's make sure your hard work is never lost, backup everything with VaultPress.", 'jetpack'); ?> </p> <p> <a href="<?php echo esc_url($url); ?> " target="_blank" title="<?php esc_attr_e('Enable Backups', 'jetpack'); ?> " data-module="vaultpress" data-jptracks-name="nudge_click" data-jptracks-prop="jitm-vault-post" class="button button-jetpack launch jptracks"><?php esc_html_e('Enable Backups', 'jetpack'); ?> </a> </p> </div> <?php //jitm is being viewed, track it $jetpack = Jetpack::init(); $jetpack->stat('jitm', 'vaultpress-publish-viewed-' . JETPACK__VERSION); $jetpack->do_stats('server_side'); }
function page_admin_scripts() { // Enqueue jp.js and localize it wp_enqueue_script('jetpack-js', plugins_url('_inc/jp.js', JETPACK__PLUGIN_FILE), array('jquery', 'wp-util'), JETPACK__VERSION . '-20121111'); wp_localize_script('jetpack-js', 'jetpackL10n', array('ays_disconnect' => __("This will deactivate all Jetpack modules.\nAre you sure you want to disconnect?", 'jetpack'), 'ays_unlink' => __("This will prevent user-specific modules such as Publicize, Notifications and Post By Email from working.\nAre you sure you want to unlink?", 'jetpack'), 'ays_dismiss' => __("This will deactivate Jetpack.\nAre you sure you want to deactivate Jetpack?", 'jetpack'), 'view_all_features' => __('View all Jetpack features', 'jetpack'), 'no_modules_found' => sprintf(__('Sorry, no modules were found for the search term "%s"', 'jetpack'), '{term}'), 'modules' => Jetpack::get_translated_modules(array_values(Jetpack_Admin::init()->get_modules())), 'currentVersion' => JETPACK__VERSION, 'ajaxurl' => admin_url('admin-ajax.php'), 'show_jumpstart' => $this->jetpack_show_jumpstart(), 'activate_nonce' => wp_create_nonce('jetpack-jumpstart-nonce'), 'admin_nonce' => wp_create_nonce('jetpack-admin-nonce'), 'jumpstart_stats_urls' => $this->build_jumpstart_stats_urls(array('dismiss', 'jumpstarted', 'learnmore', 'viewed', 'manual')), 'admin_stats_urls' => $this->build_nux_admin_stats_urls(array('enabled', 'deactivated', 'learnmore')), 'site_url_manage' => Jetpack::build_raw_urls(get_site_url()))); }
<?php if (is_plugin_active('vaultpress/vaultpress.php')) { if (VaultPress::init()->is_registered()) { $vp_link = 'https://dashboard.vaultpress.com'; $target = '_blank'; } else { $vp_link = admin_url('admin.php?page=vaultpress'); $target = '_self'; } } else { $vp_link = esc_url('https://wordpress.com/plans/' . Jetpack::build_raw_urls(get_home_url())); $target = '_blank'; } $modules = array('Appearance', 'Developers', 'Mobile', 'Other', 'Photos and Videos', 'Social', 'Site Stats', 'Writing'); ?> <script id="tmpl-category" type="text/html"> <?php foreach ($modules as $module) { $translated_module = Jetpack::translate_module_tag($module); $module_slug = strtolower(str_replace(array(' ', '.'), array('-', ''), $translated_module)); ?> <div class="cat category-<?php echo esc_attr($module_slug); ?> "><h3><?php echo esc_html($translated_module); ?> </h3><div class="clear"></div></div> <?php }
<?php if (is_plugin_active('vaultpress/vaultpress.php')) { if (VaultPress::init()->is_registered()) { $vp_link = 'https://dashboard.vaultpress.com'; $target = '_blank'; } else { $vp_link = admin_url('admin.php?page=vaultpress'); $target = '_self'; } } else { $vp_link = add_query_arg(array('from' => 'jpnux', 'url' => Jetpack::build_raw_urls(get_home_url())), 'https://vaultpress.com/jetpack'); $target = '_blank'; } $modules = array('Appearance', 'Developers', 'Mobile', 'Other', 'Photos and Videos', 'Social', 'Site Stats', 'Writing'); ?> <script id="tmpl-category" type="text/html"> <?php foreach ($modules as $module) { $translated_module = Jetpack::translate_module_tag($module); $module_slug = strtolower(str_replace(array(' ', '.'), array('-', ''), $translated_module)); ?> <div class="cat category-<?php echo esc_attr($module_slug); ?> "><h3><?php echo esc_html($translated_module); ?> </h3><div class="clear"></div></div> <?php }
function page_admin_scripts() { // Enqueue jp.js and localize it wp_enqueue_script('react-plugin', plugins_url('_inc/build/admin.js', JETPACK__PLUGIN_FILE), array(), time(), true); wp_enqueue_style('dops-css', plugins_url('_inc/build/dops-style.css', JETPACK__PLUGIN_FILE), array(), time()); wp_enqueue_style('components-css', plugins_url('_inc/build/style.min.css', JETPACK__PLUGIN_FILE), array(), time()); $localeSlug = explode('_', get_locale()); $localeSlug = $localeSlug[0]; // 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' => 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))), 'dismissedNotices' => $this->get_dismissed_jetpack_notices(), 'isDevVersion' => Jetpack::is_development_version(), 'currentVersion' => JETPACK__VERSION, 'happinessGravIds' => jetpack_get_happiness_gravatar_ids(), 'getModules' => Jetpack_Core_Json_Api_Endpoints::get_modules(), 'showJumpstart' => jetpack_show_jumpstart(), 'rawUrl' => Jetpack::build_raw_urls(get_home_url()), 'adminUrl' => esc_url(admin_url()), 'statsData' => build_initial_stats_shape(), 'settingNames' => array('jetpack_holiday_snow_enabled' => function_exists('jetpack_holiday_snow_option_name') ? jetpack_holiday_snow_option_name() : false), 'userData' => array('othersLinked' => jetpack_get_other_linked_users(), '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')))); }
/** * Display message in editor prompting user to enable stats. * * @since 3.9.0 */ function stats_msg() { $stats_active = Jetpack::is_module_active('stats'); $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); ?> <div class="jp-jitm"> <a href="#" data-module="stats" class="dismiss"><span class="genericon genericon-close"></span></a> <div class="jp-emblem"> <?php echo self::get_jp_emblem(); ?> </div> <p class="msg"> <?php esc_html_e('Track detailed stats on this post and the rest of your site.', 'jetpack'); ?> </p> <?php if (!$stats_active) { ?> <p> <img class="j-spinner hide" src="<?php echo esc_url(includes_url('images/spinner-2x.gif')); ?> " alt="<?php echo esc_attr__('Loading...', 'jetpack'); ?> " /><a href="#" data-module="stats" data-module-success="<?php esc_attr_e('Success! Jetpack Stats is now activated.', 'jetpack'); ?> " class="activate button"><?php esc_html_e('Enable Jetpack Stats', 'jetpack'); ?> </a> </p> <?php } // stats inactive ?> <p class="show-after-enable <?php echo $stats_active ? '' : 'hide'; ?> "> <a href="<?php echo esc_url('https://wordpress.com/stats/insights/' . $normalized_site_url); ?> " target="_blank" title="<?php esc_attr_e('Go to WordPress.com', 'jetpack'); ?> " data-module="stats" class="button button-jetpack launch show-after-enable"><?php esc_html_e('Go to WordPress.com', 'jetpack'); ?> </a> </p> </div> <?php //jitm is being viewed, track it $jetpack = Jetpack::init(); $jetpack->stat('jitm', 'post-stats-viewed-' . JETPACK__VERSION); $jetpack->do_stats('server_side'); }
/** * Display message in editor prompting user to compose entry in WordPress.com. * * @since 3.8.2 */ function editor_msg() { global $typenow; if (current_user_can('manage_options')) { $normalized_site_url = Jetpack::build_raw_urls(get_home_url()); $editor_dismissed = isset(self::$jetpack_hide_jitm['editor']); if (!$editor_dismissed) { ?> <div class="jp-jitm"> <a href="#" data-module="editor" 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 class="msg"> <?php esc_html_e('Try the brand new editor.', 'jetpack'); ?> </p> <p> <a href="<?php echo esc_url('https://wordpress.com/' . $typenow . '/' . $normalized_site_url); ?> " target="_blank" title="<?php esc_attr_e('Write on WordPress.com', 'jetpack'); ?> " data-module="editor" class="button button-jetpack launch show-after-enable"><?php esc_html_e('Write on WordPress.com', 'jetpack'); ?> </a> </p> </div> <?php //jitm is being viewed, track it $jetpack = Jetpack::init(); $jetpack->stat('jitm', 'editor-viewed-' . JETPACK__VERSION); $jetpack->do_stats('server_side'); } // manage or editor inactive } }