challenge
1 year ago
css
1 day ago
img
1 year ago
js
1 month ago
menu
1 month ago
partials
1 week ago
rest-api
1 day ago
scss
1 year ago
settings
1 day ago
uninstall
1 year ago
wpchill
1 month ago
admin-notices.php
5 months ago
admin.php
1 month ago
class-strong-testimonials-addons.php
1 month ago
class-strong-testimonials-admin-category-list.php
1 year ago
class-strong-testimonials-admin-list.php
1 year ago
class-strong-testimonials-admin-scripts.php
1 month ago
class-strong-testimonials-admin.php
1 month ago
class-strong-testimonials-debug.php
5 months ago
class-strong-testimonials-exporter.php
1 year ago
class-strong-testimonials-help.php
1 year ago
class-strong-testimonials-helper.php
1 month ago
class-strong-testimonials-list-table.php
1 year ago
class-strong-testimonials-lite-vs-pro-page.php
1 month ago
class-strong-testimonials-post-editor.php
6 months ago
class-strong-testimonials-review.php
1 year ago
class-strong-testimonials-updater.php
1 month ago
class-strong-testimonials-upsell.php
1 day ago
class-strong-views-list-table.php
1 month ago
class-walker-strong-category-checklist.php
1 year ago
class-walker-strong-form-category-checklist.php
1 year ago
class-wpmtst-onboarding.php
1 year ago
compat.php
1 year ago
custom-fields-ajax.php
1 year ago
custom-fields.php
1 day ago
form-preview.php
1 year ago
view-list-order.php
1 year ago
views-ajax.php
1 month ago
views-validate.php
1 year ago
views.php
1 month ago
class-strong-testimonials-admin-scripts.php
566 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Strong_Testimonials_Admin_Scripts |
| 4 | */ |
| 5 | class Strong_Testimonials_Admin_Scripts { |
| 6 | |
| 7 | /** |
| 8 | * Strong_Testimonials_Admin_Scripts constructor. |
| 9 | */ |
| 10 | public function __construct() {} |
| 11 | |
| 12 | /** |
| 13 | * Initialize. |
| 14 | */ |
| 15 | public static function init() { |
| 16 | self::add_actions(); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Add actions and filters. |
| 21 | */ |
| 22 | public static function add_actions() { |
| 23 | add_action( 'admin_init', array( __CLASS__, 'admin_register' ) ); |
| 24 | add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_dequeue_scripts' ), 500 ); |
| 25 | add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) ); |
| 26 | |
| 27 | add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-views', array( __CLASS__, 'admin_views' ) ); |
| 28 | add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-fields', array( __CLASS__, 'admin_fields' ) ); |
| 29 | add_action( 'admin_print_styles-wpm-testimonial_page_testimonial-settings', array( __CLASS__, 'admin_settings' ) ); |
| 30 | add_action( 'admin_print_styles-wpm-testimonial_page_strong-testimonials-extensions', array( __CLASS__, 'admin_extensions' ) ); |
| 31 | add_action( 'admin_print_styles-wpm-testimonial_page_about-strong-testimonials', array( __CLASS__, 'admin_about' ) ); |
| 32 | add_action( 'admin_print_styles-wpm-testimonial_page_strong-testimonials-logs', array( __CLASS__, 'admin_logs_view' ) ); |
| 33 | |
| 34 | add_action( 'load-edit.php', array( __CLASS__, 'admin_load_edit' ) ); |
| 35 | add_action( 'load-post.php', array( __CLASS__, 'admin_load_post' ) ); |
| 36 | add_action( 'load-post-new.php', array( __CLASS__, 'admin_load_post' ) ); |
| 37 | add_action( 'load-edit-tags.php', array( __CLASS__, 'admin_load_edit_tags' ) ); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Register admin scripts. |
| 42 | */ |
| 43 | public static function admin_register() { |
| 44 | |
| 45 | $plugin_version = get_option( 'wpmtst_plugin_version' ); |
| 46 | |
| 47 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 48 | |
| 49 | wp_register_script( |
| 50 | 'wpmtst-help', |
| 51 | WPMTST_ADMIN_URL . 'js/help.js', |
| 52 | array( 'jquery' ), |
| 53 | $plugin_version, |
| 54 | true |
| 55 | ); |
| 56 | |
| 57 | wp_register_script( |
| 58 | 'wpmtst-admin-script', |
| 59 | WPMTST_ASSETS_JS . 'admin.js', |
| 60 | array( 'jquery', 'underscore' ), |
| 61 | $plugin_version, |
| 62 | true |
| 63 | ); |
| 64 | |
| 65 | wp_register_style( |
| 66 | 'wpmtst-admin-global-style', |
| 67 | WPMTST_ASSETS_CSS . 'admin-global.css', |
| 68 | array(), |
| 69 | $plugin_version |
| 70 | ); |
| 71 | |
| 72 | wp_register_style( |
| 73 | 'wpmtst-admin-style', |
| 74 | WPMTST_ASSETS_CSS . 'admin.css', |
| 75 | array(), |
| 76 | $plugin_version |
| 77 | ); |
| 78 | |
| 79 | wp_register_style( |
| 80 | 'wpmtst-post-editor', |
| 81 | WPMTST_ADMIN_URL . 'css/post-editor.css', |
| 82 | array(), |
| 83 | $plugin_version |
| 84 | ); |
| 85 | |
| 86 | wp_register_style( |
| 87 | 'wpmtst-lite-vs-pro', |
| 88 | WPMTST_ADMIN_URL . 'css/lite-vs-pro.css', |
| 89 | array(), |
| 90 | $plugin_version |
| 91 | ); |
| 92 | |
| 93 | wp_register_style( |
| 94 | 'wpmtst-admin-upsells-style', |
| 95 | WPMTST_ASSETS_CSS . 'admin-upsells.css', |
| 96 | array(), |
| 97 | $plugin_version |
| 98 | ); |
| 99 | |
| 100 | wp_register_script( |
| 101 | 'wpmtst-custom-spinner', |
| 102 | WPMTST_ADMIN_URL . 'js/custom-spinner.js', |
| 103 | array( 'jquery' ), |
| 104 | $plugin_version, |
| 105 | true |
| 106 | ); |
| 107 | |
| 108 | wp_register_script( |
| 109 | 'autosize', |
| 110 | WPMTST_ADMIN_URL . 'js/lib/autosize/autosize.min.js', |
| 111 | array(), |
| 112 | '4.0.1', |
| 113 | true |
| 114 | ); |
| 115 | |
| 116 | /** |
| 117 | * Form tab |
| 118 | */ |
| 119 | wp_register_style( |
| 120 | 'wpmtst-admin-form-style', |
| 121 | WPMTST_ADMIN_URL . 'css/admin-form.css', |
| 122 | array( 'wpmtst-admin-style' ), |
| 123 | $plugin_version |
| 124 | ); |
| 125 | |
| 126 | wp_register_script( |
| 127 | 'wpmtst-admin-form-script', |
| 128 | WPMTST_ADMIN_URL . 'js/admin-form.js', |
| 129 | array( 'wpmtst-admin-script', 'autosize' ), |
| 130 | $plugin_version, |
| 131 | true |
| 132 | ); |
| 133 | |
| 134 | /** |
| 135 | * Fields |
| 136 | */ |
| 137 | wp_register_style( |
| 138 | 'wpmtst-admin-fields-style', |
| 139 | WPMTST_ADMIN_URL . 'css/fields.css', |
| 140 | array(), |
| 141 | $plugin_version |
| 142 | ); |
| 143 | |
| 144 | wp_register_style( |
| 145 | 'wpmtst-admin-form-preview', |
| 146 | WPMTST_ADMIN_URL . 'css/form-preview.css', |
| 147 | array(), |
| 148 | $plugin_version |
| 149 | ); |
| 150 | |
| 151 | wp_register_script( |
| 152 | 'wpmtst-admin-fields-script', |
| 153 | WPMTST_ADMIN_URL . 'js/admin-fields.js', |
| 154 | array( 'jquery', 'jquery-ui-sortable', 'wpmtst-help' ), |
| 155 | $plugin_version, |
| 156 | true |
| 157 | ); |
| 158 | |
| 159 | $params = array( |
| 160 | 'ajax_nonce' => wp_create_nonce( 'wpmtst-admin' ), |
| 161 | 'newField' => esc_html_x( 'New Field', 'Field editor: The default label for new fields', 'strong-testimonials' ), |
| 162 | 'inUse' => esc_html_x( '(in use)', 'Fields editor: To indicate when a field type can only be used once.', 'strong-testimonials' ), |
| 163 | 'noneFound' => esc_html_x( '(none found)', 'Fields editor: To indicate when no categories have been found.', 'strong-testimonials' ), |
| 164 | ); |
| 165 | wp_localize_script( 'wpmtst-admin-fields-script', 'wpmtstAdmin', $params ); |
| 166 | |
| 167 | /** |
| 168 | * Ratings |
| 169 | */ |
| 170 | wp_register_style( |
| 171 | 'wpmtst-rating-display', |
| 172 | WPMTST_PUBLIC_URL . 'css/rating-display.css', |
| 173 | array(), |
| 174 | $plugin_version |
| 175 | ); |
| 176 | |
| 177 | wp_register_style( |
| 178 | 'wpmtst-rating-form', |
| 179 | WPMTST_PUBLIC_URL . 'css/rating-form.css', |
| 180 | array(), |
| 181 | $plugin_version |
| 182 | ); |
| 183 | |
| 184 | wp_register_script( |
| 185 | 'wpmtst-rating-script', |
| 186 | WPMTST_ADMIN_URL . 'js/rating-edit.js', |
| 187 | array( 'jquery' ), |
| 188 | $plugin_version, |
| 189 | true |
| 190 | ); |
| 191 | |
| 192 | /** |
| 193 | * Views |
| 194 | */ |
| 195 | wp_register_style( |
| 196 | 'wpmtst-admin-views-style', |
| 197 | WPMTST_ADMIN_URL . 'css/views.css', |
| 198 | array(), |
| 199 | $plugin_version |
| 200 | ); |
| 201 | |
| 202 | wp_register_script( |
| 203 | 'wpmtst-admin-views-script', |
| 204 | WPMTST_ADMIN_URL . 'js/views.js', |
| 205 | array( 'jquery', 'jquery-ui-sortable', 'wp-color-picker', 'jquery-masonry', 'wpmtst-help' ), |
| 206 | $plugin_version, |
| 207 | true |
| 208 | ); |
| 209 | |
| 210 | // Add nonce to the script. |
| 211 | wp_add_inline_script( |
| 212 | 'wpmtst-admin-views-script', |
| 213 | 'const wpmtst_admin_views_script_nonce = "' . wp_create_nonce( 'wpmtst-admin-views-script-nonce' ) . '";', |
| 214 | 'before' |
| 215 | ); |
| 216 | |
| 217 | /** |
| 218 | * Category filter in View editor. |
| 219 | * |
| 220 | * JavaScript adapted under GPL-2.0+ license |
| 221 | * from Post Category Filter plugin by Javier Villanueva (http://www.jahvi.com) |
| 222 | * |
| 223 | * @since 2.2.0 |
| 224 | */ |
| 225 | wp_register_script( |
| 226 | 'wpmtst-view-category-filter-script', |
| 227 | WPMTST_ADMIN_URL . 'js/view-category-filter.js', |
| 228 | array( 'jquery' ), |
| 229 | $plugin_version, |
| 230 | true |
| 231 | ); |
| 232 | |
| 233 | wp_register_style( |
| 234 | 'wpmtst-about-style', |
| 235 | WPMTST_ADMIN_URL . 'css/about.css', |
| 236 | array(), |
| 237 | $plugin_version |
| 238 | ); |
| 239 | |
| 240 | /** |
| 241 | * Extensions |
| 242 | * |
| 243 | * @since 3.3 |
| 244 | */ |
| 245 | $extensions_asset_file = WPMTST_DIR . 'assets/dist/extensions/index.asset.php'; |
| 246 | $extensions_asset = file_exists( $extensions_asset_file ) |
| 247 | ? require $extensions_asset_file |
| 248 | : array( |
| 249 | 'dependencies' => array( 'wp-components' ), |
| 250 | 'version' => $plugin_version, |
| 251 | ); |
| 252 | |
| 253 | wp_register_script( |
| 254 | 'wpmtst-extensions', |
| 255 | WPMTST_ASSETS_JS . 'extensions/index.js', |
| 256 | $extensions_asset['dependencies'], |
| 257 | $extensions_asset['version'], |
| 258 | true |
| 259 | ); |
| 260 | |
| 261 | wp_register_style( |
| 262 | 'wpmtst-extensions', |
| 263 | WPMTST_ASSETS_JS . 'extensions/index.css', |
| 264 | array(), |
| 265 | $extensions_asset['version'] |
| 266 | ); |
| 267 | |
| 268 | /** |
| 269 | * General Settings (React) |
| 270 | * |
| 271 | * @since 3.3 |
| 272 | */ |
| 273 | $general_settings_asset_file = WPMTST_DIR . 'assets/dist/general-settings/index.asset.php'; |
| 274 | $general_settings_asset = file_exists( $general_settings_asset_file ) |
| 275 | ? require $general_settings_asset_file |
| 276 | : array( |
| 277 | 'dependencies' => array( 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n' ), |
| 278 | 'version' => $plugin_version, |
| 279 | ); |
| 280 | |
| 281 | wp_register_script( |
| 282 | 'wpmtst-general-settings', |
| 283 | WPMTST_ASSETS_JS . 'general-settings/index.js', |
| 284 | $general_settings_asset['dependencies'], |
| 285 | $general_settings_asset['version'], |
| 286 | true |
| 287 | ); |
| 288 | |
| 289 | wp_register_style( |
| 290 | 'wpmtst-general-settings', |
| 291 | WPMTST_ASSETS_JS . 'general-settings/index.css', |
| 292 | array( 'wp-components' ), |
| 293 | $general_settings_asset['version'] |
| 294 | ); |
| 295 | |
| 296 | /** |
| 297 | * Are You Sure? for dirty forms |
| 298 | * |
| 299 | * @since 2.18 |
| 300 | */ |
| 301 | wp_register_script( |
| 302 | 'wpmtst-ays-script', |
| 303 | WPMTST_ADMIN_URL . "js/lib/are-you-sure/jquery.are-you-sure{$min}.js", |
| 304 | array( 'jquery' ), |
| 305 | $plugin_version, |
| 306 | true |
| 307 | ); |
| 308 | |
| 309 | wp_register_style( |
| 310 | 'wpmtst-logs-style', |
| 311 | WPMTST_ADMIN_URL . 'css/logs.css', |
| 312 | array(), |
| 313 | $plugin_version |
| 314 | ); |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Enqueue global admin scripts. |
| 319 | */ |
| 320 | public static function admin_enqueue_scripts() { |
| 321 | $screen = get_current_screen(); |
| 322 | $plugin_version = get_option( 'wpmtst_plugin_version' ); |
| 323 | |
| 324 | wp_enqueue_style( 'wpmtst-admin-global-style' ); |
| 325 | |
| 326 | wp_enqueue_script( |
| 327 | 'wpmtst-admin-global', |
| 328 | WPMTST_ADMIN_URL . 'js/admin-global.js', |
| 329 | array( 'jquery' ), |
| 330 | $plugin_version, |
| 331 | true |
| 332 | ); |
| 333 | |
| 334 | wp_localize_script( |
| 335 | 'wpmtst-admin-global', |
| 336 | 'wpmtst_admin', |
| 337 | array( |
| 338 | 'nonce' => wp_create_nonce( 'wpmtst-admin' ), |
| 339 | 'templateTagTitle' => esc_html__( 'click to insert into message at caret', 'strong-testimonials' ), |
| 340 | 'something_wrong' => esc_html__( 'Something went wrong. Please try again.', 'strong-testimonials' ), |
| 341 | 'email_license_sent' => esc_html__( 'An email containing the license was sent.', 'strong-testimonials' ), |
| 342 | 'activate' => esc_html__( 'Activate', 'strong-testimonials' ), |
| 343 | 'deactivate' => esc_html__( 'Deactivate', 'strong-testimonials' ), |
| 344 | 'enter_email' => esc_html__( 'Please enter your email address.', 'strong-testimonials' ), |
| 345 | 'activating' => esc_html__( 'Activating...', 'strong-testimonials' ), |
| 346 | 'deactivating' => esc_html__( 'Deactivating...', 'strong-testimonials' ), |
| 347 | 'retrieving_data' => esc_html__( 'Retrieving data...', 'strong-testimonials' ), |
| 348 | 'enter_license' => esc_html__( 'Please enter your license key.', 'strong-testimonials' ), |
| 349 | ) |
| 350 | ); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Enqueue specific styles and scripts. |
| 355 | * |
| 356 | * Using separate hooks for readability, troubleshooting, and future refactoring. Focus on _where_. |
| 357 | * |
| 358 | * @since 2.12.0 |
| 359 | */ |
| 360 | |
| 361 | /** |
| 362 | * Views |
| 363 | */ |
| 364 | public static function admin_views() { |
| 365 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 366 | wp_enqueue_script( 'wpmtst-admin-script' ); |
| 367 | |
| 368 | wp_add_inline_script( |
| 369 | 'wpmtst-admin-script', |
| 370 | 'const wpmtstAdminScriptNonce = "' . wp_create_nonce( 'wpmtst-admin-script-nonce' ) . '";', |
| 371 | 'before' |
| 372 | ); |
| 373 | |
| 374 | wp_enqueue_style( 'wpmtst-admin-views-style' ); |
| 375 | wp_enqueue_script( 'wpmtst-admin-views-script' ); |
| 376 | wp_enqueue_script( 'wpmtst-view-category-filter-script' ); |
| 377 | |
| 378 | wp_enqueue_style( 'wp-color-picker' ); |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Fields |
| 383 | */ |
| 384 | public static function admin_fields() { |
| 385 | $tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : ''; |
| 386 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 387 | wp_enqueue_script( 'wpmtst-admin-script' ); |
| 388 | |
| 389 | wp_add_inline_script( |
| 390 | 'wpmtst-admin-script', |
| 391 | 'const wpmtstAdminScriptNonce = "' . wp_create_nonce( 'wpmtst-admin-script-nonce' ) . '";', |
| 392 | 'before' |
| 393 | ); |
| 394 | |
| 395 | switch ( $tab ) { |
| 396 | case 'form': |
| 397 | wp_enqueue_style( 'wpmtst-admin-form-style' ); |
| 398 | wp_enqueue_script( 'wpmtst-admin-form-script' ); |
| 399 | wp_add_inline_script( |
| 400 | 'wpmtst-admin-form-script', |
| 401 | 'const wpmtst_admin_form_script_nonce = "' . wp_create_nonce( 'wpmtst-admin-form-script-nonce' ) . '";', |
| 402 | 'before' |
| 403 | ); |
| 404 | break; |
| 405 | case 'fields': |
| 406 | wp_enqueue_style( 'wpmtst-admin-fields-style' ); |
| 407 | wp_enqueue_script( 'wpmtst-admin-fields-script' ); |
| 408 | |
| 409 | wp_enqueue_style( 'wpmtst-admin-form-preview' ); |
| 410 | wp_enqueue_style( 'wpmtst-rating-form' ); |
| 411 | break; |
| 412 | default: |
| 413 | wp_enqueue_style( 'wpmtst-admin-fields-style' ); |
| 414 | wp_enqueue_script( 'wpmtst-admin-fields-script' ); |
| 415 | |
| 416 | wp_enqueue_style( 'wpmtst-admin-form-preview' ); |
| 417 | wp_enqueue_style( 'wpmtst-rating-form' ); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | /** |
| 422 | * Settings (React-based general settings page) |
| 423 | */ |
| 424 | public static function admin_settings() { |
| 425 | wp_enqueue_style( 'wpmtst-general-settings' ); |
| 426 | wp_enqueue_script( 'wpmtst-general-settings' ); |
| 427 | |
| 428 | wp_add_inline_script( |
| 429 | 'wpmtst-general-settings', |
| 430 | 'const wpmtstGeneralSettings = ' . wp_json_encode( |
| 431 | array( |
| 432 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 433 | 'adminUrl' => admin_url(), |
| 434 | 'pluginUrl' => WPMTST_URL, |
| 435 | ) |
| 436 | ) . ';', |
| 437 | 'before' |
| 438 | ); |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /** |
| 443 | * Extensions |
| 444 | */ |
| 445 | public static function admin_extensions() { |
| 446 | |
| 447 | wp_enqueue_style( 'wpmtst-extensions' ); |
| 448 | wp_enqueue_script( 'wpmtst-extensions' ); |
| 449 | |
| 450 | wp_localize_script( |
| 451 | 'wpmtst-extensions', |
| 452 | 'extensionsStrings', |
| 453 | array( |
| 454 | 'proExists' => defined( 'WPMTST_PRO_VERSION' ), |
| 455 | 'offer' => apply_filters( 'wpmtst_extensions_offer', new \stdClass() ), |
| 456 | ), |
| 457 | 'before' |
| 458 | ); |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * About |
| 463 | */ |
| 464 | public static function admin_about() { |
| 465 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 466 | wp_enqueue_script( 'wpmtst-admin-script' ); |
| 467 | |
| 468 | wp_add_inline_script( |
| 469 | 'wpmtst-admin-script', |
| 470 | 'const wpmtstAdminScriptNonce = "' . wp_create_nonce( 'wpmtst-admin-script-nonce' ) . '";', |
| 471 | 'before' |
| 472 | ); |
| 473 | |
| 474 | wp_enqueue_style( 'wpmtst-about-style' ); |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * List table |
| 479 | */ |
| 480 | public static function admin_load_edit() { |
| 481 | if ( wpmtst_is_testimonial_screen() ) { |
| 482 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 483 | wp_enqueue_script( 'wpmtst-admin-script' ); |
| 484 | |
| 485 | wp_add_inline_script( |
| 486 | 'wpmtst-admin-script', |
| 487 | 'const wpmtstAdminScriptNonce = "' . wp_create_nonce( 'wpmtst-admin-script-nonce' ) . '";', |
| 488 | 'before' |
| 489 | ); |
| 490 | |
| 491 | wp_enqueue_style( 'wpmtst-rating-display' ); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * Logs View |
| 497 | */ |
| 498 | public static function admin_logs_view() { |
| 499 | wp_enqueue_style( 'wpmtst-logs-style' ); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Categories |
| 504 | */ |
| 505 | public static function admin_load_edit_tags() { |
| 506 | if ( wpmtst_is_testimonial_screen() ) { |
| 507 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * Edit post |
| 513 | */ |
| 514 | public static function admin_load_post() { |
| 515 | if ( wpmtst_is_testimonial_screen() ) { |
| 516 | wp_enqueue_style( 'wpmtst-admin-style' ); |
| 517 | wp_enqueue_style( 'wpmtst-post-editor' ); |
| 518 | wp_enqueue_script( 'wpmtst-admin-script' ); |
| 519 | |
| 520 | wp_add_inline_script( |
| 521 | 'wpmtst-admin-script', |
| 522 | 'const wpmtstAdminScriptNonce = "' . wp_create_nonce( 'wpmtst-admin-script-nonce' ) . '";', |
| 523 | 'before' |
| 524 | ); |
| 525 | |
| 526 | wp_enqueue_style( 'wpmtst-rating-display' ); |
| 527 | wp_enqueue_style( 'wpmtst-rating-form' ); |
| 528 | wp_enqueue_script( 'wpmtst-rating-script' ); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Known theme and plugin conflicts. |
| 534 | * |
| 535 | * @param $hook |
| 536 | */ |
| 537 | public static function admin_dequeue_scripts( $hook ) { |
| 538 | if ( wp_style_is( 'CPTStyleSheets' ) ) { |
| 539 | wp_dequeue_style( 'CPTStyleSheets' ); |
| 540 | } |
| 541 | |
| 542 | $hooks_to_script = array( |
| 543 | 'wpm-testimonial_page_testimonial-views', |
| 544 | 'wpm-testimonial_page_testimonial-fields', |
| 545 | 'wpm-testimonial_page_testimonial-settings', |
| 546 | 'wpm-testimonial_page_about-strong-testimonials', |
| 547 | ); |
| 548 | |
| 549 | if ( wpmtst_is_testimonial_screen() ) { |
| 550 | $hooks_to_script = array_merge( $hooks_to_script, array( 'edit.php' ) ); |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Block RT Themes and their overzealous JavaScript on our admin pages. |
| 555 | * @since 2.2.12.1 |
| 556 | */ |
| 557 | if ( in_array( $hook, $hooks_to_script, true ) ) { |
| 558 | if ( class_exists( 'RTThemeAdmin' ) && wp_script_is( 'admin-scripts' ) ) { |
| 559 | wp_dequeue_script( 'admin-scripts' ); |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | Strong_Testimonials_Admin_Scripts::init(); |
| 566 |