|
74 | 74 | * Load styles and scripts to head. |
75 | 75 | */ |
76 | 76 | function ableplayer_enqueue_scripts() { |
| 77 | + $debug = ( SCRIPT_DEBUG || ABLEPLAYER_DEBUG ) ? true : false; |
77 | 78 | $version = ABLEPLAYER_VERSION; |
78 | | - $version = ( SCRIPT_DEBUG ) ? $version . '-' . wp_rand( 1000, 9999 ) : $version; |
| 79 | + $version = ( $debug ) ? $version . '-' . wp_rand( 1000, 9999 ) : $version; |
79 | 80 | // Register/enqueue other dependencies. |
80 | | - $cookie_js = ( SCRIPT_DEBUG ) ? '/js.cookie.js' : '/js.cookie.min.js'; |
| 81 | + $cookie_js = ( $debug ) ? '/js.cookie.js' : '/js.cookie.min.js'; |
81 | 82 | wp_enqueue_script( 'js-cookie', plugins_url( 'thirdparty', __FILE__ ) . $cookie_js, array(), $version, true ); |
82 | 83 | wp_enqueue_script( 'vimeo', 'https://player.vimeo.com/api/player.js', array(), $version, true ); |
83 | 84 | wp_enqueue_style( 'ableplayer-video', plugins_url( 'assets', __FILE__ ) . '/css/media.css', array(), $version ); |
84 | | - $media_js = ( SCRIPT_DEBUG ) ? 'media.js' : 'media.min.js'; |
| 85 | + $media_js = ( $debug ) ? 'media.js' : 'media.min.js'; |
85 | 86 | wp_register_script( 'ableplayer-video', plugins_url( 'assets', __FILE__ ) . '/js/' . $media_js, array(), $version, true ); |
86 | 87 | wp_localize_script( |
87 | 88 | 'ableplayer-video', |
|
90 | 91 | 'settings' => ableplayer_get_settings(), |
91 | 92 | ) |
92 | 93 | ); |
93 | | - // if the environment is production, use minified files. Otherwise, inherit the value of SCRIPT_DEBUG. |
94 | | - $is_production = ( function_exists( 'wp_get_environment_type' ) && wp_get_environment_type() === 'production' ) ? true : SCRIPT_DEBUG; |
95 | 94 |
|
96 | | - $js_file = ( $is_production ) ? 'ableplayer.min.js' : 'ableplayer.js'; |
97 | | - $css_file = ( $is_production ) ? 'ableplayer.min.css' : 'ableplayer.css'; |
| 95 | + $js_file = ( ! $debug ) ? 'ableplayer.min.js' : 'ableplayer.js'; |
| 96 | + $css_file = ( ! $debug ) ? 'build/ableplayer.min.css' : 'styles/ableplayer.css'; |
98 | 97 | /** |
99 | 98 | * Filter the Able Player JS URL. |
100 | 99 | * |
101 | 100 | * @hook able_player_js |
102 | 101 | * |
103 | 102 | * @param {string} $url URL to Able Player root directory. |
104 | | - * @param {bool} $is_production True if environment is designated as production. |
| 103 | + * @param {bool} $debug True if environment is in debugging. |
105 | 104 | * |
106 | 105 | * @return {string} |
107 | 106 | */ |
108 | | - $js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $is_production ); |
| 107 | + $js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $debug ); |
109 | 108 | /** |
110 | 109 | * Filter the Able Player CSS URL. |
111 | 110 | * |
112 | 111 | * @hook able_player_css |
113 | 112 | * |
114 | 113 | * @param {string} $url URL to Able Player root directory. |
115 | | - * @param {bool} $is_production True if environment is designated as production. |
| 114 | + * @param {bool} $debug True if environment is debugging. |
116 | 115 | * |
117 | 116 | * @return {string} |
118 | 117 | */ |
119 | | - $css_dir = apply_filters( 'able_player_css', plugins_url( 'build', __FILE__ ) . '/' . $css_file, $is_production ); |
| 118 | + $css_dir = apply_filters( 'able_player_css', plugins_url( '', __FILE__ ) . '/' . $css_file, $debug ); |
120 | 119 |
|
121 | 120 | $dependencies = array( 'js-cookie', 'jquery', 'ableplayer-video' ); |
122 | 121 | /** |
|
125 | 124 | * @hook ableplayer_dependencies |
126 | 125 | * |
127 | 126 | * @param {array} $dependencies Array of scripts required by the main Able Player script. |
128 | | - * @param {bool} $is_production True if environment is designated as production. |
| 127 | + * @param {bool} $debug True if environment is in debugging mode. |
129 | 128 | * |
130 | 129 | * @return {array} |
131 | 130 | */ |
132 | | - $dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $is_production ); |
| 131 | + $dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $debug ); |
133 | 132 | wp_enqueue_script( 'ableplayer', $js_dir, $dependencies, $version, true ); |
134 | 133 | wp_enqueue_style( 'ableplayer', $css_dir, array(), $version ); |
135 | 134 | } |
|
0 commit comments