From f9f027f05aff2758819e6fb09cae3b0a35438f5b Mon Sep 17 00:00:00 2001 From: stevenlin-x Date: Thu, 19 Apr 2018 22:40:59 +0800 Subject: [PATCH 1/5] Widget: Added option to set DoNotTrack in Twitter Widget --- modules/widgets/twitter-timeline.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/widgets/twitter-timeline.php b/modules/widgets/twitter-timeline.php index d9c8c94708eef..647f9c58cabfe 100644 --- a/modules/widgets/twitter-timeline.php +++ b/modules/widgets/twitter-timeline.php @@ -115,7 +115,7 @@ public function widget( $args, $instance ) { // Start tag output // This tag is transformed into the widget markup by Twitter's // widgets.js code - echo ' Date: Sat, 21 Apr 2018 00:24:14 +0800 Subject: [PATCH 2/5] Make the attribute filterable --- modules/widgets/twitter-timeline.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/widgets/twitter-timeline.php b/modules/widgets/twitter-timeline.php index 647f9c58cabfe..6b128e56c2eb2 100644 --- a/modules/widgets/twitter-timeline.php +++ b/modules/widgets/twitter-timeline.php @@ -115,7 +115,7 @@ public function widget( $args, $instance ) { // Start tag output // This tag is transformed into the widget markup by Twitter's // widgets.js code - echo ' 'light', 'chrome' => array(), 'tweet-limit' => null, + 'dnt' => apply_filters( 'jetpack_twitter_timeline_default_dnt', false ), ); $instance = wp_parse_args( (array) $instance, $defaults ); From 050d1a9549828a559f4ee6a304994386ea5030cb Mon Sep 17 00:00:00 2001 From: stevenlin-x Date: Tue, 24 Apr 2018 00:33:13 +0800 Subject: [PATCH 3/5] Make the attribute filterable #2 --- modules/widgets/twitter-timeline.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/widgets/twitter-timeline.php b/modules/widgets/twitter-timeline.php index 6b128e56c2eb2..2f6a490de59cc 100644 --- a/modules/widgets/twitter-timeline.php +++ b/modules/widgets/twitter-timeline.php @@ -271,6 +271,12 @@ public function update( $new_instance, $old_instance ) { } } + if ( 'true' === $new_instance['dnt'] | 'false' === $new_instance['dnt'] ) { + $instance['dnt'] = $new_instance['dnt']; + } else { + $instance['dnt'] = 'true'; + } + return $instance; } From e5dc8499b0e716b1b6de607b3b1718cafcd106d7 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Fri, 7 Sep 2018 14:49:13 +0200 Subject: [PATCH 4/5] Twitter Timeline: add DNT option via filter. See https://github.com/Automattic/jetpack/pull/9359/ --- modules/widgets/twitter-timeline.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/widgets/twitter-timeline.php b/modules/widgets/twitter-timeline.php index 2f6a490de59cc..259758646ee66 100644 --- a/modules/widgets/twitter-timeline.php +++ b/modules/widgets/twitter-timeline.php @@ -138,6 +138,20 @@ public function widget( $args, $instance ) { echo ' data-partner="' . esc_attr( $partner ) . '"'; } + /** + * Allow the activation of Do Not Track for the Twitter Timeline Widget. + * + * @see https://developer.twitter.com/en/docs/twitter-for-websites/timelines/guides/parameter-reference.html + * + * @since 6.6.0 + * + * @param bool false Should the Twitter Timeline use the DNT attribute? Default to false. + */ + $dnt = apply_filters( 'jetpack_twitter_timeline_default_dnt', false ); + if ( true === $dnt ) { + echo ' data-dnt="true"'; + } + if ( ! empty( $instance['chrome'] ) && is_array( $instance['chrome'] ) ) { echo ' data-chrome="' . esc_attr( join( ' ', $instance['chrome'] ) ) . '"'; } @@ -271,12 +285,6 @@ public function update( $new_instance, $old_instance ) { } } - if ( 'true' === $new_instance['dnt'] | 'false' === $new_instance['dnt'] ) { - $instance['dnt'] = $new_instance['dnt']; - } else { - $instance['dnt'] = 'true'; - } - return $instance; } @@ -312,7 +320,6 @@ public function form( $instance ) { 'theme' => 'light', 'chrome' => array(), 'tweet-limit' => null, - 'dnt' => apply_filters( 'jetpack_twitter_timeline_default_dnt', false ), ); $instance = wp_parse_args( (array) $instance, $defaults ); From ccdf18c1d70d5662084552edd9d0536338f02b18 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Thu, 6 Dec 2018 14:59:28 +0100 Subject: [PATCH 5/5] Twitter timeline: update new filter's docblock --- modules/widgets/twitter-timeline.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/widgets/twitter-timeline.php b/modules/widgets/twitter-timeline.php index 259758646ee66..0f16e330df6bc 100644 --- a/modules/widgets/twitter-timeline.php +++ b/modules/widgets/twitter-timeline.php @@ -143,7 +143,9 @@ public function widget( $args, $instance ) { * * @see https://developer.twitter.com/en/docs/twitter-for-websites/timelines/guides/parameter-reference.html * - * @since 6.6.0 + * @module widgets + * + * @since 6.9.0 * * @param bool false Should the Twitter Timeline use the DNT attribute? Default to false. */