← All changes
|
vendor/arraytics/plugin-notice-sdk/src/Notice.php
+68
-0
1.0.17
→
1.0.29
View file →
| @@ -145,9 +145,77 @@ | ||
| 145 | 145 | * @return void |
| 146 | 146 | */ |
| 147 | 147 | public static function init() |
| 148 | 148 | { |
| 149 | + static $initialized = false; | |
| 150 | + | |
| 151 | + // Prevent multiple initializations | |
| 152 | + if ( $initialized ) { | |
| 153 | + return; | |
| 154 | + } | |
| 155 | + | |
| 149 | 156 | add_action('wp_ajax_wpmet-notices', [__CLASS__, 'dismiss_ajax_call']); |
| 157 | + add_action( 'admin_head', [ __CLASS__, 'enqueue_scripts' ] ); | |
| 158 | + | |
| 159 | + $initialized = true; | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * Enqueue comparison scripts and styles | |
| 164 | + * | |
| 165 | + * @return void | |
| 166 | + */ | |
| 167 | + public static function enqueue_scripts() | |
| 168 | + { | |
| 169 | + ?> | |
| 170 | + <script> | |
| 171 | + jQuery(document).ready(function ($) { | |
| 172 | + $( '.wpmet-notice.is-dismissible' ).on( 'click', '.notice-dismiss', function() { | |
| 173 | + var _this = $( this ).parents('.wpmet-notice').eq(0); | |
| 174 | + var notice_id = _this.attr( 'id' ) || ''; | |
| 175 | + var expired_time = _this.attr( 'expired_time' ) || ''; | |
| 176 | + var dismissible = _this.attr( 'dismissible' ) || ''; | |
| 177 | + var nonce = '<?php echo wp_create_nonce( 'wpmet-notices' ); ?>'; | |
| 178 | + | |
| 179 | + _this.hide(); | |
| 180 | + | |
| 181 | + $.ajax({ | |
| 182 | + url: ajaxurl, | |
| 183 | + type: 'POST', | |
| 184 | + data: { | |
| 185 | + action: 'wpmet-notices', | |
| 186 | + notice_id: notice_id, | |
| 187 | + dismissible: dismissible, | |
| 188 | + expired_time: expired_time, | |
| 189 | + nonce: nonce | |
| 190 | + }, | |
| 191 | + }); | |
| 192 | + }); | |
| 193 | + }); | |
| 194 | + </script> | |
| 195 | + <style> | |
| 196 | + .wpmet-notice { margin-bottom: 15px; padding: 0 !important; display: flex; align-items: center; } | |
| 197 | + .wpmet-notice .notice-right-container { margin: .7rem .8rem .8rem; } | |
| 198 | + .notice-container-full-width { width: 100% !important; } | |
| 199 | + | |
| 200 | + .wpmet-notice.no-gutter { padding: 0 !important; border-width: 0 !important; } | |
| 201 | + .wpmet-notice.no-gutter .notice-right-container { padding: 0 !important; margin: 0 !important; } | |
| 202 | + | |
| 203 | + .notice-right-container .notice-vert-space { margin-bottom: .8rem; } | |
| 204 | + .notice-right-container .notice-vert-space:last-child, | |
| 205 | + .notice-right-container .notice-vert-space:only-child { margin-bottom: 0; } | |
| 206 | + | |
| 207 | + .wpmet-notice .notice-logo { padding: 3px; max-width: 110px; max-height: 110px; } | |
| 208 | + .wpmet-notice .plugin-notice-href img { max-width: 100%; height: auto; } | |
| 209 | + | |
| 210 | + .wpmet-notice-button { text-decoration: none; } | |
| 211 | + .wpmet-notice-button > i { margin-right: 3px; } | |
| 212 | + .wpmet-notice-button .notice-icon { display: inline-block; } | |
| 213 | + .wpmet-notice-button .notice-icon:before { vertical-align: middle !important; margin-top: -1px; } | |
| 214 | + | |
| 215 | + .wpmet-notice .notice-main-title { color: #1d2327; font-size: 1.2rem; } | |
| 216 | + </style> | |
| 217 | + <?php | |
| 150 | 218 | } |
| 151 | 219 | |
| 152 | 220 | /** |
| 153 | 221 | * Configure basic properties of the notice. |