From 94c72825c0124611b1cdac93bc668c0d8dbd03c4 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 13:24:10 -0400 Subject: [PATCH 1/7] add redirects for old plugin urls --- inc/Admin.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/inc/Admin.php b/inc/Admin.php index 2c17cd4..9a16724 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -29,6 +29,9 @@ public function __construct() { \add_action( 'admin_head', array( __CLASS__, 'admin_nav_style' ) ); /* Add runtime for data store */ \add_filter( 'newfold_runtime', array( __CLASS__, 'add_to_runtime' ) ); + /* Add redirect from old url */ + \add_action( 'admin_menu', array( __CLASS__, 'old_admin_pages' ) ); + \add_action( 'admin_init', array( __CLASS__, 'old_admin_redirect' ) ); if ( isset( $_GET['page'] ) && strpos( filter_input( INPUT_GET, 'page', FILTER_UNSAFE_RAW ), 'mojo' ) >= 0 ) { // phpcs:ignore \add_action( 'admin_footer_text', array( __CLASS__, 'add_brand_to_admin_footer' ) ); @@ -226,4 +229,53 @@ public static function add_brand_to_admin_footer( $footer_text ) { $footer_text = \sprintf( \__( 'Thank you for creating with WordPress and MOJO.', 'wp-plugin-mojo' ) ); return $footer_text; } + + /** + * Old Mojo Url ids + * @return array + */ + public static function get_old_url_ids(){ + return array( + 'mojo-marketplace', + 'mojo-performance', + 'mojo-staging', + 'mojo-home', + 'mojo-hosting-panel', + 'mojo-jetpack-connect-bounce' + ); + } + + /** + * Keep dummy links for old admin pages + * so we can redirect to the new page. + * + * @return void + */ + public static function old_admin_pages() { + // Add old plugin pages (for redirecting) + foreach( self::get_old_url_ids() as $id ) { + \add_menu_page( + __( 'MOJO', 'wp-plugin-mojo' ), + __( 'MOJO', 'wp-plugin-mojo' ), + 'manage_options', + $id, + false + ); + } + } + + /** + * Redirect old admin page to new admin page, + * only applies on first nav click after update or a bookmark. + * + * @return void + */ + public static function old_admin_redirect() { + global $pagenow; + if ( $pagenow == 'admin.php' && in_array( $_GET['page'], self::get_old_url_ids() ) ) { + wp_redirect( admin_url( 'admin.php?page=mojo' ) ); + exit; + } + } + } // END \MOJO\Admin From 601ad717c566b3799f1be53306a5fcf0957f8c8d Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 17:25:32 +0000 Subject: [PATCH 2/7] WordPress i18n triggered by commit 94c72825c0124611b1cdac93bc668c0d8dbd03c4 --- languages/wp-plugin-mojo.pot | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/languages/wp-plugin-mojo.pot b/languages/wp-plugin-mojo.pot index 04db75f..7b7af78 100644 --- a/languages/wp-plugin-mojo.pot +++ b/languages/wp-plugin-mojo.pot @@ -74,51 +74,53 @@ msgstr "" msgid "Preview the coming soon landing page" msgstr "" -#: inc/Admin.php:58 -#: inc/Admin.php:212 +#: inc/Admin.php:61 +#: inc/Admin.php:215 #: build/3.2.0/index.js:1 msgid "Home" msgstr "" -#: inc/Admin.php:61 +#: inc/Admin.php:64 #: build/3.2.0/index.js:1 msgid "Marketplace" msgstr "" -#: inc/Admin.php:66 +#: inc/Admin.php:69 #: build/3.2.0/index.js:1 msgid "Performance" msgstr "" -#: inc/Admin.php:70 -#: inc/Admin.php:213 +#: inc/Admin.php:73 +#: inc/Admin.php:216 #: build/3.2.0/index.js:1 msgid "Settings" msgstr "" -#: inc/Admin.php:73 +#: inc/Admin.php:76 #: build/3.2.0/index.js:1 msgid "Help" msgstr "" -#: inc/Admin.php:115 -#: inc/Admin.php:116 +#: inc/Admin.php:118 +#: inc/Admin.php:119 +#: inc/Admin.php:258 +#: inc/Admin.php:259 msgid "MOJO" msgstr "" -#: inc/Admin.php:158 +#: inc/Admin.php:161 msgid "Please update to a newer WordPress version." msgstr "" -#: inc/Admin.php:159 +#: inc/Admin.php:162 msgid "There are new WordPress components which this plugin requires in order to render the interface." msgstr "" -#: inc/Admin.php:160 +#: inc/Admin.php:163 msgid "Please update now" msgstr "" -#: inc/Admin.php:226 +#: inc/Admin.php:229 msgid "Thank you for creating with WordPress and MOJO." msgstr "" From 8f652f171faf0d2b598312a3f60dbce151a6a868 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 13:44:48 -0400 Subject: [PATCH 3/7] add another old page id --- inc/Admin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/Admin.php b/inc/Admin.php index 9a16724..0697673 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -241,7 +241,8 @@ public static function get_old_url_ids(){ 'mojo-staging', 'mojo-home', 'mojo-hosting-panel', - 'mojo-jetpack-connect-bounce' + 'mojo-jetpack-connect-bounce', + 'mojo-marketplace-page', ); } From 86976cb679cbb4c9871b4a513ba2f836678238dc Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 17:46:31 +0000 Subject: [PATCH 4/7] WordPress i18n triggered by commit 5e601eff902231313f20f5022723fbcade69e5cc --- languages/wp-plugin-mojo.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/wp-plugin-mojo.pot b/languages/wp-plugin-mojo.pot index 7b7af78..32f0d8d 100644 --- a/languages/wp-plugin-mojo.pot +++ b/languages/wp-plugin-mojo.pot @@ -103,8 +103,8 @@ msgstr "" #: inc/Admin.php:118 #: inc/Admin.php:119 -#: inc/Admin.php:258 #: inc/Admin.php:259 +#: inc/Admin.php:260 msgid "MOJO" msgstr "" From 5bcb5a65f99e02e400749b8ce4504db61ff81f26 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 14:47:18 -0400 Subject: [PATCH 5/7] linting --- inc/Admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/Admin.php b/inc/Admin.php index 0697673..61d9e9b 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -232,9 +232,10 @@ public static function add_brand_to_admin_footer( $footer_text ) { /** * Old Mojo Url ids + * * @return array */ - public static function get_old_url_ids(){ + public static function get_old_url_ids() { return array( 'mojo-marketplace', 'mojo-performance', @@ -254,7 +255,7 @@ public static function get_old_url_ids(){ */ public static function old_admin_pages() { // Add old plugin pages (for redirecting) - foreach( self::get_old_url_ids() as $id ) { + foreach ( self::get_old_url_ids() as $id ) { \add_menu_page( __( 'MOJO', 'wp-plugin-mojo' ), __( 'MOJO', 'wp-plugin-mojo' ), @@ -273,10 +274,9 @@ public static function old_admin_pages() { */ public static function old_admin_redirect() { global $pagenow; - if ( $pagenow == 'admin.php' && in_array( $_GET['page'], self::get_old_url_ids() ) ) { + if ( $pagenow === 'admin.php' && in_array( $_GET['page'], self::get_old_url_ids() ) ) { wp_redirect( admin_url( 'admin.php?page=mojo' ) ); exit; } } - } // END \MOJO\Admin From d12ea52f67e4d23c96d226e8ad19e4da80aec832 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 18:48:50 +0000 Subject: [PATCH 6/7] WordPress i18n triggered by commit d3f4a1b591cd84ac2000b6af76a035ee832925a4 --- languages/wp-plugin-mojo.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/wp-plugin-mojo.pot b/languages/wp-plugin-mojo.pot index 32f0d8d..ef072c4 100644 --- a/languages/wp-plugin-mojo.pot +++ b/languages/wp-plugin-mojo.pot @@ -103,8 +103,8 @@ msgstr "" #: inc/Admin.php:118 #: inc/Admin.php:119 -#: inc/Admin.php:259 #: inc/Admin.php:260 +#: inc/Admin.php:261 msgid "MOJO" msgstr "" From 61c283aa50e17719a14bd31d4ec6d2e6b1b56ca2 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Aug 2024 14:50:50 -0400 Subject: [PATCH 7/7] yoda lint --- inc/Admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/Admin.php b/inc/Admin.php index 61d9e9b..79b781e 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -274,7 +274,7 @@ public static function old_admin_pages() { */ public static function old_admin_redirect() { global $pagenow; - if ( $pagenow === 'admin.php' && in_array( $_GET['page'], self::get_old_url_ids() ) ) { + if ( 'admin.php' === $pagenow && in_array( $_GET['page'], self::get_old_url_ids() ) ) { wp_redirect( admin_url( 'admin.php?page=mojo' ) ); exit; }