enqueues.php
2 weeks ago
health-check.php
2 weeks ago
helpers.php
2 weeks ago
scripts.php
2 weeks ago
styles.php
2 weeks ago
enqueues.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * AlphaListing Styles and Scripts enqueue functions |
| 4 | * |
| 5 | * @package alphalisting |
| 6 | */ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Register default A-Z stylesheet and add our enqueue |
| 16 | * functions to the `wp_enqueue_scripts` action |
| 17 | * |
| 18 | * @since 2.0.0 Renamed from alphalisting_add_styling. |
| 19 | * @return void |
| 20 | */ |
| 21 | function alphalisting_do_enqueue() { |
| 22 | wp_register_style( |
| 23 | 'alphalisting', |
| 24 | plugins_url( 'css/alphalisting-default.css', dirname( __FILE__ ) ), |
| 25 | array( 'dashicons' ), |
| 26 | ALPHALISTING_VERSION |
| 27 | ); |
| 28 | |
| 29 | wp_register_style( |
| 30 | 'alphalisting-admin', |
| 31 | plugins_url( 'css/alphalisting-customize.css', dirname( __FILE__ ) ), |
| 32 | array(), |
| 33 | ALPHALISTING_VERSION |
| 34 | ); |
| 35 | |
| 36 | wp_register_script( |
| 37 | 'alphalisting-widget-admin', |
| 38 | plugins_url( 'scripts/alphalisting-widget-admin.js', dirname( __FILE__ ) ), |
| 39 | array( 'jquery', 'jquery-ui-autocomplete' ), |
| 40 | ALPHALISTING_VERSION, |
| 41 | true |
| 42 | ); |
| 43 | |
| 44 | /* |
| 45 | * wp_add_inline_script() rather than wp_localize_script(): this is plain |
| 46 | * configuration data, not translations, and wp_localize_script() runs every value |
| 47 | * through html_entity_decode(), which corrupts values containing an ampersand. |
| 48 | */ |
| 49 | wp_add_inline_script( |
| 50 | 'alphalisting-widget-admin', |
| 51 | 'var alphalisting_widget_admin = ' . wp_json_encode( array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ) . ';', |
| 52 | 'before' |
| 53 | ); |
| 54 | |
| 55 | $add_styles = get_option( 'alphalisting-add-styling', true ); |
| 56 | |
| 57 | /** |
| 58 | * Determine whether to add default listing styling |
| 59 | * |
| 60 | * @param bool True to add default styling, False to disable. |
| 61 | * @since 1.7.1 |
| 62 | */ |
| 63 | $add_styles = apply_filters( 'alphalisting_add_styling', $add_styles ); //phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound |
| 64 | |
| 65 | if ( defined( 'ALPHALISTING_LOG' ) && ALPHALISTING_LOG ) { |
| 66 | do_action( 'alphalisting_log', 'AlphaListing: Add Styles', $add_styles ); |
| 67 | } |
| 68 | if ( true === $add_styles && ! has_action( 'wp_enqueue_scripts', 'alphalisting_enqueue_styles' ) ) { |
| 69 | add_action( 'wp_enqueue_scripts', 'alphalisting_enqueue_styles' ); |
| 70 | } |
| 71 | |
| 72 | add_action( 'customize_controls_enqueue_scripts', 'alphalisting_customize_enqueue_styles' ); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | add_action( 'init', 'alphalisting_do_enqueue' ); |
| 77 |