From a6b006c0f1ef757f23375f7906193370337d8bd7 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Fri, 8 Jun 2018 10:09:24 -0400 Subject: Update jetpack 6.2 --- .../jetpack/modules/carousel/jetpack-carousel.js | 4 + .../jetpack/modules/carousel/jetpack-carousel.php | 4 + plugins/jetpack/modules/comment-likes.php | 4 + plugins/jetpack/modules/contact-form/admin.php | 4 +- .../modules/contact-form/grunion-contact-form.php | 214 +++++++++++++++++++ .../jetpack/modules/contact-form/js/editor-view.js | 5 + .../modules/custom-css/csstidy/class.csstidy.php | 5 + .../custom-css/csstidy/class.csstidy_optimise.php | 21 +- .../custom-css/csstidy/class.csstidy_print.php | 4 + plugins/jetpack/modules/custom-css/custom-css.php | 2 +- .../jetpack/modules/custom-post-types/comics.php | 4 - plugins/jetpack/modules/custom-post-types/nova.php | 4 - .../modules/custom-post-types/portfolios.php | 77 ++++++- .../modules/custom-post-types/testimonial.php | 5 - plugins/jetpack/modules/google-analytics.php | 2 +- .../classes/wp-google-analytics-universal.php | 20 +- plugins/jetpack/modules/gravatar-hovercards.php | 4 +- .../jetpack/modules/infinite-scroll/infinity.js | 17 +- .../jetpack/modules/infinite-scroll/infinity.php | 71 ++++--- plugins/jetpack/modules/lazy-images.php | 2 +- .../jetpack/modules/lazy-images/js/lazy-images.js | 42 ++-- .../jetpack/modules/lazy-images/lazy-images.php | 3 + plugins/jetpack/modules/likes.php | 33 +-- .../modules/likes/jetpack-likes-master-iframe.php | 2 +- .../modules/likes/jetpack-likes-settings.php | 15 ++ plugins/jetpack/modules/markdown/easy-markdown.php | 50 +++++ plugins/jetpack/modules/masterbar/masterbar.php | 22 +- plugins/jetpack/modules/monitor.php | 2 +- plugins/jetpack/modules/protect.php | 2 +- plugins/jetpack/modules/publicize.php | 233 --------------------- .../modules/publicize/assets/publicize-rtl.css | 1 - .../modules/publicize/assets/publicize-rtl.min.css | 2 +- .../jetpack/modules/publicize/assets/publicize.css | 1 - .../modules/publicize/assets/publicize.min.css | 2 +- .../modules/publicize/assets/rtl/publicize-rtl.css | 3 +- .../modules/publicize/enhanced-open-graph.php | 4 +- .../modules/publicize/publicize-jetpack.php | 25 +++ plugins/jetpack/modules/publicize/publicize.php | 148 +++++++++++-- plugins/jetpack/modules/publicize/ui.php | 4 +- .../class.related-posts-customize.php | 4 +- .../related-posts/jetpack-related-posts.php | 12 +- .../modules/search/class.jetpack-search.php | 15 +- .../modules/seo-tools/jetpack-seo-titles.php | 2 +- plugins/jetpack/modules/sharedaddy/recaptcha.php | 9 + .../jetpack/modules/sharedaddy/sharing-service.php | 31 ++- .../jetpack/modules/sharedaddy/sharing-sources.php | 93 ++++---- plugins/jetpack/modules/sharedaddy/sharing.js | 12 +- plugins/jetpack/modules/sharedaddy/sharing.php | 24 ++- .../class.filter-embedded-html-objects.php | 2 +- .../modules/shortcodes/css/blocks/vr-block.css | 16 ++ plugins/jetpack/modules/shortcodes/facebook.php | 5 +- .../modules/shortcodes/js/blocks/vr-block.js | 102 +++++++++ plugins/jetpack/modules/shortcodes/mixcloud.php | 56 +++-- plugins/jetpack/modules/shortcodes/polldaddy.php | 13 +- plugins/jetpack/modules/shortcodes/vr.php | 27 ++- plugins/jetpack/modules/shortcodes/wordads.php | 67 ++++++ .../jetpack/modules/sitemaps/sitemap-builder.php | 78 ++++++- .../jetpack/modules/sitemaps/sitemap-librarian.php | 6 +- plugins/jetpack/modules/sitemaps/sitemaps.php | 3 +- plugins/jetpack/modules/sso.php | 28 ++- .../modules/sso/class.jetpack-sso-helpers.php | 3 +- plugins/jetpack/modules/stats.php | 135 ++++++++++-- plugins/jetpack/modules/subscriptions.php | 21 +- .../theme-tools/compat/twentysixteen-rtl.css | 66 ++++++ .../modules/theme-tools/compat/twentysixteen.css | 66 ++++++ .../modules/theme-tools/compat/twentysixteen.php | 16 ++ .../theme-tools/content-options/blog-display.php | 10 +- .../content-options/featured-images.php | 25 +++ .../modules/theme-tools/featured-content.php | 27 ++- .../modules/theme-tools/responsive-videos.php | 11 +- .../tiled-gallery/tiled-gallery-item.php | 18 +- .../widget-conditions/widget-conditions-rtl.css | 1 + .../widget-conditions-rtl.min.css | 2 +- .../widget-conditions/widget-conditions.css | 1 + .../widget-conditions/widget-conditions.min.css | 2 +- .../jetpack/modules/widgets/customizer-utils.js | 11 +- plugins/jetpack/modules/widgets/eu-cookie-law.php | 90 ++++++-- .../widgets/eu-cookie-law/eu-cookie-law-admin.js | 30 +++ .../modules/widgets/eu-cookie-law/eu-cookie-law.js | 16 +- .../jetpack/modules/widgets/eu-cookie-law/form.php | 226 +++++++++++++------- .../modules/widgets/eu-cookie-law/style.css | 19 +- .../modules/widgets/eu-cookie-law/widget.php | 12 +- .../jetpack/modules/widgets/google-translate.php | 23 +- .../jetpack/modules/widgets/gravatar-profile.php | 10 +- plugins/jetpack/modules/widgets/social-icons.php | 10 +- .../modules/widgets/social-icons/social-icons.css | 18 ++ plugins/jetpack/modules/widgets/top-posts.php | 7 +- .../jetpack/modules/widgets/twitter-timeline.php | 72 +++---- .../classes/wp-woocommerce-analytics-universal.php | 14 +- .../wp-woocommerce-analytics.php | 2 +- plugins/jetpack/modules/wordads/php/api.php | 18 ++ plugins/jetpack/modules/wordads/php/params.php | 16 +- plugins/jetpack/modules/wordads/php/widgets.php | 3 +- plugins/jetpack/modules/wordads/wordads.php | 170 +++++++++------ 94 files changed, 2051 insertions(+), 792 deletions(-) create mode 100644 plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css create mode 100644 plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js create mode 100644 plugins/jetpack/modules/shortcodes/wordads.php create mode 100644 plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js (limited to 'plugins/jetpack/modules') diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.js b/plugins/jetpack/modules/carousel/jetpack-carousel.js index dbb83150..f07ec826 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.js +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.js @@ -597,6 +597,8 @@ jQuery(document).ready(function($) { } }, + + selectedSlide : function(){ return this.find('.selected'); }, @@ -746,6 +748,7 @@ jQuery(document).ready(function($) { '&rand=' + Math.random(); } + // Load the images for the next and previous slides. $( next ).add( previous ).each( function() { gallery.jp_carousel( 'loadFullImage', $( this ) ); @@ -1059,6 +1062,7 @@ jQuery(document).ready(function($) { return size_parts; }, + originalDimensions: function() { var splitted = $(this).data('orig-size').split(','); return {width: parseInt(splitted[0], 10), height: parseInt(splitted[1], 10)}; diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.php b/plugins/jetpack/modules/carousel/jetpack-carousel.php index 6b76fb0e..1fb4394b 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -398,6 +398,10 @@ class Jetpack_Carousel { function add_data_to_images( $attr, $attachment = null ) { $attachment_id = intval( $attachment->ID ); + if ( ! wp_attachment_is_image( $attachment_id ) ) { + return $attr; + } + $orig_file = wp_get_attachment_image_src( $attachment_id, 'full' ); $orig_file = isset( $orig_file[0] ) ? $orig_file[0] : wp_get_attachment_url( $attachment_id ); $meta = wp_get_attachment_metadata( $attachment_id ); diff --git a/plugins/jetpack/modules/comment-likes.php b/plugins/jetpack/modules/comment-likes.php index 00c5a0bf..18aae8b4 100644 --- a/plugins/jetpack/modules/comment-likes.php +++ b/plugins/jetpack/modules/comment-likes.php @@ -125,6 +125,10 @@ class Jetpack_Comment_Likes { return; } + if ( Jetpack_AMP_Support::is_amp_request() ) { + return; + } + add_action( 'wp_enqueue_scripts', array( $this, 'load_styles_register_scripts' ) ); add_filter( 'comment_text', array( $this, 'comment_likes' ), 10, 2 ); } diff --git a/plugins/jetpack/modules/contact-form/admin.php b/plugins/jetpack/modules/contact-form/admin.php index e09730a3..90acdde4 100644 --- a/plugins/jetpack/modules/contact-form/admin.php +++ b/plugins/jetpack/modules/contact-form/admin.php @@ -244,7 +244,7 @@ add_filter( 'views_edit-feedback', 'grunion_admin_view_tabs' ); function grunion_admin_view_tabs( $views ) { global $current_screen; if ( 'edit-feedback' != $current_screen->id ) - return $actions; + return $views; unset( $views['publish'] ); @@ -873,7 +873,7 @@ function grunion_recheck_queue() { if ( $is_spam ) { wp_update_post( array( 'ID' => $feedback->ID, 'post_status' => 'spam' ) ); /** This action is already documented in modules/contact-form/admin.php */ - do_action( 'contact_form_akismet', 'spam', $akismet_values ); + do_action( 'contact_form_akismet', 'spam', $meta ); } } diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php index 7bb7c47a..97676b58 100644 --- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php +++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php @@ -59,9 +59,30 @@ class Grunion_Contact_Form_Plugin { return; } + /** + * Fires right before deleting the _feedback_akismet_values post meta on $feedback_ids + * + * @module contact-form + * + * @since 6.1.0 + * + * @param array $feedback_ids list of feedback post ID + */ + do_action( 'jetpack_daily_akismet_meta_cleanup_before', $feedback_ids ); foreach ( $feedback_ids as $feedback_id ) { delete_post_meta( $feedback_id, '_feedback_akismet_values' ); } + + /** + * Fires right after deleting the _feedback_akismet_values post meta on $feedback_ids + * + * @module contact-form + * + * @since 6.1.0 + * + * @param array $feedback_ids list of feedback post ID + */ + do_action( 'jetpack_daily_akismet_meta_cleanup_after', $feedback_ids ); } /** @@ -115,6 +136,10 @@ class Grunion_Contact_Form_Plugin { add_action( 'wp_ajax_grunion-contact-form', array( $this, 'ajax_request' ) ); add_action( 'wp_ajax_nopriv_grunion-contact-form', array( $this, 'ajax_request' ) ); + // GDPR: personal data exporter & eraser. + add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_personal_data_exporter' ) ); + add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_personal_data_eraser' ) ); + // Export to CSV feature if ( is_admin() ) { add_action( 'admin_init', array( $this, 'download_feedback_as_csv' ) ); @@ -714,6 +739,195 @@ class Grunion_Contact_Form_Plugin { return $mapped_fields; } + /** + * Registers the personal data exporter. + * + * @since 6.1.1 + * + * @param array $exporters An array of personal data exporters. + * + * @return array $exporters An array of personal data exporters. + */ + public function register_personal_data_exporter( $exporters ) { + $exporters[] = array( + 'exporter_friendly_name' => __( 'Feedback', 'jetpack' ), + 'callback' => array( $this, 'personal_data_exporter' ), + ); + + return $exporters; + } + + /** + * Registers the personal data eraser. + * + * @since 6.1.1 + * + * @param array $erasers An array of personal data erasers. + * + * @return array $erasers An array of personal data erasers. + */ + public function register_personal_data_eraser( $erasers ) { + $erasers[] = array( + 'eraser_friendly_name' => __( 'Feedback', 'jetpack' ), + 'callback' => array( $this, 'personal_data_eraser' ), + ); + + return $erasers; + } + + /** + * Exports personal data. + * + * @since 6.1.1 + * + * @param string $email Email address. + * @param int $page Page to export. + * + * @return array $return Associative array with keys expected by core. + */ + public function personal_data_exporter( $email, $page = 1 ) { + $per_page = 250; + $export_data = array(); + $post_ids = $this->personal_data_post_ids_by_email( $email, $per_page, $page ); + + foreach ( $post_ids as $post_id ) { + $post_fields = $this->get_parsed_field_contents_of_post( $post_id ); + + if ( ! is_array( $post_fields ) || empty( $post_fields['_feedback_subject'] ) ) { + continue; // Corrupt data. + } + + $post_fields['_feedback_main_comment'] = $this->get_post_content_for_csv_export( $post_id ); + $post_fields = $this->map_parsed_field_contents_of_post_to_field_names( $post_fields ); + + if ( ! is_array( $post_fields ) || empty( $post_fields ) ) { + continue; // No fields to export. + } + + $post_meta = $this->get_post_meta_for_csv_export( $post_id ); + $post_meta = is_array( $post_meta ) ? $post_meta : array(); + + $post_export_data = array(); + $post_data = array_merge( $post_fields, $post_meta ); + ksort( $post_data ); + + foreach ( $post_data as $post_data_key => $post_data_value ) { + $post_export_data[] = array( + 'name' => preg_replace( '/^[0-9]+_/', '', $post_data_key ), + 'value' => $post_data_value, + ); + } + + $export_data[] = array( + 'group_id' => 'feedback', + 'group_label' => __( 'Feedback', 'jetpack' ), + 'item_id' => 'feedback-' . $post_id, + 'data' => $post_export_data, + ); + } + + return array( + 'data' => $export_data, + 'done' => count( $post_ids ) < $per_page, + ); + } + + /** + * Erases personal data. + * + * @since 6.1.1 + * + * @param string $email Email address. + * @param int $page Page to erase. + * + * @return array Associative array with keys expected by core. + */ + public function personal_data_eraser( $email, $page = 1 ) { + $per_page = 250; + $removed = 0; + $retained = 0; + $messages = array(); + $post_ids = $this->personal_data_post_ids_by_email( $email, $per_page, $page ); + + foreach ( $post_ids as $post_id ) { + if ( wp_delete_post( $post_id, true ) ) { + $removed++; + } else { + $retained++; + $messages[] = sprintf( + // translators: %d: Post ID. + __( 'Feedback ID %d could not be removed at this time.', 'jetpack' ), + $post_id + ); + } + } + + return array( + 'items_removed' => $removed, + 'items_retained' => $retained, + 'messages' => $messages, + 'done' => count( $post_ids ) < $per_page, + ); + } + + /** + * Queries personal data by email address. + * + * @since 6.1.1 + * + * @param string $email Email address. + * @param int $per_page Post IDs per page. Default is `250`. + * @param int $page Page to query. Default is `1`. + * + * @return array An array of post IDs. + */ + public function personal_data_post_ids_by_email( $email, $per_page = 250, $page = 1 ) { + add_filter( 'posts_search', array( $this, 'personal_data_search_filter' ) ); + + $post_ids = get_posts( array( + 'post_type' => 'feedback', + 'post_status' => 'publish', + 's' => 'AUTHOR EMAIL: ' . $email, + 'sentence' => true, + 'order' => 'ASC', + 'fields' => 'ids', + 'posts_per_page' => $per_page, + 'paged' => $page, + 'suppress_filters' => false, + ) ); + + remove_filter( 'posts_search', array( $this, 'personal_data_search_filter' ) ); + + return $post_ids; + } + + /** + * Filters searches by email address. + * + * @since 6.1.1 + * + * @param string $search SQL where clause. + * + * @return array Filtered SQL where clause. + */ + public function personal_data_search_filter( $search ) { + global $wpdb; + + /* + * Limits search to `post_content` only, and we only match the + * author's email address whenever it's on a line by itself. + * `CHAR(13)` = `\r`, `CHAR(10)` = `\n` + */ + if ( preg_match( '/AUTHOR EMAIL\: ([^{\s]+)/', $search, $m ) ) { + $esc_like_email = esc_sql( $wpdb->esc_like( 'AUTHOR EMAIL: ' . $m[1] ) ); + $search = " AND ( + {$wpdb->posts}.post_content LIKE CONCAT('%', CHAR(13), '{$esc_like_email}', CHAR(13), '%') + OR {$wpdb->posts}.post_content LIKE CONCAT('%', CHAR(10), '{$esc_like_email}', CHAR(10), '%') + )"; + } + + return $search; + } /** * Prepares feedback post data for CSV export. diff --git a/plugins/jetpack/modules/contact-form/js/editor-view.js b/plugins/jetpack/modules/contact-form/js/editor-view.js index 7cc0674c..951a0d88 100644 --- a/plugins/jetpack/modules/contact-form/js/editor-view.js +++ b/plugins/jetpack/modules/contact-form/js/editor-view.js @@ -115,6 +115,11 @@ $editframe.trigger( 'checkheight' ); }, 250 ); + // Add a second timeout for super long forms racing, and to not slow it down for shorter forms unnecessarily. + setTimeout( function(){ + $editframe.trigger( 'checkheight' ); + }, 500 ); + var $editfields = $editframe.contents().find( '.grunion-fields' ), $buttons = $editframe.contents().find( '.grunion-controls' ); diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php index b9e933aa..a502fac5 100644 --- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php +++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php @@ -241,6 +241,7 @@ class csstidy { * @var string */ public $tokens_list = ""; + /** * Loads standard template and sets default settings * @access private @@ -285,6 +286,10 @@ class csstidy { $this->tokens_list = & $GLOBALS['csstidy']['tokens']; } + function csstidy() { + $this->__construct(); + } + /** * Get the value of a setting. * @param string $setting diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php index b2e8eb96..176e0fd3 100644 --- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php +++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php @@ -40,7 +40,6 @@ * @version 1.0 */ class csstidy_optimise { - /** * Constructor * @param array $css contains the class csstidy @@ -57,6 +56,10 @@ class csstidy_optimise { $this->value = & $css->value; } + function csstidy_optimise(&$css) { + $this->__construct($css); + } + /** * Optimises $css after parsing * @access public @@ -214,7 +217,7 @@ class csstidy_optimise { * @return string * @version 1.0 */ - function shorthand($value) { + static function shorthand($value) { $important = ''; if (csstidy::is_important($value)) { $values = csstidy::gvw_important($value); @@ -500,7 +503,7 @@ class csstidy_optimise { * @version 1.0 * @see merge_4value_shorthands() */ - function dissolve_4value_shorthands($property, $value) { + static function dissolve_4value_shorthands($property, $value) { $shorthands = & $GLOBALS['csstidy']['shorthands']; if (!is_array($shorthands[$property])) { $return[$property] = $value; @@ -545,7 +548,7 @@ class csstidy_optimise { * @return array * @version 1.0 */ - function explode_ws($sep, $string) { + static function explode_ws($sep, $string) { $status = 'st'; $to = ''; @@ -588,7 +591,7 @@ class csstidy_optimise { * @version 1.2 * @see dissolve_4value_shorthands() */ - function merge_4value_shorthands($array) { + static function merge_4value_shorthands($array) { $return = $array; $shorthands = & $GLOBALS['csstidy']['shorthands']; @@ -622,7 +625,7 @@ class csstidy_optimise { * @see merge_bg() * @todo full CSS 3 compliance */ - function dissolve_short_bg($str_value) { + static function dissolve_short_bg($str_value) { // don't try to explose background gradient ! if (stripos($str_value, "gradient(")!==FALSE) return array('background'=>$str_value); @@ -700,7 +703,7 @@ class csstidy_optimise { * @see dissolve_short_bg() * @todo full CSS 3 compliance */ - function merge_bg($input_css) { + static function merge_bg($input_css) { $background_prop_default = & $GLOBALS['csstidy']['background_prop_default']; // Max number of background images. CSS3 not yet fully implemented $number_of_values = @max(count(csstidy_optimise::explode_ws(',', $input_css['background-image'])), count(csstidy_optimise::explode_ws(',', $input_css['background-color'])), 1); @@ -780,7 +783,7 @@ class csstidy_optimise { * @version 1.3 * @see merge_font() */ - function dissolve_short_font($str_value) { + static function dissolve_short_font($str_value) { $font_prop_default = & $GLOBALS['csstidy']['font_prop_default']; $font_weight = array('normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900); $font_variant = array('normal', 'small-caps'); @@ -867,7 +870,7 @@ class csstidy_optimise { * @version 1.3 * @see dissolve_short_font() */ - function merge_font($input_css) { + static function merge_font($input_css) { $font_prop_default = & $GLOBALS['csstidy']['font_prop_default']; $new_font_value = ''; $important = ''; diff --git a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php index 21f438cb..c720d398 100644 --- a/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php +++ b/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php @@ -76,6 +76,10 @@ class csstidy_print { $this->namespace = & $css->namespace; } + function csstidy_print(&$css) { + $this->__construct($css); + } + /** * Resets output_css and output_css_plain (new css code) * @access private diff --git a/plugins/jetpack/modules/custom-css/custom-css.php b/plugins/jetpack/modules/custom-css/custom-css.php index 77570e9b..3e29a410 100644 --- a/plugins/jetpack/modules/custom-css/custom-css.php +++ b/plugins/jetpack/modules/custom-css/custom-css.php @@ -1751,7 +1751,7 @@ function safecss_post_title( $title, $post_id ) { function safe_css_enqueue_scripts() { _deprecated_function( __FUNCTION__, '2.1', 'Jetpack_Custom_CSS::enqueue_scripts()' ); - return Jetpack_Custom_CSS::enqueue_scripts(); + return Jetpack_Custom_CSS::enqueue_scripts( null ); } function safecss_admin_head() { diff --git a/plugins/jetpack/modules/custom-post-types/comics.php b/plugins/jetpack/modules/custom-post-types/comics.php index 6ff4fbad..381e9b15 100644 --- a/plugins/jetpack/modules/custom-post-types/comics.php +++ b/plugins/jetpack/modules/custom-post-types/comics.php @@ -47,10 +47,6 @@ class Jetpack_Comic { // post type needs to be registered no matter what, but none of the UI needs to be // available. - // Enable Omnisearch for Comic posts. - if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) - new Jetpack_Omnisearch_Posts( self::POST_TYPE ); - add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); if ( function_exists( 'queue_publish_post' ) ) { diff --git a/plugins/jetpack/modules/custom-post-types/nova.php b/plugins/jetpack/modules/custom-post-types/nova.php index 8024825c..37404974 100644 --- a/plugins/jetpack/modules/custom-post-types/nova.php +++ b/plugins/jetpack/modules/custom-post-types/nova.php @@ -71,10 +71,6 @@ class Nova_Restaurant { add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_nova_styles' ) ); add_action( 'admin_head', array( $this, 'set_custom_font_icon' ) ); - // Enable Omnisearch for Menu Items. - if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) - new Jetpack_Omnisearch_Posts( self::MENU_ITEM_POST_TYPE ); - // Always sort menu items correctly add_action( 'parse_query', array( $this, 'sort_menu_item_queries_by_menu_order' ) ); add_filter( 'posts_results', array( $this, 'sort_menu_item_queries_by_menu_taxonomy' ), 10, 2 ); diff --git a/plugins/jetpack/modules/custom-post-types/portfolios.php b/plugins/jetpack/modules/custom-post-types/portfolios.php index 416aea81..43d9d455 100644 --- a/plugins/jetpack/modules/custom-post-types/portfolios.php +++ b/plugins/jetpack/modules/custom-post-types/portfolios.php @@ -45,10 +45,6 @@ class Jetpack_Portfolio { return; } - // Enable Omnisearch for Portfolio Items. - 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 ); @@ -62,6 +58,14 @@ class Jetpack_Portfolio { add_filter( sprintf( 'manage_%s_posts_custom_column', self::CUSTOM_POST_TYPE), array( $this, 'image_column' ), 10, 2 ); add_action( 'customize_register', array( $this, 'customize_register' ) ); + 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_project_stat_bump' ) ); + } + add_image_size( 'jetpack-portfolio-admin-thumb', 50, 50, true ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); @@ -69,6 +73,10 @@ class Jetpack_Portfolio { add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) ); add_shortcode( 'jetpack_portfolio', array( $this, 'portfolio_shortcode' ) ); + // Adjust CPT archive and custom taxonomies to obey CPT reading setting + add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) ); + add_filter( 'infinite_scroll_results', array( $this, 'infinite_scroll_results' ), 10, 3 ); + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { // Add to Dotcom XML sitemaps add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) ); @@ -146,6 +154,33 @@ class Jetpack_Portfolio { endif; } + /* + * Bump Portfolio > New Activation stat + */ + function new_activation_stat_bump() { + bump_stats_extras( 'portfolios', 'new-activation' ); + } + + /* + * Bump Portfolio > Option On/Off stats to get total active + */ + function update_option_stat_bump( $old, $new ) { + if ( empty( $old ) && ! empty( $new ) ) { + bump_stats_extras( 'portfolios', 'option-on' ); + } + + if ( ! empty( $old ) && empty( $new ) ) { + bump_stats_extras( 'portfolios', 'option-off' ); + } + } + + /* + * Bump Portfolio > Published Projects stat when projects are published + */ + function new_project_stat_bump() { + bump_stats_extras( 'portfolios', 'published-projects' ); + } + /** * Should this Custom Post Type be made available? */ @@ -461,14 +496,42 @@ class Jetpack_Portfolio { * Follow CPT reading setting on CPT archive and taxonomy pages */ function query_reading_setting( $query ) { - if ( ! is_admin() && - $query->is_main_query() && - ( $query->is_post_type_archive( self::CUSTOM_POST_TYPE ) || $query->is_tax( self::CUSTOM_TAXONOMY_TYPE ) || $query->is_tax( self::CUSTOM_TAXONOMY_TAG ) ) + if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) + && $query->is_main_query() + && ( $query->is_post_type_archive( self::CUSTOM_POST_TYPE ) + || $query->is_tax( self::CUSTOM_TAXONOMY_TYPE ) + || $query->is_tax( self::CUSTOM_TAXONOMY_TAG ) ) ) { $query->set( 'posts_per_page', get_option( self::OPTION_READING_SETTING, '10' ) ); } } + /* + * If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`. + */ + function infinite_scroll_click_posts_per_page( $settings ) { + global $wp_query; + + if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) + && true === $settings['click_handle'] + && ( $wp_query->is_post_type_archive( self::CUSTOM_POST_TYPE ) + || $wp_query->is_tax( self::CUSTOM_TAXONOMY_TYPE ) + || $wp_query->is_tax( self::CUSTOM_TAXONOMY_TAG ) ) + ) { + $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] ); + } + + return $settings; + } + + /* + * Filter the results of infinite scroll to make sure we get `lastbatch` right. + */ + function infinite_scroll_results( $results, $query_args, $query ) { + $results['lastbatch'] = $query_args['paged'] >= $query->max_num_pages; + return $results; + } + /** * Add CPT to Dotcom sitemap */ diff --git a/plugins/jetpack/modules/custom-post-types/testimonial.php b/plugins/jetpack/modules/custom-post-types/testimonial.php index 6a7426cc..3199d5a6 100644 --- a/plugins/jetpack/modules/custom-post-types/testimonial.php +++ b/plugins/jetpack/modules/custom-post-types/testimonial.php @@ -58,11 +58,6 @@ class Jetpack_Testimonial { 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 ); diff --git a/plugins/jetpack/modules/google-analytics.php b/plugins/jetpack/modules/google-analytics.php index 1f077ab4..21a42921 100644 --- a/plugins/jetpack/modules/google-analytics.php +++ b/plugins/jetpack/modules/google-analytics.php @@ -9,7 +9,7 @@ * Auto Activate: No * Feature: Engagement * Additional Search Queries: webmaster, google, analytics, console - * Plans: business + * Plans: business, premium */ include dirname( __FILE__ ) . "/google-analytics/wp-google-analytics.php"; diff --git a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php index eb6734b3..f86edf65 100644 --- a/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php +++ b/plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php @@ -248,22 +248,26 @@ class Jetpack_Google_Analytics_Universal { } /** - * Adds the product ID and SKU to the remove product link (for use by remove_from_cart above) if not present - */ + * Adds the product ID and SKU to the remove product link (for use by remove_from_cart above) if not present + * + * @param string $url Full HTML a tag of the link to remove an item from the cart. + * @param string $key Unique Key ID for a cart item. + */ public function remove_from_cart_attributes( $url, $key ) { if ( false !== strpos( $url, 'data-product_id' ) ) { return $url; } - $item = WC()->cart->get_cart_item( $key ); - $product = $item[ 'data' ]; + $item = WC()->cart->get_cart_item( $key ); + $product = $item['data']; - $new_attributes = sprintf( 'href="%s" data-product_id="%s" data-product_sku="%s"', - esc_attr( $url ), + $new_attributes = sprintf( + '" data-product_id="%1$s" data-product_sku="%2$s">', esc_attr( $product->get_id() ), esc_attr( $product->get_sku() ) - ); - $url = str_replace( 'href=', $new_attributes, $url ); + ); + + $url = str_replace( '">', $new_attributes, $url ); return $url; } diff --git a/plugins/jetpack/modules/gravatar-hovercards.php b/plugins/jetpack/modules/gravatar-hovercards.php index fe6cce61..49ebac04 100644 --- a/plugins/jetpack/modules/gravatar-hovercards.php +++ b/plugins/jetpack/modules/gravatar-hovercards.php @@ -185,7 +185,7 @@ function grofiles_attach_cards() { return; } - wp_enqueue_script( 'grofiles-cards', ( is_ssl() ? 'https://secure' : 'http://s' ) . '.gravatar.com/js/gprofiles.js', array( 'jquery' ), GROFILES__CACHE_BUSTER, true ); + wp_enqueue_script( 'grofiles-cards', 'https://secure.gravatar.com/js/gprofiles.js', array( 'jquery' ), GROFILES__CACHE_BUSTER, true ); wp_enqueue_script( 'wpgroho', plugins_url( 'wpgroho.js', __FILE__ ), array( 'grofiles-cards' ), false, true ); if ( is_user_logged_in() ) { $cu = wp_get_current_user(); @@ -246,7 +246,7 @@ function grofiles_hovercards_data_html( $author ) { } elseif ( is_a( $author, 'WP_User' ) ) { $hash = md5( $author->user_email ); } - + if ( ! $hash ) { return; } diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.js b/plugins/jetpack/modules/infinite-scroll/infinity.js index a52cbfd0..010b7148 100644 --- a/plugins/jetpack/modules/infinite-scroll/infinity.js +++ b/plugins/jetpack/modules/infinite-scroll/infinity.js @@ -70,7 +70,7 @@ Scroller = function( settings ) { self.thefooter(); // Fire the refresh self.refresh(); - self.determineURL(); // determine the url + self.determineURL(); // determine the url } }, 250 ); @@ -131,13 +131,14 @@ Scroller.prototype.render = function( response ) { */ Scroller.prototype.query = function() { return { - page : this.page + this.offset, // Load the next page. - currentday : this.currentday, - order : this.order, - scripts : window.infiniteScroll.settings.scripts, - styles : window.infiniteScroll.settings.styles, - query_args : window.infiniteScroll.settings.query_args, - last_post_date : window.infiniteScroll.settings.last_post_date + page : this.page + this.offset, // Load the next page. + currentday : this.currentday, + order : this.order, + scripts : window.infiniteScroll.settings.scripts, + styles : window.infiniteScroll.settings.styles, + query_args : window.infiniteScroll.settings.query_args, + query_before : window.infiniteScroll.settings.query_before, + last_post_date: window.infiniteScroll.settings.last_post_date }; }; diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.php b/plugins/jetpack/modules/infinite-scroll/infinity.php index 6c156983..896db249 100644 --- a/plugins/jetpack/modules/infinite-scroll/infinity.php +++ b/plugins/jetpack/modules/infinite-scroll/infinity.php @@ -372,11 +372,31 @@ class The_Neverending_Home_Page { if ( ! current_theme_supports( 'infinite-scroll' ) ) return; + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + // This setting is no longer configurable in wp-admin on WordPress.com -- leave a pointer + add_settings_field( self::$option_name_enabled, + '' . esc_html__( 'Infinite Scroll Behavior', 'jetpack' ) . '', + array( $this, 'infinite_setting_html_calypso_placeholder' ), + 'reading' + ); + return; + } + // Add the setting field [infinite_scroll] and place it in Settings > Reading add_settings_field( self::$option_name_enabled, '' . esc_html__( 'Infinite Scroll Behavior', 'jetpack' ) . '', array( $this, 'infinite_setting_html' ), 'reading' ); register_setting( 'reading', self::$option_name_enabled, 'esc_attr' ); } + function infinite_setting_html_calypso_placeholder() { + $details = get_blog_details(); + echo '' . sprintf( + /* translators: Variables are the enclosing link to the settings page */ + esc_html__( 'This option has moved. You can now manage it %1$shere%2$s.' ), + '', + '' + ) . ''; + } + /** * HTML code to display a checkbox true/false option * for the infinite_scroll setting. @@ -629,9 +649,9 @@ class The_Neverending_Home_Page { } /** - * Create a where clause that will make sure post queries - * will always return results prior to (descending sort) - * or before (ascending sort) the last post date. + * Create a where clause that will make sure post queries return posts + * in the correct order, without duplicates, if a new post is added + * and we're sorting by post date. * * @global $wpdb * @param string $where @@ -645,18 +665,19 @@ class The_Neverending_Home_Page { global $wpdb; $sort_field = self::get_query_sort_field( $query ); - if ( false == $sort_field ) - return $where; - $last_post_date = $_REQUEST['last_post_date']; - // Sanitize timestamp - if ( empty( $last_post_date ) || !preg_match( '|\d{4}\-\d{2}\-\d{2}|', $last_post_date ) ) + if ( 'post_date' !== $sort_field || 'DESC' !== $_REQUEST['query_args']['order'] ) { return $where; + } + + $query_before = sanitize_text_field( wp_unslash( $_REQUEST['query_before'] ) ); - $operator = 'ASC' == $_REQUEST['query_args']['order'] ? '>' : '<'; + if ( empty( $query_before ) ) { + return $where; + } // Construct the date query using our timestamp - $clause = $wpdb->prepare( " AND {$wpdb->posts}.{$sort_field} {$operator} %s", $last_post_date ); + $clause = $wpdb->prepare( " AND {$wpdb->posts}.post_date <= %s", $query_before ); /** * Filter Infinite Scroll's SQL date query making sure post queries @@ -667,10 +688,12 @@ class The_Neverending_Home_Page { * * @param string $clause SQL Date query. * @param object $query Query. - * @param string $operator Query operator. - * @param string $last_post_date Last Post Date timestamp. + * @param string $operator @deprecated Query operator. + * @param string $last_post_date @deprecated Last Post Date timestamp. */ - $where .= apply_filters( 'infinite_scroll_posts_where', $clause, $query, $operator, $last_post_date ); + $operator = 'ASC' === $_REQUEST['query_args']['order'] ? '>' : '<'; + $last_post_date = sanitize_text_field( wp_unslash( $_REQUEST['last_post_date'] ) ); + $where .= apply_filters( 'infinite_scroll_posts_where', $clause, $query, $operator, $last_post_date ); } return $where; @@ -839,6 +862,7 @@ class The_Neverending_Home_Page { 'parameters' => self::get_request_parameters(), ), 'query_args' => self::get_query_vars(), + 'query_before' => current_time( 'mysql' ), 'last_post_date' => self::get_last_post_date(), 'body_class' => self::body_class(), ); @@ -1200,17 +1224,6 @@ class The_Neverending_Home_Page { $previousday = $_REQUEST['currentday']; } - $sticky = get_option( 'sticky_posts' ); - $post__not_in = self::wp_query()->get( 'post__not_in' ); - - //we have to take post__not_in args into consideration here not only sticky posts - if ( true === isset( $_REQUEST['query_args']['post__not_in'] ) ) { - $post__not_in = array_merge( $post__not_in, array_map( 'intval', (array) $_REQUEST['query_args']['post__not_in'] ) ); - } - - if ( ! empty( $post__not_in ) ) - $sticky = array_unique( array_merge( $sticky, $post__not_in ) ); - $post_status = array( 'publish' ); if ( current_user_can( 'read_private_posts' ) ) array_push( $post_status, 'private' ); @@ -1221,7 +1234,6 @@ class The_Neverending_Home_Page { 'paged' => $page, 'post_status' => $post_status, 'posts_per_page' => self::posts_per_page(), - 'post__not_in' => ( array ) $sticky, 'order' => $order ) ); @@ -1246,7 +1258,6 @@ class The_Neverending_Home_Page { */ $query_args = apply_filters( 'infinite_scroll_query_args', $query_args ); - // Add query filter that checks for posts below the date add_filter( 'posts_where', array( $this, 'query_time_filter' ), 10, 2 ); $GLOBALS['wp_the_query'] = $GLOBALS['wp_query'] = $infinite_scroll_query = new WP_Query(); @@ -1607,6 +1618,14 @@ add_action( 'init', 'the_neverending_home_page_init', 20 ); * If so, include the files which add theme support. */ function the_neverending_home_page_theme_support() { + if ( + defined( 'IS_WPCOM' ) && IS_WPCOM && + defined( 'REST_API_REQUEST' ) && REST_API_REQUEST && + ! doing_action( 'restapi_theme_after_setup_theme' ) + ) { + // Don't source theme compat files until we're in the site's context + return; + } $theme_name = get_stylesheet(); /** diff --git a/plugins/jetpack/modules/lazy-images.php b/plugins/jetpack/modules/lazy-images.php index a0c498cc..56a005e5 100644 --- a/plugins/jetpack/modules/lazy-images.php +++ b/plugins/jetpack/modules/lazy-images.php @@ -9,7 +9,7 @@ * Requires Connection: No * Auto Activate: No * Module Tags: Appearance, Recommended - * Feature: Appearance + * Feature: Appearance, Jumpstart * Additional Search Queries: mobile, theme, performance, image */ diff --git a/plugins/jetpack/modules/lazy-images/js/lazy-images.js b/plugins/jetpack/modules/lazy-images/js/lazy-images.js index 08ff18ce..2c7137b9 100644 --- a/plugins/jetpack/modules/lazy-images/js/lazy-images.js +++ b/plugins/jetpack/modules/lazy-images/js/lazy-images.js @@ -93,30 +93,46 @@ var jetpackLazyImagesModule = function( $ ) { * @param {object} image The image object. */ function applyImage( image ) { - var src = image.getAttribute( 'data-lazy-src' ), - srcset = image.getAttribute( 'data-lazy-srcset' ), - sizes = image.getAttribute( 'data-lazy-sizes' ); + var theImage = $( image ), + src, + srcset, + sizes, + theClone; + if ( ! theImage.length ) { + return; + } + + src = theImage.attr( 'data-lazy-src' ); if ( ! src ) { return; } - // Prevent this from being lazy loaded a second time. - image.classList && image.classList.add( 'jetpack-lazy-image--handled' ); - image.setAttribute( 'data-lazy-loaded', '1' ); + srcset = theImage.attr( 'data-lazy-srcset' ); + sizes = theImage.attr( 'data-lazy-sizes' ); + theClone = theImage.clone(); + + // Remove lazy attributes from the clone. + theClone.removeAttr( 'data-lazy-src' ), + theClone.removeAttr( 'data-lazy-srcset' ), + theClone.removeAttr( 'data-lazy-sizes' ); - image.setAttribute( 'src', src ); - image.removeAttribute( 'data-lazy-src' ); + // Add the attributes we want on the finished image. + theClone.addClass( 'jetpack-lazy-image--handled' ); + theClone.attr( 'data-lazy-loaded', 1 ); + theClone.attr( 'src', src ); if ( srcset ) { - image.setAttribute( 'srcset', srcset ); - image.removeAttribute( 'data-lazy-srcset' ); + theClone.attr( 'srcset', srcset ); } - if ( sizes ) { - image.setAttribute( 'sizes', sizes ); - image.removeAttribute( 'data-lazy-sizes' ); + theClone.attr( 'sizes', sizes ); } + + theImage.replaceWith( theClone ); + + // Fire an event so that third-party code can perform actions after an image is loaded. + theClone.trigger( 'jetpack-lazy-loaded-image' ); } }; diff --git a/plugins/jetpack/modules/lazy-images/lazy-images.php b/plugins/jetpack/modules/lazy-images/lazy-images.php index fc800159..25ca181b 100644 --- a/plugins/jetpack/modules/lazy-images/lazy-images.php +++ b/plugins/jetpack/modules/lazy-images/lazy-images.php @@ -290,6 +290,9 @@ class Jetpack_Lazy_Images { } public function enqueue_assets() { + if ( Jetpack_AMP_Support::is_amp_request() ) { + return; + } wp_enqueue_script( 'jetpack-lazy-images', Jetpack::get_file_url_for_environment( diff --git a/plugins/jetpack/modules/likes.php b/plugins/jetpack/modules/likes.php index bc28744b..a2ecff78 100644 --- a/plugins/jetpack/modules/likes.php +++ b/plugins/jetpack/modules/likes.php @@ -140,6 +140,20 @@ class Jetpack_Likes { } } + + /** + * Stub for is_post_likeable, since some wpcom functions call this directly on the class + * Are likes enabled for this post? + * + * @param int $post_id + * @return bool + */ + static function is_post_likeable( $post_id = 0 ) { + _deprecated_function( __METHOD__, 'jetpack-5.4', 'Jetpack_Likes_Settings()->is_post_likeable' ); + $settings = new Jetpack_Likes_Settings(); + return $settings->is_post_likeable(); + } + /** * Stub for is_likes_visible, since some themes were calling it directly from this class * @@ -163,21 +177,6 @@ class Jetpack_Likes { return $html; } - /** - * WordPress.com: Metabox option for sharing (sharedaddy will handle this on the JP blog) - */ - function sharing_meta_box_content( $post ) { - $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID(); - $disabled = get_post_meta( $post_id, 'sharing_disabled', true ); ?> -

- - -

in_jetpack ) { add_filter( 'the_content', array( &$this, 'post_likes' ), 30, 1 ); add_filter( 'the_excerpt', array( &$this, 'post_likes' ), 30, 1 ); diff --git a/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php b/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php index 38e5f235..9ccca4c1 100644 --- a/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php +++ b/plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php @@ -4,7 +4,7 @@ * This function needs to get loaded after the like scripts get added to the page. */ function jetpack_likes_master_iframe() { - $version = '20171126'; + $version = gmdate( 'YW' ); $in_jetpack = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? false : true; $_locale = get_locale(); diff --git a/plugins/jetpack/modules/likes/jetpack-likes-settings.php b/plugins/jetpack/modules/likes/jetpack-likes-settings.php index cafe111e..b58467a6 100644 --- a/plugins/jetpack/modules/likes/jetpack-likes-settings.php +++ b/plugins/jetpack/modules/likes/jetpack-likes-settings.php @@ -156,6 +156,21 @@ class Jetpack_Likes_Settings { return $post_id; } + /** + * WordPress.com: Metabox option for sharing (sharedaddy will handle this on the JP blog) + */ + public function sharing_meta_box_content( $post ) { + $post_id = ! empty( $post->ID ) ? (int) $post->ID : get_the_ID(); + $disabled = get_post_meta( $post_id, 'sharing_disabled', true ); ?> +

+ + +

get_parser()->contain_span_tags_re . '/'; + foreach ( $tags as $tag => $attributes ) { + if ( preg_match( $re, $tag ) ) { + $attributes['markdown'] = true; + $tags[ $tag ] = $attributes; + } + } + + return $tags; + } + + /** + * TinyMCE needs to know not to strip the 'markdown' attribute. Unfortunately, it doesn't + * really offer a nice API for whitelisting attributes, so we have to manually add it + * to the schema instead. + */ + public function after_wp_tiny_mce() { +?> + + 'mb-icon user-info-item', ), ) ); - - $wp_admin_bar->add_menu( array( - 'parent' => $id, - 'id' => 'next-steps', - 'title' => esc_html__( 'Next Steps', 'jetpack' ), - 'href' => 'https://wordpress.com/me/next', - 'meta' => array( - 'class' => 'mb-icon user-info-item', - ), - ) ); - + $help_link = 'https://jetpack.com/support/'; if ( jetpack_is_atomic_site() ) { @@ -872,15 +862,15 @@ class A8C_WPCOM_Masterbar { } $theme_title = $this->create_menu_item_pair( - array( - 'url' => 'https://wordpress.com/themes/' . esc_attr( $this->primary_site_slug ), - 'id' => 'wp-admin-bar-themes', - 'label' => esc_html__( 'Themes', 'jetpack' ), - ), array( 'url' => $customizer_url, 'id' => 'wp-admin-bar-cmz', 'label' => esc_html_x( 'Customize', 'admin bar customize item label', 'jetpack' ), + ), + array( + 'url' => 'https://wordpress.com/themes/' . esc_attr( $this->primary_site_slug ), + 'id' => 'wp-admin-bar-themes', + 'label' => esc_html__( 'Themes', 'jetpack' ), ) ); $meta = array( 'class' => 'mb-icon', 'class' => 'inline-action' ); diff --git a/plugins/jetpack/modules/monitor.php b/plugins/jetpack/modules/monitor.php index 9f947abf..1e03c850 100644 --- a/plugins/jetpack/modules/monitor.php +++ b/plugins/jetpack/modules/monitor.php @@ -52,7 +52,7 @@ class Jetpack_Monitor { public function jetpack_configuration_screen() { ?> -

+

diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php index 1a56c292..5a8b2e4f 100644 --- a/plugins/jetpack/modules/protect.php +++ b/plugins/jetpack/modules/protect.php @@ -554,7 +554,7 @@ class Jetpack_Protect_Module { * @param bool true Should we fallback to the Math questions when an IP is blocked. Default to true. */ $allow_math_fallback_on_fail = apply_filters( 'jpp_use_captcha_when_blocked', true ); - if ( ! $allow_math_fallback_on_fail || Jetpack_Constants::is_true( 'XMLRPC_REQUEST' ) ) { + if ( ! $allow_math_fallback_on_fail ) { $this->kill_login(); } include_once dirname( __FILE__ ) . '/protect/math-fallback.php'; diff --git a/plugins/jetpack/modules/publicize.php b/plugins/jetpack/modules/publicize.php index 0b2b8c73..577c2929 100644 --- a/plugins/jetpack/modules/publicize.php +++ b/plugins/jetpack/modules/publicize.php @@ -57,239 +57,6 @@ class Jetpack_Publicize { global $publicize_ui; new Jetpack_Publicize; -/** -* Helper functions for shared use in the services files -*/ -class Publicize_Util { - /** - * Truncates a string to be shorter than or equal to the length specified - * Attempts to truncate on word boundaries - * - * @param string $string - * @param int $length - * @return string - */ - public static function crop_str( $string, $length = 256 ) { - $string = Publicize_Util::sanitize_message( $string ); - $length = absint( $length ); - - if ( mb_strlen( $string, 'UTF-8' ) <= $length ) { - return $string; - } - - // @see wp_trim_words() - if ( 'characters' == _x( 'words', 'word count: words or characters?', 'jetpack' ) ) { - return trim( mb_substr( $string, 0, $length - 1, 'UTF-8' ) ) . "\xE2\x80\xA6"; // ellipsis - } - - $words = explode( ' ', $string ); - - $return = ''; - while ( strlen( $word = array_shift( $words ) ) ) { - $new_return = $return ? "$return $word" : $word; - $new_return_length = mb_strlen( $new_return, 'UTF-8' ); - if ( $new_return_length < $length - 1 ) { - $return = $new_return; - continue; - } elseif ( $new_return_length == $length - 1 ) { - $return = $new_return; - break; - } - - if ( !$return ) { - $return = mb_substr( $new_return, 0, $length - 1, 'UTF-8' ); - } - - break; - } - - return "$return\xE2\x80\xA6"; // ellipsis - } - - - /** - * Returns an array of DOMNodes that are comments (including recursing child nodes) - * - * @param DOMNode $node - * @return array - */ - - function get_comment_nodes( $node ) { - $comment_nodes = array(); - foreach ( $node->childNodes as $child ) { - - if ( XML_COMMENT_NODE === $child->nodeType ) { - $comment_nodes[] = $child; - } - - if ( $child->hasChildNodes() ) { - $child_comment_nodes = self::get_comment_nodes( $child ); - $comment_nodes = array_merge( $comment_nodes, $child_comment_nodes ); - } - } - - return $comment_nodes; - } - - /** - * Truncates HTML so that its textContent (text without markup) is shorter than or equal to the length specified. - * The length of the returned string may be larger than the specified length due to the markup. - * Attempts to truncate on word boundaries. - * - * @param string $string - * @param int $length - * @param array $allowed_tags KSES input - * @return string - */ - function crop_html( $string, $length = 256, $allowed_tags = array() ) { - $tags = $GLOBALS['allowedtags']; // Markup allowed in comments... - - $tags['img'] = array( // ... plus images ... - 'alt' => true, - 'height' => true, - 'src' => true, - 'width' => true, - ); - - // ... and some other basics - $tags['p'] = array(); - $tags['ul'] = array(); - $tags['ol'] = array(); - $tags['li'] = array(); - $tags['br'] = array(); - - $tags = array_merge( $tags, $allowed_tags ); - - // Clean up, then KSES to really lock it down - $string = trim( (string) $string ); - $string = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $string ); - $string = wp_kses( $string, $tags ); - - $string = mb_convert_encoding( $string, 'HTML-ENTITIES', 'UTF-8' ); - $dom = new DOMDocument( '1.0', 'UTF-8' ); - - // The @ is not enough to suppress errors when dealing with libxml, - // we have to tell it directly how we want to handle errors. - libxml_use_internal_errors( true ); - @$dom->loadHTML( "$string" ); - libxml_use_internal_errors( false ); - - // Strip comment nodes, if any - $comment_nodes = self::get_comment_nodes( $dom->documentElement ); - foreach ( $comment_nodes as &$comment_node ) { - $comment_node->parentNode->removeChild( $comment_node ); - } - if ( $comment_nodes ) { - // Update the $string (some return paths work from just $string) - $string = $dom->saveHTML(); - $string = preg_replace( '/^/', '', $string ); - $string = str_replace( array('', '', '', '' ), array( '', '', '', '' ), $string ); - $string = trim( $string ); - } - - // Find the body - $body = false; - foreach ( $dom->childNodes as $child ) { - if ( XML_ELEMENT_NODE === $child->nodeType && 'html' === strtolower( $child->tagName ) ) { - $body = $child->firstChild; - break; - } - } - - if ( !$body ) { - return self::crop_str( $string, $length ); - } - - // If the text (without the markup) is shorter than $length, just return - if ( mb_strlen( $body->textContent, 'UTF-8' ) <= $length ) { - return $string; - } - - $node = false; - do { - $node = self::remove_innermost_last_child( $body, $node_removed_from ); - $new_string_length = mb_strlen( $body->textContent, 'UTF-8' ); - } while ( $new_string_length > $length ); - - $new_string = $dom->saveHTML( $body ); - $new_string = mb_substr( $new_string, 6, -7, 'UTF-8' ); // 6: , 7: - - if ( !$node ) { - return $new_string ? $new_string : self::crop_str( $string, $length ); - } - - $append_string_length = $length - $new_string_length; - - if ( !$append_string_length ) { - return $new_string; - } - - if ( $append_string_length > 1 && XML_TEXT_NODE === $node->nodeType ) { // 1: ellipsis - $append_string = self::crop_str( $node->textContent, $append_string_length ); // includes ellipsis - $append_node = $dom->createTextNode( $append_string ); - $node_removed_from->appendChild( $append_node ); - $new_string = $dom->saveHTML( $body ); - $new_string = mb_substr( $new_string, 6, -7, 'UTF-8' ); - } elseif ( $append_string_length > 9 && XML_ELEMENT_NODE === $node->nodeType && 'p' == strtolower( $node->nodeName ) ) { // 9: '

X{\xE2\x80\xA6}

' - $new_string .= '

' . self::crop_str( $node->textContent, $append_string_length - 8 ) . '

'; - } - - // Clean up any empty Paragraphs that might have occurred after removing their children - return trim( preg_replace( '#

\s*

#i', '', $new_string ) ); - } - - function remove_innermost_last_child( $node, &$node_removed_from ) { - $node_removed_from = $node; - - if ( !$node->lastChild ) { - return false; - } - - if ( $node->lastChild->hasChildNodes() ) { - return self::remove_innermost_last_child( $node->lastChild, $node_removed_from ); - } - - $innermost_last_child = $node->lastChild; - $node->removeChild( $innermost_last_child ); - - return $innermost_last_child; - } - - function bump_stats_extras_publicize_url( $bin, $post_id ) { - static $done = array(); - if ( isset( $done[$post_id] ) ) { - return; - } - $done[$post_id] = true; - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'publicize_url', $bin ); - } - - public static function build_sprintf( $args ) { - $search = array(); - $replace = array(); - foreach ( $args as $k => $arg ) { - if ( 0 == $k ) { - $string = $arg; - continue; - } - $search[] = "%$arg%"; - $replace[] = "%$k\$s"; - } - return str_replace( $search, $replace, $string ); - } - - public static function sanitize_message( $message ) { - $message = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $message ); - $message = wp_kses( $message, array() ); - $message = preg_replace('/[\r\n\t ]+/', ' ', $message); - $message = trim( $message ); - $message = htmlspecialchars_decode( $message, ENT_QUOTES ); - return $message; - } -} - if( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) && ! function_exists( 'publicize_init' ) ) { /** * Helper for grabbing a Publicize object from the "front-end" (non-admin) of diff --git a/plugins/jetpack/modules/publicize/assets/publicize-rtl.css b/plugins/jetpack/modules/publicize/assets/publicize-rtl.css index 3f9c39d0..31fb06a5 100644 --- a/plugins/jetpack/modules/publicize/assets/publicize-rtl.css +++ b/plugins/jetpack/modules/publicize/assets/publicize-rtl.css @@ -110,7 +110,6 @@ div.publicize-service-right li { border-top-style: none; border-top-width: 0px; color: #CCC; - cursor: auto; display: inline; font-size: 20px; font-style: normal; diff --git a/plugins/jetpack/modules/publicize/assets/publicize-rtl.min.css b/plugins/jetpack/modules/publicize/assets/publicize-rtl.min.css index 6e943b26..6bfc77c9 100644 --- a/plugins/jetpack/modules/publicize/assets/publicize-rtl.min.css +++ b/plugins/jetpack/modules/publicize/assets/publicize-rtl.min.css @@ -1 +1 @@ -div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 20px 5px 25px;overflow:hidden;max-width:1200px}span.pub-logos{float:right;display:block;width:130px;height:75px;margin-top:-18px;margin-right:5px;vertical-align:top}.left,.right{width:50%;float:right}div#facebook{background:url(publicize-fb-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#path{background:url(publicize-path-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px 0;border-bottom:1px #eee solid;margin-left:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:left;float:left;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-bottom-color:#ccc;border-bottom-style:none;border-bottom-width:0;border-right-color:#ccc;border-right-style:none;border-right-width:0;border-left-color:#ccc;border-left-style:none;border-left-width:0;border-top-color:#ccc;border-top-style:none;border-top-width:0;color:#ccc;cursor:auto;display:inline;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style-image:none;list-style-position:outside;list-style-type:none;margin-bottom:0;margin-right:0;margin-left:0;margin-top:0;outline-color:#ccc;outline-style:none;outline-width:0;overflow-y:visible;padding-bottom:0;padding-right:0;padding-left:0;padding-top:0;position:static;left:auto;text-align:right;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio{padding-left:20px}table#option-profile td.thumbnail{padding-left:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px 5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-left:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red} \ No newline at end of file +div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 20px 5px 25px;overflow:hidden;max-width:1200px}span.pub-logos{float:right;display:block;width:130px;height:75px;margin-top:-18px;margin-right:5px;vertical-align:top}.left,.right{width:50%;float:right}div#facebook{background:url(publicize-fb-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#path{background:url(publicize-path-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) no-repeat;background-size:32px 32px;padding-right:42px;background-position:0 0;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px 0;border-bottom:1px #eee solid;margin-left:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:left;float:left;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-bottom-color:#ccc;border-bottom-style:none;border-bottom-width:0;border-right-color:#ccc;border-right-style:none;border-right-width:0;border-left-color:#ccc;border-left-style:none;border-left-width:0;border-top-color:#ccc;border-top-style:none;border-top-width:0;color:#ccc;display:inline;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style-image:none;list-style-position:outside;list-style-type:none;margin-bottom:0;margin-right:0;margin-left:0;margin-top:0;outline-color:#ccc;outline-style:none;outline-width:0;overflow-y:visible;padding-bottom:0;padding-right:0;padding-left:0;padding-top:0;position:static;left:auto;text-align:right;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio{padding-left:20px}table#option-profile td.thumbnail{padding-left:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px 5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-left:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red} \ No newline at end of file diff --git a/plugins/jetpack/modules/publicize/assets/publicize.css b/plugins/jetpack/modules/publicize/assets/publicize.css index 842612fc..3d75ab7b 100644 --- a/plugins/jetpack/modules/publicize/assets/publicize.css +++ b/plugins/jetpack/modules/publicize/assets/publicize.css @@ -109,7 +109,6 @@ div.publicize-service-right li { border-top-style: none; border-top-width: 0px; color: #CCC; - cursor: auto; display: inline; font-size: 20px; font-style: normal; diff --git a/plugins/jetpack/modules/publicize/assets/publicize.min.css b/plugins/jetpack/modules/publicize/assets/publicize.min.css index 675e8ce7..43b2583e 100644 --- a/plugins/jetpack/modules/publicize/assets/publicize.min.css +++ b/plugins/jetpack/modules/publicize/assets/publicize.min.css @@ -1,2 +1,2 @@ /* Do not modify this file directly. It is concatenated from individual module CSS files. */ -div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 25px 5px 20px;overflow:hidden;max-width:1200px}span.pub-logos{float:left;display:block;width:130px;height:75px;margin-top:-18px;margin-left:5px;vertical-align:top}.left,.right{width:50%;float:left}div#facebook{background:url(publicize-fb-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#path{background:url(publicize-path-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px 0;border-bottom:1px #eee solid;margin-right:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:right;float:right;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-bottom-color:#ccc;border-bottom-style:none;border-bottom-width:0;border-left-color:#ccc;border-left-style:none;border-left-width:0;border-right-color:#ccc;border-right-style:none;border-right-width:0;border-top-color:#ccc;border-top-style:none;border-top-width:0;color:#ccc;cursor:auto;display:inline;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style-image:none;list-style-position:outside;list-style-type:none;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;outline-color:#ccc;outline-style:none;outline-width:0;overflow-y:visible;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;position:static;right:auto;text-align:left;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio{padding-right:20px}table#option-profile td.thumbnail{padding-right:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px 5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-right:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red} \ No newline at end of file +div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 25px 5px 20px;overflow:hidden;max-width:1200px}span.pub-logos{float:left;display:block;width:130px;height:75px;margin-top:-18px;margin-left:5px;vertical-align:top}.left,.right{width:50%;float:left}div#facebook{background:url(publicize-fb-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#path{background:url(publicize-path-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) no-repeat;background-size:32px 32px;padding-left:42px;background-position:0 0;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px 0;border-bottom:1px #eee solid;margin-right:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:right;float:right;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-bottom-color:#ccc;border-bottom-style:none;border-bottom-width:0;border-left-color:#ccc;border-left-style:none;border-left-width:0;border-right-color:#ccc;border-right-style:none;border-right-width:0;border-top-color:#ccc;border-top-style:none;border-top-width:0;color:#ccc;display:inline;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style-image:none;list-style-position:outside;list-style-type:none;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;outline-color:#ccc;outline-style:none;outline-width:0;overflow-y:visible;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;position:static;right:auto;text-align:left;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio{padding-right:20px}table#option-profile td.thumbnail{padding-right:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px 5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-right:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red} \ No newline at end of file diff --git a/plugins/jetpack/modules/publicize/assets/rtl/publicize-rtl.css b/plugins/jetpack/modules/publicize/assets/rtl/publicize-rtl.css index 9a8f314c..33ea3813 100644 --- a/plugins/jetpack/modules/publicize/assets/rtl/publicize-rtl.css +++ b/plugins/jetpack/modules/publicize/assets/rtl/publicize-rtl.css @@ -1,4 +1,4 @@ -/* This file was automatically generated on Jan 15 2014 20:27:52 */ +/* This file was automatically generated on Mar 01 2018 13:02:41 */ div#publicize-services-block { display: block; @@ -111,7 +111,6 @@ div.publicize-service-right li { border-top-style: none; border-top-width: 0px; color: #CCC; - cursor: auto; display: inline; font-family: sans-serif; font-size: 20px; diff --git a/plugins/jetpack/modules/publicize/enhanced-open-graph.php b/plugins/jetpack/modules/publicize/enhanced-open-graph.php index 26322245..ba60b821 100644 --- a/plugins/jetpack/modules/publicize/enhanced-open-graph.php +++ b/plugins/jetpack/modules/publicize/enhanced-open-graph.php @@ -101,8 +101,8 @@ function enhanced_og_video( $tags ) { if ( preg_match( '/((youtube|vimeo)\.com|youtu.be)/', $video_url ) ) { if ( strstr( $video_url, 'youtube' ) ) { $id = jetpack_get_youtube_id( $video_url ); - $video_url = 'http://www.youtube.com/v/' . $id . '?version=3&autohide=1'; - $secure_video_url = 'https://www.youtube.com/v/' . $id . '?version=3&autohide=1'; + $video_url = 'http://www.youtube.com/embed/' . $id; + $secure_video_url = 'https://www.youtube.com/embed/' . $id; } else if ( strstr( $video_url, 'vimeo' ) ) { preg_match( '|vimeo\.com/(\d+)/?$|i', $video_url, $match ); $id = (int) $match[1]; diff --git a/plugins/jetpack/modules/publicize/publicize-jetpack.php b/plugins/jetpack/modules/publicize/publicize-jetpack.php index 0923af21..9834fe20 100644 --- a/plugins/jetpack/modules/publicize/publicize-jetpack.php +++ b/plugins/jetpack/modules/publicize/publicize-jetpack.php @@ -138,6 +138,27 @@ class Publicize extends Publicize_Base { return false; } + function get_all_connections_for_user() { + $connections = Jetpack_Options::get_option( 'publicize_connections' ); + + $connections_to_return = array(); + if ( ! empty( $connections ) ) { + foreach ( (array) $connections as $service_name => $connections_for_service ) { + foreach ( $connections_for_service as $id => $connection ) { + $user_id = intval( $connection['connection_data']['user_id'] ); + // phpcs:ignore WordPress.PHP.YodaConditions.NotYoda + if ( $user_id === 0 || $this->user_id() === $user_id ) { + $connections_to_return[ $service_name ][ $id ] = $connection; + } + } + } + + return $connections_to_return; + } + + return false; + } + function get_connection_id( $connection ) { return $connection['connection_data']['id']; } @@ -395,6 +416,10 @@ class Publicize extends Publicize_Base { } function flag_post_for_publicize( $new_status, $old_status, $post ) { + if ( ! $this->post_type_is_publicizeable( $post->post_type ) ) { + return; + } + if ( 'publish' == $new_status && 'publish' != $old_status ) { /** * Determines whether a post being published gets publicized. diff --git a/plugins/jetpack/modules/publicize/publicize.php b/plugins/jetpack/modules/publicize/publicize.php index 8f051f75..d438859c 100644 --- a/plugins/jetpack/modules/publicize/publicize.php +++ b/plugins/jetpack/modules/publicize/publicize.php @@ -46,7 +46,7 @@ abstract class Publicize_Base { * Sets up the basics of Publicize */ function __construct() { - $this->default_message = Publicize_Util::build_sprintf( array( + $this->default_message = self::build_sprintf( array( /** * Filter the default Publicize message. * @@ -61,7 +61,7 @@ abstract class Publicize_Base { 'url', ) ); - $this->default_prefix = Publicize_Util::build_sprintf( array( + $this->default_prefix = self::build_sprintf( array( /** * Filter the message prepended to the Publicize custom message. * @@ -75,7 +75,7 @@ abstract class Publicize_Base { 'url', ) ); - $this->default_suffix = Publicize_Util::build_sprintf( array( + $this->default_suffix = self::build_sprintf( array( /** * Filter the message appended to the Publicize custom message. * @@ -107,6 +107,7 @@ abstract class Publicize_Base { // then check meta and publicize based on that. stage 3 implemented on wpcom add_action( 'transition_post_status', array( $this, 'flag_post_for_publicize' ), 10, 3 ); add_action( 'save_post', array( &$this, 'save_meta' ), 20, 2 ); + add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 20, 1 ); // Connection test callback add_action( 'wp_ajax_test_publicize_conns', array( $this, 'test_publicize_conns' ) ); @@ -133,8 +134,8 @@ abstract class Publicize_Base { /** * Returns an external URL to the connection's profile */ - function get_profile_link( $service_name, $c ) { - $cmeta = $this->get_connection_meta( $c ); + function get_profile_link( $service_name, $connection ) { + $cmeta = $this->get_connection_meta( $connection ); if ( isset( $cmeta['connection_data']['meta']['link'] ) ) { if ( 'facebook' == $service_name && 0 === strpos( parse_url( $cmeta['connection_data']['meta']['link'], PHP_URL_PATH ), '/app_scoped_user_id/' ) ) { @@ -177,8 +178,8 @@ abstract class Publicize_Base { /** * Returns a display name for the connection */ - function get_display_name( $service_name, $c ) { - $cmeta = $this->get_connection_meta( $c ); + function get_display_name( $service_name, $connection ) { + $cmeta = $this->get_connection_meta( $connection ); if ( isset( $cmeta['connection_data']['meta']['display_name'] ) ) { return $cmeta['connection_data']['meta']['display_name']; @@ -211,8 +212,8 @@ abstract class Publicize_Base { } } - function show_options_popup( $service_name, $c ) { - $cmeta = $this->get_connection_meta( $c ); + function show_options_popup( $service_name, $connection ) { + $cmeta = $this->get_connection_meta( $connection ); // always show if no selection has been made for facebook if ( 'facebook' == $service_name && empty( $cmeta['connection_data']['meta']['facebook_profile'] ) && empty( $cmeta['connection_data']['meta']['facebook_page'] ) ) @@ -418,15 +419,99 @@ abstract class Publicize_Base { // Next up will be ::publicize_post() } + public function update_published_message( $messages ) { + global $post_type, $post_type_object, $post; + if ( ! $this->post_type_is_publicizeable( $post_type ) ) { + return $messages; + } + $view_post_link_html = ''; + $viewable = is_post_type_viewable( $post_type_object ); + if ( $viewable ) { + $view_text = esc_html__( 'View post' ); // intentionally omitted domain + + if ( 'jetpack-portfolio' == $post_type ) { + $view_text = esc_html__( 'View project', 'jetpack' ); + } + + $view_post_link_html = sprintf( ' %2$s', + esc_url( get_permalink( $post ) ), + $view_text + ); + } + + $services = $this->get_publicizing_services( $post->ID ); + if ( empty( $services ) ) { + return $messages; + } + + $labels = array(); + foreach ( $services as $service => $display_names ) { + $labels[] = sprintf( + /* translators: Service name is %1$s, and account name is %2$s. */ + esc_html__( '%1$s (%2$s)', 'jetpack' ), + esc_html( $service ), + esc_html( implode( ', ', $display_names ) ) + ); + } + + $messages['post'][6] = sprintf( + /* translators: %1$s is a comma-separated list of services and accounts. Ex. Facebook (@jetpack), Twitter (@jetpack) */ + esc_html__( 'Post published and sharing on %1$s.', 'jetpack' ), + implode( ', ', $labels ) + ) . $view_post_link_html; + + if ( $post_type == 'post' && class_exists('Jetpack_Subscriptions' ) ) { + $subscription = Jetpack_Subscriptions::init(); + if ( $subscription->should_email_post_to_subscribers( $post ) ) { + $messages['post'][6] = sprintf( + /* translators: %1$s is a comma-separated list of services and accounts. Ex. Facebook (@jetpack), Twitter (@jetpack) */ + esc_html__( 'Post published, sending emails to subscribers and sharing post on %1$s.', 'jetpack' ), + implode( ', ', $labels ) + ) . $view_post_link_html; + } + } + + $messages['jetpack-portfolio'][6] = sprintf( + /* translators: %1$s is a comma-separated list of services and accounts. Ex. Facebook (@jetpack), Twitter (@jetpack) */ + esc_html__( 'Project published and sharing project on %1$s.', 'jetpack' ), + implode( ', ', $labels ) + ) . $view_post_link_html; + + return $messages; + } + + function get_publicizing_services( $post_id ) { + $services = array(); + + foreach ( (array) $this->get_services( 'connected' ) as $service_name => $connections ) { + // services have multiple connections. + foreach ( $connections as $connection ) { + $unique_id = ''; + if ( ! empty( $connection->unique_id ) ) + $unique_id = $connection->unique_id; + else if ( ! empty( $connection['connection_data']['token_id'] ) ) + $unique_id = $connection['connection_data']['token_id']; + + // Did we skip this connection? + if ( get_post_meta( $post_id, $this->POST_SKIP . $unique_id, true ) ) { + continue; + } + $services[ $this->get_service_label( $service_name ) ][] = $this->get_display_name( $service_name, $connection ); + } + } + + return $services; + } + /** - * Is a given post type Publicize-able? - * - * Not every CPT lends itself to Publicize-ation. Allow CPTs to register by adding their CPT via - * the publicize_post_types array filter. - * - * @param string $post_type The post type to check. - * $return bool True if the post type can be Publicized. - */ + * Is a given post type Publicize-able? + * + * Not every CPT lends itself to Publicize-ation. Allow CPTs to register by adding their CPT via + * the publicize_post_types array filter. + * + * @param string $post_type The post type to check. + * @return bool True if the post type can be Publicized. + */ function post_type_is_publicizeable( $post_type ) { if ( 'post' == $post_type ) return true; @@ -480,4 +565,33 @@ abstract class Publicize_Base { wp_send_json_success( $test_results ); } + + protected static function build_sprintf( $args ) { + $search = array(); + $replace = array(); + foreach ( $args as $k => $arg ) { + if ( 0 == $k ) { + $string = $arg; + continue; + } + $search[] = "%$arg%"; + $replace[] = "%$k\$s"; + } + return str_replace( $search, $replace, $string ); + } +} + +function publicize_calypso_url() { + $calypso_sharing_url = 'https://wordpress.com/sharing/'; + if ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'build_raw_urls' ) ) { + $site_suffix = Jetpack::build_raw_urls( home_url() ); + } elseif ( class_exists( 'WPCOM_Masterbar' ) && method_exists( 'WPCOM_Masterbar', 'get_calypso_site_slug' ) ) { + $site_suffix = WPCOM_Masterbar::get_calypso_site_slug( get_current_blog_id() ); + } + + if ( $site_suffix ) { + return $calypso_sharing_url . $site_suffix; + } else { + return $calypso_sharing_url; + } } diff --git a/plugins/jetpack/modules/publicize/ui.php b/plugins/jetpack/modules/publicize/ui.php index 38215545..162c3ee0 100644 --- a/plugins/jetpack/modules/publicize/ui.php +++ b/plugins/jetpack/modules/publicize/ui.php @@ -86,9 +86,9 @@ class Publicize_UI { '20121019' ); if( is_rtl() ) { - wp_enqueue_style( 'publicize', plugins_url( 'assets/rtl/publicize-rtl.css', __FILE__ ), array(), '20120925' ); + wp_enqueue_style( 'publicize', plugins_url( 'assets/rtl/publicize-rtl.css', __FILE__ ), array(), '20180301' ); } else { - wp_enqueue_style( 'publicize', plugins_url( 'assets/publicize.css', __FILE__ ), array(), '20120925' ); + wp_enqueue_style( 'publicize', plugins_url( 'assets/publicize.css', __FILE__ ), array(), '20180301' ); } diff --git a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php index ae1d1d78..8349b530 100644 --- a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php +++ b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php @@ -191,7 +191,7 @@ class Jetpack_Related_Posts_Customize { ), 'show_thumbnails' => array( 'label' => esc_html__( 'Show thumbnails', 'jetpack' ), - 'description' => esc_html__( 'Use a large and visually striking layout.', 'jetpack' ), + 'description' => esc_html__( 'Show a thumbnail image where available.', 'jetpack' ), 'control_type' => 'checkbox', 'default' => 1, 'setting_type' => 'option', @@ -275,4 +275,4 @@ class Jetpack_Message_Control extends WP_Customize_Control { } // class end // Initialize controls -new Jetpack_Related_Posts_Customize; \ No newline at end of file +new Jetpack_Related_Posts_Customize; diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php index 131d6a93..751a66dd 100644 --- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php +++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php @@ -386,7 +386,7 @@ EOT; checked( $options['show_headline'], true, false ), esc_html__( 'Show a "Related" header to more clearly separate the related section from posts', 'jetpack' ), checked( $options['show_thumbnails'], true, false ), - esc_html__( 'Use a large and visually striking layout', 'jetpack' ), + esc_html__( 'Show a thumbnail image where available', 'jetpack' ), checked( $options['show_date'], true, false ), esc_html__( 'Show entry date', 'jetpack' ), checked( $options['show_context'], true, false ), @@ -591,11 +591,13 @@ EOT; public function get_for_post_id( $post_id, array $args ) { $options = $this->get_options(); - if ( ! empty( $args['size'] ) ) + if ( ! empty( $args['size'] ) ) { $options['size'] = $args['size']; + } - if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) ) + if ( ! $options['enabled'] || 0 == (int)$post_id || empty( $options['size'] ) || get_post_status( $post_id) !== 'publish' ) { return array(); + } $defaults = array( 'size' => (int)$options['size'], @@ -1413,7 +1415,9 @@ EOT; && ! is_admin() && - ( !$this->_allow_feature_toggle() || $this->get_option( 'enabled' ) ); + ( !$this->_allow_feature_toggle() || $this->get_option( 'enabled' ) ) + && + ! Jetpack_AMP_Support::is_amp_request(); /** * Filter the Enabled value to allow related posts to be shown on pages as well. diff --git a/plugins/jetpack/modules/search/class.jetpack-search.php b/plugins/jetpack/modules/search/class.jetpack-search.php index 5908bd61..62909e91 100644 --- a/plugins/jetpack/modules/search/class.jetpack-search.php +++ b/plugins/jetpack/modules/search/class.jetpack-search.php @@ -333,15 +333,15 @@ class Jetpack_Search { $do_authenticated_request = false; if ( class_exists( 'Jetpack_Client' ) && - isset( $es_args['authenticated_request'] ) && - true === $es_args['authenticated_request'] ) { + isset( $es_args['authenticated_request'] ) && + true === $es_args['authenticated_request'] ) { $do_authenticated_request = true; } unset( $es_args['authenticated_request'] ); $request_args = array( - 'headers' => array( + 'headers' => array( 'Content-Type' => 'application/json', ), 'timeout' => 10, @@ -371,7 +371,8 @@ class Jetpack_Search { } $response_code = wp_remote_retrieve_response_code( $request ); - $response = json_decode( wp_remote_retrieve_body( $request ), true ); + + $response = json_decode( wp_remote_retrieve_body( $request ), true ); $took = is_array( $response ) && ! empty( $response['took'] ) ? $response['took'] @@ -499,6 +500,10 @@ class Jetpack_Search { * @param WP_Query $query The original WP_Query to use for the parameters of our search. */ public function do_search( WP_Query $query ) { + if ( ! $query->is_main_query() || ! $query->is_search() ) { + return; + } + $page = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1; // Get maximum allowed offset and posts per page values for the API. @@ -716,7 +721,6 @@ class Jetpack_Search { return $sanitized_post_types; } - /** * Get the Elasticsearch result. * @@ -1113,6 +1117,7 @@ class Jetpack_Search { unset( $es_query_args['sort'] ); } + // Aggregations if ( ! empty( $args['aggregations'] ) ) { $this->add_aggregations_to_es_query_builder( $args['aggregations'], $parser ); } diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php b/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php index 54747b5a..a1bac401 100644 --- a/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php +++ b/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php @@ -249,7 +249,7 @@ class Jetpack_SEO_Titles { if ( '' === $format_array ) { continue; } - + if ( ! is_array( $format_array ) ) { return false; } diff --git a/plugins/jetpack/modules/sharedaddy/recaptcha.php b/plugins/jetpack/modules/sharedaddy/recaptcha.php index 3e4fc915..58ae6563 100644 --- a/plugins/jetpack/modules/sharedaddy/recaptcha.php +++ b/plugins/jetpack/modules/sharedaddy/recaptcha.php @@ -61,6 +61,7 @@ class Jetpack_ReCaptcha { 'invalid-input-response' => __( 'The response parameter is invalid or malformed', 'jetpack' ), 'invalid-json' => __( 'Invalid JSON', 'jetpack' ), 'unexpected-response' => __( 'Unexpected response', 'jetpack' ), + 'unexpected-hostname' => __( 'Unexpected hostname', 'jetpack' ), ); } @@ -128,6 +129,14 @@ class Jetpack_ReCaptcha { return new WP_Error( $error_code, $error_message ); } + // Validate the hostname matches expected source + if ( isset( $resp_decoded['hostname'] ) ) { + $url = wp_parse_url( get_home_url() ); + if ( $url['host'] !== $resp_decoded['hostname'] ) { + return new WP_Error( 'unexpected-host', $this->error_codes['unexpected-hostname'] ); + } + } + return true; } diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php index 2a056991..86e3cc20 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -221,8 +221,17 @@ class Sharing_Service { } // Cleanup after any filters that may have produced duplicate services - $enabled['visible'] = array_unique( $enabled['visible'] ); - $enabled['hidden'] = array_unique( $enabled['hidden'] ); + if ( is_array( $enabled['visible'] ) ) { + $enabled['visible'] = array_unique( $enabled['visible'] ); + } else { + $enabled['visible'] = array(); + } + + if ( is_array( $enabled['hidden'] ) ) { + $enabled['hidden'] = array_unique( $enabled['hidden'] ); + } else { + $enabled['hidden'] = array(); + } // Form the enabled services $blog = array( 'visible' => array(), 'hidden' => array() ); @@ -230,7 +239,10 @@ class Sharing_Service { foreach ( $blog AS $area => $stuff ) { foreach ( (array)$enabled[$area] AS $service ) { if ( isset( $services[$service] ) ) { - $blog[$area][$service] = new $services[$service]( $service, array_merge( $global, isset( $options[$service] ) ? $options[$service] : array() ) ); + if ( ! isset( $options[ $service ] ) || ! is_array( $options[ $service ] ) ) { + $options[ $service ] = array(); + } + $blog[ $area ][ $service ] = new $services[ $service ]( $service, array_merge( $global, $options[ $service ] ) ); } } } @@ -339,10 +351,11 @@ class Sharing_Service { if ( $this->global === false ) { $options = get_option( 'sharing-options' ); - if ( is_array( $options ) && isset( $options['global'] ) ) + if ( is_array( $options ) && isset( $options['global'] ) && is_array( $options['global'] ) ) { $this->global = $options['global']; - else + } else { $this->global = $this->set_global_options( $options['global'] ); + } } if ( ! isset( $this->global['show'] ) ) { @@ -676,8 +689,9 @@ function sharing_display( $text = '', $echo = false ) { // Disabled for this post? $switched_status = get_post_meta( $post->ID, 'sharing_disabled', false ); - if ( !empty( $switched_status ) ) + if ( !empty( $switched_status ) ) { $show = false; + } // Private post? $post_status = get_post_status( $post->ID ); @@ -691,6 +705,7 @@ function sharing_display( $text = '', $echo = false ) { $show = true; $sharing_content = ''; + $enabled = false; if ( $show ) { /** @@ -812,10 +827,12 @@ function sharing_display( $text = '', $echo = false ) { * @module sharedaddy * * @since 3.8.0 + * @since 6.2.0 Started sending $enabled as a second parameter. * * @param string $sharing_content Content markup of the Jetpack sharing links + * @param array $enabled Array of Sharing Services currently enabled. */ - $sharing_markup = apply_filters( 'jetpack_sharing_display_markup', $sharing_content ); + $sharing_markup = apply_filters( 'jetpack_sharing_display_markup', $sharing_content, $enabled ); if ( $echo ) echo $text . $sharing_markup; diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php index 679449e1..6df9b210 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php @@ -367,10 +367,9 @@ abstract class Sharing_Advanced_Source extends Sharing_Source { abstract public function get_options(); } - class Share_Email extends Sharing_Source { public $shortname = 'email'; - public $genericon = '\f410'; + public $icon = '\f410'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -554,7 +553,7 @@ class Share_Email extends Sharing_Source { class Share_Twitter extends Sharing_Source { public $shortname = 'twitter'; - public $genericon = '\f202'; + public $icon = '\f202'; // 'https://dev.twitter.com/rest/reference/get/help/configuration' ( 2015/02/06 ) short_url_length is 22, short_url_length_https is 23 public $short_url_length = 24; @@ -572,7 +571,14 @@ class Share_Twitter extends Sharing_Source { return __( 'Twitter', 'jetpack' ); } - function sharing_twitter_via( $post ) { + /** + * Determine the Twitter 'via' value for a post. + * + * @param WP_Post|int $post Post object or post ID. + * @return string Twitter handle without the preceding @. + **/ + public static function sharing_twitter_via( $post ) { + $post = get_post( $post ); /** * Allow third-party plugins to customize the Twitter username used as "twitter:site" Twitter Card Meta Tag. * @@ -611,7 +617,14 @@ class Share_Twitter extends Sharing_Source { return preg_replace( '/[^\da-z_]+/i', '', $twitter_site_tag_value ); } - public function get_related_accounts( $post ) { + /** + * Determine the 'related' Twitter accounts for a post. + * + * @param WP_Post|int $post Post object or post ID. + * @return string Comma-separated list of Twitter handles. + **/ + public static function get_related_accounts( $post ) { + $post = get_post( $post ); /** * Filter the list of related Twitter accounts added to the Twitter sharing button. * @@ -752,7 +765,7 @@ class Share_Twitter extends Sharing_Source { class Share_Reddit extends Sharing_Source { public $shortname = 'reddit'; - public $genericon = '\f222'; + public $icon = '\f222'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -789,7 +802,7 @@ class Share_Reddit extends Sharing_Source { class Share_LinkedIn extends Sharing_Source { public $shortname = 'linkedin'; - public $genericon = '\f207'; + public $icon = '\f207'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -865,7 +878,7 @@ class Share_LinkedIn extends Sharing_Source { class Share_Facebook extends Sharing_Source { public $shortname = 'facebook'; - public $genericon = '\f204'; + public $icon = '\f204'; private $share_type = 'default'; public function __construct( $id, array $settings ) { @@ -1000,7 +1013,7 @@ class Share_Facebook extends Sharing_Source { class Share_Print extends Sharing_Source { public $shortname = 'print'; - public $genericon = '\f469'; + public $icon = '\f469'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1022,7 +1035,7 @@ class Share_Print extends Sharing_Source { class Share_PressThis extends Sharing_Source { public $shortname = 'pressthis'; - public $genericon = '\f205'; + public $icon = '\f205'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1098,7 +1111,7 @@ class Share_PressThis extends Sharing_Source { class Share_GooglePlus1 extends Sharing_Source { public $shortname = 'googleplus1'; - public $genericon = '\f218'; + public $icon = '\f218'; private $state = false; public function __construct( $id, array $settings ) { @@ -1269,11 +1282,12 @@ class Share_Custom extends Sharing_Advanced_Source { $tagged = ''; if ( $tags ) { + $tagged_raw = array(); foreach ( $tags as $tag ) { - $tagged[] = rawurlencode( $tag->name ); + $tagged_raw[] = rawurlencode( $tag->name ); } - $tagged = implode( ',', $tagged ); + $tagged = implode( ',', $tagged_raw ); } $url = str_replace( '%post_tags%', $tagged, $url ); @@ -1399,7 +1413,7 @@ class Share_Custom extends Sharing_Advanced_Source { class Share_Tumblr extends Sharing_Source { public $shortname = 'tumblr'; - public $genericon = '\f214'; + public $icon = '\f214'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); if ( 'official' == $this->button_style ) { @@ -1447,7 +1461,7 @@ class Share_Tumblr extends Sharing_Source { class Share_Pinterest extends Sharing_Source { public $shortname = 'pinterest'; - public $genericon = '\f209'; + public $icon = '\f209'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1599,7 +1613,7 @@ class Share_Pinterest extends Sharing_Source { class Share_Pocket extends Sharing_Source { public $shortname = 'pocket'; - public $genericon = '\f224'; + public $icon = '\f224'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); @@ -1699,13 +1713,13 @@ class Jetpack_Share_WhatsApp extends Sharing_Source { } public function get_display( $post ) { - return $this->get_link( 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) ) . ' ' . rawurlencode( $this->get_share_url( $post->ID ) ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ) ); + return $this->get_link( 'https://api.whatsapp.com/send?text=' . rawurlencode( $this->get_share_title( $post->ID ) . ' ' . $this->get_share_url( $post->ID ) ), _x( 'WhatsApp', 'share to', 'jetpack' ), __( 'Click to share on WhatsApp', 'jetpack' ) ); } } class Share_Skype extends Sharing_Source { public $shortname = 'skype'; - public $genericon = '\f220'; + public $icon = '\f220'; private $share_type = 'default'; public function __construct( $id, array $settings ) { @@ -1720,6 +1734,7 @@ class Share_Skype extends Sharing_Source { } else { $this->smart = false; } + } public function get_name() { @@ -1741,7 +1756,7 @@ class Share_Skype extends Sharing_Source { sharing_register_post_for_share_counts( $post->ID ); } return $this->get_link( - $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID ); + $this->get_process_request_url( $post->ID ), _x( 'Skype', 'share to', 'jetpack' ), __( 'Click to share on Skype', 'jetpack' ), 'share=skype', 'sharing-skype-' . $post->ID ); } public function process_request( $post, array $post_data ) { @@ -1761,26 +1776,26 @@ class Share_Skype extends Sharing_Source { public function display_footer() { if ( $this->smart ) : - ?> - - + + js_dialog( $this->shortname, array( 'width' => 305, 'height' => 665 ) ); endif; diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js index fd7d47b9..9d8d5c5d 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing.js +++ b/plugins/jetpack/modules/sharedaddy/sharing.js @@ -22,14 +22,14 @@ if ( sharing_js_options && sharing_js_options.counts ) { // Pinterest handles share counts for both http and https pinterest: [ window.location.protocol + - '//api.pinterest.com/v1/urls/count.json?callback=WPCOMSharing.update_pinterest_count&url=' + - encodeURIComponent( url ) + '//api.pinterest.com/v1/urls/count.json?callback=WPCOMSharing.update_pinterest_count&url=' + + encodeURIComponent( url ) ], // Facebook protocol summing has been shown to falsely double counts, so we only request the current URL facebook: [ window.location.protocol + - '//graph.facebook.com/?callback=WPCOMSharing.update_facebook_count&ids=' + - encodeURIComponent( url ) + '//graph.facebook.com/?callback=WPCOMSharing.update_facebook_count&ids=' + + encodeURIComponent( url ) ] }; @@ -333,6 +333,10 @@ if ( sharing_js_options && sharing_js_options.counts ) { // Email button $( 'a.share-email', this ).on( 'click', function() { var url = $( this ).attr( 'href' ); + var currentDomain = window.location.protocol + '//' + window.location.hostname + '/'; + if ( url.indexOf( currentDomain ) !== 0 ) { + return true; + } if ( $sharing_email.is( ':visible' ) ) { $sharing_email.slideUp( 200 ); diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php index f6a6bebd..c6f57436 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing.php +++ b/plugins/jetpack/modules/sharedaddy/sharing.php @@ -1,12 +1,11 @@

- +

@@ -457,7 +465,7 @@ class Sharing_Admin { - + loading diff --git a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php index 8555da37..8912c936 100644 --- a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php +++ b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php @@ -242,7 +242,7 @@ class Filter_Embedded_HTML_Objects { } static function get_attrs( $html ) { - if ( ! ( function_exists( 'libxml_use_internal_errors' ) && function_exists( 'simplexml_load_string' ) ) ) { + if ( ! ( class_exists( 'DOMDocument' ) && function_exists( 'libxml_use_internal_errors' ) && function_exists( 'simplexml_load_string' ) ) ) { trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); return array(); } diff --git a/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css b/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css new file mode 100644 index 00000000..996d62fc --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css @@ -0,0 +1,16 @@ +.wp-block-jetpack-vr { + position: relative; + max-width: 525px; + margin-left: auto; + margin-right: auto; + overflow: hidden; +} + +iframe.wp-block-jetpack-vr { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + height: 100%; +} \ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/facebook.php b/plugins/jetpack/modules/shortcodes/facebook.php index ab7a04f4..9f787539 100644 --- a/plugins/jetpack/modules/shortcodes/facebook.php +++ b/plugins/jetpack/modules/shortcodes/facebook.php @@ -44,7 +44,10 @@ function jetpack_facebook_embed_handler( $matches, $attr, $url ) { // since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] ) { - return $embed . wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) ); + ob_start(); + wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) ); + $scripts = ob_get_clean(); + return $embed . $scripts; } else { wp_enqueue_script( 'jetpack-facebook-embed' ); return $embed; diff --git a/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js b/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js new file mode 100644 index 00000000..9466a671 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js @@ -0,0 +1,102 @@ +'use strict'; + +/* global wp */ +/* eslint react/react-in-jsx-scope: 0 */ + +(function (blocks, components, i18n) { + var registerBlockType = blocks.registerBlockType, + UrlInput = blocks.UrlInput; + var Placeholder = components.Placeholder, + SelectControl = components.SelectControl; + var __ = i18n.__; + + + registerBlockType('jetpack/vr', { + title: __('VR Image', 'jetpack'), + icon: 'embed-photo', + category: 'embed', + support: { + html: false + }, + attributes: { + url: { + type: 'string' + }, + view: { + type: 'string' + } + }, + + edit: function edit(props) { + var attributes = props.attributes; + + var onSetUrl = function onSetUrl(value) { + return props.setAttributes({ url: value }); + }; + var onSetView = function onSetView(value) { + return props.setAttributes({ view: value }); + }; + + var renderEdit = function renderEdit() { + if (attributes.url && attributes.view) { + return wp.element.createElement( + 'div', + { className: props.className }, + wp.element.createElement('iframe', { + title: __('VR Image', 'jetpack'), + allowFullScreen: 'true', + frameBorder: '0', + width: '100%', + height: '300', + src: 'https://vr.me.sh/view/?view=' + encodeURIComponent(attributes.view) + '&url=' + encodeURIComponent(attributes.url) + }) + ); + } + return wp.element.createElement( + 'div', + null, + wp.element.createElement( + Placeholder, + { + key: 'placeholder', + instructions: __('Enter URL to VR image', 'jetpack'), + icon: 'format-image', + label: __('VR Image', 'jetpack'), + className: props.className + }, + wp.element.createElement(UrlInput, { + value: attributes.url, + onChange: onSetUrl + }), + wp.element.createElement( + 'div', + { style: { marginTop: '10px' } }, + wp.element.createElement(SelectControl, { + label: __('View Type', 'jetpack'), + value: attributes.view, + onChange: onSetView, + options: [{ label: '', value: '' }, { label: __('360', 'jetpack'), value: '360' }, { label: __('Cinema', 'jetpack'), value: 'cinema' }] + }) + ) + ) + ); + }; + + return renderEdit(); + }, + save: function save(props) { + return wp.element.createElement( + 'div', + { className: props.className }, + wp.element.createElement('iframe', { + title: __('VR Image', 'jetpack'), + allowFullScreen: 'true', + frameBorder: '0', + width: '100%', + height: '300', + src: 'https://vr.me.sh/view/?view=' + encodeURIComponent(props.attributes.view) + '&url=' + encodeURIComponent(props.attributes.url) + }) + ); + } + }); +})(wp.blocks, wp.components, wp.i18n); \ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/mixcloud.php b/plugins/jetpack/modules/shortcodes/mixcloud.php index 8c244f17..ac5c3f01 100644 --- a/plugins/jetpack/modules/shortcodes/mixcloud.php +++ b/plugins/jetpack/modules/shortcodes/mixcloud.php @@ -9,44 +9,66 @@ * [mixcloud http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ width=640 height=480 /] * [mixcloud]http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/[/mixcloud] * [mixcloud]MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/[/mixcloud] + * [mixcloud http://www.mixcloud.com/mat/playlists/classics/ width=660 height=208 hide_cover=1 hide_tracklist=1] */ // Register oEmbed provider // Example URL: http://www.mixcloud.com/oembed/?url=http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ -wp_oembed_add_provider('#https?://(?:www\.)?mixcloud\.com/\S*#i', 'http://www.mixcloud.com/oembed', true); +wp_oembed_add_provider( '#https?://(?:www\.)?mixcloud\.com/\S*#i', 'https://www.mixcloud.com/oembed', true ); // Register mixcloud shortcode add_shortcode( 'mixcloud', 'mixcloud_shortcode' ); function mixcloud_shortcode( $atts, $content = null ) { - if ( empty( $atts[0] ) && empty( $content ) ) - return ""; + if ( empty( $atts[0] ) && empty( $content ) ) { + return ''; + } - $regular_expression = '#((?<=mixcloud.com/)([A-Za-z0-9%-]+/[A-Za-z0-9%-]+))|^([A-Za-z0-9%-]+/[A-Za-z0-9%-]+)#i'; + $regular_expression = '/((?<=mixcloud\\.com\\/)[\\w-\\/]+$)|(^[\\w-\\/]+$)/i'; preg_match( $regular_expression, $content, $match ); if ( ! empty( $match ) ) { $resource_id = trim( $match[0] ); } else { preg_match( $regular_expression, $atts[0], $match ); - if ( ! empty( $match ) ) + if ( ! empty( $match ) ) { $resource_id = trim( $match[0] ); + } + } + + if ( empty( $resource_id ) ) { + return ''; } - if ( empty( $resource_id ) ) - return ""; + $mixcloud_url = 'https://mixcloud.com/' . $resource_id; - $atts = shortcode_atts( array( - 'width' => 300, - 'height' => 300, - ), $atts, 'mixcloud' ); + $atts = shortcode_atts( + array( + 'width' => false, + 'height' => false, + 'color' => false, + 'light' => false, + 'dark' => false, + 'hide_tracklist' => false, + 'hide_cover' => false, + 'mini' => false, + 'hide_followers' => false, + 'hide_artwork' => false, + ), $atts + ); + // remove falsey values + $atts = array_filter( $atts ); - // Build URL - $url = add_query_arg( $atts, "http://api.mixcloud.com/$resource_id/embed-html/" ); - $head = wp_remote_head( $url ); - if ( is_wp_error( $head ) || 200 != $head['response']['code'] ) - return ""; + $query_args = array( 'url' => $mixcloud_url ); + $query_args = array_merge( $query_args, $atts ); + + $url = add_query_arg( urlencode_deep( $query_args ), 'https://www.mixcloud.com/oembed/' ); + $mixcloud_response = wp_remote_get( $url, array( 'redirection' => 0 ) ); + if ( is_wp_error( $mixcloud_response ) || 200 !== $mixcloud_response['response']['code'] || empty( $mixcloud_response['body'] ) ) { + return ''; + } - return sprintf( '', $atts['width'], $atts['height'], esc_url( $url ) ); + $response_body = json_decode( $mixcloud_response['body'] ); + return $response_body->html; } diff --git a/plugins/jetpack/modules/shortcodes/polldaddy.php b/plugins/jetpack/modules/shortcodes/polldaddy.php index b72866ce..609794ff 100644 --- a/plugins/jetpack/modules/shortcodes/polldaddy.php +++ b/plugins/jetpack/modules/shortcodes/polldaddy.php @@ -76,7 +76,7 @@ CONTAINER; /* * Polldaddy Poll Embed script - transforms code that looks like that: - * + * * * into the [polldaddy poll=...] shortcode format */ @@ -221,7 +221,7 @@ CONTAINER; - + SCRIPT; } else { if ( false === self::$scripts ) { @@ -338,7 +338,7 @@ SCRIPT;
- + CONTAINER; } @@ -496,13 +496,13 @@ CONTAINER; foreach( self::$scripts['rating'] as $rating ) { $script .= "PDRTJS_settings_{$rating['id']}{$rating['item_id']}={$rating['settings']}; if ( typeof PDRTJS_RATING !== 'undefined' ){if ( typeof PDRTJS_{$rating['id']}{$rating['item_id']} == 'undefined' ){PDRTJS_{$rating['id']}{$rating['item_id']} = new PDRTJS_RATING( PDRTJS_settings_{$rating['id']}{$rating['item_id']} );}}"; } - $script .= "\n//-->"; + $script .= "\n//-->"; } if ( isset( self::$scripts['poll'] ) ) { foreach( self::$scripts['poll'] as $poll ) { - $script .= ""; + $script .= ""; } } } @@ -544,6 +544,7 @@ CONTAINER; if ( !d.getElementById( j ) ) { var pd = d.createElement( c ), s; pd.id = j; + pd.async = true; pd.src = '{$script_url}'; s = d.getElementsByTagName( c )[0]; s.parentNode.insertBefore( pd, s ); @@ -565,7 +566,7 @@ new PolldaddyShortcode(); if ( ! function_exists( 'polldaddy_link' ) ) { // http://polldaddy.com/poll/1562975/?view=results&msg=voted function polldaddy_link( $content ) { - return jetpack_preg_replace_outside_tags( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n\n", $content, 'polldaddy.com/poll' ); + return jetpack_preg_replace_outside_tags( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n\n", $content, 'polldaddy.com/poll' ); } // higher priority because we need it before auto-link and autop get to it diff --git a/plugins/jetpack/modules/shortcodes/vr.php b/plugins/jetpack/modules/shortcodes/vr.php index 15906c70..12835b8a 100644 --- a/plugins/jetpack/modules/shortcodes/vr.php +++ b/plugins/jetpack/modules/shortcodes/vr.php @@ -97,7 +97,6 @@ function jetpack_vr_viewer_get_html( $url_params ) { * @return html - complete vr viewer html */ function jetpack_vr_viewer_shortcode( $atts ) { - $params = shortcode_atts( array( 0 => null, 'url' => null, @@ -129,3 +128,29 @@ function jetpack_vr_viewer_shortcode( $atts ) { } add_shortcode( 'vr', 'jetpack_vr_viewer_shortcode' ); + +// Gutenberg! +add_action( 'admin_init', 'jetpack_register_block_type_vr' ); +function jetpack_register_block_type_vr() { + if ( ! function_exists( 'register_block_type' ) ) { + return; + } + + wp_register_script( + 'jetpack_vr_viewer_shortcode_editor_script', + Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/blocks/vr-block.min.js', 'modules/shortcodes/js/blocks/vr-block.js' ), + array( 'wp-blocks', 'wp-element', 'wp-i18n' ) + ); + + wp_register_style( + 'jetpack_vr_viewer_shortcode_editor_style', + plugins_url( 'modules/shortcodes/css/blocks/vr-block.css', JETPACK__PLUGIN_FILE ), + array( 'wp-edit-blocks' ) + ); + + register_block_type( 'jetpack/vr', array( + 'editor_script' => 'jetpack_vr_viewer_shortcode_editor_script', + 'editor_style' => 'jetpack_vr_viewer_shortcode_editor_style', + 'render_callback' => 'jetpack_vr_viewer_shortcode', + ) ); +} \ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/wordads.php b/plugins/jetpack/modules/shortcodes/wordads.php new file mode 100644 index 00000000..7306eb77 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/wordads.php @@ -0,0 +1,67 @@ +' . __( 'The WordAds module is not active', 'jetpack' ) . '
'; + } + + $html = '
'; + + $html .= '
'; + + $html = $wordads->insert_inline_ad( $html ); + + return $html; + } +} + +new Jetpack_WordAds_Shortcode(); diff --git a/plugins/jetpack/modules/sitemaps/sitemap-builder.php b/plugins/jetpack/modules/sitemaps/sitemap-builder.php index 55358c8a..2af3b749 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-builder.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-builder.php @@ -130,7 +130,9 @@ class Jetpack_Sitemap_Builder { } for ( $i = 1; $i <= JP_SITEMAP_UPDATE_SIZE; $i++ ) { - $this->build_next_sitemap_file(); + if ( true === $this->build_next_sitemap_file() ) { + break; // All finished! + } } if ( $this->logger ) { @@ -146,14 +148,18 @@ class Jetpack_Sitemap_Builder { * constructs the next file, and updates the state. * * @since 4.8.0 + * + * @return bool True when finished. */ private function build_next_sitemap_file() { + $finished = false; // Initialize finished flag. + // Get the most recent state, and lock the state. $state = Jetpack_Sitemap_State::check_out(); // Do nothing if the state was locked. if ( false === $state ) { - return; + return false; } // Otherwise, branch on the sitemap-type key of $state. @@ -218,19 +224,23 @@ class Jetpack_Sitemap_Builder { $this->logger->report( '-- Finished.' ); $this->logger->time(); } + $finished = true; - die(); + break; default: - // Otherwise, reset the state. Jetpack_Sitemap_State::reset( JP_PAGE_SITEMAP_TYPE ); - die(); + $finished = true; + + break; } // End switch(). // Unlock the state. Jetpack_Sitemap_State::unlock(); + + return $finished; } /** @@ -510,7 +520,7 @@ class Jetpack_Sitemap_Builder { * } */ public function build_one_page_sitemap( $number, $from_id ) { - $last_post_id = $from_id; + $last_post_id = $from_id; $any_posts_left = true; if ( $this->logger ) { @@ -547,7 +557,7 @@ class Jetpack_Sitemap_Builder { } // Add as many items to the buffer as possible. - while ( false === $buffer->is_full() ) { + while ( $last_post_id >= 0 && false === $buffer->is_full() ) { $posts = $this->librarian->query_posts_after_id( $last_post_id, JP_SITEMAP_BATCH_SIZE ); @@ -569,6 +579,60 @@ class Jetpack_Sitemap_Builder { } } + // Handle other page sitemap URLs. + if ( false === $any_posts_left || $last_post_id < 0 ) { + // Negative IDs are used to track URL indexes. + $last_post_id = min( 0, $last_post_id ); + $any_posts_left = true; // Reinitialize. + + /** + * Filter other page sitemap URLs. + * + * @module sitemaps + * + * @since 6.1.0 + * + * @param array $urls An array of other URLs. + */ + $other_urls = apply_filters( 'jetpack_page_sitemap_other_urls', array() ); + + if ( $other_urls ) { // Start with index [1]. + $other_urls = array_values( $other_urls ); + array_unshift( $other_urls, $other_urls[0] ); + unset( $other_urls[0] ); + } + + // Add as many items to the buffer as possible. + while ( false === $buffer->is_full() ) { + $last_post_id_index = abs( $last_post_id ); + $start_from_post_id_index = $last_post_id_index ? $last_post_id_index + 1 : 0; + $urls = array_slice( + $other_urls, + $start_from_post_id_index, + JP_SITEMAP_BATCH_SIZE, + true + ); + + if ( ! $urls ) { + $any_posts_left = false; + break; + } + + foreach ( $urls as $index => $url ) { + if ( ! is_array( $url ) ) { + $url = array( 'loc' => $url ); + } + $item = array( 'xml' => compact( 'url' ) ); + + if ( true === $buffer->append( $item['xml'] ) ) { + $last_post_id = -$index; + } else { + break; + } + } + } + } + // If no items were added, return false. if ( true === $buffer->is_empty() ) { return false; diff --git a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php index f56a0ff8..4c41d095 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php @@ -325,10 +325,11 @@ class Jetpack_Sitemap_Librarian { "SELECT * FROM $wpdb->posts WHERE post_type='attachment' - AND post_mime_type IN ('image/jpeg','image/png','image/gif') + AND post_mime_type LIKE %s AND ID>%d ORDER BY ID ASC LIMIT %d;", + 'image/%', $from_id, $num_posts ) @@ -357,10 +358,11 @@ class Jetpack_Sitemap_Librarian { "SELECT * FROM $wpdb->posts WHERE post_type='attachment' - AND post_mime_type IN ('video/mpeg','video/wmv','video/mov','video/avi','video/ogg') + AND post_mime_type LIKE %s AND ID>%d ORDER BY ID ASC LIMIT %d;", + 'video/%', $from_id, $num_posts ) diff --git a/plugins/jetpack/modules/sitemaps/sitemaps.php b/plugins/jetpack/modules/sitemaps/sitemaps.php index 2c433a1d..d6fecb25 100644 --- a/plugins/jetpack/modules/sitemaps/sitemaps.php +++ b/plugins/jetpack/modules/sitemaps/sitemaps.php @@ -87,7 +87,8 @@ class Jetpack_Sitemap_Manager { // Add callback for sitemap URL handler. add_action( 'init', - array( $this, 'callback_action_catch_sitemap_urls' ) + array( $this, 'callback_action_catch_sitemap_urls' ), + defined( 'IS_WPCOM' ) && IS_WPCOM ? 100 : 10 ); // Add generator to wp_cron task list. diff --git a/plugins/jetpack/modules/sso.php b/plugins/jetpack/modules/sso.php index f84ba42e..eddd6e97 100644 --- a/plugins/jetpack/modules/sso.php +++ b/plugins/jetpack/modules/sso.php @@ -436,14 +436,14 @@ class Jetpack_SSO { time() + HOUR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, - false, + is_ssl(), true ); if ( ! empty( $_GET['redirect_to'] ) ) { // If we have something to redirect to $url = esc_url_raw( $_GET['redirect_to'] ); - setcookie( 'jetpack_sso_redirect_to', $url, time() + HOUR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, false, true ); + setcookie( 'jetpack_sso_redirect_to', $url, time() + HOUR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true ); } elseif ( ! empty( $_COOKIE['jetpack_sso_redirect_to'] ) ) { // Otherwise, if it's already set, purge it. setcookie( 'jetpack_sso_redirect_to', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); @@ -539,7 +539,8 @@ class Jetpack_SSO { ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } @@ -549,7 +550,8 @@ class Jetpack_SSO { ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } } @@ -567,7 +569,8 @@ class Jetpack_SSO { ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } @@ -577,7 +580,8 @@ class Jetpack_SSO { ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } @@ -587,7 +591,8 @@ class Jetpack_SSO { ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } } @@ -637,7 +642,8 @@ class Jetpack_SSO { $nonce, time() + ( 10 * MINUTE_IN_SECONDS ), COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } @@ -1043,7 +1049,8 @@ class Jetpack_SSO { $user_data->display_name, time() + WEEK_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); setcookie( @@ -1054,7 +1061,8 @@ class Jetpack_SSO { ), time() + WEEK_IN_SECONDS, COOKIEPATH, - COOKIE_DOMAIN + COOKIE_DOMAIN, + is_ssl() ); } diff --git a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php index 1bf2617c..307e3786 100644 --- a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php +++ b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php @@ -250,10 +250,11 @@ class Jetpack_SSO_Helpers { * @module sso * * @since 4.4.0 + * @since 6.1.0 Fixed a typo. Filter was previously jetpack_sso_auth_cookie_expirtation. * * @param int YEAR_IN_SECONDS */ - return intval( apply_filters( 'jetpack_sso_auth_cookie_expirtation', YEAR_IN_SECONDS ) ); + return intval( apply_filters( 'jetpack_sso_auth_cookie_expiration', YEAR_IN_SECONDS ) ); } /** diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php index 1f349527..fd20f517 100644 --- a/plugins/jetpack/modules/stats.php +++ b/plugins/jetpack/modules/stats.php @@ -90,6 +90,33 @@ function stats_enqueue_dashboard_head() { add_action( 'admin_head', 'stats_dashboard_head' ); } +/** + * Checks if filter is set and dnt is enabled. + * + * @return bool + */ +function jetpack_is_dnt_enabled() { + /** + * Filter the option which decides honor DNT or not. + * + * @module stats + * @since 6.1.0 + * + * @param bool false Honors DNT for clients who don't want to be tracked. Defaults to false. Set to true to enable. + */ + if ( false === apply_filters( 'jetpack_honor_dnt_header_for_stats', false ) ) { + return false; + } + + foreach ( $_SERVER as $name => $value ) { + if ( 'http_dnt' == strtolower( $name ) && 1 == $value ) { + return true; + } + } + + return false; +} + /** * Prevent sparkline img requests being redirected to upgrade.php. * See wp-admin/admin.php where it checks $wp_db_version. @@ -142,9 +169,9 @@ function stats_map_meta_caps( $caps, $cap, $user_id ) { * @return void */ function stats_template_redirect() { - global $current_user, $stats_footer; + global $current_user, $rendered_stats_footer; - if ( is_feed() || is_robots() || is_trackback() || is_preview() ) { + if ( is_feed() || is_robots() || is_trackback() || is_preview() || jetpack_is_dnt_enabled() ) { return; } @@ -159,19 +186,7 @@ function stats_template_redirect() { add_action( 'wp_footer', 'stats_footer', 101 ); add_action( 'wp_head', 'stats_add_shutdown_action' ); - $script = 'https://stats.wp.com/e-' . gmdate( 'YW' ) . '.js'; - $data = stats_build_view_data(); - $data_stats_array = stats_array( $data ); - - $stats_footer = << - - -END; + $rendered_stats_footer = false; } @@ -228,9 +243,45 @@ function stats_add_shutdown_action() { * @return void */ function stats_footer() { - global $stats_footer; + global $rendered_stats_footer; + + if ( ! $rendered_stats_footer ) { + $data = stats_build_view_data(); + if ( Jetpack_AMP_Support::is_amp_request() ) { + stats_render_amp_footer( $data ); + } else { + stats_render_footer( $data ); + } + $rendered_stats_footer = true; + } +} + +function stats_render_footer( $data ) { + $script = 'https://stats.wp.com/e-' . gmdate( 'YW' ) . '.js'; + $data_stats_array = stats_array( $data ); + + $stats_footer = << + + +END; print $stats_footer; - $stats_footer = ''; +} + +function stats_render_amp_footer( $data ) { + $data['host'] = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; // input var ok. + $data['rand'] = 'RANDOM'; // AMP placeholder. + $data['ref'] = 'DOCUMENT_REFERRER'; // AMP placeholder. + $data = array_map( 'rawurlencode', $data ); + $pixel_url = add_query_arg( $data, 'https://pixel.wp.com/g.gif' ); + + ?> + +