See also: Jetpack_Options::get_option_names() jetpack_register (string) Temporary verification secrets. jetpack_activated (int) 1: the plugin was activated normally 2: the plugin was activated on this site because of a network-wide activation 3: the plugin was auto-installed 4: the plugin was manually disconnected (but is still installed) jetpack_active_modules (array) Array of active module slugs. jetpack_do_activate (bool) Flag for "activating" the plugin on sites where the activation hook never fired (auto-installs)
Example #1
0
 function __construct()
 {
     if (class_exists('Jetpack') && Jetpack::is_active()) {
         add_action('jetpack-start_step-connect-social', array($this, 'render'));
         add_filter('jetpack_start_js_globals', array($this, 'jetpack_start_js_globals'));
     }
 }
 protected static function format_module($module_slug)
 {
     $module_data = Jetpack::get_module($module_slug);
     $module = array();
     $module['id'] = $module_slug;
     $module['active'] = Jetpack::is_module_active($module_slug);
     $module['name'] = $module_data['name'];
     $module['short_description'] = $module_data['description'];
     $module['sort'] = $module_data['sort'];
     $module['introduced'] = $module_data['introduced'];
     $module['changed'] = $module_data['changed'];
     $module['free'] = $module_data['free'];
     $module['module_tags'] = $module_data['module_tags'];
     // Fetch the HTML formatted long description
     ob_start();
     if (Jetpack::is_active() && has_action('jetpack_module_more_info_connected_' . $module_slug)) {
         /** This action is documented in class.jetpack-modules-list-table.php */
         do_action('jetpack_module_more_info_connected_' . $module_slug);
     } else {
         /** This action is documented in class.jetpack-modules-list-table.php */
         do_action('jetpack_module_more_info_' . $module_slug);
     }
     $module['description'] = ob_get_clean();
     return $module;
 }
 /**
  * Gets locally stored token
  *
  * @return object|false
  */
 public static function get_access_token($user_id = false)
 {
     if ($user_id) {
         if (!($tokens = Jetpack::get_option('user_tokens'))) {
             return false;
         }
         if ($user_id === JETPACK_MASTER_USER) {
             if (!($user_id = Jetpack::get_option('master_user'))) {
                 return false;
             }
         }
         if (!isset($tokens[$user_id]) || !($token = $tokens[$user_id])) {
             return false;
         }
         $token_chunks = explode('.', $token);
         if (empty($token_chunks[1]) || empty($token_chunks[2])) {
             return false;
         }
         if ($user_id != $token_chunks[2]) {
             return false;
         }
         $token = "{$token_chunks[0]}.{$token_chunks[1]}";
     } else {
         $token = Jetpack::get_option('blog_token');
         if (empty($token)) {
             return false;
         }
     }
     return (object) array('secret' => $token, 'external_user_id' => (int) $user_id);
 }
/**
 * Executes an elasticsearch query via our REST API.
 *
 * Requires setup on our end and a paid addon to your hosting account.
 * You probably shouldn't be using this function. Questions? Ask us.
 *
 * Valid arguments:
 *
 * * size: Number of query results to return.
 *
 * * from: Offset, the starting result to return.
 *
 * * multi_match: Will do a match search against the default fields (this is almost certainly what you want).
 *                e.g. array( 'query' => 'this is a test', 'fields' => array( 'content' ) )
 *                See: http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html
 *
 * * query_string: Will do a query_string search, interprets the string as Lucene query syntax.
 *                 e.g. array( 'default_field' => 'content', 'query' => 'tag:(world OR nation) howdy' )
 *                 This can fail if the user doesn't close parenthesis, or specifies a field that is not valid.
 *                 See: http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html
 *
 * * more_like_this: Will do a more_like_this search, which is best for related content.
 *                   e.g. array( 'fields' => array( 'title', 'content' ), 'like_text' => 'this is a test', 'min_term_freq' => 1, 'max_query_terms' => 12 )
 *                   See: http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html
 *
 * * facets: Structured set of facets. DO NOT do a terms facet on the content of posts/comments. It will load ALL terms into memory,
 *           probably taking minutes to complete and slowing down the entire cluster. With great power... etc.
 *           See: http://www.elasticsearch.org/guide/reference/api/search/facets/index.html
 *
 * * filter: Structured set of filters (often FASTER, since cached from one query to the next).
 *            See: http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html
 *
 * * highlight: Structure defining how to highlight the results.
 *              See: http://www.elasticsearch.org/guide/reference/api/search/highlighting.html
 *
 * * fields: Structure defining what fields to return with the results.
 *           See: http://www.elasticsearch.org/guide/reference/api/search/fields.html
 *
 * * sort: Structure defining how to sort the results.
 *         See: http://www.elasticsearch.org/guide/reference/api/search/sort.html
 *
 * @param array $args
 * @return bool|string False if WP_Error, otherwise JSON string
 */
