| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin notice |
| 4 |
* |
| 5 |
*/ |
| 6 |
if ( ! defined( 'ABSPATH' ) ) exit; //exit if access directly |
| 7 |
|
| 8 |
if( ! class_exists( 'GutSlider_Admin_Notice' ) ) { |
| 9 |
|
| 10 |
class GutSlider_Admin_Notice { |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor |
| 14 |
* return void |
| 15 |
*/ |
| 16 |
public function __construct() { |
| 17 |
add_action( 'admin_notices', [ $this, 'admin_notice' ] ); |
| 18 |
add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] ); |
| 19 |
add_action( 'wp_ajax_dismiss_gutslider_admin_notice', [ $this, 'dismiss_notice' ] ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Admin notice |
| 24 |
* return void |
| 25 |
*/ |
| 26 |
public function admin_notice() { |
| 27 |
$screen = get_current_screen(); |
| 28 |
if( $screen->id == 'plugins' ) { |
| 29 |
$this->plugin_notice(); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Plugin notice |
| 35 |
* return void |
| 36 |
*/ |
| 37 |
public function plugin_notice() { |
| 38 |
$notice = get_option( 'gutslider_notice' ); |
| 39 |
if( $notice ) return; |
| 40 |
?> |
| 41 |
<div class="notice notice-success gutslider-notice"> |
| 42 |
<div class="gutslider-notice-content" style="padding: 10px;"> |
| 43 |
<p><b><?php _e('Note: ', 'slider-blocks') ?></b><?php _e( 'Due to some internal changes, your block will throw "Attempt to Block Recover". To fix it, simply click on the "Attempt Block Recovery" button. You will never need to do this in the future updates.', 'slider-blocks' ); ?></p> |
| 44 |
<a href="https://youtu.be/uEuiQdj6M38" target="_blank" class="button button-primary"><?php _e( 'Watch Video', 'slider-blocks' ); ?></a> |
| 45 |
<button id="gutslider_notice" class="button button-primary" style="background: #b32e2e; border-color: #b32e2e"> |
| 46 |
<?php _e('Close Notice', 'slider-blocks'); ?> |
| 47 |
</button> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
<?php |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Admin scripts |
| 55 |
* return void |
| 56 |
*/ |
| 57 |
public function admin_scripts( $screen ) { |
| 58 |
if( $screen != 'plugins.php' ) return; |
| 59 |
wp_enqueue_script( 'gutslider-admin-notice', GUTSLIDER_URL . 'includes/admin/notice/notice.js', [ 'jquery' ], GUTSLIDER_VERSION, true ); |
| 60 |
wp_localize_script( 'gutslider-admin-notice', 'gutslider_admin_notice', [ |
| 61 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 62 |
'nonce' => wp_create_nonce( 'gutslider_admin_notice_nonce' ) |
| 63 |
] ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Dismiss notice |
| 68 |
* return void |
| 69 |
*/ |
| 70 |
public function dismiss_notice() { |
| 71 |
update_option( 'gutslider_notice', true ); |
| 72 |
wp_die(); |
| 73 |
} |
| 74 |
|
| 75 |
} |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
new GutSlider_Admin_Notice(); // Initialize the class |