Esempio n. 1
0
function https_stats_footer()
{
    $protocol = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? "https://" : "http://";
    global $wp_the_query, $current_user;
    $options = stats_get_options();
    if (!empty($current_user->ID) || empty($options['blog_id'])) {
        return;
    }
    $a['blog'] = $options['blog_id'];
    $a['v'] = 'ext';
    if ($wp_the_query->is_single || $wp_the_query->is_page) {
        $a['post'] = $wp_the_query->get_queried_object_id();
    } else {
        $a['post'] = '0';
    }
    ?>
<script src="<?php 
    echo $protocol;
    ?>
stats.wordpress.com/e-<?php 
    echo gmdate('YW');
    ?>
.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({<?php 
    echo stats_array($a);
    ?>
});
var load_cmc = function(){linktracker_init(<?php 
    echo "{$a['blog']},{$a['post']},2";
    ?>
);};
if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc);
else load_cmc();
</script>
<?php 
}
Esempio n. 2
0
function stats_get_blog()
{
    $home = parse_url(trailingslashit(get_option('home')));
    $blog = array('host' => $home['host'], 'path' => $home['path'], 'blogname' => get_option('blogname'), 'blogdescription' => get_option('blogdescription'), 'siteurl' => get_option('siteurl'), 'gmt_offset' => get_option('gmt_offset'), 'timezone_string' => get_option('timezone_string'), 'stats_version' => STATS_VERSION, 'stats_api' => 'jetpack', 'page_on_front' => get_option('page_on_front'), 'permalink_structure' => get_option('permalink_structure'), 'category_base' => get_option('category_base'), 'tag_base' => get_option('tag_base'));
    $blog = array_merge(stats_get_options(), $blog);
    unset($blog['roles'], $blog['blog_id']);
    return stats_esc_html_deep($blog);
}
Esempio n. 3
0
 /**
  * Modify Infinite Scroll configuration information
  *
  * @uses Jetpack::get_active_modules, is_user_logged_in, stats_get_options, Jetpack_Options::get_option, get_option, JETPACK__API_VERSION, JETPACK__VERSION
  * @filter infinite_scroll_js_settings
  * @return array
  */
 public function filter_infinite_scroll_js_settings($settings)
 {
     // Provide WP Stats info for tracking Infinite Scroll loads
     // Abort if Stats module isn't active
     if (in_array('stats', Jetpack::get_active_modules())) {
         // Abort if user is logged in but logged-in users shouldn't be tracked.
         if (is_user_logged_in()) {
             $stats_options = stats_get_options();
             $track_loggedin_users = isset($stats_options['reg_users']) ? (bool) $stats_options['reg_users'] : false;
             if (!$track_loggedin_users) {
                 return $settings;
             }
         }
         // We made it this far, so gather the data needed to track IS views
         $settings['stats'] = 'blog=' . Jetpack_Options::get_option('id') . '&host=' . parse_url(get_option('home'), PHP_URL_HOST) . '&v=ext&j=' . JETPACK__API_VERSION . ':' . JETPACK__VERSION;
         // Pagetype parameter
         $settings['stats'] .= '&x_pagetype=infinite';
         if ('click' == $settings['type']) {
             $settings['stats'] .= '-click';
         }
         $settings['stats'] .= '-jetpack';
     }
     // Check if Google Analytics tracking is requested
     $settings['google_analytics'] = (bool) get_option($this->option_name_google_analytics);
     return $settings;
 }
