Skip to content

Commit 388be6a

Browse files
Remove prompt
1 parent 950dfca commit 388be6a

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

admin/load.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,9 @@ function perflab_enqueue_modules_page_scripts() {
558558
'perflab-module-migration-notice',
559559
'perflab_module_migration_notice',
560560
array(
561-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
562-
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
563-
'network_error' => esc_html__( 'Network response was not ok.', 'performance-lab' ),
564-
'prompt_message' => esc_html__( 'Are you sure you want to migrate legacy modules to standalone plugins?', 'performance-lab' ),
561+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
562+
'nonce' => wp_create_nonce( 'perflab-install-activate-plugins' ),
563+
'network_error' => esc_html__( 'Network response was not ok.', 'performance-lab' ),
565564
)
566565
);
567566
}

admin/perflab-module-migration-notice.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,43 @@
22
document.addEventListener( 'DOMContentLoaded', function() {
33
document.addEventListener( 'click', function(event) {
44
if ( event.target.classList.contains( 'perflab-install-active-plugin' ) ) {
5+
var target = event.target;
6+
target.parentElement.querySelector( 'span' ).classList.remove( 'hidden' );
57

6-
if ( confirm( perflab_module_migration_notice.prompt_message ) ) {
7-
var target = event.target;
8-
target.parentElement.querySelector( 'span' ).classList.remove( 'hidden' );
8+
var data = new FormData();
9+
data.append( 'action', 'perflab_install_activate_standalone_plugins' );
10+
data.append( 'nonce', perflab_module_migration_notice.nonce );
911

10-
var data = new FormData();
11-
data.append( 'action', 'perflab_install_activate_standalone_plugins' );
12-
data.append( 'nonce', perflab_module_migration_notice.nonce );
13-
14-
fetch( perflab_module_migration_notice.ajaxurl, {
15-
method: 'POST',
16-
credentials: 'same-origin',
17-
body: data
18-
})
19-
.then( function ( response ) {
20-
if ( ! response.ok ) {
21-
throw new Error( perflab_module_migration_notice.network_error );
22-
}
23-
return response.json();
24-
})
25-
.then( function( result ) {
26-
target.parentElement.querySelector( 'span' ).classList.add( 'hidden' );
27-
if ( ! result.success ) {
28-
alert( result.data.errorMessage );
29-
}
30-
window.location.reload();
31-
})
32-
.catch( function( error ) {
33-
alert( error.errorMessage );
34-
window.location.reload();
35-
});
36-
}
12+
fetch( perflab_module_migration_notice.ajaxurl, {
13+
method: 'POST',
14+
credentials: 'same-origin',
15+
body: data
16+
})
17+
.then( function ( response ) {
18+
if ( ! response.ok ) {
19+
throw new Error( perflab_module_migration_notice.network_error );
20+
}
21+
return response.json();
22+
})
23+
.then( function( result ) {
24+
target.parentElement.querySelector( 'span' ).classList.add( 'hidden' );
25+
if ( ! result.success ) {
26+
alert( perflab_replace_html_entity( result.data.errorMessage ) );
27+
}
28+
window.location.reload();
29+
})
30+
.catch( function( error ) {
31+
alert( error.errorMessage );
32+
window.location.reload();
33+
});
3734
}
3835
});
36+
37+
// Function to replace HTML entities with their corresponding characters.
38+
function perflab_replace_html_entity( str ) {
39+
return str.replace( /&#(\d+);/g, function( match, dec ) {
40+
return String.fromCharCode( dec );
41+
});
42+
}
3943
});
4044
} )( document );

admin/plugins.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ function perflab_render_plugin_card( array $plugin_data ) {
155155
$action_links = array();
156156

157157
$status = install_plugin_install_status( $plugin_data );
158+
158159
switch ( $status['status'] ) {
159160
case 'install':
160161
if ( $status['url'] ) {

0 commit comments

Comments
 (0)