This commit is contained in:
Javier Casares 2026-03-02 14:31:34 +00:00
commit 2c300652a6
9 changed files with 230 additions and 82 deletions

View file

@ -89,11 +89,15 @@ class Robotstxt_Mlp2_Mlp5_Admin_Page {
if ( ! current_user_can( self::CAPABILITY ) ) {
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
}
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::rename_to_backup();
$args = array( 'renamed' => count( $result['renamed'] ) );
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::rename_to_backup();
$sitemeta_renamed = Robotstxt_Mlp2_Mlp5_Table_Preparer::rename_mlp2_sitemeta();
$args = array( 'renamed' => count( $result['renamed'] ) );
if ( ! empty( $result['errors'] ) ) {
$args['rename_errors'] = count( $result['errors'] );
}
if ( $sitemeta_renamed > 0 ) {
$args['sitemeta_renamed'] = $sitemeta_renamed;
}
wp_safe_redirect( self::page_url( $args ) );
exit;
}
@ -106,11 +110,15 @@ class Robotstxt_Mlp2_Mlp5_Admin_Page {
if ( ! current_user_can( self::CAPABILITY ) ) {
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
}
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::restore_from_backup();
$args = array( 'restored' => count( $result['restored'] ) );
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::restore_from_backup();
$sitemeta_restored = Robotstxt_Mlp2_Mlp5_Table_Preparer::restore_mlp2_sitemeta();
$args = array( 'restored' => count( $result['restored'] ) );
if ( ! empty( $result['errors'] ) ) {
$args['restore_errors'] = count( $result['errors'] );
}
if ( $sitemeta_restored > 0 ) {
$args['sitemeta_restored'] = $sitemeta_restored;
}
wp_safe_redirect( self::page_url( $args ) );
exit;
}
@ -423,6 +431,12 @@ class Robotstxt_Mlp2_Mlp5_Admin_Page {
/* translators: %d: number of tables that could not be renamed */
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( sprintf( _n( '%d table could not be renamed. Check database permissions.', '%d tables could not be renamed. Check database permissions.', $count, 'robotstxt-mlp2-mlp5' ), $count ) ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders
}
if ( isset( $_GET['sitemeta_renamed'] ) ) {
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html__( 'MLP2 sitemeta backed up. MultilingualPress 5 can now activate cleanly.', 'robotstxt-mlp2-mlp5' ) );
}
if ( isset( $_GET['sitemeta_restored'] ) ) {
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html__( 'MLP2 sitemeta restored to original keys.', 'robotstxt-mlp2-mlp5' ) );
}
if ( isset( $_GET['restored'] ) ) {
$count = (int) $_GET['restored'];
/* translators: %d: number of restored tables */