function es_api_search_index($args)
{
    if (class_exists('Jetpack')) {
        $jetpack_blog_id = Jetpack::get_option('id');
        if (!$jetpack_blog_id) {
            return array('error' => 'Failed to get Jetpack blog_id');
        }
        $args['blog_id'] = $jetpack_blog_id;
    }
    $defaults = array('blog_id' => get_current_blog_id());
    $args = wp_parse_args($args, $defaults);
    $args['blog_id'] = absint($args['blog_id']);
    $service_url = 'http://public-api.wordpress.com/rest/v1/sites/' . $args['blog_id'] . '/search';
    unset($args['blog_id']);
    $request = wp_remote_post($service_url, array('headers' => array('Content-Type' => 'application/json'), 'body' => json_encode($args)));
    if (is_wp_error($request)) {
        return false;
    }
    $response = json_decode(wp_remote_retrieve_body($request), true);
    // Rewrite blog id from remote to local id
    if (isset($response['results']) && isset($response['results']['hits'])) {
        $local_blog_id = get_current_blog_id();
        foreach ($response['results']['hits'] as $key => $hit) {
            if (isset($hit['fields']['blog_id']) && $hit['fields']['blog_id'] == $jetpack_blog_id) {
                $response['results']['hits'][$key]['fields']['blog_id'] = $local_blog_id;
            }
        }
    }
    return $response;
}
Example #5
0
 function __construct()
 {
     global $current_user;
     $this->log('Created WP_Polldaddy Object: constructor');
     $this->errors = new WP_Error();
     $this->scheme = 'https';
     $this->version = '2.0.22';
     $this->multiple_accounts = true;
     $this->polldaddy_client_class = 'api_client';
     $this->polldaddy_clients = array();
     $this->is_admin = (bool) current_user_can('manage_options');
     $this->is_author = (bool) current_user_can('edit_posts');
     $this->is_editor = (bool) current_user_can('delete_others_pages');
     $this->user_code = null;
     $this->rating_user_code = null;
     $this->id = $current_user instanceof WP_User ? intval($current_user->ID) : 0;
     $this->has_feedback_menu = false;
     if (class_exists('Jetpack')) {
         if (method_exists('Jetpack', 'is_active') && Jetpack::is_active()) {
             $jetpack_active_modules = get_option('jetpack_active_modules');
             if ($jetpack_active_modules && in_array('contact-form', $jetpack_active_modules)) {
                 $this->has_feedback_menu = true;
             }
         }
     }
 }
Example #6
0
/**
 * Load stylesheets for the front end.
 *
 * @since 1.0
 * @access public
 * @return void
 */
