PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.3.5
AlphaListing v4.3.5
trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / functions / scripts.php
alphalisting / functions Last commit date
enqueues.php 1 year ago health-check.php 1 year ago helpers.php 1 year ago scripts.php 1 year ago styles.php 1 year ago
scripts.php
70 lines
1 <?php
2 /**
3 * Javascripts enqueueing functions.
4 *
5 * @package alphalisting
6 */
7
8 declare(strict_types=1);
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Enqueue Tabs script on pages where the shortcode is active
16 *
17 * @since 2.0.0
18 * @param bool $force Set this to true if you want the script to always be enqueued.
19 * @return void
20 */
21 function alphalisting_enqueue_tabs( bool $force = false ) {
22 global $post;
23 if ( $force || ( is_singular() && has_shortcode( $post->post_content, 'alphalisting' ) ) ) {
24 wp_enqueue_script( 'alphalisting-tabs' );
25 }
26 }
27
28 /**
29 * Forcibly enqueue Tabs script. This is a helper function which can be hooked in-place of the default hook added in `alphalisting_add_styling`
30 *
31 * @since 2.0.0
32 * @return void
33 */
34 function alphalisting_force_enqueue_tabs() {
35 alphalisting_enqueue_tabs( true );
36 }
37
38 /**
39 * Replace the default Tabs script enqueue function with `alphalisting_force_enqueue_tabs` to always add the Tabs script to pages
40 *
41 * @since 2.0.0
42 * @return void
43 */
44 function alphalisting_force_enable_tabs() {
45 if ( false !== has_action( 'wp_enqueue_scripts', 'alphalisting_enqueue_tabs' ) ) {
46 remove_action( 'wp_enqueue_scripts', 'alphalisting_enqueue_tabs' );
47 }
48 add_action( 'wp_enqueue_scripts', 'alphalisting_force_enqueue_tabs' );
49 }
50
51 /**
52 * Enqueue the widget configuration support script
53 *
54 * @since 2.1.0
55 * @return void
56 */
57 function alphalisting_enqueue_widget_admin_script() {
58 wp_enqueue_script( 'alphalisting-widget-admin' );
59 }
60
61 /**
62 * Enqueue Scrollfix script
63 *
64 * @since 4.0.0
65 * @return void
66 */
67 function alphalisting_enqueue_scroll_fix() {
68 wp_enqueue_script( 'alphalisting-scroll-fix' );
69 }
70