From e76a4e0bb181993e7dd0cd8ae622df950849fc61 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Wed, 14 Apr 2021 22:39:16 +0100 Subject: [PATCH 1/3] fix: add separate prod/dev cache-busters --- class/dashboard/layout.php | 37 ++++++++++--------------------------- class/init.php | 6 +----- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index 840410a..a38b88a 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -211,33 +211,16 @@ abstract class MCI_Footnotes_Layout_Engine { * automated update of version number for cache busting. * No need to use '-styles' in the handle, as '-css' is appended automatically. */ - if ( C_BOOL_CSS_PRODUCTION_MODE ) { - - wp_register_style( - 'mci-footnotes-admin', - plugins_url( 'footnotes/css/settings.min.css' ), - array(), - filemtime( - plugin_dir_path( - dirname( __FILE__ ) - ) . 'css/settings.min.css' - ) - ); - - } else { - - wp_register_style( - 'mci-footnotes-admin', - plugins_url( 'footnotes/css/settings.css' ), - array(), - filemtime( - plugin_dir_path( - dirname( __FILE__, 2 ) - ) . 'css/settings.css' - ) - ); - - } + wp_register_style( + 'mci-footnotes-admin', + plugins_url( 'footnotes/css/settings' . ( ( C_BOOL_CSS_PRODUCTION_MODE ) ? '.min' : '' ) . '.css' ), + array(), + ( C_BOOL_CSS_PRODUCTION_MODE ) ? C_STR_PACKAGE_VERSION : filemtime( + plugin_dir_path( + dirname( __FILE__ ) + ) . 'css/settings' . ( ( C_BOOL_CSS_PRODUCTION_MODE ) ? '.min' : '' ) . '.css' + ) + ); wp_enqueue_style( 'mci-footnotes-admin' ); } diff --git a/class/init.php b/class/init.php index af20d85..6e70d9c 100644 --- a/class/init.php +++ b/class/init.php @@ -416,11 +416,7 @@ class MCI_Footnotes { MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_tooltip_mode_short . 'brpl' . $l_str_layout_mode . '.min.css' ), array(), - filemtime( - plugin_dir_path( - dirname( __FILE__ ) - ) . 'css/footnotes-' . $l_str_tooltip_mode_short . 'ttbrpl' . $l_str_layout_mode . '.min.css' - ), + C_STR_PACKAGE_VERSION, 'all' ); From b824a44541644885054839e5238eb2de3c7f9acc Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Wed, 14 Apr 2021 22:47:44 +0100 Subject: [PATCH 2/3] style: rename production flag variable Renames the current production flag variable to be shorter, non-Hungarian (presaging changes to come in #35) and not specifically CSS_-related. See #80 --- _tools/build.sh | 2 +- class/dashboard/layout.php | 6 +++--- class/init.php | 2 +- class/layout/abstract-engine.php | 2 +- footnotes.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_tools/build.sh b/_tools/build.sh index e4b908b..aa89c41 100755 --- a/_tools/build.sh +++ b/_tools/build.sh @@ -12,7 +12,7 @@ cp -t dist/img img/fn-wysiwyg.png img/main-menu.png echo "Copying files..." cp -t dist features.txt license.txt readme.txt includes.php wpml-config.xml customized-documentation-schema.txt customized-template-stack.txt CONTRIBUTING.md README.md SECURITY.md echo "Setting production flag..." -sed "s/'C_BOOL_CSS_PRODUCTION_MODE', false/'C_BOOL_CSS_PRODUCTION_MODE', true/g" footnotes.php > dist/footnotes.php +sed "s/'PRODUCTION_ENV', false/'PRODUCTION_ENV', true/g" footnotes.php > dist/footnotes.php echo "Production flag set." # TODO: once automatic minification is implemented, this should handle that. diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index a38b88a..61c9934 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -213,12 +213,12 @@ abstract class MCI_Footnotes_Layout_Engine { */ wp_register_style( 'mci-footnotes-admin', - plugins_url( 'footnotes/css/settings' . ( ( C_BOOL_CSS_PRODUCTION_MODE ) ? '.min' : '' ) . '.css' ), + plugins_url( 'footnotes/css/settings' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.css' ), array(), - ( C_BOOL_CSS_PRODUCTION_MODE ) ? C_STR_PACKAGE_VERSION : filemtime( + ( PRODUCTION_ENV ) ? C_STR_PACKAGE_VERSION : filemtime( plugin_dir_path( dirname( __FILE__ ) - ) . 'css/settings' . ( ( C_BOOL_CSS_PRODUCTION_MODE ) ? '.min' : '' ) . '.css' + ) . 'css/settings' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.css' ) ); diff --git a/class/init.php b/class/init.php index 6e70d9c..5939040 100644 --- a/class/init.php +++ b/class/init.php @@ -339,7 +339,7 @@ class MCI_Footnotes { * The Boolean may be set at the bottom of the plugin’s main PHP file. * @see footnotes.php */ - if ( C_BOOL_CSS_PRODUCTION_MODE ) { + if ( PRODUCTION_ENV ) { /** * Enqueues a minified united external stylesheet in production. diff --git a/class/layout/abstract-engine.php b/class/layout/abstract-engine.php index 143ad96..b1826e6 100644 --- a/class/layout/abstract-engine.php +++ b/class/layout/abstract-engine.php @@ -211,7 +211,7 @@ abstract class MCI_Footnotes_Layout_Engine { * automated update of version number for cache busting. * No need to use '-styles' in the handle, as '-css' is appended automatically. */ - if ( true === C_BOOL_CSS_PRODUCTION_MODE ) { + if ( true === PRODUCTION_ENV ) { wp_register_style( 'mci-footnotes-admin', plugins_url( 'footnotes/css/settings.min.css' ), array(), C_STR_PACKAGE_VERSION ); diff --git a/footnotes.php b/footnotes.php index 5917208..b6ab661 100755 --- a/footnotes.php +++ b/footnotes.php @@ -103,4 +103,4 @@ $g_obj_mci_footnotes->run(); * Developing stylesheets is meant to be easier when this is set to false. * WARNING: This facility designed for development must NOT be used in production. */ -define( 'C_BOOL_CSS_PRODUCTION_MODE', false ); +define( 'PRODUCTION_ENV', false ); From eb34f30880c12b3b0cc8698b7295ef8305dfb7f7 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Wed, 14 Apr 2021 22:52:56 +0100 Subject: [PATCH 3/3] fix: correct relative filepaths --- class/dashboard/layout.php | 2 +- class/init.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php index 61c9934..16d492e 100644 --- a/class/dashboard/layout.php +++ b/class/dashboard/layout.php @@ -217,7 +217,7 @@ abstract class MCI_Footnotes_Layout_Engine { array(), ( PRODUCTION_ENV ) ? C_STR_PACKAGE_VERSION : filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 2 ) ) . 'css/settings' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.css' ) ); diff --git a/class/init.php b/class/init.php index 5939040..ce57b02 100644 --- a/class/init.php +++ b/class/init.php @@ -436,7 +436,7 @@ class MCI_Footnotes { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 1 ) ) . 'css/dev-common.css' ) ); @@ -446,7 +446,7 @@ class MCI_Footnotes { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 1 ) ) . 'css/dev-tooltips.css' ) ); @@ -458,7 +458,7 @@ class MCI_Footnotes { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 1 ) ) . 'css/dev-amp-tooltips.css' ) ); @@ -471,7 +471,7 @@ class MCI_Footnotes { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 1 ) ) . 'css/dev-tooltips-alternative.css' ) ); @@ -487,7 +487,7 @@ class MCI_Footnotes { array(), filemtime( plugin_dir_path( - dirname( __FILE__ ) + dirname( __FILE__, 1 ) ) . 'css/dev-layout-' . $l_str_page_layout_option . '.css' ), 'all'