From e9bd0d36336d84aae1e870f430a5a4645f5df588 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Wed, 7 Jun 2023 15:58:34 +0530 Subject: [PATCH 1/7] Update class-wpcom-liveblog-entry-embed-sdks.php --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index 01c84b8ae..837a75b4f 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -14,7 +14,7 @@ class WPCOM_Liveblog_Entry_Embed_SDKs { 'facebook' => 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5', 'twitter' => 'https://platform.twitter.com/widgets.js', 'instagram' => 'https://platform.instagram.com/en_US/embeds.js', - 'reddit' => 'https://embed.redditmedia.com/widgets/platform.js', + 'reddit' => 'https://embed.reddit.com/widgets.js', ); /** From 9114a7ceba619434c222c9a4517b2642cf3996f8 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Fri, 9 Jun 2023 07:15:44 +0530 Subject: [PATCH 2/7] Update class-wpcom-liveblog-entry-embed-sdks.php found reddit js file does not working with version. these are the third party library then we don't needs to add version on these sdks --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index 837a75b4f..d54bf495f 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -39,7 +39,7 @@ public static function enqueue() { } foreach ( self::$sdks as $name => $url ) { - wp_enqueue_script( $name, esc_url( $url ), array(), WPCOM_Liveblog::VERSION, false ); + wp_enqueue_script( $name, esc_url( $url ), array(), null, false ); } } From a1e8bd6f2666009fca30d7a71b872170889f7d5d Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Fri, 9 Jun 2023 17:50:40 +0530 Subject: [PATCH 3/7] Update class-wpcom-liveblog-entry-embed-sdks.php Instagram js also changed --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index d54bf495f..f9a3ad3da 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -13,7 +13,7 @@ class WPCOM_Liveblog_Entry_Embed_SDKs { protected static $sdks = array( 'facebook' => 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5', 'twitter' => 'https://platform.twitter.com/widgets.js', - 'instagram' => 'https://platform.instagram.com/en_US/embeds.js', + 'instagram' => 'https://www.instagram.com/embed.js', 'reddit' => 'https://embed.reddit.com/widgets.js', ); From cb6b6a505d0af459d8af2d6da95c7aea74acf518 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Tue, 20 Jun 2023 23:12:17 +0530 Subject: [PATCH 4/7] Update class-wpcom-liveblog-entry-embed-sdks.php for reddit added conditional statement, version should not add in reddit js otherwise it will redirect to 404 --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index f9a3ad3da..6f05f0915 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -39,7 +39,11 @@ public static function enqueue() { } foreach ( self::$sdks as $name => $url ) { - wp_enqueue_script( $name, esc_url( $url ), array(), null, false ); + if ( 'reddit' === $name ) { + wp_enqueue_script( $name, esc_url( $url ), array(), null, false ); + } else { + wp_enqueue_script( $name, esc_url( $url ), array(), WPCOM_Liveblog::VERSION, false ); + } } } From 9485e8c521e6413810126894b6f21dd55ca21067 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Mon, 26 Jun 2023 10:40:12 +0530 Subject: [PATCH 5/7] Apply suggestions from code review Version added except reddit script Co-authored-by: Rebecca Hum <16962021+rebeccahum@users.noreply.github.com> --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index 6f05f0915..bfd175a24 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -40,7 +40,9 @@ public static function enqueue() { foreach ( self::$sdks as $name => $url ) { if ( 'reddit' === $name ) { - wp_enqueue_script( $name, esc_url( $url ), array(), null, false ); + // Do not attach `?ver=` for reddit script due to redirects + $version = 'reddit' === $name ? null : WPCOM_Liveblog::VERSION; + wp_enqueue_script( $name, esc_url( $url ), array(), $version, false ); } else { wp_enqueue_script( $name, esc_url( $url ), array(), WPCOM_Liveblog::VERSION, false ); } From e66ea516781f000e5a1fe8efb72d04bd6fb67569 Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Mon, 26 Jun 2023 10:45:04 +0530 Subject: [PATCH 6/7] Update class-wpcom-liveblog-entry-embed-sdks.php Comments added --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index bfd175a24..e4b2f6e91 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -40,7 +40,7 @@ public static function enqueue() { foreach ( self::$sdks as $name => $url ) { if ( 'reddit' === $name ) { - // Do not attach `?ver=` for reddit script due to redirects + // Don't attach version with reddit js script file, it will generate 404 error with reddit js $version = 'reddit' === $name ? null : WPCOM_Liveblog::VERSION; wp_enqueue_script( $name, esc_url( $url ), array(), $version, false ); } else { From 403d51315b725b9bfed140810c6f3aff81ead8cb Mon Sep 17 00:00:00 2001 From: Deepak rohilla Date: Mon, 26 Jun 2023 10:58:16 +0530 Subject: [PATCH 7/7] Update class-wpcom-liveblog-entry-embed-sdks.php Reddit js script file will enqueue without version and rest js will be added with version. --- classes/class-wpcom-liveblog-entry-embed-sdks.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/class-wpcom-liveblog-entry-embed-sdks.php b/classes/class-wpcom-liveblog-entry-embed-sdks.php index e4b2f6e91..3c36127bd 100644 --- a/classes/class-wpcom-liveblog-entry-embed-sdks.php +++ b/classes/class-wpcom-liveblog-entry-embed-sdks.php @@ -39,13 +39,9 @@ public static function enqueue() { } foreach ( self::$sdks as $name => $url ) { - if ( 'reddit' === $name ) { - // Don't attach version with reddit js script file, it will generate 404 error with reddit js - $version = 'reddit' === $name ? null : WPCOM_Liveblog::VERSION; - wp_enqueue_script( $name, esc_url( $url ), array(), $version, false ); - } else { - wp_enqueue_script( $name, esc_url( $url ), array(), WPCOM_Liveblog::VERSION, false ); - } + // Don't attach version with reddit js script file, it will generate 404 error with reddit js + $version = 'reddit' === $name ? null : WPCOM_Liveblog::VERSION; + wp_enqueue_script( $name, esc_url( $url ), array(), $version, false ); } }