Child Theme Configurator - Version 1.3.1

Version Description

  • Updated help tab content. Added additional sanitization of source and target file paths.
Download this release

Release Info

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

Code changes from version 1.3.0 to 1.3.1

child-theme-configurator.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Create a Child Theme from any installed Theme. Each CSS selector, rule and value can then be searched, previewed and modified.
9
- Version: 1.3.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -16,7 +16,7 @@ if ( !defined('ABSPATH')) exit;
16
  */
17
 
18
  defined('LF') or define('LF', "\n");
19
- define('CHLD_THM_CFG_VERSION', '1.3.0');
20
 
21
  if (is_admin()):
22
  include_once( 'includes/class-ctc.php' );
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Create a Child Theme from any installed Theme. Each CSS selector, rule and value can then be searched, previewed and modified.
9
+ Version: 1.3.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
16
  */
17
 
18
  defined('LF') or define('LF', "\n");
19
+ define('CHLD_THM_CFG_VERSION', '1.3.1');
20
 
21
  if (is_admin()):
22
  include_once( 'includes/class-ctc.php' );
includes/class-ctc-css.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Class: Child_Theme_Configurator_CSS
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Handles all CSS output, parsing, normalization
9
- Version: 1.3.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -44,7 +44,7 @@ class Child_Theme_Configurator_CSS {
44
 
45
  function __construct() {
46
  // scalars
47
- $this->version = '1.3.0';
48
  $this->querykey = 0;
49
  $this->selkey = 0;
50
  $this->qskey = 0;
@@ -232,9 +232,12 @@ class Child_Theme_Configurator_CSS {
232
  $source = $this->get_prop($template);
233
  if (empty($source) || !is_scalar($source)) return false;
234
  $stylesheet = apply_filters('chld_thm_cfg_' . $template, get_theme_root() . '/' . $source . '/style.css', $this);
 
235
  // read stylesheet
236
- if (!is_file($stylesheet)) return false;
237
- return @file_get_contents($stylesheet);
 
 
238
  }
239
 
240
  /*
@@ -496,15 +499,18 @@ class Child_Theme_Configurator_CSS {
496
  if ($has_selector) $output .= $sel_output;
497
  endforeach;
498
  $stylesheet = apply_filters('chld_thm_cfg_target', $this->get_child_target(), $this);
499
- // backup current stylesheet
500
- if ($backup && is_file($stylesheet)):
501
- $timestamp = date('YmdHis', current_time('timestamp'));
502
- $bakfile = preg_replace("/\.css$/", '', $stylesheet) . '-' . $timestamp . '.css';
503
- if (false === file_put_contents($bakfile, file_get_contents($stylesheet))) return false;
504
- endif;
505
- // write new stylesheet
506
- if (false === file_put_contents($stylesheet, $output)) return false;
507
- return true;
 
 
 
508
  }
509
 
510
  /*
@@ -957,5 +963,21 @@ class Child_Theme_Configurator_CSS {
957
  function from_ascii($matches) {
958
  return chr($matches[0]);
959
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
960
  }
961
  ?>
6
  Class: Child_Theme_Configurator_CSS
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Handles all CSS output, parsing, normalization
9
+ Version: 1.3.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
44
 
45
  function __construct() {
46
  // scalars
47
+ $this->version = '1.3.1';
48
  $this->querykey = 0;
49
  $this->selkey = 0;
50
  $this->qskey = 0;
232
  $source = $this->get_prop($template);
233
  if (empty($source) || !is_scalar($source)) return false;
234
  $stylesheet = apply_filters('chld_thm_cfg_' . $template, get_theme_root() . '/' . $source . '/style.css', $this);
235
+
236
  // read stylesheet
237
+ if ($stylesheet_verified = $this->is_file_ok($stylesheet, 'read')):
238
+ return @file_get_contents($stylesheet_verified);
239
+ endif;
240
+ return false;
241
  }
242
 
243
  /*
499
  if ($has_selector) $output .= $sel_output;
500
  endforeach;
501
  $stylesheet = apply_filters('chld_thm_cfg_target', $this->get_child_target(), $this);
502
+ if ($stylesheet_verified = $this->is_file_ok($stylesheet, 'write')):
503
+ // backup current stylesheet
504
+ if ($backup && is_file($stylesheet_verified)):
505
+ $timestamp = date('YmdHis', current_time('timestamp'));
506
+ $bakfile = preg_replace("/\.css$/", '', $stylesheet_verified) . '-' . $timestamp . '.css';
507
+ if (false === file_put_contents($bakfile, file_get_contents($stylesheet_verified))) return false;
508
+ endif;
509
+ // write new stylesheet
510
+ if (false === file_put_contents($stylesheet_verified, $output)) return false;
511
+ return true;
512
+ endif;
513
+ return false;
514
  }
515
 
516
  /*
963
  function from_ascii($matches) {
964
  return chr($matches[0]);
965
  }
966
+
967
+ /* is_file_ok
968
+ * verify file exists and is in valid location
969
+ */
970
+ function is_file_ok($stylesheet, $permission = 'read') {
971
+ // remove any ../ manipulations
972
+ $stylesheet = preg_replace("%\.\./%", '/', $stylesheet);
973
+ if ('read' == $permission && !is_file($stylesheet)) return false;
974
+ // sanity check for php files
975
+ if (preg_match('%php$%', $stylesheet)) return false;
976
+ // check if in themes dir;
977
+ if (preg_match('%^' . get_theme_root() . '%', $stylesheet)) return $stylesheet;
978
+ // check if in plugins dir
979
+ if (preg_match('%^' . WP_PLUGIN_DIR . '%', $stylesheet)) return $stylesheet;
980
+ return false;
981
+ }
982
  }
983
  ?>
includes/class-ctc-ui.php CHANGED
@@ -5,7 +5,7 @@ if ( !defined('ABSPATH')) exit;
5
  Class: Child_Theme_Configurator_UI
6
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
7
  Description: Handles the plugin User Interface
8
- Version: 1.3.0
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
@@ -457,6 +457,15 @@ class Child_Theme_Configurator_UI {
457
  'id' => 'ctc_faq',
458
  'title' => __( 'FAQs', 'chld_thm_cfg' ),
459
  'content' => __( '
 
 
 
 
 
 
 
 
 
460
  <h5 id="specific_color">How do I change a specific color/font style/background?</h5>
461
  <p>You can override a specific value globally using the Rule/Value tab. See Rule/Value, above.</p>
462
  <h5 id="add_styles">How do I add styles that aren\'t in the Parent Theme?</h5>
@@ -506,6 +515,8 @@ class Child_Theme_Configurator_UI {
506
  // Set help sidebar
507
  $screen->set_help_sidebar(
508
  '
 
 
509
  <ul>
510
  <li><a href="http://www.lilaeamedia.com/about/contact/">' . __( 'Contact us', 'chld_thm_cfg' ) . '</a></li>
511
  <li><a href="http://www.lilaeamedia.com/plugins/child-theme-configurator">' . __( 'Plugin Website', 'chld_thm_cfg' ) . '</a></li>
5
  Class: Child_Theme_Configurator_UI
6
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
7
  Description: Handles the plugin User Interface
8
+ Version: 1.3.1
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
457
  'id' => 'ctc_faq',
458
  'title' => __( 'FAQs', 'chld_thm_cfg' ),
459
  'content' => __( '
460
+ <h5>Does it work with Plugins?</h5>
461
+ <p>We offer a premium extension to let you easily modify styles for any WordPress Plugin installed on your website. The Child Theme Configurator Plugin Extension scans your plugins and allows you to create custom stylesheets in your Child Theme. <a href="http://www.lilaeamedia.com/plugins/child-theme-plugin-styles" title="Child Theme Configurator Extension">Learn more</a></p>
462
+ <h5 id="doesnt_work">Why doesn’t this work with my (insert theme vendor here) theme?</h5>
463
+ <p>Some themes (particularly commercial themes) do not adhere to the Theme Development guidelines set forth by WordPress.org, and do not automatically load child theme stylesheets or php files. This is unfortunate, because it effectively prohibits the webmaster from adding any customizations (other than those made through the admin theme options) that will survive past an upgrade.</p>
464
+ <p>Contact the vendor directly to ask for this core functionality. It is our opinion that ALL themes (especially commercial ones) must pass the Theme Unit Tests outlined by WordPress.org.</p>
465
+ <h5 id="menus-broken">Why are my menus displaying incorrectly when I activate the new child theme?</h5>
466
+ <p>The child theme creates a new instance in the WordPress options data and the menus have to be assigned. Go to Appearance &gt; Menus and assign locations to each of the menus for the new Child Theme.</p>
467
+ <h5 "preview-not-loading">Why do the preview tabs return "Stylesheet could not be displayed"?</h5>
468
+ <p>You have to configure at least one child theme from the Parent/Child tab for the preview to display.</p>
469
  <h5 id="specific_color">How do I change a specific color/font style/background?</h5>
470
  <p>You can override a specific value globally using the Rule/Value tab. See Rule/Value, above.</p>
471
  <h5 id="add_styles">How do I add styles that aren\'t in the Parent Theme?</h5>
515
  // Set help sidebar
516
  $screen->set_help_sidebar(
517
  '
518
+ <h4>Now it works with plugins, too!</h4>
519
+ <p style="font-size:smaller">Easily modify styles for any WordPress Plugin installed on your website. The Child Theme Configurator Plugin Extension scans your plugins and allows you to create custom stylesheets in your Child Theme. <a href="http://www.lilaeamedia.com/plugins/child-theme-plugin-styles" title="Child Theme Configurator Extension">Learn more</a></p>
520
  <ul>
521
  <li><a href="http://www.lilaeamedia.com/about/contact/">' . __( 'Contact us', 'chld_thm_cfg' ) . '</a></li>
522
  <li><a href="http://www.lilaeamedia.com/plugins/child-theme-configurator">' . __( 'Plugin Website', 'chld_thm_cfg' ) . '</a></li>
includes/class-ctc.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Class: Child_Theme_Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Main Controller Class
9
- Version: 1.3.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -138,16 +138,6 @@ class Child_Theme_Configurator {
138
  endforeach;
139
  }
140
 
141
- function load_config() {
142
- if (!($this->css = get_option($this->optionsName))
143
- || !is_object($this->css)
144
- // upgrade to v.1.1.1
145
- || !($version = $this->css->get_prop('version'))
146
- )
147
-
148
- $this->css = new Child_Theme_Configurator_CSS();
149
- }
150
-
151
  function validate_post($action = 'ctc_update', $noncefield = '_wpnonce') {
152
  return ('POST' == $_SERVER['REQUEST_METHOD']
153
  && current_user_can('edit_theme_options')
@@ -194,6 +184,16 @@ class Child_Theme_Configurator {
194
  die(0);
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
197
  function write_config() {
198
  if (!isset($_POST['ctc_load_styles'])) return false;
199
  $this->errors = array();
6
  Class: Child_Theme_Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Main Controller Class
9
+ Version: 1.3.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
138
  endforeach;
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
141
  function validate_post($action = 'ctc_update', $noncefield = '_wpnonce') {
142
  return ('POST' == $_SERVER['REQUEST_METHOD']
143
  && current_user_can('edit_theme_options')
184
  die(0);
185
  }
186
 
187
+ function load_config() {
188
+ if (!($this->css = get_option($this->optionsName))
189
+ || !is_object($this->css)
190
+ // upgrade to v.1.1.1
191
+ || !($version = $this->css->get_prop('version'))
192
+ )
193
+
194
+ $this->css = new Child_Theme_Configurator_CSS();
195
+ }
196
+
197
  function write_config() {
198
  if (!isset($_POST['ctc_load_styles'])) return false;
199
  $this->errors = array();
js/chld-thm-cfg.js CHANGED
@@ -2,7 +2,7 @@
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.3.0
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 1.3.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
js/chld-thm-cfg.min.js CHANGED
@@ -2,7 +2,7 @@
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.3.0
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 1.3.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: lilaeamedia
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8QE5YJ8WE96AJ
4
  Tags: child theme, custom theme, CSS, responsive design, CSS editor, theme generator
5
  Requires at least: 3.7
6
- Tested up to: 3.8
7
- Stable tag: 1.3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,7 +14,12 @@ Create a Child Theme from any installed Theme. Each CSS selector, rule and value
14
 
15
  Created by Lilaea Media, the team that brought you IntelliWidget, the Child Theme Configurator provides a new approach to WordPress stylesheets. The Child Theme Configurator lets you identify and override only the Parent Theme style attributes you want to change. It gives you unlimited control over your WordPress look and feel while leaving your Parent Theme untouched.
16
 
17
- The Child Theme Configurator attacks this challenge from a new angle. First, it parses and indexes a Theme's stylesheet so that every media query, selector, rule and value are at your fingertips. Second, it shows you how each change you make will look before you commit it to the Child Theme.Finally, it saves your work so that you can fine-tune your Child Theme without the risk of losing your edits.
 
 
 
 
 
18
  You can create any number of Child Themes from any existing Parent Theme. The Child Theme Configurator lets you choose from your installed themes (even existing Child Themes) and save the results in your Themes directory.
19
 
20
  When you are ready, just activate the Child Theme and your WordPress site takes on the new look and feel automatically.
@@ -32,7 +37,6 @@ Why create Child Themes using the Child Theme Configurator?
32
  * Import web fonts and use them in place of Theme fonts
33
  * Save hours of development time
34
 
35
-
36
  == Installation ==
37
 
38
  1. Download the Child Theme Configurator plugin archive and unzip it.
@@ -41,6 +45,10 @@ Why create Child Themes using the Child Theme Configurator?
41
 
42
  == Frequently Asked Questions ==
43
 
 
 
 
 
44
  = Is there a tutorial? =
45
 
46
  http://www.youtube.com/watch?v=xL2HkWQxgOA
@@ -49,6 +57,10 @@ http://www.youtube.com/watch?v=xL2HkWQxgOA
49
 
50
  Some themes (particularly commercial themes) do not adhere to the Theme Development guidelines set forth by WordPress.org, and do not automatically load child theme stylesheets or php files. This is unfortunate, because it effectively prohibits the webmaster from adding any customizations (other than those made through the admin theme options) that will survive past an upgrade. Contact the vendor directly to ask for this core functionality. It is our opinion that ALL themes (especially commercial ones) must pass the Theme Unit Tests outlined by WordPress.org.
51
 
 
 
 
 
52
  = Where is it in the Admin? =
53
 
54
  The Child Theme Configurator can be found under the "Tools" menu in the WordPress Admin. Click "Child Themes" to get started.
@@ -125,6 +137,9 @@ You can also create a secondary stylesheet that contains @font-face rules and im
125
 
126
  == Changelog ==
127
 
 
 
 
128
  = 1.3.0 =
129
  * Changed CSS preview to retrieve directly from WordPress Admin instead of remote http GET to prevent caching issues.
130
  * Added loading icon for CSS preview.
@@ -195,27 +210,8 @@ You can also create a secondary stylesheet that contains @font-face rules and im
195
  * Initial release.
196
 
197
  == Upgrade Notice ==
198
- = 1.2.2 =
199
- * New features and bugs fixed.
200
-
201
- = 1.2.0 =
202
- * New features: Link to Query/Selector tab from specific Rule/Value selector, new rule focus on adding new rule. Bugs fixed: clear Query/Selector inputs when loaded selector is empty, use latest min.js script.
203
-
204
- = 1.1.9 =
205
- * Several bugs fixed/improvements made, see change log for details.
206
-
207
- = 1.1.5 =
208
- * Several bugs fixed/improvements made, see change log for details.
209
-
210
- = 1.1.4 =
211
- * Fixed sort bug in shorthand parser that was returning rules in wrong order
212
-
213
- = 1.1.1 =
214
- * This release fixes a major bug that caused input values containing '0' to be ignored
215
- * Several other bugs fixed/improvements made, see change log for details.
216
-
217
- = 1.0.0 =
218
- * Initial release.
219
 
220
  == Create Your Child Theme ==
221
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8QE5YJ8WE96AJ
4
  Tags: child theme, custom theme, CSS, responsive design, CSS editor, theme generator
5
  Requires at least: 3.7
6
+ Tested up to: 3.8.1
7
+ Stable tag: 1.3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  Created by Lilaea Media, the team that brought you IntelliWidget, the Child Theme Configurator provides a new approach to WordPress stylesheets. The Child Theme Configurator lets you identify and override only the Parent Theme style attributes you want to change. It gives you unlimited control over your WordPress look and feel while leaving your Parent Theme untouched.
16
 
17
+ = Now it works with plugins! =
18
+
19
+ We offer a premium extension to let you easily modify styles for any WordPress Plugin installed on your website. The Child Theme Configurator Plugin Extension scans your plugins and allows you to create custom stylesheets in your Child Theme. Learn more at http://www.lilaeamedia.com/plugins/child-theme-plugin-styles
20
+
21
+ The Child Theme Configurator parses and indexes a Theme's stylesheet so that every media query, selector, rule and value are at your fingertips. Second, it shows you how each change you make will look before you commit it to the Child Theme.Finally, it saves your work so that you can fine-tune your Child Theme without the risk of losing your edits.
22
+
23
  You can create any number of Child Themes from any existing Parent Theme. The Child Theme Configurator lets you choose from your installed themes (even existing Child Themes) and save the results in your Themes directory.
24
 
25
  When you are ready, just activate the Child Theme and your WordPress site takes on the new look and feel automatically.
37
  * Import web fonts and use them in place of Theme fonts
38
  * Save hours of development time
39
 
 
40
  == Installation ==
41
 
42
  1. Download the Child Theme Configurator plugin archive and unzip it.
45
 
46
  == Frequently Asked Questions ==
47
 
48
+ = Does it work with plugins? =
49
+
50
+ We offer a premium extension to let you easily modify styles for any WordPress Plugin installed on your website. The Child Theme Configurator Plugin Extension scans your plugins and allows you to create custom stylesheets in your Child Theme. Learn more at http://www.lilaeamedia.com/plugins/child-theme-plugin-styles
51
+
52
  = Is there a tutorial? =
53
 
54
  http://www.youtube.com/watch?v=xL2HkWQxgOA
57
 
58
  Some themes (particularly commercial themes) do not adhere to the Theme Development guidelines set forth by WordPress.org, and do not automatically load child theme stylesheets or php files. This is unfortunate, because it effectively prohibits the webmaster from adding any customizations (other than those made through the admin theme options) that will survive past an upgrade. Contact the vendor directly to ask for this core functionality. It is our opinion that ALL themes (especially commercial ones) must pass the Theme Unit Tests outlined by WordPress.org.
59
 
60
+ = Why are my menus displaying incorrectly when I activate the new child theme? =
61
+
62
+ The child theme creates a new instance in the WordPress options data and the menus have to be assigned. Go to Appearance > Menus and assign locations to each of the menus for the new Child Theme.
63
+
64
  = Where is it in the Admin? =
65
 
66
  The Child Theme Configurator can be found under the "Tools" menu in the WordPress Admin. Click "Child Themes" to get started.
137
 
138
  == Changelog ==
139
 
140
+ = 1.3.1 =
141
+ * Updated help tab content. Added additional sanitization of source and target file paths.
142
+
143
  = 1.3.0 =
144
  * Changed CSS preview to retrieve directly from WordPress Admin instead of remote http GET to prevent caching issues.
145
  * Added loading icon for CSS preview.
210
  * Initial release.
211
 
212
  == Upgrade Notice ==
213
+ = 1.3.1 =
214
+ * This update adds additional sanitization of source and target file paths.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
  == Create Your Child Theme ==
217