lightspeeddevelopment /
lsx
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * LSX functions and definitions - Scripts. |
||
| 4 | * |
||
| 5 | * @package lsx |
||
| 6 | * @subpackage scripts |
||
| 7 | */ |
||
| 8 | |||
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 10 | exit; |
||
| 11 | } |
||
| 12 | |||
| 13 | if ( ! function_exists( 'lsx_scripts' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 14 | |||
| 15 | /** |
||
| 16 | * Enqueue scripts, fonts and styles. |
||
| 17 | * |
||
| 18 | * @package lsx |
||
| 19 | * @subpackage scripts |
||
| 20 | */ |
||
| 21 | function lsx_scripts() { |
||
|
0 ignored issues
–
show
|
|||
| 22 | lsx_scripts_add_styles(); |
||
| 23 | lsx_scripts_add_fonts(); |
||
| 24 | lsx_scripts_add_scripts(); |
||
| 25 | } |
||
|
0 ignored issues
–
show
|
|||
| 26 | |||
| 27 | endif; |
||
| 28 | |||
| 29 | add_action( 'wp_enqueue_scripts', 'lsx_scripts', 5 ); |
||
| 30 | |||
| 31 | if ( ! function_exists( 'lsx_admin_scripts' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 32 | |||
| 33 | /** |
||
| 34 | * Enqueue scripts (admin). |
||
| 35 | * |
||
| 36 | * @package lsx |
||
| 37 | * @subpackage scripts |
||
| 38 | */ |
||
| 39 | function lsx_admin_scripts() { |
||
|
0 ignored issues
–
show
|
|||
| 40 | wp_enqueue_script( 'lsx-admin', get_template_directory_uri() . '/assets/js/admin/lsx-admin.js', array( 'jquery' ), LSX_VERSION, true ); |
||
| 41 | } |
||
|
0 ignored issues
–
show
|
|||
| 42 | |||
| 43 | endif; |
||
| 44 | |||
| 45 | add_action( 'admin_enqueue_scripts', 'lsx_admin_scripts' ); |
||
| 46 | |||
| 47 | if ( ! function_exists( 'lsx_scripts_add_styles' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 48 | |||
| 49 | /** |
||
| 50 | * Enqueue styles. |
||
| 51 | * |
||
| 52 | * @package lsx |
||
| 53 | * @subpackage scripts |
||
| 54 | */ |
||
| 55 | function lsx_scripts_add_styles() { |
||
|
0 ignored issues
–
show
|
|||
| 56 | wp_enqueue_style( 'lsx_fonts', get_template_directory_uri() . '/assets/css/lsx-fonts.css', array(), LSX_VERSION ); |
||
| 57 | |||
| 58 | wp_register_style( 'fontawesome', get_template_directory_uri() . '/assets/css/vendor/font-awesome.css', array(), LSX_VERSION ); |
||
| 59 | wp_style_add_data( 'fontawesome', 'rtl', 'replace' ); |
||
| 60 | |||
| 61 | wp_register_style( 'bootstrap', get_template_directory_uri() . '/assets/css/vendor/bootstrap.css', array(), LSX_VERSION ); |
||
| 62 | wp_style_add_data( 'bootstrap', 'rtl', 'replace' ); |
||
| 63 | |||
| 64 | wp_enqueue_style( 'lsx_main', get_template_directory_uri() . '/assets/css/lsx.css', array( 'lsx_fonts', 'fontawesome', 'bootstrap'/*, 'slick'*/ ), LSX_VERSION ); |
||
| 65 | wp_enqueue_style( 'lsx_gutenberg', get_template_directory_uri() . '/assets/css/gutenberg.css', array( 'lsx_main' ), LSX_VERSION ); |
||
| 66 | |||
| 67 | wp_style_add_data( 'lsx_main', 'rtl', 'replace' ); |
||
| 68 | } |
||
|
0 ignored issues
–
show
|
|||
| 69 | |||
| 70 | endif; |
||
| 71 | |||
| 72 | if ( ! function_exists( 'lsx_scripts_add_fonts' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 73 | /** |
||
| 74 | * Enqueue fonts. |
||
| 75 | * |
||
| 76 | * @package lsx |
||
| 77 | * @subpackage scripts |
||
| 78 | */ |
||
| 79 | function lsx_scripts_add_fonts() { |
||
|
0 ignored issues
–
show
|
|||
| 80 | $disable_fonts = get_theme_mod( 'lsx_disable_fonts', false ); |
||
| 81 | if ( false !== $disable_fonts ) { |
||
|
0 ignored issues
–
show
|
|||
| 82 | return; |
||
| 83 | } |
||
| 84 | } |
||
|
0 ignored issues
–
show
|
|||
| 85 | endif; |
||
| 86 | |||
| 87 | if ( ! function_exists( 'lsx_scripts_add_scripts' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 88 | |||
| 89 | /** |
||
| 90 | * Enqueue scripts. |
||
| 91 | * |
||
| 92 | * @package lsx |
||
| 93 | * @subpackage scripts |
||
| 94 | */ |
||
| 95 | function lsx_scripts_add_scripts() { |
||
|
0 ignored issues
–
show
|
|||
| 96 | if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 97 | wp_enqueue_script( 'comment-reply' ); |
||
| 98 | } |
||
| 99 | |||
| 100 | wp_enqueue_script( 'platform', get_template_directory_uri() . '/assets/js/vendor/platform.min.js', array(), LSX_VERSION, true ); |
||
| 101 | wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/vendor/bootstrap.min.js', array( 'jquery' ), LSX_VERSION, true ); |
||
| 102 | |||
| 103 | wp_enqueue_script( 'imagesLoaded', get_template_directory_uri() . '/assets/js/vendor/imagesloaded.pkgd.min.js', array( 'masonry' ), LSX_VERSION, true ); |
||
| 104 | wp_enqueue_script( 'scrolltofixed', get_template_directory_uri() . '/assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), LSX_VERSION, true ); |
||
| 105 | wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/js/vendor/slick.min.js', array( 'jquery' ), LSX_VERSION, true ); |
||
| 106 | wp_enqueue_script( 'slick-lightbox', get_template_directory_uri() . '/assets/js/vendor/slick-lightbox.min.js', array( 'jquery', 'slick' ), LSX_VERSION, true ); |
||
| 107 | wp_enqueue_script( 'picturefill', get_template_directory_uri() . '/assets/js/vendor/picturefill.min.js', array(), LSX_VERSION, true ); |
||
| 108 | |||
| 109 | if ( defined( 'SCRIPT_DEBUG' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 110 | $prefix = 'src/'; |
||
| 111 | $suffix = ''; |
||
| 112 | } else { |
||
| 113 | $prefix = ''; |
||
| 114 | $suffix = '.min'; |
||
| 115 | } |
||
|
0 ignored issues
–
show
|
|||
| 116 | wp_enqueue_script( 'lsx_script', get_template_directory_uri() . '/assets/js/' . $prefix . 'lsx' . $suffix . '.js', array( 'jquery', 'platform', 'bootstrap', 'masonry', 'imagesLoaded', 'scrolltofixed', 'slick', 'slick-lightbox', 'picturefill' ), LSX_VERSION, true ); |
||
| 117 | |||
| 118 | $param_array = array( |
||
| 119 | 'columns' => apply_filters( 'lsx_archive_column_number', 3 ), |
||
| 120 | 'stickyMenuSelector' => apply_filters( 'lsx_sticky_menu_selector', 'header.navbar' ), |
||
| 121 | ); |
||
| 122 | |||
| 123 | wp_localize_script( 'lsx_script', 'lsx_params', $param_array ); |
||
| 124 | } |
||
|
0 ignored issues
–
show
|
|||
| 125 | |||
| 126 | endif; |
||
| 127 | |||
| 128 | if ( ! function_exists( 'lsx_scripts_child_theme' ) ) : |
||
|
0 ignored issues
–
show
|
|||
| 129 | |||
| 130 | /** |
||
| 131 | * Enqueue scripts and styles (for child theme). |
||
| 132 | * |
||
| 133 | * @package lsx |
||
| 134 | * @subpackage scripts |
||
| 135 | */ |
||
| 136 | function lsx_scripts_child_theme() { |
||
|
0 ignored issues
–
show
|
|||
| 137 | if ( is_child_theme() && file_exists( get_stylesheet_directory() . '/assets/css/custom.css' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 138 | wp_enqueue_style( 'child-css', get_stylesheet_directory_uri() . '/assets/css/custom.css', array( 'lsx_main' ), LSX_VERSION ); |
||
| 139 | wp_style_add_data( 'child-css', 'rtl', 'replace' ); |
||
| 140 | } |
||
| 141 | } |
||
|
0 ignored issues
–
show
|
|||
| 142 | |||
| 143 | endif; |
||
| 144 | |||
| 145 | add_action( 'wp_enqueue_scripts', 'lsx_scripts_child_theme', 1999 ); |
||
| 146 |