function hoot_base_enqueue_styles()
{
    /* Gets ".min" suffix. */
    $suffix = hoot_get_min_suffix();
    /* Load Google Fonts if 'google-fonts' is active. */
    if (current_theme_supports('google-fonts')) {
        wp_enqueue_style('hoot-google-fonts', hoot_google_fonts_enqueue_url(), array(), null);
    }
    /* Load lightSlider style if 'light-slider' is active. */
    if (current_theme_supports('slick-slider')) {
        wp_enqueue_style('slick', trailingslashit(THEME_URI) . "css/slick{$suffix}.css", false, '1.5.9');
        wp_enqueue_style('slick-theme', trailingslashit(THEME_URI) . "css/slick-theme{$suffix}.css", false, '1.5.9');
    }
    /* Load gallery style if 'cleaner-gallery' is active. */
    if (current_theme_supports('cleaner-gallery')) {
        wp_enqueue_style('gallery', trailingslashit(HOOT_CSS) . "gallery{$suffix}.css");
    }
    /* Load gallery styles if Jetpack 'tiled-gallery' module is active */
    if (class_exists('Jetpack') && Jetpack::is_module_active('tiled-gallery')) {
        wp_enqueue_style('gallery', trailingslashit(HOOT_CSS) . "gallery{$suffix}.css");
        wp_enqueue_style('hoot-jetpack', trailingslashit(THEME_URI) . "css/jetpack{$suffix}.css");
    }
    /* Load font awesome if 'font-awesome' is active. */
    if (current_theme_supports('font-awesome')) {
        wp_enqueue_style('font-awesome', trailingslashit(HOOT_CSS) . "font-awesome{$suffix}.css", false, '4.2.0');
    }
}
    function photon_msg()
    {
        if (current_user_can('jetpack_manage_modules')) {
            ?>
			<div class="jp-jitm">
				<a href="#"  data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a>
				<div class="jp-emblem">
					<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 172.9 172.9" enable-background="new 0 0 172.9 172.9" xml:space="preserve">
						<path d="M86.4 0C38.7 0 0 38.7 0 86.4c0 47.7 38.7 86.4 86.4 86.4s86.4-38.7 86.4-86.4C172.9 38.7 134.2 0 86.4 0zM83.1 106.6l-27.1-6.9C49 98 45.7 90.1 49.3 84l33.8-58.5V106.6zM124.9 88.9l-33.8 58.5V66.3l27.1 6.9C125.1 74.9 128.4 82.8 124.9 88.9z"/>
					</svg>
				</div>
				<p>
					<?php 
            _e('Deliver super-fast images to your visitors that are automatically optimized for any device.', 'jetpack');
            ?>
				</p>
				<p>
					<a href="#" data-module="photon" class="activate button button-jetpack">
						<?php 
            esc_html_e('Activate Photon', 'jetpack');
            ?>
					</a>
				</p>
			</div>
		<?php 
            //jitm is being viewed, track it
            $jetpack = Jetpack::init();
            $jetpack->stat('jitm', 'photon-viewed');
            $jetpack->do_stats('server_side');
        }
    }
Example #8
0
/**
 * Vine embed code:
 * <iframe class="vine-embed" src="https://vine.co/v/bjHh0zHdgZT" width="600" height="600" frameborder="0"></iframe>
 * <script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
 *
 * URL example:
 * https://vine.co/v/bjHh0zHdgZT/
 *
 * Embed shortcode examples:
 * [embed]https://vine.co/v/bjHh0zHdgZT[/embed]
 * [embed width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
 * [embed type="postcard" width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
 **/
