Jetpack_Sync_Settings::is_syncing PHP Method

is_syncing() static public method

static public is_syncing ( )
    static function is_syncing()
    {
        return (bool) self::$is_syncing;
    }

Usage Example

コード例 #1
0
 /**
  * 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;
 }
All Usage Examples Of Jetpack_Sync_Settings::is_syncing