summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
committerAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
commita6b006c0f1ef757f23375f7906193370337d8bd7 (patch)
tree4467c6423b2c54e6ef8c3e79241a833fb17833a5 /plugins/jetpack/modules
parentUpdate akismet 4.0.7 (diff)
downloadblogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.gz
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.bz2
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.zip
Update jetpack 6.2
Diffstat (limited to 'plugins/jetpack/modules')
-rw-r--r--plugins/jetpack/modules/carousel/jetpack-carousel.js4
-rw-r--r--plugins/jetpack/modules/carousel/jetpack-carousel.php4
-rw-r--r--plugins/jetpack/modules/comment-likes.php4
-rw-r--r--plugins/jetpack/modules/contact-form/admin.php4
-rw-r--r--plugins/jetpack/modules/contact-form/grunion-contact-form.php214
-rw-r--r--plugins/jetpack/modules/contact-form/js/editor-view.js5
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy.php5
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php21
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/class.csstidy_print.php4
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css.php2
-rw-r--r--plugins/jetpack/modules/custom-post-types/comics.php4
-rw-r--r--plugins/jetpack/modules/custom-post-types/nova.php4
-rw-r--r--plugins/jetpack/modules/custom-post-types/portfolios.php77
-rw-r--r--plugins/jetpack/modules/custom-post-types/testimonial.php5
-rw-r--r--plugins/jetpack/modules/google-analytics.php2
-rw-r--r--plugins/jetpack/modules/google-analytics/classes/wp-google-analytics-universal.php20
-rw-r--r--plugins/jetpack/modules/gravatar-hovercards.php4
-rw-r--r--plugins/jetpack/modules/infinite-scroll/infinity.js17
-rw-r--r--plugins/jetpack/modules/infinite-scroll/infinity.php71
-rw-r--r--plugins/jetpack/modules/lazy-images.php2
-rw-r--r--plugins/jetpack/modules/lazy-images/js/lazy-images.js42
-rw-r--r--plugins/jetpack/modules/lazy-images/lazy-images.php3
-rw-r--r--plugins/jetpack/modules/likes.php33
-rw-r--r--plugins/jetpack/modules/likes/jetpack-likes-master-iframe.php2
-rw-r--r--plugins/jetpack/modules/likes/jetpack-likes-settings.php15
-rw-r--r--plugins/jetpack/modules/markdown/easy-markdown.php50
-rw-r--r--plugins/jetpack/modules/masterbar/masterbar.php22
-rw-r--r--plugins/jetpack/modules/monitor.php2
-rw-r--r--plugins/jetpack/modules/protect.php2
-rw-r--r--plugins/jetpack/modules/publicize.php233
-rw-r--r--plugins/jetpack/modules/publicize/assets/publicize-rtl.css1
-rw-r--r--plugins/jetpack/modules/publicize/assets/publicize-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/publicize/assets/publicize.css1
-rw-r--r--plugins/jetpack/modules/publicize/assets/publicize.min.css2
-rw-r--r--plugins/jetpack/modules/publicize/assets/rtl/publicize-rtl.css3
-rw-r--r--plugins/jetpack/modules/publicize/enhanced-open-graph.php4
-rw-r--r--plugins/jetpack/modules/publicize/publicize-jetpack.php25
-rw-r--r--plugins/jetpack/modules/publicize/publicize.php148
-rw-r--r--plugins/jetpack/modules/publicize/ui.php4
-rw-r--r--plugins/jetpack/modules/related-posts/class.related-posts-customize.php4
-rw-r--r--plugins/jetpack/modules/related-posts/jetpack-related-posts.php12
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search.php15
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php2
-rw-r--r--plugins/jetpack/modules/sharedaddy/recaptcha.php9
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-service.php31
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing-sources.php93
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js12
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.php24
-rw-r--r--plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css16
-rw-r--r--plugins/jetpack/modules/shortcodes/facebook.php5
-rw-r--r--plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js102
-rw-r--r--plugins/jetpack/modules/shortcodes/mixcloud.php56
-rw-r--r--plugins/jetpack/modules/shortcodes/polldaddy.php13
-rw-r--r--plugins/jetpack/modules/shortcodes/vr.php27
-rw-r--r--plugins/jetpack/modules/shortcodes/wordads.php67
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-builder.php78
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-librarian.php6
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemaps.php3
-rw-r--r--plugins/jetpack/modules/sso.php28
-rw-r--r--plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php3
-rw-r--r--plugins/jetpack/modules/stats.php135
-rw-r--r--plugins/jetpack/modules/subscriptions.php21
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentysixteen-rtl.css66
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentysixteen.css66
-rw-r--r--plugins/jetpack/modules/theme-tools/compat/twentysixteen.php16
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/blog-display.php10
-rw-r--r--plugins/jetpack/modules/theme-tools/content-options/featured-images.php25
-rw-r--r--plugins/jetpack/modules/theme-tools/featured-content.php27
-rw-r--r--plugins/jetpack/modules/theme-tools/responsive-videos.php11
-rw-r--r--plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php18
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css1
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.css1
-rw-r--r--plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css2
-rw-r--r--plugins/jetpack/modules/widgets/customizer-utils.js11
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law.php90
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js30
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js16
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/form.php226
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/style.css19
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/widget.php12
-rw-r--r--plugins/jetpack/modules/widgets/google-translate.php23
-rw-r--r--plugins/jetpack/modules/widgets/gravatar-profile.php10
-rw-r--r--plugins/jetpack/modules/widgets/social-icons.php10
-rw-r--r--plugins/jetpack/modules/widgets/social-icons/social-icons.css18
-rw-r--r--plugins/jetpack/modules/widgets/top-posts.php7
-rw-r--r--plugins/jetpack/modules/widgets/twitter-timeline.php72
-rw-r--r--plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php14
-rw-r--r--plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php2
-rw-r--r--plugins/jetpack/modules/wordads/php/api.php18
-rw-r--r--plugins/jetpack/modules/wordads/php/params.php16
-rw-r--r--plugins/jetpack/modules/wordads/php/widgets.php3
-rw-r--r--plugins/jetpack/modules/wordads/wordads.php170
94 files changed, 2051 insertions, 792 deletions
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,
+ '<span id="infinite-scroll-options">' . esc_html__( 'Infinite Scroll Behavior', 'jetpack' ) . '</span>',
+ 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, '<span id="infinite-scroll-options">' . esc_html__( 'Infinite Scroll Behavior', 'jetpack' ) . '</span>', 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 '<span>' . 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.' ),
+ '<a href="' . esc_url( 'https://wordpress.com/settings/writing/' . $details->domain ) . '">',
+ '</a>'
+ ) . '</span>';
+ }
+
/**
* 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
*
@@ -164,21 +178,6 @@ class Jetpack_Likes {
}
/**
- * 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 ); ?>
- <p>
- <label for="wpl_enable_post_sharing">
- <input type="checkbox" name="wpl_enable_post_sharing" id="wpl_enable_post_sharing" value="1" <?php checked( !$disabled ); ?>>
- <?php _e( 'Show sharing buttons.', 'jetpack' ); ?>
- </label>
- <input type="hidden" name="wpl_sharing_status_hidden" value="1" />
- </p> <?php
- }
-
- /**
* Options to be added to the discussion page (see also admin_settings_init, etc below for Sharing settings page)
*/
@@ -259,6 +258,10 @@ class Jetpack_Likes {
return;
}
+ if ( Jetpack_AMP_Support::is_amp_request() ) {
+ return;
+ }
+
if ( $this->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
@@ -157,6 +157,21 @@ class Jetpack_Likes_Settings {
}
/**
+ * 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 ); ?>
+ <p>
+ <label for="wpl_enable_post_sharing">
+ <input type="checkbox" name="wpl_enable_post_sharing" id="wpl_enable_post_sharing" value="1" <?php checked( !$disabled ); ?>>
+ <?php _e( 'Show sharing buttons.', 'jetpack' ); ?>
+ </label>
+ <input type="hidden" name="wpl_sharing_status_hidden" value="1" />
+ </p> <?php
+ }
+
+ /**
* Adds the 'sharing' menu to the settings menu.
* Only ran if sharedaddy and publicize are not already active.
*/
diff --git a/plugins/jetpack/modules/markdown/easy-markdown.php b/plugins/jetpack/modules/markdown/easy-markdown.php
index 824be5e9..65e4685e 100644
--- a/plugins/jetpack/modules/markdown/easy-markdown.php
+++ b/plugins/jetpack/modules/markdown/easy-markdown.php
@@ -115,6 +115,8 @@ class WPCom_Markdown {
* @return null
*/
public function load_markdown_for_posts() {
+ add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
+ add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
add_action( 'wp_insert_post', array( $this, 'wp_insert_post' ) );
add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );
add_filter( 'edit_post_content', array( $this, 'edit_post_content' ), 10, 2 );
@@ -133,6 +135,8 @@ class WPCom_Markdown {
* @return null
*/
public function unload_markdown_for_posts() {
+ remove_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ) );
+ remove_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
remove_action( 'wp_insert_post', array( $this, 'wp_insert_post' ) );
remove_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 10, 2 );
remove_filter( 'edit_post_content', array( $this, 'edit_post_content' ), 10, 2 );
@@ -416,6 +420,52 @@ class WPCom_Markdown {
}
/**
+ * Some tags are allowed to have a 'markdown' attribute, allowing them to contain Markdown.
+ * We need to tell KSES about those tags.
+ * @param array $tags List of tags that KSES allows.
+ * @param string $context The context that KSES is allowing these tags.
+ * @return array The tags that KSES allows, with our extra 'markdown' parameter where necessary.
+ */
+ public function wp_kses_allowed_html( $tags, $context ) {
+ if ( 'post' !== $context ) {
+ return $tags;
+ }
+
+ $re = '/' . $this->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() {
+?>
+<script type="text/javascript">
+jQuery( function() {
+ tinymce.on( 'AddEditor', function( event ) {
+ event.editor.on( 'BeforeSetContent', function( event ) {
+ var editor = event.target;
+ Object.keys( editor.schema.elements ).forEach( function( key, index ) {
+ editor.schema.elements[ key ].attributes['markdown'] = {};
+ editor.schema.elements[ key ].attributesOrder.push( 'markdown' );
+ } );
+ } );
+ }, true );
+} );
+</script>
+<?php
+ }
+
+ /**
* Magic happens here. Markdown is converted and stored on post_content. Original Markdown is stored
* in post_content_filtered so that we can continue editing as Markdown.
* @param array $post_data The post data that will be inserted into the DB. Slashed.
diff --git a/plugins/jetpack/modules/masterbar/masterbar.php b/plugins/jetpack/modules/masterbar/masterbar.php
index 5045047b..0ad65937 100644
--- a/plugins/jetpack/modules/masterbar/masterbar.php
+++ b/plugins/jetpack/modules/masterbar/masterbar.php
@@ -509,17 +509,7 @@ class A8C_WPCOM_Masterbar {
'class' => '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() ) {
@@ -873,14 +863,14 @@ 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() {
?>
- <p><?php esc_html_e( 'Nobody likes downtime, and that\'s why Jetpack Monitor is on the job, keeping tabs on your site by checking it every five minutes. As soon as any downtime is detected, you will receive an email notification alerting you to the issue. That way you can act quickly, to get your site back online again!', 'jetpack' ); ?>
+ <p><?php esc_html_e( 'Nobody likes downtime, and that\'s why Downtime Monitor is on the job, keeping tabs on your site by checking it every five minutes. As soon as any downtime is detected, you will receive an email notification alerting you to the issue. That way you can act quickly, to get your site back online again!', 'jetpack' ); ?>
<p><?php esc_html_e( 'We’ll also let you know as soon as your site is up and running, so you can keep an eye on total downtime.', 'jetpack'); ?></p>
<div class="narrow">
<?php if ( Jetpack::is_user_connected() && current_user_can( 'manage_options' ) ) : ?>
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)[^>]*?>.*?</\\1>@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( "<html><body>$string</body></html>" );
- 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( '/^<!DOCTYPE.+?>/', '', $string );
- $string = str_replace( array('<html>', '</html>', '<body>', '</body>' ), 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: <body>, 7: </body>
-
- 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: '<p>X{\xE2\x80\xA6}</p>'
- $new_string .= '<p>' . self::crop_str( $node->textContent, $append_string_length - 8 ) . '</p>';
- }
-
- // Clean up any empty Paragraphs that might have occurred after removing their children
- return trim( preg_replace( '#<p>\s*</p>#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)[^>]*?>.*?</\\1>@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( ' <a href="%1$s">%2$s</a>',
+ 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 ) :
- ?>
- <script>
- (function(r, d, s) {
- r.loadSkypeWebSdkAsync = r.loadSkypeWebSdkAsync || function(p) {
- var js, sjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(p.id)) { return; }
- js = d.createElement(s);
- js.id = p.id;
- js.src = p.scriptToLoad;
- js.onload = p.callback
- sjs.parentNode.insertBefore(js, sjs);
- };
- var p = {
- scriptToLoad: 'https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js',
- id: 'skype_web_sdk'
- };
- r.loadSkypeWebSdkAsync(p);
- })(window, document, 'script');
- </script>
- <?php
+ ?>
+ <script>
+ (function(r, d, s) {
+ r.loadSkypeWebSdkAsync = r.loadSkypeWebSdkAsync || function(p) {
+ var js, sjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(p.id)) { return; }
+ js = d.createElement(s);
+ js.id = p.id;
+ js.src = p.scriptToLoad;
+ js.onload = p.callback
+ sjs.parentNode.insertBefore(js, sjs);
+ };
+ var p = {
+ scriptToLoad: 'https://swx.cdn.skype.com/shared/v/latest/skypewebsdk.js',
+ id: 'skype_web_sdk'
+ };
+ r.loadSkypeWebSdkAsync(p);
+ })(window, document, 'script');
+ </script>
+ <?php
else :
$this->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 @@
<?php
+if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
+ define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
+ define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
+}
class Sharing_Admin {
public function __construct() {
- if ( ! defined( 'WP_SHARING_PLUGIN_URL' ) ) {
- define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
- define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
- }
-
require_once WP_SHARING_PLUGIN_DIR . 'sharing-service.php';
add_action( 'admin_init', array( &$this, 'admin_init' ) );
@@ -32,7 +31,16 @@ class Sharing_Admin {
array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ),
2
);
- $postfix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
+
+ /**
+ * Filters the switch that if set to true allows Jetpack to use minified assets. Defaults to true
+ * if the SCRIPT_DEBUG constant is not set or set to false. The filter overrides it.
+ *
+ * @since 6.2.0
+ *
+ * @param boolean $var should Jetpack use minified assets.
+ */
+ $postfix = apply_filters( 'jetpack_should_use_minified_assets', true ) ? '.min' : '';
if ( is_rtl() ) {
wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL . 'admin-sharing-rtl' . $postfix . '.css', false, JETPACK__VERSION );
} else {
@@ -422,7 +430,7 @@ class Sharing_Admin {
</table>
<p class="submit">
- <input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'jetpack' ); ?>" />
+ <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'jetpack' ); ?>" />
</p>
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
@@ -457,7 +465,7 @@ class Sharing_Admin {
<tr valign="top" width="100">
<th scope="row"></th>
<td>
- <input type="submit" class="button-primary" value="<?php _e( 'Create Share Button', 'jetpack' ); ?>" />
+ <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Create Share Button', 'jetpack' ); ?>" />
<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</td>
</tr>
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 "<!-- mixcloud error: invalid mixcloud resource -->";
+ if ( empty( $atts[0] ) && empty( $content ) ) {
+ return '<!-- mixcloud error: invalid mixcloud resource -->';
+ }
- $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 '<!-- mixcloud error: invalid mixcloud resource -->';
}
- if ( empty( $resource_id ) )
- return "<!-- mixcloud error: invalid mixcloud resource -->";
+ $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 "<!-- mixcloud error: invalid mixcloud resource -->";
+ $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 '<!-- mixcloud error: invalid mixcloud resource -->';
+ }
- return sprintf( '<iframe width="%d" height="%d" scrolling="no" frameborder="no" src="%s"></iframe>', $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:
- * <script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/123456.js"></script>
+ * <script type="text/javascript" charset="utf-8" async src="http://static.polldaddy.com/p/123456.js"></script>
* <noscript><a href="http://polldaddy.com/poll/123456/">What is your favourite color?</a></noscript>
* into the [polldaddy poll=...] shortcode format
*/
@@ -221,7 +221,7 @@ CONTAINER;
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
PDRTJS_settings_{$rating}{$item_id}={$settings};
//--><!]]></script>
-<script type="text/javascript" charset="UTF-8" src="{$rating_js_file}"></script>
+<script type="text/javascript" charset="UTF-8" async src="{$rating_js_file}"></script>
SCRIPT;
} else {
if ( false === self::$scripts ) {
@@ -338,7 +338,7 @@ SCRIPT;
<a id="pd_a_{$poll}"></a>
<div class="PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div>
<div id="PD_superContainer"></div>
-<script type="text/javascript" charset="UTF-8" src="{$poll_js}{$cb}"></script>
+<script type="text/javascript" charset="UTF-8" async src="{$poll_js}{$cb}"></script>
<noscript>{$poll_link}</noscript>
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><script type='text/javascript' charset='UTF-8' src='{$rating_js_file}'></script>";
+ $script .= "\n//--><!]]></script><script type='text/javascript' charset='UTF-8' async src='{$rating_js_file}'></script>";
}
if ( isset( self::$scripts['poll'] ) ) {
foreach( self::$scripts['poll'] as $poll ) {
- $script .= "<script type='text/javascript' charset='UTF-8' src='{$poll['url']}'></script>";
+ $script .= "<script type='text/javascript' charset='UTF-8' async src='{$poll['url']}'></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<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content, 'polldaddy.com/poll' );
+ return jetpack_preg_replace_outside_tags( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' async src='//static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\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 @@
+<?php
+
+/**
+ * Embed WordAds 'ad' in post
+ *
+ */
+class Jetpack_WordAds_Shortcode {
+
+ private $scripts_and_style_included = false;
+
+ function __construct() {
+ add_action( 'init', array( $this, 'action_init' ) );
+ }
+
+ /**
+ * Register our shortcode and enqueue necessary files.
+ */
+ function action_init() {
+ global $wordads;
+
+ if ( empty( $wordads ) ) {
+ return null;
+ }
+ add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) );
+ }
+
+ /**
+ * Our [wordads] shortcode.
+ * Prints a WordAds Ad.
+ *
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
+ * @return string HTML for WordAds shortcode.
+ */
+ static function wordads_shortcode( $atts, $content = '' ) {
+ $atts = shortcode_atts( array(), $atts, 'wordads');
+
+ return self::wordads_shortcode_html( $atts, $content );
+ }
+
+ /**
+ * The shortcode output
+ *
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
+ * @return string HTML output
+ */
+ static function wordads_shortcode_html( $atts, $content = '' ) {
+ global $wordads;
+
+ if ( empty( $wordads ) ) {
+ return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>';
+ }
+
+ $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock">';
+
+ $html .= '</div>';
+
+ $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
@@ -91,6 +91,33 @@ function stats_enqueue_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
-<script type='text/javascript' src='{$script}' async='async' defer='defer'></script>
-<script type='text/javascript'>
- _stq = window._stq || [];
- _stq.push([ 'view', {{$data_stats_array}} ]);
- _stq.push([ 'clickTrackerInit', '{$data['blog']}', '{$data['post']}' ]);
-</script>
-
-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
+<script type='text/javascript' src='{$script}' async='async' defer='defer'></script>
+<script type='text/javascript'>
+ _stq = window._stq || [];
+ _stq.push([ 'view', {{$data_stats_array}} ]);
+ _stq.push([ 'clickTrackerInit', '{$data['blog']}', '{$data['post']}' ]);
+</script>
+
+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' );
+
+ ?>
+ <amp-pixel src="<?php echo esc_url( $pixel_url ); ?>"></amp-pixel>
+ <?php
}
/**
@@ -410,6 +461,10 @@ function stats_reports_load() {
wp_enqueue_script( 'postbox' );
wp_enqueue_script( 'underscore' );
+ $rtl = is_rtl() ? '.rtl' : '';
+ wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/admin.dops-style$rtl.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
+ wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min$rtl.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
+
add_action( 'admin_print_styles', 'stats_reports_css' );
if ( isset( $_GET['nojs'] ) && $_GET['nojs'] ) {
@@ -436,6 +491,20 @@ function stats_reports_load() {
function stats_reports_css() {
?>
<style type="text/css">
+#wpcontent {
+ padding-left: 0 !important;
+}
+
+.jetpack_page_stats {
+ background-color: #f3f6f8;
+}
+
+#jp-stats-wrap {
+ max-width: 720px;
+ margin: 0 auto;
+ overflow: hidden;
+}
+
#stats-loading-wrap p {
text-align: center;
font-size: 2em;
@@ -502,11 +571,25 @@ function stats_reports_page( $main_chart_only = false ) {
$blog_id = stats_get_option( 'blog_id' );
$domain = Jetpack::build_raw_urls( get_home_url() );
+ $jetpack_admin_url = admin_url() . 'admin.php?page=jetpack';
+
if ( ! $main_chart_only && ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) {
$nojs_url = add_query_arg( 'nojs', '1' );
$http = is_ssl() ? 'https' : 'http';
// Loading message. No JS fallback message.
?>
+<div id="jp-plugin-container">
+ <div class="jp-masthead">
+ <div class="jp-masthead__inside-container">
+ <div class="jp-masthead__logo-container">
+ <a class="jp-masthead__logo-link" href="<?php echo esc_url( $jetpack_admin_url ); ?>">
+ <svg class="jetpack-logo__masthead" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="32" viewBox="0 0 118 32"><path fill="#00BE28" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"></path><path d="M41.3,26.6c-0.5-0.7-0.9-1.4-1.3-2.1c2.3-1.4,3-2.5,3-4.6V8h-3V6h6v13.4C46,22.8,45,24.8,41.3,26.6z"></path><path d="M65,18.4c0,1.1,0.8,1.3,1.4,1.3c0.5,0,2-0.2,2.6-0.4v2.1c-0.9,0.3-2.5,0.5-3.7,0.5c-1.5,0-3.2-0.5-3.2-3.1V12H60v-2h2.1V7.1 H65V10h4v2h-4V18.4z"></path><path d="M71,10h3v1.3c1.1-0.8,1.9-1.3,3.3-1.3c2.5,0,4.5,1.8,4.5,5.6s-2.2,6.3-5.8,6.3c-0.9,0-1.3-0.1-2-0.3V28h-3V10z M76.5,12.3 c-0.8,0-1.6,0.4-2.5,1.2v5.9c0.6,0.1,0.9,0.2,1.8,0.2c2,0,3.2-1.3,3.2-3.9C79,13.4,78.1,12.3,76.5,12.3z"></path><path d="M93,22h-3v-1.5c-0.9,0.7-1.9,1.5-3.5,1.5c-1.5,0-3.1-1.1-3.1-3.2c0-2.9,2.5-3.4,4.2-3.7l2.4-0.3v-0.3c0-1.5-0.5-2.3-2-2.3 c-0.7,0-2.3,0.5-3.7,1.1L84,11c1.2-0.4,3-1,4.4-1c2.7,0,4.6,1.4,4.6,4.7L93,22z M90,16.4l-2.2,0.4c-0.7,0.1-1.4,0.5-1.4,1.6 c0,0.9,0.5,1.4,1.3,1.4s1.5-0.5,2.3-1V16.4z"></path><path d="M104.5,21.3c-1.1,0.4-2.2,0.6-3.5,0.6c-4.2,0-5.9-2.4-5.9-5.9c0-3.7,2.3-6,6.1-6c1.4,0,2.3,0.2,3.2,0.5V13 c-0.8-0.3-2-0.6-3.2-0.6c-1.7,0-3.2,0.9-3.2,3.6c0,2.9,1.5,3.8,3.3,3.8c0.9,0,1.9-0.2,3.2-0.7V21.3z"></path><path d="M110,15.2c0.2-0.3,0.2-0.8,3.8-5.2h3.7l-4.6,5.7l5,6.3h-3.7l-4.2-5.8V22h-3V6h3V15.2z"></path><path d="M58.5,21.3c-1.5,0.5-2.7,0.6-4.2,0.6c-3.6,0-5.8-1.8-5.8-6c0-3.1,1.9-5.9,5.5-5.9s4.9,2.5,4.9,4.9c0,0.8,0,1.5-0.1,2h-7.3 c0.1,2.5,1.5,2.8,3.6,2.8c1.1,0,2.2-0.3,3.4-0.7C58.5,19,58.5,21.3,58.5,21.3z M56,15c0-1.4-0.5-2.9-2-2.9c-1.4,0-2.3,1.3-2.4,2.9 C51.6,15,56,15,56,15z"></path></svg>
+ </a>
+ </div>
+ <div class="jp-masthead__nav"><span class="dops-button-group"><a href="<?php echo esc_url( $jetpack_admin_url ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Dashboard', 'jetpack' ); ?></a><a href="<?php echo esc_url( $jetpack_admin_url . '#/settings' ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a></span></div>
+ </div>
+ </div>
+ <div id="jp-stats-wrap">
<div class="wrap">
<h2><?php esc_html_e( 'Site Stats', 'jetpack' ); ?> <?php if ( current_user_can( 'jetpack_manage_modules' ) ) : ?><a style="font-size:13px;" href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack&configure=stats' ) ); ?>"><?php esc_html_e( 'Configure', 'jetpack' ); ?></a><?php endif; ?></h2>
</div>
@@ -528,6 +611,24 @@ function stats_reports_page( $main_chart_only = false ) {
<p class="hide-if-js"><?php esc_html_e( 'Your Site Stats work better with JavaScript enabled.', 'jetpack' ); ?><br />
<a href="<?php echo esc_url( $nojs_url ); ?>"><?php esc_html_e( 'View Site Stats without JavaScript', 'jetpack' ); ?></a>.</p>
</div>
+</div>
+<div class="jp-footer">
+ <ul class="jp-footer__links">
+ <li class="jp-footer__link-item">
+ <a href="https://jetpack.com" target="_blank" rel="noopener noreferrer" class="jp-footer__link" title="<?php esc_html_e( 'Jetpack version', 'jetpack' ); ?>">Jetpack <?php echo JETPACK__VERSION; ?></a>
+ </li>
+ <li class="jp-footer__link-item">
+ <a href="https://wordpress.com/tos/" target="_blank" rel="noopener noreferrer" title="<?php esc_html__( 'WordPress.com Terms of Service', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?></a>
+ </li>
+ <li class="jp-footer__link-item">
+ <a href="<?php echo esc_url( $jetpack_admin_url . '#/privacy' ); ?>" rel="noopener noreferrer" title="<?php esc_html_e( 'Automattic\'s Privacy Policy', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Privacy', 'Navigation item', 'jetpack' ); ?></a>
+ </li>
+ <li class="jp-footer__link-item">
+ <a href="<?php echo esc_url( admin_url() . 'admin.php?page=jetpack-debugger' ); ?>" title="<?php esc_html_e( 'Test your site\'s compatibility with Jetpack.', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Debug', 'Navigation item', 'jetpack' ); ?></a>
+ </li>
+ </ul>
+</div>
+</div>
<?php
return;
}
diff --git a/plugins/jetpack/modules/subscriptions.php b/plugins/jetpack/modules/subscriptions.php
index de7cd148..8db983d3 100644
--- a/plugins/jetpack/modules/subscriptions.php
+++ b/plugins/jetpack/modules/subscriptions.php
@@ -100,6 +100,8 @@ class Jetpack_Subscriptions {
add_action( 'transition_post_status', array( $this, 'maybe_send_subscription_email' ), 10, 3 );
add_filter( 'jetpack_published_post_flags', array( $this, 'set_post_flags' ), 10, 2 );
+
+ add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 );
}
/**
@@ -183,6 +185,24 @@ class Jetpack_Subscriptions {
}
}
+ function update_published_message( $messages ) {
+ global $post;
+ if ( ! $this->should_email_post_to_subscribers( $post ) ) {
+ return $messages;
+ }
+
+ $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
+ esc_url( get_permalink( $post ) ),
+ __( 'View post' ) // intentinally omitted domain
+ );
+
+ $messages['post'][6] = sprintf(
+ /* translators: Message shown after a post is published */
+ esc_html__( 'Post published and sending emails to subscribers.', 'jetpack' )
+ ) . $view_post_link_html;
+ return $messages;
+ }
+
public function should_email_post_to_subscribers( $post ) {
$should_email = true;
if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
@@ -320,7 +340,6 @@ class Jetpack_Subscriptions {
*/
function subscriptions_settings_section() {
?>
-
<p id="jetpack-subscriptions-settings"><?php _e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
<?php
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen-rtl.css b/plugins/jetpack/modules/theme-tools/compat/twentysixteen-rtl.css
index 8b0efbd3..a616269d 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen-rtl.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen-rtl.css
@@ -161,6 +161,72 @@
opacity: 0.8;
}
+/* Social Icons Widget */
+.widget.jetpack_widget_social_icons ul {
+ margin: 0 0 -0.4375em;
+}
+
+.widget.jetpack_widget_social_icons ul:before,
+.widget.jetpack_widget_social_icons ul:after {
+ content: "";
+ display: table;
+}
+
+.widget.jetpack_widget_social_icons ul:after {
+ clear: both;
+}
+
+.widget.jetpack_widget_social_icons li {
+ float: right;
+ margin: 0 0 0.4375em 0.4375em;
+}
+
+.widget.jetpack_widget_social_icons li a {
+ border: 1px solid currentColor;
+ border-radius: 50%;
+ color: inherit;
+ display: block;
+ position: relative;
+}
+
+.widget.jetpack_widget_social_icons li a:hover,
+.widget.jetpack_widget_social_icons li a:focus {
+ opacity: 0.8;
+}
+
+.widget.jetpack_widget_social_icons ul.size-small a {
+ height: 38px;
+ padding: 6px;
+ width: 38px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-small svg {
+ height: 24px;
+ width: 24px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-medium a {
+ height: 50px;
+ padding: 8px;
+ width: 50px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-medium svg {
+ height: 32px;
+ width: 32px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-large a {
+ height: 70px;
+ padding: 10px;
+ width: 70px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-large svg {
+ height: 48px;
+ width: 48px;
+}
+
/* Top Posts & Pages Widget */
.widget_top-posts .widgets-list-layout .widgets-list-layout-blavatar {
margin-top: 0.25em;
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
index 9495c9b3..672b264e 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
+++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.css
@@ -161,6 +161,72 @@
opacity: 0.8;
}
+/* Social Icons Widget */
+.widget.jetpack_widget_social_icons ul {
+ margin: 0 0 -0.4375em;
+}
+
+.widget.jetpack_widget_social_icons ul:before,
+.widget.jetpack_widget_social_icons ul:after {
+ content: "";
+ display: table;
+}
+
+.widget.jetpack_widget_social_icons ul:after {
+ clear: both;
+}
+
+.widget.jetpack_widget_social_icons li {
+ float: left;
+ margin: 0 0.4375em 0.4375em 0;
+}
+
+.widget.jetpack_widget_social_icons li a {
+ border: 1px solid currentColor;
+ border-radius: 50%;
+ color: inherit;
+ display: block;
+ position: relative;
+}
+
+.widget.jetpack_widget_social_icons li a:hover,
+.widget.jetpack_widget_social_icons li a:focus {
+ opacity: 0.8;
+}
+
+.widget.jetpack_widget_social_icons ul.size-small a {
+ height: 38px;
+ padding: 6px;
+ width: 38px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-small svg {
+ height: 24px;
+ width: 24px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-medium a {
+ height: 50px;
+ padding: 8px;
+ width: 50px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-medium svg {
+ height: 32px;
+ width: 32px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-large a {
+ height: 70px;
+ padding: 10px;
+ width: 70px;
+}
+
+.widget.jetpack_widget_social_icons ul.size-large svg {
+ height: 48px;
+ width: 48px;
+}
+
/* Top Posts & Pages Widget */
.widget_top-posts .widgets-list-layout .widgets-list-layout-blavatar {
margin-top: 0.25em;
diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
index 4f96c7c4..7e106037 100644
--- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
+++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php
@@ -49,3 +49,19 @@ function twentysixteen_remove_share() {
}
}
add_action( 'loop_start', 'twentysixteen_remove_share' );
+
+function twentysixteen_jetpack_lazy_images_compat() {
+ if ( ! function_exists( 'wp_add_inline_script' ) ) {
+ return;
+ }
+
+ // Since TwentySixteen outdents when window is resized, let's trigger a window resize
+ // every time we lazy load an image on the TwentySixteen theme.
+ wp_add_inline_script(
+ 'jetpack-lazy-images',
+ "jQuery( document.body ).on( 'jetpack-lazy-loaded-image', function () { jQuery( window ).trigger( 'resize' ); } );"
+ );
+}
+
+// Priority needs to be 11 here so that we have already enqueued jetpack-lazy-images.
+add_action( 'wp_enqueue_scripts', 'twentysixteen_jetpack_lazy_images_compat', 11 );
diff --git a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
index 3b87c1d2..89665396 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/blog-display.php
@@ -74,7 +74,7 @@ function jetpack_blog_display_custom_excerpt( $content ) {
* Display Excerpt instead of Content.
*/
function jetpack_the_content_to_the_excerpt( $content ) {
- if ( is_home() || is_archive() ) {
+ if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
if ( post_password_required() ) {
$content = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
} else {
@@ -88,7 +88,7 @@ function jetpack_the_content_to_the_excerpt( $content ) {
* Display Content instead of Excerpt.
*/
function jetpack_the_excerpt_to_the_content( $content ) {
- if ( is_home() || is_archive() ) {
+ if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
ob_start();
the_content( sprintf(
wp_kses(
@@ -112,7 +112,7 @@ function jetpack_the_excerpt_to_the_content( $content ) {
*/
function jetpack_the_content_customizer( $content ) {
$class = jetpack_the_content_customizer_class();
- if ( is_home() || is_archive() ) {
+ if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
if ( post_password_required() ) {
$excerpt = sprintf( '<p>%s</p>', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) );
} else {
@@ -130,7 +130,7 @@ function jetpack_the_content_customizer( $content ) {
* Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them.
*/
function jetpack_the_excerpt_customizer( $excerpt ) {
- if ( is_home() || is_archive() ) {
+ if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
ob_start();
the_content( sprintf(
wp_kses(
@@ -157,7 +157,7 @@ function jetpack_the_excerpt_customizer( $excerpt ) {
* Display Content instead of Excerpt in the Customizer when theme uses a 'Mixed' display.
*/
function jetpack_the_excerpt_mixed_customizer( $content ) {
- if ( is_home() || is_archive() ) {
+ if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) {
jetpack_the_content_customizer_class( 'output-the-excerpt' );
ob_start();
the_content();
diff --git a/plugins/jetpack/modules/theme-tools/content-options/featured-images.php b/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
index ce66a830..52ebe7fb 100644
--- a/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
+++ b/plugins/jetpack/modules/theme-tools/content-options/featured-images.php
@@ -14,6 +14,7 @@ function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $
if (
( true === $opts['archive']
&& ( is_home() || is_archive() || is_search() )
+ && ! jetpack_is_shop_page()
&& ! $opts['archive-option']
&& ( isset( $meta_key )
&& '_thumbnail_id' === $meta_key )
@@ -57,3 +58,27 @@ add_filter( 'get_post_metadata', 'jetpack_featured_images_remove_post_thumbnail'
function jetpack_is_product() {
return ( function_exists( 'is_product' ) ) ? is_product() : false;
}
+
+/**
+ * Check if we are in a WooCommerce Shop in order to exclude it from the is_archive check.
+ */
+function jetpack_is_shop_page() {
+ // Check if WooCommerce is active first.
+ if ( ! class_exists( 'WooCommerce' ) ) {
+ return false;
+ }
+
+ global $wp_query;
+
+ $front_page_id = get_option( 'page_on_front' );
+ $current_page_id = $wp_query->get( 'page_id' );
+ $is_static_front_page = 'page' === get_option( 'show_on_front' );
+
+ if ( $is_static_front_page && $front_page_id === $current_page_id ) {
+ $is_shop_page = ( $current_page_id === wc_get_page_id( 'shop' ) ) ? true : false;
+ } else {
+ $is_shop_page = is_shop();
+ }
+
+ return $is_shop_page;
+}
diff --git a/plugins/jetpack/modules/theme-tools/featured-content.php b/plugins/jetpack/modules/theme-tools/featured-content.php
index 07ad833b..d63f3fd5 100644
--- a/plugins/jetpack/modules/theme-tools/featured-content.php
+++ b/plugins/jetpack/modules/theme-tools/featured-content.php
@@ -114,6 +114,8 @@ class Featured_Content {
add_action( 'switch_theme', array( __CLASS__, 'switch_theme' ) );
add_action( 'switch_theme', array( __CLASS__, 'delete_transient' ) );
add_action( 'wp_loaded', array( __CLASS__, 'wp_loaded' ) );
+ add_action( 'update_option_featured-content', array( __CLASS__, 'flush_post_tag_cache' ), 10, 2 );
+ add_action( 'delete_option_featured-content', array( __CLASS__, 'flush_post_tag_cache' ), 10, 2 );
add_action( 'split_shared_term', array( __CLASS__, 'jetpack_update_featured_content_for_split_terms', 10, 4 ) );
@@ -172,9 +174,9 @@ class Featured_Content {
}
$featured_posts = get_posts( array(
- 'include' => $post_ids,
- 'posts_per_page' => count( $post_ids ),
- 'post_type' => self::$post_types,
+ 'include' => $post_ids,
+ 'posts_per_page' => count( $post_ids ),
+ 'post_type' => self::$post_types,
'suppress_filters' => false,
) );
@@ -268,6 +270,23 @@ class Featured_Content {
}
/**
+ * Flush the Post Tag relationships cache.
+ *
+ * Hooks in the "update_option_featured-content" action.
+ */
+ public static function flush_post_tag_cache( $prev, $opts ) {
+ if ( ! empty( $opts ) && ! empty( $opts['tag-id'] ) ) {
+ $query = new WP_Query( array(
+ 'tag_id' => (int) $opts['tag-id'],
+ 'posts_per_page' => -1,
+ ) );
+ foreach ( $query->posts as $post ) {
+ wp_cache_delete( $post->ID, 'post_tag_relationships' );
+ }
+ }
+ }
+
+ /**
* Exclude featured posts from the blog query when the blog is the front-page,
* and user has not checked the "Also display tagged posts outside the Featured Content area" checkbox.
*
@@ -644,7 +663,7 @@ class Featured_Content {
Featured_Content::setup();
/**
- * Adds the featured content plugin to the set of files for which action
+ * Adds the featured content plugin to the set of files for which action
* handlers should be copied when the theme context is loaded by the REST API.
*
* @param array $copy_dirs Copy paths with actions to be copied
diff --git a/plugins/jetpack/modules/theme-tools/responsive-videos.php b/plugins/jetpack/modules/theme-tools/responsive-videos.php
index c7a5d72f..eb97130e 100644
--- a/plugins/jetpack/modules/theme-tools/responsive-videos.php
+++ b/plugins/jetpack/modules/theme-tools/responsive-videos.php
@@ -20,6 +20,9 @@ function jetpack_responsive_videos_init() {
/* Wrap videos in Buddypress */
add_filter( 'bp_embed_oembed_html', 'jetpack_responsive_videos_embed_html' );
+
+ /* Wrap Slideshare shortcodes */
+ add_filter( 'jetpack_slideshare_shortcode', 'jetpack_responsive_videos_embed_html' );
}
add_action( 'after_setup_theme', 'jetpack_responsive_videos_init', 99 );
@@ -46,9 +49,9 @@ function jetpack_responsive_videos_embed_html( $html ) {
}
if ( defined( 'SCRIPT_DEBUG' ) && true == SCRIPT_DEBUG ) {
- wp_enqueue_script( 'jetpack-responsive-videos-script', plugins_url( 'responsive-videos/responsive-videos.js', __FILE__ ), array( 'jquery' ), '1.2', true );
+ wp_enqueue_script( 'jetpack-responsive-videos-script', plugins_url( 'responsive-videos/responsive-videos.js', __FILE__ ), array( 'jquery' ), '1.3', true );
} else {
- wp_enqueue_script( 'jetpack-responsive-videos-min-script', plugins_url( 'responsive-videos/responsive-videos.min.js', __FILE__ ), array( 'jquery' ), '1.2', true );
+ wp_enqueue_script( 'jetpack-responsive-videos-min-script', plugins_url( 'responsive-videos/responsive-videos.min.js', __FILE__ ), array( 'jquery' ), '1.3', true );
}
// Enqueue CSS to ensure compatibility with all themes
@@ -58,11 +61,11 @@ function jetpack_responsive_videos_embed_html( $html ) {
}
/**
- * Check if oEmbed is a `$video_patterns` provider video before wrapping.
+ * Check if oEmbed is YouTube or Vimeo before wrapping.
*
* @return string
*/
-function jetpack_responsive_videos_maybe_wrap_oembed( $html, $url = null ) {
+function jetpack_responsive_videos_maybe_wrap_oembed( $html, $url ) {
if ( empty( $html ) || ! is_string( $html ) || ! $url ) {
return $html;
}
diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
index f46a6d63..694e7bf6 100644
--- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
+++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php
@@ -19,15 +19,21 @@ abstract class Jetpack_Tiled_Gallery_Item {
}
$this->orig_file = wp_get_attachment_url( $this->image->ID );
+ // If Photon is active, use it for original
+ if ( in_array( 'photon', Jetpack::get_active_modules() ) ) {
+ $this->orig_file = jetpack_photon_url( $this->orig_file );
+ }
$this->link = $needs_attachment_link ? get_attachment_link( $this->image->ID ) : $this->orig_file;
+ $img_args = array(
+ 'w' => $this->image->width,
+ 'h' => $this->image->height,
+ );
// If h and w are the same, there's a reasonably good chance the image will need cropping to avoid being stretched.
- $crop = $this->image->height == $this->image->width ? true : false;
- $this->img_src = jetpack_photon_url( $this->orig_file, array(
- 'w' => $this->image->width,
- 'h' => $this->image->height,
- 'crop' => $crop
- ) );
+ if ( $this->image->height == $this->image->width ) {
+ $img_args['crop'] = true;
+ }
+ $this->img_src = jetpack_photon_url( $this->orig_file, $img_args );
}
public function fuzzy_image_meta() {
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
index d2770de6..69d6031f 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.css
@@ -70,6 +70,7 @@
.widget-conditional .condition-control a:before {
position: absolute;
text-indent: 0;
+ top: 0;
right: 0;
}
.widget-conditional .condition-control .delete-condition {
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
index 51338f69..410e7a46 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions-rtl.min.css
@@ -1 +1 @@
-.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f9f9f9;border:1px solid #dfdfdf;padding:12px 10px 0}.widget-conditional{margin-bottom:12px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-left:50px;margin-right:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;right:0}.widget-conditional .condition-control .delete-condition{right:0;color:#f11}.widget-conditional .condition-control .add-condition{left:0}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-left:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}} \ No newline at end of file
+.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f9f9f9;border:1px solid #dfdfdf;padding:12px 10px 0}.widget-conditional{margin-bottom:12px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-left:50px;margin-right:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;top:0;right:0}.widget-conditional .condition-control .delete-condition{right:0;color:#f11}.widget-conditional .condition-control .add-condition{left:0}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-left:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.css
index 264abe9b..72d27b8b 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.css
@@ -71,6 +71,7 @@
.widget-conditional .condition-control a:before {
position: absolute;
text-indent: 0;
+ top: 0;
left: 0;
}
.widget-conditional .condition-control .delete-condition {
diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
index db85d2f8..33ba43d1 100644
--- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
+++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.min.css
@@ -1,2 +1,2 @@
/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f9f9f9;border:1px solid #dfdfdf;padding:12px 10px 0}.widget-conditional{margin-bottom:12px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-right:50px;margin-left:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;left:0}.widget-conditional .condition-control .delete-condition{left:0;color:#f11}.widget-conditional .condition-control .add-condition{right:0}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-right:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}} \ No newline at end of file
+.wp-customizer .expanded .widget-conditional .widget-conditional-inner{width:98%;box-sizing:border-box}.wp-customizer .expanded .widget-conditional .form{overflow:scroll;margin-bottom:20px}.widget-liquid-right .widget.expanded{overflow:visible}.widget-conditional-hide{display:none}.widget-conditional .widget-conditional-inner{background:#f9f9f9;border:1px solid #dfdfdf;padding:12px 10px 0}.widget-conditional{margin-bottom:12px}.widget-conditional .conditions{margin-bottom:12px}.widget-conditional .condition,.widget-conditional .condition-top{clear:both}.widget-conditional .condition{padding-top:12px;position:relative}.widget-conditional .condition select{width:120px;position:relative;z-index:2}.widget-conditional .condition-top select{width:auto}.widget-conditional .condition-control{padding-top:4px;clear:both;margin-top:-20px}.widget-conditional .selection{margin-right:50px;margin-left:20px}.widget-conditional .conditions-rule-has-children{display:block}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition .actions{margin-top:-28px}.widget-conditional .condition-control a{text-decoration:none;position:absolute;top:17px;text-indent:-9999px;z-index:1}.widget-conditional .condition-control a:before{position:absolute;text-indent:0;top:0;left:0}.widget-conditional .condition-control .delete-condition{left:0;color:#f11}.widget-conditional .condition-control .add-condition{right:0}.widget-conditional .condition:last-child .condition-conjunction,.widget-conditional .condition:last-child .condition-intersection{display:none}.widget-conditional.conjunction .condition-intersection{display:none}.widget-conditional.intersection .condition-conjunction{display:none}.wp-core-ui .button.display-options{margin-right:5px}.wp-core-ui .button.display-options:hover{text-decoration:none}.wp-customizer .widget-conditional select{min-width:0;max-width:none;height:auto}.wp-customizer .widget-conditional .condition-control a{top:15px}@media screen and (max-width:782px){.widget-conditional .condition-control a{top:20px}} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widgets/customizer-utils.js b/plugins/jetpack/modules/widgets/customizer-utils.js
index fae4bcbc..e14c5f16 100644
--- a/plugins/jetpack/modules/widgets/customizer-utils.js
+++ b/plugins/jetpack/modules/widgets/customizer-utils.js
@@ -58,6 +58,11 @@ wp.isJetpackWidgetPlaced = function( placement, widgetName ) {
twttr.widgets.load( placement.container[0] );
} else if ( wp.isJetpackWidgetPlaced( placement, 'eu_cookie_law_widget' ) ) {
// Refresh EU Cookie Law
+ if ( $( '#eu-cookie-law' ).hasClass( 'top' ) ) {
+ $( '.widget_eu_cookie_law_widget' ).addClass( 'top' );
+ } else {
+ $( '.widget_eu_cookie_law_widget' ).removeClass( 'top' );
+ }
placement.container.fadeIn();
}
}
@@ -66,7 +71,6 @@ wp.isJetpackWidgetPlaced = function( placement, widgetName ) {
// Refresh widgets when they're moved.
wp.customize.selectiveRefresh.bind( 'partial-content-moved', function( placement ) {
if ( placement.container ) {
-
// Refresh Twitter timeline iframe, since it has to be re-built.
if ( wp.isJetpackWidgetPlaced( placement, 'twitter_timeline' ) && placement.container.find( 'iframe.twitter-timeline:not([src]):first' ).length ) {
placement.partial.refresh();
@@ -74,6 +78,5 @@ wp.isJetpackWidgetPlaced = function( placement, widgetName ) {
}
} );
}
- });
-
-})(jQuery); \ No newline at end of file
+ } );
+} )( jQuery );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law.php b/plugins/jetpack/modules/widgets/eu-cookie-law.php
index 993bd8d3..f12b84fb 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law.php
@@ -22,13 +22,6 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
public static $cookie_name = 'eucookielaw';
/**
- * EU Cookie Law cookie validity (30 days).
- *
- * @var int
- */
- public static $cookie_validity = 2592000;
-
- /**
* Default hide options.
*
* @var array
@@ -70,15 +63,25 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
);
/**
+ * Widget position options.
+ *
+ * @var array
+ */
+ private $position_options = array(
+ 'bottom',
+ 'top',
+ );
+
+ /**
* Constructor.
*/
function __construct() {
parent::__construct(
'eu_cookie_law_widget',
/** This filter is documented in modules/widgets/facebook-likebox.php */
- apply_filters( 'jetpack_widget_name', esc_html__( 'EU Cookie Law Banner', 'jetpack' ) ),
+ apply_filters( 'jetpack_widget_name', esc_html__( 'Cookies & Consents Banner', 'jetpack' ) ),
array(
- 'description' => esc_html__( 'Display a banner for compliance with the EU Cookie Law.', 'jetpack' ),
+ 'description' => esc_html__( 'Display a banner for EU Cookie Law and GDPR compliance.', 'jetpack' ),
'customize_selective_refresh' => true,
),
array()
@@ -101,7 +104,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
'modules/widgets/eu-cookie-law/eu-cookie-law.js'
),
array( 'jquery' ),
- '20170404',
+ '20180522',
true
);
}
@@ -117,15 +120,17 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
return array(
'hide' => $this->hide_options[0],
'hide-timeout' => 30,
+ 'consent-expiration' => 180,
'text' => $this->text_options[0],
'customtext' => '',
'color-scheme' => $this->color_scheme_options[0],
- 'policy-url' => $this->policy_url_options[0],
- 'default-policy-url' => 'https://jetpack.com/support/cookies/',
- 'custom-policy-url' => '',
- 'policy-link-text' => esc_html__( 'Our Cookie Policy', 'jetpack' ),
+ 'policy-url' => get_option( 'wp_page_for_privacy_policy' ) ? $this->policy_url_options[1] : $this->policy_url_options[0],
+ 'default-policy-url' => 'https://automattic.com/cookies/',
+ 'custom-policy-url' => get_option( 'wp_page_for_privacy_policy' ) ? get_permalink( (int) get_option( 'wp_page_for_privacy_policy' ) ) : '',
+ 'position' => $this->position_options[0],
+ 'policy-link-text' => esc_html__( 'Cookie Policy', 'jetpack' ),
'button' => esc_html__( 'Close and accept', 'jetpack' ),
- 'default-text' => esc_html__( 'Privacy & Cookies: This site uses cookies.', 'jetpack' ),
+ 'default-text' => esc_html__( "Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. \r\nTo find out more, including how to control cookies, see here:", 'jetpack' ),
);
}
@@ -136,7 +141,34 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
+ /**
+ * Filters the display of the EU Cookie Law widget.
+ *
+ * @since 6.1.1
+ *
+ * @param bool true Should the EU Cookie Law widget be disabled. Default to false.
+ */
+ if ( apply_filters( 'jetpack_disable_eu_cookie_law_widget', false ) ) {
+ return;
+ }
+
$instance = wp_parse_args( $instance, $this->defaults() );
+
+ $classes = array();
+ $classes['hide'] = 'hide-on-' . esc_attr( $instance['hide'] );
+ if ( 'negative' === $instance['color-scheme'] ) {
+ $classes['negative'] = 'negative';
+ }
+
+ if ( 'top' === $instance['position'] ) {
+ $classes['top'] = 'top';
+ }
+
+ if ( Jetpack::is_module_active( 'wordads' ) ) {
+ $classes['ads'] = 'ads-active';
+ $classes['hide'] = 'hide-on-button';
+ }
+
echo $args['before_widget'];
require( dirname( __FILE__ ) . '/eu-cookie-law/widget.php' );
echo $args['after_widget'];
@@ -151,6 +183,20 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
*/
public function form( $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
+ if ( Jetpack::is_module_active( 'wordads' ) ) {
+ $instance['hide'] = 'button';
+ }
+
+ wp_enqueue_script(
+ 'eu-cookie-law-widget-admin',
+ Jetpack::get_file_url_for_environment(
+ '_inc/build/widgets/eu-cookie-law/eu-cookie-law-admin.min.js',
+ 'modules/widgets/eu-cookie-law/eu-cookie-law-admin.js'
+ ),
+ array( 'jquery' ),
+ 20180417
+ );
+
require( dirname( __FILE__ ) . '/eu-cookie-law/form.php' );
}
@@ -165,16 +211,22 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
$instance = array();
$defaults = $this->defaults();
- $instance['hide'] = $this->filter_value( $new_instance['hide'], $this->hide_options );
- $instance['text'] = $this->filter_value( $new_instance['text'], $this->text_options );
- $instance['color-scheme'] = $this->filter_value( $new_instance['color-scheme'], $this->color_scheme_options );
- $instance['policy-url'] = $this->filter_value( $new_instance['policy-url'], $this->policy_url_options );
+ $instance['hide'] = $this->filter_value( isset( $new_instance['hide'] ) ? $new_instance['hide'] : '', $this->hide_options );
+ $instance['text'] = $this->filter_value( isset( $new_instance['text'] ) ? $new_instance['text'] : '', $this->text_options );
+ $instance['color-scheme'] = $this->filter_value( isset( $new_instance['color-scheme'] ) ? $new_instance['color-scheme'] : '', $this->color_scheme_options );
+ $instance['policy-url'] = $this->filter_value( isset( $new_instance['policy-url'] ) ? $new_instance['policy-url'] : '', $this->policy_url_options );
+ $instance['position'] = $this->filter_value( isset( $new_instance['position'] ) ? $new_instance['position'] : '', $this->position_options );
if ( isset( $new_instance['hide-timeout'] ) ) {
// Time can be a value between 3 and 1000 seconds.
$instance['hide-timeout'] = min( 1000, max( 3, intval( $new_instance['hide-timeout'] ) ) );
}
+ if ( isset( $new_instance['consent-expiration'] ) ) {
+ // Time can be a value between 1 and 365 days.
+ $instance['consent-expiration'] = min( 365, max( 1, intval( $new_instance['consent-expiration'] ) ) );
+ }
+
if ( isset( $new_instance['customtext'] ) ) {
$instance['customtext'] = mb_substr( wp_kses( $new_instance['customtext'], array() ), 0, 4096 );
} else {
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js
new file mode 100644
index 00000000..b0bfd484
--- /dev/null
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law-admin.js
@@ -0,0 +1,30 @@
+
+/* eslint no-var: 0 */
+
+( function( $ ) {
+ var $document = $( document );
+
+ $document.on( 'ready', function() {
+ var maybeShowNotice = function( e, policyUrl ) {
+ var $policyUrl = $( policyUrl || this )
+ .closest( '.eu-cookie-law-widget-policy-url' );
+
+ if ( $policyUrl.find( 'input[type="radio"][value="default"]' ).is( ':checked' ) ) {
+ $policyUrl.find( '.notice.default-policy' ).css( 'display', 'block' );
+ $policyUrl.find( '.notice.custom-policy' ).hide();
+ } else {
+ $policyUrl.find( '.notice.default-policy' ).hide();
+ $policyUrl.find( '.notice.custom-policy' ).css( 'display', 'block' );
+ }
+ };
+
+ $document.on( 'click', '.eu-cookie-law-widget-policy-url input[type="radio"]', maybeShowNotice );
+ $document.on( 'widget-updated widget-added', function( e, widget ) {
+ var widgetId = $( widget ).attr( 'id' );
+ if ( widgetId.indexOf( 'eu_cookie_law_widget' ) !== -1 ) {
+ maybeShowNotice( null, $( '#' + widgetId + ' .eu-cookie-law-widget-policy-url' ) );
+ }
+ } );
+ $( '.eu-cookie-law-widget-policy-url' ).each( maybeShowNotice );
+ } );
+} )( jQuery );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
index 18ed69c5..b7f8c7db 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
@@ -4,7 +4,16 @@
initialScrollPosition,
scrollFunction;
- if ( '' !== cookieValue ) {
+ if ( overlay.hasClass( 'top' ) ) {
+ $( '.widget_eu_cookie_law_widget' ).addClass( 'top' );
+ }
+
+ if ( overlay.hasClass( 'ads-active' ) ) {
+ var adsCookieValue = document.cookie.replace( /(?:(?:^|.*;\s*)personalized-ads-consent\s*\=\s*([^;]*).*$)|^.*$/, '$1' );
+ if ( '' !== cookieValue && '' !== adsCookieValue ) {
+ overlay.remove();
+ }
+ } else if ( '' !== cookieValue ) {
overlay.remove();
}
@@ -40,9 +49,12 @@
}
var expireTime = new Date();
- expireTime.setTime( expireTime.getTime() + 2592000000 ); // 30 days
+ expireTime.setTime( expireTime.getTime() + ( overlay.data( 'consent-expiration' ) * 24 * 60 * 60 * 1000 ) );
document.cookie = 'eucookielaw=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
+ if ( overlay.hasClass( 'ads-active' ) && overlay.hasClass( 'hide-on-button' ) ) {
+ document.cookie = 'personalized-ads-consent=' + expireTime.getTime() + ';path=/;expires=' + expireTime.toGMTString();
+ }
overlay.fadeOut( 400, function() {
overlay.remove();
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
index cdd777ad..7b00877b 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/form.php
@@ -1,6 +1,130 @@
<p>
<strong>
- <?php _ex( 'Hide the banner', 'action', 'jetpack' ); ?>
+ <?php esc_html_e( 'Banner text', 'jetpack' ); ?>
+ </strong>
+ <ul>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['text'], 'default' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
+ type="radio"
+ value="default"
+ />
+ <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['text'], 'custom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
+ type="radio"
+ value="custom"
+ />
+ <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
+ </label>
+ </li>
+ </ul>
+ <textarea
+ class="widefat"
+ name="<?php echo esc_attr( $this->get_field_name( 'customtext' ) ); ?>"
+ placeholder="<?php echo esc_attr( $instance['default-text'] ); ?>"
+ ><?php echo esc_html( $instance['customtext'] ); ?></textarea>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Privacy Policy Link', 'jetpack' ); ?>
+ </strong>
+ <ul class="eu-cookie-law-widget-policy-url">
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['policy-url'], 'default' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ type="radio"
+ value="default"
+ />
+ <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['policy-url'], 'custom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ type="radio"
+ value="custom"
+ />
+ <?php esc_html_e( 'Custom URL:', 'jetpack' ); ?>
+ </label>
+ <input
+ class="widefat"
+ name="<?php echo esc_attr( $this->get_field_name( 'custom-policy-url' ) ); ?>"
+ placeholder="<?php echo esc_url( $instance['default-policy-url'] ); ?>"
+ style="margin-top: .5em;"
+ type="text"
+ value="<?php echo esc_url( $instance['custom-policy-url'] ); ?>"
+ />
+ <span class="notice notice-warning default-policy" style="display: none;">
+ <span style="display: block; margin: .5em 0;">
+ <strong><?php esc_html_e( 'Caution:', 'jetpack' ); ?></strong>
+ <?php esc_html_e( 'The default policy URL only covers cookies set by Jetpack. If you’re running other plugins, custom cookies, or third-party tracking technologies, you should create and link to your own cookie statement.', 'jetpack' ); ?>
+ </span>
+ </span>
+ <?php if ( Jetpack::is_module_active( 'wordads' ) ) : ?>
+ <span class="notice notice-warning custom-policy" style="display: none;">
+ <span style="display: block; margin: .5em 0;">
+ <strong><?php esc_html_e( 'Caution:', 'jetpack' ); ?></strong>
+ <?php echo sprintf(
+ __( 'For GDPR compliance, please make sure your policy contains <a href="%s" target="_blank">privacy information relating to Jetpack Ads</a>.', 'jetpack' ),
+ esc_url( 'https://jetpack.com/support/ads/#privacy' )
+ ); ?>
+ </span>
+ </span>
+ <?php endif; ?>
+ </li>
+ </ul>
+</p>
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Link text', 'jetpack' ); ?>
+ </strong>
+ <label>
+ <input
+ class="widefat"
+ name="<?php echo $this->get_field_name( 'policy-link-text' ); ?>"
+ type="text"
+ value="<?php echo esc_attr( $instance['policy-link-text'] ); ?>"
+ />
+ </label>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php esc_html_e( 'Button text', 'jetpack' ); ?>
+ </strong>
+ <label>
+ <input
+ class="widefat"
+ name="<?php echo $this->get_field_name( 'button' ); ?>"
+ type="text"
+ value="<?php echo esc_attr( $instance['button'] ); ?>"
+ />
+ </label>
+</p>
+
+<hr />
+
+<p>
+ <strong>
+ <?php _ex( 'Capture consent & hide the banner', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
@@ -10,6 +134,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="button"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after the user clicks the dismiss button', 'jetpack' ); ?>
</label>
@@ -21,6 +146,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="scroll"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after the user scrolls the page', 'jetpack' ); ?>
</label>
@@ -32,6 +158,7 @@
name="<?php echo esc_attr( $this->get_field_name( 'hide' ) ); ?>"
type="radio"
value="time"
+ <?php echo Jetpack::is_module_active( 'wordads' ) ? 'disabled' : ''; ?>
/>
<?php esc_html_e( 'after this amount of time', 'jetpack' ); ?>
</label>
@@ -46,43 +173,34 @@
<?php esc_html_e( 'seconds', 'jetpack' ); ?>
</li>
</ul>
+ <?php if ( Jetpack::is_module_active( 'wordads' ) ) : ?>
+ <span class="notice notice-warning" style="display: block;">
+ <span style="display: block; margin: .5em 0;">
+ <?php esc_html_e( 'Visitors must provide consent by clicking the dismiss button when Jetpack Ads is turned on.', 'jetpack' ); ?>
+ </span>
+ </span>
+ <?php endif; ?>
</p>
<hr />
<p>
<strong>
- <?php esc_html_e( 'Banner text', 'jetpack' ); ?>
+ <?php _ex( 'Consent expires after', 'action', 'jetpack' ); ?>
</strong>
<ul>
<li>
- <label>
- <input
- <?php checked( $instance['text'], 'default' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
- type="radio"
- value="default"
- />
- <?php esc_html_e( 'Default', 'jetpack' ); ?>
- </label>
- </li>
- <li>
- <label>
- <input
- <?php checked( $instance['text'], 'custom' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"
- type="radio"
- value="custom"
- />
- <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
- </label>
+ <input
+ max="365"
+ min="1"
+ name="<?php echo esc_attr( $this->get_field_name( 'consent-expiration' ) ); ?>"
+ style="padding: 3px 5px; width: 3.75em;"
+ type="number"
+ value="<?php echo esc_attr( $instance['consent-expiration'] ); ?>"
+ />
+ <?php esc_html_e( 'days', 'jetpack' ); ?>
</li>
</ul>
- <textarea
- class="widefat"
- name="<?php echo esc_attr( $this->get_field_name( 'customtext' ) ); ?>"
- placeholder="<?php echo esc_attr( $instance['default-text'] ); ?>"
- ><?php echo esc_html( $instance['customtext'] ); ?></textarea>
</p>
<hr />
@@ -121,72 +239,36 @@
<p>
<strong>
- <?php esc_html_e( 'Policy URL', 'jetpack' ); ?>
+ <?php _e( 'Position', 'jetpack' ); ?>
</strong>
<ul>
<li>
<label>
<input
- <?php checked( $instance['policy-url'], 'default' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ <?php checked( $instance['position'], 'bottom' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'position' ) ); ?>"
type="radio"
- value="default"
+ value="bottom"
/>
- <?php esc_html_e( 'Default', 'jetpack' ); ?>
+ <?php esc_html_e( 'Bottom', 'jetpack' ); ?>
</label>
</li>
<li>
<label>
<input
- <?php checked( $instance['policy-url'], 'custom' ); ?>
- name="<?php echo esc_attr( $this->get_field_name( 'policy-url' ) ); ?>"
+ <?php checked( $instance['position'], 'top' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'position' ) ); ?>"
type="radio"
- value="custom"
+ value="top"
/>
- <?php esc_html_e( 'Custom:', 'jetpack' ); ?>
+ <?php esc_html_e( 'Top', 'jetpack' ); ?>
</label>
- <input
- class="widefat"
- name="<?php echo esc_attr( $this->get_field_name( 'custom-policy-url' ) ); ?>"
- placeholder="<?php echo esc_url( $instance['default-policy-url'] ); ?>"
- style="margin-top: .5em;"
- type="text"
- value="<?php echo esc_url( $instance['custom-policy-url'] ); ?>"
- />
</li>
</ul>
</p>
-<p>
- <strong>
- <?php esc_html_e( 'Policy link text', 'jetpack' ); ?>
- </strong>
- <label>
- <input
- class="widefat"
- name="<?php echo $this->get_field_name( 'policy-link-text' ); ?>"
- type="text"
- value="<?php echo esc_attr( $instance['policy-link-text'] ); ?>"
- />
- </label>
-</p>
-
<hr />
-<p>
- <strong>
- <?php esc_html_e( 'Button text', 'jetpack' ); ?>
- </strong>
- <label>
- <input
- class="widefat"
- name="<?php echo $this->get_field_name( 'button' ); ?>"
- type="text"
- value="<?php echo esc_attr( $instance['button'] ); ?>"
- />
- </label>
-</p>
-
<p class="small">
<?php esc_html_e( 'It is your own responsibility to ensure that your site complies with the relevant laws.', 'jetpack' ); ?>
<a href="https://jetpack.com/support/extra-sidebar-widgets/eu-cookie-law-widget/">
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
index b97f306d..c1e2520f 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
@@ -1,4 +1,4 @@
-.widget_eu_cookie_law_widget.widget {
+.widget_eu_cookie_law_widget {
border: none;
bottom: 1em;
display: none;
@@ -11,6 +11,15 @@
z-index: 50001;
}
+.widget_eu_cookie_law_widget.widget.top {
+ bottom: auto;
+ top: 1em;
+}
+
+.admin-bar .widget_eu_cookie_law_widget.widget.top {
+ top: 3em;
+}
+
#eu-cookie-law {
background-color: #fff;
border: 1px solid #dedede;
@@ -42,6 +51,14 @@
}
/**
+ * Using a highly-specific rule to make sure that certain form styles
+ * will be reset
+ */
+#eu-cookie-law form {
+ margin-bottom: 0;
+}
+
+/**
* Using a highly-specific rule to make sure that all button styles
* will be reset
*/
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
index c45edfee..cd016a3e 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/widget.php
@@ -1,7 +1,7 @@
<div
- class="<?php echo 'negative' === $instance['color-scheme'] ? 'negative ' : '';
- ?>hide-on-<?php echo esc_attr( $instance['hide'] ); ?>"
+ class="<?php echo implode( ' ', $classes ); ?>"
data-hide-timeout="<?php echo intval( $instance['hide-timeout'] ); ?>"
+ data-consent-expiration="<?php echo intval( $instance['consent-expiration'] ); ?>"
id="eu-cookie-law"
>
<form method="post">
@@ -9,13 +9,9 @@
</form>
<?php if ( 'default' == $instance['text'] || empty( $instance['customtext'] ) ) {
- echo $instance['default-text'];
- ?>
- <br />
- <?php
- esc_html_e( 'To find out more, as well as how to remove or block these, see here:', 'jetpack' );
+ echo nl2br( $instance['default-text'] );
} else {
- echo esc_html( $instance['customtext'] );
+ echo nl2br( esc_html( $instance['customtext'] ) );
} ?>
<a href="<?php
diff --git a/plugins/jetpack/modules/widgets/google-translate.php b/plugins/jetpack/modules/widgets/google-translate.php
index ddb40ec5..dee475b8 100644
--- a/plugins/jetpack/modules/widgets/google-translate.php
+++ b/plugins/jetpack/modules/widgets/google-translate.php
@@ -53,8 +53,29 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
);
wp_register_script( 'google-translate', '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit', array( 'google-translate-init' ) );
// Admin bar is also displayed on top of the site which causes google translate bar to hide beneath.
+ // Overwrite position of body.admin-bar
// This is a hack to show google translate bar a bit lower.
- wp_add_inline_style( 'admin-bar', '.goog-te-banner-frame { top:32px !important }' );
+ $lowerTranslateBar = '
+ .admin-bar {
+ position: inherit !important;
+ top: auto !important;
+ }
+ .admin-bar .goog-te-banner-frame {
+ top: 32px !important
+ }
+ @media screen and (max-width: 782px) {
+ .admin-bar .goog-te-banner-frame {
+ top: 46px !important;
+ }
+ }
+ @media screen and (max-width: 480px) {
+ .admin-bar .goog-te-banner-frame {
+ position: absolute;
+ }
+ }
+ ';
+ wp_add_inline_style( 'admin-bar', $lowerTranslateBar );
+ wp_add_inline_style( 'wpcom-admin-bar', $lowerTranslateBar );
}
/**
diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php
index c9c7df2c..7c64cd22 100644
--- a/plugins/jetpack/modules/widgets/gravatar-profile.php
+++ b/plugins/jetpack/modules/widgets/gravatar-profile.php
@@ -344,10 +344,16 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
$cache_key = 'grofile-' . $hashed_email;
if( ! $profile = get_transient( $cache_key ) ) {
- $profile_url = esc_url_raw( sprintf( '%s.gravatar.com/%s.json', ( is_ssl() ? 'https://secure' : 'http://www' ), $hashed_email ), array( 'http', 'https' ) );
+ $profile_url = sprintf(
+ 'https://secure.gravatar.com/%s.json',
+ $hashed_email
+ );
$expire = 300;
- $response = wp_remote_get( $profile_url, array( 'User-Agent' => 'WordPress.com Gravatar Profile Widget' ) );
+ $response = wp_remote_get(
+ esc_url_raw( $profile_url ),
+ array( 'User-Agent' => 'WordPress.com Gravatar Profile Widget' )
+ );
$response_code = wp_remote_retrieve_response_code( $response );
if ( 200 == $response_code ) {
$profile = wp_remote_retrieve_body( $response );
diff --git a/plugins/jetpack/modules/widgets/social-icons.php b/plugins/jetpack/modules/widgets/social-icons.php
index b61c5934..a2e02645 100644
--- a/plugins/jetpack/modules/widgets/social-icons.php
+++ b/plugins/jetpack/modules/widgets/social-icons.php
@@ -42,13 +42,9 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
/**
* Script & styles for admin widget form.
*/
- public function enqueue_admin_scripts( $hook ) {
- global $wp_customize;
-
- if ( isset( $wp_customize ) || 'widgets.php' === $hook ) {
- wp_enqueue_script( 'jetpack-widget-social-icons-script', plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ), array( 'jquery-ui-sortable' ), '20170506' );
- wp_enqueue_style( 'jetpack-widget-social-icons-admin', plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ), array(), '20170506' );
- }
+ public function enqueue_admin_scripts() {
+ wp_enqueue_script( 'jetpack-widget-social-icons-script', plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ), array( 'jquery-ui-sortable' ), '20170506' );
+ wp_enqueue_style( 'jetpack-widget-social-icons-admin', plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ), array(), '20170506' );
}
/**
diff --git a/plugins/jetpack/modules/widgets/social-icons/social-icons.css b/plugins/jetpack/modules/widgets/social-icons/social-icons.css
index 5701ef2c..505f0663 100644
--- a/plugins/jetpack/modules/widgets/social-icons/social-icons.css
+++ b/plugins/jetpack/modules/widgets/social-icons/social-icons.css
@@ -55,3 +55,21 @@
height: 48px;
width: 48px;
}
+
+/*
+Text meant only for screen readers.
+Provides support for themes that do not bundle this CSS yet.
+@see https://make.wordpress.org/accessibility/2015/02/09/hiding-text-for-screen-readers-with-wordpress-core/
+***********************************/
+.screen-reader-text {
+ border: 0;
+ clip: rect(1px, 1px, 1px, 1px);
+ clip-path: inset(50%);
+ height: 1px;
+ margin: -1px;
+ overflow: hidden;
+ padding: 0;
+ position: absolute ! important;
+ width: 1px;
+ word-wrap: normal ! important;
+}
diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php
index a4b6b157..f581741c 100644
--- a/plugins/jetpack/modules/widgets/top-posts.php
+++ b/plugins/jetpack/modules/widgets/top-posts.php
@@ -303,10 +303,15 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
echo $args['before_title'] . $title . $args['after_title'];
if ( ! $posts ) {
+ $link = 'https://jetpack.com/support/getting-more-views-and-traffic/';
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ $link = 'http://en.support.wordpress.com/getting-more-site-traffic/';
+ }
+
if ( current_user_can( 'edit_theme_options' ) ) {
echo '<p>' . sprintf(
__( 'There are no posts to display. <a href="%s" target="_blank">Want more traffic?</a>', 'jetpack' ),
- 'https://jetpack.com/support/getting-more-views-and-traffic/'
+ esc_url( $link )
) . '</p>';
}
diff --git a/plugins/jetpack/modules/widgets/twitter-timeline.php b/plugins/jetpack/modules/widgets/twitter-timeline.php
index 72e9242f..60500676 100644
--- a/plugins/jetpack/modules/widgets/twitter-timeline.php
+++ b/plugins/jetpack/modules/widgets/twitter-timeline.php
@@ -82,6 +82,20 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
* @param array $instance Saved values from database.
*/
public function widget( $args, $instance ) {
+ // Twitter deprecated `data-widget-id` on 2018-05-25,
+ // with cease support deadline on 2018-07-27.
+ // 1532563200 is 2018-07-26, one day early.
+ if ( 'widget-id' === $instance['type'] && time() > 1532563200 ) {
+ if ( current_user_can( 'edit_theme_options' ) ) {
+ echo $args['before_widget'];
+ echo $args['before_title'] . esc_html__( 'Twitter Timeline', 'jetpack' ) . $args['after_title'];
+ echo '<p>' . esc_html__( "The Twitter Timeline widget can't display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username. Otherwise, delete this widget.", 'jetpack' ) . '</p>';
+ echo '<p>' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . '</p>';
+ echo $args['after_widget'];
+ }
+ return;
+ }
+
$instance['lang'] = substr( strtoupper( get_locale() ), 0, 2 );
echo $args['before_widget'];
@@ -94,6 +108,11 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
echo $args['before_title'] . $title . $args['after_title'];
}
+ if ( 'widget-id' === $instance['type'] && current_user_can( 'edit_theme_options' ) ) {
+ echo '<p>' . esc_html__( 'As of July 27, 2018, the Twitter Timeline widget will no longer display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username.', 'jetpack' ) . '</p>';
+ echo '<p>' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . '</p>';
+ }
+
// Start tag output
// This tag is transformed into the widget markup by Twitter's
// widgets.js code
@@ -135,6 +154,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
echo ' data-widget-id="' . esc_attr( $widget_id ) . '"';
break;
}
+ echo ' href="https://twitter.com/' . esc_attr( $widget_id ) . '"';
// End tag output
echo '>';
@@ -230,10 +250,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
}
- $instance['type'] = 'widget-id';
- if ( in_array( $new_instance['type'], array( 'widget-id', 'profile' ) ) ) {
- $instance['type'] = $new_instance['type'];
- }
+ $instance['type'] = 'profile';
$instance['theme'] = 'light';
if ( in_array( $new_instance['theme'], array( 'light', 'dark' ) ) ) {
@@ -284,6 +301,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
'title' => esc_html__( 'Follow me on Twitter', 'jetpack' ),
'width' => '',
'height' => '400',
+ 'type' => 'profile',
'widget-id' => '',
'link-color' => '#f96e5b',
'border-color' => '#e8e8e8',
@@ -294,16 +312,11 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
$instance = wp_parse_args( (array) $instance, $defaults );
- if ( empty( $instance['type'] ) ) {
- // Decide the correct widget type. If this is a pre-existing
- // widget with a numeric widget ID, then the type should be
- // 'widget-id', otherwise it should be 'profile'.
- if ( ! empty( $instance['widget-id'] ) && is_numeric( $instance['widget-id'] ) ) {
- $instance['type'] = 'widget-id';
- } else {
- $instance['type'] = 'profile';
- }
+ if ( 'widget-id' === $instance['type'] ) {
+ $instance['widget-id'] = '';
}
+
+ $instance['type'] = 'profile';
?>
<p>
@@ -358,39 +371,8 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
/>
</p>
- <p class="jetpack-twitter-timeline-widget-type-container">
- <label for="<?php echo $this->get_field_id( 'type' ); ?>">
- <?php esc_html_e( 'Widget Type:', 'jetpack' ); ?>
- <?php echo $this->get_docs_link( '#widget-type' ); ?>
- </label>
- <select
- name="<?php echo $this->get_field_name( 'type' ); ?>"
- id="<?php echo $this->get_field_id( 'type' ); ?>"
- class="jetpack-twitter-timeline-widget-type widefat"
- >
- <option value="profile"<?php selected( $instance['type'], 'profile' ); ?>>
- <?php esc_html_e( 'Profile', 'jetpack' ); ?>
- </option>
- <option value="widget-id"<?php selected( $instance['type'], 'widget-id' ); ?>>
- <?php esc_html_e( 'Widget ID', 'jetpack' ); ?>
- </option>
- </select>
- </p>
-
<p class="jetpack-twitter-timeline-widget-id-container">
- <label
- for="<?php echo $this->get_field_id( 'widget-id' ); ?>"
- data-widget-type="widget-id"
- <?php echo ( 'widget-id' === $instance['type'] ? '' : 'style="display: none;"' ); ?>
- >
- <?php esc_html_e( 'Widget ID:', 'jetpack' ); ?>
- <?php echo $this->get_docs_link( '#widget-id' ); ?>
- </label>
- <label
- for="<?php echo $this->get_field_id( 'widget-id' ); ?>"
- data-widget-type="profile"
- <?php echo ( 'profile' === $instance['type'] ? '' : 'style="display: none;"' ); ?>
- >
+ <label for="<?php echo $this->get_field_id( 'widget-id' ); ?>">
<?php esc_html_e( 'Twitter Username:', 'jetpack' ); ?>
<?php echo $this->get_docs_link( '#twitter-username' ); ?>
</label>
diff --git a/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php b/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php
index ee5dc5cf..8482bb29 100644
--- a/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php
+++ b/plugins/jetpack/modules/woocommerce-analytics/classes/wp-woocommerce-analytics-universal.php
@@ -136,8 +136,9 @@ class Jetpack_WooCommerce_Analytics_Universal {
/**
* Adds the product ID to the remove product link (for use by remove_from_cart above) if not present
*
- * @param string $url url.
- * @param string $key key.
+ * @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.
+ *
* @return mixed.
*/
public function remove_from_cart_attributes( $url, $key ) {
@@ -149,12 +150,11 @@ class Jetpack_WooCommerce_Analytics_Universal {
$product = $item['data'];
$new_attributes = sprintf(
- 'href="%s" data-product_id="%s" data-product_sku="%s"',
- esc_attr( $url ),
- esc_attr( $product->get_id() ),
- esc_attr( $product->get_sku() )
+ '" data-product_id="%s">',
+ esc_attr( $product->get_id() )
);
- $url = str_replace( 'href=', $new_attributes, $url );
+
+ $url = str_replace( '">', $new_attributes, $url );
return $url;
}
diff --git a/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php b/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php
index eafca1e2..f3ab5d9e 100644
--- a/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php
+++ b/plugins/jetpack/modules/woocommerce-analytics/wp-woocommerce-analytics.php
@@ -55,7 +55,7 @@ class Jetpack_WooCommerce_Analytics {
*
* This action is documented in https://docs.woocommerce.com/document/create-a-plugin
*/
- if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
+ if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', Jetpack::get_active_plugins() ) ) ) {
return false;
}
diff --git a/plugins/jetpack/modules/wordads/php/api.php b/plugins/jetpack/modules/wordads/php/api.php
index f8203aa8..704193ed 100644
--- a/plugins/jetpack/modules/wordads/php/api.php
+++ b/plugins/jetpack/modules/wordads/php/api.php
@@ -44,6 +44,24 @@ class WordAds_API {
}
/**
+ * Returns the ads.txt content needed to run WordAds.
+ * @return array string contents of the ads.txt file.
+ *
+ * @since 6.1.0
+ */
+ public static function get_wordads_ads_txt() {
+ $endpoint = sprintf( '/sites/%d/wordads/ads-txt', Jetpack::get_option( 'id' ) );
+ $wordads_status_response = $response = Jetpack_Client::wpcom_json_api_request_as_blog( $endpoint );
+ if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
+ return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
+ }
+
+ $body = json_decode( wp_remote_retrieve_body( $response ) );
+ $ads_txt = str_replace( '\\n', PHP_EOL, $body->adstxt );
+ return $ads_txt;
+ }
+
+ /**
* Returns status of WordAds approval.
* @return boolean true if site is WordAds approved
*
diff --git a/plugins/jetpack/modules/wordads/php/params.php b/plugins/jetpack/modules/wordads/php/params.php
index dbce7145..cb50023a 100644
--- a/plugins/jetpack/modules/wordads/php/params.php
+++ b/plugins/jetpack/modules/wordads/php/params.php
@@ -71,16 +71,12 @@ class WordAds_Params {
* @since 4.5.0
*/
public static function is_cloudflare() {
- if ( defined( 'WORDADS_CLOUDFLARE' ) ) {
- return true;
- }
- if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
- return true;
- }
- if ( isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
- return true;
- }
- if ( isset( $_SERVER['HTTP_CF_VISITOR'] ) ) {
+ if (
+ defined( 'WORDADS_CLOUDFLARE' )
+ || isset( $_SERVER['HTTP_CF_CONNECTING_IP'] )
+ || isset( $_SERVER['HTTP_CF_IPCOUNTRY'] )
+ || isset( $_SERVER['HTTP_CF_VISITOR'] )
+ ) {
return true;
}
diff --git a/plugins/jetpack/modules/wordads/php/widgets.php b/plugins/jetpack/modules/wordads/php/widgets.php
index 04fed064..f4eb90b8 100644
--- a/plugins/jetpack/modules/wordads/php/widgets.php
+++ b/plugins/jetpack/modules/wordads/php/widgets.php
@@ -52,7 +52,7 @@ class WordAds_Sidebar_Widget extends WP_Widget {
$snippet = $wordads->get_house_ad( $unit );
} else {
- $snippet = $wordads->get_ad_snippet( $section_id, $height, $width );
+ $snippet = $wordads->get_ad_snippet( $section_id, $height, $width, 'widget' );
}
echo <<< HTML
@@ -113,4 +113,3 @@ function jetpack_wordads_widgets_init_callback() {
}
add_action( 'widgets_init', 'jetpack_wordads_widgets_init_callback' );
-
diff --git a/plugins/jetpack/modules/wordads/wordads.php b/plugins/jetpack/modules/wordads/wordads.php
index bf97e69c..c1370300 100644
--- a/plugins/jetpack/modules/wordads/wordads.php
+++ b/plugins/jetpack/modules/wordads/wordads.php
@@ -15,9 +15,11 @@ class WordAds {
public $params = null;
+ public $ads = array();
+
/**
- * The different supported ad types.
- * v0.1 - mrec only for now
+ * Array of supported ad types.
+ *
* @var array
*/
public static $ad_tag_ids = array(
@@ -45,6 +47,7 @@ class WordAds {
/**
* Convenience function for grabbing options from params->options
+ *
* @param string $option the option to grab
* @param mixed $default (optional)
* @return option or $default if not set
@@ -92,10 +95,34 @@ class WordAds {
}
$this->insert_adcode();
+
+ if ( '/ads.txt' === $_SERVER['REQUEST_URI'] ) {
+
+ if ( false === ( $ads_txt_transient = get_transient( 'jetpack_ads_txt' ) ) ) {
+ $ads_txt_transient = ! is_wp_error( WordAds_API::get_wordads_ads_txt() ) ? WordAds_API::get_wordads_ads_txt() : '';
+ set_transient( 'jetpack_ads_txt', $ads_txt_transient, DAY_IN_SECONDS );
+ }
+
+ /**
+ * Provide plugins a way of modifying the contents of the automatically-generated ads.txt file.
+ *
+ * @module wordads
+ *
+ * @since 6.1.0
+ *
+ * @param string WordAds_API::get_wordads_ads_txt() The contents of the ads.txt file.
+ */
+ $ads_txt_content = apply_filters( 'wordads_ads_txt', $ads_txt_transient );
+
+ header( 'Content-Type: text/plain; charset=utf-8' );
+ echo esc_html( $ads_txt_content );
+ die();
+ }
}
/**
* Check for Jetpack's The_Neverending_Home_Page and use got_infinity
+ *
* @return boolean true if load came from infinite scroll
*
* @since 4.5.0
@@ -110,9 +137,9 @@ class WordAds {
* @since 4.5.0
*/
private function insert_adcode() {
- add_action( 'wp_head', array( $this, 'insert_head_meta' ), 20 );
- add_action( 'wp_head', array( $this, 'insert_head_iponweb' ), 30 );
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
+ add_action( 'wp_head', array( $this, 'insert_head_meta' ), 20 );
+ add_action( 'wp_head', array( $this, 'insert_head_iponweb' ), 30 );
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
/**
* Filters enabling ads in `the_content` filter
@@ -181,9 +208,10 @@ class WordAds {
$pagetype = intval( $this->params->get_page_type_ipw() );
$data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : '';
$site_id = $this->params->blog_id;
+ $consent = intval( isset( $_COOKIE['personalized-ads-consent'] ) );
echo <<<HTML
<script$data_tags type="text/javascript">
- var __ATA_PP = { pt: $pagetype, ht: 2, tn: '$themename', amp: false, siteid: $site_id };
+ var __ATA_PP = { pt: $pagetype, ht: 2, tn: '$themename', amp: false, siteid: $site_id, consent: $consent };
var __ATA = __ATA || {};
__ATA.cmd = __ATA.cmd || [];
__ATA.criteo = __ATA.criteo || {};
@@ -214,9 +242,6 @@ HTML;
<link rel='dns-prefetch' href='//ad.doubleclick.net' />
<link rel='dns-prefetch' href='//googleads.g.doubleclick.net' />
<link rel='dns-prefetch' href='//www.googletagservices.com' />
- <link rel='dns-prefetch' href='//cdn.switchadhub.com' />
- <link rel='dns-prefetch' href='//delivery.g.switchadhub.com' />
- <link rel='dns-prefetch' href='//delivery.swid.switchadhub.com' />
<script$data_tags async type="text/javascript" src="//s.pubmine.com/head.js"></script>
HTML;
}
@@ -227,8 +252,8 @@ HTML;
* @since 4.5.0
*/
function insert_ad( $content ) {
- // Ad JS won't work in XML feeds.
- if ( is_feed() ) {
+ // Don't insert ads in feeds, or for anything but the main display. (This is required for compatibility with the Publicize module).
+ if ( is_feed() || ! is_main_query() || ! in_the_loop() ) {
return $content;
}
/**
@@ -250,6 +275,36 @@ HTML;
}
/**
+ * Insert an inline ad into a post content
+ * Used for rendering the `wordads` shortcode.
+ *
+ * @since 6.1.0
+ */
+ function insert_inline_ad( $content ) {
+ // Ad JS won't work in XML feeds.
+ if ( is_feed() ) {
+ return $content;
+ }
+ /**
+ * Allow third-party tools to disable the display of in post ads.
+ *
+ * @module wordads
+ *
+ * @since 4.5.0
+ *
+ * @param bool true Should the in post unit be disabled. Default to false.
+ */
+ $disable = apply_filters( 'wordads_inpost_disable', false );
+ if ( $disable ) {
+ return $content;
+ }
+
+ $ad_type = $this->option( 'wordads_house' ) ? 'house' : 'iponweb';
+ $content .= $this->get_ad( 'inline', $ad_type );
+ return $content;
+ }
+
+ /**
* Inserts ad into header
*
* @since 4.5.0
@@ -315,16 +370,17 @@ HTML;
/**
* Get the ad for the spot and type.
- * @param string $spot top, side, or belowpost
+ * @param string $spot top, side, inline, or belowpost
* @param string $type iponweb or adsense
*/
function get_ad( $spot, $type = 'iponweb' ) {
$snippet = '';
- $blocker_unit = 'mrec';
if ( 'iponweb' == $type ) {
- $section_id = WORDADS_API_TEST_ID;
+ // Default to mrec
$width = 300;
$height = 250;
+
+ $section_id = WORDADS_API_TEST_ID;
$second_belowpost = '';
$snippet = '';
if ( 'top' == $spot ) {
@@ -332,18 +388,20 @@ HTML;
$section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '2';
$width = $this->params->mobile_device ? 300 : 728;
$height = $this->params->mobile_device ? 250 : 90;
- $blocker_unit = $this->params->mobile_device ? 'top_mrec' : 'top';
- $snippet = $this->get_ad_snippet( $section_id, $height, $width, $blocker_unit );
+ $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot );
} else if ( 'belowpost' == $spot ) {
$section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '1';
$width = 300;
$height = 250;
- $snippet = $this->get_ad_snippet( $section_id, $height, $width, 'mrec', 'float:left;margin-right:5px;margin-top:0px;' );
+ $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot, 'float:left;margin-right:5px;margin-top:0px;' );
if ( $this->option( 'wordads_second_belowpost', true ) ) {
$section_id2 = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID2 : $this->params->blog_id . '4';
- $snippet .= $this->get_ad_snippet( $section_id2, $height, $width, 'mrec2', 'float:left;margin-top:0px;' );
+ $snippet .= $this->get_ad_snippet( $section_id2, $height, $width, $spot, 'float:left;margin-top:0px;' );
}
+ } else if ( 'inline' === $spot ) {
+ $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '5';
+ $snippet = $this->get_ad_snippet( $section_id, $height, $width, $spot, 'mrec', 'float:left;margin-right:5px;margin-top:0px;' );
}
} else if ( 'house' == $type ) {
$leaderboard = 'top' == $spot && ! $this->params->mobile_device;
@@ -373,70 +431,41 @@ HTML;
* @param int $section_id
* @param int $height
* @param int $width
+ * @param int $location
* @param string $css
* @return string
*
* @since 5.7
*/
- function get_ad_snippet( $section_id, $height, $width, $adblock_unit = 'mrec', $css = '' ) {
- $this->ads[] = array( 'id' => $section_id, 'width' => $width, 'height' => $height );
+ function get_ad_snippet( $section_id, $height, $width, $location = '', $css = '' ) {
+ $this->ads[] = array( 'location' => $location, 'width' => $width, 'height' => $height );
+ $ad_number = count( $this->ads );
+ // Max 6 ads per page.
+ if ( $ad_number > 5 && 'top' !== $location ) {
+ return;
+ }
$data_tags = $this->params->cloudflare ? ' data-cfasync="false"' : '';
- $adblock_ad = $this->get_adblocker_ad( $adblock_unit );
return <<<HTML
<div style="padding-bottom:15px;width:{$width}px;height:{$height}px;$css">
- <div id="atatags-{$section_id}">
+ <div id="atatags-{$ad_number}">
<script$data_tags type="text/javascript">
__ATA.cmd.push(function() {
- __ATA.initSlot('atatags-{$section_id}', {
+ __ATA.initSlot('atatags-{$ad_number}', {
collapseEmpty: 'before',
sectionId: '{$section_id}',
+ location: '{$location}',
width: {$width},
height: {$height}
});
});
</script>
- $adblock_ad
</div>
</div>
HTML;
}
/**
- * Get Criteo Acceptable Ad unit
- * @param string $unit mrec, mrec2, widesky, top, top_mrec
- *
- * @since 5.3
- */
- public function get_adblocker_ad( $unit = 'mrec' ) {
- $data_tags = $this->params->cloudflare ? ' data-cfasync="false"' : '';
- $criteo_id = mt_rand();
- $height = 250;
- $width = 300;
- $zone_id = 388248;
- if ( 'mrec2' == $unit ) { // 2nd belowpost
- $zone_id = 837497;
- } else if ( 'widesky' == $unit ) { // sidebar
- $zone_id = 563902;
- $width = 160;
- $height= 600;
- } else if ( 'top' == $unit ) { // top leaderboard
- $zone_id = 563903;
- $width = 728;
- $height = 90;
- } else if ( 'top_mrec' == $unit ) { // top mrec
- $zone_id = 563903;
- }
-
- return <<<HTML
- <div id="crt-$criteo_id" style="width:{$width}px;height:{$height}px;display:none !important;"></div>
- <script$data_tags type="text/javascript">
- (function(){var c=function(){var a=document.getElementById("crt-{$criteo_id}");window.Criteo?(a.parentNode.style.setProperty("display","inline-block","important"),a.style.setProperty("display","block","important"),window.Criteo.DisplayAcceptableAdIfAdblocked({zoneid:{$zone_id},containerid:"crt-{$criteo_id}",collapseContainerIfNotAdblocked:!0,callifnotadblocked:function(){a.style.setProperty("display","none","important");a.style.setProperty("visbility","hidden","important")}})):(a.style.setProperty("display","none","important"),a.style.setProperty("visibility","hidden","important"))};if(window.Criteo)c();else{if(!__ATA.criteo.script){var b=document.createElement("script");b.src="//static.criteo.net/js/ld/publishertag.js";b.onload=function(){for(var a=0;a<__ATA.criteo.cmd.length;a++){var b=__ATA.criteo.cmd[a];"function"===typeof b&&b()}};(document.head||document.getElementsByTagName("head")[0]).appendChild(b);__ATA.criteo.script=b}__ATA.criteo.cmd.push(c)}})();
- </script>
-HTML;
- }
-
- /**
* Check the reasons to bail before we attempt to insert ads.
* @return true if we should bail (don't insert ads)
*
@@ -454,18 +483,21 @@ HTML;
* @since 4.7.0
*/
public function get_house_ad( $unit = 'mrec' ) {
- if ( ! in_array( $unit, array( 'mrec', 'widesky', 'leaderboard' ) ) ) {
- $unit = 'mrec';
- }
- $width = 300;
- $height = 250;
- if ( 'widesky' == $unit ) {
- $width = 160;
- $height = 600;
- } else if ( 'leaderboard' == $unit ) {
- $width = 728;
- $height = 90;
+ switch ( $unit ) {
+ case 'widesky':
+ $width = 160;
+ $height = 600;
+ break;
+ case 'leaderboard':
+ $width = 728;
+ $height = 90;
+ break;
+ case 'mrec':
+ default:
+ $width = 300;
+ $height = 250;
+ break;
}
return <<<HTML