Skip to content

Commit f3aa9cc

Browse files
author
Md. Alimuzzaman Alim
committed
Error notice fix #276
1 parent d2076fc commit f3aa9cc

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

lib/classes/class-errors.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct( $args ) {
8686
parent::__construct( $args );
8787
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
8888
add_action( 'wp_ajax_ud_dismiss', array( $this, 'dismiss_notices' ) );
89-
add_action( 'wp_ajax_button_action', array( $this, 'button_action' ) );
89+
add_action( 'wp_ajax_stateless_notice_button_action', array( $this, 'stateless_notice_button_action' ) );
9090
}
9191

9292
/**
@@ -255,10 +255,10 @@ public function dismiss_notices(){
255255
}
256256

257257
/**
258-
* Action for the button_action ajax callback
258+
* Action for the stateless_notice_button_action ajax callback
259259
* @throws \Exception
260260
*/
261-
public function button_action(){
261+
public function stateless_notice_button_action(){
262262
$response = array(
263263
'success' => '1',
264264
);

static/scripts/error-notice.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
jQuery( document ).ready( function () {
55

6-
jQuery( '.ud-admin-notice' ).on( 'click', '.button-action', function(e){
6+
jQuery( document ).on( 'click', '.stateless-admin-notice.ud-admin-notice .button-action', function(e){
77
var _this = jQuery( this );
88
if(_this.attr('href') != '#'){
99
return;
@@ -13,20 +13,41 @@ jQuery( document ).ready( function () {
1313

1414

1515
var data = {
16-
action: 'button_action',
16+
action: 'stateless_notice_button_action',
1717
key: _this.data('key'),
1818
}
1919

2020
jQuery.post( ajaxurl, data, function ( result_data ) {
2121
if( result_data.success == '1' ) {
2222
_this.closest('.ud-admin-notice').remove();
2323
} else if ( result_data.success == '0' ) {
24-
alert(result_data.error);
24+
// alert(result_data.error);
2525
}
2626
}, "json" );
2727
return false;
2828
});
2929

30+
31+
jQuery( document ).on( 'click', '.stateless-admin-notice.ud-admin-notice .dismiss-warning', function(e){
32+
e.preventDefault();
33+
34+
var _this = jQuery( this );
35+
36+
var data = {
37+
action: 'ud_dismiss',
38+
key: _this.data('key'),
39+
}
40+
41+
jQuery.post( ajaxurl, data, function ( result_data ) {
42+
if( result_data.success == '1' ) {
43+
_this.closest('.ud-admin-notice').remove();
44+
} else if ( result_data.success == '0' ) {
45+
// alert(result_data.error);
46+
}
47+
}, "json" );
48+
49+
});
50+
3051
jQuery('#stless_settings_tab .sm-mode input[type=radio]').on('change', function(){
3152
var $this = jQuery('#sm_mode_stateless');
3253
if($this.is(':checked')){

static/scripts/wp-stateless.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ var wpStatelessApp = angular.module('wpStatelessApp', [])
737737
if(value == 'stateless'){
738738
$scope.backup.hashify_file_name = $scope.sm.hashify_file_name;
739739
$scope.sm.hashify_file_name = 'true';
740-
$scope.apply();
740+
// $scope.apply();
741741
}
742742
else{
743743
if($scope.backup.hashify_file_name){
744744
$scope.sm.hashify_file_name = $scope.backup.hashify_file_name;
745-
$scope.apply();
745+
// $scope.apply();
746746
}
747747
}
748748
});

static/views/error-notice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="stateless-notice-<?php echo $data['key'];?>" class="stateless-admin-notice ud-admin-notice <?php echo $data['class'];?> update-nag fade">
1+
<div id="stateless-notice-<?php if(!empty($data['key'])) echo $data['key'];?>" class="stateless-admin-notice ud-admin-notice <?php echo $data['class'];?> update-nag fade">
22
<div>
33
<div class="title"><?php echo $data['title'];?></div>
44
<div class="description"><?php echo $data['message'];?></div>

0 commit comments

Comments
 (0)