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