Child Theme Configurator - Version 1.4.1

Version Description

  • Tweaked the Files tab options and added check for DISALLOW_FILE_EDIT
  • Removed automatic @import rules for additional stylesheets that are loaded.
  • Fixed bug caused by new jQuery .css function handling of empty css values (preview swatch).
Download this release

Release Info

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

Code changes from version 1.0.0 to 1.4.1

child-theme-configurator.php CHANGED
@@ -5,22 +5,26 @@ if ( !defined('ABSPATH')) exit;
5
  /*
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
- Description: Create Child Theme from any Theme or Stylesheet
9
- Version: 1.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
- Copyright (C) 2013 Lilaea Media
16
  */
17
 
18
- defined('CHLD_THM_CFG_NS') or define('CHLD_THM_CFG_NS', 'chld_thm_cfg');
19
  defined('LF') or define('LF', "\n");
 
 
 
20
 
21
- require_once( 'includes/class-ctc.php' );
22
- global $chld_thm_cfg;
23
- $chld_thm_cfg = new Child_Theme_Configurator( __FILE__ );
 
 
24
 
25
  register_uninstall_hook( __FILE__ , 'child_theme_configurator_delete_plugin');
26
  function child_theme_configurator_delete_plugin() {
5
  /*
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.4.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
+ Copyright (C) 2014 Lilaea Media
16
  */
17
 
 
18
  defined('LF') or define('LF', "\n");
19
+ define('CHLD_THM_CFG_VERSION', '1.4.1');
20
+ define('CHLD_THM_CFG_MAX_SELECTORS', '5000');
21
+ define('CHLD_THM_CFG_MAX_RECURSE_LOOPS', '100');
22
 
23
+ if (is_admin()):
24
+ include_once( 'includes/class-ctc.php' );
25
+ global $chld_thm_cfg;
26
+ $chld_thm_cfg = new Child_Theme_Configurator( __FILE__ );
27
+ endif;
28
 
29
  register_uninstall_hook( __FILE__ , 'child_theme_configurator_delete_plugin');
30
  function child_theme_configurator_delete_plugin() {
css/chld-thm-cfg.css CHANGED
@@ -1,151 +1,192 @@
 
1
  .nav-tab, .nav-tab:focus, .nav-tab:active {
2
  outline: none;
3
  }
 
4
  .nav-tab-active {
5
- /*background-color:#f9f9f9;*/
6
  }
 
7
  .ctc-option-panel-container {
8
- position:relative;
9
- min-height:600px;
10
- max-height:800px;
11
- overflow:auto;
 
12
  }
13
- #preview_options_panel {
14
- white-space:pre;
15
- overflow:auto;
16
- font-family:monospace;
17
- word-wrap:normal;
 
18
  }
 
19
  .ctc-option-panel {
20
  visibility: hidden;
21
- position:absolute;
22
- width:96%;
23
- top:0;
24
- left:0;
25
- padding:10px 2%;
26
  }
 
27
  .ctc-option-panel-active {
28
  visibility: visible;
29
  }
 
30
  .ctc-swatch {
31
- display:block;
32
- float:left;
 
 
 
 
33
  }
 
34
  .ctc-hidden {
35
- display:none;
36
  }
 
37
  .ctc-swatch.ctc-specific {
38
- min-height:60px;
39
- max-height:100px;
40
- max-width:100px;
41
- margin:0 2% 0 0;
42
- padding:0;
43
- line-height:1;
44
- /*color:#7f7f7f;
45
  border: 1px solid #ddd;*/
46
- overflow: hidden;
47
  }
 
48
  .ctc-parent-row {
49
- clear:both;
50
- position:relative;
51
- margin:4px 0;
52
  }
 
53
  .ctc-parent-value {
54
  }
 
55
  .ctc-input-cell {
56
- display:block;
57
- float:left;
58
- width:25%;
59
- max-width:250px;
60
- margin-right:2.13%;
61
  }
 
62
  .ctc-input-cell-wide {
63
- display:block;
64
- float:left;
65
- width:70%;
66
- margin-right:2.13%;
67
  }
 
68
  .ctc-input-cell-wide textarea {
69
- width:100%;
70
- height:200px;
71
- white-space:pre;
72
- overflow:auto;
73
- font-family:monospace;
74
- word-wrap:normal;
75
  }
 
76
  .ctc-save-input {
77
  }
 
78
  .ctc-button-cell, .ctc-input-cell.ctc-button-cell {
79
- width:80px;
80
  }
 
81
  .ctc-textarea-button-cell {
82
- margin:15px 0;
83
- width:80px;
84
  }
 
85
  .ctc-selector-link {
86
  }
 
87
  .ctc-selector-handle {
88
  }
 
 
 
 
 
 
89
  .ctc-selector-container {
90
- clear:both;
91
- background:#f9f9f9;
92
- border:1px solid #ddd;
93
- padding:10px;
94
- min-height:300px;
95
- max-height:500px;
96
- position:absolute;
97
- width:90%;
98
  overflow: auto;
99
- left:0;
100
- top:30px;
101
- display:none;
102
- z-index:99999;
 
 
 
103
  }
 
104
  .ctc-query-heading {
105
  }
 
106
  .ctc-selector-row {
107
- clear:both;
108
  margin: 0;
109
- padding:8px 0;
110
  border-top: 1px solid #ddd;
111
  border-bottom: 1px solid #fff;
112
  }
 
113
  .ctc-input-row {
114
- clear:both;
115
- margin:4px 0;
116
- padding:4px 0;
117
  border-bottom: 1px solid #ddd;
118
  }
 
119
  .ctc-selector-value {
120
  }
 
121
  .ctc-selector-cell {
122
- float:left;
123
- width:30%;
124
- margin-right:2%;
125
  }
 
126
  .ctc-child-input-cell {
127
- display:block;
128
- float:left;
129
- margin-right:2.13%;
130
-
131
  }
 
132
  .ctc-child-input-cell-container {
133
- float:left;
134
- width:40%;
135
- margin-right:2%;
136
  }
 
137
  .ctc-child-input-cell-container label {
138
- float:left;
139
- clear:both;
140
- width:100px;
141
- margin-right:2%;
142
  }
 
143
  .ctc-child-input-cell input[type="text"] {
144
- width:60px;
 
 
 
145
  }
146
  .ctc-child-input-cell input[type="text"].ctc-input-wide {
147
- width:200px;
148
  }
 
149
  .clearfix:after, .clearfix:before {
150
  content: ' ';
151
  display: table;
@@ -160,4 +201,6 @@
160
  .ie7 .clearfix {
161
  zoom: 1;
162
  }
163
-
 
 
1
+
2
  .nav-tab, .nav-tab:focus, .nav-tab:active {
3
  outline: none;
4
  }
5
+
6
  .nav-tab-active {
7
+ /*background-color:#f9f9f9;*/
8
  }
9
+
10
  .ctc-option-panel-container {
11
+ position: relative;
12
+ min-height: 600px;
13
+ max-height: 800px;
14
+ overflow: auto;
15
+ border-bottom: 1px solid #f9f9f9;
16
  }
17
+
18
+ #view_child_options_panel, #view_parnt_options_panel {
19
+ white-space: pre;
20
+ overflow: auto;
21
+ font-family: monospace;
22
+ word-wrap: normal;
23
  }
24
+
25
  .ctc-option-panel {
26
  visibility: hidden;
27
+ position: absolute;
28
+ width: 96%;
29
+ top: 0;
30
+ left: 0;
31
+ padding: 10px 2%;
32
  }
33
+
34
  .ctc-option-panel-active {
35
  visibility: visible;
36
  }
37
+
38
  .ctc-swatch {
39
+ display: block;
40
+ float: left;
41
+ font-size: 16px;
42
+ padding: 0;
43
+ line-height: 1;
44
+ overflow: hidden;
45
  }
46
+
47
  .ctc-hidden {
48
+ display: none;
49
  }
50
+
51
  .ctc-swatch.ctc-specific {
52
+ min-height: 60px;
53
+ max-height: 100px;
54
+ max-width: 100px;
55
+ margin: 0 2% 0 0;/*color:#7f7f7f;
 
 
 
56
  border: 1px solid #ddd;*/
 
57
  }
58
+
59
  .ctc-parent-row {
60
+ clear: both;
61
+ position: relative;
62
+ margin: 4px 0;
63
  }
64
+
65
  .ctc-parent-value {
66
  }
67
+
68
  .ctc-input-cell {
69
+ display: block;
70
+ float: left;
71
+ width: 25%;
72
+ max-width: 250px;
73
+ margin-right: 2.13%;
74
  }
75
+
76
  .ctc-input-cell-wide {
77
+ display: block;
78
+ float: left;
79
+ width: 70%;
80
+ margin-right: 2.13%;
81
  }
82
+
83
  .ctc-input-cell-wide textarea {
84
+ width: 100%;
85
+ height: 200px;
86
+ white-space: pre;
87
+ overflow: auto;
88
+ font-family: monospace;
89
+ word-wrap: normal;
90
  }
91
+
92
  .ctc-save-input {
93
  }
94
+
95
  .ctc-button-cell, .ctc-input-cell.ctc-button-cell {
96
+ width: 85px;
97
  }
98
+
99
  .ctc-textarea-button-cell {
100
+ margin: 15px 0;
101
+ width: 85px;
102
  }
103
+
104
  .ctc-selector-link {
105
  }
106
+
107
  .ctc-selector-handle {
108
  }
109
+ .ctc-rewrite-toggle {
110
+ font-size:0.8em;
111
+ padding-left:1em;
112
+ display:none;
113
+ outline:none;
114
+ }
115
  .ctc-selector-container {
116
+ clear: both;
117
+ background: #f9f9f9;
118
+ border: 1px solid #ddd;
119
+ padding: 10px;
120
+ min-height: 300px;
121
+ max-height: 500px;
122
+ position: absolute;
123
+ width: 90%;
124
  overflow: auto;
125
+ left: 0;
126
+ top: 30px;
127
+ display: none;
128
+ z-index: 99999;
129
+ -moz-box-shadow: 1px 2px 10px rgba(51,51,51,0.4);
130
+ -webkit-box-shadow: 1px 2px 10px rgba(51,51,51,0.4);
131
+ box-shadow: 1px 2px 10px rgba(51,51,51,0.4);
132
  }
133
+
134
  .ctc-query-heading {
135
  }
136
+
137
  .ctc-selector-row {
138
+ clear: both;
139
  margin: 0;
140
+ padding: 8px 0;
141
  border-top: 1px solid #ddd;
142
  border-bottom: 1px solid #fff;
143
  }
144
+
145
  .ctc-input-row {
146
+ clear: both;
147
+ margin: 4px 0;
148
+ padding: 4px 0;
149
  border-bottom: 1px solid #ddd;
150
  }
151
+
152
  .ctc-selector-value {
153
  }
154
+
155
  .ctc-selector-cell {
156
+ float: left;
157
+ width: 30%;
158
+ margin-right: 2%;
159
  }
160
+
161
  .ctc-child-input-cell {
162
+ display: block;
163
+ float: left;
164
+ margin-right: 2.13%;
 
165
  }
166
+
167
  .ctc-child-input-cell-container {
168
+ float: left;
169
+ width: 40%;
170
+ margin-right: 2%;
171
  }
172
+
173
  .ctc-child-input-cell-container label {
174
+ float: left;
175
+ clear: both;
176
+ width: 100px;
177
+ margin-right: 2%;
178
  }
179
+
180
  .ctc-child-input-cell input[type="text"] {
181
+ /*width:60px;*/
182
+ }
183
+ .ctc-select {
184
+ max-width:100%;
185
  }
186
  .ctc-child-input-cell input[type="text"].ctc-input-wide {
187
+ width: 200px;
188
  }
189
+
190
  .clearfix:after, .clearfix:before {
191
  content: ' ';
192
  display: table;
201
  .ie7 .clearfix {
202
  zoom: 1;
203
  }
204
+ .smaller {
205
+ font-size: .85em;
206
+ }
includes/class-ctc-css.php CHANGED
@@ -6,260 +6,431 @@ 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.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
- Copyright (C) 2013 Lilaea Media
16
  */
17
  class Child_Theme_Configurator_CSS {
18
-
19
- var $sel_ndx;
20
- var $val_ndx;
21
- var $data;
22
- var $imports;
23
- var $keynum;
24
- var $updates;
25
- var $author;
26
- var $child_theme;
27
- var $parent_theme;
28
- var $child_theme_name;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  function __construct() {
31
- $this->keynum = 0;
32
- $this->child_theme = '';
33
- $this->parent_theme = '';
34
- $this->child_theme_name = '';
35
- $this->author = 'Child Theme Configurator by Lilaea Media';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  $this->sel_ndx = array();
37
  $this->val_ndx = array();
38
- $this->data = array();
39
- $this->imports = array();
40
  $this->updates = array();
41
  }
42
 
43
- function set_property($prop, $value) {
44
- if (is_scalar($this->{$prop}))
45
- $this->{$prop} = $value;
46
- else return false;
47
- }
48
-
49
- function get_property($objname, $selnum = null) {
50
  switch ($objname):
51
  case 'updates':
52
- return $this->obj_to_utf8($this->updates[$this->child_theme]);
53
  case 'imports':
54
- return $this->obj_to_utf8($this->imports);
55
  case 'sel_ndx':
56
- return $this->obj_to_utf8($this->sel_ndx);
57
- case 'val_ndx':
58
- return $this->obj_to_utf8($this->val_ndx);
59
- case 'child_theme':
60
- return $this->child_theme;
61
- case 'parent_theme':
62
- return $this->parent_theme;
63
- case 'child_theme_name':
64
- return $this->child_theme_name;
 
 
 
 
 
 
 
 
 
 
 
 
65
  case 'author':
66
- return $this->author;
67
- case 'data':
68
- return ($selnum ? $this->obj_to_utf8($this->data[$selnum]) : $this->obj_to_utf8($this->data));
 
 
 
69
  endswitch;
70
  return false;
71
  }
72
 
73
- function obj_to_utf8($data) {
74
- if (is_object($data)) {
75
- $data = get_object_vars($data);
76
- }
77
- if (is_array($data)) {
78
- return array_map(array(&$this, __FUNCTION__), $data);
79
- }
80
- else {
81
- return is_null( $data ) ? '' : utf8_encode($data);
82
- }
83
- }
84
-
85
- function normalize_background($value, &$rules, &$values){
86
- if (false !== strpos($value, 'gradient')):
87
- // only supporting linear syntax
88
- if (preg_match('#(linear\-|Microsoft\.)#', $value)):
89
- $values[] = $value;
90
- $rules[] = 'background-image';
91
- endif;
92
- else:
93
- $regex = '#^(\#\w{3,6})? *(url\([^\)]+\))?(.+)?$#';
94
- preg_match($regex, $value, $parts);
95
- if (empty($parts[1]) && empty($parts[2])):
96
- // this is a named color or single hex color
97
- $parts[1] = $parts[3];
98
- unset($parts[3]);
99
- endif;
100
- if (!empty($parts[1])):
101
- if ('none' != $parts[1]):
102
- $rules[] = 'background-color';
103
- else:
104
- $rules[] = 'background';
105
- endif;
106
- $values[] = $parts[1];
107
- endif;
108
- if (!empty($parts[2])):
109
- $rules[] = 'background-image';
110
- $values[] = $parts[2];
111
- endif;
112
- if (!empty($parts[3])):
113
- $position = array();
114
- foreach(preg_split('/ +/', trim($parts[3])) as $part):
115
- if (false === strpos($part, 'repeat')):
116
- $position[] = $part;
117
- else:
118
- $rules[] = 'background-repeat';
119
- $values[] = $part;
120
- endif;
121
- endforeach;
122
- if (count($position)):
123
- $rules[] = 'background-position';
124
- $values[] = implode(' ', $position);
125
- endif;
126
- endif;
127
- endif;
128
  }
129
 
130
- function normalize_font($value, &$rules, &$values) {
131
- $regex = '#^((\d+|bold|normal) )?((italic|normal) )?(([\d\.]+(px|r?em|%))[\/ ])?(([\d\.]+(px|r?em|%)?) )?(.+)$#is';
132
- preg_match($regex, $value, $parts);
133
- if (!empty($parts[2])):
134
- $rules[] = 'font-weight';
135
- $values[] = $parts[2];
136
- endif;
137
- if (!empty($parts[4])):
138
- $rules[] = 'font-style';
139
- $values[] = $parts[4];
140
- endif;
141
- if (!empty($parts[6])):
142
- $rules[] = 'font-size';
143
- $values[] = $parts[6];
144
- endif;
145
- if (!empty($parts[9])):
146
- $rules[] = 'line-height';
147
- $values[] = $parts[9];
148
- endif;
149
- if (!empty($parts[11])):
150
- $rules[] = 'font-family';
151
- $values[] = $parts[11];
152
  endif;
153
  }
154
-
155
- function normalize_margin_padding($rule, $value, &$rules, &$values) {
156
- $parts = preg_split("/ +/", trim($value));
157
- if (empty($parts[1])) $parts[1] = $parts[0];
158
- if (empty($parts[2])) $parts[2] = $parts[0];
159
- if (empty($parts[3])) $parts[3] = $parts[1];
160
- $rules[0] = $rule . '-top';
161
- $values[0] = $parts[0];
162
- $rules[1] = $rule . '-right';
163
- $values[1] = $parts[1];
164
- $rules[2] = $rule . '-bottom';
165
- $values[2] = $parts[2];
166
- $rules[3] = $rule . '-left';
167
- $values[3] = $parts[3];
168
  }
169
-
170
-
171
- function parse_css_file($obj) {
172
- if (empty($this->{$obj}) || !is_scalar($this->{$obj})) return false;
173
- $stylesheet = get_theme_root() . '/' . $this->{$obj} . '/style.css';
174
- // read parent stylesheet
175
- if (!is_file($stylesheet)) return false;
176
- $styles = file_get_contents($stylesheet);
177
- // get theme name
178
- $regex = '#Theme Name:\s*(.+?)\n#i';
179
- preg_match($regex, $styles, $matches);
180
- if (empty($matches[1])) return false;
181
- $this->set_property('child_theme_name', $matches[1]);
182
- $this->parse_css($this->{$obj}, $styles);
183
  }
184
- function reset_updates() {
185
- $this->updates = array();
186
  }
187
- function update_arrays($template, $query, $sel, $rule = null, $value = null, $important = null, $old_value = null) {
 
 
 
 
 
 
 
 
 
188
  // add selector and query to index
189
- if (!isset($this->sel_ndx[$query][$sel])):
 
 
190
  // increment key number
191
- $this->sel_ndx[$query][$sel] = ++$this->keynum;
192
- $this->data[$this->sel_ndx[$query][$sel]]['selector'] = $sel;
193
- $this->data[$this->sel_ndx[$query][$sel]]['query'] = $query;
194
- $this->updates[$template]['insert'][] = array(
195
- 'selector' => $sel,
196
- 'query' => $query,
197
- 'selnum' => $this->sel_ndx[$query][$sel],
 
 
 
 
 
 
 
198
  );
199
  endif;
200
- // det data and value
 
 
201
  if ($rule):
202
- $selnum = $this->sel_ndx[$query][$sel];
203
- if ('' == $value && isset($old_value) && '' != $old_value):
204
- $this->data[$selnum]['value'][$rule][$template] = '';
205
- unset($this->val_ndx[$template][$rule][$value][$query][$selnum]);
206
- if (isset($this->val_ndx[$template][$rule][$old_value][$query][$selnum])):
207
- unset($this->val_ndx[$template][$rule][$old_value][$query][$selnum]);
208
- $delete = array(
209
- 'rule' => $rule,
210
- 'value' => $old_value,
211
- 'query' => $query,
212
- 'selnum' => $selnum,
213
- );
214
- endif;
215
- if (isset($this->val_ndx[$template][$rule][$old_value][$query])
216
- && !count($this->val_ndx[$template][$rule][$old_value][$query])):
217
- unset($this->val_ndx[$template][$rule][$old_value][$query]);
218
- $delete = array(
219
- 'rule' => $rule,
220
- 'value' => $old_value,
221
- 'query' => $query,
222
- );
223
- endif;
224
- if (isset($this->val_ndx[$template][$rule][$old_value])
225
- && !count($this->val_ndx[$template][$rule][$old_value])):
226
- unset($this->val_ndx[$template][$rule][$old_value]);
227
- $delete = array(
228
- 'rule' => $rule,
229
- 'value' => $old_value,
230
- );
231
- endif;
232
- if (isset($this->val_ndx[$template][$rule])
233
- && !count($this->val_ndx[$template][$rule])):
234
- unset($this->val_ndx[$template][$rule]);
235
- $delete = array(
236
- 'rule' => $rule,
237
- );
238
- endif;
239
- $this->updates[$template]['del'][] = $delete;
240
- $this->updates[$template]['update'][] = array(
241
- 'rule' => $rule,
242
- 'value' => '',
243
- 'query' => $query,
244
- 'selnum' => $selnum,
245
- 'important' => '',
246
  );
247
- else:
248
- // add values to data array
249
- $this->data[$selnum]['value'][$rule][$template] = $value . ($important?' !important':'');
250
- // add rule and values to index
251
- $this->val_ndx[$template][$rule][$value][$query][$selnum] = 0;
252
- $this->updates[$template]['update'][] = array(
253
- 'rule' => $rule,
254
- 'value' => $value,
255
- 'query' => $query,
256
- 'selnum' => $selnum,
257
- 'important' => $important,
 
 
 
 
 
 
 
 
 
 
 
258
  );
259
  endif;
260
  endif;
261
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  function parse_css($template, $styles, $basequery = null, $parse_imports = true) {
264
  if (false === strpos($basequery, '@')):
265
  $basequery = 'base';
@@ -273,8 +444,12 @@ class Child_Theme_Configurator_CSS {
273
  if ($parse_imports):
274
  $regex = '#(\@import.+?);#';
275
  preg_match_all($regex, $styles, $matches);
276
- $this->imports[$template] = preg_grep('#style\.css#', $matches[1], PREG_GREP_INVERT);
277
- $this->updates[$template]['imports'] = $this->imports[$template];
 
 
 
 
278
  endif;
279
  // break into @ segments
280
  $regex = '#(\@media.+?)\{(.*?\})\s*\}#s';
@@ -284,7 +459,6 @@ class Child_Theme_Configurator_CSS {
284
  endforeach;
285
  // remove rulesets from styles
286
  $ruleset[$basequery] = preg_replace($regex, '', $styles);
287
- //echo 'template: ' . $template . ' styles: ' . $styles . ' basequery: ' . $basequery . LF;
288
  foreach ($ruleset as $query => $segment):
289
  // make sure there is semicolon before closing brace
290
  $segment = preg_replace('#(\})#', ";$1", $segment);
@@ -292,15 +466,14 @@ class Child_Theme_Configurator_CSS {
292
  preg_match_all($regex, $segment, $matches);
293
  foreach($matches[1] as $sel):
294
  $stuff = array_shift($matches[2]);
295
- // normalize selector styling
296
- $sel = implode(', ', preg_split('#\s*,\s*#s', trim($sel)));
297
  $this->update_arrays($template, $query, $sel);
298
- //echo 'query: ' . $query . ' sel: ' . $sel . ' selnum: ' . $selnum . LF;
299
  foreach (explode(';', $stuff) as $ruleval):
 
300
  if (false === strpos($ruleval, ':')) continue;
301
  list($rule, $value) = explode(':', $ruleval, 2);
302
  $rule = trim($rule);
303
- $value = trim($value);
 
304
 
305
  $rules = $values = array();
306
  // save important flag
@@ -332,49 +505,60 @@ class Child_Theme_Configurator_CSS {
332
  $value = $this->encode_gradient($value);
333
  endif;
334
  // normalize common vendor prefixes
335
- $rule = preg_replace('#(\-(o|ms|moz|webkit)\-)?(border\-radius|box\-shadow|transition)#', "$3", $rule);
336
  $this->update_arrays($template, $query, $sel, $rule, $value, $important);
337
  endforeach;
338
  endforeach;
339
  endforeach;
340
  endforeach;
341
  }
342
-
343
- function write_css() {
 
 
 
 
 
 
 
344
  // write new stylesheet
345
- $output = '/*' . LF;
346
- $output .= 'Theme Name: ' . $this->child_theme_name . LF;
347
- $output .= 'Template: ' . $this->parent_theme . LF;
348
- $output .= 'Author: ' . $this->author . LF;
349
- $output .= 'Version: 1.0' . LF;
350
- $output .= '*/' . LF . LF;
351
- $output .= '@charset "UTF-8";' . LF;
352
- $output .= '@import url(\'../' . $this->parent_theme . '/style.css\');' . LF;
353
- if (!empty($this->imports[$this->child_theme])):
354
- foreach ($this->imports[$this->child_theme] as $import):
355
  $output .= $import . ';' . LF;
356
  endforeach;
357
  endif;
358
  $output .= LF;
 
 
 
 
359
  foreach ($this->sort_queries() as $query => $sort_order):
360
- $selector = $this->sel_ndx[$query];
361
- asort($selector);
362
  $has_selector = 0;
363
  $sel_output = '';
 
 
364
  if ('base' != $query) $sel_output .= $query . ' {' . LF;
365
- foreach ($selector as $sel => $selnum):
366
  $has_value = 0;
367
- if (!empty($this->data[$selnum]['value'])):
368
- foreach ($this->data[$selnum]['value'] as $rule => $value):
369
- if (isset($value[$this->child_theme]) && '' != $value[$this->child_theme]):
 
 
370
  if (! $has_value):
 
371
  $sel_output .= $sel . ' {' . LF;
372
  $has_value = 1;
373
  $has_selector = 1;
374
  endif;
375
- $sel_output .= $this->add_vendor_rules($rule, $value[$this->child_theme]);
 
 
376
  endif;
377
  endforeach;
 
378
  if ($has_value):
379
  $sel_output .= '}' . LF;
380
  endif;
@@ -383,34 +567,46 @@ class Child_Theme_Configurator_CSS {
383
  if ('base' != $query) $sel_output .= '}' . LF;
384
  if ($has_selector) $output .= $sel_output;
385
  endforeach;
386
- $themedir = get_theme_root() . '/' . $this->child_theme;
387
-
388
- $stylesheet = $themedir . '/style.css';
389
- if (!is_dir($themedir)):
390
- mkdir($themedir, 0755);
391
- endif;
392
- // backup current stylesheet if no backup exists
393
- if (is_file($stylesheet) && !is_file($stylesheet . '.bak')):
394
- file_put_contents($stylesheet . '.bak', file_get_contents($stylesheet));
395
- endif;
396
- // write new stylesheet
397
- file_put_contents($stylesheet, $output);
 
398
  }
399
 
400
- function add_vendor_rules($rule, $value) {
 
 
 
 
 
 
401
  $rules = '';
402
- if (preg_match("/^(border\-radius|box\-shadow|transition)$/", $rule)):
 
 
 
 
 
403
  foreach(array('moz', 'webkit', 'o') as $prefix):
404
- $rules .= ' -' . $prefix . '-' . $rule . ': ' . $value . ';' . LF;
405
  endforeach;
406
- $rules .= ' ' . $rule . ': ' . $value . ';' . LF;
407
  elseif ('background-image' == $rule):
408
  // gradient?
409
  if ($gradient = $this->decode_gradient($value)):
410
  // standard gradient
411
  foreach(array('moz', 'webkit', 'o', 'ms') as $prefix):
412
  $rules .= ' background-image: -' . $prefix . '-' . 'linear-gradient(' . $gradient['origin'] . ', '
413
- . $gradient['color1'] . ', ' . $gradient['color2'] . ');' . LF;
414
  endforeach;
415
  // W3C standard gradient
416
  // rotate origin 90 degrees
@@ -424,7 +620,7 @@ class Child_Theme_Configurator_CSS {
424
  $org = 'to ' . implode(' ', $dirs);
425
  endif;
426
  $rules .= ' background-image: linear-gradient(' . $org . ', '
427
- . $gradient['color1'] . ', ' . $gradient['color2'] . ');' . LF;
428
 
429
  // legacy webkit gradient - we'll add if there is demand
430
  // '-webkit-gradient(linear,' .$origin . ', ' . $color1 . ', '. $color2 . ')';
@@ -433,18 +629,173 @@ class Child_Theme_Configurator_CSS {
433
  $type = (in_array($gradient['origin'], array('left', 'right', '0deg', '180deg')) ? 1 : 0);
434
  $color1 = preg_replace("/^#/", '#00', $gradient['color1']);
435
  $rules .= ' filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=' . $type . ', StartColorStr="'
436
- . strtoupper($color1) . '", EndColorStr="' . strtoupper($gradient['color2']) . '");' . LF;
437
  else:
438
  // url or other value
439
- $rules .= ' ' . $rule . ': ' . $value . ';' . LF;
440
  endif;
441
  else:
442
- $rules .= ' ' . $rule . ': ' . $value . ';' . LF;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  return $rules;
445
  }
 
 
 
 
 
 
 
446
  function encode_gradient($value) {
447
- $regex = '#gradient[^\)]*?\((((top|bottom|left|right)?( (top|bottom|left|right))?|\d+deg),)?([^\)]*[\'"]?(\#\w{3,8}|rgba?\([\d, ]+?\))( \d+%)?)([^\)]*[\'"]?(\#\w{3,8}|rgba?\([\d, ]+?\))( \d+%)?)([^\)]*gradienttype=[\'"]?(\d)[\'"]?)?[^\)]*\)#i';
448
  $param = $parts = array();
449
  preg_match($regex, $value, $parts);
450
  if (empty($parts[13])):
@@ -472,12 +823,19 @@ class Child_Theme_Configurator_CSS {
472
  $param[2] = '0%';
473
  $param[4] = '100%';
474
  endif;
475
- $param[1] = $parts[7];
476
- $param[3] = $parts[10];
477
- ksort($param);
478
- return implode(':', $param);
 
 
 
479
  }
480
 
 
 
 
 
481
  function decode_border($value) {
482
  if (preg_match('#^(0|none)#i', $value)):
483
  $parts[0] = $value;
@@ -491,101 +849,145 @@ class Child_Theme_Configurator_CSS {
491
  'color' => empty($parts[2])?'':$parts[2],
492
  );
493
  }
494
-
 
 
 
 
495
  function decode_gradient($value) {
496
  $parts = explode(':', $value, 5);
497
- if (count($parts) == 5):
498
  return array(
499
- 'origin' => empty($parts[0])?'':$parts[0],
500
- 'color1' => empty($parts[1])?'':$parts[1],
501
- 'stop1' => empty($parts[2])?'':$parts[2],
502
- 'color2' => empty($parts[3])?'':$parts[3],
503
- 'stop2' => empty($parts[4])?'':$parts[4],
504
  );
505
- else:
506
- return false;
507
  endif;
 
508
  }
509
-
510
- function parse_post_data() {
511
- if (isset($_POST['ctc_new_selectors'])):
512
- $this->parse_css($this->child_theme, LF . $_POST['ctc_new_selectors'], (isset($_POST['ctc_sel_ovrd_query'])?trim($_POST['ctc_sel_ovrd_query']):null), false);
513
- elseif (isset($_POST['ctc_child_imports'])):
514
- $this->parse_css($this->child_theme, $_POST['ctc_child_imports']);
515
- else:
516
- $parts = array();
517
- foreach (preg_grep('#^ctc_(ovrd_)?child#', array_keys($_POST)) as $post_key):
518
- if (preg_match('#^ctc_(ovrd_)?child_([\w\-]+?)_(\d+?)(_(.+))?$#', $post_key, $matches)):
519
- $rule = $matches[2];
520
- $selnum = $matches[3];
521
- $value = sanitize_text_field($_POST[$post_key]);
522
- if (isset($this->data[$selnum]['value'][$rule]) && isset($this->data[$selnum]['value'][$rule][$this->child_theme])):
523
- $child_value = $this->data[$selnum]['value'][$rule][$this->child_theme];
524
- else:
525
- $child_value = $this->data[$selnum]['value'][$rule][$this->child_theme] = '';
526
- endif;
527
- if (isset($this->data[$selnum]['value'][$rule][$this->parent_theme])):
528
- $parent_value = $this->data[$selnum]['value'][$rule][$this->parent_theme];
529
- else:
530
- $parent_value = $this->data[$selnum]['value'][$rule][$this->parent_theme] = '';
531
- endif;
532
- $important = $this->is_important($parent_value) ? ' !important' : '';
533
- $query = $this->data[$selnum]['query'];
534
- if (!empty($matches[5])):
535
- $parts[$selnum][$rule][$matches[5]] = $value;
536
- $parts[$selnum][$rule]['important'] = $important;
537
- $parts[$selnum][$rule]['query'] = $query;
538
- else:
539
- $this->update_arrays($this->child_theme, $query, $this->data[$selnum]['selector'],
540
- $rule, $value, $important, $child_value);
541
- endif;
542
- endif;
543
  endforeach;
544
- foreach ($parts as $selnum => $rule_arr):
545
- foreach ($rule_arr as $rule => $rule_part):
546
- if ('background' == $rule):
547
- $value = $rule_part['background_url'];
548
- elseif ('background-image' == $rule):
549
- if (empty($rule_part['background_url'])):
550
- if (empty($rule_part['background_color2'])):
551
- $value = '';
552
- else:
553
- $value = implode(':', array(
554
- $rule_part['background_origin'],
555
- $rule_part['background_color1'], '0%',
556
- $rule_part['background_color2'], '100%'
557
- ));
558
- endif;
559
- else:
560
- $value = $rule_part['background_url'];
561
- endif;
562
- elseif (preg_match('#^border(\-(top|right|bottom|left))?$#', $rule)):
563
- $value = implode(' ', array(
564
- $rule_part['border_width'],
565
- $rule_part['border_style'],
566
- $rule_part['border_color']
567
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568
  else:
569
- $value = '';
570
  endif;
571
- $this->update_arrays($this->child_theme, $rule_part['query'], $this->data[$selnum]['selector'],
572
- $rule, $value, $rule_part['important'], $child_value);
573
  endforeach;
574
- endforeach;
 
575
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  }
 
577
  /*
 
578
  * Strip important flag from value ref and return boolean
 
579
  */
580
  function is_important(&$value) {
581
  $important = 0;
582
- $value = str_replace('!important', '', $value, $important);
583
  return $important;
584
  }
585
 
 
 
 
 
 
 
 
 
586
  function sort_queries() {
587
  $queries = array();
588
- foreach (array_keys($this->sel_ndx) as $query):
 
 
589
  if ('base' == $query):
590
  $queries['base'] = -999999;
591
  continue;
@@ -593,11 +995,62 @@ class Child_Theme_Configurator_CSS {
593
  if (preg_match("/((min|max)(\-device)?\-width)\s*:\s*(\d+)/", $query, $matches)):
594
  $queries[$query] = 'min-width' == $matches[1] ? $matches[4] : -$matches[4];
595
  else:
596
- $queries[$query] = 0;
597
  endif;
598
  endforeach;
599
  asort($queries);
600
  return $queries;
601
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  }
603
  ?>
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.4.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
+ Copyright (C) 2014 Lilaea Media
16
  */
17
  class Child_Theme_Configurator_CSS {
18
+ var $version;
19
+ // data dictionaries
20
+ var $dict_query; // @media queries and 'base'
21
+ var $dict_sel; // selectors
22
+ var $dict_qs; // query/selector lookup
23
+ var $dict_rule; // css rules
24
+ var $dict_val; // css values
25
+ var $dict_seq; // child load order (priority)
26
+ // hierarchies
27
+ var $sel_ndx; // query => selector hierarchy
28
+ var $val_ndx; // selector => rule => value hierarchy
29
+ // key counters
30
+ var $qskey; // counter for dict_qs
31
+ var $querykey; // counter for dict_query
32
+ var $selkey; // counter for dict_sel
33
+ var $rulekey; // counter for dict_rule
34
+ var $valkey; // counter for dict_val
35
+ // miscellaneous properties
36
+ var $imports; // @import rules
37
+ var $updates; // temporary update cache
38
+ var $child; // child theme slug
39
+ var $parnt; // parent theme slug
40
+ var $configtype; // theme or plugin extension
41
+ var $child_name; // child theme name
42
+ var $child_author; // stylesheet author
43
+ var $child_version; // stylesheet version
44
 
45
  function __construct() {
46
+ // scalars
47
+ $this->version = '1.4.1';
48
+ $this->querykey = 0;
49
+ $this->selkey = 0;
50
+ $this->qskey = 0;
51
+ $this->rulekey = 0;
52
+ $this->valkey = 0;
53
+ $this->child = '';
54
+ $this->parnt = '';
55
+ $this->configtype = 'theme';
56
+ $this->child_name = '';
57
+ $this->child_author = 'Child Theme Configurator by Lilaea Media';
58
+ $this->child_version = '1.0';
59
+ // multi-dim arrays
60
+ $this->dict_qs = array();
61
+ $this->dict_sel = array();
62
+ $this->dict_query = array();
63
+ $this->dict_rule = array();
64
+ $this->dict_val = array();
65
+ $this->dict_seq = array();
66
  $this->sel_ndx = array();
67
  $this->val_ndx = array();
68
+ $this->imports = array('child' => array(), 'parnt' => array());
 
69
  $this->updates = array();
70
  }
71
 
72
+ /*
73
+ * get_prop
74
+ * Getter interface (data sliced different ways depending on objname)
75
+ */
76
+ function get_prop($objname, $params = null) {
 
 
77
  switch ($objname):
78
  case 'updates':
79
+ return $this->obj_to_utf8($this->updates);
80
  case 'imports':
81
+ return $this->obj_to_utf8(is_array($this->imports['child']) ? (current($this->imports['child']) == 1 ? array_keys($this->imports['child']) : array_keys(array_flip($this->imports['child']))) : array());
82
  case 'sel_ndx':
83
+ return $this->obj_to_utf8($this->denorm_sel_ndx(empty($params['key'])?null:$params['key']));
84
+ case 'rule_val':
85
+ return empty($params['key']) ? array() : $this->denorm_rule_val($params['key']);
86
+ case 'val_qry':
87
+ if (isset($params['rule']) && isset($this->dict_rule[$params['rule']])):
88
+ return empty($params['key']) ?
89
+ array() : $this->denorm_val_query($params['key'], $params['rule']);
90
+ endif;
91
+ case 'sel_val':
92
+ return empty($params['key']) ?
93
+ array() : $this->denorm_sel_val($params['key']);
94
+ case 'rule':
95
+ return $this->obj_to_utf8(array_flip($this->dict_rule));
96
+ case 'child':
97
+ return $this->child;
98
+ case 'parnt':
99
+ return $this->parnt;
100
+ case 'configtype':
101
+ return $this->configtype;
102
+ case 'child_name':
103
+ return $this->child_name;
104
  case 'author':
105
+ return $this->child_author;
106
+ case 'version':
107
+ return $this->child_version;
108
+ case 'preview':
109
+ $template = (empty($params['key']) || 'child' == $params['key']) ? 'child' : 'parnt';
110
+ return $this->get_raw_css($template);
111
  endswitch;
112
  return false;
113
  }
114
 
115
+ /*
116
+ * set_prop
117
+ * Setter interface (scalar values only)
118
+ */
119
+ function set_prop($prop, $value) {
120
+ if (is_scalar($this->{$prop}))
121
+ $this->{$prop} = $value;
122
+ else return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
+ function get_raw_css($template = 'child') {
126
+ if ($styles = $this->read_stylesheet($template)):
127
+ if (preg_match("/\}[\w\#\.]/", $styles)): // prettify compressed CSS
128
+ $styles = preg_replace("/\*\/\s*/s", "*/\n", $styles); // end comment
129
+ $styles = preg_replace("/\{\s*/s", " {\n ", $styles); // open brace
130
+ $styles = preg_replace("/;\s*/s", ";\n ", $styles); // semicolon
131
+ $styles = preg_replace("/\s*\}\s*/s", "\n}\n", $styles); // close brace
132
+ endif;
133
+ return $styles;
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  endif;
135
  }
136
+
137
+ function get_css_header() {
138
+ $parnt = $this->get_prop('parnt');
139
+ return '/*' . LF
140
+ . 'Theme Name: ' . $this->get_prop('child_name') . LF
141
+ . 'Template: ' . $parnt . LF
142
+ . 'Author: ' . $this->get_prop('author'). LF
143
+ . 'Version: ' . $this->get_prop('version') . LF
144
+ . 'Updated: ' . current_time('mysql') . LF
145
+ . '*/' . LF . LF
146
+ . '@charset "UTF-8";' . LF
147
+ . '@import url(\'../' . $parnt . '/style.css\');' . LF;
 
 
148
  }
149
+
150
+ function get_child_target($file = 'style.css') {
151
+ return get_theme_root() . '/' . $this->get_prop('child') . '/' . $file;
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
+ function get_parent_source($file = 'style.css') {
154
+ return get_theme_root() . '/' . $this->get_prop('parnt') . '/' . $file;
155
  }
156
+
157
+ /*
158
+ * update_arrays
159
+ * accepts CSS properties as raw strings and normilizes into
160
+ * CTC object arrays, creating update cache in the process.
161
+ * Update cache is returned to UI via AJAX to refresh page
162
+ */
163
+ function update_arrays($template, $query, $sel, $rule = null, $value = null, $important = 0, $seq = null) {
164
+ // normalize selector styling
165
+ $sel = implode(', ', preg_split('#\s*,\s*#s', trim($sel)));
166
  // add selector and query to index
167
+ if (!isset($this->dict_query[$query])) $this->dict_query[$query] = ++$this->querykey;
168
+ if (!isset($this->dict_sel[$sel])) $this->dict_sel[$sel] = ++$this->selkey;
169
+ if (!isset($this->sel_ndx[$this->dict_query[$query]][$this->dict_sel[$sel]])):
170
  // increment key number
171
+ $this->sel_ndx[$this->dict_query[$query]][$this->dict_sel[$sel]] = ++$this->qskey;
172
+
173
+ $this->dict_qs[$this->qskey]['s'] = $this->dict_sel[$sel];
174
+ $this->dict_qs[$this->qskey]['q'] = $this->dict_query[$query];
175
+ // tell the UI to update a single cached query/selector lookup by passing 'qsid' as the key
176
+ // (normally the entire array is replaced):
177
+ $this->updates[] = array(
178
+ 'obj' => 'sel_ndx',
179
+ 'key' => 'qsid',
180
+ 'data' => array(
181
+ 'query' => $query,
182
+ 'selector' => $sel,
183
+ 'qsid' => $this->qskey,
184
+ ),
185
  );
186
  endif;
187
+ if (!isset($this->dict_seq[$this->qskey]))
188
+ $this->dict_seq[$this->qskey] = $this->qskey;
189
+ // set data and value
190
  if ($rule):
191
+ if (!isset($this->dict_rule[$rule])):
192
+ $this->dict_rule[$rule] = ++$this->rulekey;
193
+ // tell the UI to update a single cached rule:
194
+ $this->updates[] = array(
195
+ 'obj' => 'rule',
196
+ 'key' => $this->rulekey,
197
+ 'data' => $rule,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  );
199
+ endif;
200
+ $qsid = $this->sel_ndx[$this->dict_query[$query]][$this->dict_sel[$sel]];
201
+ $ruleid = $this->dict_rule[$rule];
202
+ if (!isset($this->dict_val[$value])):
203
+ $this->dict_val[$value] = ++$this->valkey;
204
+ endif;
205
+ $this->val_ndx[$qsid][$ruleid][$template] = $this->dict_val[$value];
206
+ // set the important flag for this value
207
+ $this->val_ndx[$qsid][$ruleid]['i_' . $template] = $important;
208
+ // tell the UI to add a single cached query/selector data array:
209
+ $updatearr = array(
210
+ 'obj' => 'sel_val',
211
+ 'key' => $qsid,
212
+ 'data' => $this->denorm_sel_val($qsid),
213
+ );
214
+ $this->updates[] = $updatearr;
215
+ if (isset($seq)): // this is a renamed selector
216
+ $this->dict_seq[$qsid] = $seq;
217
+ $this->updates[] = array(
218
+ 'obj' => 'rewrite',
219
+ 'key' => $qsid,
220
+ 'data' => $sel,
221
  );
222
  endif;
223
  endif;
224
  }
225
+
226
+ /*
227
+ * reset_updates
228
+ * clears temporary update cache
229
+ */
230
+ function reset_updates() {
231
+ $this->updates = array();
232
+ }
233
+
234
+ function read_stylesheet($template = 'child') {
235
+ $source = $this->get_prop($template);
236
+ $configtype = $this->get_prop('configtype');
237
+ if (empty($source) || !is_scalar($source)) return false;
238
+ $stylesheets = array();
239
+ $themedir = get_theme_root() . '/' . $source;
240
+ if ('parnt' == $template && (empty($configtype) || 'theme' == $configtype) && isset($_POST['ctc_scan_subdirs'])):
241
+ $stylesheets = $this->recurse_directory($themedir);
242
+ else:
243
+ $stylesheets[] = apply_filters('chld_thm_cfg_' . $template, $themedir . '/style.css', $this);
244
+ endif;
245
+
246
+ // read stylesheets
247
+ $styles = '';
248
+ foreach ($stylesheets as $stylesheet):
249
+ if ($stylesheet_verified = $this->is_file_ok($stylesheet, 'read')):
250
+ $import_url = preg_replace('%^' . preg_quote($themedir) . '/%', '', $stylesheet_verified);
251
+ $styles .= @file_get_contents($stylesheet_verified) . "\n";
252
+ /*if ($styles && isset($_POST['ctc_scan_subdirs'])
253
+ && 'parnt' == $template
254
+ && (empty($configtype) || 'theme' == $configtype)
255
+ && 'style.css' != $import_url):
256
+ $this->imports['child']["@import url('../" . $source . '/' . $import_url . "')"] = 1;
257
+ // convert relative urls to absolute
258
+ $this->convert_parent_rel_url_to_abs_url($import_url, $styles);
259
+ endif;*/
260
+ endif;
261
+ endforeach;
262
+ return $styles;
263
+ }
264
+
265
+ function recurse_directory($rootdir, $ext = 'css') {
266
+ if (!$this->is_file_ok($rootdir, 'search')) return array(); // make sure we are only recursing theme and plugin files
267
+ $files = array();
268
+ $dirs = array($rootdir);
269
+ $loops = 0;
270
+ if ('img' == $ext):
271
+ global $chld_thm_cfg;
272
+ $ext = '(' . implode('|', $chld_thm_cfg->image_formats) . ')';
273
+ endif;
274
+ while(count($dirs) && $loops < CHLD_THM_CFG_MAX_RECURSE_LOOPS):
275
+ $loops++;
276
+ $dir = array_shift($dirs);
277
+ if ($handle = opendir($dir)):
278
+ while (false !== ($file = readdir($handle))):
279
+ if (preg_match("/^\./", $file)) continue;
280
+ $filepath = $dir . '/' . $file;
281
+ if (is_dir($filepath)):
282
+ array_unshift($dirs, $filepath);
283
+ elseif (is_file($filepath) && preg_match("/\.".$ext."$/", $filepath)):
284
+ $files[] = $filepath;
285
+ endif;
286
+ endwhile;
287
+ closedir($handle);
288
+ endif;
289
+ endwhile;
290
+ return $files;
291
+ }
292
+
293
+ function convert_parent_rel_url_to_abs_url($url, &$styles) {
294
+ $source = $this->get_prop('parnt');
295
+ $spliton = '%[/\\\\]%';
296
+ $dirname = dirname($url);
297
+ $dirs = preg_split($spliton, $dirname);
298
+ $dds = '';
299
+ $themeuri = get_theme_root_uri();
300
+ while (count($dirs)):
301
+ $thisdir = array_pop($dirs);
302
+ $upone = implode('/', $dirs);
303
+ $dds .= '\.\.\/';
304
+ $regex = '%url\([\'" ]*' . $dds . '(.+?)[\'" ]*\)%';
305
+ $fullurl = $themeuri . '/' . $source . '/' . $upone . ('' == $upone ? '' : '/' );
306
+ $styles = preg_replace($regex, "url(" . $fullurl . "$1)", $styles);
307
+ endwhile;
308
+ }
309
+ /*
310
+ * parse_post_data
311
+ * Parse user form input into separate properties and pass to update_arrays
312
+ */
313
+ function parse_post_data() {
314
+ if (isset($_POST['ctc_new_selectors'])):
315
+
316
+ $this->parse_css('child', LF . $this->parse_css_input($_POST['ctc_new_selectors']),
317
+ (isset($_POST['ctc_sel_ovrd_query'])?trim($_POST['ctc_sel_ovrd_query']):null), false);
318
+ elseif (isset($_POST['ctc_child_imports'])):
319
+ $this->imports['child'] = array();
320
+ $this->parse_css('child', $this->parse_css_input($_POST['ctc_child_imports']));
321
+ else:
322
+ $newselector = isset($_POST['ctc_rewrite_selector']) ? sanitize_text_field($this->parse_css_input(($_POST['ctc_rewrite_selector']))) : NULL;
323
+ // set the custom sequence value
324
+ foreach (preg_grep('#^ctc_ovrd_child_seq_#', array_keys($_POST)) as $post_key):
325
+ if (preg_match('#^ctc_ovrd_child_seq_(\d+)$#', $post_key, $matches)):
326
+ $qsid = $matches[1];
327
+ $this->dict_seq[$qsid] = intval($_POST[$post_key]);
328
+ endif;
329
+ endforeach;
330
+ $parts = array();
331
+ foreach (preg_grep('#^ctc_(ovrd|\d+)_child#', array_keys($_POST)) as $post_key):
332
+ if (preg_match('#^ctc_(ovrd|\d+)_child_([\w\-]+?)_(\d+?)(_(.+))?$#', $post_key, $matches)):
333
+ $valid = $matches[1];
334
+ $rule = $matches[2];
335
+ if (null == $rule || !isset($this->dict_rule[$rule])) continue;
336
+ $ruleid = $this->dict_rule[$rule];
337
+ $qsid = $matches[3];
338
+ $value = sanitize_text_field($this->parse_css_input(($_POST[$post_key])));
339
+ $important = $this->is_important($value);
340
+ if (!empty($_POST['ctc_' . $valid . '_child_' . $rule . '_i_' . $qsid])) $important = 1;
341
+
342
+ $selarr = $this->denorm_query_sel($qsid);
343
+ if (!empty($matches[5])):
344
+ $parts[$qsid][$rule][$matches[5]] = $value;
345
+ $parts[$qsid][$rule]['important'] = $important;
346
+ $parts[$qsid][$rule]['query'] = $selarr['query'];
347
+ $parts[$qsid][$rule]['selector'] = $selarr['selector'];
348
+ else:
349
+ if ($newselector && $newselector != $selarr['selector']):
350
+ // If this is a renamed selector, add new selector to array
351
+ // and clear original child selector values.
352
+ // Passing the sequence in the last argument serves two purposes:
353
+ // 1. sets sequence for new renamed selector.
354
+ // 2. tells the update_arrays function to flag this as a
355
+ // renamed selector to pass back in result array.
356
+ $this->update_arrays('child', $selarr['query'], $newselector,
357
+ $rule, trim($value), $important, $this->dict_seq[$qsid]);
358
+ $this->update_arrays('child', $selarr['query'], $selarr['selector'], $rule, '');
359
+ else:
360
+ // Otherwise, just update with the new values:
361
+ $this->update_arrays('child', $selarr['query'], $selarr['selector'],
362
+ $rule, trim($value), $important);
363
+ endif;
364
+ endif;
365
+ endif;
366
+ endforeach;
367
+ foreach ($parts as $qsid => $rule_arr):
368
+ foreach ($rule_arr as $rule => $rule_part):
369
+ if ('background' == $rule):
370
+ $value = $rule_part['background_url'];
371
+ elseif ('background-image' == $rule):
372
+ if (empty($rule_part['background_url'])):
373
+ if (empty($rule_part['background_color2'])):
374
+ $value = '';
375
+ else:
376
+ $value = implode(':', array(
377
+ $rule_part['background_origin'],
378
+ $rule_part['background_color1'], '0%',
379
+ $rule_part['background_color2'], '100%'
380
+ ));
381
+ endif;
382
+ else:
383
+ $value = $rule_part['background_url'];
384
+ endif;
385
+ elseif (preg_match('#^border(\-(top|right|bottom|left))?$#', $rule)):
386
+ $value = implode(' ', array(
387
+ $rule_part['border_width'],
388
+ $rule_part['border_style'],
389
+ $rule_part['border_color']
390
+ ));
391
+ else:
392
+ $value = '';
393
+ endif;
394
+ if ($newselector && $newselector != $rule_part['selector']):
395
+ $this->update_arrays('child', $rule_part['query'], $newselector,
396
+ $rule, trim($value), $rule_part['important'], $this->dict_seq[$qsid]);
397
+ $this->update_arrays('child', $rule_part['query'], $rule_part['selector'], $rule, '');
398
+ else:
399
+ $this->update_arrays('child', $rule_part['query'], $rule_part['selector'],
400
+ $rule, trim($value), $rule_part['important']);
401
+ endif;
402
+ endforeach;
403
+ endforeach;
404
+ endif;
405
+ }
406
 
407
+ /*
408
+ * parse_css_input
409
+ * Normalize raw user CSS input so that the parser can read it.
410
+ * TODO: this is a stub for future use
411
+ */
412
+ function parse_css_input($styles) {
413
+ return stripslashes($styles);
414
+ }
415
+
416
+ /*
417
+ * parse_css_file
418
+ * reads stylesheet to get WordPress meta data and passes rest to parse_css
419
+ */
420
+ function parse_css_file($template) {
421
+ $styles = $this->read_stylesheet($template);
422
+ // get theme name
423
+ $regex = '#Theme Name:\s*(.+?)\n#i';
424
+ preg_match($regex, $styles, $matches);
425
+ $child_name = $this->get_prop('child_name');
426
+ if (!empty($matches[1]) && 'child' == $template && empty($child_name)) $this->set_prop('child_name', $matches[1]);
427
+ $this->parse_css($template, $styles);
428
+ }
429
+
430
+ /*
431
+ * parse_css
432
+ * accepts raw CSS as text and parses into separate properties
433
+ */
434
  function parse_css($template, $styles, $basequery = null, $parse_imports = true) {
435
  if (false === strpos($basequery, '@')):
436
  $basequery = 'base';
444
  if ($parse_imports):
445
  $regex = '#(\@import.+?);#';
446
  preg_match_all($regex, $styles, $matches);
447
+ foreach (preg_grep('#style\.css#', $matches[1], PREG_GREP_INVERT) as $import)
448
+ $this->imports[$template][$import] = 1;
449
+ $this->updates[] = array(
450
+ 'obj' => 'imports',
451
+ 'data' => array_keys($this->imports[$template]),
452
+ );
453
  endif;
454
  // break into @ segments
455
  $regex = '#(\@media.+?)\{(.*?\})\s*\}#s';
459
  endforeach;
460
  // remove rulesets from styles
461
  $ruleset[$basequery] = preg_replace($regex, '', $styles);
 
462
  foreach ($ruleset as $query => $segment):
463
  // make sure there is semicolon before closing brace
464
  $segment = preg_replace('#(\})#', ";$1", $segment);
466
  preg_match_all($regex, $segment, $matches);
467
  foreach($matches[1] as $sel):
468
  $stuff = array_shift($matches[2]);
 
 
469
  $this->update_arrays($template, $query, $sel);
 
470
  foreach (explode(';', $stuff) as $ruleval):
471
+ if ($this->qskey > CHLD_THM_CFG_MAX_SELECTORS) break;
472
  if (false === strpos($ruleval, ':')) continue;
473
  list($rule, $value) = explode(':', $ruleval, 2);
474
  $rule = trim($rule);
475
+ $rule = preg_replace_callback("/[^\w\-]/", array($this, 'to_ascii'), $rule);
476
+ $value = stripslashes(trim($value));
477
 
478
  $rules = $values = array();
479
  // save important flag
505
  $value = $this->encode_gradient($value);
506
  endif;
507
  // normalize common vendor prefixes
508
+ $rule = preg_replace('#(\-(o|ms|moz|webkit)\-)?(box\-sizing|font\-smoothing|border\-radius|box\-shadow|transition)#', "$3", $rule);
509
  $this->update_arrays($template, $query, $sel, $rule, $value, $important);
510
  endforeach;
511
  endforeach;
512
  endforeach;
513
  endforeach;
514
  }
515
+
516
+ /*
517
+ * write_css
518
+ * converts normalized CSS object data into stylesheet.
519
+ * Preserves selector sequence and !important flags of parent stylesheet.
520
+ * @media query blocks are sorted using internal heuristics (see sort_queries)
521
+ * New selectors are appended to the end of each media query block.
522
+ */
523
+ function write_css($backup = false) {
524
  // write new stylesheet
525
+ $output = apply_filters('chld_thm_cfg_css_header', $this->get_css_header(), $this);
526
+ $imports = $this->get_prop('imports');
527
+ if (!empty($imports)):
528
+ foreach ($imports as $import):
 
 
 
 
 
 
529
  $output .= $import . ';' . LF;
530
  endforeach;
531
  endif;
532
  $output .= LF;
533
+ // turn the dictionaries into indexes (value => id into id => value):
534
+ $rulearr = array_flip($this->dict_rule);
535
+ $valarr = array_flip($this->dict_val);
536
+ $selarr = array_flip($this->dict_sel);
537
  foreach ($this->sort_queries() as $query => $sort_order):
 
 
538
  $has_selector = 0;
539
  $sel_output = '';
540
+ $selectors = $this->sel_ndx[$this->dict_query[$query]];
541
+ uasort($selectors, array($this, 'cmp_seq'));
542
  if ('base' != $query) $sel_output .= $query . ' {' . LF;
543
+ foreach ($selectors as $selid => $qsid):
544
  $has_value = 0;
545
+ $sel = $selarr[$selid];
546
+ if (!empty($this->val_ndx[$qsid])):
547
+ $shorthand = array();
548
+ foreach ($this->val_ndx[$qsid] as $ruleid => $valid):
549
+ if (isset($valid['child']) && isset($valarr[$valid['child']]) && '' !== $valarr[$valid['child']]):
550
  if (! $has_value):
551
+ $sel_output .= isset($this->dict_seq[$qsid])?'/*' . $this->dict_seq[$qsid] . '*/' . LF:''; // show load order
552
  $sel_output .= $sel . ' {' . LF;
553
  $has_value = 1;
554
  $has_selector = 1;
555
  endif;
556
+ $important_parnt = empty($valid['i_parnt']) ? 0 : 1;
557
+ $important = isset($valid['i_child']) ? $valid['i_child'] : $important_parnt;
558
+ $sel_output .= $this->add_vendor_rules($rulearr[$ruleid], stripslashes($valarr[$valid['child']]), $shorthand, $important);
559
  endif;
560
  endforeach;
561
+ $sel_output .= $this->encode_shorthand($shorthand); // . ($important ? ' !important' : '');
562
  if ($has_value):
563
  $sel_output .= '}' . LF;
564
  endif;
567
  if ('base' != $query) $sel_output .= '}' . LF;
568
  if ($has_selector) $output .= $sel_output;
569
  endforeach;
570
+ $stylesheet = apply_filters('chld_thm_cfg_target', $this->get_child_target(), $this);
571
+ if ($stylesheet_verified = $this->is_file_ok($stylesheet, 'write')):
572
+ // backup current stylesheet
573
+ if ($backup && is_file($stylesheet_verified)):
574
+ $timestamp = date('YmdHis', current_time('timestamp'));
575
+ $bakfile = preg_replace("/\.css$/", '', $stylesheet_verified) . '-' . $timestamp . '.css';
576
+ if (false === file_put_contents($bakfile, file_get_contents($stylesheet_verified))) return false;
577
+ endif;
578
+ // write new stylesheet
579
+ if (false === file_put_contents($stylesheet_verified, $output)) return false;
580
+ return true;
581
+ endif;
582
+ return false;
583
  }
584
 
585
+ /*
586
+ * add_vendor_rules
587
+ * Applies vendor prefixes to rules/values
588
+ * These are based on commonly used practices and not all vendor prefixed are supported
589
+ * TODO: verify this logic against vendor and W3C documentation
590
+ */
591
+ function add_vendor_rules($rule, $value, &$shorthand, $important = 0) {
592
  $rules = '';
593
+ if ('filter' == $rule && (false !== strpos($value, 'progid:DXImageTransform.Microsoft.Gradient'))) return;
594
+ $importantstr = $important ? ' !important' : '';
595
+ if (preg_match("/^(margin|padding)\-(top|right|bottom|left)$/", $rule, $matches)):
596
+ $shorthand[$matches[1]][$matches[2]] = $value . $importantstr;
597
+ return '';
598
+ elseif (preg_match("/^(box\-sizing|font\-smoothing|border\-radius|box\-shadow|transition)$/", $rule)):
599
  foreach(array('moz', 'webkit', 'o') as $prefix):
600
+ $rules .= ' -' . $prefix . '-' . $rule . ': ' . $value . $importantstr . ';' . LF;
601
  endforeach;
602
+ $rules .= ' ' . $rule . ': ' . $value . $importantstr . ';' . LF;
603
  elseif ('background-image' == $rule):
604
  // gradient?
605
  if ($gradient = $this->decode_gradient($value)):
606
  // standard gradient
607
  foreach(array('moz', 'webkit', 'o', 'ms') as $prefix):
608
  $rules .= ' background-image: -' . $prefix . '-' . 'linear-gradient(' . $gradient['origin'] . ', '
609
+ . $gradient['color1'] . ', ' . $gradient['color2'] . ')' . $importantstr . ';' . LF;
610
  endforeach;
611
  // W3C standard gradient
612
  // rotate origin 90 degrees
620
  $org = 'to ' . implode(' ', $dirs);
621
  endif;
622
  $rules .= ' background-image: linear-gradient(' . $org . ', '
623
+ . $gradient['color1'] . ', ' . $gradient['color2'] . ')' . $importantstr . ';' . LF;
624
 
625
  // legacy webkit gradient - we'll add if there is demand
626
  // '-webkit-gradient(linear,' .$origin . ', ' . $color1 . ', '. $color2 . ')';
629
  $type = (in_array($gradient['origin'], array('left', 'right', '0deg', '180deg')) ? 1 : 0);
630
  $color1 = preg_replace("/^#/", '#00', $gradient['color1']);
631
  $rules .= ' filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=' . $type . ', StartColorStr="'
632
+ . strtoupper($color1) . '", EndColorStr="' . strtoupper($gradient['color2']) . '")' . $importantstr . ';' . LF;
633
  else:
634
  // url or other value
635
+ $rules .= ' ' . $rule . ': ' . $value . $importantstr . ';' . LF;
636
  endif;
637
  else:
638
+ $rule = preg_replace_callback("/\d+/", array($this, 'from_ascii'), $rule);
639
+ $rules .= ' ' . $rule . ': ' . $value . $importantstr . ';' . LF;
640
+ endif;
641
+ return $rules;
642
+ }
643
+
644
+ /*
645
+ * normalize_background
646
+ * parses background shorthand value and returns
647
+ * normalized rule/value pairs for each property
648
+ */
649
+ function normalize_background($value, &$rules, &$values){
650
+ if (false !== strpos($value, 'gradient')):
651
+ // only supporting linear syntax
652
+ if (preg_match('#(linear\-|Microsoft\.)#', $value)):
653
+ $values[] = $value;
654
+ $rules[] = 'background-image';
655
+ endif;
656
+ else:
657
+ $regex = '#(url *\([^\)]+\))#';
658
+ if (preg_match($regex, $value, $matches)) $url = $matches[1];
659
+ $parts = preg_split($regex, $value);
660
+
661
+ if (count($parts) == 1):
662
+ // this is a named color or single hex color or none
663
+ $part = str_replace(' ', '', $parts[0]);
664
+ $rules[] = 'none' == $part ? 'background' : 'background-color';
665
+ $values[] = $part;
666
+ else:
667
+ $rules[] = 'background-image';
668
+ $values[] = $url;
669
+ if (!empty($parts[0]) && '' !== $parts[0]):
670
+ $rules[] = 'background-color';
671
+ $values[] = trim($parts[0]);
672
+ endif;
673
+ $position = array();
674
+ foreach(preg_split('/ +/', trim($parts[1])) as $part):
675
+ if ('' === $part) continue; // empty($part) ||
676
+ if (false === strpos($part, 'repeat')):
677
+ $position[] = $part;
678
+ else:
679
+ $rules[] = 'background-repeat';
680
+ $values[] = $part;
681
+ endif;
682
+ endforeach;
683
+ if (count($position)):
684
+ $rules[] = 'background-position';
685
+ $values[] = implode(' ', $position);
686
+ endif;
687
+ endif;
688
+ endif;
689
+ }
690
+
691
+ /*
692
+ * normalize_font
693
+ * parses font shorthand value and returns
694
+ * normalized rule/value pairs for each property
695
+ */
696
+ function normalize_font($value, &$rules, &$values) {
697
+ $regex = '#^((\d+|bold|normal) )?((italic|normal) )?(([\d\.]+(px|r?em|%))[\/ ])?(([\d\.]+(px|r?em|%)?) )?(.+)$#is';
698
+ preg_match($regex, $value, $parts);
699
+ if (!empty($parts[2])):
700
+ $rules[] = 'font-weight';
701
+ $values[] = $parts[2];
702
+ endif;
703
+ if (!empty($parts[4])):
704
+ $rules[] = 'font-style';
705
+ $values[] = $parts[4];
706
+ endif;
707
+ if (!empty($parts[6])):
708
+ $rules[] = 'font-size';
709
+ $values[] = $parts[6];
710
+ endif;
711
+ if (!empty($parts[9])):
712
+ $rules[] = 'line-height';
713
+ $values[] = $parts[9];
714
+ endif;
715
+ if (!empty($parts[11])):
716
+ $rules[] = 'font-family';
717
+ $values[] = $parts[11];
718
  endif;
719
+ }
720
+
721
+ /*
722
+ * normalize_margin_padding
723
+ * parses margin or padding shorthand value and returns
724
+ * normalized rule/value pairs for each property
725
+ * TODO: reassemble into shorthand when writing CSS file
726
+ */
727
+ function normalize_margin_padding($rule, $value, &$rules, &$values) {
728
+ $parts = preg_split("/ +/", trim($value));
729
+ if (!isset($parts[1])) $parts[1] = $parts[0];
730
+ if (!isset($parts[2])) $parts[2] = $parts[0];
731
+ if (!isset($parts[3])) $parts[3] = $parts[1];
732
+ $rules[0] = $rule . '-top';
733
+ $values[0] = $parts[0];
734
+ $rules[1] = $rule . '-right';
735
+ $values[1] = $parts[1];
736
+ $rules[2] = $rule . '-bottom';
737
+ $values[2] = $parts[2];
738
+ $rules[3] = $rule . '-left';
739
+ $values[3] = $parts[3];
740
+ }
741
+
742
+ function encode_shorthand($shorthand) {
743
+ $rules = '';
744
+ $importantstr = ' !important';
745
+ foreach (array_keys($shorthand) as $key):
746
+ $important = array();
747
+ $rule = array();
748
+ $importantct = 0;
749
+ // which sides do we have and are they important?
750
+ foreach($shorthand[$key] as $side => $val):
751
+ $ict = 0;
752
+ $rule[$side] = trim(preg_replace('/'.$importantstr.'/', '', $val, 1, $ict));
753
+ $important[$side] = $ict;
754
+ $importantct += $ict;
755
+ endforeach;
756
+ // shorthand must have 4 explicit values and all must have same priority
757
+ if (4 == count($rule) && (0 == $importantct || 4 == $importantct )):
758
+ // let's try to condense the values into as few as possible, starting with the top value
759
+ $parts = array();
760
+ $parts[0] = $rule['top'];
761
+ // if left is not the same as right, we must use all 4 values
762
+ if ($rule['left'] !== $rule['right']):
763
+ $parts[3] = $rule['left'];
764
+ $parts[2] = $rule['bottom'];
765
+ $parts[1] = $rule['right'];
766
+ endif;
767
+ // if top is not the same as bottom, we must use at least 3 values
768
+ if ($rule['bottom'] !== $rule['top']):
769
+ $parts[2] = $rule['bottom'];
770
+ $parts[1] = $rule['right'];
771
+ endif;
772
+ // if top is not the same as right, we must use at least 2 values
773
+ if ($rule['right'] !== $rule['top']):
774
+ $parts[1] = $rule['right'];
775
+ endif;
776
+ // the order of the sides is critical: top right bottom left
777
+ ksort($parts);
778
+ $shorthandstr = implode(' ', $parts);
779
+ // if important counter is > 0, it must be == 4, add flag
780
+ $rules .= ' ' . $key . ': ' . $shorthandstr . ($importantct ? ' ' . $importantstr : '') . ';' . LF;
781
+ else:
782
+ // otherwise return separate rule for each side
783
+ foreach ($rule as $side => $value):
784
+ $rules .= ' ' . $key . '-' . $side . ': ' . $value . ($important[$side] ? $importantstr : '') . ';' . LF;
785
+ endforeach;
786
+ endif;
787
+ endforeach;
788
  return $rules;
789
  }
790
+
791
+ /*
792
+ * encode_gradient
793
+ * Normalize linear gradients from a bazillion formats into standard CTC syntax:
794
+ * Currently only supports two-color linear gradients with no inner stops.
795
+ * TODO: legacy webkit? more gradients?
796
+ */
797
  function encode_gradient($value) {
798
+ $regex = '#gradient[^\)]*?\((((top|bottom|left|right)?( (top|bottom|left|right))?|\d+deg),)?([^\)]*[\'"]?(\#\w{3,8}|rgba?\([\d, ]+?\)|hsla?\([\d%, ]+?\))( \d+%)?)([^\)]*[\'"]?(\#\w{3,8}|rgba?\([\d, ]+?\)|hsla?\([\d%, ]+?\))( \d+%)?)([^\)]*gradienttype=[\'"]?(\d)[\'"]?)?[^\)]*\)#i';
799
  $param = $parts = array();
800
  preg_match($regex, $value, $parts);
801
  if (empty($parts[13])):
823
  $param[2] = '0%';
824
  $param[4] = '100%';
825
  endif;
826
+ if (isset($parts[7]) && isset($parts[10])):
827
+ $param[1] = $parts[7];
828
+ $param[3] = $parts[10];
829
+ ksort($param);
830
+ return implode(':', $param);
831
+ else: return $value;
832
+ endif;
833
  }
834
 
835
+ /*
836
+ * decode_border
837
+ * De-normalize CTC border syntax into separate properties.
838
+ */
839
  function decode_border($value) {
840
  if (preg_match('#^(0|none)#i', $value)):
841
  $parts[0] = $value;
849
  'color' => empty($parts[2])?'':$parts[2],
850
  );
851
  }
852
+
853
+ /*
854
+ * decode_gradient
855
+ * Decode CTC gradient syntax into separate properties.
856
+ */
857
  function decode_gradient($value) {
858
  $parts = explode(':', $value, 5);
859
+ if (5 == count($parts)):
860
  return array(
861
+ 'origin' => empty($parts[0]) ? '' : $parts[0],
862
+ 'color1' => empty($parts[1]) ? '' : $parts[1],
863
+ 'stop1' => empty($parts[2]) ? '' : $parts[2],
864
+ 'color2' => empty($parts[3]) ? '' : $parts[3],
865
+ 'stop2' => empty($parts[4]) ? '' : $parts[4],
866
  );
 
 
867
  endif;
868
+ return false;
869
  }
870
+
871
+ /*
872
+ * denorm_rule_val
873
+ * Return array of unique values corresponding to specific rule
874
+ */
875
+ function denorm_rule_val($ruleid) {
876
+ $rule_sel_arr = array();
877
+ $val_arr = array_flip($this->dict_val);
878
+ foreach ($this->val_ndx as $selid => $rules):
879
+ if (!isset($rules[$ruleid])) continue;
880
+ foreach ($rules[$ruleid] as $theme => $val):
881
+ if (!isset($val_arr[$val]) || '' === $val_arr[$val]) continue;
882
+ $rule_sel_arr[$val] = $val_arr[$val];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
883
  endforeach;
884
+ endforeach;
885
+ return $rule_sel_arr;
886
+ }
887
+
888
+ /*
889
+ * denorm_val_query
890
+ * Return array of queries, selectors, rules, and values corresponding to
891
+ * specific rule/value combo grouped by query, selector
892
+ */
893
+ function denorm_val_query($valid, $rule) {
894
+ $value_query_arr = array();
895
+ foreach ($this->val_ndx as $qsid => $rules):
896
+ foreach ($rules as $ruleid => $values):
897
+ if ($ruleid != $this->dict_rule[$rule]) continue;
898
+ foreach ($values as $name => $val):
899
+ if ('i' == $name || $val != $valid) continue;
900
+ $selarr = $this->denorm_query_sel($qsid);
901
+ $valarr = $this->denorm_sel_val($qsid);
902
+ $value_query_arr[$rule][$selarr['query']][$qsid] = $valarr;
903
+ endforeach;
904
+ endforeach;
905
+ endforeach;
906
+ return $value_query_arr;
907
+ }
908
+
909
+ /*
910
+ * denorm_query_sel
911
+ * Return id, query and selector values of a specific qsid (query-selector ID)
912
+ */
913
+ function denorm_query_sel($qsid) {
914
+ $queryarr = array_flip($this->dict_query);
915
+ $selarr = array_flip($this->dict_sel);
916
+ $this->dict_seq[$qsid] = isset($this->dict_seq[$qsid]) ? $this->dict_seq[$qsid] : $qsid;
917
+ return array(
918
+ 'id' => $qsid,
919
+ 'query' => $queryarr[$this->dict_qs[$qsid]['q']],
920
+ 'selector' => $selarr[$this->dict_qs[$qsid]['s']],
921
+ 'seq' => $this->dict_seq[$qsid],
922
+ );
923
+ }
924
+
925
+ /*
926
+ * denorm_sel_val
927
+ * Return array of rules, and values matching specific qsid (query-selector ID)
928
+ * grouped by query, selector
929
+ */
930
+ function denorm_sel_val($qsid) {
931
+ $selarr = $this->denorm_query_sel($qsid);
932
+ $valarr = array_flip($this->dict_val);
933
+ $rulearr = array_flip($this->dict_rule);
934
+ if (isset($this->val_ndx[$qsid]) && is_array($this->val_ndx[$qsid])):
935
+ foreach ($this->val_ndx[$qsid] as $ruleid => $values):
936
+ foreach ($values as $name => $val):
937
+ if ('i_parnt' == $name || 'i_child' == $name):
938
+ $selarr['value'][$rulearr[$ruleid]][$name] = (empty($val) ? 0 : 1);
939
+ elseif (!isset($valarr[$val]) || '' === $valarr[$val]):
940
+ continue;
941
  else:
942
+ $selarr['value'][$rulearr[$ruleid]][$name] = $valarr[$val];
943
  endif;
 
 
944
  endforeach;
945
+ // add load order
946
+ endforeach;
947
  endif;
948
+ return $selarr;
949
+ }
950
+
951
+ /*
952
+ * denorm_sel_ndx
953
+ * Return denormalized array containing query and selector heirarchy
954
+ */
955
+ function denorm_sel_ndx($query = null) {
956
+ $sel_ndx_norm = array();
957
+ $queryarr = array_flip($this->dict_query);
958
+ $selarr = array_flip($this->dict_sel);
959
+ foreach($this->sel_ndx as $queryid => $sel):
960
+ foreach($sel as $selid => $qsid):
961
+ $sel_ndx_norm[$queryarr[$queryid]][$selarr[$selid]] = $qsid;
962
+ endforeach;
963
+ endforeach;
964
+ return empty($query) ? $sel_ndx_norm : $sel_ndx_norm[$query];
965
  }
966
+
967
  /*
968
+ * is_important
969
  * Strip important flag from value ref and return boolean
970
+ * Value is updated because it is a ref
971
  */
972
  function is_important(&$value) {
973
  $important = 0;
974
+ $value = trim(str_ireplace('!important', '', $value, $important));
975
  return $important;
976
  }
977
 
978
+ /*
979
+ * sort_queries
980
+ * De-normalize query data and return array sorted as follows:
981
+ * base
982
+ * @media max-width queries in descending order
983
+ * other @media queries in no particular order
984
+ * @media min-width queries in ascending order
985
+ */
986
  function sort_queries() {
987
  $queries = array();
988
+ $queryarr = array_flip($this->dict_query);
989
+ foreach (array_keys($this->sel_ndx) as $queryid):
990
+ $query = $queryarr[$queryid];
991
  if ('base' == $query):
992
  $queries['base'] = -999999;
993
  continue;
995
  if (preg_match("/((min|max)(\-device)?\-width)\s*:\s*(\d+)/", $query, $matches)):
996
  $queries[$query] = 'min-width' == $matches[1] ? $matches[4] : -$matches[4];
997
  else:
998
+ $queries[$query] = $queryid - 10000;
999
  endif;
1000
  endforeach;
1001
  asort($queries);
1002
  return $queries;
1003
  }
1004
+
1005
+ // sort selectors based on dict_seq if exists, otherwise qsid
1006
+ function cmp_seq($a, $b) {
1007
+ $cmpa = isset($this->dict_seq[$a])?$this->dict_seq[$a]:$a;
1008
+ $cmpb = isset($this->dict_seq[$b])?$this->dict_seq[$b]:$b;
1009
+ if ($cmpa == $cmpb) return 0;
1010
+ return ($cmpa < $cmpb) ? -1 : 1;
1011
+ }
1012
+
1013
+ /*
1014
+ * obj_to_utf8
1015
+ * sets object data to UTF8
1016
+ * and stringifies NULLs
1017
+ */
1018
+ function obj_to_utf8($data) {
1019
+
1020
+ if (is_object($data)) {
1021
+ $data = get_object_vars($data);
1022
+ }
1023
+ if (is_array($data)) {
1024
+ return array_map(array(&$this, __FUNCTION__), $data);
1025
+ }
1026
+ else {
1027
+ return is_null( $data ) ? '' : utf8_encode($data);
1028
+ }
1029
+ }
1030
+
1031
+ function to_ascii($matches) {
1032
+ return ord($matches[0]);
1033
+ }
1034
+
1035
+ function from_ascii($matches) {
1036
+ return chr($matches[0]);
1037
+ }
1038
+
1039
+ /* is_file_ok
1040
+ * verify file exists and is in valid location
1041
+ */
1042
+ function is_file_ok($stylesheet, $permission = 'read') {
1043
+ // remove any ../ manipulations
1044
+ $stylesheet = preg_replace("%\.\./%", '/', $stylesheet);
1045
+ if ('read' == $permission && !is_file($stylesheet)) return false;
1046
+ if ('search' == $permission && !is_dir($stylesheet)) return false;
1047
+ // sanity check for php files
1048
+ //if (!preg_match('%' . preg_quote($ext) . '$%', $stylesheet)) return false;
1049
+ // check if in themes dir;
1050
+ if (preg_match('%^' . preg_quote(get_theme_root()) . '%', $stylesheet)) return $stylesheet;
1051
+ // check if in plugins dir
1052
+ if (preg_match('%^' . preg_quote(WP_PLUGIN_DIR) . '%', $stylesheet)) return $stylesheet;
1053
+ return false;
1054
+ }
1055
  }
1056
  ?>
includes/class-ctc-ui.php CHANGED
@@ -1,254 +1,378 @@
1
  <?php
2
  // Exit if accessed directly
3
  if ( !defined('ABSPATH')) exit;
4
-
5
  /*
6
  Class: Child_Theme_Configurator_UI
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Handles the plugin User Interface
9
- Version: 1.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
- Copyright (C) 2013 Lilaea Media
16
  */
17
  class Child_Theme_Configurator_UI {
18
  var $swatch_text;
 
 
 
19
  function __construct() {
20
- $this->swatch_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
 
21
  }
22
 
23
  function render_options() {
24
  global $chld_thm_cfg;
25
- $css = $chld_thm_cfg->css;
26
- $parent = $css->get_property('parent_theme');
27
- $child = $css->get_property('child_theme');
28
- $imports= $css->get_property('imports');
29
- $id = 0;
30
- ?>
 
 
 
31
 
32
  <div class="wrap">
33
  <div id="icon-tools" class="icon32"></div>
 
34
  <h2><?php echo $chld_thm_cfg->pluginName; ?></h2>
35
- <?php $this->settings_errors(); ?>
 
 
36
  <?php
37
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'parent_child_options';
38
  ?>
39
- <h2 class="nav-tab-wrapper">
40
- <a id="parent_child_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=parent_child_options"
41
  class="nav-tab<?php echo 'parent_child_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
42
- <?php _e('Parent/Child', $chld_thm_cfg->ns); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  </a>
44
- <a id="query_selector_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=query_selector_options"
45
- class="nav-tab<?php echo 'query_selector_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
46
- <?php _e('Query/Selector', $chld_thm_cfg->ns); ?>
47
- </a>
48
- <a id="rule_value_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=rule_value_options"
49
- class="nav-tab<?php echo 'rule_value_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
50
- <?php _e('Rule/Value', $chld_thm_cfg->ns); ?>
51
- </a>
52
- <a id="import_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=import_options"
53
- class="nav-tab<?php echo 'import_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
54
- <?php _e('@import', $chld_thm_cfg->ns); ?>
55
  </a>
56
- <a id="preview_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=preview_options"
57
- class="nav-tab<?php echo 'preview_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
58
- <?php _e('Preview CSS', $chld_thm_cfg->ns); ?>
59
- </a>
60
- </h2>
61
  <div class="ctc-option-panel-container">
62
  <div id="parent_child_options_panel" class="ctc-option-panel<?php echo 'parent_child_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
63
- <form id="ctc_load_form" method="post" action="">
64
  <?php wp_nonce_field( 'ctc_update' ); ?>
65
- <div class="ctc-input-row clearfix" id="input_row_parent_theme">
66
- <div class="ctc-input-cell">
67
- <label>
68
- <?php _e('Parent Theme', $chld_thm_cfg->ns); ?>
69
- </label>
70
- </div>
71
  <div class="ctc-input-cell">
72
- <?php $this->render_theme_dropdown(); ?>
 
 
73
  </div>
74
  </div>
75
- <div class="ctc-input-row clearfix" id="input_row_child_theme">
 
 
 
76
  <div class="ctc-input-cell">
77
- <label>
78
- <?php _e('Child Theme', $chld_thm_cfg->ns); ?>
 
 
 
79
  </label>
80
  </div>
81
  <div class="ctc-input-cell">
82
- <?php $this->render_theme_dropdown(true); ?>
83
- </div>
84
- </div>
85
- <div class="ctc-input-row clearfix" id="input_row_child_template">
86
- <div class="ctc-input-cell">
87
- <label>
88
- <?php _e('Author', $chld_thm_cfg->ns); ?>
89
  </label>
90
  </div>
 
 
 
 
91
  <div class="ctc-input-cell">
92
- <input class="ctc_text" id="ctc_theme_author" name="ctc_theme_author" type="text" value="<? echo $css->get_property('author'); ?>"/>
 
 
93
  </div>
94
  </div>
95
  <div class="ctc-input-row clearfix" id="input_row_child_name">
 
 
 
96
  <div class="ctc-input-cell">
97
- <label>
98
- <?php _e('New Child Theme Name', $chld_thm_cfg->ns); ?>
99
- </label>
100
  </div>
 
 
 
 
 
 
101
  <div class="ctc-input-cell">
102
- <input class="ctc_text" id="ctc_child_name" name="ctc_child_name" type="text"/>
 
103
  </div>
104
  </div>
105
  <div class="ctc-input-row clearfix" id="input_row_child_template">
 
 
 
106
  <div class="ctc-input-cell">
107
- <label>
108
- <?php _e('New Child Theme Slug', $chld_thm_cfg->ns); ?>
109
- </label>
110
  </div>
 
 
 
 
 
111
  <div class="ctc-input-cell">
112
- <input class="ctc_text" id="ctc_child_template" name="ctc_child_template" type="text"/>
 
113
  </div>
114
  </div>
115
  <div class="ctc-input-row clearfix" id="input_row_child_template">
 
 
 
116
  <div class="ctc-input-cell">
117
- <label>&nbsp;</label>
 
118
  </div>
 
 
 
119
  <div class="ctc-input-cell">
120
- <input class="ctc_submit button button-primary" id="ctc_load_styles" name="ctc_load_styles" type="submit"
121
- value="<?php _e('Load Styles', $chld_thm_cfg->ns); ?>" />
122
  </div>
123
  </div>
124
  </form>
125
  </div>
126
- <div id="rule_value_options_panel" class="ctc-option-panel<?php echo 'rule_value_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
127
- <form id="ctc_rule_value_form" method="post" action="">
 
128
  <?php wp_nonce_field( 'ctc_update' ); ?>
129
  <div class="ctc-input-row clearfix" id="ctc_input_row_rule_menu">
130
  <div class="ctc-input-cell"> <strong>
131
- <?php _e('Rule', $chld_thm_cfg->ns); ?>
132
  </strong> </div>
133
  <div class="ctc-input-cell" id="ctc_rule_menu_selected">&nbsp;</div>
 
134
  <div class="ctc-input-cell">
135
  <div class="ui-widget">
136
  <input id="ctc_rule_menu"/>
 
137
  </div>
138
  </div>
139
  </div>
140
  <div class="ctc-input-row clearfix" id="ctc_input_row_rule_header" style="display:none">
141
  <div class="ctc-input-cell"> <strong>
142
- <?php _e('Value', $chld_thm_cfg->ns); ?>
143
  </strong> </div>
144
  <div class="ctc-input-cell"> <strong>
145
- <?php _e('Sample', $chld_thm_cfg->ns); ?>
146
  </strong> </div>
147
  <div class="ctc-input-cell"> <strong>
148
- <?php _e('Selectors', $chld_thm_cfg->ns); ?>
149
  </strong> </div>
150
  </div>
151
  <div class="ctc-rule-value-input-container clearfix" id="ctc_rule_value_inputs" style="display:none"> </div>
152
  </form>
153
  </div>
154
- <div id="query_selector_options_panel" class="ctc-option-panel<?php echo 'query_selector_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
155
- <form id="ctc_query_selector_form" method="post" action="">
 
156
  <div class="ctc-input-row clearfix" id="input_row_query">
157
  <div class="ctc-input-cell"> <strong>
158
- <?php _e('Query', $chld_thm_cfg->ns); ?>
159
  </strong> </div>
160
  <div class="ctc-input-cell" id="ctc_sel_ovrd_query_selected">&nbsp;</div>
161
  <div class="ctc-input-cell">
162
  <div class="ui-widget">
163
- <input id="ctc_sel_ovrd_query"/>
164
  </div>
165
  </div>
166
  </div>
167
  <div class="ctc-input-row clearfix" id="input_row_selector">
168
  <div class="ctc-input-cell"> <strong>
169
- <?php _e('Selector', $chld_thm_cfg->ns); ?>
170
- </strong> </div>
171
  <div class="ctc-input-cell" id="ctc_sel_ovrd_selector_selected">&nbsp;</div>
172
  <div class="ctc-input-cell">
173
  <div class="ui-widget">
174
- <input id="ctc_sel_ovrd_selector"/>
 
175
  </div>
176
  </div>
177
  </div>
178
  <div class="ctc-selector-row clearfix" id="ctc_sel_ovrd_rule_inputs_container" style="display:none">
179
  <div class="ctc-input-row clearfix">
180
  <div class="ctc-input-cell"><strong>
181
- <?php _e('Sample', $chld_thm_cfg->ns); ?>
182
  </strong></div>
183
  <div class="ctc-input-cell clearfix" style="max-height:150px;overflow:hidden">
184
  <div class="ctc-swatch" id="ctc_child_all_0_swatch"><?php echo $this->swatch_text; ?></div>
185
  </div>
 
186
  <div class="ctc-input-cell ctc-button-cell" id="ctc_save_query_selector_cell">
187
- <input type="button" class="button ctc-save-input" id="ctc_save_query_selector"
188
- name="ctc_save_query_selector" value="Save" />
189
- <input type="hidden" id="ctc_sel_ovrd_selnum"
190
- name="ctc_sel_ovrd_selnum" value="" />
191
  </div>
192
  </div>
193
  <div class="ctc-input-row clearfix" id="ctc_sel_ovrd_rule_header" style="display:none">
194
  <div class="ctc-input-cell"> <strong>
195
- <?php _e('Rule', $chld_thm_cfg->ns); ?>
196
  </strong> </div>
197
  <div class="ctc-input-cell"> <strong>
198
- <?php _e('Parent Value', $chld_thm_cfg->ns); ?>
199
  </strong> </div>
200
  <div class="ctc-input-cell"> <strong>
201
- <?php _e('Child Value', $chld_thm_cfg->ns); ?>
202
  </strong> </div>
203
  </div>
204
  <div id="ctc_sel_ovrd_rule_inputs" style="display:none"> </div>
205
  <div class="ctc-input-row clearfix" id="ctc_sel_ovrd_new_rule" style="display:none">
206
- <div class="ctc-input-cell"> <strong>
207
- <?php _e('New Rule', $chld_thm_cfg->ns); ?>
208
- </strong> </div>
209
- <div class="ctc-input-cell">
210
- <div class="ui-widget">
211
- <input id="ctc_new_rule_menu"/>
 
212
  </div>
213
  </div>
214
- </div>
215
- </div>
216
- <div class="ctc-selector-row clearfix" id="ctc_new_selector_row">
217
  <div class="ctc-input-cell"> <strong>
218
- <?php _e('New Selector(s)', $chld_thm_cfg->ns); ?>
219
- </strong>
220
- <div class="ctc-textarea-button-cell" id="ctc_save_query_selector_cell">
221
- <input type="button" class="button ctc-save-input" id="ctc_save_new_selectors"
222
- name="ctc_save_new_selectors" value="Save" />
223
- </div>
224
- </div>
225
- <div class="ctc-input-cell-wide"> <textarea id="ctc_new_selectors" name="ctc_new_selectors" wrap="off"></textarea> </div>
226
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  </form>
228
  </div>
229
- <div id="import_options_panel" class="ctc-option-panel<?php echo 'import_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
230
- <form id="ctc_import_form" method="post" action="">
 
231
  <?php wp_nonce_field( 'ctc_update' ); ?>
232
- <div class="ctc-input-row clearfix" id="ctc_child_imports_row">
233
- <div class="ctc-input-cell"> <strong>
234
- <?php _e('@import Statements', $chld_thm_cfg->ns); ?>
235
- </strong>
236
- <div class="ctc-textarea-button-cell" id="ctc_save_imports_cell">
237
- <input type="button" class="button ctc-save-input" id="ctc_save_imports"
238
- name="ctc_save_imports" value="Save" />
239
- </div>
240
  </div>
241
- <div class="ctc-input-cell-wide"> <textarea id="ctc_child_imports" name="ctc_child_imports" wrap="off">
242
- <?php if (!empty($imports[$child])):
243
- foreach ($imports[$child] as $import):
 
 
244
  echo esc_textarea($import . ';' . LF);
245
- endforeach; endif;?></textarea> </div>
246
-
247
  </div>
 
248
  </form>
249
  </div>
250
- <div id="preview_options_panel" class="ctc-option-panel<?php echo 'preview_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  </div>
 
 
252
  </div>
253
  </div>
254
  <style type="text/css">
@@ -274,22 +398,130 @@ class Child_Theme_Configurator_UI {
274
  <?php
275
  }
276
 
277
- function render_theme_dropdown($child = false) {
278
- global $chld_thm_cfg;
279
- echo '<select class="chld-thm-cfg-select" id="ctc_theme_' . ($child?'child':'parent') . '" name="ctc_theme_' . ($child?'child':'parent') . '">' . LF;
280
- if ($child):
281
- echo '<option value="new">New Theme</option>' . LF;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  endif;
283
- foreach (wp_get_themes() as $theme):
284
- $parent = $theme->parent();
285
- if ($child !== empty($parent)):
286
- $template = $child ? $theme->get_stylesheet() : $theme->get_template();
287
- echo '<option value="' . $template . '"'
288
- . ($template == $chld_thm_cfg->css->get_property($child?'child_theme':'parent_theme') ? ' selected' : '')
289
- . '>' . $theme->get('Name') . '</option>' . LF;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  endif;
291
  endforeach;
292
- echo '</select>' . LF;
293
  }
294
 
295
  function settings_errors() {
@@ -301,10 +533,16 @@ class Child_Theme_Configurator_UI {
301
  endforeach;
302
  echo '</ul></div>' . LF;
303
  elseif (isset($_GET['updated'])):
304
- echo '<div class="updated"><p>' . LF
305
- . __('Child Theme', $chld_thm_cfg->ns) . ' <strong>' . $chld_thm_cfg->css->get_property('child_theme_name')
306
- . '</strong> ' . __('has been updated.', $chld_thm_cfg->ns) . LF
307
- . '</p></div>' . LF;
 
 
 
 
 
 
308
  endif;
309
  }
310
 
@@ -317,88 +555,133 @@ class Child_Theme_Configurator_UI {
317
  if ( $screen->id != $chld_thm_cfg->hook )
318
  return;
319
  // Add help tabs
 
 
 
 
 
 
 
 
320
  $screen->add_help_tab( array(
321
  'id' => 'ctc_getting_started',
322
- 'title' => __( 'Start Here', $chld_thm_cfg->ns ),
323
  'content' => __( '
324
  <p>The first step is to create a child theme and import your parent theme styles into the configurator.</p>
325
  <ol><li>Select an existing parent theme from the menu.</li>
326
- <li>Select an existing child theme from the menu, or "New Theme" if you are creating one from scratch.</li>
 
 
 
327
  <li>Enter an author for the child theme.</li>
328
- <li>If this is a new theme, enter a Name.</li>
329
- <li>If this is a new theme, enter a "slug" (lower case, no spaces). This is used to name the theme directory and identify the theme to WordPress.</li>
330
- <li>Click "Load Styles." If you are loading an existing child theme, The Child Theme Configurator will create a backup of your existing stylesheet in the theme directory.</li></ol>
331
- ', $chld_thm_cfg->ns
332
  ),
333
  ) );
334
 
335
  $screen->add_help_tab( array(
336
  'id' => 'ctc_query_selector',
337
- 'title' => __( 'Query/Selector', $chld_thm_cfg->ns ),
338
  'content' => __( '
339
  <p>There are two ways to identify and override parent styles. The Child Theme Configurator lets you search styles by <strong>selector</strong> and by <strong>rule</strong>. If you wish to change a specific selector (e.g., h1), use the "Query/Selector" tab. If you have a specific value you wish to change site-wide (e.g., the color of the type), use the "Rule/Value" tab.</p>
340
  <p>The Query/Selector tab lets you find specific selectors and edit them. First, find the query that contains the selector you wish to edit by typing in the <strong>Query</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys. Selectors are in the <strong>base</strong> query by default.</p>
341
  <p>Next, find the selector by typing in the <strong>Selector</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys.</p>
342
  <p>This will load all of the rules for that selector with the Parent values on the left and the Child values inputs on the right. Any existing child values will be automatically populated. There is also a Sample preview that displays the combination of Parent and Child overrides. Note that the <strong>border</strong> and <strong>background-image</strong> get special treatment.</p>
 
343
  <p>Click "Save" to update the child stylesheet and save your changes to the WordPress admin.</p>
344
- ', $chld_thm_cfg->ns
345
  ),
346
  ) );
347
 
348
  $screen->add_help_tab( array(
349
  'id' => 'ctc_rule_value',
350
- 'title' => __( 'Rule/Value', $chld_thm_cfg->ns ),
351
  'content' => __( '
352
  <p>There are two ways to identify and override parent styles. The Child Theme Configurator lets you search styles by <strong>selector</strong> and by <strong>rule</strong>. If you wish to change a specific selector (e.g., h1), use the "Query/Selector" tab. If you have a specific value you wish to change site-wide (e.g., the color of the type), use the "Rule/Value" tab.</p>
353
  <p>The Rule/Value tab lets you find specific values for a given rule and then edit that value for individual selectors that use that rule/value combination. First, find the rule you wish to override by typing in the <strong>Rule</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys.</p>
354
  <p>This will load all of the unique values that exist for that rule in the parent stylesheet with a Sample preview for that value. If there are values that exist in the child stylesheet that do not exist in the parent stylesheet, they will be displayed as well.</p>
355
  <p>For each unique value, click the "Selectors" link to view a list of selectors that use that rule/value combination, grouped by query with a Sample preview of the value and inputs for the child value. Any existing child values will be automatically populated.</p>
356
  <p>Click "Save" to update the child stylesheet and save your changes to the WordPress admin.</p>
357
- ', $chld_thm_cfg->ns
358
  ),
359
  ) );
360
 
361
  $screen->add_help_tab( array(
362
  'id' => 'ctc_new_styles',
363
- 'title' => __( 'Add New Styles', $chld_thm_cfg->ns ),
364
  'content' => __( '
365
  <p>If you wish to add additional rules to a given selector, first load the selector using the Query/Selector tab. Then find the rule you wish to override by typing in the <strong>New Rule</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys. This will add a new input row to the selector inputs.</p>
366
  <p>If you wish to add completely new selectors, or even new @media queries, you can enter free-form CSS in the "New Selector" textarea. Be aware that your syntax must be correct (i.e., balanced curly braces, etc.) for the parser to load the new styles. You will know it is invalid because a red "X" will appear next to the save button.</p>
367
  <p>If you prefer to use shorthand syntax for rules and values instead of the inputs provided by the Child Theme Configurator, you can enter them here as well. The parser will convert your input into normalized CSS code automatically.</p>
368
- ', $chld_thm_cfg->ns
369
  ),
370
  ) );
371
 
372
  $screen->add_help_tab( array(
373
  'id' => 'ctc_imports',
374
- 'title' => __( '@imports', $chld_thm_cfg->ns ),
375
  'content' => __( '
376
  <p>You can add additional stylesheets and web fonts by typing @import rules into the textarea on the @import tab. <strong>Important: The Child Theme Configurator adds the @import rule that loads the Parent Theme\'s stylesheet automatically. Do not need to add it here.</strong></p>
 
377
  <p>Below is an example that loads a local custom stylesheet (you would have to add the "fonts" directory and stylesheet) as well as the web font "Open Sans" from Google Web Fonts:</p>
378
  <blockquote><pre><code>
379
  @import url(fonts/stylesheet.css);
380
  @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic);
381
  </code></pre></blockquote>
382
- ', $chld_thm_cfg->ns
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  ),
384
  ) );
385
 
386
  $screen->add_help_tab( array(
387
  'id' => 'ctc_preview',
388
- 'title' => __( 'Preview and Activate', $chld_thm_cfg->ns ),
389
  'content' => __( '
390
- <p>Click the Preview CSS tab to see your new masterpiece as CSS code. To preview the stylesheet as a WordPress theme follow these steps:</p>
391
  <ol><li>Navigate to Appearance > Themes in the WordPress Admin. You will now see the new Child Theme as one of the installed Themes.</li>
392
  <li>Click "Live Preview" below the new Child Theme to see it in action.</li>
393
  <li>When you are ready to take the Child Theme live, click "Activate."</li></ol>
394
- ', $chld_thm_cfg->ns
395
  ),
396
  ) );
397
 
398
  $screen->add_help_tab( array(
399
  'id' => 'ctc_faq',
400
- 'title' => __( 'FAQs', $chld_thm_cfg->ns ),
401
  'content' => __( '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  <h5 id="specific_color">How do I change a specific color/font style/background?</h5>
403
  <p>You can override a specific value globally using the Rule/Value tab. See Rule/Value, above.</p>
404
  <h5 id="add_styles">How do I add styles that aren\'t in the Parent Theme?</h5>
@@ -407,6 +690,8 @@ class Child_Theme_Configurator_UI {
407
  <p>You shouldn\'t really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.</p>
408
  <h5 id="remove_styles">How do I remove a style from the Child Theme?</h5>
409
  <p>Delete the value from the input for the rule you wish to remove. The Child Theme Configurator only adds overrides for rules that contain values.</p>
 
 
410
  <h5 id="gradients">How do I create cross-browser gradients?</h5>
411
  <p>The Child Theme Configurator automatically generates the vendor prefixes and filters to display gradients across most browsers. It uses a normalized syntax and only supports two colors without intermediate stops. The inputs consist of origin (e.g., top, left, 135deg, etc.), start color and end color. The browser-specific syntax is generated automatically when you save these values. <strong>Note:</strong> For Internet Explorer, a filter rule approximates the gradient but can only be horizontal (origin top) or vertical (origin left). The legacy webkit-gradient syntax is not supported.</p>
412
  <h5 id="responsive">How do I make my Theme responsive?</h5>
@@ -417,15 +702,15 @@ class Child_Theme_Configurator_UI {
417
  <h5 id="web_fonts">How do I add Web Fonts?</h5>
418
  <p>The easiest method is to paste the @import code provided by Google, Font Squirrel or any other Web Font site into the @import tab. The fonts will then be available to use as a value of the <strong>font-family</strong> rule. Be sure you understand the license for any embedded fonts.</p>
419
  <p>You can also create a secondary stylesheet that contains @font-face rules and import it using the @import tab. <strong>Note:</strong> Currently the Child Theme Configurator does not generate previews of imported web fonts, but will in a later release.</p>
420
- <h5 id="functions_file">Where is the functions.php file?</h5>
421
- <p>You can add your own functions.php file, and any other files and directories you need for your Child Theme. The Child Theme Configurator helps you identify and override the Parent stylesheet without touching the other files.</p>
422
- ', $chld_thm_cfg->ns
423
  ),
424
  ) );
425
 
426
  $screen->add_help_tab( array(
427
  'id' => 'ctc_glossary',
428
- 'title' => __( 'Glossary', $chld_thm_cfg->ns ),
429
  'content' => __( '
430
  <h3 id="terms">Glossary</h3>
431
  <ul><li id="parent_theme"><strong>Parent Theme</strong> The WordPress Theme you wish to edit. WordPress first loads the Child Theme, then loads the Parent Theme. If a style exists in the Child Theme, it overrides the Parent Theme.</li>
@@ -439,18 +724,22 @@ class Child_Theme_Configurator_UI {
439
  </ul></li>
440
  <li id="override"><strong>Override</strong> When a selector exists in both the Child Theme and the Parent Theme, the Child Theme takes priority over the Parent theme. This is where the Child Theme Configurator stands out: it helps you create <strong>exact overrides</strong> of selectors from the Parent Theme, eliminating hours of trial and error.</li>
441
  </ul>
442
- ', $chld_thm_cfg->ns
443
  ),
444
  ) );
445
 
446
  // Set help sidebar
447
  $screen->set_help_sidebar(
448
  '
 
 
449
  <ul>
450
- <li><a href="http://www.lilaeamedia.com/about/contact/">' . __( 'Contact us', $chld_thm_cfg->ns ) . '</a></li>
451
- <li><a href="http://www.lilaeamedia.com/plugins/child-theme-configurator">' . __( 'Plugin Website', $chld_thm_cfg->ns ) . '</a></li>
452
- <li><a href="http://codex.wordpress.org/Child_Themes">' . __( 'WordPress Codex', $chld_thm_cfg->ns ) . '</a></li>
453
- <li><a href="http://wordpress.stackexchange.com/">' . __( 'WordPress Answers', $chld_thm_cfg->ns ) . '</a></li>
 
 
454
  </ul>
455
  '
456
  );
1
  <?php
2
  // Exit if accessed directly
3
  if ( !defined('ABSPATH')) exit;
 
4
  /*
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.4.1
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
12
  Domain Path: /lang
13
  License: GPLv2
14
+ Copyright (C) 2014 Lilaea Media
15
  */
16
  class Child_Theme_Configurator_UI {
17
  var $swatch_text;
18
+ var $themes;
19
+ var $extLink;
20
+
21
  function __construct() {
22
+ $this->swatch_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
23
+ $this->extLink = '<a href="http://www.lilaeamedia.com/plugins/child-theme-configurator-plugins/" target="_blank" title="' . __('Easily customize your plugins with the CTC Plugin Extension', 'chld_thm_cfg') . '" style="float:right">' . __('Use this to customize your plugins', 'chld_thm_cfg') . '</a>';
24
  }
25
 
26
  function render_options() {
27
  global $chld_thm_cfg;
28
+ $css = $chld_thm_cfg->css;
29
+ $themes = $chld_thm_cfg->themes;
30
+ $parent = $css->get_prop('parnt');
31
+ $child = $css->get_prop('child');
32
+ $configtype = $css->get_prop('configtype');
33
+ $hidechild = (count($themes['child']) ? '' : 'style="display:none"');
34
+ $imports = $css->get_prop('imports');
35
+ $id = 0;
36
+ add_thickbox(); ?>
37
 
38
  <div class="wrap">
39
  <div id="icon-tools" class="icon32"></div>
40
+ <?php echo $this->extLink; ?>
41
  <h2><?php echo $chld_thm_cfg->pluginName; ?></h2>
42
+ <div id="ctc_error_notice">
43
+ <?php $this->settings_errors(); ?>
44
+ </div>
45
  <?php
46
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'parent_child_options';
47
  ?>
48
+ <h2 class="nav-tab-wrapper"><a id="parent_child_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=parent_child_options"
 
49
  class="nav-tab<?php echo 'parent_child_options' == $active_tab ? ' nav-tab-active' : ''; ?>">
50
+ <?php _e('Parent/Child', 'chld_thm_cfg'); ?>
51
+ </a><!----><a id="query_selector_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=query_selector_options"
52
+ class="nav-tab<?php echo 'query_selector_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
53
+ <?php _e('Query/Selector', 'chld_thm_cfg'); ?>
54
+ </a><!----><a id="rule_value_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=rule_value_options"
55
+ class="nav-tab<?php echo 'rule_value_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
56
+ <?php _e('Rule/Value', 'chld_thm_cfg'); ?>
57
+ </a><!----><a id="import_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=import_options"
58
+ class="nav-tab<?php echo 'import_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
59
+ <?php _e('@import', 'chld_thm_cfg'); ?>
60
+ </a><!----><a id="view_child_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=view_child_options"
61
+ class="nav-tab<?php echo 'view_child_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
62
+ <?php _e('Child CSS', 'chld_thm_cfg'); ?>
63
+ </a><!----><a id="view_parnt_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=view_parnt_options"
64
+ class="nav-tab<?php echo 'view_parnt_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
65
+ <?php _e('Parent CSS', 'chld_thm_cfg'); ?>
66
  </a>
67
+ <?php
68
+ if ('' == $hidechild && (empty($configtype) || 'theme' == $configtype)):
69
+ ?>
70
+ <a id="file_options" href="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=file_options"
71
+ class="nav-tab<?php echo 'file_options' == $active_tab ? ' nav-tab-active' : ''; ?>" <?php echo $hidechild; ?>>
72
+ <?php _e('Files', 'chld_thm_cfg'); ?>
 
 
 
 
 
73
  </a>
74
+ <?php
75
+ endif;
76
+ do_action('chld_thm_cfg_tabs', $chld_thm_cfg, $active_tab, $hidechild);?>
77
+ <i id="ctc_status_preview"></i></h2>
 
78
  <div class="ctc-option-panel-container">
79
  <div id="parent_child_options_panel" class="ctc-option-panel<?php echo 'parent_child_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>">
80
+ <form id="ctc_load_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>">
81
  <?php wp_nonce_field( 'ctc_update' ); ?>
82
+ <div class="ctc-input-row clearfix" id="input_row_parnt">
83
+ <div class="ctc-input-cell"> <strong>
84
+ <?php _e('Parent Theme', 'chld_thm_cfg'); ?>
85
+ </strong> </div>
 
 
86
  <div class="ctc-input-cell">
87
+ <select class="ctc-select" id="ctc_theme_parnt" name="ctc_theme_parnt">
88
+ <?php echo $chld_thm_cfg->render_menu('parnt', $parent); ?>
89
+ </select>
90
  </div>
91
  </div>
92
+ <div class="ctc-input-row clearfix" id="input_row_child">
93
+ <div class="ctc-input-cell"> <strong>
94
+ <?php _e('Child Theme', 'chld_thm_cfg'); ?>
95
+ </strong> </div>
96
  <div class="ctc-input-cell">
97
+ <input class="ctc-radio" id="ctc_child_type_new" name="ctc_child_type" type="radio" value="new"
98
+ <?php echo (!empty($hidechild) ? 'checked' : ''); ?>
99
+ <?php echo $hidechild;?> />
100
+ <label for="ctc_child_type_new">
101
+ <?php _e('Create New Child Theme', 'chld_thm_cfg'); ?>
102
  </label>
103
  </div>
104
  <div class="ctc-input-cell">
105
+ <input class="ctc-radio" id="ctc_child_type_existing" name="ctc_child_type" type="radio" value="existing"
106
+ <?php echo (empty($hidechild) ? 'checked' : ''); ?>
107
+ <?php echo $hidechild; ?>/>
108
+ &nbsp;
109
+ <label for="ctc_child_type_existing" <?php echo $hidechild;?>>
110
+ <?php _e('Use Existing Child Theme', 'chld_thm_cfg'); ?>
 
111
  </label>
112
  </div>
113
+ <div class="ctc-input-cell" style="clear:both"> <strong>&nbsp;</strong> </div>
114
+ <div class="ctc-input-cell" >
115
+ <input class="ctc_text" id="ctc_child_template" name="ctc_child_template" type="text" placeholder="<?php _e('Theme Slug', 'chld_thm_cfg'); ?>" autocomplete="off"/>
116
+ </div>
117
  <div class="ctc-input-cell">
118
+ <select class="ctc-select" id="ctc_theme_child" name="ctc_theme_child" <?php echo $hidechild; ?>>
119
+ <?php echo $chld_thm_cfg->render_menu('child', $child); ?>
120
+ </select>
121
  </div>
122
  </div>
123
  <div class="ctc-input-row clearfix" id="input_row_child_name">
124
+ <div class="ctc-input-cell"> <strong>
125
+ <?php _e('Child Theme Name', 'chld_thm_cfg'); ?>
126
+ </strong> </div>
127
  <div class="ctc-input-cell">
128
+ <input class="ctc_text" id="ctc_child_name" name="ctc_child_name" type="text"
129
+ value="<?php echo esc_attr($css->get_prop('child_name')); ?>" placeholder="<?php _e('Theme Name', 'chld_thm_cfg'); ?>" autocomplete="off" />
 
130
  </div>
131
+ </div>
132
+ <?php if ('' == $hidechild) do_action('chld_thm_cfg_controls', $chld_thm_cfg); ?>
133
+ <div class="ctc-input-row clearfix" id="input_row_child_template">
134
+ <div class="ctc-input-cell"> <strong>
135
+ <?php _e('Author', 'chld_thm_cfg'); ?>
136
+ </strong> </div>
137
  <div class="ctc-input-cell">
138
+ <input class="ctc_text" id="ctc_child_author" name="ctc_child_author" type="text"
139
+ value="<?php echo esc_attr($css->get_prop('author')); ?>" placeholder="<?php _e('Author', 'chld_thm_cfg'); ?>" autocomplete="off" />
140
  </div>
141
  </div>
142
  <div class="ctc-input-row clearfix" id="input_row_child_template">
143
+ <div class="ctc-input-cell"> <strong>
144
+ <?php _e('Version', 'chld_thm_cfg'); ?>
145
+ </strong> </div>
146
  <div class="ctc-input-cell">
147
+ <input class="ctc_text" id="ctc_child_version" name="ctc_child_version" type="text"
148
+ value="<?php echo esc_attr($css->get_prop('version')); ?>" placeholder="<?php _e('Version', 'chld_thm_cfg'); ?>" autocomplete="off" />
 
149
  </div>
150
+ </div>
151
+ <div class="ctc-input-row clearfix" id="input_row_child_template">
152
+ <div class="ctc-input-cell"> <strong>
153
+ <?php _e('Backup Stylesheet', 'chld_thm_cfg'); ?>
154
+ </strong> </div>
155
  <div class="ctc-input-cell">
156
+ <input class="ctc_checkbox" id="ctc_backup" name="ctc_backup" type="checkbox"
157
+ value="1" />
158
  </div>
159
  </div>
160
  <div class="ctc-input-row clearfix" id="input_row_child_template">
161
+ <div class="ctc-input-cell"> <strong>
162
+ <?php _e('Scan Parent Theme<br/>for Additional Stylesheets', 'chld_thm_cfg'); ?>
163
+ </strong> </div>
164
  <div class="ctc-input-cell">
165
+ <input class="ctc_checkbox" id="ctc_scan_subdirs" name="ctc_scan_subdirs" type="checkbox"
166
+ value="1" />
167
  </div>
168
+ </div>
169
+ <div class="ctc-input-row clearfix" id="input_row_child_template">
170
+ <div class="ctc-input-cell"> <strong>&nbsp;</strong> </div>
171
  <div class="ctc-input-cell">
172
+ <input class="ctc_submit button button-primary" id="ctc_load_styles" name="ctc_load_styles" type="submit"
173
+ value="<?php _e('Generate Child Theme Files', 'chld_thm_cfg'); ?>" disabled />
174
  </div>
175
  </div>
176
  </form>
177
  </div>
178
+ <div id="rule_value_options_panel"
179
+ class="ctc-option-panel<?php echo 'rule_value_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>>
180
+ <form id="ctc_rule_value_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=rule_value_options">
181
  <?php wp_nonce_field( 'ctc_update' ); ?>
182
  <div class="ctc-input-row clearfix" id="ctc_input_row_rule_menu">
183
  <div class="ctc-input-cell"> <strong>
184
+ <?php _e('Rule', 'chld_thm_cfg'); ?>
185
  </strong> </div>
186
  <div class="ctc-input-cell" id="ctc_rule_menu_selected">&nbsp;</div>
187
+ <div id="ctc_status_rule_val"></div>
188
  <div class="ctc-input-cell">
189
  <div class="ui-widget">
190
  <input id="ctc_rule_menu"/>
191
+ <div id="ctc_status_rule"></div>
192
  </div>
193
  </div>
194
  </div>
195
  <div class="ctc-input-row clearfix" id="ctc_input_row_rule_header" style="display:none">
196
  <div class="ctc-input-cell"> <strong>
197
+ <?php _e('Value', 'chld_thm_cfg'); ?>
198
  </strong> </div>
199
  <div class="ctc-input-cell"> <strong>
200
+ <?php _e('Sample', 'chld_thm_cfg'); ?>
201
  </strong> </div>
202
  <div class="ctc-input-cell"> <strong>
203
+ <?php _e('Selectors', 'chld_thm_cfg'); ?>
204
  </strong> </div>
205
  </div>
206
  <div class="ctc-rule-value-input-container clearfix" id="ctc_rule_value_inputs" style="display:none"> </div>
207
  </form>
208
  </div>
209
+ <div id="query_selector_options_panel"
210
+ class="ctc-option-panel<?php echo 'query_selector_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>>
211
+ <form id="ctc_query_selector_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=query_selector_options">
212
  <div class="ctc-input-row clearfix" id="input_row_query">
213
  <div class="ctc-input-cell"> <strong>
214
+ <?php _e('Query', 'chld_thm_cfg'); ?>
215
  </strong> </div>
216
  <div class="ctc-input-cell" id="ctc_sel_ovrd_query_selected">&nbsp;</div>
217
  <div class="ctc-input-cell">
218
  <div class="ui-widget">
219
+ <input id="ctc_sel_ovrd_query" />
220
  </div>
221
  </div>
222
  </div>
223
  <div class="ctc-input-row clearfix" id="input_row_selector">
224
  <div class="ctc-input-cell"> <strong>
225
+ <?php _e('Selector', 'chld_thm_cfg'); ?>
226
+ </strong> <a href="#" class="ctc-rewrite-toggle"></a></div>
227
  <div class="ctc-input-cell" id="ctc_sel_ovrd_selector_selected">&nbsp;</div>
228
  <div class="ctc-input-cell">
229
  <div class="ui-widget">
230
+ <input id="ctc_sel_ovrd_selector" />
231
+ <div id="ctc_status_sel_ndx"></div>
232
  </div>
233
  </div>
234
  </div>
235
  <div class="ctc-selector-row clearfix" id="ctc_sel_ovrd_rule_inputs_container" style="display:none">
236
  <div class="ctc-input-row clearfix">
237
  <div class="ctc-input-cell"><strong>
238
+ <?php _e('Sample', 'chld_thm_cfg'); ?>
239
  </strong></div>
240
  <div class="ctc-input-cell clearfix" style="max-height:150px;overflow:hidden">
241
  <div class="ctc-swatch" id="ctc_child_all_0_swatch"><?php echo $this->swatch_text; ?></div>
242
  </div>
243
+ <div id="ctc_status_sel_val"></div>
244
  <div class="ctc-input-cell ctc-button-cell" id="ctc_save_query_selector_cell">
245
+ <input type="button" class="button button-primary ctc-save-input" id="ctc_save_query_selector"
246
+ name="ctc_save_query_selector" value="<?php _e('Save', 'chld_thm_cfg'); ?>" disabled />
247
+ <input type="hidden" id="ctc_sel_ovrd_qsid"
248
+ name="ctc_sel_ovrd_qsid" value="" />
249
  </div>
250
  </div>
251
  <div class="ctc-input-row clearfix" id="ctc_sel_ovrd_rule_header" style="display:none">
252
  <div class="ctc-input-cell"> <strong>
253
+ <?php _e('Rule', 'chld_thm_cfg'); ?>
254
  </strong> </div>
255
  <div class="ctc-input-cell"> <strong>
256
+ <?php _e('Parent Value', 'chld_thm_cfg'); ?>
257
  </strong> </div>
258
  <div class="ctc-input-cell"> <strong>
259
+ <?php _e('Child Value', 'chld_thm_cfg'); ?>
260
  </strong> </div>
261
  </div>
262
  <div id="ctc_sel_ovrd_rule_inputs" style="display:none"> </div>
263
  <div class="ctc-input-row clearfix" id="ctc_sel_ovrd_new_rule" style="display:none">
264
+ <div class="ctc-input-cell"> <strong>
265
+ <?php _e('New Rule', 'chld_thm_cfg'); ?>
266
+ </strong> </div>
267
+ <div class="ctc-input-cell">
268
+ <div class="ui-widget">
269
+ <input id="ctc_new_rule_menu" />
270
+ </div>
271
  </div>
272
  </div>
273
+ <div class="ctc-input-row clearfix" id="input_row_selector">
 
 
274
  <div class="ctc-input-cell"> <strong>
275
+ <?php _e('Order', 'chld_thm_cfg'); ?>
276
+ </strong> </div>
277
+ <div class="ctc-input-cell" id="ctc_child_load_order_container">&nbsp;</div>
 
 
 
 
 
278
  </div>
279
+ </div>
280
+ <div class="ctc-selector-row clearfix" id="ctc_new_selector_row">
281
+ <div class="ctc-input-cell"> <strong>
282
+ <?php _e('Raw CSS', 'chld_thm_cfg'); ?>
283
+ </strong>
284
+ <div class="ctc-textarea-button-cell" id="ctc_save_query_selector_cell">
285
+ <input type="button" class="button ctc-save-input" id="ctc_save_new_selectors"
286
+ name="ctc_save_new_selectors" value="<?php _e('Save', 'chld_thm_cfg'); ?>" disabled />
287
+ </div>
288
+ </div>
289
+ <div class="ctc-input-cell-wide">
290
+ <textarea id="ctc_new_selectors" name="ctc_new_selectors" wrap="off"></textarea>
291
+ </div>
292
+ </div>
293
  </form>
294
  </div>
295
+ <div id="import_options_panel"
296
+ class="ctc-option-panel<?php echo 'import_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>>
297
+ <form id="ctc_import_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=import_options">
298
  <?php wp_nonce_field( 'ctc_update' ); ?>
299
+ <div class="ctc-input-row clearfix" id="ctc_child_imports_row">
300
+ <div class="ctc-input-cell"> <strong>
301
+ <?php _e('@import Statements', 'chld_thm_cfg'); ?>
302
+ </strong>
303
+ <div class="ctc-textarea-button-cell" id="ctc_save_imports_cell">
304
+ <input type="button" class="button ctc-save-input" id="ctc_save_imports"
305
+ name="ctc_save_imports" value="<?php _e('Save', 'chld_thm_cfg'); ?>" disabled />
 
306
  </div>
307
+ </div>
308
+ <div class="ctc-input-cell-wide">
309
+ <textarea id="ctc_child_imports" name="ctc_child_imports" wrap="off">
310
+ <?php if (!empty($imports)):
311
+ foreach ($imports as $import):
312
  echo esc_textarea($import . ';' . LF);
313
+ endforeach; endif;?>
314
+ </textarea>
315
  </div>
316
+ </div>
317
  </form>
318
  </div>
319
+ <div id="view_child_options_panel"
320
+ class="ctc-option-panel<?php echo 'view_child_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>> </div>
321
+ <div id="view_parnt_options_panel"
322
+ class="ctc-option-panel<?php echo 'view_parnt_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>> </div>
323
+ <?php if ('' == $hidechild && (empty($configtype) || 'theme' == $configtype)): ?>
324
+ <div id="file_options_panel"
325
+ class="ctc-option-panel<?php echo 'file_options' == $active_tab ? ' ctc-option-panel-active' : ''; ?>" <?php echo $hidechild; ?>>
326
+ <?php $this->render_file_form('parnt'); ?>
327
+ <?php $this->render_file_form('child'); ?>
328
+ <?php $this->render_image_form(); ?>
329
+ <div class="ctc-input-row clearfix" id="input_row_theme_image">
330
+ <form id="ctc_<?php echo $template; ?>_theme_image_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=file_options" enctype="multipart/form-data">
331
+ <?php wp_nonce_field( 'ctc_update' ); ?>
332
+ <div class="ctc-input-cell"> <strong>
333
+ <?php _e('Upload New Child Theme Image', 'chld_thm_cfg'); ?>
334
+ </strong>
335
+ <p class="howto">
336
+ <?php _e('Theme images reside under the <code>images</code> directory in your child theme and are meant for stylesheet use only. Use the Media Library for content images.', 'chld_thm_cfg'); ?>
337
+ </p>
338
+ </div>
339
+ <div class="ctc-input-cell-wide">
340
+ <input type="file" id="ctc_theme_image" name="ctc_theme_image" value="" />
341
+ <input class="ctc_submit button button-primary" id="ctc_theme_image_submit"
342
+ name="ctc_theme_image_submit" type="submit"
343
+ value="<?php _e('Upload', 'chld_thm_cfg'); ?>" />
344
+ </div>
345
+ </form>
346
+ </div>
347
+ <?php if ($screenshot = $this->get_theme_screenshot()): ?>
348
+ <div class="ctc-input-row clearfix" id="input_row_screenshot_view">
349
+ <div class="ctc-input-cell"> <strong>
350
+ <?php _e('Child Theme Screenshot', 'chld_thm_cfg'); ?>
351
+ </strong> </div>
352
+ <div class="ctc-input-cell-wide"> <a href="<?php echo $screenshot; ?>" class="thickbox"><img src="<?php echo $screenshot; ?>" height="150" width="200" style="max-height:150px;max-width:200px;width:auto;height:auto" /></a> </div>
353
+ </div>
354
+ <?php endif; ?>
355
+ <div class="ctc-input-row clearfix" id="input_row_screenshot">
356
+ <form id="ctc_screenshot_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=file_options" enctype="multipart/form-data">
357
+ <?php wp_nonce_field( 'ctc_update' ); ?>
358
+ <div class="ctc-input-cell"> <strong>
359
+ <?php _e('Upload New Screenshot', 'chld_thm_cfg'); ?>
360
+ </strong>
361
+ <p class="howto">
362
+ <?php _e('The theme screenshot should be a 4:3 ratio (e.g., 880px x 660px) JPG, PNG or GIF. It will be renamed <code>screenshot</code>.', 'chld_thm_cfg'); ?>
363
+ </p>
364
+ </div>
365
+ <div class="ctc-input-cell-wide">
366
+ <input type="file" id="ctc_theme_screenshot" name="ctc_theme_screenshot" value="" />
367
+ <input class="ctc_submit button button-primary" id="ctc_theme_screenshot_submit"
368
+ name="ctc_theme_screenshot_submit" type="submit"
369
+ value="<?php _e('Upload', 'chld_thm_cfg'); ?>" />
370
+ </div>
371
+ </form>
372
+ </div>
373
  </div>
374
+ <?php endif; ?>
375
+ <?php do_action('chld_thm_cfg_panels', $chld_thm_cfg, $active_tab, $hidechild); ?>
376
  </div>
377
  </div>
378
  <style type="text/css">
398
  <?php
399
  }
400
 
401
+ function render_file_form($template = 'parnt') {
402
+ global $chld_thm_cfg;
403
+ if ($theme = $chld_thm_cfg->css->get_prop($template)):
404
+ $themeroot = get_theme_root() . '/' . $theme;
405
+ $files = $chld_thm_cfg->css->recurse_directory($themeroot, 'php');
406
+ $counter = 0;
407
+ sort($files);
408
+ ob_start();
409
+ foreach ($files as $file):
410
+ $templatefile = preg_replace('%(^' . preg_quote($themeroot) . '\/|\.php$)%', '', $file);
411
+ if (preg_match('%^(inc|core|lang|css|js)%',$templatefile) || 'functions' == basename($templatefile)) continue; ?>
412
+ <label class="ctc-input-cell smaller">
413
+ <input class="ctc_checkbox" id="ctc_file_<?php echo $template . '_' . ++$counter; ?>"
414
+ name="ctc_file_<?php echo $template; ?>[]" type="checkbox"
415
+ value="<?php echo $templatefile; ?>" />
416
+ <?php echo $templatefile; ?></label>
417
+ <?php
418
+ endforeach;
419
+ $linktext = __('Click here to edit template files using the Theme Editor', 'chld_thm_cfg');
420
+ $editorlink = '<a href="' . admin_url('theme-editor.php?file=functions.php&theme=' . $chld_thm_cfg->css->get_prop('child')) . '" title="' . $linktext . '">';
421
+ $editorlinkend = '</a>';
422
+ if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT):
423
+ $linktext = __('The Theme editor has been disabled. Template files must be edited offline.', 'chld_thm_cfg');
424
+ $editorlink = '';
425
+ $editorlinkend = '';
426
+ endif;
427
+ $inputs = ob_get_contents();
428
+ ob_end_clean();
429
+ if ($counter): ?>
430
+ <div class="ctc-input-row clearfix" id="input_row_<?php echo $template; ?>_templates">
431
+ <form id="ctc_<?php echo $template; ?>_templates_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=file_options">
432
+ <?php wp_nonce_field( 'ctc_update' ); ?>
433
+ <div class="ctc-input-cell"> <strong>
434
+ <?php _e(('parnt' == $template ? 'Parent' : 'Child') . ' Templates', 'chld_thm_cfg'); ?>
435
+ </strong>
436
+ <p class="howto">
437
+ <?php if ('parnt' == $template):
438
+ _e('Copy PHP template files from the parent theme by selecting them here.', 'chld_thm_cfg');?>
439
+ </p>
440
+ <p><strong>
441
+ <?php _e('CAUTION: If your child theme is active, the child theme version of the file will be used instead of the parent immediately after it is copied.', 'chld_thm_cfg');?>
442
+ </strong></p>
443
+ <p class="howto">
444
+ <?php echo sprintf(__('The %s file is generated separately and cannot be copied here.', 'chld_thm_cfg'),
445
+ $editorlink . '<code>functions.php</code>' . $editorlinkend
446
+ );
447
+ else:
448
+ echo $editorlink . $linktext . $editorlinkend; ?></p>
449
+ <p class="howto">
450
+ <?php _e('Remove child theme templates by selecting them here.', 'chld_thm_cfg');
451
+ endif; ?>
452
+ </p>
453
+ </div>
454
+ <div class="ctc-input-cell-wide"> <?php echo $inputs; ?> </div>
455
+ <div class="ctc-input-cell"> <strong>&nbsp;</strong> </div>
456
+ <div class="ctc-input-cell-wide" style="margin-top:10px;margin-bottom:10px">
457
+ <input class="ctc_submit button button-primary" id="ctc_<?php echo $template; ?>_templates_submit"
458
+ name="ctc_<?php echo $template; ?>_templates_submit" type="submit"
459
+ value="<?php echo ('parnt' == $template ? __('Copy Selected to Child Theme', 'chld_thm_cfg') : __('Remove Selected from Child Theme', 'chld_thm_cfg')); ?>" />
460
+ </div>
461
+ </form>
462
+ </div>
463
+ <?php
464
+ endif;
465
  endif;
466
+ }
467
+
468
+ function render_image_form() {
469
+ global $chld_thm_cfg;
470
+ if ($theme = $chld_thm_cfg->css->get_prop('child')):
471
+ $themeroot = get_theme_root() . '/' . $theme . '/images';
472
+ $themeuri = get_theme_root_uri() . '/' . $theme . '/images/';
473
+ $files = $chld_thm_cfg->css->recurse_directory($themeroot, 'img');
474
+ $counter = 0;
475
+ sort($files);
476
+ ob_start();
477
+ foreach ($files as $file):
478
+ $templatefile = preg_replace('%^' . preg_quote($themeroot) . '/%', '', $file); ?>
479
+ <div class="ctc-input-cell" style="height:100px">
480
+ <label class="smaller">
481
+ <input class="ctc_checkbox" id="ctc_img_<?php echo ++$counter; ?>"
482
+ name="ctc_img[]" type="checkbox"
483
+ value="<?php echo $templatefile; ?>" />
484
+ <?php echo $templatefile; ?></label>
485
+ <br/>
486
+ <a href="<?php echo $themeuri . $templatefile . '?' . time(); ?>" class="thickbox"><img src="<?php echo $themeuri . $templatefile . '?' . time(); ?>" height="72" width="72" style="max-height:72px;max-width:100%;width:auto;height:auto" /></a></div>
487
+ <?php
488
+ endforeach;
489
+ $inputs = ob_get_contents();
490
+ ob_end_clean();
491
+ if ($counter): ?>
492
+ <div class="ctc-input-row clearfix" id="input_row_images">
493
+ <form id="ctc_image_form" method="post" action="?page=<?php echo $chld_thm_cfg->menuName; ?>&amp;tab=file_options">
494
+ <?php wp_nonce_field( 'ctc_update' ); ?>
495
+ <div class="ctc-input-cell"> <strong>
496
+ <?php _e('Child Theme Images', 'chld_thm_cfg'); ?>
497
+ </strong>
498
+ <p class="howto">
499
+ <?php _e('Remove child theme images by selecting them here.', 'chld_thm_cfg');?>
500
+ </p>
501
+ </div>
502
+ <div class="ctc-input-cell-wide"> <?php echo $inputs; ?> </div>
503
+ <div class="ctc-input-cell"> <strong>&nbsp;</strong> </div>
504
+ <div class="ctc-input-cell-wide" style="margin-top:10px;margin-bottom:10px">
505
+ <input class="ctc_submit button button-primary" id="ctc_image_submit"
506
+ name="ctc_image_submit" type="submit"
507
+ value="<?php _e('Remove Selected', 'chld_thm_cfg'); ?>" disabled />
508
+ </div>
509
+ </form>
510
+ </div>
511
+ <?php
512
+ endif;
513
+ endif;
514
+ }
515
+
516
+ function get_theme_screenshot() {
517
+ global $chld_thm_cfg;
518
+ foreach ($chld_thm_cfg->image_formats as $ext):
519
+ if ($screenshot = $chld_thm_cfg->css->is_file_ok($chld_thm_cfg->css->get_child_target('screenshot.' . $ext))):
520
+ $screenshot = preg_replace('%^' . preg_quote(get_theme_root()) . '%', get_theme_root_uri(), $screenshot);
521
+ return $screenshot . '?' . time();
522
  endif;
523
  endforeach;
524
+ return false;
525
  }
526
 
527
  function settings_errors() {
533
  endforeach;
534
  echo '</ul></div>' . LF;
535
  elseif (isset($_GET['updated'])):
536
+ echo '<div class="updated">' . LF;
537
+ if ( 8 == $_GET['updated']):
538
+ echo '<p>' . __('Child Theme files modified successfully.', 'chld_thm_cfg') . '</p>' . LF;
539
+ else:
540
+ echo '<p>' . apply_filters('chld_thm_cfg_update_msg', sprintf(__('Child Theme <strong>%s</strong> has been generated successfully.', 'chld_thm_cfg'),
541
+ $chld_thm_cfg->css->get_prop('child_name')), $chld_thm_cfg) . LF
542
+ . '</p>';
543
+ endif;
544
+ if ( 9 == $_GET['updated']) echo '<p>' . __('Please verify the imports below and remove any imports that are not needed by the front end, such as admin or configuration stylesheets.', 'chld_thm_cfg') . '</p>' . LF;
545
+ echo '</div>' . LF;
546
  endif;
547
  }
548
 
555
  if ( $screen->id != $chld_thm_cfg->hook )
556
  return;
557
  // Add help tabs
558
+
559
+ $screen->add_help_tab( array(
560
+ 'id' => 'ctc_tutorial',
561
+ 'title' => __( 'Tutorial Video', 'chld_thm_cfg' ),
562
+ 'content' => __('<iframe width="480" height="270" src="//www.youtube.com/embed/xL2HkWQxgOA?rel=0&modestbranding=1" frameborder="0" allowfullscreen></iframe>', 'chld_thm_cfg'),
563
+ ) );
564
+
565
+
566
  $screen->add_help_tab( array(
567
  'id' => 'ctc_getting_started',
568
+ 'title' => __( 'Start Here', 'chld_thm_cfg' ),
569
  'content' => __( '
570
  <p>The first step is to create a child theme and import your parent theme styles into the configurator.</p>
571
  <ol><li>Select an existing parent theme from the menu.</li>
572
+ <li>Select "New" or "Existing" child theme.
573
+ <ul><li>If creating a new theme, enter a "slug" (lower case, no spaces). This is used to name the theme directory and identify the theme to WordPress.</li>
574
+ <li>If using an existing theme, select a child theme from the menu.</li></ul></li>
575
+ <li>Enter a Name for the child theme.</li>
576
  <li>Enter an author for the child theme.</li>
577
+ <li>Enter the child theme version number.</li>
578
+ <li>If your theme uses multiple stylesheets, check "Scan Parent Theme for additional stylesheets.</li>
579
+ <li>Click "Generate Child Theme." If you are loading an existing child theme, The Child Theme Configurator will create a backup of your existing stylesheet in the theme directory.</li></ol>
580
+ ', 'chld_thm_cfg'
581
  ),
582
  ) );
583
 
584
  $screen->add_help_tab( array(
585
  'id' => 'ctc_query_selector',
586
+ 'title' => __( 'Query/Selector', 'chld_thm_cfg' ),
587
  'content' => __( '
588
  <p>There are two ways to identify and override parent styles. The Child Theme Configurator lets you search styles by <strong>selector</strong> and by <strong>rule</strong>. If you wish to change a specific selector (e.g., h1), use the "Query/Selector" tab. If you have a specific value you wish to change site-wide (e.g., the color of the type), use the "Rule/Value" tab.</p>
589
  <p>The Query/Selector tab lets you find specific selectors and edit them. First, find the query that contains the selector you wish to edit by typing in the <strong>Query</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys. Selectors are in the <strong>base</strong> query by default.</p>
590
  <p>Next, find the selector by typing in the <strong>Selector</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys.</p>
591
  <p>This will load all of the rules for that selector with the Parent values on the left and the Child values inputs on the right. Any existing child values will be automatically populated. There is also a Sample preview that displays the combination of Parent and Child overrides. Note that the <strong>border</strong> and <strong>background-image</strong> get special treatment.</p>
592
+ <p>The "Order" field contains the original sequence of the selector in the parent theme stylesheet. You can change the selector order sequence by entering a lower or higher number in the "Order" field. You can also force style overrides (so called "!important" flag) by checking the "!" box next to each input. Please use judiciously.</p>
593
  <p>Click "Save" to update the child stylesheet and save your changes to the WordPress admin.</p>
594
+ ', 'chld_thm_cfg'
595
  ),
596
  ) );
597
 
598
  $screen->add_help_tab( array(
599
  'id' => 'ctc_rule_value',
600
+ 'title' => __( 'Rule/Value', 'chld_thm_cfg' ),
601
  'content' => __( '
602
  <p>There are two ways to identify and override parent styles. The Child Theme Configurator lets you search styles by <strong>selector</strong> and by <strong>rule</strong>. If you wish to change a specific selector (e.g., h1), use the "Query/Selector" tab. If you have a specific value you wish to change site-wide (e.g., the color of the type), use the "Rule/Value" tab.</p>
603
  <p>The Rule/Value tab lets you find specific values for a given rule and then edit that value for individual selectors that use that rule/value combination. First, find the rule you wish to override by typing in the <strong>Rule</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys.</p>
604
  <p>This will load all of the unique values that exist for that rule in the parent stylesheet with a Sample preview for that value. If there are values that exist in the child stylesheet that do not exist in the parent stylesheet, they will be displayed as well.</p>
605
  <p>For each unique value, click the "Selectors" link to view a list of selectors that use that rule/value combination, grouped by query with a Sample preview of the value and inputs for the child value. Any existing child values will be automatically populated.</p>
606
  <p>Click "Save" to update the child stylesheet and save your changes to the WordPress admin.</p>
607
+ ', 'chld_thm_cfg'
608
  ),
609
  ) );
610
 
611
  $screen->add_help_tab( array(
612
  'id' => 'ctc_new_styles',
613
+ 'title' => __( 'Add New Styles', 'chld_thm_cfg' ),
614
  'content' => __( '
615
  <p>If you wish to add additional rules to a given selector, first load the selector using the Query/Selector tab. Then find the rule you wish to override by typing in the <strong>New Rule</strong> autoselect box. Select by clicking with the mouse or by pressing the "Enter" or "Tab" keys. This will add a new input row to the selector inputs.</p>
616
  <p>If you wish to add completely new selectors, or even new @media queries, you can enter free-form CSS in the "New Selector" textarea. Be aware that your syntax must be correct (i.e., balanced curly braces, etc.) for the parser to load the new styles. You will know it is invalid because a red "X" will appear next to the save button.</p>
617
  <p>If you prefer to use shorthand syntax for rules and values instead of the inputs provided by the Child Theme Configurator, you can enter them here as well. The parser will convert your input into normalized CSS code automatically.</p>
618
+ ', 'chld_thm_cfg'
619
  ),
620
  ) );
621
 
622
  $screen->add_help_tab( array(
623
  'id' => 'ctc_imports',
624
+ 'title' => __( '@imports', 'chld_thm_cfg' ),
625
  'content' => __( '
626
  <p>You can add additional stylesheets and web fonts by typing @import rules into the textarea on the @import tab. <strong>Important: The Child Theme Configurator adds the @import rule that loads the Parent Theme\'s stylesheet automatically. Do not need to add it here.</strong></p>
627
+ <p><strong>Important:</strong> If you chose "Scan Parent Theme for additional stylesheets," the Child Theme Configurator automically places @import rules for the additional stylesheets here. Be sure to delete any imports that are not needed by the front end, such as admin or configuration stylesheets.</p>
628
  <p>Below is an example that loads a local custom stylesheet (you would have to add the "fonts" directory and stylesheet) as well as the web font "Open Sans" from Google Web Fonts:</p>
629
  <blockquote><pre><code>
630
  @import url(fonts/stylesheet.css);
631
  @import url(http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic);
632
  </code></pre></blockquote>
633
+ ', 'chld_thm_cfg'
634
+ ),
635
+ ) );
636
+
637
+ $screen->add_help_tab( array(
638
+ 'id' => 'ctc_files',
639
+ 'title' => __( 'Files', 'chld_thm_cfg' ),
640
+ 'content' => __( '
641
+ <h5>Parent Templates</h5><p>Copy PHP template files from the parent theme by checking the boxes and clicking "Copy Selected to Child Theme" and the templates will be added to the child theme directory.</p>
642
+ <p><strong>CAUTION: If your child theme is active, the child theme version of the file will be used instead of the parent immediately after it is copied.</strong></p>
643
+ <p>The <code>functions.php</code> file is generated separately and cannot be copied here.</p>
644
+ <h5>Child Templates</h5><p>Templates copied from the parent are listed here. These can be edited using the Theme Editor in the Appearance Menu.</p>
645
+ <p>Remove child theme images by checking the boxes and clicking "Remove Selected from Child Theme."</p>
646
+ <h5>Child Theme Images</h5><p>Theme images reside under the <code>images</code> directory in your child theme and are meant for stylesheet use only. Use the media gallery for content images.</p>
647
+ <p>You can upload new images using the image upload form.</p>
648
+ <h5>Child Theme Screenshot</h5><p>You can upload a custom screenshot for the child theme here.</p>
649
+ <p>The theme screenshot should be a 4:3 ratio (eg., 880px x 660px) JPG, PNG or GIF. It will be renamed <code>screenshot</code>.</p>
650
+ ', 'chld_thm_cfg'
651
  ),
652
  ) );
653
 
654
  $screen->add_help_tab( array(
655
  'id' => 'ctc_preview',
656
+ 'title' => __( 'Preview and Activate', 'chld_thm_cfg' ),
657
  'content' => __( '
658
+ <p>Click the Child or Parent CSS tab to reference the stylesheet code. To preview the stylesheet as a WordPress theme follow these steps:</p>
659
  <ol><li>Navigate to Appearance > Themes in the WordPress Admin. You will now see the new Child Theme as one of the installed Themes.</li>
660
  <li>Click "Live Preview" below the new Child Theme to see it in action.</li>
661
  <li>When you are ready to take the Child Theme live, click "Activate."</li></ol>
662
+ ', 'chld_thm_cfg'
663
  ),
664
  ) );
665
 
666
  $screen->add_help_tab( array(
667
  'id' => 'ctc_faq',
668
+ 'title' => __( 'FAQs', 'chld_thm_cfg' ),
669
  'content' => __( '
670
+ <h5>Does it work with Plugins?</h5>
671
+ <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>
672
+ <h5 id="doesnt_work">Why doesn’t this work with my (insert theme vendor here) theme?</h5>
673
+ <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>
674
+ <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>
675
+ <h5>Can I edit the Child Theme stylesheet manually offline or by using the Editor or do I have to use the Configurator?</h5>
676
+ <p>You can make any manual changes you wish to the stylesheet. Just make sure you import the revised stylesheet using the Parent/Child panel or the Configurator will overwrite your changes the next time you use it. Just follow the steps as usual but select the "Use Existing Child Theme" radio button as the "Child Theme" option. The Configurator will automatically update its internal data from the new stylesheet.</p>
677
+ <h5>Why doesn\'t the Parent Theme have any styles when I "View Parent CSS"?</h5>
678
+ <p>Your Parent theme is probably using a non-standard location for the stylesheets. Check "Scan Parent Theme for additional stylesheets" on the Parent/Child tab and load the Child Theme again.</p>
679
+ <h5>Why is everything backwards?</h5>
680
+ <p>More than likely you selected "Scan Parent Theme for additional stylesheets" and your theme uses a "right-to-left" (rtl) stylesheet. Go to the @imports tab and remove the rtl stylesheet from the list of imported stylesheets.</p>
681
+ <h5 id="menus-broken">Why are my menus displaying incorrectly when I activate the new child theme?</h5>
682
+ <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>
683
+ <h5 "preview-not-loading">Why do the preview tabs return "Stylesheet could not be displayed"?</h5>
684
+ <p>You have to configure at least one child theme from the Parent/Child tab for the preview to display.</p>
685
  <h5 id="specific_color">How do I change a specific color/font style/background?</h5>
686
  <p>You can override a specific value globally using the Rule/Value tab. See Rule/Value, above.</p>
687
  <h5 id="add_styles">How do I add styles that aren\'t in the Parent Theme?</h5>
690
  <p>You shouldn\'t really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.</p>
691
  <h5 id="remove_styles">How do I remove a style from the Child Theme?</h5>
692
  <p>Delete the value from the input for the rule you wish to remove. The Child Theme Configurator only adds overrides for rules that contain values.</p>
693
+ <h5 id="important_flag">How do I set the !important flag?</h5>
694
+ <p>We always recommend relying on good cascading design over global overrides. To that end, you have ability to change the load order of child theme styles by entering a value in the "Order" field. And yes, you can now set rules as important by checking the "!" box next to each input. Please use judiciously.</p>
695
  <h5 id="gradients">How do I create cross-browser gradients?</h5>
696
  <p>The Child Theme Configurator automatically generates the vendor prefixes and filters to display gradients across most browsers. It uses a normalized syntax and only supports two colors without intermediate stops. The inputs consist of origin (e.g., top, left, 135deg, etc.), start color and end color. The browser-specific syntax is generated automatically when you save these values. <strong>Note:</strong> For Internet Explorer, a filter rule approximates the gradient but can only be horizontal (origin top) or vertical (origin left). The legacy webkit-gradient syntax is not supported.</p>
697
  <h5 id="responsive">How do I make my Theme responsive?</h5>
702
  <h5 id="web_fonts">How do I add Web Fonts?</h5>
703
  <p>The easiest method is to paste the @import code provided by Google, Font Squirrel or any other Web Font site into the @import tab. The fonts will then be available to use as a value of the <strong>font-family</strong> rule. Be sure you understand the license for any embedded fonts.</p>
704
  <p>You can also create a secondary stylesheet that contains @font-face rules and import it using the @import tab. <strong>Note:</strong> Currently the Child Theme Configurator does not generate previews of imported web fonts, but will in a later release.</p>
705
+ <h5 id="functions_file">Where are the PHP files?</h5>
706
+ <p>The configurator automatically adds a blank functions.php file to the child theme directory. Other parent theme files can be copied using the "Files" tab. Theme images and a custom screenshot can be uploaded there as well.</p>
707
+ ', 'chld_thm_cfg'
708
  ),
709
  ) );
710
 
711
  $screen->add_help_tab( array(
712
  'id' => 'ctc_glossary',
713
+ 'title' => __( 'Glossary', 'chld_thm_cfg' ),
714
  'content' => __( '
715
  <h3 id="terms">Glossary</h3>
716
  <ul><li id="parent_theme"><strong>Parent Theme</strong> The WordPress Theme you wish to edit. WordPress first loads the Child Theme, then loads the Parent Theme. If a style exists in the Child Theme, it overrides the Parent Theme.</li>
724
  </ul></li>
725
  <li id="override"><strong>Override</strong> When a selector exists in both the Child Theme and the Parent Theme, the Child Theme takes priority over the Parent theme. This is where the Child Theme Configurator stands out: it helps you create <strong>exact overrides</strong> of selectors from the Parent Theme, eliminating hours of trial and error.</li>
726
  </ul>
727
+ ', 'chld_thm_cfg'
728
  ),
729
  ) );
730
 
731
  // Set help sidebar
732
  $screen->set_help_sidebar(
733
  '
734
+ <h4>Now it works with plugins, too!</h4>
735
+ <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>
736
  <ul>
737
+ <li><a href="http://www.lilaeamedia.com/about/contact/">' . __( 'Contact us', 'chld_thm_cfg' ) . '</a></li>
738
+ <li><a href="http://www.lilaeamedia.com/plugins/child-theme-configurator">' . __( 'Plugin Website', 'chld_thm_cfg' ) . '</a></li>
739
+ <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8QE5YJ8WE96AJ">' . __( 'Donate', 'chld_thm_cfg' ) . '</a></li>
740
+ <li><a href="http://wordpress.org/support/view/plugin-reviews/child-theme-configurator?rate=5#postform">' . __( 'Give Us 5 Stars', 'chld_thm_cfg' ) . '</a></li>
741
+ <li><a href="http://codex.wordpress.org/Child_Themes">' . __( 'WordPress Codex', 'chld_thm_cfg' ) . '</a></li>
742
+ <li><a href="http://wordpress.stackexchange.com/">' . __( 'WordPress Answers', 'chld_thm_cfg' ) . '</a></li>
743
  </ul>
744
  '
745
  );
includes/class-ctc.php CHANGED
@@ -6,19 +6,18 @@ 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.0
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
- Copyright (C) 2013 Lilaea Media
16
  */
17
  require_once('class-ctc-ui.php');
18
  require_once('class-ctc-css.php');
19
  class Child_Theme_Configurator {
20
 
21
- var $version = '1.0';
22
  var $css;
23
  var $optionsName;
24
  var $menuName;
@@ -27,29 +26,34 @@ class Child_Theme_Configurator {
27
  var $shortName;
28
  var $ns;
29
  var $ui;
 
30
  var $errors;
31
  var $hook;
32
  var $is_ajax;
33
-
 
 
34
  function __construct($file) {
35
  $this->dir = dirname( $file );
36
- $this->ns = CHLD_THM_CFG_NS;
37
- $this->optionsName = $this->ns . '_options';
38
- $this->menuName = $this->ns . '_menu';
39
-
40
- $lang_dir = $this->dir . '/lang';
41
- load_plugin_textdomain($this->ns, false, $lang_dir, $lang_dir);
42
 
43
- $this->pluginName = __('Child Theme Configurator', $this->ns);
44
- $this->shortName = __('Child Themes', $this->ns);
45
- $this->pluginPath = $this->dir . '/';
46
- $this->pluginURL = plugin_dir_url($file);
 
47
 
48
  // setup plugin hooks
49
- add_action('admin_menu', array(&$this, 'admin_menu'));
50
- add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
51
- add_action('wp_ajax_ctc_update', array(&$this, 'ajax_save_postdata' ));
52
- add_action('update_option_' . $this->optionsName, array(&$this, 'update_redirect'), 10);
 
 
 
53
  }
54
 
55
  function admin_menu() {
@@ -63,36 +67,50 @@ class Child_Theme_Configurator {
63
  if ($this->hook == $hook):
64
  wp_enqueue_style('chld-thm-cfg-admin', $this->pluginURL . 'css/chld-thm-cfg.css');
65
  wp_enqueue_script('iris');
 
66
  wp_enqueue_script('ctc-thm-cfg-ctcgrad', $this->pluginURL . 'js/ctcgrad.min.js', array('iris'), '1.0');
67
- wp_enqueue_script('chld-thm-cfg-admin', $this->pluginURL . 'js/chld-thm-cfg.min.js',
68
  array('jquery-ui-autocomplete'), '1.0', true);
69
  wp_localize_script( 'chld-thm-cfg-admin', 'ctcAjax',
70
- apply_filters('ctc_localize_script', array(
71
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
72
- 'theme_uri' => get_theme_root_uri(),
73
- 'load_msg' => __('Are you sure? This will replace your current settings.', $this->ns),
74
- 'parent_theme' => $this->css->get_property('parent_theme'),
75
- 'child_theme' => $this->css->get_property('child_theme'),
76
- 'data' => $this->css->get_property('data'),
77
- 'imports' => $this->css->get_property('imports'),
78
- 'sel_ndx' => $this->css->get_property('sel_ndx'),
79
- 'val_ndx' => $this->css->get_property('val_ndx'),
80
- 'labels' => array(
81
- '_background_url' => __('URL/None', $this->ns),
82
- '_background_origin' => __('Origin', $this->ns),
83
- '_background_color1' => __('Color 1', $this->ns),
84
- '_background_color2' => __('Color 2', $this->ns),
85
- '_border_width' => __('Width', $this->ns),
86
- '_border_style' => __('Style', $this->ns),
87
- '_border_color' => __('Color', $this->ns),
 
 
 
 
 
 
88
  ),
89
- 'swatch_text' => $this->ui->swatch_text,
90
- 'swatch_label' => __('Sample', $this->ns),
91
- 'selector_text' => __('Selectors', $this->ns),
92
- 'close_text' => __('Close', $this->ns),
93
- 'new_query' => __('New Query', $this->ns),
94
- 'new_selector' => __('New Selector', $this->ns),
95
- 'css_fail' => __('The stylesheet cannot be displayed.', $this->ns),
 
 
 
 
 
 
 
96
  )));
97
  endif;
98
  }
@@ -102,95 +120,343 @@ class Child_Theme_Configurator {
102
  }
103
 
104
  function ctc_page_init () {
105
- $this->load_css();
 
 
 
106
  $this->ui = new Child_Theme_Configurator_UI();
107
  $this->ui->render_help_tabs();
108
- $this->handle_inputs();
109
  }
110
- function load_css() {
111
- if (!($this->css = get_option($this->optionsName)))
112
- $this->css = new Child_Theme_Configurator_CSS();
 
 
 
 
 
 
 
 
 
 
113
  }
114
- function validate_post() {
 
115
  return ('POST' == $_SERVER['REQUEST_METHOD']
116
  && current_user_can('edit_theme_options')
117
- && ($this->is_ajax ? check_ajax_referer( 'ctc_update', '_wpnonce', false ) : check_admin_referer( 'ctc_update', '_wpnonce', false )));
118
  }
119
 
120
  function ajax_save_postdata() {
121
  $this->is_ajax = true;
122
  if ($this->validate_post()):
123
- $this->load_css();
124
  $this->css->parse_post_data();
125
  $this->css->write_css();
126
- $result = $this->css->get_property('updates');
 
127
  $this->css->reset_updates();
128
  update_option($this->optionsName, $this->css);
 
129
  die(json_encode($result));
130
  else:
131
  die(0);
132
  endif;
133
  }
134
 
135
- function handle_inputs() {
136
- if (isset($_POST['ctc_load_styles']) && current_user_can('install_themes') && $this->validate_post()):
137
- $author = '';
138
- if (isset($_POST['ctc_theme_parent'])):
139
- $theme = sanitize_text_field($_POST['ctc_theme_parent']);
140
- if (! $this->check_theme_exists($theme)):
141
- $this->errors[] = sprintf(__('%s does not exist. Please select a valid Parent Theme', $this->ns), $theme);
142
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  else:
144
- $this->css->set_property('parent_theme', $theme);
145
  endif;
146
- endif;
147
- if (isset($_POST['ctc_theme_child'])):
148
- $theme = sanitize_text_field($_POST['ctc_theme_child']);
149
- $theme_name = empty($_POST['ctc_child_name']) ? '' : sanitize_text_field($_POST['ctc_child_name']);
150
- if ('new' == $theme):
151
- $theme = empty($_POST['ctc_child_template']) ? '' :
152
- strtolower(preg_replace("%\W%", '', sanitize_text_field($_POST['ctc_child_template'])));
153
- if (empty($theme)):
154
- $this->errors[] = __('Please enter a valid Child Theme template name', $this->ns);
155
- return false;
156
- elseif ($this->check_theme_exists($theme)):
157
- $this->errors[] = sprintf(__('%s exists. Please enter a different Child Theme template name', $this->ns), $theme);
158
- return false;
159
- elseif (empty($theme_name)):
160
- $this->errors[] = sprintf(__('Please enter a valid Child Theme name', $this->ns), $theme_name);
161
- return false;
162
  endif;
163
- elseif (!$this->check_theme_exists($theme)):
164
- $this->errors[] = sprintf(__('%s does not exist. Please select a valid Child Theme', $this->ns), $theme);
165
- return false;
 
 
 
 
 
166
  endif;
167
- $this->css->set_property('child_theme', $theme);
168
- $this->css->set_property('child_theme_name', $theme_name);
169
- if (isset($_POST['ctc_theme_author'])):
170
- $this->css->set_property('author', sanitize_text_field($_POST['ctc_theme_author']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  endif;
173
- $this->css->parse_css_file('parent_theme');
174
- $this->css->parse_css_file('child_theme');
175
- $this->css->write_css();
176
- update_option($this->optionsName, $this->css);
177
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  function check_theme_exists($theme) {
181
- return in_array(strtolower($theme), array_keys(wp_get_themes()));
182
  }
183
 
 
 
 
184
  function sanitize_options($input) {
185
  return $input;
186
  }
187
 
188
- function update_redirect() {
189
  if (empty($this->is_ajax)):
190
- wp_safe_redirect(admin_url('tools.php?page=' . $this->menuName . '&updated=true'));
191
- exit();
192
  endif;
193
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
 
 
 
 
 
 
 
 
 
 
 
 
195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  }
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.5
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
13
  Domain Path: /lang
14
  License: GPLv2
15
+ Copyright (C) 2014 Lilaea Media
16
  */
17
  require_once('class-ctc-ui.php');
18
  require_once('class-ctc-css.php');
19
  class Child_Theme_Configurator {
20
 
 
21
  var $css;
22
  var $optionsName;
23
  var $menuName;
26
  var $shortName;
27
  var $ns;
28
  var $ui;
29
+ var $themes;
30
  var $errors;
31
  var $hook;
32
  var $is_ajax;
33
+ var $updated;
34
+ var $image_formats;
35
+
36
  function __construct($file) {
37
  $this->dir = dirname( $file );
38
+ $this->optionsName = 'chld_thm_cfg_options';
39
+ $this->menuName = 'chld_thm_cfg_menu';
40
+ $lang_dir = $this->dir . '/lang';
41
+ load_plugin_textdomain('chld_thm_cfg', false, $lang_dir, $lang_dir);
 
 
42
 
43
+ $this->pluginName = __('Child Theme Configurator', 'chld_thm_cfg');
44
+ $this->shortName = __('Child Themes', 'chld_thm_cfg');
45
+ $this->pluginPath = $this->dir . '/';
46
+ $this->pluginURL = plugin_dir_url($file);
47
+ $this->image_formats = array('jpg','jpeg','gif','png','JPG','JPEG','GIF','PNG');
48
 
49
  // setup plugin hooks
50
+ add_action('admin_menu', array(&$this, 'admin_menu'));
51
+ add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
52
+ add_action('wp_ajax_ctc_update', array(&$this, 'ajax_save_postdata' ));
53
+ add_action('wp_ajax_ctc_query', array(&$this, 'ajax_query_css' ));
54
+ add_action('chld_thm_cfg_addl_files', array(&$this, 'add_functions_file'), 10, 2);
55
+ add_action('chld_thm_cfg_addl_files', array(&$this, 'copy_screenshot'), 10, 2);
56
+ //add_action('update_option_' . $this->optionsName, array(&$this, 'update_redirect'), 10);
57
  }
58
 
59
  function admin_menu() {
67
  if ($this->hook == $hook):
68
  wp_enqueue_style('chld-thm-cfg-admin', $this->pluginURL . 'css/chld-thm-cfg.css');
69
  wp_enqueue_script('iris');
70
+ // wp_enqueue_script('thickbox');
71
  wp_enqueue_script('ctc-thm-cfg-ctcgrad', $this->pluginURL . 'js/ctcgrad.min.js', array('iris'), '1.0');
72
+ wp_enqueue_script('chld-thm-cfg-admin', $this->pluginURL . 'js/chld-thm-cfg.js',
73
  array('jquery-ui-autocomplete'), '1.0', true);
74
  wp_localize_script( 'chld-thm-cfg-admin', 'ctcAjax',
75
+ apply_filters('chld_thm_cfg_localize_script', array(
76
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
77
+ 'theme_uri' => get_theme_root_uri(),
78
+ 'themes' => $this->themes,
79
+ 'source' => apply_filters('chld_thm_cfg_source_uri', get_theme_root_uri() . '/'
80
+ . $this->css->get_prop('parnt') . '/style.css', $this->css),
81
+ 'target' => apply_filters('chld_thm_cfg_target_uri', get_theme_root_uri() . '/'
82
+ . $this->css->get_prop('child') . '/style.css', $this->css),
83
+ 'parnt' => $this->css->get_prop('parnt'),
84
+ 'child' => $this->css->get_prop('child'),
85
+ 'imports' => $this->css->get_prop('imports'),
86
+ 'rule' => $this->css->get_prop('rule'),
87
+ 'sel_ndx' => $this->css->get_prop('sel_ndx'),
88
+ 'val_qry' => array(),
89
+ 'rule_val' => array(),
90
+ 'sel_val' => array(),
91
+ 'field_labels' => array(
92
+ '_background_url' => __('URL/None', 'chld_thm_cfg'),
93
+ '_background_origin' => __('Origin', 'chld_thm_cfg'),
94
+ '_background_color1' => __('Color 1', 'chld_thm_cfg'),
95
+ '_background_color2' => __('Color 2', 'chld_thm_cfg'),
96
+ '_border_width' => __('Width', 'chld_thm_cfg'),
97
+ '_border_style' => __('Style', 'chld_thm_cfg'),
98
+ '_border_color' => __('Color', 'chld_thm_cfg'),
99
  ),
100
+ 'load_txt' => __('Are you sure? This will replace your current settings.', 'chld_thm_cfg'),
101
+ 'swatch_txt' => $this->ui->swatch_text,
102
+ 'swatch_label' => __('Sample', 'chld_thm_cfg'),
103
+ 'important_label' => __('<span style="font-size:10px">!</span>', 'chld_thm_cfg'),
104
+ 'selector_txt' => __('Selectors', 'chld_thm_cfg'),
105
+ 'close_txt' => __('Close', 'chld_thm_cfg'),
106
+ 'edit_txt' => __('Edit', 'chld_thm_cfg'),
107
+ 'cancel_txt' => __('Cancel', 'chld_thm_cfg'),
108
+ 'rename_txt' => __('Rename', 'chld_thm_cfg'),
109
+ 'css_fail_txt' => __('The stylesheet cannot be displayed.', 'chld_thm_cfg'),
110
+ 'child_only_txt' => __('(Child Only)', 'chld_thm_cfg'),
111
+ 'inval_theme_txt' => __('Please enter a valid Child Theme', 'chld_thm_cfg'),
112
+ 'inval_name_txt' => __('Please enter a valid Child Theme name', 'chld_thm_cfg'),
113
+ 'theme_exists_txt' => __('<strong>%s</strong> exists. Please enter a different Child Theme', 'chld_thm_cfg'),
114
  )));
115
  endif;
116
  }
120
  }
121
 
122
  function ctc_page_init () {
123
+ $this->get_themes();
124
+ $this->load_config();
125
+ do_action('chld_thm_cfg_forms', $this); // hook for custom forms
126
+ $this->write_config();
127
  $this->ui = new Child_Theme_Configurator_UI();
128
  $this->ui->render_help_tabs();
 
129
  }
130
+
131
+ function get_themes() {
132
+ $this->themes = array('child' => array(), 'parnt' => array());
133
+ foreach (wp_get_themes() as $theme):
134
+ $parent = $theme->parent();
135
+ if (empty($parent)):
136
+ $slug = $theme->get_template();
137
+ $this->themes['parnt'][$slug] = array('Name' => $theme->get('Name'));
138
+ else:
139
+ $slug = $theme->get_stylesheet();
140
+ $this->themes['child'][$slug] = array('Name' => $theme->get('Name'), 'Author' => $theme->get('Author'), 'Version' => $theme->get('Version'));
141
+ endif;
142
+ endforeach;
143
  }
144
+
145
+ function validate_post($action = 'ctc_update', $noncefield = '_wpnonce') {
146
  return ('POST' == $_SERVER['REQUEST_METHOD']
147
  && current_user_can('edit_theme_options')
148
+ && ($this->is_ajax ? check_ajax_referer( $action, $noncefield, false ) : check_admin_referer($action, $noncefield, false )));
149
  }
150
 
151
  function ajax_save_postdata() {
152
  $this->is_ajax = true;
153
  if ($this->validate_post()):
154
+ $this->load_config();
155
  $this->css->parse_post_data();
156
  $this->css->write_css();
157
+ $result = $this->css->get_prop('updates');
158
+ // clear updates so they aren't saved in options object
159
  $this->css->reset_updates();
160
  update_option($this->optionsName, $this->css);
161
+ // send all updates back to browser to update cache
162
  die(json_encode($result));
163
  else:
164
  die(0);
165
  endif;
166
  }
167
 
168
+ function ajax_query_css() {
169
+ $this->is_ajax = true;
170
+ if ($this->validate_post()):
171
+ $this->load_config();
172
+ $regex = "/^ctc_query_/";
173
+ foreach(preg_grep($regex, array_keys($_POST)) as $key):
174
+ $name = preg_replace($regex, '', $key);
175
+ $param[$name] = sanitize_text_field($_POST[$key]);
176
+ endforeach;
177
+ if (!empty($param['obj'])):
178
+ $result = array(
179
+ array(
180
+ 'key' => isset($param['key'])?$param['key']:'',
181
+ 'obj' => $param['obj'],
182
+ 'data' => $this->css->get_prop($param['obj'], $param),
183
+ ),
184
+ );
185
+ die(json_encode($result));
186
+ endif;
187
+ endif;
188
+ die(0);
189
+ }
190
+
191
+ function load_config() {
192
+ if (!($this->css = get_option($this->optionsName))
193
+ || !is_object($this->css)
194
+ || ! $this->check_theme_exists($this->css->get_prop('child'))
195
+ || ! $this->check_theme_exists($this->css->get_prop('parnt'))
196
+ // upgrade to v.1.1.1
197
+ || !($version = $this->css->get_prop('version'))
198
+ )
199
+
200
+ $this->css = new Child_Theme_Configurator_CSS();
201
+ }
202
+
203
+ function write_config() {
204
+ if (!isset($_POST['ctc_load_styles'])
205
+ && !isset($_POST['ctc_parnt_templates_submit'])
206
+ && !isset($_POST['ctc_child_templates_submit'])
207
+ && !isset($_POST['ctc_image_submit'])
208
+ && !isset($_POST['ctc_theme_image_submit'])
209
+ && !isset($_POST['ctc_theme_screenshot_submit'])) return false;
210
+ $this->errors = array();
211
+ //die(print_r($_POST, true));
212
+ if (current_user_can('install_themes')): // && $this->validate_post()):
213
+ if (isset($_POST['ctc_load_styles'])):
214
+ foreach (array(
215
+ 'ctc_theme_parnt',
216
+ 'ctc_child_type',
217
+ 'ctc_theme_child',
218
+ 'ctc_child_name',
219
+ 'ctc_configtype',
220
+ 'ctc_child_template',
221
+ 'ctc_child_author',
222
+ 'ctc_child_version') as $postfield):
223
+ $varparts = explode('_', $postfield);
224
+ $varname = end($varparts);
225
+ ${$varname} = empty($_POST[$postfield])?'':sanitize_text_field($_POST[$postfield]);
226
+ endforeach;
227
+ if ($parnt):
228
+ if (! $this->check_theme_exists($parnt)):
229
+ $this->errors[] = sprintf(__('%s does not exist. Please select a valid Parent Theme', 'chld_thm_cfg'), $parnt);
230
+ endif;
231
  else:
232
+ $this->errors[] = __('Please select a valid Parent Theme', 'chld_thm_cfg');
233
  endif;
234
+ if ('new' == $type):
235
+ $configtype = 'theme'; // no custom stylesheets until style.css exists!
236
+ $child = strtolower(preg_replace("%[^\w\-]%", '', $template));
237
+ if ($this->check_theme_exists($child)):
238
+ $this->errors[] = sprintf(__('<strong>%s</strong> exists. Please enter a different Child Theme template name', 'chld_thm_cfg'), $child);
239
+ endif;
 
 
 
 
 
 
 
 
 
 
240
  endif;
241
+ if (empty($child)):
242
+ $this->errors[] = __('Please enter a valid Child Theme template name', 'chld_thm_cfg');
243
+ endif;
244
+ if (empty($name)):
245
+ $this->errors[] = __('Please enter a valid Child Theme name', 'chld_thm_cfg');
246
+ endif;
247
+ if (false === $this->verify_child_theme($child)):
248
+ $this->errors[] = __('Your theme directories are not writable. Please adjust permissions and try again.', 'chld_thm_cfg');
249
  endif;
250
+ if (empty($this->errors)):
251
+ $this->css = new Child_Theme_Configurator_CSS();
252
+ $this->css->set_prop('parnt', $parnt);
253
+ $this->css->set_prop('child', $child);
254
+ $this->css->set_prop('child_name', $name);
255
+ $this->css->set_prop('child_author', $author);
256
+ $this->css->set_prop('child_version', $version);
257
+ $this->css->set_prop('configtype', $configtype);
258
+ do_action('chld_thm_cfg_addl_files', $this); // hook for add'l plugin files and subdirectories
259
+ $this->css->parse_css_file('parnt');
260
+ $this->css->parse_css_file('child');
261
+ if (false === $this->css->write_css(isset($_POST['ctc_backup']))):
262
+ $this->errors[] = __('Your stylesheet is not writable. Please adjust permissions and try again.', 'chld_thm_cfg');
263
+ return false;
264
+ endif;
265
+ $this->css->reset_updates();
266
+ update_option($this->optionsName, $this->css);
267
+ do_action('chld_thm_cfg_addl_options', $this); // hook for add'l plugin options
268
+ $msg = 1; //isset($_POST['ctc_scan_subdirs']) ? '9&tab=import_options' : 1;
269
  endif;
270
+ elseif (isset($_POST['ctc_parnt_templates_submit']) && isset($_POST['ctc_file_parnt'])):
271
+ foreach ($_POST['ctc_file_parnt'] as $file):
272
+ $this->copy_parent_file(sanitize_text_field($file));
273
+ endforeach;
274
+ $msg = '8&tab=file_options';
275
+ elseif (isset($_POST['ctc_child_templates_submit']) && isset($_POST['ctc_file_child'])):
276
+ foreach ($_POST['ctc_file_child'] as $file):
277
+ $this->delete_child_file(sanitize_text_field($file));
278
+ endforeach;
279
+ $msg = '8&tab=file_options';
280
+ elseif (isset($_POST['ctc_image_submit']) && isset($_POST['ctc_img'])):
281
+ foreach ($_POST['ctc_img'] as $file):
282
+
283
+ $this->delete_child_file('images/' . sanitize_text_field($file), 'img');
284
+ endforeach;
285
+ $msg = '8&tab=file_options';
286
+ elseif (isset($_POST['ctc_theme_image_submit']) && isset($_FILES['ctc_theme_image'])):
287
+ $this->handle_file_upload('ctc_theme_image', 'images');
288
+ $msg = '8&tab=file_options';
289
+ elseif (isset($_POST['ctc_theme_screenshot_submit']) && isset($_FILES['ctc_theme_screenshot'])):
290
+ // remove old screenshot
291
+ foreach($this->image_formats as $ext):
292
+ $this->delete_child_file('screenshot', $ext);
293
+ endforeach;
294
+ $this->handle_file_upload('ctc_theme_screenshot');
295
+ $msg = '8&tab=file_options';
296
+ else:
297
+ $msg = '8&tab=file_options';
298
  endif;
299
+ if (empty($this->errors)):
300
+ $this->update_redirect($msg);
301
+ endif;
302
+ else:
303
+ $this->errors[] = __('You do not have permission to configure child themes.', 'chld_thm_cfg');
304
+ endif;
305
+
306
+ //$this->errors[] = sprintf(__('Child Theme %s was unchanged.', 'chld_thm_cfg'), $name, $this->optionsName);
307
+ }
308
+
309
+ function render_menu($template = 'child', $selected = null) {
310
+ $menu = '<option value="">Select</option>' . LF;
311
+ foreach ($this->themes[$template] as $slug => $theme):
312
+ $menu .= '<option value="' . $slug . '"' . ($slug == $selected ? ' selected' : '') . '>'
313
+ . $slug . ' - "' . $theme['Name'] . '"' . '</option>' . LF;
314
+ endforeach;
315
+ return $menu;
316
  }
317
 
318
  function check_theme_exists($theme) {
319
+ return in_array($theme, array_keys(wp_get_themes()));
320
  }
321
 
322
+ /*
323
+ * TODO: this is a stub for future use
324
+ */
325
  function sanitize_options($input) {
326
  return $input;
327
  }
328
 
329
+ function update_redirect($msg = 1) {
330
  if (empty($this->is_ajax)):
331
+ wp_safe_redirect(admin_url('tools.php?page=' . $this->menuName . '&updated=' . $msg));
332
+ die();
333
  endif;
334
  }
335
+
336
+ function verify_child_theme($child) {
337
+ $themedir = get_theme_root();
338
+ if (! is_writable($themedir)) return false;
339
+ $childdir = $themedir . '/' . $child;
340
+
341
+ if (! is_dir($childdir)):
342
+ if (! mkdir($childdir, 0755)):
343
+ return false;
344
+ endif;
345
+ elseif (! is_writable($childdir)):
346
+ return false;
347
+ endif;
348
+ }
349
+
350
+ function add_functions_file($obj){
351
+ // add functions.php file
352
+ $file = $obj->css->is_file_ok($obj->css->get_child_target('functions.php'), 'write');
353
+ if ($file && !file_exists($file)):
354
+ if (false === file_put_contents($file,
355
+ "<?php\n// Exit if accessed directly\nif ( !defined('ABSPATH')) exit;\n\n/* Add custom functions below */")) return false;
356
+ endif;
357
+ }
358
+
359
+ function copy_screenshot($obj) {
360
+ // always copy screenshot
361
+ $this->copy_parent_file('screenshot');
362
+ }
363
+
364
+ function copy_parent_file($file, $ext = 'php') {
365
+ $parent_file = NULL;
366
+ if ('screenshot' == $file):
367
+ foreach ($this->image_formats as $ext):
368
+ if ($parent_file = $this->css->is_file_ok($this->css->get_parent_source('screenshot.' . $ext))) break;
369
+ endforeach;
370
+ else:
371
+ $parent_file = $this->css->is_file_ok($this->css->get_parent_source($file . '.' . $ext));
372
+ endif;
373
+ $child_file = $this->css->get_child_target($file . '.' . $ext);
374
+
375
+ if ($parent_file && $child_file && !file_exists($child_file)):
376
+ $childdir = dirname($child_file);
377
+ if (! is_dir($childdir)):
378
+ if (! @mkdir($childdir, 0755, true)):
379
+ return false;
380
+ endif;
381
+ elseif (! is_writable($childdir)):
382
+ return false;
383
+ endif;
384
+ if (false === file_put_contents($child_file,
385
+ @file_get_contents($parent_file))) return false;
386
+ endif;
387
+ }
388
+
389
+ function delete_child_file($file, $ext = 'php') {
390
+ // verify file is in child theme and exists before removing.
391
+ $file = ('img' == $ext ? $file : $file . '.' . $ext);
392
+ $child_file = $this->css->get_child_target($file);
393
+ if ($this->css->is_file_ok($child_file, 'write') && file_exists($child_file)):
394
+ if (false === @unlink($child_file)) return false;
395
+ endif;
396
+
397
+
398
+ }
399
+
400
+ function handle_file_upload($field, $childdir = NULL){
401
+ /* adapted from http://www.php.net/manual/en/features.file-upload.php#114004 */
402
+ try {
403
+ // Undefined | Multiple Files | $_FILES Corruption Attack
404
+ // If this request falls under any of them, treat it invalid.
405
+ if ( !isset($_FILES[$field]['error']) || is_array($_FILES[$field]['error']) ):
406
+ throw new RuntimeException(__('Invalid parameters.', 'chld_thm_cfg'));
407
+ endif;
408
 
409
+ // Check $_FILES['upfile']['error'] value.
410
+ switch ($_FILES[$field]['error']):
411
+ case UPLOAD_ERR_OK:
412
+ break;
413
+ case UPLOAD_ERR_NO_FILE:
414
+ throw new RuntimeException(__('Please select a file to upload.', 'chld_thm_cfg'));
415
+ case UPLOAD_ERR_INI_SIZE:
416
+ case UPLOAD_ERR_FORM_SIZE:
417
+ throw new RuntimeException(__('File is too large.', 'chld_thm_cfg'));
418
+ default:
419
+ throw new RuntimeException(__('There was a problem uploading the file.', 'chld_thm_cfg'));
420
+ endswitch;
421
 
422
+ if ($_FILES[$field]['size'] > 1024 * 1024):
423
+ throw new RuntimeException(__('Theme images cannot be over 1MB.', 'chld_thm_cfg'));
424
+ endif;
425
+
426
+ if (false === ($ext = array_search(
427
+ exif_imagetype($_FILES[$field]['tmp_name']),
428
+ array(
429
+ 'jpg' => IMAGETYPE_JPEG,
430
+ 'png' => IMAGETYPE_PNG,
431
+ 'gif' => IMAGETYPE_GIF,
432
+ ),
433
+ true
434
+ ))):
435
+ throw new RuntimeException(__('Theme images must be JPG, PNG or GIF.', 'chld_thm_cfg'));
436
+ endif;
437
+ // strip extension
438
+ $filename = preg_replace('%\.[^\.]+$%', '', $_FILES[$field]['name']);
439
+ // strip non alphas and replace with dash
440
+ $filename = preg_replace('%[^\w]+%', '-', $filename);
441
+ // Ensure target is in child theme
442
+ $target = $this->css->get_child_target(isset($childdir) ? $childdir . '/' . $filename . '.' . $ext : 'screenshot.' . $ext);
443
+ $targetdir = dirname($target);
444
+ if (! is_dir($targetdir)):
445
+ if (! @mkdir($targetdir, 0755, true)):
446
+ throw new RuntimeException(__('Unable to create directory.', 'chld_thm_cfg'));
447
+ endif;
448
+ elseif (! is_writable($targetdir)):
449
+ throw new RuntimeException(__('Child theme directory is not writable.', 'chld_thm_cfg'));
450
+ endif;
451
+ if (!$target || !move_uploaded_file(
452
+ $_FILES[$field]['tmp_name'],
453
+ $target
454
+ )):
455
+ throw new RuntimeException(__('There was a problem uploading the file.', 'chld_thm_cfg'));
456
+ endif;
457
+
458
+ } catch (RuntimeException $e) {
459
+ $this->errors[] = $e->getMessage();
460
+ }
461
+ }
462
  }
js/chld-thm-cfg.js CHANGED
@@ -2,16 +2,20 @@
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.0
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
- (function($){
12
 
13
  var lf = "\n",
14
-
 
 
 
 
15
  // initialize functions
16
  ctc_setup_iris = function(obj) {
17
  $(obj).iris({
@@ -20,13 +24,21 @@
20
  }
21
  });
22
  },
23
-
 
 
 
 
 
 
 
 
24
  ctc_coalesce_inputs = function(obj) {
25
- var regex = /^(ctc_(ovrd_)?(parent|child)_([a-z\-]+)_(\d+))(_\w+)?$/,
26
  $container = $(obj).parents('.ctc-selector-row, .ctc-parent-row').first(),
27
  $swatch = $container.find('.ctc-swatch').first(),
28
- cssrules = { 'parent': {}, 'child': {} },
29
- gradient = {
30
  'parent': {
31
  'origin': '',
32
  'start': '',
@@ -39,21 +51,28 @@
39
  }
40
  },
41
  has_gradient = { 'child': false, 'parent': false },
42
- postdata = {};
43
  // set up objects for all neighboring inputs
44
  $container.find('.ctc-parent-value, .ctc-child-value').each(function(){
45
  var inputid = $(this).attr('id'),
46
- inputparts = inputid.match(regex),
 
47
  inputtheme = inputparts[3],
48
- inputrule = (undefined == inputparts[4] ? '' : inputparts[4]),
49
- selnum = inputparts[5],
50
- rulepart = (undefined == inputparts[6] ? '' : inputparts[6]),
51
  value = ('parent' == inputtheme ? $(this).text() : $(this).val()),
 
52
  parts, subparts;
53
  if ('child' == inputtheme) {
54
  postdata[inputid] = value;
 
55
  }
56
- if (ctc_is_empty(value)) return;
 
 
 
 
57
  // handle specific inputs
58
  if (false === ctc_is_empty(rulepart)) {
59
  switch(rulepart) {
@@ -87,21 +106,21 @@
87
  }
88
  } else {
89
  // handle borders
90
- if (parts = inputrule.match(/^border(\-(top|right|bottom|left))?$/) && !value.match(/none/)) {
91
- subparts = value.split(/ +/);
92
- cssrules[inputtheme][inputrule + '-width'] = undefined == subparts[0] ? '' : subparts[0];
93
- cssrules[inputtheme][inputrule + '-style'] = undefined == subparts[1] ? '' : subparts[1];
94
- cssrules[inputtheme][inputrule + '-color'] = undefined == subparts[2] ? '' : subparts[2];
95
  // handle background images
96
  } else if ( 'background-image' == inputrule ) {
97
- if (value.match(/url\(/)) {
98
  cssrules[inputtheme]['background-image'] = ctc_image_url(inputtheme, value);
99
  } else {
100
- subparts = value.split(/ +/);
101
  if (subparts.length > 2) {
102
- gradient[inputtheme].origin = undefined == subparts[0] ? 'top' : subparts[0];
103
- gradient[inputtheme].start = undefined == subparts[1] ? 'transparent' : subparts[1];
104
- gradient[inputtheme].end = undefined == subparts[2] ? 'transparent' : subparts[2];
105
  has_gradient[inputtheme] = true;
106
  } else {
107
  cssrules[inputtheme]['background-image'] = value;
@@ -111,93 +130,74 @@
111
  cssrules[inputtheme][inputrule] = value;
112
  }
113
  }
 
114
  });
115
  // update swatch
116
- if (undefined != $swatch) {
117
  $($swatch).removeAttr('style');
118
  if (has_gradient.parent) { $($swatch).ctcgrad(gradient.parent.origin, [gradient.parent.start, gradient.parent.end]); }
119
  $($swatch).css(cssrules.parent);
120
- if (!($swatch.attr('id').match(/parent/))){
121
  if (has_gradient.child) { $($swatch).ctcgrad(gradient.child.origin, [gradient.child.start, gradient.child.end]); }
122
  $($swatch).css(cssrules.child);
123
  }
124
  }
125
  return postdata;
126
  },
127
- ctc_apply_updates = function(obj) {
128
- var currQuery, currSelnum, currRule;
129
- if (undefined != obj.imports) {
130
- ctcAjax.imports[ctcAjax.child_theme] = obj.imports;
131
- }
132
- $(obj.del).each(function(){
133
- if (undefined != this.selnum) {
134
- delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum];
135
- } else if (undefined != this.query) {
136
- delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query];
137
- } else if (undefined != this.value) {
138
- delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value];
139
- } else if (undefined != this.rule) {
140
- delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule];
141
- }
142
- if (undefined != this.query) currQuery = this.query;
143
- if (undefined != this.selnum) currSelnum = this.selnum;
144
- if (undefined != this.rule) currRule = this.rule;
145
- });
146
- $(obj.insert).each(function(){
147
- ctcAjax.sel_ndx[this.query][this.selector] = this.selnum;
148
- ctcAjax.data[this.selnum] = {
149
- 'selector': this.selector,
150
- 'query': this.query,
151
- 'value': {}
152
- };
153
- if (undefined != this.query) currQuery = this.query;
154
- if (undefined != this.selnum) currSelnum = this.selnum;
155
- if (undefined != this.rule) currRule = this.rule;
156
- });
157
- $(obj.update).each(function(){
158
- if (undefined == ctcAjax.val_ndx[ctcAjax.child_theme]) {
159
- ctcAjax.val_ndx[ctcAjax.child_theme] = {};
160
- }
161
- if (undefined == ctcAjax.val_ndx[ctcAjax.child_theme][this.rule]) {
162
- ctcAjax.val_ndx[ctcAjax.child_theme][this.rule] = {};
163
- }
164
- if (this.value && undefined == ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value]) {
165
- ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value] = {};
166
- }
167
- if (this.value && undefined == ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query]) {
168
- ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query] = {};
169
- }
170
- if (this.value && undefined == ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum]) {
171
- ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum] = 0;
172
- }
173
- if (this.rule && undefined == ctcAjax.data[this.selnum].value[this.rule]) {
174
- ctcAjax.data[this.selnum].value[this.rule] = {};
175
- //ctcAjax.val_ndx[ctcAjax.child_theme][this.rule] = {};
176
  }
177
- ctcAjax.data[this.selnum].value[this.rule][ctcAjax.child_theme] = this.value + (this.important > 0 ? ' !important':'');
178
- if (undefined != this.query) currQuery = this.query;
179
- if (undefined != this.selnum) currSelnum = this.selnum;
180
- if (undefined != this.rule) currRule = this.rule;
181
  });
182
- // refresh page with new values if available
183
- if (currQuery) {
184
- ctc_set_query(currQuery, currQuery);
185
- }
186
- if (currSelnum) {
187
- ctc_set_selector(currSelnum, ctcAjax.data[currSelnum].selector);
188
- }
189
- if (currRule) {
190
- ctc_set_rule(currRule, currRule);
191
- }
192
  },
193
  ctc_image_url = function(theme, value) {
194
- var parts = value.match(/url\([" ]*(.+?)[" ]*\)/),
195
- path = (undefined == parts ? null : parts[1]),
196
- url = ctcAjax.theme_uri + '/' + ('parent' == theme ? ctcAjax.parent_theme : ctcAjax.child_theme) + '/',
197
  image_url;
198
  if (!path) {
199
  return false;
200
- } else if (path.match(/^(http:|\/)/)) {
201
  image_url = value;
202
  } else {
203
  image_url = 'url(' + url + path + ')';
@@ -206,8 +206,8 @@
206
  },
207
 
208
  ctc_is_empty = function(obj) {
209
- // first bail when definitely empty or undefined (true)
210
- if (undefined == obj || false === obj || null === obj || '' === obj || 0 === obj) { return true; }
211
  // then, if this is bool, string or number it must not be empty (false)
212
  if (true === obj || "string" === typeof obj || "number" === typeof obj) { return false; }
213
  // thanks to Abena Kuttin for Win safe version
@@ -233,9 +233,16 @@
233
 
234
  ctc_load_queries = function() {
235
  var arr = [];
236
- if (false === ctc_is_empty(ctcAjax.sel_ndx)){
 
 
 
 
 
 
 
237
  $.each(ctcAjax.sel_ndx, function(key, value) {
238
- obj = { label: key, value: key };
239
  arr.push(obj);
240
  });
241
  }
@@ -244,9 +251,18 @@
244
 
245
  ctc_load_selectors = function(query) {
246
  var arr = [];
247
- if (false === ctc_is_empty(ctcAjax.sel_ndx[query])){
 
 
 
 
 
 
 
 
 
248
  $.each(ctcAjax.sel_ndx[query], function(key, value) {
249
- obj = { label: key, value: value };
250
  arr.push(obj);
251
  });
252
  }
@@ -254,145 +270,276 @@
254
  },
255
 
256
  ctc_load_rules = function() {
257
- var obj = {},
258
- arr = [];
259
- if (false === ctc_is_empty(ctcAjax.val_ndx[ctcAjax.parent_theme])) {
260
- $.each(ctcAjax.val_ndx[ctcAjax.parent_theme], function(key, value) {
261
- obj[key]++;
262
- });
263
  }
264
- if (false === ctc_is_empty(ctcAjax.val_ndx[ctcAjax.child_theme])) {
265
- $.each(ctcAjax.val_ndx[ctcAjax.child_theme], function(key, value) {
266
- obj[key]++;
 
267
  });
268
  }
269
- $.each(['border-width', 'border-style', 'border-color', 'padding', 'margin', 'background', 'font'], function() {
270
- obj[this]++;
 
 
 
 
271
  });
272
- if (false === ctc_is_empty(obj)){
273
- $.each(obj, function(key, value) {
274
- arr.push(key);
275
- });
276
- }
277
- return arr.sort();
278
  },
279
 
280
- ctc_render_child_rule_input = function(selnum, rule, specific) {
281
- var html = '',
282
- value = (undefined == ctcAjax.data[selnum].value || undefined == ctcAjax.data[selnum].value[rule] ? '' : ctcAjax.data[selnum].value[rule]),
283
- oldRuleObj = ctc_decode_value(rule, (undefined == value ? '' : value[ctcAjax.parent_theme])),
284
- newRuleObj = ctc_decode_value(rule, (undefined == value ? '' : value[ctcAjax.child_theme]));
285
- if (value) {
286
- unique_rule_value[rule + '%%' + value[ctcAjax.parent_theme]] = 1;
287
- unique_rule_value[rule + '%%' + value[ctcAjax.child_theme]] = 1;
288
- }
289
- html += '<div class="ctc-' + (specific ? 'selector' : 'input' ) + '-row clearfix">' + lf;
290
- html += '<div class="ctc-input-cell">' + (specific ? ctcAjax.data[selnum].selector : rule) + '</div>' + lf;
291
- html += '<div class="ctc-parent-value' + (specific ? ' ctc-hidden' : ' ctc-input-cell') +'" id="ctc_parent_' + rule + '_' + selnum + '">'
292
- + (ctc_is_empty(oldRuleObj.orig) ? '[no value]' : oldRuleObj.orig) + '</div>' + lf;
293
- html += '<div class="ctc-input-cell">' + lf;
294
- if (false === ctc_is_empty(oldRuleObj.names)){
295
- $.each(oldRuleObj.names, function(ndx, newname) {
296
- newname = (ctc_is_empty(newname) ? '' : newname);
297
- html += '<div class="ctc-child-input-cell">' + lf;
298
- var id = 'ctc_' + (specific? '' : 'ovrd_') + 'child_' + rule + '_' + selnum + newname,
299
- newval;
300
- if (!(newval = newRuleObj.values.shift()) ){
301
- newval = '';
302
- }
 
 
 
 
 
 
 
 
303
 
304
- html += (ctc_is_empty(newname) ? '' : ctcAjax.labels[newname] + ':<br/>')
305
- + '<input type="text" id="' + id + '" name="' + id + '" class="ctc-child-value'
306
- + ((newname + rule).match(/color/) ? ' color-picker' : '')
307
- + ((newname).match(/url/) ? ' ctc-input-wide' : '')
308
- + '" value="' + newval + '" />' + lf;
309
- html += '</div>' + lf;
310
- });
 
 
 
 
 
 
 
 
 
 
311
  }
312
- html += '</div>' + lf;
313
- html += (specific ? '<div class="ctc-swatch ctc-specific" id="ctc_child_' + rule + '_' + selnum + '_swatch">'
314
- + ctcAjax.swatch_text + '</div>' + lf
315
- + '<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_' + rule + '_' + selnum + '_cell">' + lf
316
- + '<input type="button" class="button ctc-save-input" id="ctc_save_' + rule + '_' + selnum
317
- + '" name="ctc_save_' + rule + '_' + selnum + '" value="Save" /></div>' + lf : '');
318
- html += '</div><!-- end input row -->' + lf;
319
  return html;
320
  },
321
-
322
- ctc_render_selector_inputs = function(selnum) {
323
- if (undefined == ctcAjax.data[selnum].value) return;
324
- var html = '', counter = 0;
325
- if (false === ctc_is_empty(ctcAjax.data[selnum].value)){
326
- $.each(ctcAjax.data[selnum].value, function(rule, value) {
327
- html += ctc_render_child_rule_input(selnum, rule, false);
328
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  }
330
- $('#ctc_sel_ovrd_rule_inputs').html(html).find('.color-picker').each(function() {
331
- ctc_setup_iris(this);
332
- });
333
- ctc_coalesce_inputs('#ctc_child_all_0_swatch');
334
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
 
336
- ctc_render_rule_value_inputs = function(rule) {
337
- var html = '<div class="ctc-input-row clearfix" id="ctc_rule_row_' + rule + '">' + lf,
338
- valID = 0,
339
- themes = {parent: ctcAjax.parent_theme, child: ctcAjax.child_theme};
340
- unique_rule_value = {},
341
-
342
- $.each(themes, function(ndx, theme) {
343
- if (ctc_is_empty(ctcAjax.val_ndx[theme]) || undefined == ctcAjax.val_ndx[theme][rule]) return;
344
- $.each(ctcAjax.val_ndx[theme][rule], function(value, sel) {
345
- if (unique_rule_value[rule + '%%' + value]) {
346
- return;
347
- } else {
348
- valID++;
349
- oldRuleObj = ctc_decode_value(rule, value),
350
- html += '<div class="ctc-parent-row clearfix" id="ctc_rule_row_' + rule + '_' + valID + '">' + lf;
351
- html += '<div class="ctc-input-cell ctc-parent-value" id="ctc_parent_' + rule + '_' + valID + '">'
352
- + oldRuleObj.orig + '</div>' + lf;
353
- html += '<div class="ctc-input-cell">' + lf;
354
- html += '<div class="ctc-swatch ctc-specific" id="ctc_parent_'+rule+'_' + valID + '_swatch">'
355
- + ctcAjax.swatch_text + '</div></div>' + lf;
356
- html += '<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_' + rule + '_' + valID + '">'
357
- + ctcAjax.selector_text + '</a></div>' + lf;
358
- html += '<div id="ctc_selector_' + rule + '_' + valID + '_container" class="ctc-selector-container clearfix">' + lf;
359
- html += '<a href="#" id="ctc_selector_' + rule + '_' + valID + '_close" class="ctc-selector-handle" style="float:right">'
360
- + ctcAjax.close_text + '</a>' + lf;
361
- html += ctc_render_selector_value_inputs(rule, sel);
362
- html += '</div></div>' + lf;
363
- }
364
  });
 
 
 
 
365
  });
366
- html += '</div>' + lf;
367
- $('#ctc_rule_value_inputs').html(html).find('.color-picker').each(function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  ctc_setup_iris(this);
369
  });
370
- $('#ctc_rule_value_inputs').find('.ctc-swatch').each(function() {
371
  ctc_coalesce_inputs(this);
372
  });
 
373
  },
374
-
375
- ctc_render_selector_value_inputs = function(rule, sel) {
376
- var html = '', lastquery = '', query;
377
- if (false === ctc_is_empty(sel)){
378
- $.each(sel, function(query, selectors) {
379
- if (query != lastquery) {
380
- lastquery = query;
381
- html += '<h4 class="ctc-query-heading">' + query + '</h4>' + lf; //queryparts[1]
382
- }
383
- if (false === ctc_is_empty(selectors)){
384
- $.each(selectors, function(selnum, zero) {
385
- html += ctc_render_child_rule_input(selnum, rule, true);
386
- });
387
- }
388
  });
389
  }
390
- return html;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  },
392
-
393
  ctc_save = function(obj) {
394
  var postdata = {},
395
- $selector, $query, $imports, $rule;
 
 
 
 
 
396
  // disable the button until ajax returns
397
  $(obj).prop('disabled', true);
398
  // clear previous success/fail icons
@@ -411,6 +558,18 @@
411
  // coalesce inputs
412
  postdata = ctc_coalesce_inputs(obj);
413
  }
 
 
 
 
 
 
 
 
 
 
 
 
414
  // add wp ajax action to array
415
  postdata['action'] = 'ctc_update';
416
  postdata['_wpnonce'] = $('#_wpnonce').val();
@@ -422,6 +581,7 @@
422
  postdata,
423
  //on success function
424
  function(response){
 
425
  // release button
426
  $(obj).prop('disabled', false);
427
  // hide spinner
@@ -433,11 +593,15 @@
433
  $('.ctc-status-icon').addClass('success');
434
  $('#ctc_new_selectors').val('');
435
  // update data objects
436
- ctc_apply_updates(response);
 
 
 
 
 
437
  }
438
  return false;
439
- },
440
- 'json'
441
  ).fail(function(){
442
  // release button
443
  $(obj).prop('disabled', false);
@@ -448,38 +612,22 @@
448
  });
449
  return false;
450
  },
451
-
452
- ctc_serialize = function(obj) {
453
- var serialized;
454
- if (undefined == obj) {
455
- serialized = '';
456
- } else if ('string' === typeof obj || 'number' === typeof obj) {
457
- serialized = obj;
458
- } else if ('object' === typeof obj) {
459
- serialized = '';
460
- $.each(obj, function(ndx,el){
461
- serialized += ndx + ': ' + el + ',' + "\n";
462
- });
463
- }
464
- return serialized;
465
- },
466
-
467
  ctc_decode_value = function(rule, value) {
468
- value = (undefined == value ? '' : value);
469
  var obj = { 'orig': value };
470
- if (rule.match(/^border(\-(top|right|bottom|left))?$/)) {
471
- var params = value.split(/ +/);
472
  obj['names'] = [
473
  '_border_width',
474
  '_border_style',
475
  '_border_color',
476
  ];
477
  obj['values'] = [
478
- (undefined == params[0] ? '' : params[0]),
479
- (undefined == params[1] ? '' : params[1]),
480
- (undefined == params[2] ? '' : params[2])
481
  ];
482
- } else if (rule.match(/^background\-image/)) {
483
  obj['names'] = [
484
  '_background_url',
485
  '_background_origin',
@@ -487,11 +635,11 @@
487
  '_background_color2'
488
  ];
489
  obj['values'] = ['','','',''];
490
- if (value.match(/:/)) {
491
- var params = value.split(/:/);
492
- obj['values'][1] = (undefined == params[0] ? '' : params[0]);
493
- obj['values'][2] = (undefined == params[1] ? '' : params[1]);
494
- obj['values'][3] = (undefined == params[3] ? '' : params[3]);
495
  obj['orig'] = [ obj['values'][1], obj['values'][2], obj['values'][3] ].join(' '); // display "origin color1 color2"
496
  } else {
497
  obj['values'][0] = value;
@@ -503,129 +651,303 @@
503
  return obj;
504
  },
505
 
506
- ctc_set_query = function(value, label) {
 
507
  $('#ctc_sel_ovrd_query').val('');
508
- $('#ctc_sel_ovrd_query_selected').text(label);
509
- ctc_selectors = ctc_load_selectors(value);
510
- $('#ctc_sel_ovrd_selector').autocomplete('option', { source: ctc_selectors });
 
 
 
511
  $('#ctc_new_selector_row').show();
512
  },
513
 
514
  ctc_set_selector = function(value,label) {
515
  $('#ctc_sel_ovrd_selector').val('');
516
  $('#ctc_sel_ovrd_selector_selected').text(label);
517
- $('#ctc_sel_ovrd_selnum').val(value);
 
 
518
  ctc_render_selector_inputs(value);
519
- $('#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs').show();
 
520
  },
521
 
522
  ctc_set_rule = function(value,label) {
523
  $('#ctc_rule_menu').val('');
524
  $('#ctc_rule_menu_selected').text(label);
 
525
  ctc_render_rule_value_inputs(value);
 
526
  $('#ctc_rule_value_inputs,#ctc_input_row_rule_header').show();
527
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  // initialize vars
529
- ctc_selectors = [],
530
- ctc_queries = ctc_load_queries(),
531
- ctc_rules = ctc_load_rules(),
532
- unique_rule_value = {},
533
- toggles = {};
534
-
535
- // initialize tools
 
 
 
 
 
 
 
 
 
536
  $('.color-picker').each(function() {
537
  ctc_setup_iris(this);
538
  });
 
539
  $('.ctc-option-panel-container').on('focus', '.color-picker', function(){
 
540
  $(this).iris('toggle');
541
  $('.iris-picker').css({'position':'absolute', 'z-index':10});
542
  });
543
  $('.ctc-option-panel-container').on('focus', 'input', function() {
 
544
  $('.color-picker').not(this).iris('hide');
545
  });
546
- $('.ctc-option-panel-container').on('change', '.ctc-child-value', function() {
547
  ctc_coalesce_inputs(this);
548
  });
549
  $('.ctc-option-panel-container').on('click', '.ctc-selector-handle', function(e) {
550
  e.preventDefault();
551
- var id = $(this).attr('id').replace('_close', '');
 
 
 
 
 
 
552
  $('#' + id + '_container').fadeToggle('fast');
553
  $('.ctc-selector-container').not('#' + id + '_container').fadeOut('fast');
554
  });
555
  $('.nav-tab').on('click', function(e){
556
  e.preventDefault();
557
- var id = '#' + $(this).attr('id'), panelid = id + '_panel';
558
- $('.nav-tab').removeClass('nav-tab-active');
559
- $('.ctc-option-panel').removeClass('ctc-option-panel-active');
560
- $('.ctc-selector-container').hide();
561
- $(id).addClass('nav-tab-active');
562
- $('.ctc-option-panel-container').scrollTop(0);
563
- $(panelid).addClass('ctc-option-panel-active');
564
- });
565
- $('#preview_options').on('click', function(e){
566
- var stamp = new Date().getTime(),
567
- css_uri = ctcAjax.theme_uri + '/' + ctcAjax.child_theme + '/style.css?' + stamp;
568
- $.get(
569
- css_uri,
570
- function(response){
571
- $('#preview_options_panel').text(response);
572
- }
573
- ).fail(function(){
574
- $('#preview_options_panel').text(ctcAjax.css_fail);
575
- });
576
  });
577
- $('#ctc_load_form').on('submit', function(e) {
578
- return confirm(ctcAjax.load_msg);
 
579
  });
 
580
  $(document).on('click', '.ctc-save-input', function(e) {
581
  ctc_save(this);
582
  });
583
- $('#ctc_sel_ovrd_query').autocomplete({
584
- source: ctc_queries,
585
- minLength: 0,
586
- selectFirst: true,
587
- autoFocus: true,
588
- select: function(e, ui) {
589
- ctc_set_query(ui.item.value, ui.item.label);
590
- return false;
591
- },
592
- focus: function(e) { e.preventDefault(); }
593
- });
594
- $('#ctc_sel_ovrd_selector').autocomplete({
595
- source: ctc_selectors,
596
- selectFirst: true,
597
- autoFocus: true,
598
- select: function(e, ui) {
599
- ctc_set_selector(ui.item.value, ui.item.label);
600
- return false;
601
- },
602
- focus: function(e) { e.preventDefault(); }
603
- });
604
- $('#ctc_rule_menu').autocomplete({
605
- source: ctc_rules,
606
- //minLength: 0,
607
- selectFirst: true,
608
- autoFocus: true,
609
- select: function(e, ui) {
610
- ctc_set_rule(ui.item.value, ui.item.label);
611
- return false;
612
- },
613
- focus: function(e) { e.preventDefault(); }
614
- });
615
- $('#ctc_new_rule_menu').autocomplete({
616
- source: ctc_rules,
617
- //minLength: 0,
618
- selectFirst: true,
619
- autoFocus: true,
620
- select: function(e, ui) {
621
- var sel = $('#ctc_sel_ovrd_selnum').val();
622
- $('#ctc_sel_ovrd_rule_inputs').append(ctc_render_child_rule_input(sel, ui.item.value, false)).find('.color-picker').each(function() {
623
- ctc_setup_iris(this);
624
- });
625
- $('#ctc_new_rule_menu').val('');
626
- return false;
627
- },
628
- focus: function(e) { e.preventDefault(); }
629
  });
630
- })(jQuery);
 
 
 
631
 
 
 
 
 
 
 
 
 
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.4.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
+ jQuery(document).ready(function($){
12
 
13
  var lf = "\n",
14
+ currentQuery = 'base',
15
+ currentSel,
16
+ saveEvents = {},
17
+ rewrite_id,
18
+ rewrite_sel,
19
  // initialize functions
20
  ctc_setup_iris = function(obj) {
21
  $(obj).iris({
24
  }
25
  });
26
  },
27
+ from_ascii = function(str) {
28
+ var ascii = parseInt(str),
29
+ chr = String.fromCharCode(ascii)
30
+ return chr;
31
+ },
32
+ to_ascii = function(str) {
33
+ var ascii = str.charCodeAt(0);
34
+ return ascii;
35
+ },
36
  ctc_coalesce_inputs = function(obj) {
37
+ var regex = /^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,
38
  $container = $(obj).parents('.ctc-selector-row, .ctc-parent-row').first(),
39
  $swatch = $container.find('.ctc-swatch').first(),
40
+ cssrules = { 'parent': {}, 'child': {} },
41
+ gradient = {
42
  'parent': {
43
  'origin': '',
44
  'start': '',
51
  }
52
  },
53
  has_gradient = { 'child': false, 'parent': false },
54
+ postdata = {};
55
  // set up objects for all neighboring inputs
56
  $container.find('.ctc-parent-value, .ctc-child-value').each(function(){
57
  var inputid = $(this).attr('id'),
58
+ inputparts = inputid.toString().match(regex),
59
+ inputseq = inputparts[2],
60
  inputtheme = inputparts[3],
61
+ inputrule = ('undefined' == typeof inputparts[4] ? '' : inputparts[4]),
62
+ qsid = inputparts[5],
63
+ rulepart = ('undefined' == typeof inputparts[6] ? '' : inputparts[6]),
64
  value = ('parent' == inputtheme ? $(this).text() : $(this).val()),
65
+ important = 'ctc_' + inputseq + '_child_' + inputrule + '_i_' + qsid,
66
  parts, subparts;
67
  if ('child' == inputtheme) {
68
  postdata[inputid] = value;
69
+ postdata[important] = ($('#' + important).is(':checked')) ? 1 : 0;
70
  }
71
+ /*if ('' === value) {
72
+ $('#'+important).prop('checked', false);
73
+ return;
74
+ }*/
75
+ if ('' != value) {
76
  // handle specific inputs
77
  if (false === ctc_is_empty(rulepart)) {
78
  switch(rulepart) {
106
  }
107
  } else {
108
  // handle borders
109
+ if (parts = inputrule.toString().match(/^border(\-(top|right|bottom|left))?$/) && !value.match(/none/)) {
110
+ subparts = value.toString().split(/ +/);
111
+ cssrules[inputtheme][inputrule + '-width'] = 'undefined' == typeof subparts[0] ? '' : subparts[0];
112
+ cssrules[inputtheme][inputrule + '-style'] = 'undefined' == typeof subparts[1] ? '' : subparts[1];
113
+ cssrules[inputtheme][inputrule + '-color'] = 'undefined' == typeof subparts[2] ? '' : subparts[2];
114
  // handle background images
115
  } else if ( 'background-image' == inputrule ) {
116
+ if (value.toString().match(/url\(/)) {
117
  cssrules[inputtheme]['background-image'] = ctc_image_url(inputtheme, value);
118
  } else {
119
+ subparts = value.toString().split(/ +/);
120
  if (subparts.length > 2) {
121
+ gradient[inputtheme].origin = 'undefined' == typeof subparts[0] ? 'top' : subparts[0];
122
+ gradient[inputtheme].start = 'undefined' == typeof subparts[1] ? 'transparent' : subparts[1];
123
+ gradient[inputtheme].end = 'undefined' == typeof subparts[2] ? 'transparent' : subparts[2];
124
  has_gradient[inputtheme] = true;
125
  } else {
126
  cssrules[inputtheme]['background-image'] = value;
130
  cssrules[inputtheme][inputrule] = value;
131
  }
132
  }
133
+ }
134
  });
135
  // update swatch
136
+ if ('undefined' != typeof $swatch && false === ctc_is_empty($swatch.attr('id'))) {
137
  $($swatch).removeAttr('style');
138
  if (has_gradient.parent) { $($swatch).ctcgrad(gradient.parent.origin, [gradient.parent.start, gradient.parent.end]); }
139
  $($swatch).css(cssrules.parent);
140
+ if (!($swatch.attr('id').toString().match(/parent/))){
141
  if (has_gradient.child) { $($swatch).ctcgrad(gradient.child.origin, [gradient.child.start, gradient.child.end]); }
142
  $($swatch).css(cssrules.child);
143
  }
144
  }
145
  return postdata;
146
  },
147
+ ctc_update_cache = function(response) {
148
+ var currQuery, currSelId, currRuleId;
149
+ $(response).each(function(){
150
+ switch (this.obj) {
151
+ case 'imports':
152
+ ctcAjax.imports = this.data;
153
+ break;
154
+
155
+ case 'rule_val':
156
+ ctcAjax.rule_val[this.key] = this.data;
157
+ currRuleId = this.key;
158
+ break;
159
+
160
+ case 'val_qry':
161
+ ctcAjax.val_qry[this.key] = this.data;
162
+ break;
163
+
164
+ case 'rule':
165
+ ctcAjax.rule = this.data;
166
+ break;
167
+
168
+ case 'sel_ndx':
169
+ if (ctc_is_empty(this.key)) {
170
+ ctcAjax.sel_ndx = this.data;
171
+ } else if ('qsid' == this.key) {
172
+ if (ctc_is_empty(ctcAjax.sel_ndx[this.data.query])) {
173
+ ctcAjax.sel_ndx[this.data.query] = {}
174
+ }
175
+ ctcAjax.sel_ndx[this.data.query][this.data.selector] = this.data.qsid;
176
+ } else {
177
+ ctcAjax.sel_ndx[this.key] = this.data;
178
+ currQuery = this.key;
179
+ }
180
+ break;
181
+
182
+ case 'sel_val':
183
+ ctcAjax.sel_val[this.key] = this.data;
184
+ currSelId = this.key;
185
+ break;
186
+ case 'rewrite':
187
+ rewrite_id = this.key;
188
+ rewrite_sel = this.data;
189
+ break;
 
 
 
 
 
 
190
  }
 
 
 
 
191
  });
 
 
 
 
 
 
 
 
 
 
192
  },
193
  ctc_image_url = function(theme, value) {
194
+ var parts = value.toString().match(/url\(['" ]*(.+?)['" ]*\)/),
195
+ path = ctc_is_empty(parts) ? null : parts[1],
196
+ url = ctcAjax.theme_uri + '/' + ('parent' == theme ? ctcAjax.parnt : ctcAjax.child) + '/',
197
  image_url;
198
  if (!path) {
199
  return false;
200
+ } else if (path.toString().match(/^(https?:|\/)/)) {
201
  image_url = value;
202
  } else {
203
  image_url = 'url(' + url + path + ')';
206
  },
207
 
208
  ctc_is_empty = function(obj) {
209
+ // first bail when definitely empty or undefined (true) NOTE: zero is not empty
210
+ if ('undefined' == typeof obj || false === obj || null === obj || '' === obj) { return true; }
211
  // then, if this is bool, string or number it must not be empty (false)
212
  if (true === obj || "string" === typeof obj || "number" === typeof obj) { return false; }
213
  // thanks to Abena Kuttin for Win safe version
233
 
234
  ctc_load_queries = function() {
235
  var arr = [];
236
+ if (1 === loading.sel_ndx) return arr;
237
+ if (0 === loading.sel_ndx) { // {
238
+ // retrieve from server
239
+ loading.sel_ndx = 1;
240
+ ctc_query_css('sel_ndx', null, ctc_setup_query_menu);
241
+ return arr;
242
+ }
243
+ if (false === ctc_is_empty(ctcAjax.sel_ndx)) {
244
  $.each(ctcAjax.sel_ndx, function(key, value) {
245
+ var obj = { label: key, value: key };
246
  arr.push(obj);
247
  });
248
  }
251
 
252
  ctc_load_selectors = function(query) {
253
  var arr = [];
254
+ if (1 === loading.sel_ndx) {
255
+ return arr;
256
+ }
257
+ if (0 === loading.sel_ndx) {
258
+ // retrieve from server
259
+ loading.sel_ndx = 1;
260
+ ctc_query_css('sel_ndx', query, ctc_setup_selector_menu);
261
+ return arr;
262
+ }
263
+ if (false === ctc_is_empty(ctcAjax.sel_ndx[query])) {
264
  $.each(ctcAjax.sel_ndx[query], function(key, value) {
265
+ var obj = { label: key, value: value };
266
  arr.push(obj);
267
  });
268
  }
270
  },
271
 
272
  ctc_load_rules = function() {
273
+ var arr = [];
274
+ if (1 === loading.rule) return arr;
275
+ if (0 === loading.rule) {
276
+ loading.rule = 1;
277
+ ctc_query_css('rule', null, ctc_setup_rule_menu);
278
+ return arr;
279
  }
280
+ if (false === ctc_is_empty(ctcAjax.rule)) {
281
+ $.each(ctcAjax.rule, function(key, value) {
282
+ var obj = { label: value.replace(/\d+/g, from_ascii), value: key };
283
+ arr.push(obj);
284
  });
285
  }
286
+ return arr.sort(function (a, b) {
287
+ if (a.label > b.label)
288
+ return 1;
289
+ if (a.label < b.label)
290
+ return -1;
291
+ return 0;
292
  });
 
 
 
 
 
 
293
  },
294
 
295
+ ctc_render_child_rule_input = function(qsid, rule, seq) {
296
+ var html = '',
297
+ value = (ctc_is_empty(ctcAjax.sel_val[qsid])
298
+ || ctc_is_empty(ctcAjax.sel_val[qsid].value)
299
+ || ctc_is_empty(ctcAjax.sel_val[qsid].value[rule]) ? '' : ctcAjax.sel_val[qsid].value[rule]),
300
+ oldRuleObj = ctc_decode_value(rule, ('undefined' == typeof value ? '' : value['parnt'])),
301
+ oldRuleFlag = (false === ctc_is_empty(value['i_parnt']) && value['i_parnt']) ?
302
+ ctcAjax.important_label : '',
303
+ newRuleObj = ctc_decode_value(rule, ('undefined' == typeof value ? '' : value['child'])),
304
+ newRuleFlag = (false === ctc_is_empty(value['i_child']) && value['i_child']) ? 1 : 0,
305
+ impid = 'ctc_' + seq + '_child_' + rule + '_i_' + qsid;
306
+ if (false === ctc_is_empty(ctcAjax.sel_val[qsid])) {
307
+ html += '<div class="ctc-' + ('ovrd' == seq ? 'input' : 'selector' ) + '-row clearfix">' + lf;
308
+ html += '<div class="ctc-input-cell">' + ('ovrd' == seq ? rule.replace(/\d+/g, from_ascii) : ctcAjax.sel_val[qsid].selector
309
+ + '<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_' + qsid + '" >' + ctcAjax.edit_txt + '</a> '
310
+ + (ctc_is_empty(oldRuleObj.orig) ? ctcAjax.child_only_txt : ''))
311
+ + '</div>' + lf;
312
+ if ('ovrd' == seq) {
313
+ html += '<div class="ctc-parent-value ctc-input-cell" id="ctc_' + seq + '_parent_' + rule + '_' + qsid + '">'
314
+ + (ctc_is_empty(oldRuleObj.orig) ? '[no value]' : oldRuleObj.orig + oldRuleFlag) + '</div>' + lf;
315
+ }
316
+ html += '<div class="ctc-input-cell">' + lf;
317
+ if (false === ctc_is_empty(oldRuleObj.names)){
318
+ $.each(oldRuleObj.names, function(ndx, newname) {
319
+ newname = (ctc_is_empty(newname) ? '' : newname);
320
+ html += '<div class="ctc-child-input-cell">' + lf;
321
+ var id = 'ctc_' + seq + '_child_' + rule + '_' + qsid + newname,
322
+ newval;
323
+ if (false === (newval = newRuleObj.values.shift()) ){
324
+ newval = '';
325
+ }
326
 
327
+ html += (ctc_is_empty(newname) ? '' : ctcAjax.field_labels[newname] + ':<br/>')
328
+ + '<input type="text" id="' + id + '" name="' + id + '" class="ctc-child-value'
329
+ + ((newname + rule).toString().match(/color/) ? ' color-picker' : '')
330
+ + ((newname).toString().match(/url/) ? ' ctc-input-wide' : '')
331
+ + '" value="' + newval + '" />' + lf;
332
+ html += '</div>' + lf;
333
+ });
334
+ html += '<label for="' + impid + '"><input type="checkbox" id="' + impid + '" name="' + impid + '" value="1" '
335
+ + (1 === newRuleFlag ? 'checked' : '') + ' />' + ctcAjax.important_label + '</label>' + lf;
336
+ }
337
+ html += '</div>' + lf;
338
+ html += ('ovrd' == seq ? '' : '<div class="ctc-swatch ctc-specific" id="ctc_child_' + rule + '_' + qsid + '_swatch">'
339
+ + ctcAjax.swatch_txt + '</div>' + lf
340
+ + '<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_' + rule + '_' + qsid + '_cell">' + lf
341
+ + '<input type="button" class="button ctc-save-input" id="ctc_save_' + rule + '_' + qsid
342
+ + '" name="ctc_save_' + rule + '_' + qsid + '" value="Save" /></div>' + lf);
343
+ html += '</div><!-- end input row -->' + lf;
344
  }
 
 
 
 
 
 
 
345
  return html;
346
  },
347
+ ctc_render_selector_inputs = function(qsid) {
348
+ if (1 === loading.sel_val) {
349
+ return false;
350
+ }
351
+ if (0 == loading.sel_val) {
352
+ loading.sel_val = 1;
353
+ ctc_query_css('sel_val', qsid, ctc_render_selector_inputs);
354
+ return false;
355
+ }
356
+ var id, html, val;
357
+ if (ctc_is_empty(ctcAjax.sel_val[qsid])) {
358
+ $('#ctc_sel_ovrd_rule_inputs').html('')
359
+ } else {
360
+ if (ctc_is_empty(ctcAjax.sel_val[qsid].seq)) {
361
+ $('#ctc_child_load_order_container').html('');
362
+ } else {
363
+ id = 'ctc_ovrd_child_seq_' + qsid;
364
+ val = parseInt(ctcAjax.sel_val[qsid].seq);
365
+ html = '<input type="text" id="' + id + '" name="' + id + '" class="ctc-child-value" value="' + val + '" />';
366
+ $('#ctc_child_load_order_container').html(html);
367
+ }
368
+ if (ctc_is_empty(ctcAjax.sel_val[qsid].value)){
369
+ $('#ctc_sel_ovrd_rule_inputs').html('');
370
+ } else {
371
+ html = '';
372
+ $.each(ctcAjax.sel_val[qsid].value, function(rule, value) {
373
+ html += ctc_render_child_rule_input(qsid, rule, 'ovrd');
374
+ });
375
+ $('#ctc_sel_ovrd_rule_inputs').html(html).find('.color-picker').each(function() {
376
+ ctc_setup_iris(this);
377
+ });
378
+ ctc_coalesce_inputs('#ctc_child_all_0_swatch');
379
+ }
380
  }
 
 
 
 
381
  }
382
+ ctc_render_css_preview = function(theme) {
383
+ if (1 === loading.preview) {
384
+ return false;
385
+ }
386
+ if (0 == loading.preview) {
387
+ loading.preview = 1;
388
+ var theme;
389
+ if (!(theme = $(this).attr('id').toString().match(/(child|parnt)/)[1])) {
390
+ theme = 'child';
391
+ }
392
+ ctc_set_notice('')
393
+ ctc_query_css('preview', theme, ctc_render_css_preview);
394
+ return false;
395
+ }
396
+ if (2 == loading.preview) {
397
+ $('#view_'+theme+'_options_panel').text(ctcAjax.previewResponse);
398
+ loading.preview = 0;
399
+ }
400
+ },
401
+ ctc_render_rule_value_inputs = function(ruleid) {
402
+ if (1 === loading.rule_val) return false;
403
 
404
+ if (0 == loading.rule_val) {
405
+ loading.rule_val = 1;
406
+ ctc_query_css('rule_val', ruleid, ctc_render_rule_value_inputs);
407
+ return false;
408
+ }
409
+ var rule = ctcAjax.rule[ruleid],
410
+ html = '<div class="ctc-input-row clearfix" id="ctc_rule_row_' + rule + '">' + lf;
411
+ if (false === ctc_is_empty(ctcAjax.rule_val[ruleid])){
412
+ $.each(ctcAjax.rule_val[ruleid], function(valid, value) {
413
+ var oldRuleObj = ctc_decode_value(rule, value);
414
+ html += '<div class="ctc-parent-row clearfix" id="ctc_rule_row_' + rule + '_' + valid + '">' + lf;
415
+ html += '<div class="ctc-input-cell ctc-parent-value" id="ctc_' + valid + '_parent_' + rule + '_' + valid + '">'
416
+ + oldRuleObj.orig + '</div>' + lf;
417
+ html += '<div class="ctc-input-cell">' + lf;
418
+ html += '<div class="ctc-swatch ctc-specific" id="ctc_' + valid + '_parent_' + rule + '_' + valid + '_swatch">'
419
+ + ctcAjax.swatch_txt + '</div></div>' + lf;
420
+ html += '<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_' + rule + '_' + valid + '">'
421
+ + ctcAjax.selector_txt + '</a></div>' + lf;
422
+ html += '<div id="ctc_selector_' + rule + '_' + valid + '_container" class="ctc-selector-container clearfix">' + lf;
423
+ html += '<a href="#" id="ctc_selector_' + rule + '_' + valid + '_close" class="ctc-selector-handle" style="float:right">'
424
+ + ctcAjax.close_txt + '</a><div id="ctc_status_val_qry_' + valid + '"></div>' + lf;
425
+ html += '<div id="ctc_selector_' + rule + '_' + valid + '_rows"></div>' + lf;
426
+ html += '</div></div>' + lf;
 
 
 
 
 
427
  });
428
+ html += '</div>' + lf;
429
+ }
430
+ $('#ctc_rule_value_inputs').html(html).find('.ctc-swatch').each(function() {
431
+ ctc_coalesce_inputs(this);
432
  });
433
+ },
434
+
435
+ ctc_render_selector_value_inputs = function(valid) {
436
+ if (1 == loading.val_qry) return false;
437
+ var params,
438
+ page_ruleid,
439
+ rule = $('#ctc_rule_menu_selected').text().replace(/[^\w\-]/g, to_ascii),
440
+ selector,
441
+ html = '';
442
+ if (0 === loading.val_qry) {
443
+ loading.val_qry = 1;
444
+ params = { 'rule': rule };
445
+ ctc_query_css('val_qry', valid, ctc_render_selector_value_inputs, params);
446
+ return false;
447
+ }
448
+ if (false === ctc_is_empty(ctcAjax.val_qry[valid])){
449
+ $.each(ctcAjax.val_qry[valid], function(rule, queries) {
450
+ page_rule = rule;
451
+ $.each(queries, function(query, selectors) {
452
+ html += '<h4 class="ctc-query-heading">' + query + '</h4>' + lf;
453
+ if (false === ctc_is_empty(selectors)){
454
+ $.each(selectors, function(qsid, data) {
455
+ ctcAjax.sel_val[qsid] = data;
456
+ html += ctc_render_child_rule_input(qsid, rule, valid);
457
+ });
458
+ }
459
+ });
460
+ });
461
+ }
462
+ selector = '#ctc_selector_' + rule + '_' + valid + '_rows';
463
+ $(selector).html(html).find('.color-picker').each(function() {
464
  ctc_setup_iris(this);
465
  });
466
+ $(selector).find('.ctc-swatch').each(function() {
467
  ctc_coalesce_inputs(this);
468
  });
469
+
470
  },
471
+ ctc_query_css = function(obj, key, callback, params) {
472
+ var postdata = { 'ctc_query_obj' : obj, 'ctc_query_key': key },
473
+ status_sel = '#ctc_status_' + obj + ('val_qry' == obj ? '_' + key : '');
474
+
475
+ if ('object' === typeof params) {
476
+ $.each(params, function(key, val){
477
+ postdata['ctc_query_' + key] = val;
 
 
 
 
 
 
 
478
  });
479
  }
480
+ $('.ctc-status-icon').remove();
481
+ $(status_sel).append('<span class="ctc-status-icon spinner"></span>');
482
+ $('.spinner').show();
483
+ // add wp ajax action to array
484
+ postdata['action'] = 'ctc_query';
485
+ postdata['_wpnonce'] = $('#_wpnonce').val();
486
+ // ajax post input data
487
+ $.post(
488
+ // get ajax url from localized object
489
+ ctcAjax.ajaxurl,
490
+ //Data
491
+ postdata,
492
+ //on success function
493
+ function(response){
494
+ // console.log(response);
495
+ // hide spinner
496
+ loading[obj] = 2;
497
+ $('.ctc-status-icon').removeClass('spinner');
498
+ // show check mark
499
+ if (ctc_is_empty(response)) {
500
+ $('.ctc-status-icon').addClass('failure');
501
+ if ('preview' == obj) {
502
+ ctcAjax.previewResponse = ctcAjax.css_fail_txt;
503
+ callback(key);
504
+ }
505
+ } else {
506
+ $('.ctc-status-icon').addClass('success');
507
+ if ('preview' == obj) {
508
+ ctcAjax.previewResponse = response.shift().data;
509
+ } else {
510
+ // update data objects
511
+ ctc_update_cache(response);
512
+ }
513
+ if ('function' === typeof callback) {
514
+ callback(key);
515
+ }
516
+ return false;
517
+ }
518
+ },'json'
519
+ ).fail(function(){
520
+ // hide spinner
521
+ $('.ctc-status-icon').removeClass('spinner');
522
+ // show check mark
523
+ $('.ctc-status-icon').addClass('failure');
524
+ if ('preview' == obj) {
525
+ ctcAjax.previewResponse = ctcAjax.css_fail_txt;
526
+ loading[obj] = 2;
527
+ callback(key);
528
+ } else {
529
+ loading[obj] = 0;
530
+ }
531
+
532
+ });
533
+ return false;
534
  },
 
535
  ctc_save = function(obj) {
536
  var postdata = {},
537
+ $selector, $query, $imports, $rule,
538
+ id = $(obj).attr('id'), newsel;
539
+ if (ctc_is_empty(saveEvents[id])) {
540
+ saveEvents[id] = 0;
541
+ }
542
+ saveEvents[id]++;
543
  // disable the button until ajax returns
544
  $(obj).prop('disabled', true);
545
  // clear previous success/fail icons
558
  // coalesce inputs
559
  postdata = ctc_coalesce_inputs(obj);
560
  }
561
+ // add rename selector value if it exists
562
+ $('#ctc_sel_ovrd_selector_selected').find('#ctc_rewrite_selector').each(function(){
563
+ newsel = $('#ctc_rewrite_selector').val(),
564
+ origsel = $('#ctc_rewrite_selector_orig').val();
565
+ if (ctc_is_empty(newsel) || !newsel.toString().match(/\w/)) {
566
+ newsel = origsel;
567
+ } else {
568
+ postdata['ctc_rewrite_selector'] = newsel;
569
+ }
570
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
571
+ $('#ctc_sel_ovrd_selector_selected').html(newsel);
572
+ });
573
  // add wp ajax action to array
574
  postdata['action'] = 'ctc_update';
575
  postdata['_wpnonce'] = $('#_wpnonce').val();
581
  postdata,
582
  //on success function
583
  function(response){
584
+ // console.log(response);
585
  // release button
586
  $(obj).prop('disabled', false);
587
  // hide spinner
593
  $('.ctc-status-icon').addClass('success');
594
  $('#ctc_new_selectors').val('');
595
  // update data objects
596
+ ctc_update_cache(response);
597
+ ctc_setup_menus();
598
+ if (false === ctc_is_empty(rewrite_id)) {
599
+ ctc_set_selector(rewrite_id, rewrite_sel);
600
+ rewrite_id = rewrite_sel = null;
601
+ }
602
  }
603
  return false;
604
+ }, 'json'
 
605
  ).fail(function(){
606
  // release button
607
  $(obj).prop('disabled', false);
612
  });
613
  return false;
614
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
  ctc_decode_value = function(rule, value) {
616
+ value = ('undefined' == typeof value ? '' : value);
617
  var obj = { 'orig': value };
618
+ if (rule.toString().match(/^border(\-(top|right|bottom|left))?$/)) {
619
+ var params = value.toString().split(/ +/);
620
  obj['names'] = [
621
  '_border_width',
622
  '_border_style',
623
  '_border_color',
624
  ];
625
  obj['values'] = [
626
+ ('undefined' == typeof params[0] ? '' : params[0]),
627
+ ('undefined' == typeof params[1] ? '' : params[1]),
628
+ ('undefined' == typeof params[2] ? '' : params[2])
629
  ];
630
+ } else if (rule.toString().match(/^background\-image/)) {
631
  obj['names'] = [
632
  '_background_url',
633
  '_background_origin',
635
  '_background_color2'
636
  ];
637
  obj['values'] = ['','','',''];
638
+ if (false === (ctc_is_empty(value)) && !(value.toString().match(/url/))) {
639
+ var params = value.toString().split(/:/);
640
+ obj['values'][1] = ('undefined' == typeof params[0] ? '' : params[0]);
641
+ obj['values'][2] = ('undefined' == typeof params[1] ? '' : params[1]);
642
+ obj['values'][3] = ('undefined' == typeof params[3] ? '' : params[3]);
643
  obj['orig'] = [ obj['values'][1], obj['values'][2], obj['values'][3] ].join(' '); // display "origin color1 color2"
644
  } else {
645
  obj['values'][0] = value;
651
  return obj;
652
  },
653
 
654
+ ctc_set_query = function(value) {
655
+ currentQuery = value;
656
  $('#ctc_sel_ovrd_query').val('');
657
+ $('#ctc_sel_ovrd_query_selected').text(value);
658
+ $('#ctc_sel_ovrd_selector').val('');
659
+ $('#ctc_sel_ovrd_selector_selected').html('&nbsp;');
660
+ $('#ctc_sel_ovrd_rule_inputs').html('');
661
+ ctc_setup_selector_menu(value);
662
+ ctc_coalesce_inputs('#ctc_child_all_0_swatch');
663
  $('#ctc_new_selector_row').show();
664
  },
665
 
666
  ctc_set_selector = function(value,label) {
667
  $('#ctc_sel_ovrd_selector').val('');
668
  $('#ctc_sel_ovrd_selector_selected').text(label);
669
+ $('#ctc_sel_ovrd_qsid').val(value);
670
+ currentSel = value;
671
+ if (1 != loading.sel_val) loading.sel_val = 0;
672
  ctc_render_selector_inputs(value);
673
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
674
+ $('#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs,.ctc-rewrite-toggle').show();
675
  },
676
 
677
  ctc_set_rule = function(value,label) {
678
  $('#ctc_rule_menu').val('');
679
  $('#ctc_rule_menu_selected').text(label);
680
+ if (1 != loading.rule_val) loading.rule_val = 0;
681
  ctc_render_rule_value_inputs(value);
682
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
683
  $('#ctc_rule_value_inputs,#ctc_input_row_rule_header').show();
684
  },
685
+ ctc_setup_query_menu = function() {
686
+ ctc_queries = ctc_load_queries();
687
+ $('#ctc_sel_ovrd_query').autocomplete({
688
+ source: ctc_queries,
689
+ minLength: 0,
690
+ selectFirst: true,
691
+ autoFocus: true,
692
+ select: function(e, ui) {
693
+ ctc_set_query(ui.item.value);
694
+ return false;
695
+ },
696
+ focus: function(e) { e.preventDefault(); }
697
+ });
698
+ },
699
+ ctc_setup_selector_menu = function(query) {
700
+ ctc_selectors = ctc_load_selectors(query);
701
+ $('#ctc_sel_ovrd_selector').autocomplete({
702
+ source: ctc_selectors,
703
+ selectFirst: true,
704
+ autoFocus: true,
705
+ select: function(e, ui) {
706
+ ctc_set_selector(ui.item.value, ui.item.label);
707
+ return false;
708
+ },
709
+ focus: function(e) { e.preventDefault(); }
710
+ });
711
+ },
712
+ ctc_setup_rule_menu = function() {
713
+ ctc_rules = ctc_load_rules();
714
+ $('#ctc_rule_menu').autocomplete({
715
+ source: ctc_rules,
716
+ //minLength: 0,
717
+ selectFirst: true,
718
+ autoFocus: true,
719
+ select: function(e, ui) {
720
+ ctc_set_rule(ui.item.value, ui.item.label);
721
+ return false;
722
+ },
723
+ focus: function(e) { e.preventDefault(); }
724
+ });
725
+ },
726
+ ctc_filtered_rules = function(request, response) {
727
+ var arr = [],
728
+ noval = (ctc_is_empty(ctcAjax.sel_val[currentSel])) || (ctc_is_empty(ctcAjax.sel_val[currentSel].value));
729
+ if (ctc_is_empty(ctc_rules)) {
730
+ ctc_rules = ctc_load_rules();
731
+ }
732
+ $.each(ctc_rules, function(key, val){
733
+ var skip = false,
734
+ matcher = new RegExp( $.ui.autocomplete.escapeRegex( request.term ), "i" );
735
+ if (matcher.test( val.label )) {
736
+ if (false === noval) {
737
+ // skip rule if in current selector array
738
+ $.each(ctcAjax.sel_val[currentSel].value, function(rule, value) {
739
+ if (val.label == rule.replace(/\d+/g, from_ascii)) {
740
+ skip = true;
741
+ return false;
742
+ }
743
+ });
744
+ if (skip) {
745
+ return;
746
+ }
747
+ }
748
+ // add rule
749
+ arr.push(val);
750
+ }
751
+ });
752
+ response(arr);
753
+ },
754
+ ctc_setup_new_rule_menu = function() {
755
+ $('#ctc_new_rule_menu').autocomplete({
756
+ source: ctc_filtered_rules,
757
+ //minLength: 0,
758
+ selectFirst: true,
759
+ autoFocus: true,
760
+ select: function(e, ui) {
761
+ e.preventDefault();
762
+ var n = $(ctc_render_child_rule_input(currentSel, ui.item.label.replace(/[^\w\-]/g, to_ascii), 'ovrd'));
763
+ $('#ctc_sel_ovrd_rule_inputs').append(n);
764
+ $('#ctc_new_rule_menu').val('');
765
+ if (ctc_is_empty(ctcAjax.sel_val[currentSel].value)) {
766
+ ctcAjax.sel_val[currentSel]['value'] = {};
767
+ }
768
+ ctcAjax.sel_val[currentSel].value[ui.item.label] = {'child': ''};
769
+ n.find('input[type="text"]').each(function(ndx, el){
770
+ if ($(el).hasClass('color-picker'))
771
+ ctc_setup_iris(el);
772
+ $(el).focus();
773
+ });
774
+ return false;
775
+ },
776
+ focus: function(e) { e.preventDefault(); }
777
+ });
778
+ },
779
+ ctc_setup_menus = function() {
780
+ ctc_setup_query_menu();
781
+ ctc_setup_selector_menu(currentQuery);
782
+ ctc_setup_rule_menu();
783
+ ctc_setup_new_rule_menu();
784
+ },
785
+ ctc_theme_exists = function(testslug, testtype) {
786
+ var exists = false;
787
+ $.each(ctcAjax.themes, function(type, theme){
788
+ $.each(theme, function(slug, data){
789
+ if (slug == testslug && ('parnt' == type || 'new' == testtype)) {
790
+ exists = true;
791
+ return false;
792
+ }
793
+ });
794
+ if (exists) return false;
795
+ });
796
+ return exists;
797
+ },
798
+
799
+ ctc_set_notice = function(noticearr) {
800
+ var errorHtml = '';
801
+ if (false === ctc_is_empty(noticearr)) {
802
+ $.each(noticearr, function(type, list){
803
+ errorHtml += '<div class="' + type + '"><ul>' + lf;
804
+ $(list).each(function(ndx, el){
805
+ errorHtml += '<li>' + el.toString() + '</li>' + lf;
806
+ });
807
+ errorHtml += '</ul></div>';
808
+ });
809
+ }
810
+ $('#ctc_error_notice').html(errorHtml);
811
+ },
812
+ ctc_validate = function() {
813
+ var regex = /[^\w\-]/,
814
+ newslug = $('#ctc_child_template').val().toString().replace(regex).toLowerCase(),
815
+ slug = $('#ctc_theme_child').val().toString().replace(regex).toLowerCase(),
816
+ type = $('input[name=ctc_child_type]:checked').val(),
817
+ errors = [];
818
+ if ('new' == type) slug = newslug;
819
+ if (ctc_theme_exists(slug, type)) {
820
+ errors.push(ctcAjax.theme_exists_txt.toString().replace(/%s/, slug));
821
+ }
822
+ if ('' === slug) {
823
+ errors.push(ctcAjax.inval_theme_txt);
824
+ }
825
+ if ('' === $('#ctc_child_name').val()) {
826
+ errors.push(ctcAjax.inval_name_txt);
827
+ }
828
+ if (errors.length) {
829
+ ctc_set_notice({'error': errors});
830
+ return false;
831
+ }
832
+ return true;
833
+ },
834
+ ctc_set_theme_menu = function(e) {
835
+ var slug = $('#ctc_theme_child').val();
836
+ if (false === ctc_is_empty(ctcAjax.themes.child[slug])) {
837
+ $('#ctc_child_name').val(ctcAjax.themes.child[slug].Name);
838
+ $('#ctc_child_author').val(ctcAjax.themes.child[slug].Author);
839
+ $('#ctc_child_version').val(ctcAjax.themes.child[slug].Version);
840
+ }
841
+ },
842
+ fade_update_notice = function() {
843
+ $('.updated, .error').slideUp('slow', function(){ $('.updated').remove(); });
844
+ },
845
+ ctc_focus_panel = function(id) {
846
+ var panelid = id + '_panel';
847
+ $('.nav-tab').removeClass('nav-tab-active');
848
+ $('.ctc-option-panel').removeClass('ctc-option-panel-active');
849
+ $('.ctc-selector-container').hide();
850
+ $(id).addClass('nav-tab-active');
851
+ $('.ctc-option-panel-container').scrollTop(0);
852
+ $(panelid).addClass('ctc-option-panel-active');
853
+ },
854
+ ctc_selector_edit = function(obj) {
855
+ var qsid = $(obj).attr('id').match(/_(\d+)$/)[1],
856
+ q = ctcAjax.sel_val[qsid].query,
857
+ s = ctcAjax.sel_val[qsid].selector,
858
+ id = '#query_selector_options';
859
+ ctc_set_query(q);
860
+ ctc_set_selector(qsid, s);
861
+ ctc_focus_panel(id);
862
+ },
863
+ ctc_selector_input_toggle = function(obj) {
864
+ var origval;
865
+ if ($('#ctc_rewrite_selector').length) {
866
+ origval = $('#ctc_rewrite_selector_orig').val();
867
+ $('#ctc_sel_ovrd_selector_selected').text(origval);
868
+ $(obj).text(ctcAjax.rename_txt);
869
+ } else {
870
+ origval = $('#ctc_sel_ovrd_selector_selected').text();
871
+ $('#ctc_sel_ovrd_selector_selected').html('<input id="ctc_rewrite_selector" name="ctc_rewrite_selector" type="text" value="'
872
+ + origval + '" autocomplete="off" /><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'
873
+ + origval + '"/>');
874
+ $(obj).text(ctcAjax.cancel_txt);
875
+ }
876
+ }
877
  // initialize vars
878
+ // ajax semaphores: 0 = reload, 1 = loading, 2 = loaded
879
+ loading = {
880
+ 'rule': 2,
881
+ 'sel_ndx': 2,
882
+ 'val_qry': 0,
883
+ 'rule_val': 0,
884
+ 'sel_val': 0,
885
+ 'preview': 0
886
+ },
887
+
888
+ ctc_selectors = [],
889
+ ctc_queries = [],
890
+ ctc_rules = [];
891
+ // -- end var definitions
892
+
893
+ // initialize Iris color picker
894
  $('.color-picker').each(function() {
895
  ctc_setup_iris(this);
896
  });
897
+ // bind event handlers
898
  $('.ctc-option-panel-container').on('focus', '.color-picker', function(){
899
+ ctc_set_notice('')
900
  $(this).iris('toggle');
901
  $('.iris-picker').css({'position':'absolute', 'z-index':10});
902
  });
903
  $('.ctc-option-panel-container').on('focus', 'input', function() {
904
+ ctc_set_notice('')
905
  $('.color-picker').not(this).iris('hide');
906
  });
907
+ $('.ctc-option-panel-container').on('change', '.ctc-child-value, input[type=checkbox]', function() {
908
  ctc_coalesce_inputs(this);
909
  });
910
  $('.ctc-option-panel-container').on('click', '.ctc-selector-handle', function(e) {
911
  e.preventDefault();
912
+ ctc_set_notice('')
913
+ var id = $(this).attr('id').toString().replace('_close', ''),
914
+ valid = id.toString().match(/_(\d+)$/)[1];
915
+ if ($('#' + id + '_container').is(':hidden')) {
916
+ if (1 != loading.val_qry) loading.val_qry = 0;
917
+ ctc_render_selector_value_inputs(valid);
918
+ }
919
  $('#' + id + '_container').fadeToggle('fast');
920
  $('.ctc-selector-container').not('#' + id + '_container').fadeOut('fast');
921
  });
922
  $('.nav-tab').on('click', function(e){
923
  e.preventDefault();
924
+ // clear the notice box
925
+ ctc_set_notice('');
926
+ $('.ctc-status-icon').remove();
927
+ var id = '#' + $(this).attr('id');
928
+ ctc_focus_panel(id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
  });
930
+ $('#view_child_options,#view_parnt_options').on('click', ctc_render_css_preview);
931
+ $('#ctc_load_form').on('submit', function() {
932
+ return (ctc_validate() && confirm(ctcAjax.load_txt) ) ;
933
  });
934
+ $('#parent_child_options_panel').on('change', '#ctc_theme_child', ctc_set_theme_menu );
935
  $(document).on('click', '.ctc-save-input', function(e) {
936
  ctc_save(this);
937
  });
938
+ $(document).on('click', '.ctc-selector-edit', function(e) {
939
+ ctc_selector_edit(this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940
  });
941
+ $(document).on('click', '.ctc-rewrite-toggle', function(e) {
942
+ e.preventDefault();
943
+ ctc_selector_input_toggle(this);
944
+ });//ctc_rewrite_toggle
945
 
946
+ // initialize menus
947
+ ctc_setup_menus();
948
+ ctc_set_query(currentQuery);
949
+ $('input[type=submit],input[type=button]').prop('disabled', false);
950
+ setTimeout(fade_update_notice, 6000);
951
+ });
952
+
953
+
js/chld-thm-cfg.min.js CHANGED
@@ -2,10 +2,10 @@
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.0
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
- (function(e){var k="\n",l=function(m){e(m).iris({change:function(){h(m)}})},h=function(s){var o=/^(ctc_(ovrd_)?(parent|child)_([a-z\-]+)_(\d+))(_\w+)?$/,t=e(s).parents(".ctc-selector-row, .ctc-parent-row").first(),r=t.find(".ctc-swatch").first(),q={parent:{},child:{}},p={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},n={child:false,parent:false},m={};t.find(".ctc-parent-value, .ctc-child-value").each(function(){var z=e(this).attr("id"),u=z.match(o),v=u[3],C=(undefined==u[4]?"":u[4]),A=u[5],y=(undefined==u[6]?"":u[6]),B=("parent"==v?e(this).text():e(this).val()),x,w;if("child"==v){m[z]=B}if(a(B)){return}if(false===a(y)){switch(y){case"_border_width":q[v][C+"-width"]=B;break;case"_border_style":q[v][C+"-style"]=B;break;case"_border_color":q[v][C+"-color"]=B;break;case"_background_url":q[v]["background-image"]=b(v,B);break;case"_background_color":q[v]["background-color"]=s.value;break;case"_background_color1":p[v].start=B;n[v]=true;break;case"_background_color2":p[v].end=B;n[v]=true;break;case"_background_origin":p[v].origin=B;n[v]=true;break}}else{if(x=C.match(/^border(\-(top|right|bottom|left))?$/)&&!B.match(/none/)){w=B.split(/ +/);q[v][C+"-width"]=undefined==w[0]?"":w[0];q[v][C+"-style"]=undefined==w[1]?"":w[1];q[v][C+"-color"]=undefined==w[2]?"":w[2]}else{if("background-image"==C){if(B.match(/url\(/)){q[v]["background-image"]=b(v,B)}else{w=B.split(/ +/);if(w.length>2){p[v].origin=undefined==w[0]?"top":w[0];p[v].start=undefined==w[1]?"transparent":w[1];p[v].end=undefined==w[2]?"transparent":w[2];n[v]=true}else{q[v]["background-image"]=B}}}else{q[v][C]=B}}}});if(undefined!=r){e(r).removeAttr("style");if(n.parent){e(r).ctcgrad(p.parent.origin,[p.parent.start,p.parent.end])}e(r).css(q.parent);if(!(r.attr("id").match(/parent/))){if(n.child){e(r).ctcgrad(p.child.origin,[p.child.start,p.child.end])}e(r).css(q.child)}}return m},j=function(p){var o,m,n;if(undefined!=p.imports){ctcAjax.imports[ctcAjax.child_theme]=p.imports}e(p.del).each(function(){if(undefined!=this.selnum){delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum]}else{if(undefined!=this.query){delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query]}else{if(undefined!=this.value){delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value]}else{if(undefined!=this.rule){delete ctcAjax.val_ndx[ctcAjax.child_theme][this.rule]}}}}if(undefined!=this.query){o=this.query}if(undefined!=this.selnum){m=this.selnum}if(undefined!=this.rule){n=this.rule}});e(p.insert).each(function(){ctcAjax.sel_ndx[this.query][this.selector]=this.selnum;ctcAjax.data[this.selnum]={selector:this.selector,query:this.query,value:{}};if(undefined!=this.query){o=this.query}if(undefined!=this.selnum){m=this.selnum}if(undefined!=this.rule){n=this.rule}});e(p.update).each(function(){if(undefined==ctcAjax.val_ndx[ctcAjax.child_theme]){ctcAjax.val_ndx[ctcAjax.child_theme]={}}if(undefined==ctcAjax.val_ndx[ctcAjax.child_theme][this.rule]){ctcAjax.val_ndx[ctcAjax.child_theme][this.rule]={}}if(this.value&&undefined==ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value]){ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value]={}}if(this.value&&undefined==ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query]){ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query]={}}if(this.value&&undefined==ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum]){ctcAjax.val_ndx[ctcAjax.child_theme][this.rule][this.value][this.query][this.selnum]=0}if(this.rule&&undefined==ctcAjax.data[this.selnum].value[this.rule]){ctcAjax.data[this.selnum].value[this.rule]={}}ctcAjax.data[this.selnum].value[this.rule][ctcAjax.child_theme]=this.value+(this.important>0?" !important":"");if(undefined!=this.query){o=this.query}if(undefined!=this.selnum){m=this.selnum}if(undefined!=this.rule){n=this.rule}});if(o){ctc_set_query(o,o)}if(m){ctc_set_selector(m,ctcAjax.data[m].selector)}if(n){ctc_set_rule(n,n)}},b=function(q,n){var p=n.match(/url\([" ]*(.+?)[" ]*\)/),o=(undefined==p?null:p[1]),m=ctcAjax.theme_uri+"/"+("parent"==q?ctcAjax.parent_theme:ctcAjax.child_theme)+"/",r;if(!o){return false}else{if(o.match(/^(http:|\/)/)){r=n}else{r="url("+m+o+")"}}return r},a=function(n){if(undefined==n||false===n||null===n||""===n||0===n){return true}if(true===n||"string"===typeof n||"number"===typeof n){return false}if("object"===typeof n){for(var m in n){if(n.hasOwnProperty(m)){return false}}return true}return false},g=function(){var m=[];if(false===a(ctcAjax.sel_ndx)){e.each(ctcAjax.sel_ndx,function(n,o){obj={label:n,value:n};m.push(obj)})}return m},d=function(n){var m=[];if(false===a(ctcAjax.sel_ndx[n])){e.each(ctcAjax.sel_ndx[n],function(o,p){obj={label:o,value:p};m.push(obj)})}return m},i=function(){var n={},m=[];if(false===a(ctcAjax.val_ndx[ctcAjax.parent_theme])){e.each(ctcAjax.val_ndx[ctcAjax.parent_theme],function(o,p){n[o]++})}if(false===a(ctcAjax.val_ndx[ctcAjax.child_theme])){e.each(ctcAjax.val_ndx[ctcAjax.child_theme],function(o,p){n[o]++})}e.each(["border-width","border-style","border-color","padding","margin","background","font"],function(){n[this]++});if(false===a(n)){e.each(n,function(o,p){m.push(o)})}return m.sort()},f=function(r,s,n){var o="",q=(undefined==ctcAjax.data[r].value||undefined==ctcAjax.data[r].value[s]?"":ctcAjax.data[r].value[s]),p=ctc_decode_value(s,(undefined==q?"":q[ctcAjax.parent_theme])),m=ctc_decode_value(s,(undefined==q?"":q[ctcAjax.child_theme]));if(q){unique_rule_value[s+"%%"+q[ctcAjax.parent_theme]]=1;unique_rule_value[s+"%%"+q[ctcAjax.child_theme]]=1}o+='<div class="ctc-'+(n?"selector":"input")+'-row clearfix">'+k;o+='<div class="ctc-input-cell">'+(n?ctcAjax.data[r].selector:s)+"</div>"+k;o+='<div class="ctc-parent-value'+(n?" ctc-hidden":" ctc-input-cell")+'" id="ctc_parent_'+s+"_"+r+'">'+(a(p.orig)?"[no value]":p.orig)+"</div>"+k;o+='<div class="ctc-input-cell">'+k;if(false===a(p.names)){e.each(p.names,function(t,u){u=(a(u)?"":u);o+='<div class="ctc-child-input-cell">'+k;var w="ctc_"+(n?"":"ovrd_")+"child_"+s+"_"+r+u,v;if(!(v=m.values.shift())){v=""}o+=(a(u)?"":ctcAjax.labels[u]+":<br/>")+'<input type="text" id="'+w+'" name="'+w+'" class="ctc-child-value'+((u+s).match(/color/)?" color-picker":"")+((u).match(/url/)?" ctc-input-wide":"")+'" value="'+v+'" />'+k;o+="</div>"+k})}o+="</div>"+k;o+=(n?'<div class="ctc-swatch ctc-specific" id="ctc_child_'+s+"_"+r+'_swatch">'+ctcAjax.swatch_text+"</div>"+k+'<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+s+"_"+r+'_cell">'+k+'<input type="button" class="button ctc-save-input" id="ctc_save_'+s+"_"+r+'" name="ctc_save_'+s+"_"+r+'" value="Save" /></div>'+k:"");o+="</div><!-- end input row -->"+k;return o},c=function(o){if(undefined==ctcAjax.data[o].value){return}var n="",m=0;if(false===a(ctcAjax.data[o].value)){e.each(ctcAjax.data[o].value,function(q,p){n+=f(o,q,false)})}e("#ctc_sel_ovrd_rule_inputs").html(n).find(".color-picker").each(function(){l(this)});h("#ctc_child_all_0_swatch")};ctc_render_rule_value_inputs=function(p){var n='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+p+'">'+k,o=0,m={parent:ctcAjax.parent_theme,child:ctcAjax.child_theme};unique_rule_value={},e.each(m,function(q,r){if(a(ctcAjax.val_ndx[r])||undefined==ctcAjax.val_ndx[r][p]){return}e.each(ctcAjax.val_ndx[r][p],function(t,s){if(unique_rule_value[p+"%%"+t]){return}else{o++;oldRuleObj=ctc_decode_value(p,t),n+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+p+"_"+o+'">'+k;n+='<div class="ctc-input-cell ctc-parent-value" id="ctc_parent_'+p+"_"+o+'">'+oldRuleObj.orig+"</div>"+k;n+='<div class="ctc-input-cell">'+k;n+='<div class="ctc-swatch ctc-specific" id="ctc_parent_'+p+"_"+o+'_swatch">'+ctcAjax.swatch_text+"</div></div>"+k;n+='<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+p+"_"+o+'">'+ctcAjax.selector_text+"</a></div>"+k;n+='<div id="ctc_selector_'+p+"_"+o+'_container" class="ctc-selector-container clearfix">'+k;n+='<a href="#" id="ctc_selector_'+p+"_"+o+'_close" class="ctc-selector-handle" style="float:right">'+ctcAjax.close_text+"</a>"+k;n+=ctc_render_selector_value_inputs(p,s);n+="</div></div>"+k}})});n+="</div>"+k;e("#ctc_rule_value_inputs").html(n).find(".color-picker").each(function(){l(this)});e("#ctc_rule_value_inputs").find(".ctc-swatch").each(function(){h(this)})},ctc_render_selector_value_inputs=function(q,o){var m="",p="",n;if(false===a(o)){e.each(o,function(s,r){if(s!=p){p=s;m+='<h4 class="ctc-query-heading">'+s+"</h4>"+k}if(false===a(r)){e.each(r,function(u,t){m+=f(u,q,true)})}})}return m},ctc_save=function(q){var p={},r,o,m,n;e(q).prop("disabled",true);e(".ctc-status-icon").remove();e(q).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner"></span>');e(".spinner").show();if((r=e("#ctc_new_selectors"))&&"ctc_save_new_selectors"==e(q).attr("id")){p.ctc_new_selectors=r.val();if(o=e("#ctc_sel_ovrd_query_selected")){p.ctc_sel_ovrd_query=o.text()}}else{if((m=e("#ctc_child_imports"))&&"ctc_save_imports"==e(q).attr("id")){p.ctc_child_imports=m.val()}else{p=h(q)}}p.action="ctc_update";p._wpnonce=e("#_wpnonce").val();e.post(ctcAjax.ajaxurl,p,function(s){e(q).prop("disabled",false);e(".ctc-status-icon").removeClass("spinner");if(a(s)){e(".ctc-status-icon").addClass("failure")}else{e(".ctc-status-icon").addClass("success");e("#ctc_new_selectors").val("");j(s)}return false},"json").fail(function(){e(q).prop("disabled",false);e(".ctc-status-icon").removeClass("spinner");e(".ctc-status-icon").addClass("failure")});return false},ctc_serialize=function(n){var m;if(undefined==n){m=""}else{if("string"===typeof n||"number"===typeof n){m=n}else{if("object"===typeof n){m="";e.each(n,function(o,p){m+=o+": "+p+",\n"})}}}return m},ctc_decode_value=function(o,m){m=(undefined==m?"":m);var n={orig:m};if(o.match(/^border(\-(top|right|bottom|left))?$/)){var p=m.split(/ +/);n.names=["_border_width","_border_style","_border_color"];n.values=[(undefined==p[0]?"":p[0]),(undefined==p[1]?"":p[1]),(undefined==p[2]?"":p[2])]}else{if(o.match(/^background\-image/)){n.names=["_background_url","_background_origin","_background_color1","_background_color2"];n.values=["","","",""];if(m.match(/:/)){var p=m.split(/:/);n.values[1]=(undefined==p[0]?"":p[0]);n.values[2]=(undefined==p[1]?"":p[1]);n.values[3]=(undefined==p[3]?"":p[3]);n.orig=[n.values[1],n.values[2],n.values[3]].join(" ")}else{n.values[0]=m}}else{n.names=[""];n.values=[m]}}return n},ctc_set_query=function(n,m){e("#ctc_sel_ovrd_query").val("");e("#ctc_sel_ovrd_query_selected").text(m);ctc_selectors=d(n);e("#ctc_sel_ovrd_selector").autocomplete("option",{source:ctc_selectors});e("#ctc_new_selector_row").show()},ctc_set_selector=function(n,m){e("#ctc_sel_ovrd_selector").val("");e("#ctc_sel_ovrd_selector_selected").text(m);e("#ctc_sel_ovrd_selnum").val(n);c(n);e("#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").show()},ctc_set_rule=function(n,m){e("#ctc_rule_menu").val("");e("#ctc_rule_menu_selected").text(m);ctc_render_rule_value_inputs(n);e("#ctc_rule_value_inputs,#ctc_input_row_rule_header").show()},ctc_selectors=[],ctc_queries=g(),ctc_rules=i(),unique_rule_value={},toggles={};e(".color-picker").each(function(){l(this)});e(".ctc-option-panel-container").on("focus",".color-picker",function(){e(this).iris("toggle");e(".iris-picker").css({position:"absolute","z-index":10})});e(".ctc-option-panel-container").on("focus","input",function(){e(".color-picker").not(this).iris("hide")});e(".ctc-option-panel-container").on("change",".ctc-child-value",function(){h(this)});e(".ctc-option-panel-container").on("click",".ctc-selector-handle",function(m){m.preventDefault();var n=e(this).attr("id").replace("_close","");e("#"+n+"_container").fadeToggle("fast");e(".ctc-selector-container").not("#"+n+"_container").fadeOut("fast")});e(".nav-tab").on("click",function(n){n.preventDefault();var o="#"+e(this).attr("id"),m=o+"_panel";e(".nav-tab").removeClass("nav-tab-active");e(".ctc-option-panel").removeClass("ctc-option-panel-active");e(".ctc-selector-container").hide();e(o).addClass("nav-tab-active");e(".ctc-option-panel-container").scrollTop(0);e(m).addClass("ctc-option-panel-active")});e("#preview_options").on("click",function(o){var m=new Date().getTime(),n=ctcAjax.theme_uri+"/"+ctcAjax.child_theme+"/style.css?"+m;e.get(n,function(p){e("#preview_options_panel").text(p)}).fail(function(){e("#preview_options_panel").text(ctcAjax.css_fail)})});e("#ctc_load_form").on("submit",function(m){return confirm(ctcAjax.load_msg)});e(document).on("click",".ctc-save-input",function(m){ctc_save(this)});e("#ctc_sel_ovrd_query").autocomplete({source:ctc_queries,minLength:0,selectFirst:true,autoFocus:true,select:function(n,m){ctc_set_query(m.item.value,m.item.label);return false},focus:function(m){m.preventDefault()}});e("#ctc_sel_ovrd_selector").autocomplete({source:ctc_selectors,selectFirst:true,autoFocus:true,select:function(n,m){ctc_set_selector(m.item.value,m.item.label);return false},focus:function(m){m.preventDefault()}});e("#ctc_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(n,m){ctc_set_rule(m.item.value,m.item.label);return false},focus:function(m){m.preventDefault()}});e("#ctc_new_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(o,n){var m=e("#ctc_sel_ovrd_selnum").val();e("#ctc_sel_ovrd_rule_inputs").append(f(m,n.item.value,false)).find(".color-picker").each(function(){l(this)});e("#ctc_new_rule_menu").val("");return false},focus:function(m){m.preventDefault()}})})(jQuery);
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.4.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
+ ;jQuery(document).ready(function(c){var l="\n",s="base",h,b={},p,q,k=function(t){c(t).iris({change:function(){f(t)}})},e=function(v){var t=parseInt(v),u=String.fromCharCode(t);return u},m=function(u){var t=u.charCodeAt(0);return t},f=function(z){var v=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,A=c(z).parents(".ctc-selector-row, .ctc-parent-row").first(),y=A.find(".ctc-swatch").first(),x={parent:{},child:{}},w={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},u={child:false,parent:false},t={};A.find(".ctc-parent-value, .ctc-child-value").each(function(){var I=c(this).attr("id"),B=I.toString().match(v),J=B[2],C=B[3],L=("undefined"==typeof B[4]?"":B[4]),H=B[5],G=("undefined"==typeof B[6]?"":B[6]),K=("parent"==C?c(this).text():c(this).val()),D="ctc_"+J+"_child_"+L+"_i_"+H,F,E;if("child"==C){t[I]=K;t[D]=(c("#"+D).is(":checked"))?1:0}if(""!=K){if(false===r(G)){switch(G){case"_border_width":x[C][L+"-width"]=K;break;case"_border_style":x[C][L+"-style"]=K;break;case"_border_color":x[C][L+"-color"]=K;break;case"_background_url":x[C]["background-image"]=i(C,K);break;case"_background_color":x[C]["background-color"]=z.value;break;case"_background_color1":w[C].start=K;u[C]=true;break;case"_background_color2":w[C].end=K;u[C]=true;break;case"_background_origin":w[C].origin=K;u[C]=true;break}}else{if(F=L.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!K.match(/none/)){E=K.toString().split(/ +/);x[C][L+"-width"]="undefined"==typeof E[0]?"":E[0];x[C][L+"-style"]="undefined"==typeof E[1]?"":E[1];x[C][L+"-color"]="undefined"==typeof E[2]?"":E[2]}else{if("background-image"==L){if(K.toString().match(/url\(/)){x[C]["background-image"]=i(C,K)}else{E=K.toString().split(/ +/);if(E.length>2){w[C].origin="undefined"==typeof E[0]?"top":E[0];w[C].start="undefined"==typeof E[1]?"transparent":E[1];w[C].end="undefined"==typeof E[2]?"transparent":E[2];u[C]=true}else{x[C]["background-image"]=K}}}else{x[C][L]=K}}}}});if("undefined"!=typeof y&&false===r(y.attr("id"))){c(y).removeAttr("style");if(u.parent){c(y).ctcgrad(w.parent.origin,[w.parent.start,w.parent.end])}c(y).css(x.parent);if(!(y.attr("id").toString().match(/parent/))){if(u.child){c(y).ctcgrad(w.child.origin,[w.child.start,w.child.end])}c(y).css(x.child)}}return t},n=function(u){var t,v,w;c(u).each(function(){switch(this.obj){case"imports":ctcAjax.imports=this.data;break;case"rule_val":ctcAjax.rule_val[this.key]=this.data;w=this.key;break;case"val_qry":ctcAjax.val_qry[this.key]=this.data;break;case"rule":ctcAjax.rule=this.data;break;case"sel_ndx":if(r(this.key)){ctcAjax.sel_ndx=this.data}else{if("qsid"==this.key){if(r(ctcAjax.sel_ndx[this.data.query])){ctcAjax.sel_ndx[this.data.query]={}}ctcAjax.sel_ndx[this.data.query][this.data.selector]=this.data.qsid}else{ctcAjax.sel_ndx[this.key]=this.data;t=this.key}}break;case"sel_val":ctcAjax.sel_val[this.key]=this.data;v=this.key;break;case"rewrite":p=this.key;q=this.data;break}})},i=function(x,u){var w=u.toString().match(/url\(['" ]*(.+?)['" ]*\)/),v=r(w)?null:w[1],t=ctcAjax.theme_uri+"/"+("parent"==x?ctcAjax.parnt:ctcAjax.child)+"/",y;if(!v){return false}else{if(v.toString().match(/^(https?:|\/)/)){y=u}else{y="url("+t+v+")"}}return y},r=function(u){if("undefined"==typeof u||false===u||null===u||""===u){return true}if(true===u||"string"===typeof u||"number"===typeof u){return false}if("object"===typeof u){for(var t in u){if(u.hasOwnProperty(t)){return false}}return true}return false},a=function(){var t=[];if(1===loading.sel_ndx){return t}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",null,ctc_setup_query_menu);return t}if(false===r(ctcAjax.sel_ndx)){c.each(ctcAjax.sel_ndx,function(u,v){var w={label:u,value:u};t.push(w)})}return t},o=function(u){var t=[];if(1===loading.sel_ndx){return t}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",u,ctc_setup_selector_menu);return t}if(false===r(ctcAjax.sel_ndx[u])){c.each(ctcAjax.sel_ndx[u],function(v,w){var x={label:v,value:w};t.push(x)})}return t},d=function(){var t=[];if(1===loading.rule){return t}if(0===loading.rule){loading.rule=1;ctc_query_css("rule",null,ctc_setup_rule_menu);return t}if(false===r(ctcAjax.rule)){c.each(ctcAjax.rule,function(u,v){var w={label:v.replace(/\d+/g,e),value:u};t.push(w)})}return t.sort(function(v,u){if(v.label>u.label){return 1}if(v.label<u.label){return -1}return 0})},j=function(x,z,C){var v="",A=(r(ctcAjax.sel_val[x])||r(ctcAjax.sel_val[x].value)||r(ctcAjax.sel_val[x].value[z])?"":ctcAjax.sel_val[x].value[z]),u=ctc_decode_value(z,("undefined"==typeof A?"":A.parnt)),y=(false===r(A.i_parnt)&&A.i_parnt)?ctcAjax.important_label:"",w=ctc_decode_value(z,("undefined"==typeof A?"":A.child)),t=(false===r(A.i_child)&&A.i_child)?1:0,B="ctc_"+C+"_child_"+z+"_i_"+x;if(false===r(ctcAjax.sel_val[x])){v+='<div class="ctc-'+("ovrd"==C?"input":"selector")+'-row clearfix">'+l;v+='<div class="ctc-input-cell">'+("ovrd"==C?z.replace(/\d+/g,e):ctcAjax.sel_val[x].selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+x+'" >'+ctcAjax.edit_txt+"</a> "+(r(u.orig)?ctcAjax.child_only_txt:""))+"</div>"+l;if("ovrd"==C){v+='<div class="ctc-parent-value ctc-input-cell" id="ctc_'+C+"_parent_"+z+"_"+x+'">'+(r(u.orig)?"[no value]":u.orig+y)+"</div>"+l}v+='<div class="ctc-input-cell">'+l;if(false===r(u.names)){c.each(u.names,function(D,E){E=(r(E)?"":E);v+='<div class="ctc-child-input-cell">'+l;var G="ctc_"+C+"_child_"+z+"_"+x+E,F;if(false===(F=w.values.shift())){F=""}v+=(r(E)?"":ctcAjax.field_labels[E]+":<br/>")+'<input type="text" id="'+G+'" name="'+G+'" class="ctc-child-value'+((E+z).toString().match(/color/)?" color-picker":"")+((E).toString().match(/url/)?" ctc-input-wide":"")+'" value="'+F+'" />'+l;v+="</div>"+l});v+='<label for="'+B+'"><input type="checkbox" id="'+B+'" name="'+B+'" value="1" '+(1===t?"checked":"")+" />"+ctcAjax.important_label+"</label>"+l}v+="</div>"+l;v+=("ovrd"==C?"":'<div class="ctc-swatch ctc-specific" id="ctc_child_'+z+"_"+x+'_swatch">'+ctcAjax.swatch_txt+"</div>"+l+'<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+z+"_"+x+'_cell">'+l+'<input type="button" class="button ctc-save-input" id="ctc_save_'+z+"_"+x+'" name="ctc_save_'+z+"_"+x+'" value="Save" /></div>'+l);v+="</div><!-- end input row -->"+l}return v},g=function(t){if(1===loading.sel_val){return false}if(0==loading.sel_val){loading.sel_val=1;ctc_query_css("sel_val",t,g);return false}var w,u,v;if(r(ctcAjax.sel_val[t])){c("#ctc_sel_ovrd_rule_inputs").html("")}else{if(r(ctcAjax.sel_val[t].seq)){c("#ctc_child_load_order_container").html("")}else{w="ctc_ovrd_child_seq_"+t;v=parseInt(ctcAjax.sel_val[t].seq);u='<input type="text" id="'+w+'" name="'+w+'" class="ctc-child-value" value="'+v+'" />';c("#ctc_child_load_order_container").html(u)}if(r(ctcAjax.sel_val[t].value)){c("#ctc_sel_ovrd_rule_inputs").html("")}else{u="";c.each(ctcAjax.sel_val[t].value,function(y,x){u+=j(t,y,"ovrd")});c("#ctc_sel_ovrd_rule_inputs").html(u).find(".color-picker").each(function(){k(this)});f("#ctc_child_all_0_swatch")}}};ctc_render_css_preview=function(t){if(1===loading.preview){return false}if(0==loading.preview){loading.preview=1;var t;if(!(t=c(this).attr("id").toString().match(/(child|parnt)/)[1])){t="child"}ctc_set_notice("");ctc_query_css("preview",t,ctc_render_css_preview);return false}if(2==loading.preview){c("#view_"+t+"_options_panel").text(ctcAjax.previewResponse);loading.preview=0}},ctc_render_rule_value_inputs=function(u){if(1===loading.rule_val){return false}if(0==loading.rule_val){loading.rule_val=1;ctc_query_css("rule_val",u,ctc_render_rule_value_inputs);return false}var v=ctcAjax.rule[u],t='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+v+'">'+l;if(false===r(ctcAjax.rule_val[u])){c.each(ctcAjax.rule_val[u],function(x,y){var w=ctc_decode_value(v,y);t+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+v+"_"+x+'">'+l;t+='<div class="ctc-input-cell ctc-parent-value" id="ctc_'+x+"_parent_"+v+"_"+x+'">'+w.orig+"</div>"+l;t+='<div class="ctc-input-cell">'+l;t+='<div class="ctc-swatch ctc-specific" id="ctc_'+x+"_parent_"+v+"_"+x+'_swatch">'+ctcAjax.swatch_txt+"</div></div>"+l;t+='<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+v+"_"+x+'">'+ctcAjax.selector_txt+"</a></div>"+l;t+='<div id="ctc_selector_'+v+"_"+x+'_container" class="ctc-selector-container clearfix">'+l;t+='<a href="#" id="ctc_selector_'+v+"_"+x+'_close" class="ctc-selector-handle" style="float:right">'+ctcAjax.close_txt+'</a><div id="ctc_status_val_qry_'+x+'"></div>'+l;t+='<div id="ctc_selector_'+v+"_"+x+'_rows"></div>'+l;t+="</div></div>"+l});t+="</div>"+l}c("#ctc_rule_value_inputs").html(t).find(".ctc-swatch").each(function(){f(this)})},ctc_render_selector_value_inputs=function(w){if(1==loading.val_qry){return false}var y,u,x=c("#ctc_rule_menu_selected").text().replace(/[^\w\-]/g,m),t,v="";if(0===loading.val_qry){loading.val_qry=1;y={rule:x};ctc_query_css("val_qry",w,ctc_render_selector_value_inputs,y);return false}if(false===r(ctcAjax.val_qry[w])){c.each(ctcAjax.val_qry[w],function(A,z){page_rule=A;c.each(z,function(C,B){v+='<h4 class="ctc-query-heading">'+C+"</h4>"+l;if(false===r(B)){c.each(B,function(D,E){ctcAjax.sel_val[D]=E;v+=j(D,A,w)})}})})}t="#ctc_selector_"+x+"_"+w+"_rows";c(t).html(v).find(".color-picker").each(function(){k(this)});c(t).find(".ctc-swatch").each(function(){f(this)})},ctc_query_css=function(v,u,y,w){var t={ctc_query_obj:v,ctc_query_key:u},x="#ctc_status_"+v+("val_qry"==v?"_"+u:"");if("object"===typeof w){c.each(w,function(z,A){t["ctc_query_"+z]=A})}c(".ctc-status-icon").remove();c(x).append('<span class="ctc-status-icon spinner"></span>');c(".spinner").show();t.action="ctc_query";t._wpnonce=c("#_wpnonce").val();c.post(ctcAjax.ajaxurl,t,function(z){loading[v]=2;c(".ctc-status-icon").removeClass("spinner");if(r(z)){c(".ctc-status-icon").addClass("failure");if("preview"==v){ctcAjax.previewResponse=ctcAjax.css_fail_txt;y(u)}}else{c(".ctc-status-icon").addClass("success");if("preview"==v){ctcAjax.previewResponse=z.shift().data}else{n(z)}if("function"===typeof y){y(u)}return false}},"json").fail(function(){c(".ctc-status-icon").removeClass("spinner");c(".ctc-status-icon").addClass("failure");if("preview"==v){ctcAjax.previewResponse=ctcAjax.css_fail_txt;loading[v]=2;y(u)}else{loading[v]=0}});return false},ctc_save=function(y){var w={},z,v,t,u,A=c(y).attr("id"),x;if(r(b[A])){b[A]=0}b[A]++;c(y).prop("disabled",true);c(".ctc-status-icon").remove();c(y).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner"></span>');c(".spinner").show();if((z=c("#ctc_new_selectors"))&&"ctc_save_new_selectors"==c(y).attr("id")){w.ctc_new_selectors=z.val();if(v=c("#ctc_sel_ovrd_query_selected")){w.ctc_sel_ovrd_query=v.text()}}else{if((t=c("#ctc_child_imports"))&&"ctc_save_imports"==c(y).attr("id")){w.ctc_child_imports=t.val()}else{w=f(y)}}c("#ctc_sel_ovrd_selector_selected").find("#ctc_rewrite_selector").each(function(){x=c("#ctc_rewrite_selector").val(),origsel=c("#ctc_rewrite_selector_orig").val();if(r(x)||!x.toString().match(/\w/)){x=origsel}else{w.ctc_rewrite_selector=x}c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_sel_ovrd_selector_selected").html(x)});w.action="ctc_update";w._wpnonce=c("#_wpnonce").val();c.post(ctcAjax.ajaxurl,w,function(B){c(y).prop("disabled",false);c(".ctc-status-icon").removeClass("spinner");if(r(B)){c(".ctc-status-icon").addClass("failure")}else{c(".ctc-status-icon").addClass("success");c("#ctc_new_selectors").val("");n(B);ctc_setup_menus();if(false===r(p)){ctc_set_selector(p,q);p=q=null}}return false},"json").fail(function(){c(y).prop("disabled",false);c(".ctc-status-icon").removeClass("spinner");c(".ctc-status-icon").addClass("failure")});return false},ctc_decode_value=function(v,t){t=("undefined"==typeof t?"":t);var u={orig:t};if(v.toString().match(/^border(\-(top|right|bottom|left))?$/)){var w=t.toString().split(/ +/);u.names=["_border_width","_border_style","_border_color"];u.values=[("undefined"==typeof w[0]?"":w[0]),("undefined"==typeof w[1]?"":w[1]),("undefined"==typeof w[2]?"":w[2])]}else{if(v.toString().match(/^background\-image/)){u.names=["_background_url","_background_origin","_background_color1","_background_color2"];u.values=["","","",""];if(false===(r(t))&&!(t.toString().match(/url/))){var w=t.toString().split(/:/);u.values[1]=("undefined"==typeof w[0]?"":w[0]);u.values[2]=("undefined"==typeof w[1]?"":w[1]);u.values[3]=("undefined"==typeof w[3]?"":w[3]);u.orig=[u.values[1],u.values[2],u.values[3]].join(" ")}else{u.values[0]=t}}else{u.names=[""];u.values=[t]}}return u},ctc_set_query=function(t){s=t;c("#ctc_sel_ovrd_query").val("");c("#ctc_sel_ovrd_query_selected").text(t);c("#ctc_sel_ovrd_selector").val("");c("#ctc_sel_ovrd_selector_selected").html("&nbsp;");c("#ctc_sel_ovrd_rule_inputs").html("");ctc_setup_selector_menu(t);f("#ctc_child_all_0_swatch");c("#ctc_new_selector_row").show()},ctc_set_selector=function(u,t){c("#ctc_sel_ovrd_selector").val("");c("#ctc_sel_ovrd_selector_selected").text(t);c("#ctc_sel_ovrd_qsid").val(u);h=u;if(1!=loading.sel_val){loading.sel_val=0}g(u);c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs,.ctc-rewrite-toggle").show()},ctc_set_rule=function(u,t){c("#ctc_rule_menu").val("");c("#ctc_rule_menu_selected").text(t);if(1!=loading.rule_val){loading.rule_val=0}ctc_render_rule_value_inputs(u);c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_rule_value_inputs,#ctc_input_row_rule_header").show()},ctc_setup_query_menu=function(){ctc_queries=a();c("#ctc_sel_ovrd_query").autocomplete({source:ctc_queries,minLength:0,selectFirst:true,autoFocus:true,select:function(u,t){ctc_set_query(t.item.value);return false},focus:function(t){t.preventDefault()}})},ctc_setup_selector_menu=function(t){ctc_selectors=o(t);c("#ctc_sel_ovrd_selector").autocomplete({source:ctc_selectors,selectFirst:true,autoFocus:true,select:function(v,u){ctc_set_selector(u.item.value,u.item.label);return false},focus:function(u){u.preventDefault()}})},ctc_setup_rule_menu=function(){ctc_rules=d();c("#ctc_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(u,t){ctc_set_rule(t.item.value,t.item.label);return false},focus:function(t){t.preventDefault()}})},ctc_filtered_rules=function(w,u){var t=[],v=(r(ctcAjax.sel_val[h]))||(r(ctcAjax.sel_val[h].value));if(r(ctc_rules)){ctc_rules=d()}c.each(ctc_rules,function(x,A){var y=false,z=new RegExp(c.ui.autocomplete.escapeRegex(w.term),"i");if(z.test(A.label)){if(false===v){c.each(ctcAjax.sel_val[h].value,function(C,B){if(A.label==C.replace(/\d+/g,e)){y=true;return false}});if(y){return}}t.push(A)}});u(t)},ctc_setup_new_rule_menu=function(){c("#ctc_new_rule_menu").autocomplete({source:ctc_filtered_rules,selectFirst:true,autoFocus:true,select:function(u,t){u.preventDefault();var v=c(j(h,t.item.label.replace(/[^\w\-]/g,m),"ovrd"));c("#ctc_sel_ovrd_rule_inputs").append(v);c("#ctc_new_rule_menu").val("");if(r(ctcAjax.sel_val[h].value)){ctcAjax.sel_val[h]["value"]={}}ctcAjax.sel_val[h].value[t.item.label]={child:""};v.find('input[type="text"]').each(function(w,x){if(c(x).hasClass("color-picker")){k(x)}c(x).focus()});return false},focus:function(t){t.preventDefault()}})},ctc_setup_menus=function(){ctc_setup_query_menu();ctc_setup_selector_menu(s);ctc_setup_rule_menu();ctc_setup_new_rule_menu()},ctc_theme_exists=function(t,u){var v=false;c.each(ctcAjax.themes,function(w,x){c.each(x,function(y,z){if(y==t&&("parnt"==w||"new"==u)){v=true;return false}});if(v){return false}});return v},ctc_set_notice=function(t){var u="";if(false===r(t)){c.each(t,function(v,w){u+='<div class="'+v+'"><ul>'+l;c(w).each(function(x,y){u+="<li>"+y.toString()+"</li>"+l});u+="</ul></div>"})}c("#ctc_error_notice").html(u)},ctc_validate=function(){var w=/[^\w\-]/,u=c("#ctc_child_template").val().toString().replace(w).toLowerCase(),t=c("#ctc_theme_child").val().toString().replace(w).toLowerCase(),v=c("input[name=ctc_child_type]:checked").val(),x=[];if("new"==v){t=u}if(ctc_theme_exists(t,v)){x.push(ctcAjax.theme_exists_txt.toString().replace(/%s/,t))}if(""===t){x.push(ctcAjax.inval_theme_txt)}if(""===c("#ctc_child_name").val()){x.push(ctcAjax.inval_name_txt)}if(x.length){ctc_set_notice({error:x});return false}return true},ctc_set_theme_menu=function(u){var t=c("#ctc_theme_child").val();if(false===r(ctcAjax.themes.child[t])){c("#ctc_child_name").val(ctcAjax.themes.child[t].Name);c("#ctc_child_author").val(ctcAjax.themes.child[t].Author);c("#ctc_child_version").val(ctcAjax.themes.child[t].Version)}},fade_update_notice=function(){c(".updated, .error").slideUp("slow",function(){c(".updated").remove()})},ctc_focus_panel=function(u){var t=u+"_panel";c(".nav-tab").removeClass("nav-tab-active");c(".ctc-option-panel").removeClass("ctc-option-panel-active");c(".ctc-selector-container").hide();c(u).addClass("nav-tab-active");c(".ctc-option-panel-container").scrollTop(0);c(t).addClass("ctc-option-panel-active")},ctc_selector_edit=function(w){var t=c(w).attr("id").match(/_(\d+)$/)[1],v=ctcAjax.sel_val[t].query,u=ctcAjax.sel_val[t].selector,x="#query_selector_options";ctc_set_query(v);ctc_set_selector(t,u);ctc_focus_panel(x)},ctc_selector_input_toggle=function(u){var t;if(c("#ctc_rewrite_selector").length){t=c("#ctc_rewrite_selector_orig").val();c("#ctc_sel_ovrd_selector_selected").text(t);c(u).text(ctcAjax.rename_txt)}else{t=c("#ctc_sel_ovrd_selector_selected").text();c("#ctc_sel_ovrd_selector_selected").html('<input id="ctc_rewrite_selector" name="ctc_rewrite_selector" type="text" value="'+t+'" autocomplete="off" /><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'+t+'"/>');c(u).text(ctcAjax.cancel_txt)}};loading={rule:2,sel_ndx:2,val_qry:0,rule_val:0,sel_val:0,preview:0},ctc_selectors=[],ctc_queries=[],ctc_rules=[];c(".color-picker").each(function(){k(this)});c(".ctc-option-panel-container").on("focus",".color-picker",function(){ctc_set_notice("");c(this).iris("toggle");c(".iris-picker").css({position:"absolute","z-index":10})});c(".ctc-option-panel-container").on("focus","input",function(){ctc_set_notice("");c(".color-picker").not(this).iris("hide")});c(".ctc-option-panel-container").on("change",".ctc-child-value, input[type=checkbox]",function(){f(this)});c(".ctc-option-panel-container").on("click",".ctc-selector-handle",function(u){u.preventDefault();ctc_set_notice("");var v=c(this).attr("id").toString().replace("_close",""),t=v.toString().match(/_(\d+)$/)[1];if(c("#"+v+"_container").is(":hidden")){if(1!=loading.val_qry){loading.val_qry=0}ctc_render_selector_value_inputs(t)}c("#"+v+"_container").fadeToggle("fast");c(".ctc-selector-container").not("#"+v+"_container").fadeOut("fast")});c(".nav-tab").on("click",function(t){t.preventDefault();ctc_set_notice("");c(".ctc-status-icon").remove();var u="#"+c(this).attr("id");ctc_focus_panel(u)});c("#view_child_options,#view_parnt_options").on("click",ctc_render_css_preview);c("#ctc_load_form").on("submit",function(){return(ctc_validate()&&confirm(ctcAjax.load_txt))});c("#parent_child_options_panel").on("change","#ctc_theme_child",ctc_set_theme_menu);c(document).on("click",".ctc-save-input",function(t){ctc_save(this)});c(document).on("click",".ctc-selector-edit",function(t){ctc_selector_edit(this)});c(document).on("click",".ctc-rewrite-toggle",function(t){t.preventDefault();ctc_selector_input_toggle(this)});ctc_setup_menus();ctc_set_query(s);c("input[type=submit],input[type=button]").prop("disabled",false);setTimeout(fade_update_notice,6000)});
lang/chld_thm_cfg.pot CHANGED
@@ -1,14 +1,744 @@
1
- # Copyright (C) 2013 Lilaea Media LLC
2
  # This file is distributed under the same license as the Child Theme Configurator package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Child Theme Configurator 1.0.0\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/intelliwidget\n"
7
- "POT-Creation-Date: 2013-10-16 00:01+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2013-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014 Child Theme Configurator
2
  # This file is distributed under the same license as the Child Theme Configurator package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Child Theme Configurator 1.4.0\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/child-theme-configurator\n"
7
+ "POT-Creation-Date: 2014-04-25 22:05:14+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: includes/class-ctc-ui.php:23
16
+ msgid "Easily customize your plugins with the CTC Plugin Extension"
17
+ msgstr ""
18
+
19
+ #: includes/class-ctc-ui.php:23
20
+ msgid "Use this to customize your plugins"
21
+ msgstr ""
22
+
23
+ #: includes/class-ctc-ui.php:50
24
+ msgid "Parent/Child"
25
+ msgstr ""
26
+
27
+ #: includes/class-ctc-ui.php:53 includes/class-ctc-ui.php:579
28
+ msgid "Query/Selector"
29
+ msgstr ""
30
+
31
+ #: includes/class-ctc-ui.php:56 includes/class-ctc-ui.php:593
32
+ msgid "Rule/Value"
33
+ msgstr ""
34
+
35
+ #: includes/class-ctc-ui.php:59
36
+ msgid "@import"
37
+ msgstr ""
38
+
39
+ #: includes/class-ctc-ui.php:62
40
+ msgid "Child CSS"
41
+ msgstr ""
42
+
43
+ #: includes/class-ctc-ui.php:65
44
+ msgid "Parent CSS"
45
+ msgstr ""
46
+
47
+ #: includes/class-ctc-ui.php:72 includes/class-ctc-ui.php:632
48
+ msgid "Files"
49
+ msgstr ""
50
+
51
+ #: includes/class-ctc-ui.php:84
52
+ msgid "Parent Theme"
53
+ msgstr ""
54
+
55
+ #: includes/class-ctc-ui.php:94
56
+ msgid "Child Theme"
57
+ msgstr ""
58
+
59
+ #: includes/class-ctc-ui.php:101
60
+ msgid "Create New Child Theme"
61
+ msgstr ""
62
+
63
+ #: includes/class-ctc-ui.php:110
64
+ msgid "Use Existing Child Theme"
65
+ msgstr ""
66
+
67
+ #: includes/class-ctc-ui.php:115
68
+ msgid "Theme Slug"
69
+ msgstr ""
70
+
71
+ #: includes/class-ctc-ui.php:125
72
+ msgid "Child Theme Name"
73
+ msgstr ""
74
+
75
+ #: includes/class-ctc-ui.php:129
76
+ msgid "Theme Name"
77
+ msgstr ""
78
+
79
+ #: includes/class-ctc-ui.php:135 includes/class-ctc-ui.php:139
80
+ msgid "Author"
81
+ msgstr ""
82
+
83
+ #: includes/class-ctc-ui.php:144 includes/class-ctc-ui.php:148
84
+ msgid "Version"
85
+ msgstr ""
86
+
87
+ #: includes/class-ctc-ui.php:153
88
+ msgid "Backup Stylesheet"
89
+ msgstr ""
90
+
91
+ #: includes/class-ctc-ui.php:162
92
+ msgid "Scan Parent Theme<br/>for Additional Stylesheets"
93
+ msgstr ""
94
+
95
+ #: includes/class-ctc-ui.php:173
96
+ msgid "Generate Child Theme Files"
97
+ msgstr ""
98
+
99
+ #: includes/class-ctc-ui.php:184 includes/class-ctc-ui.php:253
100
+ msgid "Rule"
101
+ msgstr ""
102
+
103
+ #: includes/class-ctc-ui.php:197
104
+ msgid "Value"
105
+ msgstr ""
106
+
107
+ #: includes/class-ctc-ui.php:200 includes/class-ctc-ui.php:238
108
+ #: includes/class-ctc.php:102
109
+ msgid "Sample"
110
+ msgstr ""
111
+
112
+ #: includes/class-ctc-ui.php:203 includes/class-ctc.php:104
113
+ msgid "Selectors"
114
+ msgstr ""
115
+
116
+ #: includes/class-ctc-ui.php:214
117
+ msgid "Query"
118
+ msgstr ""
119
+
120
+ #: includes/class-ctc-ui.php:225
121
+ msgid "Selector"
122
+ msgstr ""
123
+
124
+ #: includes/class-ctc-ui.php:246 includes/class-ctc-ui.php:286
125
+ #: includes/class-ctc-ui.php:305
126
+ msgid "Save"
127
+ msgstr ""
128
+
129
+ #: includes/class-ctc-ui.php:256
130
+ msgid "Parent Value"
131
+ msgstr ""
132
+
133
+ #: includes/class-ctc-ui.php:259
134
+ msgid "Child Value"
135
+ msgstr ""
136
+
137
+ #: includes/class-ctc-ui.php:265
138
+ msgid "New Rule"
139
+ msgstr ""
140
+
141
+ #: includes/class-ctc-ui.php:275
142
+ msgid "Order"
143
+ msgstr ""
144
+
145
+ #: includes/class-ctc-ui.php:282
146
+ msgid "Raw CSS"
147
+ msgstr ""
148
+
149
+ #: includes/class-ctc-ui.php:301
150
+ msgid "@import Statements"
151
+ msgstr ""
152
+
153
+ #: includes/class-ctc-ui.php:333
154
+ msgid "Upload New Child Theme Image"
155
+ msgstr ""
156
+
157
+ #: includes/class-ctc-ui.php:336
158
+ msgid ""
159
+ "Theme images reside under the <code>images</code> directory in your child "
160
+ "theme and are meant for stylesheet use only. Use the media gallery for "
161
+ "content images."
162
+ msgstr ""
163
+
164
+ #: includes/class-ctc-ui.php:343 includes/class-ctc-ui.php:369
165
+ msgid "Upload"
166
+ msgstr ""
167
+
168
+ #: includes/class-ctc-ui.php:350
169
+ msgid "Child Theme Screenshot"
170
+ msgstr ""
171
+
172
+ #: includes/class-ctc-ui.php:359
173
+ msgid "Upload New Screenshot"
174
+ msgstr ""
175
+
176
+ #: includes/class-ctc-ui.php:362
177
+ msgid ""
178
+ "The theme screenshot should be a 4:3 ratio (eg., 880px x 660px) JPG, PNG or "
179
+ "GIF. It will be renamed <code>screenshot</code>."
180
+ msgstr ""
181
+
182
+ #: includes/class-ctc-ui.php:430
183
+ msgid "Copy PHP template files from the parent theme by selecting them here."
184
+ msgstr ""
185
+
186
+ #: includes/class-ctc-ui.php:433
187
+ msgid ""
188
+ "CAUTION: If your child theme is active, the child theme version of the file "
189
+ "will be used instead of the parent immediately after it is copied."
190
+ msgstr ""
191
+
192
+ #: includes/class-ctc-ui.php:436
193
+ msgid ""
194
+ "The <code>functions.php</code> file is generated separately and cannot be "
195
+ "copied here."
196
+ msgstr ""
197
+
198
+ #: includes/class-ctc-ui.php:438
199
+ msgid "Click here to edit template files using the Theme Editor"
200
+ msgstr ""
201
+
202
+ #: includes/class-ctc-ui.php:443
203
+ msgid "Remove child theme templates by selecting them here."
204
+ msgstr ""
205
+
206
+ #: includes/class-ctc-ui.php:452
207
+ msgid "Copy Selected to Child Theme"
208
+ msgstr ""
209
+
210
+ #: includes/class-ctc-ui.php:452
211
+ msgid "Remove Selected from Child Theme"
212
+ msgstr ""
213
+
214
+ #: includes/class-ctc-ui.php:489
215
+ msgid "Child Theme Images"
216
+ msgstr ""
217
+
218
+ #: includes/class-ctc-ui.php:492
219
+ msgid "Remove child theme images by selecting them here."
220
+ msgstr ""
221
+
222
+ #: includes/class-ctc-ui.php:500
223
+ msgid "Remove Selected"
224
+ msgstr ""
225
+
226
+ #: includes/class-ctc-ui.php:531
227
+ msgid "Child Theme files modified successfully."
228
+ msgstr ""
229
+
230
+ #: includes/class-ctc-ui.php:533
231
+ msgid "Child Theme <strong>%s</strong> has been generated successfully."
232
+ msgstr ""
233
+
234
+ #: includes/class-ctc-ui.php:537
235
+ msgid ""
236
+ "Please verify the imports below and remove any imports that are not needed "
237
+ "by the front end, such as admin or configuration stylesheets."
238
+ msgstr ""
239
+
240
+ #: includes/class-ctc-ui.php:554
241
+ msgid "Tutorial Video"
242
+ msgstr ""
243
+
244
+ #: includes/class-ctc-ui.php:555
245
+ msgid ""
246
+ "<iframe width=\"480\" height=\"270\" src=\"//www.youtube.com/embed/"
247
+ "xL2HkWQxgOA?rel=0&modestbranding=1\" frameborder=\"0\" allowfullscreen></"
248
+ "iframe>"
249
+ msgstr ""
250
+
251
+ #: includes/class-ctc-ui.php:561
252
+ msgid "Start Here"
253
+ msgstr ""
254
+
255
+ #: includes/class-ctc-ui.php:562
256
+ msgid ""
257
+ "\n"
258
+ "<p>The first step is to create a child theme and import your parent theme "
259
+ "styles into the configurator.</p>\n"
260
+ "<ol><li>Select an existing parent theme from the menu.</li>\n"
261
+ "<li>Select \"New\" or \"Existing\" child theme.\n"
262
+ "<ul><li>If creating a new theme, enter a \"slug\" (lower case, no spaces). "
263
+ "This is used to name the theme directory and identify the theme to WordPress."
264
+ "</li>\n"
265
+ "<li>If using an existing theme, select a child theme from the menu.</li></"
266
+ "ul></li>\n"
267
+ "<li>Enter a Name for the child theme.</li>\n"
268
+ "<li>Enter an author for the child theme.</li>\n"
269
+ "<li>Enter the child theme version number.</li>\n"
270
+ "<li>If your theme uses multiple stylesheets, check \"Scan Parent Theme for "
271
+ "additional stylesheets.</li>\n"
272
+ "<li>Click \"Generate Child Theme.\" If you are loading an existing child "
273
+ "theme, The Child Theme Configurator will create a backup of your existing "
274
+ "stylesheet in the theme directory.</li></ol>\n"
275
+ "\t\t\t\t "
276
+ msgstr ""
277
+
278
+ #: includes/class-ctc-ui.php:580
279
+ msgid ""
280
+ "\n"
281
+ "<p>There are two ways to identify and override parent styles. The Child "
282
+ "Theme Configurator lets you search styles by <strong>selector</strong> and "
283
+ "by <strong>rule</strong>. If you wish to change a specific selector (e.g., "
284
+ "h1), use the \"Query/Selector\" tab. If you have a specific value you wish "
285
+ "to change site-wide (e.g., the color of the type), use the \"Rule/Value\" "
286
+ "tab.</p>\n"
287
+ "<p>The Query/Selector tab lets you find specific selectors and edit them. "
288
+ "First, find the query that contains the selector you wish to edit by typing "
289
+ "in the <strong>Query</strong> autoselect box. Select by clicking with the "
290
+ "mouse or by pressing the \"Enter\" or \"Tab\" keys. Selectors are in the "
291
+ "<strong>base</strong> query by default.</p>\n"
292
+ "<p>Next, find the selector by typing in the <strong>Selector</strong> "
293
+ "autoselect box. Select by clicking with the mouse or by pressing the \"Enter"
294
+ "\" or \"Tab\" keys.</p>\n"
295
+ "<p>This will load all of the rules for that selector with the Parent values "
296
+ "on the left and the Child values inputs on the right. Any existing child "
297
+ "values will be automatically populated. There is also a Sample preview that "
298
+ "displays the combination of Parent and Child overrides. Note that the "
299
+ "<strong>border</strong> and <strong>background-image</strong> get special "
300
+ "treatment.</p>\n"
301
+ "<p>The \"Order\" field contains the original sequence of the selector in the "
302
+ "parent theme stylesheet. You can change the selector order sequence by "
303
+ "entering a lower or higher number in the \"Order\" field. You can also force "
304
+ "style overrides (so called \"!important\" flag) by checking the \"!\" box "
305
+ "next to each input. Please use judiciously.</p>\n"
306
+ "<p>Click \"Save\" to update the child stylesheet and save your changes to "
307
+ "the WordPress admin.</p>\n"
308
+ "\t\t\t\t "
309
+ msgstr ""
310
+
311
+ #: includes/class-ctc-ui.php:594
312
+ msgid ""
313
+ "\n"
314
+ "<p>There are two ways to identify and override parent styles. The Child "
315
+ "Theme Configurator lets you search styles by <strong>selector</strong> and "
316
+ "by <strong>rule</strong>. If you wish to change a specific selector (e.g., "
317
+ "h1), use the \"Query/Selector\" tab. If you have a specific value you wish "
318
+ "to change site-wide (e.g., the color of the type), use the \"Rule/Value\" "
319
+ "tab.</p>\n"
320
+ "<p>The Rule/Value tab lets you find specific values for a given rule and "
321
+ "then edit that value for individual selectors that use that rule/value "
322
+ "combination. First, find the rule you wish to override by typing in the "
323
+ "<strong>Rule</strong> autoselect box. Select by clicking with the mouse or "
324
+ "by pressing the \"Enter\" or \"Tab\" keys.</p>\n"
325
+ "<p>This will load all of the unique values that exist for that rule in the "
326
+ "parent stylesheet with a Sample preview for that value. If there are values "
327
+ "that exist in the child stylesheet that do not exist in the parent "
328
+ "stylesheet, they will be displayed as well.</p>\n"
329
+ "<p>For each unique value, click the \"Selectors\" link to view a list of "
330
+ "selectors that use that rule/value combination, grouped by query with a "
331
+ "Sample preview of the value and inputs for the child value. Any existing "
332
+ "child values will be automatically populated.</p>\n"
333
+ "<p>Click \"Save\" to update the child stylesheet and save your changes to "
334
+ "the WordPress admin.</p>\n"
335
+ "\t\t\t\t "
336
+ msgstr ""
337
+
338
+ #: includes/class-ctc-ui.php:606
339
+ msgid "Add New Styles"
340
+ msgstr ""
341
+
342
+ #: includes/class-ctc-ui.php:607
343
+ msgid ""
344
+ "\n"
345
+ "<p>If you wish to add additional rules to a given selector, first load the "
346
+ "selector using the Query/Selector tab. Then find the rule you wish to "
347
+ "override by typing in the <strong>New Rule</strong> autoselect box. Select "
348
+ "by clicking with the mouse or by pressing the \"Enter\" or \"Tab\" keys. "
349
+ "This will add a new input row to the selector inputs.</p>\n"
350
+ "<p>If you wish to add completely new selectors, or even new @media queries, "
351
+ "you can enter free-form CSS in the \"New Selector\" textarea. Be aware that "
352
+ "your syntax must be correct (i.e., balanced curly braces, etc.) for the "
353
+ "parser to load the new styles. You will know it is invalid because a red \"X"
354
+ "\" will appear next to the save button.</p>\n"
355
+ "<p>If you prefer to use shorthand syntax for rules and values instead of the "
356
+ "inputs provided by the Child Theme Configurator, you can enter them here as "
357
+ "well. The parser will convert your input into normalized CSS code "
358
+ "automatically.</p>\n"
359
+ "\t\t\t\t "
360
+ msgstr ""
361
+
362
+ #: includes/class-ctc-ui.php:617
363
+ msgid "@imports"
364
+ msgstr ""
365
+
366
+ #: includes/class-ctc-ui.php:618
367
+ msgid ""
368
+ "\n"
369
+ "<p>You can add additional stylesheets and web fonts by typing @import rules "
370
+ "into the textarea on the @import tab. <strong>Important: The Child Theme "
371
+ "Configurator adds the @import rule that loads the Parent Theme's stylesheet "
372
+ "automatically. Do not need to add it here.</strong></p>\n"
373
+ "<p><strong>Important:</strong> If you chose \"Scan Parent Theme for "
374
+ "additional stylesheets,\" the Child Theme Configurator automically places "
375
+ "@import rules for the additional stylesheets here. Be sure to delete any "
376
+ "imports that are not needed by the front end, such as admin or configuration "
377
+ "stylesheets.</p>\n"
378
+ "<p>Below is an example that loads a local custom stylesheet (you would have "
379
+ "to add the \"fonts\" directory and stylesheet) as well as the web font "
380
+ "\"Open Sans\" from Google Web Fonts:</p>\n"
381
+ "<blockquote><pre><code>\n"
382
+ "@import url(fonts/stylesheet.css);\n"
383
+ "@import url(http://fonts.googleapis.com/css?family=Open"
384
+ "+Sans:400,400italic,700,700italic);\n"
385
+ "</code></pre></blockquote>\n"
386
+ "\t\t\t\t "
387
+ msgstr ""
388
+
389
+ #: includes/class-ctc-ui.php:633
390
+ msgid ""
391
+ "\n"
392
+ "<h5>Parent Templates</h5><p>Copy PHP template files from the parent theme by "
393
+ "checking the boxes and clicking \"Copy Selected to Child Theme\" and the "
394
+ "templates will be added to the child theme directory.</p>\n"
395
+ "<p><strong>CAUTION: If your child theme is active, the child theme version "
396
+ "of the file will be used instead of the parent immediately after it is "
397
+ "copied.</strong></p>\n"
398
+ "<p>The <code>functions.php</code> file is generated separately and cannot be "
399
+ "copied here.</p>\n"
400
+ "<h5>Child Templates</h5><p>Templates copied from the parent are listed here. "
401
+ "These can be edited using the Theme Editor in the Appearance Menu.</p>\n"
402
+ "<p>Remove child theme images by checking the boxes and clicking \"Remove "
403
+ "Selected from Child Theme.\"</p>\n"
404
+ "<h5>Child Theme Images</h5><p>Theme images reside under the <code>images</"
405
+ "code> directory in your child theme and are meant for stylesheet use only. "
406
+ "Use the media gallery for content images.</p>\n"
407
+ "<p>You can upload new images using the image upload form.</p>\n"
408
+ "<h5>Child Theme Screenshot</h5><p>You can upload a custom screenshot for the "
409
+ "child theme here.</p>\n"
410
+ "<p>The theme screenshot should be a 4:3 ratio (eg., 880px x 660px) JPG, PNG "
411
+ "or GIF. It will be renamed <code>screenshot</code>.</p>\n"
412
+ "\t\t\t\t "
413
+ msgstr ""
414
+
415
+ #: includes/class-ctc-ui.php:649
416
+ msgid "Preview and Activate"
417
+ msgstr ""
418
+
419
+ #: includes/class-ctc-ui.php:650
420
+ msgid ""
421
+ "\n"
422
+ "<p>Click the Child or Parent CSS tab to reference the stylesheet code. To "
423
+ "preview the stylesheet as a WordPress theme follow these steps:</p>\n"
424
+ "<ol><li>Navigate to Appearance > Themes in the WordPress Admin. You will now "
425
+ "see the new Child Theme as one of the installed Themes.</li>\n"
426
+ "<li>Click \"Live Preview\" below the new Child Theme to see it in action.</"
427
+ "li>\n"
428
+ "<li>When you are ready to take the Child Theme live, click \"Activate.\"</"
429
+ "li></ol>\n"
430
+ "\t\t\t\t "
431
+ msgstr ""
432
+
433
+ #: includes/class-ctc-ui.php:661
434
+ msgid "FAQs"
435
+ msgstr ""
436
+
437
+ #: includes/class-ctc-ui.php:662
438
+ msgid ""
439
+ "\n"
440
+ "<h5>Does it work with Plugins?</h5>\n"
441
+ "<p>We offer a premium extension to let you easily modify styles for any "
442
+ "WordPress Plugin installed on your website. The Child Theme Configurator "
443
+ "Plugin Extension scans your plugins and allows you to create custom "
444
+ "stylesheets in your Child Theme. <a href=\"http://www.lilaeamedia.com/"
445
+ "plugins/child-theme-plugin-styles\" title=\"Child Theme Configurator "
446
+ "Extension\">Learn more</a></p>\n"
447
+ "<h5 id=\"doesnt_work\">Why doesn’t this work with my (insert theme vendor "
448
+ "here) theme?</h5>\n"
449
+ "<p>Some themes (particularly commercial themes) do not adhere to the Theme "
450
+ "Development guidelines set forth by WordPress.org, and do not automatically "
451
+ "load child theme stylesheets or php files. This is unfortunate, because it "
452
+ "effectively prohibits the webmaster from adding any customizations (other "
453
+ "than those made through the admin theme options) that will survive past an "
454
+ "upgrade.</p>\n"
455
+ "<p>Contact the vendor directly to ask for this core functionality. It is our "
456
+ "opinion that ALL themes (especially commercial ones) must pass the Theme "
457
+ "Unit Tests outlined by WordPress.org.</p>\n"
458
+ "<h5>Can I edit the Child Theme stylesheet manually offline or by using the "
459
+ "Editor or do I have to use the Configurator?</h5>\n"
460
+ "<p>You can make any manual changes you wish to the stylesheet. Just make "
461
+ "sure you import the revised stylesheet using the Parent/Child panel or the "
462
+ "Configurator will overwrite your changes the next time you use it. Just "
463
+ "follow the steps as usual but select the \"Use Existing Child Theme\" radio "
464
+ "button as the \"Child Theme\" option. The Configurator will automatically "
465
+ "update its internal data from the new stylesheet.</p>\n"
466
+ "<h5>Why doesn't the Parent Theme have any styles when I \"View Parent CSS\"?"
467
+ "</h5>\n"
468
+ "<p>Your Parent theme is probably using a non-standard location for the "
469
+ "stylesheets. Check \"Scan Parent Theme for additional stylesheets\" on the "
470
+ "Parent/Child tab and load the Child Theme again.</p>\n"
471
+ "<h5>Why is everything backwards?</h5>\n"
472
+ "<p>More than likely you selected \"Scan Parent Theme for additional "
473
+ "stylesheets\" and your theme uses a \"right-to-left\" (rtl) stylesheet. Go "
474
+ "to the @imports tab and remove the rtl stylesheet from the list of imported "
475
+ "stylesheets.</p>\n"
476
+ "<h5 id=\"menus-broken\">Why are my menus displaying incorrectly when I "
477
+ "activate the new child theme?</h5>\n"
478
+ "<p>The child theme creates a new instance in the WordPress options data and "
479
+ "the menus have to be assigned. Go to Appearance &gt; Menus and assign "
480
+ "locations to each of the menus for the new Child Theme.</p>\n"
481
+ "<h5 \"preview-not-loading\">Why do the preview tabs return \"Stylesheet "
482
+ "could not be displayed\"?</h5>\n"
483
+ "<p>You have to configure at least one child theme from the Parent/Child tab "
484
+ "for the preview to display.</p>\n"
485
+ "<h5 id=\"specific_color\">How do I change a specific color/font style/"
486
+ "background?</h5>\n"
487
+ "<p>You can override a specific value globally using the Rule/Value tab. See "
488
+ "Rule/Value, above.</p>\n"
489
+ "<h5 id=\"add_styles\">How do I add styles that aren't in the Parent Theme?</"
490
+ "h5>\n"
491
+ "<p>You can add queries and selectors using the \"New Selector(s)\" textarea "
492
+ "on the Query/Selector tab. See Query/Selector, above.</p>\n"
493
+ "<h5 id=\"add_styles\">How do I remove a style from the Parent Theme?</h5>\n"
494
+ "<p>You shouldn't really \"remove\" a style from the Parent. You can, "
495
+ "however, set the rule to \"inherit,\" \"none,\" or zero (depending on the "
496
+ "rule). This will negate the Parent value. Some experimentation may be "
497
+ "necessary.</p>\n"
498
+ "<h5 id=\"remove_styles\">How do I remove a style from the Child Theme?</h5>\n"
499
+ "<p>Delete the value from the input for the rule you wish to remove. The "
500
+ "Child Theme Configurator only adds overrides for rules that contain values.</"
501
+ "p>\n"
502
+ "<h5 id=\"important_flag\">How do I set the !important flag?</h5>\n"
503
+ "<p>We always recommend relying on good cascading design over global "
504
+ "overrides. To that end, you have ability to change the load order of child "
505
+ "theme styles by entering a value in the \"Order\" field. And yes, you can "
506
+ "now set rules as important by checking the \"!\" box next to each input. "
507
+ "Please use judiciously.</p>\n"
508
+ "<h5 id=\"gradients\">How do I create cross-browser gradients?</h5>\n"
509
+ "<p>The Child Theme Configurator automatically generates the vendor prefixes "
510
+ "and filters to display gradients across most browsers. It uses a normalized "
511
+ "syntax and only supports two colors without intermediate stops. The inputs "
512
+ "consist of origin (e.g., top, left, 135deg, etc.), start color and end "
513
+ "color. The browser-specific syntax is generated automatically when you save "
514
+ "these values. <strong>Note:</strong> For Internet Explorer, a filter rule "
515
+ "approximates the gradient but can only be horizontal (origin top) or "
516
+ "vertical (origin left). The legacy webkit-gradient syntax is not supported.</"
517
+ "p>\n"
518
+ "<h5 id=\"responsive\">How do I make my Theme responsive?</h5>\n"
519
+ "<p>This topic is beyond the scope of this document. The short answer is to "
520
+ "use a responsive Parent Theme. Some common characteristics of responsive "
521
+ "design are:\n"
522
+ "<ul><li>Avoiding fixed width and height values. Using max- and min-height "
523
+ "values and percentages are ways to make your designs respond to the viewer's "
524
+ "browser size.</li>\n"
525
+ "<li>Combining floats and clears with inline and relative positions allow the "
526
+ "elements to adjust gracefully to their container's width.</li>\n"
527
+ "<li>Showing and hiding content with Javascript.</li></ul>\n"
528
+ "<h5 id=\"web_fonts\">How do I add Web Fonts?</h5>\n"
529
+ "<p>The easiest method is to paste the @import code provided by Google, Font "
530
+ "Squirrel or any other Web Font site into the @import tab. The fonts will "
531
+ "then be available to use as a value of the <strong>font-family</strong> "
532
+ "rule. Be sure you understand the license for any embedded fonts.</p>\n"
533
+ "<p>You can also create a secondary stylesheet that contains @font-face rules "
534
+ "and import it using the @import tab. <strong>Note:</strong> Currently the "
535
+ "Child Theme Configurator does not generate previews of imported web fonts, "
536
+ "but will in a later release.</p>\n"
537
+ "<h5 id=\"functions_file\">Where are the PHP files?</h5>\n"
538
+ "<p>The configurator automatically adds a blank functions.php file to the "
539
+ "child theme directory. Other parent theme files can be copied using the "
540
+ "\"Files\" tab. Theme images and a custom screenshot can be uploaded there as "
541
+ "well.</p>\n"
542
+ " "
543
+ msgstr ""
544
+
545
+ #: includes/class-ctc-ui.php:706
546
+ msgid "Glossary"
547
+ msgstr ""
548
+
549
+ #: includes/class-ctc-ui.php:707
550
+ msgid ""
551
+ "\n"
552
+ "<h3 id=\"terms\">Glossary</h3>\n"
553
+ "<ul><li id=\"parent_theme\"><strong>Parent Theme</strong> The WordPress "
554
+ "Theme you wish to edit. WordPress first loads the Child Theme, then loads "
555
+ "the Parent Theme. If a style exists in the Child Theme, it overrides the "
556
+ "Parent Theme.</li>\n"
557
+ " <li id=\"child_theme\"><strong>Child Theme</strong> New Theme based on "
558
+ "Parent Theme. You can create any number of Child Themes from a single Parent "
559
+ "Theme.</li>\n"
560
+ " <li id=\"class\"><strong>Class</strong> A term used to organize objects. "
561
+ "For example, a &lt;div&gt; might be assigned the \"blue-text\" class. The "
562
+ "stylesheet might then assign the \"color: blue;\" rule to members of the "
563
+ "\"blue-text\" class. Thus, the &lt;div&gt; would display text as blue in the "
564
+ "browser.</li>\n"
565
+ " <li id=\"selector\"><strong>Selector</strong> One or more html elements, "
566
+ "classes, ids or other terms used to identify groups of objects.</li>\n"
567
+ " <li id=\"rule\"><strong>Rule</strong> One of many standardized attributes "
568
+ "used to tell the browser how to display objects matching a given selector. "
569
+ "Examples are <strong>color</strong>, <strong>background-image</strong> and "
570
+ "<strong>font-size</strong>.</li>\n"
571
+ "<li id=\"at-rule\"><strong>At-rule</strong> CSS browser instruction to "
572
+ "extend default functionality. The Child Theme Configurator supports two At-"
573
+ "rules:\n"
574
+ "<ul> <li id=\"import\"><strong>@import</strong> Instructs the browser to "
575
+ "load additional CSS information from an external source.</li>\n"
576
+ " <li id=\"query\"><strong>@media (Media Query)</strong> Identifies blocks of "
577
+ "styles that are used only when certain browser characteristics are true. "
578
+ "Examples are max-width, screen and print.</li>\n"
579
+ "</ul></li>\n"
580
+ " <li id=\"override\"><strong>Override</strong> When a selector exists in "
581
+ "both the Child Theme and the Parent Theme, the Child Theme takes priority "
582
+ "over the Parent theme. This is where the Child Theme Configurator stands "
583
+ "out: it helps you create <strong>exact overrides</strong> of selectors from "
584
+ "the Parent Theme, eliminating hours of trial and error.</li>\n"
585
+ " </ul> \n"
586
+ "\t\t\t\t "
587
+ msgstr ""
588
+
589
+ #: includes/class-ctc-ui.php:730
590
+ msgid "Contact us"
591
+ msgstr ""
592
+
593
+ #: includes/class-ctc-ui.php:731
594
+ msgid "Plugin Website"
595
+ msgstr ""
596
+
597
+ #: includes/class-ctc-ui.php:732
598
+ msgid "Donate"
599
+ msgstr ""
600
+
601
+ #: includes/class-ctc-ui.php:733
602
+ msgid "Give Us 5 Stars"
603
+ msgstr ""
604
+
605
+ #: includes/class-ctc-ui.php:734
606
+ msgid "WordPress Codex"
607
+ msgstr ""
608
+
609
+ #: includes/class-ctc-ui.php:735
610
+ msgid "WordPress Answers"
611
+ msgstr ""
612
+
613
+ #. #-#-#-#-# ctc.pot.txt (Child Theme Configurator 1.4.0) #-#-#-#-#
614
+ #. Plugin Name of the plugin/theme
615
+ #: includes/class-ctc.php:43
616
+ msgid "Child Theme Configurator"
617
+ msgstr ""
618
+
619
+ #: includes/class-ctc.php:44
620
+ msgid "Child Themes"
621
+ msgstr ""
622
+
623
+ #: includes/class-ctc.php:92
624
+ msgid "URL/None"
625
+ msgstr ""
626
+
627
+ #: includes/class-ctc.php:93
628
+ msgid "Origin"
629
+ msgstr ""
630
+
631
+ #: includes/class-ctc.php:94
632
+ msgid "Color 1"
633
+ msgstr ""
634
+
635
+ #: includes/class-ctc.php:95
636
+ msgid "Color 2"
637
+ msgstr ""
638
+
639
+ #: includes/class-ctc.php:96
640
+ msgid "Width"
641
+ msgstr ""
642
+
643
+ #: includes/class-ctc.php:97
644
+ msgid "Style"
645
+ msgstr ""
646
+
647
+ #: includes/class-ctc.php:98
648
+ msgid "Color"
649
+ msgstr ""
650
+
651
+ #: includes/class-ctc.php:100
652
+ msgid "Are you sure? This will replace your current settings."
653
+ msgstr ""
654
+
655
+ #: includes/class-ctc.php:103
656
+ msgid "<span style=\"font-size:10px\">!</span>"
657
+ msgstr ""
658
+
659
+ #: includes/class-ctc.php:105
660
+ msgid "Close"
661
+ msgstr ""
662
+
663
+ #: includes/class-ctc.php:106
664
+ msgid "Edit"
665
+ msgstr ""
666
+
667
+ #: includes/class-ctc.php:107
668
+ msgid "Cancel"
669
+ msgstr ""
670
+
671
+ #: includes/class-ctc.php:108
672
+ msgid "Rename"
673
+ msgstr ""
674
+
675
+ #: includes/class-ctc.php:109
676
+ msgid "The stylesheet cannot be displayed."
677
+ msgstr ""
678
+
679
+ #: includes/class-ctc.php:110
680
+ msgid "(Child Only)"
681
+ msgstr ""
682
+
683
+ #: includes/class-ctc.php:111
684
+ msgid "Please enter a valid Child Theme"
685
+ msgstr ""
686
+
687
+ #: includes/class-ctc.php:112 includes/class-ctc.php:245
688
+ msgid "Please enter a valid Child Theme name"
689
+ msgstr ""
690
+
691
+ #: includes/class-ctc.php:113
692
+ msgid "<strong>%s</strong> exists. Please enter a different Child Theme"
693
+ msgstr ""
694
+
695
+ #: includes/class-ctc.php:229
696
+ msgid "%s does not exist. Please select a valid Parent Theme"
697
+ msgstr ""
698
+
699
+ #: includes/class-ctc.php:232
700
+ msgid "Please select a valid Parent Theme"
701
+ msgstr ""
702
+
703
+ #: includes/class-ctc.php:238
704
+ msgid ""
705
+ "<strong>%s</strong> exists. Please enter a different Child Theme template "
706
+ "name"
707
+ msgstr ""
708
+
709
+ #: includes/class-ctc.php:242
710
+ msgid "Please enter a valid Child Theme template name"
711
+ msgstr ""
712
+
713
+ #: includes/class-ctc.php:248
714
+ msgid ""
715
+ "Your theme directories are not writable. Please adjust permissions and try "
716
+ "again."
717
+ msgstr ""
718
+
719
+ #: includes/class-ctc.php:262
720
+ msgid ""
721
+ "Your stylesheet is not writable. Please adjust permissions and try again."
722
+ msgstr ""
723
+
724
+ #: includes/class-ctc.php:299
725
+ msgid "You do not have permission to configure child themes."
726
+ msgstr ""
727
+
728
+ #. Plugin URI of the plugin/theme
729
+ msgid "http://www.lilaeamedia.com/plugins/child-theme-configurator/"
730
+ msgstr ""
731
+
732
+ #. Description of the plugin/theme
733
+ msgid ""
734
+ "Create a Child Theme from any installed Theme. Each CSS selector, rule and "
735
+ "value can then be searched, previewed and modified."
736
+ msgstr ""
737
+
738
+ #. Author of the plugin/theme
739
+ msgid "Lilaea Media"
740
+ msgstr ""
741
+
742
+ #. Author URI of the plugin/theme
743
+ msgid "http://www.lilaeamedia.com/"
744
+ msgstr ""
readme.txt CHANGED
@@ -2,24 +2,37 @@
2
  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.5
6
- Tested up to: 3.8
7
- Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Create a Child Theme from any installed Theme by parsing and indexing its stylesheet. Each selector, rule and value can then be searched, previewed and modified.
12
 
13
  == Description ==
14
 
15
- Created by Lilaea Media, the team that brought you IntelliWidget, the Child Theme Configurator provides a new approach to WordPress stylesheets. The Childe 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.
21
 
22
- Why create Child Themes using the Child Theme Configurator?
23
 
24
  * Apply changes in a Child Theme without touching the Parent Theme
25
  * Identify and override exact selectors from the Parent Theme
@@ -30,9 +43,11 @@ Why create Child Themes using the Child Theme Configurator?
30
  * View style changes before commiting to them
31
  * Add and modify individual @media queries
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,31 +56,85 @@ Why create Child Themes using the Child Theme Configurator?
41
 
42
  == Frequently Asked Questions ==
43
 
44
- = Where is the functions.php file? =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- You can add your own functions.php file, and any other files and directories you need for your Child Theme. The Child Theme Configurator helps you identify and override selectors in the Parent stylesheet without touching the other files.
 
47
 
48
- = How Do I change a specific color/font style/background? =
49
 
50
- You can override a specific value globally using the Rule/Value tab. See "Rule/Value," below.
 
51
 
52
- = How Do I add styles that aren't in the Parent Theme? =
53
 
54
- You can add queries and selectors using the "New Selector(s)" textarea on the Query/Selector tab. See "Query/Selector," below.
55
 
56
- = How Do I remove a style from the Parent Theme? =
57
 
58
- You can't really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.
59
 
60
- = How Do I remove a style from the Child Theme? =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  Delete the value from the input for the rule you wish to remove. The Child Theme Configurator only adds overrides for rules that contain values.
63
 
64
- = How Do I create cross-browser gradients? =
 
 
 
 
65
 
66
  The Child Theme Configurator uses a standardized syntax for gradients and only supports two-color gradients without intermediate stops. The inputs consist of origin (e.g., top, left, 135deg, etc.), start color and end color. The browser-specific syntax is generated automatically when you save these values. See Caveats, below, for more information.
67
 
68
- = How Do I make my Theme responsive? =
69
 
70
  This topic is beyond the scope of this document. The short answer is to use a responsive Parent Theme. Some common characteristics of responsive design are:
71
 
@@ -73,9 +142,9 @@ This topic is beyond the scope of this document. The short answer is to use a re
73
  * Combining floats and clears with inline and relative positions allow the elements to adjust gracefully to their container's width.
74
  * Showing and hiding content with Javascript.
75
 
76
- = How Do I add Web Fonts? =
77
 
78
- The easiest method is to paste the @import code provided by Google, Font Squirrel or any other Web Font site into the @import tab. The fonts will then be available to use as a value of the font-family rule. Be sure you understand the license for any embedded fonts.
79
 
80
  You can also create a secondary stylesheet that contains @font-face rules and import it using the @import tab.
81
 
@@ -89,26 +158,124 @@ You can also create a secondary stylesheet that contains @font-face rules and im
89
 
90
  == Changelog ==
91
 
92
- == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
  = 1.0.0 =
95
  * Initial release.
96
 
97
  == Upgrade Notice ==
98
 
99
- = 1.0.0 =
100
- * Initial release.
 
 
101
 
102
  == Create Your Child Theme ==
103
 
104
  The first step is to create a child theme and import your parent theme styles into the configurator.
105
 
106
  1. Select an existing parent theme from the menu.
107
- 2. Select an existing child theme from the menu, or "New Theme" if you are creating one from scratch.
108
- 3. Enter an author for the child theme.
109
- 4. If this is a new theme, enter a Name.
110
- 5. If this is a new theme, enter a "slug" (lower case, no spaces). This is used to name the theme directory and identify the theme to WordPress.
111
- 6. Click "Load Styles." If you are loading an existing child theme, The Child Theme Configurator will create a backup of your existing stylesheet in the theme directory.
 
 
 
 
 
 
112
 
113
  == Override Parent Styles ==
114
 
@@ -121,6 +288,8 @@ Next, find the selector by typing in the Selector autoselect box. Select by clic
121
 
122
  This will load all of the rules for that selector with the Parent values on the left and the Child values inputs on the right. Any existing child values will be automatically populated. There is also a Sample preview that displays the combination of Parent and Child overrides. Note that the border and background-image get special treatment.
123
 
 
 
124
  Click "Save" to update the child stylesheet and save your changes to the WordPress admin.
125
 
126
  = Rule/Value =
@@ -145,7 +314,28 @@ If you prefer to use shorthand syntax for rules and values instead of the inputs
145
 
146
  You can add additional stylesheets and web fonts by typing @import rules into the textarea on the @import tab. Important: The Child Theme Configurator adds the @import rule that loads the Parent Theme's stylesheet automatically. Do not need to add it here.
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  == Preview and Activate ==
 
149
  Click the Preview CSS tab to see your new masterpiece as CSS code. To preview the stylesheet as a WordPress theme follow these steps:
150
 
151
  1. Navigate to Appearance > Themes in the WordPress Admin. You will now see the new Child Theme as one of the installed Themes.
@@ -163,3 +353,5 @@ Click the Preview CSS tab to see your new masterpiece as CSS code. To preview th
163
  == Documentation ==
164
 
165
  Go to http://www.lilaeamedia.com/plugins/child-theme-configurator
 
 
2
  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.9
7
+ Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Create a Child Theme from any installed Theme. Each CSS selector, rule and value can then be searched, previewed and modified.
12
 
13
  == Description ==
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
+ = New Files Tab! =
18
+
19
+ Now you can copy parent theme template files into your child themes and edit them using the Theme Editor. We've also added an image uploader to add custom theme images for your stylesheets along with a screenshot uploader.
20
+
21
+ = Now it works with plugins! =
22
+
23
+ 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
24
+
25
+ = Take Control of Your Child Themes =
26
+
27
+ https://www.youtube.com/watch?v=xL2HkWQxgOA
28
+
29
+ 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.
30
 
 
31
  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.
32
 
33
  When you are ready, just activate the Child Theme and your WordPress site takes on the new look and feel automatically.
34
 
35
+ = Why create Child Themes using the Child Theme Configurator? =
36
 
37
  * Apply changes in a Child Theme without touching the Parent Theme
38
  * Identify and override exact selectors from the Parent Theme
43
  * View style changes before commiting to them
44
  * Add and modify individual @media queries
45
  * Import web fonts and use them in place of Theme fonts
46
+ * Copy theme templates and edit them using Theme Editor
47
+ * Upload theme images for use with stylesheets
48
+ * Upload custom screenshot for your child theme
49
  * Save hours of development time
50
 
 
51
  == Installation ==
52
 
53
  1. Download the Child Theme Configurator plugin archive and unzip it.
56
 
57
  == Frequently Asked Questions ==
58
 
59
+ = Does it work with plugins? =
60
+
61
+ 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
62
+
63
+ = Is there a tutorial? =
64
+
65
+ https://www.youtube.com/watch?v=xL2HkWQxgOA
66
+
67
+ https://www.youtube.com/watch?v=DSfx2RbZobo
68
+
69
+ = Why doesn't this work with my (insert theme vendor here) theme? =
70
+
71
+ 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.
72
+
73
+ 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.
74
+
75
+ = Why doesn't the Parent Theme have any styles when I "View Parent CSS"? =
76
+
77
+ Your Parent theme is probably using a non-standard location for the stylesheets. Check "Scan Parent Theme for additional stylesheets" on the Parent/Child tab and load the Child Theme again.
78
+
79
+ = Where is it in the Admin? =
80
 
81
+ The Child Theme Configurator can be found under the "Tools" menu in the WordPress Admin. Click "Child Themes" to get started.
82
+ Click the "Help" tab at the top right for a quick reference.
83
 
84
+ = Where are the styles? The configurator doesn't show anything! =
85
 
86
+ All of the styles are loaded dynamically. You must start typing in the text boxes to select styles to edit.
87
+ "Base" is the query group that contains styles that are not associated with any particular "At-rule."
88
 
89
+ Start by clicking the "Query/Selector" tab and typing "base" in the first box. You can then start typing in the second box to retrieve the style selectors to edit.
90
 
91
+ = Why do the preview tabs return "Stylesheet could not be displayed"? =
92
 
93
+ You have to load a child theme from the Parent/Child tab for the preview to display. This can also happen when your WP_CONTENT_URL is different than $bloginfo('site_url'). Ajax cannot make cross-domain requests by default. Check that your Settings > General > "WordPress Address (URL)" value is correct. (Often caused by missing "www" in the domain.)
94
 
95
+ = Can I edit the Child Theme stylesheet manually offline or by using the Editor or do I have to use the Configurator? =
96
 
97
+ You can make any manual changes you wish to the stylesheet. Just make sure you import the revised stylesheet using the Parent/Child panel or the Configurator will overwrite your changes the next time you use it. Just follow the steps as usual but select the "Use Existing Child Theme" radio button as the "Child Theme" option. The Configurator will automatically update its internal data from the new stylesheet.
98
+
99
+ = Why are my menus displaying incorrectly when I activate the new child theme? =
100
+
101
+ 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.
102
+
103
+ = If the parent theme changes (e.g., upgrade), do I have to update the child theme? =
104
+
105
+ No. This is the point of using child themes. Changes to the parent theme are automatically inherited by the child theme.
106
+
107
+ A child theme is not a "copy" of the parent theme. It is a special feature of WordPress that let's you override specific styles and functions leaving the rest of the theme intact. The only time you need to make changes after an upgrade is if the parent removes or changes style or function names. Quality themes should identify any deprecated functions or styles in the upgrade notes so that child theme users can make adjustments accordingly.
108
+
109
+ = Where are the .php files? =
110
+
111
+ The configurator automatically adds a blank functions.php file to the child theme directory. Other parent theme files can be copied using the "Files" tab. Theme images and a custom screenshot can be uploaded there as well.
112
+
113
+ = How do I change a specific color/font style/background? =
114
+
115
+ You can override a specific value globally using the Rule/Value tab. See Rule/Value, above.
116
+
117
+ = How do I add styles that aren't in the Parent Theme? =
118
+
119
+ You can add queries and selectors using the "Raw CSS" textarea on the Query/Selector tab. See Query/Selector, above.
120
+
121
+ = How do I remove a style from the Parent Theme? =
122
+
123
+ You shouldn't really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.
124
+
125
+ = How do I remove a style from the Child Theme? =
126
 
127
  Delete the value from the input for the rule you wish to remove. The Child Theme Configurator only adds overrides for rules that contain values.
128
 
129
+ = How do I set the !important flag? =
130
+
131
+ We always recommend relying on good cascading design over global overrides. To that end, you have ability to change the load order of child theme styles by entering a value in the "Order" field. And yes, you can now set rules as important by checking the "!" box next to each input. Please use judiciously.
132
+
133
+ = How do I create cross-browser gradients? =
134
 
135
  The Child Theme Configurator uses a standardized syntax for gradients and only supports two-color gradients without intermediate stops. The inputs consist of origin (e.g., top, left, 135deg, etc.), start color and end color. The browser-specific syntax is generated automatically when you save these values. See Caveats, below, for more information.
136
 
137
+ = How do I make my Theme responsive? =
138
 
139
  This topic is beyond the scope of this document. The short answer is to use a responsive Parent Theme. Some common characteristics of responsive design are:
140
 
142
  * Combining floats and clears with inline and relative positions allow the elements to adjust gracefully to their container's width.
143
  * Showing and hiding content with Javascript.
144
 
145
+ = How do I add Web Fonts? =
146
 
147
+ The easiest method is to paste the @import code provided by Google, Font Squirrel or any other Web Font site into the @import tab. The fonts will then be available to use as a value of the font-family rule. Be sure you understand the license for any embedded fonts.
148
 
149
  You can also create a secondary stylesheet that contains @font-face rules and import it using the @import tab.
150
 
158
 
159
  == Changelog ==
160
 
161
+ = 1.4.1 =
162
+ * Tweaked the Files tab options and added check for DISALLOW_FILE_EDIT
163
+ * Removed automatic @import rules for additional stylesheets that are loaded.
164
+ * Fixed bug caused by new jQuery .css function handling of empty css values (preview swatch).
165
+
166
+ = 1.4.0 =
167
+ * New Feature: Theme Files tab:
168
+ * Copy parent templates to child theme to be edited using the Theme Editor.
169
+ * Remove child theme templates.
170
+ * Upload child theme images.
171
+ * Remove child theme images.
172
+ * Upload child theme screenshot.
173
+
174
+ = 1.3.5 =
175
+ * Fixes a bug with the way the @import data is stored that threw errors on php 5.3 and corrupted v1.3.2 @import data.
176
+
177
+ = 1.3.3 =
178
+ * New Feature: option to scan parent theme for additional stylesheets. This allows CTC to be used with themes such as "Responsive" by CyberChimps.
179
+ * New Feature: automatically copies parent theme screenshot to child.
180
+
181
+ = 1.3.2 =
182
+ * Fixed unquoted regex pattern in file path security check function. Thanks to buzcuz for reporting this.
183
+
184
+ = 1.3.1 =
185
+ * Updated help tab content. Added additional sanitization of source and target file paths.
186
+
187
+ = 1.3.0 =
188
+ * Changed CSS preview to retrieve directly from WordPress Admin instead of remote http GET to prevent caching issues.
189
+ * Added loading icon for CSS preview.
190
+ * Fixed JS type error on backup toggle.
191
+ * Improved extensibility throughout.
192
+
193
+ = 1.2.3 =
194
+ * Replace PHP short tags with standard codes.
195
+
196
+ = 1.2.2 =
197
+ * New Features: You can now rename selectors in place from the Query/Selector panel. Made stylesheet backup optional. Bugs fixed: Incorrect parsing of background position when '0', fixed type error when background image url value is removed.
198
+
199
+ = 1.2.1 =
200
+ * Bugs fixed: "star hack" rules no longer throwing js error. Important flag now works on borders and gradients.
201
+
202
+ = 1.2.0 =
203
+ * 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.
204
+
205
+ = 1.1.9 =
206
+ * Added check for writability before attempting to create child theme files to avoid fatal error on servers not running suEXEC. Fixed a bug in the ctc_update_cache function that was throwing a fatal JS error when new media queries were saved via the Raw CSS input. Configurator now adds functions.php file to child theme when it does not exist.
207
+
208
+ = 1.1.8 =
209
+ * Added reorder sequence and important flag functionality. Fixed bug where multiple inputs with same selector/rule combo were assigned the same id. Fixed bug in the shorthand encoding routine.
210
+
211
+ = 1.1.7 =
212
+ * Added tutorial video to help tabs.
213
+
214
+ = 1.1.6 =
215
+ * Added call to reset_updates() before update_option() to prevent serialization errors.
216
+
217
+ = 1.1.5 =
218
+ * Query/Selector panel now defaults to 'base'
219
+ * Fixed bug causing background-image with full urls (http://) to be parsed as gradients
220
+ * Fixed bug causing rule menu to throw error when selector has no rules
221
+
222
+ = 1.1.4 =
223
+ * Fixed sort bug in shorthand parser that was returning rules in wrong order
224
+
225
+ = 1.1.3 =
226
+ * Fixed bug that assumed lowercase only for theme slugs. (Thanks to timk)
227
+ * Fixed update redirect to execute on first run
228
+
229
+ = 1.1.2 =
230
+ * Small bug fix to javascript (casting number to string)
231
+
232
+ = 1.1.1 =
233
+ * Fixed major bug where inputs containing '0' were being ignored
234
+ * Removed "no leading digits" requirement for theme slug
235
+ * Change query sort function to keep parent order of queries without device width rules
236
+ * Fixed gettext calls to use static namespace parameter
237
+ * Auto populate child theme inputs when existing theme is selected
238
+ * Correctly remove border when values are blanked
239
+ * Fixed duplicate "new rule" bug on Query/Selector panel
240
+ * added timestamp to backup file
241
+ * Added encode_shorthand function to recombine margin/padding values when all 4 sides are present
242
+
243
+ = 1.1.0 =
244
+ * Corrected parsing for certain backgrounds and gradients (e.g., supports hsla color syntax)
245
+ * Handle empty selectors
246
+ * Ajax load for menus and updates
247
+ * Clean up Parent/Child form UI and validation
248
+ * Streamlined UI overall
249
+
250
+ = 1.0.1 =
251
+ * Updates to Readme.txt
252
 
253
  = 1.0.0 =
254
  * Initial release.
255
 
256
  == Upgrade Notice ==
257
 
258
+ = 1.4.1 =
259
+ * New Files Tab!
260
+ * Now you can copy parent theme template files into your child themes and edit them using the Theme Editor.
261
+ * We've also added an image uploader to add custom theme images for your stylesheets along with a screenshot uploader.
262
 
263
  == Create Your Child Theme ==
264
 
265
  The first step is to create a child theme and import your parent theme styles into the configurator.
266
 
267
  1. Select an existing parent theme from the menu.
268
+ 2. Select "New" or "Existing" child theme.
269
+ * If creating a new theme, enter a "slug" (lower case, no spaces). This is used to name the theme directory and identify the theme to WordPress.
270
+ * If using an existing theme, select a child theme from the menu.
271
+ 3. Enter a Name for the child theme.
272
+ 4. Enter an author for the child theme.
273
+ 5. Enter the child theme version number.
274
+ 6. Check "Backup Stylesheet" if you want to backup original version of child stylesheet.
275
+ 7. Check "Scan Parent Theme for Additional Stylesheets" if your theme uses multiple stylesheets or if the the stylesheets are in a non-standard location. For example, the "Responsive" theme puts the stylesheets in a subdirectory named "core."
276
+ 8. Click "Generate Child Theme Files."
277
+
278
+ If you are loading an existing child theme and checked "Backup Stylesheet," the Child Theme Configurator will create a backup of your existing stylesheet in the theme directory.
279
 
280
  == Override Parent Styles ==
281
 
288
 
289
  This will load all of the rules for that selector with the Parent values on the left and the Child values inputs on the right. Any existing child values will be automatically populated. There is also a Sample preview that displays the combination of Parent and Child overrides. Note that the border and background-image get special treatment.
290
 
291
+ The "Order" field contains the original sequence of the selector in the parent theme stylesheet. You can change the selector order sequence by entering a lower or higher number in the "Order" field. You can also force style overrides (so called "!important" flag) by checking the "!" box next to each input. Please use judiciously.
292
+
293
  Click "Save" to update the child stylesheet and save your changes to the WordPress admin.
294
 
295
  = Rule/Value =
314
 
315
  You can add additional stylesheets and web fonts by typing @import rules into the textarea on the @import tab. Important: The Child Theme Configurator adds the @import rule that loads the Parent Theme's stylesheet automatically. Do not need to add it here.
316
 
317
+ == Files ==
318
+
319
+ = Parent Templates =
320
+
321
+ You can copy PHP template files from the parent theme by checking the boxes. Click "Copy Selected to Child Theme" and the templates will be added to the child theme directory.
322
+
323
+ CAUTION: If your child theme is active, the child theme version of the file will be used instead of the parent immediately after it is copied. The functions.php file is generated separately and cannot be copied here.
324
+
325
+ = Child Templates =
326
+
327
+ Templates copied from the parent are listed here. These can be edited using the Theme Editor in the Appearance Menu. Remove child theme images by checking the boxes and clicking "Remove Selected from Child Theme."</p>
328
+
329
+ = Child Theme Images =
330
+
331
+ Theme images reside under the <code>images</code> directory in your child theme and are meant for stylesheet use only. Use the media gallery for content images. You can upload new images using the image upload form.
332
+
333
+ = Child Theme Screenshot =
334
+
335
+ You can upload a custom screenshot for the child theme here. The theme screenshot should be a 4:3 ratio (eg., 880px x 660px) JPG, PNG or GIF. It will be renamed "screenshot".
336
+
337
  == Preview and Activate ==
338
+
339
  Click the Preview CSS tab to see your new masterpiece as CSS code. To preview the stylesheet as a WordPress theme follow these steps:
340
 
341
  1. Navigate to Appearance > Themes in the WordPress Admin. You will now see the new Child Theme as one of the installed Themes.
353
  == Documentation ==
354
 
355
  Go to http://www.lilaeamedia.com/plugins/child-theme-configurator
356
+
357
+ Copyright: (C) 2014 Lilaea Media
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
screenshot-3.jpg CHANGED
Binary file
screenshot-4.jpg CHANGED
Binary file
screenshot-5.jpg CHANGED
Binary file