is_syncing() static public method

static public is_syncing ( )
 /**
  * The contact-form shortcode processor
  *
  * @param array $attributes Key => Value pairs as parsed by shortcode_parse_atts()
  * @param string|null $content The shortcode's inner content: [contact-form]$content[/contact-form]
  * @return string HTML for the concat form.
  */
 static function parse($attributes, $content)
 {
     if (Jetpack_Sync_Settings::is_syncing()) {
         return '';
     }
     // Create a new Grunion_Contact_Form object (this class)
     $form = new Grunion_Contact_Form($attributes, $content);
     $id = $form->get_attribute('id');
     if (!$id) {
         // something terrible has happened
         return '[contact-form]';
     }
     if (is_feed()) {
         return '[contact-form]';
     }
     // Only allow one contact form per post/widget
     if (self::$last && $id == self::$last->get_attribute('id')) {
         // We're processing the same post
         if (self::$last->attributes != $form->attributes || self::$last->content != $form->content) {
             // And we're processing a different shortcode;
             return '';
         }
         // else, we're processing the same shortcode - probably a separate run of do_shortcode() - let it through
     } else {
         self::$last = $form;
     }
     // Enqueue the grunion.css stylesheet if self::$style allows it
     if (self::$style && (empty($_REQUEST['action']) || $_REQUEST['action'] != 'grunion_shortcode_to_json')) {
         // Enqueue the style here instead of printing it, because if some other plugin has run the_post()+rewind_posts(),
         // (like VideoPress does), the style tag gets "printed" the first time and discarded, leaving the contact form unstyled.
         // when WordPress does the real loop.
         wp_enqueue_style('grunion.css');
     }
     $r = '';
     $r .= "<div id='contact-form-{$id}'>\n";
     if (is_wp_error($form->errors) && $form->errors->get_error_codes()) {
         // There are errors.  Display them
         $r .= "<div class='form-error'>\n<h3>" . __('Error!', 'jetpack') . "</h3>\n<ul class='form-errors'>\n";
         foreach ($form->errors->get_error_messages() as $message) {
             $r .= "\t<li class='form-error-message'>" . esc_html($message) . "</li>\n";
         }
         $r .= "</ul>\n</div>\n\n";
     }
     if (isset($_GET['contact-form-id']) && $_GET['contact-form-id'] == self::$last->get_attribute('id') && isset($_GET['contact-form-sent'])) {
         // The contact form was submitted.  Show the success message/results
         $feedback_id = (int) $_GET['contact-form-sent'];
         $back_url = remove_query_arg(array('contact-form-id', 'contact-form-sent', '_wpnonce'));
         $r_success_message = "<h3>" . __('Message Sent', 'jetpack') . ' (<a href="' . esc_url($back_url) . '">' . esc_html__('go back', 'jetpack') . '</a>)' . "</h3>\n\n";
         // Don't show the feedback details unless the nonce matches
         if ($feedback_id && wp_verify_nonce(stripslashes($_GET['_wpnonce']), "contact-form-sent-{$feedback_id}")) {
             $r_success_message .= self::success_message($feedback_id, $form);
         }
         /**
          * Filter the message returned after a successfull contact form submission.
          *
          * @module contact-form
          *
          * @since 1.3.1
          *
          * @param string $r_success_message Success message.
          */
         $r .= apply_filters('grunion_contact_form_success_message', $r_success_message);
     } else {
         // Nothing special - show the normal contact form
         if ($form->get_attribute('widget')) {
             // Submit form to the current URL
             $url = remove_query_arg(array('contact-form-id', 'contact-form-sent', 'action', '_wpnonce'));
         } else {
             // Submit form to the post permalink
             $url = get_permalink();
         }
         // For SSL/TLS page. See RFC 3986 Section 4.2
         $url = set_url_scheme($url);
         // May eventually want to send this to admin-post.php...
         /**
          * Filter the contact form action URL.
          *
          * @module contact-form
          *
          * @since 1.3.1
          *
          * @param string $contact_form_id Contact form post URL.
          * @param $post $GLOBALS['post'] Post global variable.
          * @param int $id Contact Form ID.
          */
         $url = apply_filters('grunion_contact_form_form_action', "{$url}#contact-form-{$id}", $GLOBALS['post'], $id);
         $r .= "<form action='" . esc_url($url) . "' method='post' class='contact-form commentsblock'>\n";
         $r .= $form->body;
         $r .= "\t<p class='contact-submit'>\n";
         $r .= "\t\t<input type='submit' value='" . esc_attr($form->get_attribute('submit_button_text')) . "' class='pushbutton-wide'/>\n";
         if (is_user_logged_in()) {
             $r .= "\t\t" . wp_nonce_field('contact-form_' . $id, '_wpnonce', true, false) . "\n";
             // nonce and referer
         }
         $r .= "\t\t<input type='hidden' name='contact-form-id' value='{$id}' />\n";
         $r .= "\t\t<input type='hidden' name='action' value='grunion-contact-form' />\n";
         $r .= "\t</p>\n";
         $r .= "</form>\n";
     }
     $r .= "</div>";
     return $r;
 }
 /**
  * Returns the HTML for the related posts section if it's running in the loop or other instances where we don't support related posts.
  *
  * @returns string
  */
 public function get_target_html_unsupported()
 {
     if (Jetpack_Sync_Settings::is_syncing()) {
         return '';
     }
     return "\n\n<!-- Jetpack Related Posts is not supported in this context. -->\n\n";
 }
 static function set_is_syncing($is_syncing)
 {
     self::$is_syncing = $is_syncing;
 }