Esempio n. 4
0
function stats_get_blog_id($api_key)
{
    $options = stats_get_options();
    require_once ABSPATH . WPINC . '/class-IXR.php';
    $client = new IXR_Client(STATS_XMLRPC_SERVER);
    extract(parse_url(get_option('home')));
    $path = rtrim($path, '/');
    if (empty($path)) {
        $path = '/';
    }
    $client->query('wpStats.get_blog_id', $api_key, stats_get_blog());
    if ($client->isError()) {
        if ($client->getErrorCode() == -32300) {
            $options['error'] = __('Your blog was unable to connect to WordPress.com. Please ask your host for help. (' . $client->getErrorMessage() . ')', 'stats');
        } else {
            $options['error'] = $client->getErrorMessage();
        }
        stats_set_options($options);
        return false;
    } else {
        $options['error'] = false;
    }
    $response = $client->getResponse();
    $blog_id = isset($response['blog_id']) ? (int) $response['blog_id'] : false;
    $options['host'] = $host;
    $options['path'] = $path;
    $options['blog_id'] = $blog_id;
    stats_set_options($options);
    stats_set_api_key($api_key);
    return $blog_id;
}
 /**
  * Remove 'validate_callback' item from options available for module.
  * Fetch current option value and add to array of module options.
  * Prepare values of module options that need special handling, like those saved in wpcom.
  *
  * @since 4.3.0
  *
  * @param string $module Module slug.
  * @return array
  */
 public static function prepare_options_for_response($module = '')
 {
     $options = self::get_module_available_options($module);
     if (!is_array($options) || empty($options)) {
         return $options;
     }
     foreach ($options as $key => $value) {
         if (isset($options[$key]['validate_callback'])) {
             unset($options[$key]['validate_callback']);
         }
         $default_value = isset($options[$key]['default']) ? $options[$key]['default'] : '';
         $current_value = get_option($key, $default_value);
         $options[$key]['current_value'] = self::cast_value($current_value, $options[$key]);
     }
     // Some modules need special treatment.
     switch ($module) {
         case 'monitor':
             // Status of user notifications
             $options['monitor_receive_notifications']['current_value'] = self::cast_value(self::get_remote_value('monitor', 'monitor_receive_notifications'), $options['monitor_receive_notifications']);
             break;
         case 'post-by-email':
             // Email address
             $options['post_by_email_address']['current_value'] = self::cast_value(self::get_remote_value('post-by-email', 'post_by_email_address'), $options['post_by_email_address']);
             break;
         case 'protect':
             // Protect
             $options['jetpack_protect_key']['current_value'] = get_site_option('jetpack_protect_key', false);
             if (!function_exists('jetpack_protect_format_whitelist')) {
                 @(include JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php');
             }
             $options['jetpack_protect_global_whitelist']['current_value'] = jetpack_protect_format_whitelist();
             break;
         case 'related-posts':
             // It's local, but it must be broken apart since it's saved as an array.
             $options = self::split_options($options, Jetpack_Options::get_option('relatedposts'));
             break;
         case 'verification-tools':
             // It's local, but it must be broken apart since it's saved as an array.
             $options = self::split_options($options, get_option('verification_services_codes'));
             break;
         case 'sharedaddy':
             // It's local, but it must be broken apart since it's saved as an array.
             if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                 break;
             }
             $sharer = new Sharing_Service();
             $options = self::split_options($options, $sharer->get_global_options());
             $options['sharing_services']['current_value'] = $sharer->get_blog_services();
             break;
         case 'site-icon':
             // Return site icon ID and URL to make it more complete.
             $options['site_icon_id']['current_value'] = Jetpack_Options::get_option('site_icon_id');
             if (!function_exists('jetpack_site_icon_url')) {
                 @(include JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php');
             }
             $options['site_icon_url']['current_value'] = jetpack_site_icon_url();
             break;
         case 'after-the-deadline':
             if (!function_exists('AtD_get_options')) {
                 @(include JETPACK__PLUGIN_DIR . 'modules/after-the-deadline.php');
             }
             $atd_options = array_merge(AtD_get_options(get_current_user_id(), 'AtD_options'), AtD_get_options(get_current_user_id(), 'AtD_check_when'));
             unset($atd_options['name']);
             foreach ($atd_options as $key => $value) {
                 $options[$key]['current_value'] = self::cast_value($value, $options[$key]);
             }
             $atd_options = AtD_get_options(get_current_user_id(), 'AtD_guess_lang');
             $options['guess_lang']['current_value'] = self::cast_value(isset($atd_options['true']), $options['guess_lang']);
             $options['ignored_phrases']['current_value'] = AtD_get_setting(get_current_user_id(), 'AtD_ignored_phrases');
             unset($options['unignore_phrase']);
             break;
         case 'minileven':
             $options['wp_mobile_excerpt']['current_value'] = 1 === intval($options['wp_mobile_excerpt']['current_value']) ? 'enabled' : 'disabled';
             $options['wp_mobile_featured_images']['current_value'] = 1 === intval($options['wp_mobile_featured_images']['current_value']) ? 'enabled' : 'disabled';
             break;
         case 'stats':
             // It's local, but it must be broken apart since it's saved as an array.
             if (!function_exists('stats_get_options')) {
                 @(include JETPACK__PLUGIN_DIR . 'modules/stats.php');
             }
             $options = self::split_options($options, stats_get_options());
             break;
     }
     return $options;
 }
Esempio n. 6
0
function stats_activate()
{
    $options = stats_get_options();
    if (empty($options['blog_id']) && ($api_key = stats_get_api_key())) {
        stats_get_blog_id($api_key);
    }
}
Esempio n. 7
0
 function enqueue_assets($output)
 {
     if (!empty($output) && !apply_filters('jp_carousel_force_enable', false)) {
         // Bail because someone is overriding the [gallery] shortcode.
         remove_filter('gallery_style', array($this, 'add_data_to_container'));
         remove_filter('wp_get_attachment_image_attributes', array($this, 'add_data_to_images'));
         // Display message that carousel has bailed, if user is super_admin, and if we're not on WordPress.com.
         if (is_super_admin() && !(defined('IS_WPCOM') && IS_WPCOM)) {
             add_filter('post_gallery', array($this, 'display_bail_message'));
         }
         return $output;
     }
     /**
      * Fires when thumbnails are shown in Carousel.
      *
      * @module carousel
      *
      * @since 1.6.0
      **/
     do_action('jp_carousel_thumbnails_shown');
     if ($this->first_run) {
         wp_enqueue_script('jetpack-carousel', plugins_url('jetpack-carousel.js', __FILE__), array('jquery.spin'), $this->asset_version('20160325'), true);
         // Note: using  home_url() instead of admin_url() for ajaxurl to be sure  to get same domain on wpcom when using mapped domains (also works on self-hosted)
         // Also: not hardcoding path since there is no guarantee site is running on site root in self-hosted context.
         $is_logged_in = is_user_logged_in();
         $current_user = wp_get_current_user();
         $comment_registration = intval(get_option('comment_registration'));
         $require_name_email = intval(get_option('require_name_email'));
         $localize_strings = array('widths' => $this->prebuilt_widths, 'is_logged_in' => $is_logged_in, 'lang' => strtolower(substr(get_locale(), 0, 2)), 'ajaxurl' => set_url_scheme(admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('carousel_nonce'), 'display_exif' => $this->test_1or0_option(Jetpack_Options::get_option_and_ensure_autoload('carousel_display_exif', true)), 'display_geo' => $this->test_1or0_option(Jetpack_Options::get_option_and_ensure_autoload('carousel_display_geo', true)), 'background_color' => $this->carousel_background_color_sanitize(Jetpack_Options::get_option_and_ensure_autoload('carousel_background_color', '')), 'comment' => __('Comment', 'jetpack'), 'post_comment' => __('Post Comment', 'jetpack'), 'write_comment' => __('Write a Comment...', 'jetpack'), 'loading_comments' => __('Loading Comments...', 'jetpack'), 'download_original' => sprintf(__('View full size <span class="photo-size">%1$s<span class="photo-size-times">&times;</span>%2$s</span>', 'jetpack'), '{0}', '{1}'), 'no_comment_text' => __('Please be sure to submit some text with your comment.', 'jetpack'), 'no_comment_email' => __('Please provide an email address to comment.', 'jetpack'), 'no_comment_author' => __('Please provide your name to comment.', 'jetpack'), 'comment_post_error' => __('Sorry, but there was an error posting your comment. Please try again later.', 'jetpack'), 'comment_approved' => __('Your comment was approved.', 'jetpack'), 'comment_unapproved' => __('Your comment is in moderation.', 'jetpack'), 'camera' => __('Camera', 'jetpack'), 'aperture' => __('Aperture', 'jetpack'), 'shutter_speed' => __('Shutter Speed', 'jetpack'), 'focal_length' => __('Focal Length', 'jetpack'), 'comment_registration' => $comment_registration, 'require_name_email' => $require_name_email, 'login_url' => wp_login_url(apply_filters('the_permalink', get_permalink())));
         if (!isset($localize_strings['jetpack_comments_iframe_src']) || empty($localize_strings['jetpack_comments_iframe_src'])) {
             // We're not using Comments after all, so fallback to standard local comments.
             if ($is_logged_in) {
                 $localize_strings['local_comments_commenting_as'] = '<p id="jp-carousel-commenting-as">' . sprintf(__('Commenting as %s', 'jetpack'), $current_user->data->display_name) . '</p>';
             } else {
                 if ($comment_registration) {
                     $localize_strings['local_comments_commenting_as'] = '<p id="jp-carousel-commenting-as">' . __('You must be <a href="#" class="jp-carousel-comment-login">logged in</a> to post a comment.', 'jetpack') . '</p>';
                 } else {
                     $required = $require_name_email ? __('%s (Required)', 'jetpack') : '%s';
                     $localize_strings['local_comments_commenting_as'] = '' . '<fieldset><label for="email">' . sprintf($required, __('Email', 'jetpack')) . '</label> ' . '<input type="text" name="email" class="jp-carousel-comment-form-field jp-carousel-comment-form-text-field" id="jp-carousel-comment-form-email-field" /></fieldset>' . '<fieldset><label for="author">' . sprintf($required, __('Name', 'jetpack')) . '</label> ' . '<input type="text" name="author" class="jp-carousel-comment-form-field jp-carousel-comment-form-text-field" id="jp-carousel-comment-form-author-field" /></fieldset>' . '<fieldset><label for="url">' . __('Website', 'jetpack') . '</label> ' . '<input type="text" name="url" class="jp-carousel-comment-form-field jp-carousel-comment-form-text-field" id="jp-carousel-comment-form-url-field" /></fieldset>';
                 }
             }
         }
         /**
          * Handle WP stats for images in full-screen.
          * Build string with tracking info.
          */
         if (in_array('stats', Jetpack::get_active_modules()) && !Jetpack::is_development_mode()) {
             $localize_strings['stats'] = 'blog=' . Jetpack_Options::get_option('id') . '&host=' . parse_url(get_option('home'), PHP_URL_HOST) . '&v=ext&j=' . JETPACK__API_VERSION . ':' . JETPACK__VERSION;
             // Set the stats as empty if user is logged in but logged-in users shouldn't be tracked.
             if (is_user_logged_in() && function_exists('stats_get_options')) {
                 $stats_options = stats_get_options();
                 $track_loggedin_users = isset($stats_options['reg_users']) ? (bool) $stats_options['reg_users'] : false;
                 if (!$track_loggedin_users) {
                     $localize_strings['stats'] = '';
                 }
             }
         }
         /**
          * Filter the strings passed to the Carousel's js file.
          *
          * @module carousel
          *
          * @since 1.6.0
          *
          * @param array $localize_strings Array of strings passed to the Jetpack js file.
          */
         $localize_strings = apply_filters('jp_carousel_localize_strings', $localize_strings);
         wp_localize_script('jetpack-carousel', 'jetpackCarouselStrings', $localize_strings);
         if (is_rtl()) {
             wp_enqueue_style('jetpack-carousel', plugins_url('/rtl/jetpack-carousel-rtl.css', __FILE__), array(), $this->asset_version('20120629'));
         } else {
             wp_enqueue_style('jetpack-carousel', plugins_url('jetpack-carousel.css', __FILE__), array(), $this->asset_version('20120629'));
         }
         wp_register_style('jetpack-carousel-ie8fix', plugins_url('jetpack-carousel-ie8fix.css', __FILE__), array(), $this->asset_version('20121024'));
         $GLOBALS['wp_styles']->add_data('jetpack-carousel-ie8fix', 'conditional', 'lte IE 8');
         wp_enqueue_style('jetpack-carousel-ie8fix');
         /**
          * Fires after carousel assets are enqueued for the first time.
          * Allows for adding additional assets to the carousel page.
          *
          * @module carousel
          *
          * @since 1.6.0
          *
          * @param bool $first_run First load if Carousel on the page.
          * @param array $localized_strings Array of strings passed to the Jetpack js file.
          */
         do_action('jp_carousel_enqueue_assets', $this->first_run, $localize_strings);
         $this->first_run = false;
     }
     return $output;
 }