Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 793f9a4

Browse files
committed
Use non-minified scripts and styles if plugin installed via git (submodule)
Also use __DIR__ instead of dirname( __FILE__ )
1 parent 7d1e373 commit 793f9a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

php/class-plugin.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Plugin extends Plugin_Base {
3434
public function __construct() {
3535

3636
// Parse plugin version.
37-
if ( preg_match( '/Version:\s*(\S+)/', file_get_contents( dirname( __FILE__ ) . '/../customize-snapshots.php' ), $matches ) ) {
37+
if ( preg_match( '/Version:\s*(\S+)/', file_get_contents( __DIR__ . '/../customize-snapshots.php' ), $matches ) ) {
3838
$this->version = $matches[1];
3939
}
4040

@@ -66,7 +66,8 @@ public function init() {
6666
* @param \WP_Scripts $wp_scripts Instance of \WP_Scripts.
6767
*/
6868
public function register_scripts( \WP_Scripts $wp_scripts ) {
69-
$min = ( SCRIPT_DEBUG ? '' : '.min' );
69+
$is_git_repo = file_exists( dirname( __DIR__ ) . '/.git' );
70+
$min = ( SCRIPT_DEBUG || $is_git_repo ? '' : '.min' );
7071

7172
$handle = 'customize-snapshots';
7273
$src = $this->dir_url . 'js/customize-snapshots' . $min . '.js';
@@ -92,7 +93,8 @@ public function register_scripts( \WP_Scripts $wp_scripts ) {
9293
* @param \WP_Styles $wp_styles Instance of \WP_Styles.
9394
*/
9495
public function register_styles( \WP_Styles $wp_styles ) {
95-
$min = ( SCRIPT_DEBUG ? '' : '.min' );
96+
$is_git_repo = file_exists( dirname( __DIR__ ) . '/.git' );
97+
$min = ( SCRIPT_DEBUG || $is_git_repo ? '' : '.min' );
9698

9799
$handle = 'customize-snapshots';
98100
$src = $this->dir_url . 'css/customize-snapshots' . $min . '.css';

0 commit comments

Comments
 (0)