Example #4
0
 /**
  * Are likes visible in this context?
  *
  * Some of this code was taken and modified from sharing_display() to ensure
  * similar logic and filters apply here, too.
  */
 function is_likes_visible()
 {
     require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
     if (Jetpack_Sync_Settings::is_syncing()) {
         return false;
     }
     global $post, $wp_current_filter;
     // Used to apply 'sharing_show' filter
     // @todo: Remove this block when 4.5 is the minimum
     global $wp_version;
     $comment_popup = false;
     if (version_compare($wp_version, '4.5-alpha', '<=')) {
         $comment_popup = is_comments_popup();
     }
     // End 4.5 conditional block.
     // Never show on feeds or previews
     if (is_feed() || is_preview() || $comment_popup) {
         // @todo: Remove $comment_popup when 4.5 is minimum.
         $enabled = false;
         // Not a feed or preview, so what is it?
     } else {
         if (in_the_loop()) {
             // If in the loop, check if the current post is likeable
             $enabled = $this->is_post_likeable();
         } else {
             // Otherwise, check and see if likes are enabled sitewide
             $enabled = $this->is_enabled_sitewide();
         }
         if (post_password_required()) {
             $enabled = false;
         }
         if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
             $enabled = false;
         }
         // Sharing Setting Overrides ****************************************
         // Single post including custom post types
         if (is_single()) {
             if (!$this->is_single_post_enabled($post->post_type)) {
                 $enabled = false;
             }
             // Single page
         } elseif (is_page() && !is_front_page()) {
             if (!$this->is_single_page_enabled()) {
                 $enabled = false;
             }
             // Attachment
         } elseif (is_attachment()) {
             if (!$this->is_attachment_enabled()) {
                 $enabled = false;
             }
             // All other loops
         } elseif (!$this->is_index_enabled()) {
             $enabled = false;
         }
     }
     if (is_object($post)) {
         // Check that the post is a public, published post.
         if ('attachment' == $post->post_type) {
             $post_status = get_post_status($post->post_parent);
         } else {
             $post_status = $post->post_status;
         }
         if ('publish' != $post_status) {
             $enabled = false;
         }
     }
     // Run through the sharing filters
     /** This filter is documented in modules/sharedaddy/sharing-service.php */
     $enabled = apply_filters('sharing_show', $enabled, $post);
     /**
      * Filters whether the Likes should be visible or not.
      * Allows overwriting the options set in Settings > Sharing.
      *
      * @module likes
      *
      * @since 2.2.0
      *
      * @param bool $enabled Should the Likes be visible?
      */
     return (bool) apply_filters('wpl_is_likes_visible', $enabled);
 }
