Skip to content

Commit 9c89948

Browse files
committed
Remove unbuilt CSS from build folder.
Now checks the styles folder if not in debug; matches AblePlayer org.
1 parent 8eb327b commit 9c89948

File tree

4 files changed

+31
-1386
lines changed

4 files changed

+31
-1386
lines changed

src/ableplayer.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ function ableplayer_plugin_deactivated() {
4848
* Load styles and scripts to head.
4949
*/
5050
function ableplayer_enqueue_scripts() {
51+
$debug = ( SCRIPT_DEBUG || ABLEPLAYER_DEBUG ) ? true : false;
5152
$version = ABLEPLAYER_VERSION;
52-
$version = ( SCRIPT_DEBUG ) ? $version . '-' . wp_rand( 1000, 9999 ) : $version;
53+
$version = ( $debug ) ? $version . '-' . wp_rand( 1000, 9999 ) : $version;
5354
// Register/enqueue other dependencies.
54-
$cookie_js = ( SCRIPT_DEBUG ) ? '/js.cookie.js' : '/js.cookie.min.js';
55+
$cookie_js = ( $debug ) ? '/js.cookie.js' : '/js.cookie.min.js';
5556
wp_enqueue_script( 'js-cookie', plugins_url( 'thirdparty', __FILE__ ) . $cookie_js, array(), $version, true );
5657
wp_enqueue_script( 'vimeo', 'https://player.vimeo.com/api/player.js', array(), $version, true );
5758
wp_enqueue_style( 'ableplayer-video', plugins_url( 'assets', __FILE__ ) . '/css/media.css', array(), $version );
58-
$media_js = ( SCRIPT_DEBUG ) ? 'media.js' : 'media.min.js';
59+
$media_js = ( $debug ) ? 'media.js' : 'media.min.js';
5960
wp_register_script( 'ableplayer-video', plugins_url( 'assets', __FILE__ ) . '/js/' . $media_js, array(), $version, true );
6061
wp_localize_script(
6162
'ableplayer-video',
@@ -64,33 +65,31 @@ function ableplayer_enqueue_scripts() {
6465
'settings' => ableplayer_get_settings(),
6566
)
6667
);
67-
// if the environment is production, use minified files. Otherwise, inherit the value of SCRIPT_DEBUG.
68-
$is_production = ( function_exists( 'wp_get_environment_type' ) && wp_get_environment_type() === 'production' ) ? true : SCRIPT_DEBUG;
6968

70-
$js_file = ( $is_production ) ? 'ableplayer.min.js' : 'ableplayer.js';
71-
$css_file = ( $is_production ) ? 'ableplayer.min.css' : 'ableplayer.css';
69+
$js_file = ( ! $debug ) ? 'ableplayer.min.js' : 'ableplayer.js';
70+
$css_file = ( ! $debug ) ? 'build/ableplayer.min.css' : 'styles/ableplayer.css';
7271
/**
7372
* Filter the Able Player JS URL.
7473
*
7574
* @hook able_player_js
7675
*
7776
* @param {string} $url URL to Able Player root directory.
78-
* @param {bool} $is_production True if environment is designated as production.
77+
* @param {bool} $debug True if environment is in debugging.
7978
*
8079
* @return {string}
8180
*/
82-
$js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $is_production );
81+
$js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $debug );
8382
/**
8483
* Filter the Able Player CSS URL.
8584
*
8685
* @hook able_player_css
8786
*
8887
* @param {string} $url URL to Able Player root directory.
89-
* @param {bool} $is_production True if environment is designated as production.
88+
* @param {bool} $debug True if environment is debugging.
9089
*
9190
* @return {string}
9291
*/
93-
$css_dir = apply_filters( 'able_player_css', plugins_url( 'build', __FILE__ ) . '/' . $css_file, $is_production );
92+
$css_dir = apply_filters( 'able_player_css', plugins_url( '', __FILE__ ) . '/' . $css_file, $debug );
9493

9594
$dependencies = array( 'js-cookie', 'jquery', 'ableplayer-video' );
9695
/**
@@ -99,11 +98,11 @@ function ableplayer_enqueue_scripts() {
9998
* @hook ableplayer_dependencies
10099
*
101100
* @param {array} $dependencies Array of scripts required by the main Able Player script.
102-
* @param {bool} $is_production True if environment is designated as production.
101+
* @param {bool} $debug True if environment is in debugging mode.
103102
*
104103
* @return {array}
105104
*/
106-
$dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $is_production );
105+
$dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $debug );
107106
wp_enqueue_script( 'ableplayer', $js_dir, $dependencies, $version, true );
108107
wp_enqueue_style( 'ableplayer', $css_dir, array(), $version );
109108
}

0 commit comments

Comments
 (0)