| 1 |
<?php |
| 2 |
namespace WPAdminify\Inc\Classes\Notifications\Model; |
| 3 |
|
| 4 |
use WPAdminify\Inc\Classes\Helper; |
| 5 |
|
| 6 |
// No, Direct access Sir !!! |
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* Notice Model for Notification |
| 13 |
* |
| 14 |
* Jewel Theme <support@jeweltheme.com> |
| 15 |
*/ |
| 16 |
abstract class Notice extends Notification { |
| 17 |
|
| 18 |
|
| 19 |
public $type = 'notice'; |
| 20 |
public $color = 'error'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Get Key |
| 24 |
* |
| 25 |
* @author Jewel Theme <support@jeweltheme.com> |
| 26 |
*/ |
| 27 |
final public function get_key() { |
| 28 |
return 'jltwp_adminify_notice_' . $this->get_id(); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Footer content |
| 33 |
* |
| 34 |
* @author Jewel Theme <support@jeweltheme.com> |
| 35 |
*/ |
| 36 |
public function footer_content() { |
| 37 |
return ''; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Notice Header |
| 42 |
* |
| 43 |
* @author Jewel Theme <support@jeweltheme.com> |
| 44 |
*/ |
| 45 |
public function notice_header() { ?> |
| 46 |
<div class="notice notice-wp-adminify is-dismissible notice-<?php echo esc_attr( $this->color ); ?> wp-adminify-notice-<?php echo esc_attr( $this->get_id() ); ?>"> |
| 47 |
<button type="button" class="notice-dismiss wp-adminify-notice-dismiss"></button> |
| 48 |
<div class="notice-content-box"> |
| 49 |
<?php |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Notice Content |
| 54 |
* |
| 55 |
* @author Jewel Theme <support@jeweltheme.com> |
| 56 |
*/ |
| 57 |
public function notice_content() { |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Notice Footer |
| 62 |
* |
| 63 |
* @return void |
| 64 |
* @author Jewel Theme <support@jeweltheme.com> |
| 65 |
*/ |
| 66 |
public function notice_footer() { |
| 67 |
?> |
| 68 |
</div> |
| 69 |
<?php echo $this->footer_content(); ?> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Core Script |
| 76 |
* |
| 77 |
* @param [type] $trigger_time . |
| 78 |
* |
| 79 |
* @return void |
| 80 |
* @author Jewel Theme <support@jeweltheme.com> |
| 81 |
*/ |
| 82 |
public function core_script( $trigger_time ) { |
| 83 |
?> |
| 84 |
<script> |
| 85 |
function jltwp_adminify_notice_action(evt, $this, action_type) { |
| 86 |
|
| 87 |
if (evt) evt.preventDefault(); |
| 88 |
|
| 89 |
$this.closest('.notice-wp-adminify').slideUp(200); |
| 90 |
|
| 91 |
jQuery.post('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', { |
| 92 |
action: 'jltwp_adminify_notification_action', |
| 93 |
_wpnonce: '<?php echo esc_js( wp_create_nonce( 'jltwp_adminify_notification_nonce' ) ); ?>', |
| 94 |
action_type: action_type, |
| 95 |
notification_type: 'notice', |
| 96 |
trigger_time: '<?php echo esc_attr( $trigger_time ); ?>' |
| 97 |
}); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
// Notice Dismiss |
| 102 |
jQuery('body').on('click', '.notice-wp-adminify .wp-adminify-notice-dismiss', function(evt) { |
| 103 |
jltwp_adminify_notice_action(evt, jQuery(this), 'dismiss'); |
| 104 |
}); |
| 105 |
|
| 106 |
// Notice Disable |
| 107 |
jQuery('body').on('click', '.notice-wp-adminify .wp-adminify-notice-disable', function(evt) { |
| 108 |
jltwp_adminify_notice_action(evt, jQuery(this), 'disable'); |
| 109 |
}); |
| 110 |
</script> |
| 111 |
<?php |
| 112 |
} |
| 113 |
} |
| 114 |
|