Example #5
0
function sharing_display($text = '', $echo = false)
{
    global $post, $wp_current_filter;
    require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
    if (Jetpack_Sync_Settings::is_syncing()) {
        return $text;
    }
    if (empty($post)) {
        return $text;
    }
    if ((is_preview() || is_admin()) && !(defined('DOING_AJAX') && DOING_AJAX)) {
        return $text;
    }
    // Don't output flair on excerpts
    if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
        return $text;
    }
    // Don't allow flair to be added to the_content more than once (prevent infinite loops)
    $done = false;
    foreach ($wp_current_filter as $filter) {
        if ('the_content' == $filter) {
            if ($done) {
                return $text;
            } else {
                $done = true;
            }
        }
    }
    // check whether we are viewing the front page and whether the front page option is checked
    $options = get_option('sharing-options');
    $display_options = $options['global']['show'];
    if (is_front_page() && (is_array($display_options) && !in_array('index', $display_options))) {
        return $text;
    }
    if (is_attachment() && in_array('the_excerpt', (array) $wp_current_filter)) {
        // Many themes run the_excerpt() conditionally on an attachment page, then run the_content().
        // We only want to output the sharing buttons once.  Let's stick with the_content().
        return $text;
    }
    $sharer = new Sharing_Service();
    $global = $sharer->get_global_options();
    $show = false;
    if (!is_feed()) {
        if (is_singular() && in_array(get_post_type(), $global['show'])) {
            $show = true;
        } elseif (in_array('index', $global['show']) && (is_home() || is_front_page() || is_archive() || is_search() || in_array(get_post_type(), $global['show']))) {
            $show = true;
        }
    }
    /**
     * Filter to decide if sharing buttons should be displayed.
     *
     * @module sharedaddy
     *
     * @since 1.1.0
     *
     * @param bool $show Should the sharing buttons be displayed.
     * @param WP_Post $post The post to share.
     */
    $show = apply_filters('sharing_show', $show, $post);
    // Disabled for this post?
    $switched_status = get_post_meta($post->ID, 'sharing_disabled', false);
    if (!empty($switched_status)) {
        $show = false;
    }
    // Private post?
    $post_status = get_post_status($post->ID);
    if ('private' === $post_status) {
        $show = false;
    }
    // Allow to be used on P2 ajax requests for latest posts.
    if (defined('DOING_AJAX') && DOING_AJAX && isset($_REQUEST['action']) && 'get_latest_posts' == $_REQUEST['action']) {
        $show = true;
    }
    $sharing_content = '';
    if ($show) {
        /**
         * Filters the list of enabled Sharing Services.
         *
         * @module sharedaddy
         *
         * @since 2.2.3
         *
         * @param array $sharer->get_blog_services() Array of Sharing Services currently enabled.
         */
        $enabled = apply_filters('sharing_enabled', $sharer->get_blog_services());
        if (count($enabled['all']) > 0) {
            global $post;
            $dir = get_option('text_direction');
            // Wrapper
            $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
            if ($global['sharing_label'] != '') {
                $sharing_content .= sprintf(apply_filters('jetpack_sharing_headline_html', '<h3 class="sd-title">%s</h3>', $global['sharing_label'], 'sharing'), esc_html($global['sharing_label']));
            }
            $sharing_content .= '<div class="sd-content"><ul>';
            // Visible items
            $visible = '';
            foreach ($enabled['visible'] as $id => $service) {
                // Individual HTML for sharing service
                $visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display($post) . '</li>';
            }
            $parts = array();
            $parts[] = $visible;
            if (count($enabled['hidden']) > 0) {
                if (count($enabled['visible']) > 0) {
                    $expand = __('More', 'jetpack');
                } else {
                    $expand = __('Share', 'jetpack');
                }
                $parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>' . $expand . '</span></a></li>';
            }
            if ($dir == 'rtl') {
                $parts = array_reverse($parts);
            }
            $sharing_content .= implode('', $parts);
            $sharing_content .= '<li class="share-end"></li></ul>';
            if (count($enabled['hidden']) > 0) {
                $sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
                if (count($enabled['hidden']) == 1) {
                    $sharing_content .= 'width:150px;';
                }
                $sharing_content .= '">';
                if (count($enabled['hidden']) == 1) {
                    $sharing_content .= '<ul style="background-image:none;">';
                } else {
                    $sharing_content .= '<ul>';
                }
                $count = 1;
                foreach ($enabled['hidden'] as $id => $service) {
                    // Individual HTML for sharing service
                    $sharing_content .= '<li class="share-' . $service->get_class() . '">';
                    $sharing_content .= $service->get_display($post);
                    $sharing_content .= '</li>';
                    if ($count % 2 == 0) {
                        $sharing_content .= '<li class="share-end"></li>';
                    }
                    $count++;
                }
                // End of wrapper
                $sharing_content .= '<li class="share-end"></li></ul></div></div>';
            }
            $sharing_content .= '</div></div></div>';
            // Register our JS
            if (defined('JETPACK__VERSION')) {
                $ver = JETPACK__VERSION;
            } else {
                $ver = '20141212';
            }
            wp_register_script('sharing-js', plugin_dir_url(__FILE__) . 'sharing.js', array('jquery'), $ver);
            add_action('wp_footer', 'sharing_add_footer');
        }
    }
    /**
     * Filters the content markup of the Jetpack sharing links
     *
     * @module sharedaddy
     *
     * @since 3.8.0
     *
     * @param string $sharing_content Content markup of the Jetpack sharing links
     */
    $sharing_markup = apply_filters('jetpack_sharing_display_markup', $sharing_content);
    if ($echo) {
        echo $text . $sharing_markup;
    } else {
        return $text . $sharing_markup;
    }
}
 /**
  * Returns the HTML for the related posts section if it's running in the loop or other instances where we don't support related posts.
  *
  * @returns string
  */
 public function get_target_html_unsupported()
 {
     require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php';
     if (Jetpack_Sync_Settings::is_syncing()) {
         return '';
     }
     return "\n\n<!-- Jetpack Related Posts is not supported in this context. -->\n\n";
 }