Skip to content

Commit 5c613b4

Browse files
committed
Resolve multisite compatibility issue with latest updates
1 parent 5534d98 commit 5c613b4

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/admin.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ const AdminPage = () => {
140140
}
141141
}
142142

143-
console.log(rollbackInfo);
144-
console.log(queryArgs);
145-
146143
return (
147144
<div className={'wpr-wrapper'}>
148145
<div className={'wpr-logo-wrap'}>

src/themes-wp-rollback.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const wprThemeRollback = theme => {
6363

6464
const wprGetThemeData = theme => {
6565
const themeData = wp.themes?.data?.themes;
66+
6667
if (!Array.isArray(themeData)) {
6768
console.error('Invalid theme data');
6869
return null;

wp-rollback.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,7 @@ private function setup_constants(): void {
188188
private function hooks(): void {
189189

190190
// Multisite compatibility: only loads on main site.
191-
if ( is_network_admin() ) {
192-
$this->multisite_compatibility = new WP_Rollback_Multisite_Compatibility( $this );
193-
}
194-
195-
if ( is_multisite() && ! is_network_admin() ) {
196-
return;
197-
}
191+
$this->multisite_compatibility = new WP_Rollback_Multisite_Compatibility( $this );
198192

199193
// i18n
200194
add_action( 'plugins_loaded', [ self::$instance, 'load_textdomain' ] );
@@ -228,7 +222,7 @@ private function hooks(): void {
228222
public function scripts( $hook ): void {
229223

230224
// Theme's listing page JS
231-
if ( 'themes.php' === $hook ) {
225+
if ( 'themes.php' === $hook && !is_multisite() ) {
232226
$theme_script_asset = require WP_ROLLBACK_PLUGIN_DIR . '/build/themes.asset.php';
233227

234228
wp_enqueue_script(
@@ -477,6 +471,11 @@ private function setup_plugin_vars() {
477471
* @return array $actions
478472
*/
479473
public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ): array {
474+
475+
if ( !is_network_admin()) {
476+
return $actions;
477+
}
478+
480479
// Filter for other devs.
481480
$plugin_data = apply_filters( 'wpr_plugin_data', $plugin_data );
482481

@@ -492,7 +491,7 @@ public function plugin_action_links( $actions, $plugin_file, $plugin_data, $cont
492491
}
493492

494493
// Base rollback URL
495-
$rollback_url = admin_url( 'index.php' );
494+
$rollback_url = is_network_admin() ? network_admin_url( 'index.php' ) : admin_url( 'index.php' );
496495

497496
$rollback_url = add_query_arg(
498497
apply_filters(
@@ -688,7 +687,7 @@ public function wpr_prepare_themes_js( $prepared_themes ): array {
688687

689688
// Loop through themes and provide a 'hasRollback' boolean key for JS.
690689
foreach ( $prepared_themes as $key => $value ) {
691-
$themes[ $key ] = $prepared_themes[ $key ];
690+
$themes[ $key ] = $value;
692691
$themes[ $key ]['hasRollback'] = isset( $rollbacks[ $key ] );
693692
}
694693

0 commit comments

Comments
 (0)