function vine_embed_video($matches, $attr, $url, $rawattr)
{
    static $vine_flag_embedded_script;
    $max_height = 300;
    $type = 'simple';
    // Only allow 'postcard' or 'simple' types
    if (isset($rawattr['type']) && $rawattr['type'] === 'postcard') {
        $type = 'postcard';
    }
    $vine_size = Jetpack::get_content_width();
    // If the user enters a value for width or height, we ignore the Jetpack::get_content_width()
    if (isset($rawattr['width']) || isset($rawattr['height'])) {
        // 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird.
        $vine_size = max($max_height, min($attr['width'], $attr['height']));
    }
    if (empty($vine_size)) {
        $vine_size = $max_height;
    }
    $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type;
    $vine_html = sprintf('<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%s" width="%s" height="%s" frameborder="0"></iframe></span>', esc_url($url), (int) $vine_size, (int) $vine_size);
    if ($vine_flag_embedded_script !== true) {
        $vine_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>';
        $vine_flag_embedded_script = true;
    }
    return $vine_html;
}
Example #9
0
function enlightenment_general_settings()
{
    add_settings_section('navbar', __('Navbar', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('page_header', __('Page Header', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('post_thumbnails', __('Post Thumbnails', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('entry_meta', __('Entry Meta', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('lightbox', __('Lightbox', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('posts_nav', __('Posts Navigation', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_section('footer', __('Footer', 'enlightenment'), '__return_false', 'enlightenment_theme_options');
    add_settings_field('navbar_position', __('Navbar Position', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'navbar', array('name' => 'navbar_position', 'options' => array('fixed-top' => 'Fixed on Top', 'static-top' => 'Static')));
    add_settings_field('navbar_background', __('Navbar Background Color', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'navbar', array('name' => 'navbar_background', 'options' => array('default' => 'Light', 'inverse' => 'Dark')));
    add_settings_field('navbar_size', __('Navbar Size', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'navbar', array('name' => 'navbar_size', 'options' => array('small' => 'Small', 'large' => 'Large'), 'description' => __('Menu Item Descriptions are hidden in the small Navbar.', 'enlightenment')));
    add_settings_field('shrink_navbar', __('Shrink Navbar', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'navbar', array('name' => 'shrink_navbar', 'label' => __('Shrink Fixed Navbar when scrolling', 'enlightenment')));
    add_settings_field('blog_header_text', __('Blog Pages Header Text', 'enlightenment'), 'enlightenment_text_input', 'enlightenment_theme_options', 'page_header', array('name' => 'blog_header_text'));
    add_settings_field('blog_header_description', __('Blog Pages Description', 'enlightenment'), 'enlightenment_textarea', 'enlightenment_theme_options', 'page_header', array('name' => 'blog_header_description'));
    add_settings_field('thumbnail_header_image', __('Thumbnail Header Image', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'page_header', array('name' => 'thumbnail_header_image', 'label' => __('Display post thumbnail as header image on single posts', 'enlightenment')));
    add_settings_field('thumbnails_crop_flag', __('Crop Thumbnails', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'post_thumbnails', array('name' => 'thumbnails_crop_flag', 'label' => __('Hard crop post thumbnails', 'enlightenment'), 'description' => sprintf(__('After changing this option, it is recommended to recreate your thumbnails using a plugin like <a href="%s">AJAX Thumbnail Rebuild</a>', 'enlightenment'), esc_url('http://wordpress.org/extend/plugins/ajax-thumbnail-rebuild/'))));
    add_settings_field('thumbnails_size', __('Thumbnails Size', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'post_thumbnails', array('name' => 'thumbnails_size', 'options' => array('small' => 'Small', 'large' => 'Large')));
    $post_meta = enlightenment_theme_option('post_meta');
    add_settings_field('post_meta', __('Post Meta', 'enlightenment'), 'enlightenment_checkboxes', 'enlightenment_theme_options', 'entry_meta', array('boxes' => array(array('name' => 'post_meta[author]', 'label' => __('Author', 'enlightenment'), 'checked' => $post_meta['author']), array('name' => 'post_meta[date]', 'label' => __('Date', 'enlightenment'), 'checked' => $post_meta['date']), array('name' => 'post_meta[category]', 'label' => __('Category', 'enlightenment'), 'checked' => $post_meta['category']), array('name' => 'post_meta[comments]', 'label' => __('Comments', 'enlightenment'), 'checked' => $post_meta['comments']), array('name' => 'post_meta[edit_link]', 'label' => __('Edit Post Link', 'enlightenment'), 'checked' => $post_meta['edit_link']))));
    if (class_exists('Jetpack') && in_array('custom-content-types', Jetpack::get_active_modules())) {
        $post_meta = enlightenment_theme_option('portfolio_meta');
        add_settings_field('portfolio_meta', __('Portfolio Meta', 'enlightenment'), 'enlightenment_checkboxes', 'enlightenment_theme_options', 'entry_meta', array('boxes' => array(array('name' => 'portfolio_meta[author]', 'label' => __('Author', 'enlightenment'), 'checked' => $post_meta['author']), array('name' => 'portfolio_meta[date]', 'label' => __('Date', 'enlightenment'), 'checked' => $post_meta['date']), array('name' => 'portfolio_meta[project_type]', 'label' => __('Project Type', 'enlightenment'), 'checked' => $post_meta['project_type']), array('name' => 'portfolio_meta[comments]', 'label' => __('Comments', 'enlightenment'), 'checked' => $post_meta['comments']), array('name' => 'portfolio_meta[edit_link]', 'label' => __('Edit Project Link', 'enlightenment'), 'checked' => $post_meta['edit_link']))));
    }
    add_settings_field('enable_lightbox', __('Enable Lightbox', 'enlightenment'), 'enlightenment_checkbox', 'enlightenment_theme_options', 'lightbox', array('name' => 'enable_lightbox', 'label' => __('Open image links in a lightbox', 'enlightenment')));
    add_settings_field('lightbox_script', __('Lightbox Script', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'lightbox', array('name' => 'lightbox_script', 'options' => array('colorbox' => __('Colorbox', 'enlightenment'), 'fluidbox' => __('Fluidbox', 'enlightenment'), 'imagelightbox' => __('ImageLightbox.js', 'enlightenment'))));
    add_settings_field('posts_nav_style', __('Posts Navigation Style', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'posts_nav', array('name' => 'posts_nav_style', 'options' => array('static' => __('Static Links', 'enlightenment'), 'ajax' => 'AJAX Links', 'infinite' => 'Infinite Scroll')));
    add_settings_field('posts_nav_labels', __('Static Links Labels', 'enlightenment'), 'enlightenment_select_box', 'enlightenment_theme_options', 'posts_nav', array('name' => 'posts_nav_labels', 'options' => array('next/prev' => __('Next Page / Previous Page', 'enlightenment'), 'older/newer' => __('Older Posts / Newer Posts', 'enlightenment'), 'earlier/later' => __('Earlier Posts / Later Posts', 'enlightenment'), 'numbered' => __('Numbered Pagination', 'enlightenment'))));
    add_settings_field('copyright_notice', __('Copyright Notice', 'enlightenment'), 'enlightenment_text_input', 'enlightenment_theme_options', 'footer', array('name' => 'copyright_notice', 'description' => __('%year% = Current Year, %sitename% = Website Name', 'enlightenment')));
    add_settings_field('credit_links', __('Credit Links', 'enlightenment'), 'enlightenment_checkboxes', 'enlightenment_theme_options', 'footer', array('boxes' => array(array('name' => 'theme_credit_link', 'label' => 'Theme Credit Link'), array('name' => 'author_credit_link', 'label' => 'Theme Author Credit Link'), array('name' => 'wordpress_credit_link', 'label' => 'WordPress Credit Link'))));
}
 /**
  * Synchronize connected user role changes
  */
 static function user_role_change($user_id)
 {
     if (Jetpack::is_active() && Jetpack::is_user_connected($user_id)) {
         $current_user_id = get_current_user_id();
         wp_set_current_user($user_id);
         $role = Jetpack::translate_current_user_to_role();
         $signed_role = Jetpack::sign_role($role);
         wp_set_current_user($current_user_id);
         $master_token = Jetpack_Data::get_access_token(JETPACK_MASTER_USER);
         $master_user_id = absint($master_token->external_user_id);
         if (!$master_user_id) {
             return;
         }
         // this shouldn't happen
         Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role);
         //@todo retry on failure
         //try to choose a new master if we're demoting the current one
         if ($user_id == $master_user_id && 'administrator' != $role) {
             $query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id)));
             $new_master = false;
             foreach ($query->results as $result) {
                 $uid = absint($result->id);
                 if ($uid && Jetpack::is_user_connected($uid)) {
                     $new_master = $uid;
                     break;
                 }
             }
             if ($new_master) {
                 Jetpack_Options::update_option('master_user', $new_master);
             }
             // else disconnect..?
         }
     }
 }
function sandwich_myshortcode()
{
    // No need to register our shortcode since it already exists
    // Check if Shortcake exists
    if (!function_exists('shortcode_ui_register_for_shortcode')) {
        return;
    }
    // Only create the UI when in the admin
    if (!is_admin()) {
        return;
    }
    // Register Shortcake UI
    shortcode_ui_register_for_shortcode('myshortcode', array('label' => __('Some Existing Shortcode', 'pbsandwich'), 'listItemImage' => 'dashicons-wordpress', 'attrs' => array(array('label' => __('Content', 'pbsandwich'), 'attr' => 'content', 'type' => 'textarea'), array('label' => __('Some Text', 'pbsandwich'), 'attr' => 'some_text', 'type' => 'text'), array('label' => __('Some Color', 'pbsandwich'), 'attr' => 'some_color', 'type' => 'color', 'value' => '#333333'))));
    // TODO: If the rendered shortcode in the editor NEEDS to be previewed in a logged out state (e.g. login forms)
    // uncomment this and add in your shortcode here.
    // sandwich_add_logged_out_shortcode( 'myshortcode' );
    // Make sure Jetpack is activated
    if (!class_exists('Jetpack')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
    // Make sure our required Jetpack module is turned on
    if (!Jetpack::is_module_active('some-jetpack-module')) {
        add_action('print_media_templates', 'sandwich_jetpack_myshortcode_disabled');
        return;
    }
}
Example #12
0
 function init()
 {
     if (fastfood_is_mobile()) {
         return;
     }
     //Infinite Scroll
     if (Jetpack::is_module_active('infinite-scroll')) {
         //nop
     }
     //Sharedaddy
     if (Jetpack::is_module_active('sharedaddy')) {
         remove_filter('the_content', 'sharing_display', 19);
         remove_filter('the_excerpt', 'sharing_display', 19);
         add_action('fastfood_hook_entry_bottom', array($this, 'sharedaddy'));
     }
     //Carousel
     if (Jetpack::is_module_active('carousel')) {
         //nop
     }
     //Likes
     if (Jetpack::is_module_active('likes')) {
         add_action('fastfood_hook_entry_bottom', array($this, 'likes'));
         remove_filter('the_content', array(Jetpack_Likes::init(), 'post_likes'), 30, 1);
         add_filter('fastfood_filter_likes', array(Jetpack_Likes::init(), 'post_likes'), 30, 1);
     }
 }
 function __construct($args = array(), $path = false, $port = 80, $timeout = 15)
 {
     $defaults = array('url' => Jetpack::xmlrpc_api_url(), 'user_id' => 0);
     $args = wp_parse_args($args, $defaults);
     $this->jetpack_args = $args;
     $this->IXR_Client($args['url'], $path, $port, $timeout);
 }
 protected function result()
 {
     $args = $this->input();
     $event = isset($args['event']) && is_string($args['event']) ? $code : false;
     $num = isset($args['num']) ? intval($num) : false;
     return array('log' => Jetpack::get_log($event, $num));
 }
 protected function format_plugin($plugin_file, $plugin_data)
 {
     $plugin = array();
     $plugin['id'] = preg_replace("/(.+)\\.php\$/", "\$1", $plugin_file);
     $plugin['slug'] = Jetpack_Autoupdate::get_plugin_slug($plugin_file);
     $plugin['active'] = Jetpack::is_plugin_active($plugin_file);
     $plugin['name'] = $plugin_data['Name'];
     $plugin['plugin_url'] = $plugin_data['PluginURI'];
     $plugin['version'] = $plugin_data['Version'];
     $plugin['description'] = $plugin_data['Description'];
     $plugin['author'] = $plugin_data['Author'];
     $plugin['author_url'] = $plugin_data['AuthorURI'];
     $plugin['network'] = $plugin_data['Network'];
     $plugin['update'] = $this->get_plugin_updates($plugin_file);
     $plugin['next_autoupdate'] = date('Y-m-d H:i:s', wp_next_scheduled('wp_maybe_auto_update'));
     $autoupdate = in_array($plugin_file, Jetpack_Options::get_option('autoupdate_plugins', array()));
     $plugin['autoupdate'] = $autoupdate;
     $autoupdate_translation = in_array($plugin_file, Jetpack_Options::get_option('autoupdate_plugins_translations', array()));
     $plugin['autoupdate_translation'] = $autoupdate || $autoupdate_translation;
     $plugin['uninstallable'] = is_uninstallable_plugin($plugin_file);
     if (!empty($this->log[$plugin_file])) {
         $plugin['log'] = $this->log[$plugin_file];
     }
     return $plugin;
 }
Example #16
0
 function __construct()
 {
     global $publicize_ui;
     $this->in_jetpack = class_exists('Jetpack') && method_exists('Jetpack', 'enable_module_configurable') ? true : false;
     if ($this->in_jetpack && method_exists('Jetpack', 'module_configuration_load')) {
         Jetpack::enable_module_configurable(__FILE__);
         Jetpack::module_configuration_load(__FILE__, array($this, 'jetpack_configuration_load'));
     }
     require_once dirname(__FILE__) . '/publicize/publicize.php';
     if ($this->in_jetpack) {
         require_once dirname(__FILE__) . '/publicize/publicize-jetpack.php';
     } else {
         require_once dirname(dirname(__FILE__)) . '/mu-plugins/keyring/keyring.php';
         require_once dirname(__FILE__) . '/publicize/publicize-wpcom.php';
     }
     require_once dirname(__FILE__) . '/publicize/ui.php';
     $publicize_ui = new Publicize_UI();
     $publicize_ui->in_jetpack = $this->in_jetpack;
     // Jetpack specific checks / hooks
     if ($this->in_jetpack) {
         // if sharedaddy isn't active, the sharing menu hasn't been added yet
         $active = Jetpack::get_active_modules();
         if (in_array('publicize', $active) && !in_array('sharedaddy', $active)) {
             add_action('admin_menu', array(&$publicize_ui, 'sharing_menu'));
         }
     }
 }
/**
 * Checks if Jetpack Photon module is enabled.
 *
 * @return boolean
 */
function eduardodomingos_photon_enabled()
{
    if (class_exists('Jetpack') && Jetpack::is_module_active('photon')) {
        return true;
    }
    return false;
}
 protected function result()
 {
     Jetpack::init();
     do_action('jetpack_sync_all_registered_options');
     $result['scheduled'] = true;
     return $result;
 }
Example #19
0
 /**
  * Registers the custom post types and adds action/filter handlers, but
  * only if the site supports it
  */
 function maybe_register_cpt()
 {
     // Add an option to enable the CPT
     add_action('admin_init', array($this, 'settings_api_init'));
     // Check on theme switch if theme supports CPT and setting is disabled
     add_action('after_switch_theme', array($this, 'activation_post_type_support'));
     $setting = Jetpack_Options::get_option_and_ensure_autoload(self::OPTION_NAME, '0');
     // Bail early if Testimonial option is not set and the theme doesn't declare support
     if (empty($setting) && !$this->site_supports_custom_post_type()) {
         return;
     }
     if ((!defined('IS_WPCOM') || !IS_WPCOM) && !Jetpack::is_module_active('custom-content-types')) {
         return;
     }
     // Enable Omnisearch for CPT.
     if (class_exists('Jetpack_Omnisearch_Posts')) {
         new Jetpack_Omnisearch_Posts(self::CUSTOM_POST_TYPE);
     }
     // CPT magic
     $this->register_post_types();
     add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
     add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'flush_rules_on_enable'), 10);
     add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'flush_rules_on_first_testimonial'));
     add_action('after_switch_theme', array($this, 'flush_rules_on_switch'));
     // Admin Customization
     add_filter('enter_title_here', array($this, 'change_default_title'));
     add_filter(sprintf('manage_%s_posts_columns', self::CUSTOM_POST_TYPE), array($this, 'edit_title_column_label'));
     add_filter('post_updated_messages', array($this, 'updated_messages'));
     add_action('customize_register', array($this, 'customize_register'));
     // Only add the 'Customize' sub-menu if the theme supports it.
     $num_testimonials = self::count_testimonials();
     if (!empty($num_testimonials) && current_theme_supports(self::CUSTOM_POST_TYPE)) {
         add_action('admin_menu', array($this, 'add_customize_page'));
     }
     if (defined('IS_WPCOM') && IS_WPCOM) {
         // Track all the things
         add_action(sprintf('add_option_%s', self::OPTION_NAME), array($this, 'new_activation_stat_bump'));
         add_action(sprintf('update_option_%s', self::OPTION_NAME), array($this, 'update_option_stat_bump'), 11, 2);
         add_action(sprintf('publish_%s', self::CUSTOM_POST_TYPE), array($this, 'new_testimonial_stat_bump'));
         // Add to Dotcom XML sitemaps
         add_filter('wpcom_sitemap_post_types', array($this, 'add_to_sitemap'));
     } else {
         // Add to Jetpack XML sitemap
         add_filter('jetpack_sitemap_post_types', array($this, 'add_to_sitemap'));
     }
     // Adjust CPT archive and custom taxonomies to obey CPT reading setting
     add_filter('pre_get_posts', array($this, 'query_reading_setting'), 20);
     add_filter('infinite_scroll_settings', array($this, 'infinite_scroll_click_posts_per_page'));
     // Register [jetpack_testimonials] always and
     // register [testimonials] if [testimonials] isn't already set
     add_shortcode('jetpack_testimonials', array($this, 'jetpack_testimonial_shortcode'));
     if (!shortcode_exists('testimonials')) {
         add_shortcode('testimonials', array($this, 'jetpack_testimonial_shortcode'));
     }
     // If CPT was enabled programatically and no CPT items exist when user switches away, disable
     if ($setting && $this->site_supports_custom_post_type()) {
         add_action('switch_theme', array($this, 'deactivation_post_type_support'));
     }
 }
function vaultpress_jetpack_stub()
{
    if (class_exists('VaultPress') || function_exists('vaultpress_contact_service')) {
        Jetpack::enable_module_configurable(__FILE__);
        Jetpack::module_configuration_load(__FILE__, 'vaultpress_jetpack_configure');
        add_filter('jetpack_module_free_text_vaultpress', 'vaultpress_jetpack_module_free_text');
    }
}
Example #21
0
/**
 * Module Name: JSON API
 * Module Description: Allow applications to securely access your content through the cloud.
 * Sort Order: 100
 * First Introduced: 1.9
 * Requires Connection: Yes
 * Auto Activate: Public
 * Module Tags: Writing, Developers
 */
function jetpack_json_api_toggle()
{
    $jetpack = Jetpack::init();
    $jetpack->sync->register('noop');
    if (false !== strpos(current_filter(), 'jetpack_activate_module_')) {
        Jetpack::check_privacy(__FILE__);
    }
}
Example #22
0
/**
 * Disable Jetpack features that are not compatible with AMP.
 *
 **/
function amp_jetpack_mods()
{
    if (Jetpack::is_module_active('stats')) {
        add_action('amp_post_template_footer', 'jetpack_amp_add_stats_pixel');
    }
    amp_jetpack_disable_sharing();
    amp_jetpack_disable_related_posts();
}
 protected function result()
 {
     Jetpack::init();
     /** This action is documented in class.jetpack.php */
     do_action('jetpack_sync_all_registered_options');
     $result['scheduled'] = true;
     return $result;
 }
 function module_state_toggle()
 {
     // extra check that we are on the JP blog, just incase
     if (class_exists('Jetpack') && $this->in_jetpack) {
         $jetpack = Jetpack::init();
         $jetpack->sync->register('noop');
     }
 }
Example #25
0
/**
 * Add theme support for Infinite Scroll.
 * See: https://jetpack.me/support/infinite-scroll/
 */
function ocin_lite_jetpack_setup()
{
    add_theme_support('infinite-scroll', array('container' => 'main', 'render' => 'ocin_lite_infinite_scroll_render', 'footer' => 'page'));
    //Enable Custom CSS
    if (class_exists('Jetpack')) {
        Jetpack::activate_module('custom-css', false, false);
    }
}
Example #26
0
function jetpack_json_api_configuration_load()
{
    if (isset($_POST['action']) && $_POST['action'] == 'save_options' && wp_verify_nonce($_POST['_wpnonce'], 'json-api')) {
        Jetpack_Options::update_option('json_api_full_management', isset($_POST['json_api_full_management']));
        Jetpack::state('message', 'module_configured');
        wp_safe_redirect(Jetpack::module_configuration_url('json-api'));
        exit;
    }
}
function jetpack_enhanced_distribution_before_activate_default_modules()
{
    $old_version = Jetpack_Options::get_option('old_version');
    list($old_version) = explode(':', $old_version);
    if (version_compare($old_version, '1.9-something', '>=')) {
        return;
    }
    Jetpack::check_privacy(__FILE__);
}
 /**
  * @author scotchfield
  * @runInSeparateProcess
  * @covers Jetpack_Client_Server::authorize
  * @since 3.2
  */
 public function test_jetpack_client_server_authorize_data_error()
 {
     $author_id = $this->factory->user->create(array('role' => 'administrator'));
     wp_set_current_user($author_id);
     $client_server = $this->getMock('Jetpack_Client_Server', array('check_admin_referer', 'wp_safe_redirect', 'do_exit'));
     $data_error = 'test_error';
     $_GET['error'] = $data_error;
     $client_server->authorize();
     $this->assertEquals($data_error, Jetpack::state('error'));
 }
Example #29
0
 /**
  * This action triggers if the module is in an active state, load related posts and options.
  *
  * @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack::module_configuration_load, Jetpack_Sync::sync_posts
  * @return null
  */
 public function action_on_load()
 {
     require_once 'related-posts/jetpack-related-posts.php';
     Jetpack_RelatedPosts::init();
     if (is_admin()) {
         // Enable "Configure" button on module card
         Jetpack::enable_module_configurable(__FILE__);
         Jetpack::module_configuration_load(__FILE__, array($this, 'module_configuration_load'));
     }
 }
 public function subscription_menu($user)
 {
     if (!defined('IS_WPCOM') || !IS_WPCOM) {
         $active = Jetpack::get_active_modules();
         if (!in_array('publicize', $active) && !current_user_can('manage_options')) {
             return;
         }
     }
     add_submenu_page('options-general.php', __('Sharing Settings', 'jetpack'), __('Sharing', 'jetpack'), 'publish_posts', 'sharing', array(&$this, 'management_page'));
 }