Skip to content

Commit

Permalink
Merge pull request #293 from newfold-labs/add/redirects-for-old-plugi…
Browse files Browse the repository at this point in the history
…n-urls

Add/redirects for old plugin urls
  • Loading branch information
circlecube authored Aug 12, 2024
2 parents 92f92e2 + 7fe520f commit 619d959
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
53 changes: 53 additions & 0 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -226,4 +229,54 @@ public static function add_brand_to_admin_footer( $footer_text ) {
$footer_text = \sprintf( \__( 'Thank you for creating with <a href="https://wordpress.org/">WordPress</a> and <a href="https://mojomarketplace.com/about">MOJO</a>.', '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',
'mojo-marketplace-page',
);
}

/**
* 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 ( 'admin.php' === $pagenow && in_array( $_GET['page'], self::get_old_url_ids() ) ) {
wp_redirect( admin_url( 'admin.php?page=mojo' ) );
exit;
}
}
} // END \MOJO\Admin
28 changes: 15 additions & 13 deletions languages/wp-plugin-mojo.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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:260
#: inc/Admin.php:261
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 <a href=\"https://wordpress.org/\">WordPress</a> and <a href=\"https://mojomarketplace.com/about\">MOJO</a>."
msgstr ""

Expand Down

0 comments on commit 619d959

Please sign in to comment.