Child Theme Configurator - Version 2.5.0

Version Description

  • Preview class now evaluates stylesheet hooks as they fire instead of calling them again to prevent function exists errors.
  • Tested for PHP version 7.1
  • Modified input parser to allow multi-stop background gradients.
Download this release

Release Info

Developer lilaeamedia
Plugin Icon 128x128 Child Theme Configurator
Version 2.5.0
Comparing to
See all releases

Code changes from version 2.4.4 to 2.5.0

child-theme-configurator.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.childthemeconfigurator.com
8
  Description: When using the Customizer is not enough - Create child themes and customize styles, templates, functions and more.
9
- Version: 2.4.4
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com
12
  Text Domain: child-theme-configurator
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.childthemeconfigurator.com
8
  Description: When using the Customizer is not enough - Create child themes and customize styles, templates, functions and more.
9
+ Version: 2.5.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com
12
  Text Domain: child-theme-configurator
includes/classes/CSS.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  Class: ChildThemeConfiguratorCSS
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Handles all CSS input, output, parsing, normalization and storage
9
- Version: 2.4.4
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -172,7 +172,7 @@ class ChildThemeConfiguratorCSS {
172
  $this->ignoreparnt = 0;
173
  $this->qpriority = 10;
174
  $this->mpriority = 10;
175
- $this->version = '2.4.4';
176
 
177
  // do not set enqueue, not being set is used to flag old versions
178
 
@@ -903,7 +903,13 @@ class ChildThemeConfiguratorCSS {
903
  $value = $rule_part[ 'background_url' ];
904
  elseif ( 'background-image' == $rule ):
905
  if ( empty( $rule_part[ 'background_url' ] ) ):
906
- if ( empty( $rule_part[ 'background_color2' ] ) ):
 
 
 
 
 
 
907
  $value = '';
908
  else:
909
  if ( empty( $rule_part[ 'background_origin' ] ) )
6
  Class: ChildThemeConfiguratorCSS
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Handles all CSS input, output, parsing, normalization and storage
9
+ Version: 2.5.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
172
  $this->ignoreparnt = 0;
173
  $this->qpriority = 10;
174
  $this->mpriority = 10;
175
+ $this->version = '2.5.0';
176
 
177
  // do not set enqueue, not being set is used to flag old versions
178
 
903
  $value = $rule_part[ 'background_url' ];
904
  elseif ( 'background-image' == $rule ):
905
  if ( empty( $rule_part[ 'background_url' ] ) ):
906
+ // custom multi-stop or radial gradients can be passed verbatim in the origin field
907
+ // but will not be parsed for vender-prefix support.
908
+ if ( !empty( $rule_part[ 'background_origin' ] )
909
+ && preg_match( '{gradient}', $rule_part[ 'background_origin' ] ) ):
910
+ $value = $rule_part[ 'background_origin' ];
911
+
912
+ elseif ( empty( $rule_part[ 'background_color2' ] ) ):
913
  $value = '';
914
  else:
915
  if ( empty( $rule_part[ 'background_origin' ] ) )
includes/classes/Core.php CHANGED
@@ -14,7 +14,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
14
  define( 'LILAEAMEDIA_URL', "http://www.lilaeamedia.com" );
15
  defined( 'CHLD_THM_CFG_DOCS_URL' ) or
16
  define( 'CHLD_THM_CFG_DOCS_URL', "http://www.childthemeconfigurator.com" );
17
- define( 'CHLD_THM_CFG_VERSION', '2.4.4' );
18
  define( 'CHLD_THM_CFG_PREV_VERSION', '1.7.9.1' );
19
  define( 'CHLD_THM_CFG_MIN_WP_VERSION', '3.7' );
20
  define( 'CHLD_THM_CFG_PRO_MIN_VERSION', '2.2.0' );
14
  define( 'LILAEAMEDIA_URL', "http://www.lilaeamedia.com" );
15
  defined( 'CHLD_THM_CFG_DOCS_URL' ) or
16
  define( 'CHLD_THM_CFG_DOCS_URL', "http://www.childthemeconfigurator.com" );
17
+ define( 'CHLD_THM_CFG_VERSION', '2.5.0' );
18
  define( 'CHLD_THM_CFG_PREV_VERSION', '1.7.9.1' );
19
  define( 'CHLD_THM_CFG_MIN_WP_VERSION', '3.7' );
20
  define( 'CHLD_THM_CFG_PRO_MIN_VERSION', '2.2.0' );
includes/classes/Preview.php CHANGED
@@ -14,11 +14,13 @@ class ChildThemeConfiguratorPreview {
14
  protected $original_stylesheet;
15
  protected $stylesheet;
16
  protected $template;
 
 
 
17
 
18
  public function __construct(){
19
  add_action( 'setup_theme', array( $this, 'setup_theme' ) );
20
  add_filter( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 );
21
-
22
  // Do not spawn cron (especially the alternate cron) while running the Customizer.
23
  remove_action( 'init', 'wp_cron' );
24
 
@@ -28,6 +30,30 @@ class ChildThemeConfiguratorPreview {
28
  remove_action( 'admin_init', '_maybe_update_themes' );
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  public function setup_theme() {
32
  // are we previewing? - removed nonce requirement to bool flag v2.2.5
33
  if ( empty( $_GET['preview_ctc'] ) || !current_user_can( 'switch_themes' ) )
@@ -44,6 +70,7 @@ class ChildThemeConfiguratorPreview {
44
  // swap out theme mods with preview theme mods
45
  add_filter( 'pre_option_theme_mods_' . $this->original_stylesheet, array( $this, 'preview_mods' ) );
46
  endif;
 
47
  // impossibly high priority to test for stylesheets loaded after wp_head()
48
  add_action( 'wp_print_styles', array( $this, 'test_css' ), 999999 );
49
  // pass the wp_styles queue back to use for stylesheet handle verification
@@ -63,8 +90,7 @@ class ChildThemeConfiguratorPreview {
63
 
64
  public function parse_stylesheet() {
65
  echo '<script>/*<![CDATA[' . LF;
66
- global $wp_styles, $wp_filter;
67
- $queue = implode( "\n", array_keys( $wp_styles->registered ) );
68
  echo 'BEGIN WP QUEUE' . LF . $queue . LF . 'END WP QUEUE' . LF;
69
  if ( is_child_theme() ):
70
  // check for signals that indicate specific settings
@@ -106,26 +132,14 @@ class ChildThemeConfiguratorPreview {
106
  */
107
  echo 'BEGIN CTC IRREGULAR' . LF;
108
  // Iterate through all the added hook priorities
109
- foreach ( $wp_filter[ 'wp_enqueue_scripts' ] as $priority => $arr ):
110
  // If this is a non-standard priority hook, determine which handles are being enqueued.
111
  // These will then be compared to the primary handle ( style.css )
112
  // to determine the enqueue priority to use for the parent stylesheet.
113
- if ( $priority != 10 ):
114
- //echo 'priority: ' . $priority . ' ' . print_r( $arr, TRUE ) . LF;
115
- // iterate through each hook in this priority group
116
- foreach ( $arr as $funcarr ):
117
- // clear the queue
118
- $wp_styles->queue = array();
119
- // now call the hooked function to populate the queue
120
- if ( !is_null($funcarr['function']) )
121
- call_user_func_array( $funcarr[ 'function' ], array( 0 ) );
122
- endforeach;
123
- // report the priority, and any handles that were added
124
- if ( !empty( $wp_styles->queue ) )
125
- echo $priority . ',' . implode( ",", $wp_styles->queue ) . LF;
126
- endif;
127
- endforeach;
128
  echo 'END CTC IRREGULAR' . LF;
 
129
  if ( defined( 'WP_CACHE' ) && WP_CACHE )
130
  echo 'HAS_WP_CACHE' . LF;
131
  if ( defined( 'AUTOPTIMIZE_PLUGIN_DIR' ) )
14
  protected $original_stylesheet;
15
  protected $stylesheet;
16
  protected $template;
17
+ protected $priorities = array();
18
+ protected $handles = array();
19
+ protected $queued = array();
20
 
21
  public function __construct(){
22
  add_action( 'setup_theme', array( $this, 'setup_theme' ) );
23
  add_filter( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 );
 
24
  // Do not spawn cron (especially the alternate cron) while running the Customizer.
25
  remove_action( 'init', 'wp_cron' );
26
 
30
  remove_action( 'admin_init', '_maybe_update_themes' );
31
  }
32
 
33
+ public function check_wp_queue(){
34
+ global $wp_filter;
35
+ if ( empty( $wp_filter[ 'wp_enqueue_scripts' ] ) )
36
+ return;
37
+ // Iterate through all the added hook priorities
38
+ $this->priorities = array_keys( $wp_filter[ 'wp_enqueue_scripts' ]->callbacks );
39
+
40
+ // add hook directly after each priority to get any added stylesheet handles
41
+ foreach ( $this->priorities as $priority )
42
+ add_action( 'wp_enqueue_scripts', array( $this, 'get_handles' ), $priority );
43
+ }
44
+
45
+ public function get_handles(){
46
+ global $wp_styles;
47
+ // remove priority from stack
48
+ $priority = array_shift( $this->priorities );
49
+ if ( !is_object( $wp_styles ) )
50
+ return;
51
+ // get handles queued since last check
52
+ $this->handles[ $priority ] = array_diff( $wp_styles->queue, $this->queued );
53
+ // add new handles to queued array
54
+ $this->queued = array_merge( $this->queued, $this->handles[ $priority ] );
55
+ }
56
+
57
  public function setup_theme() {
58
  // are we previewing? - removed nonce requirement to bool flag v2.2.5
59
  if ( empty( $_GET['preview_ctc'] ) || !current_user_can( 'switch_themes' ) )
70
  // swap out theme mods with preview theme mods
71
  add_filter( 'pre_option_theme_mods_' . $this->original_stylesheet, array( $this, 'preview_mods' ) );
72
  endif;
73
+ add_action( 'wp_head', array( $this, 'check_wp_queue' ), 0 );
74
  // impossibly high priority to test for stylesheets loaded after wp_head()
75
  add_action( 'wp_print_styles', array( $this, 'test_css' ), 999999 );
76
  // pass the wp_styles queue back to use for stylesheet handle verification
90
 
91
  public function parse_stylesheet() {
92
  echo '<script>/*<![CDATA[' . LF;
93
+ $queue = implode( "\n", $this->queued );
 
94
  echo 'BEGIN WP QUEUE' . LF . $queue . LF . 'END WP QUEUE' . LF;
95
  if ( is_child_theme() ):
96
  // check for signals that indicate specific settings
132
  */
133
  echo 'BEGIN CTC IRREGULAR' . LF;
134
  // Iterate through all the added hook priorities
135
+ foreach ( $this->handles as $priority => $arr )
136
  // If this is a non-standard priority hook, determine which handles are being enqueued.
137
  // These will then be compared to the primary handle ( style.css )
138
  // to determine the enqueue priority to use for the parent stylesheet.
139
+ if ( $priority != 10 && !empty( $arr ) )
140
+ echo $priority . ',' . implode( ",", $arr ) . LF;
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  echo 'END CTC IRREGULAR' . LF;
142
+ ;
143
  if ( defined( 'WP_CACHE' ) && WP_CACHE )
144
  echo 'HAS_WP_CACHE' . LF;
145
  if ( defined( 'AUTOPTIMIZE_PLUGIN_DIR' ) )
js/chldthmcfg.js CHANGED
@@ -2,7 +2,7 @@
2
  * Script: chldthmcfg.js
3
  * Plugin URI: http://www.childthemeconfigurator.com/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 2.4.4
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
2
  * Script: chldthmcfg.js
3
  * Plugin URI: http://www.childthemeconfigurator.com/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 2.5.0
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: child, theme, child theme, child themes, custom styles, customize styles, customize theme, css, responsive, css editor, child theme editor, child theme generator, child theme creator, style, stylesheet, customizer, childtheme, childthemes
5
  Requires at least: 4.0
6
  Requires PHP: 5.6.36
7
- Tested up to: 5.1
8
- Stable tag: 2.4.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -298,21 +298,22 @@ https://www.youtube.com/watch?v=iBiiAgsK4G4
298
  7. Files tab
299
 
300
  == Changelog ==
301
- = 2.4.4 =
 
 
 
 
 
302
  * Analyzer now saves all signals on successful child theme regardless of analysis results.
303
  * This fixes a bug in some themes where the enqueue hooks were being rewitten incorrectly after adding web fonts.
304
- = 2.4.3 =
305
  * Fixed a serious regression bug created by version 2.4.2.
306
- = 2.4.2 =
307
  * Added call to customizer.php to initialize theme mods prior to analyzing child theme
308
  * Deferred copy_theme_mods until after child theme analysis. This allows hooks in Preview to initialize custom theme mods
309
  * Added mpriority (max priority) to CSS object to accommodate multiple irregular stylesheet hooks
310
  * Restored original (pre 2.4.1) version filter hook style_loader_src to child theme stylesheets to prevent caching
311
  * Strip closing php tag from functions.php to prevent premature response header
312
- = 2.4.1 =
313
  * Fixed localization issues (thanks @alexclassroom for identifying these)
314
  * Modified style_loader_src hook to only add timestamp under certain conditions to prevent loading delay for most requests. (thanks @anthony750)
315
- = 2.4.0 =
316
  * Automatically add action parent RTL stylesheet when child theme does not have one.
317
  * Handle case where parent theme changes queue action incorrectly points to non-existent child theme stylesheet.
318
  * Correctly copies customizer css to child theme.
@@ -573,8 +574,9 @@ https://www.youtube.com/watch?v=iBiiAgsK4G4
573
 
574
  == Upgrade Notice ==
575
 
576
- 2.4.4 Analyzer now always resubmits on success to ensure all signals are saved. This fixes a bug in some themes where the enqueue hooks were being rewitten incorrectly after adding web fonts.
577
- 2.4.3 Fixed a serious regression bug created by version 2.4.2. Please update immediately.
 
578
 
579
  == Query/Selector Tab ==
580
 
4
  Tags: child, theme, child theme, child themes, custom styles, customize styles, customize theme, css, responsive, css editor, child theme editor, child theme generator, child theme creator, style, stylesheet, customizer, childtheme, childthemes
5
  Requires at least: 4.0
6
  Requires PHP: 5.6.36
7
+ Tested up to: 5.2
8
+ Stable tag: 2.5.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
298
  7. Files tab
299
 
300
  == Changelog ==
301
+ = 2.5.0 =
302
+ * Preview class now evaluates stylesheet hooks as they fire instead of calling them again to prevent function exists errors.
303
+ * Tested for PHP version 7.1
304
+ * Modified input parser to allow multi-stop background gradients.
305
+
306
+ = 2.4.x =
307
  * Analyzer now saves all signals on successful child theme regardless of analysis results.
308
  * This fixes a bug in some themes where the enqueue hooks were being rewitten incorrectly after adding web fonts.
 
309
  * Fixed a serious regression bug created by version 2.4.2.
 
310
  * Added call to customizer.php to initialize theme mods prior to analyzing child theme
311
  * Deferred copy_theme_mods until after child theme analysis. This allows hooks in Preview to initialize custom theme mods
312
  * Added mpriority (max priority) to CSS object to accommodate multiple irregular stylesheet hooks
313
  * Restored original (pre 2.4.1) version filter hook style_loader_src to child theme stylesheets to prevent caching
314
  * Strip closing php tag from functions.php to prevent premature response header
 
315
  * Fixed localization issues (thanks @alexclassroom for identifying these)
316
  * Modified style_loader_src hook to only add timestamp under certain conditions to prevent loading delay for most requests. (thanks @anthony750)
 
317
  * Automatically add action parent RTL stylesheet when child theme does not have one.
318
  * Handle case where parent theme changes queue action incorrectly points to non-existent child theme stylesheet.
319
  * Correctly copies customizer css to child theme.
574
 
575
  == Upgrade Notice ==
576
 
577
+ * Preview class now evaluates stylesheet hooks as they fire instead of calling them again to prevent function exists errors.
578
+ * Tested for PHP version 7.1
579
+ * See changelog for details.
580
 
581
  == Query/Selector Tab ==
582