Child Theme Configurator - Version 2.2.3

Version Description

  • Show raw results after Analysis to help debugging
  • Fix javascript not escaping quotes in input fields
  • Restored original ajax preview and added fallback method for cross-domain preview
Download this release

Release Info

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

Code changes from version 2.2.2 to 2.2.3

child-theme-configurator.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.childthemeconfigurator.com
8
  Description: When using the Customizer is not enough - Create child themes and customize styles, templates, functions and more.
9
- Version: 2.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com
12
  Text Domain: child-theme-configurator
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.childthemeconfigurator.com
8
  Description: When using the Customizer is not enough - Create child themes and customize styles, templates, functions and more.
9
+ Version: 2.2.3
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com
12
  Text Domain: child-theme-configurator
includes/classes/Admin.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  Class: ChildThemeConfiguratorAdmin
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Main Controller Class
9
- Version: 2.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: child-theme-configurator
@@ -344,7 +344,7 @@ class ChildThemeConfiguratorAdmin {
344
  $this->is_ajax = TRUE;
345
  if ( $this->validate_post( 'ctc_update' ) ):
346
  $analysis = new ChildThemeConfiguratorAnalysis();
347
- $analysis->do_analysis();
348
  die( json_encode( $analysis->get_analysis() ) );
349
  endif;
350
  die( 0 );
6
  Class: ChildThemeConfiguratorAdmin
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Main Controller Class
9
+ Version: 2.2.3
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: child-theme-configurator
344
  $this->is_ajax = TRUE;
345
  if ( $this->validate_post( 'ctc_update' ) ):
346
  $analysis = new ChildThemeConfiguratorAnalysis();
347
+ $analysis->fetch_page();
348
  die( json_encode( $analysis->get_analysis() ) );
349
  endif;
350
  die( 0 );
includes/classes/Analysis.php CHANGED
@@ -28,233 +28,27 @@ class ChildThemeConfiguratorAnalysis {
28
  'preview_ctc' => wp_create_nonce(),
29
  'now' => time(),
30
  );
31
-
32
  }
33
 
34
- // helper function to globalize ctc object
35
- function ctc() {
36
- return ChildThemeConfigurator::ctc();
37
- }
38
-
39
-
40
  function is_child(){
41
  return $this->params[ 'template' ] !== $this->params[ 'stylesheet' ];
42
  }
43
 
44
  function fetch_page(){
45
- $this->url = get_home_url() . '?' . build_query( $this->params );
46
  $args = array(
47
- 'cookies' => $_COOKIE,
48
- );
49
- $this->response = wp_remote_get( $this->url, $args );
50
- }
51
-
52
- function do_analysis(){
53
-
54
- $this->fetch_page();
55
-
56
- $this->analysis = array(
57
- 'url' => $this->url,
58
- 'queue' => array(),
59
- 'imports' => array(),
60
- 'irreg' => array(),
61
- 'dependencies' => array(),
62
- 'errors' => array(),
63
- 'deps' => array( array(), array() ),
64
- 'signals' => array(
65
- /*
66
- err_fatal: 0,
67
- err_fnf: 0,
68
- err_other: 0,
69
- ctc_sep_loaded: 0,
70
- ctc_ext_loaded: 0,
71
- ctc_child_loaded: 0,
72
- ctc_parnt_loaded: 0,
73
- thm_wrong_order: 0,
74
- thm_past_wphead: 0,
75
- thm_unregistered: 0,
76
- thm_parnt_loaded: 0,
77
- thm_child_loaded: 0,
78
- thm_is_ctc: 0,
79
- thm_no_styles: 0,
80
- thm_notheme: 0
81
- */
82
- ),
83
  );
 
84
  if ( is_wp_error( $this->response ) ):
85
- $this->analysis[ 'signals' ][ 'failure' ] = 1;
86
- $this->analysis[ 'signals' ][ 'xhrerr' ] = $this->response->get_error_message();
87
- return;
88
- else:
89
- $body = $this->response[ 'body' ];
90
- endif;
91
- $themepath = preg_replace( "|^https?://|", '', get_theme_root_uri() );
92
- $escaped = preg_quote( $this->params[ 'template' ] ) . ( $this->is_child() ? '|' . preg_quote( $this->params[ 'stylesheet' ] ) : '' );
93
- $regex_link = '%<link( rel=["\']stylesheet["\'] id=[\'"]([^\'"]+?)[\'"])?[^>]+?' .
94
- preg_quote( $themepath ) . '/(' . $escaped . ')/([^"\']+\.css)(\?[^"\']+)?["\'][^>]+>%si';
95
- $regex_err = '%<br \/>\n[^\n]+?(fatal|strict|notice|warning|error).+?<br \/>%si'; //[\s\S]
96
-
97
- $themeloaded = 0; // flag when style.css link is detected
98
- $testloaded = 0; // flag when test link is detected
99
- $this->ctc()->debug( 'regex link: ' . $regex_link . ' regex err: ' . $regex_err, __FUNCTION__ );
100
- // retrieve enqueued stylesheet ids
101
- if ( preg_match( '/BEGIN WP QUEUE\n(.*?)\nEND WP QUEUE/s', $body, $matches ) ):
102
- $this->analysis[ 'queue' ] = explode( "\n", $matches[ 1 ] );
103
- //console.log( 'QUEUE:' );
104
- //console.log( analysis.queue );
105
  else:
106
- $this->analysis[ 'queue' ] = array();
107
- $this->analysis[ 'signals' ][ 'thm_noqueue' ] = 1;
108
- //analysis.signals.failure = 1;
109
- //console.log( 'NO QUEUE' );
110
  endif;
111
- if ( preg_match( '/BEGIN IMPORT STYLESHEETS\n(.*?)\nEND IMPORT STYLESHEETS/s', $body, $matches ) ):
112
- $this->analysis[ 'imports' ] = explode( "\n", $matches[ 1 ] );
113
- else:
114
- $this->analysis[ 'imports' ] = array();
115
- endif;
116
- if ( preg_match( '/BEGIN CTC IRREGULAR\n(.*?)\nEND CTC IRREGULAR/s', $body, $matches ) ):
117
- $this->analysis[ 'irreg' ] = explode( "\n", $matches[ 1 ] );
118
- else:
119
- $this->analysis[ 'irreg' ] = array();
120
- endif;
121
- if ( preg_match( "/CHLD_THM_CFG_IGNORE_PARENT/", $body ) ):
122
- $this->analysis[ 'signals' ][ 'thm_ignoreparnt' ] = 1;
123
- //console.log( 'thm_ignoreparnt' );
124
- endif;
125
- if ( preg_match( "/IS_CTC_THEME/", $body ) ):
126
- $this->analysis[ 'signals' ][ 'thm_is_ctc' ] = 1;
127
- //console.log( 'thm_is_ctc' );
128
- endif;
129
-
130
- if ( preg_match( "/NO_CTC_STYLES/", $body ) ):
131
- $this->analysis[ 'signals' ][ 'thm_no_styles' ] = 1;
132
- //console.log( 'thm_no_styles' );
133
- endif;
134
- if ( preg_match( "/HAS_CTC_IMPORT/", $body ) ):
135
- $this->analysis[ 'signals' ][ 'thm_has_import' ] = 1;
136
- //console.log( 'thm_has_import' );
137
- endif;
138
-
139
- // remove comments to avoid flagging conditional stylesheets ( IE compatability, etc. )
140
- $body = preg_replace( '/<!\-\-.*?\-\->/s', '', $body );
141
- //console.log( 'PARSE:' );
142
- preg_match_all( $regex_err, $body, $regexmatch );
143
- foreach( $regexmatch[ 0 ] as $msg ):
144
- $msg = preg_replace( "/<.*?>/s", '', $msg );
145
- $this->analysis[ 'errors' ][] = $msg;
146
- $this->analysis[ 'signals' ][ 'err_php' ] = 1;
147
- if ( strstr( $msg, "Fatal error" ) )
148
- $this->analysis[ 'signals' ][ 'err_fatal' ] = 1;
149
-
150
- //else if ( errstr.match( /(FileNotFoundException|Failed opening|failed to open stream)/i ) ) {
151
- //analysis.signals.err_fnf = 1;
152
- //}
153
- endforeach;
154
- preg_match_all( $regex_link, $body, $regexmatch );
155
- foreach( $regexmatch[ 0 ] as $msg ):
156
- $stylesheetid = preg_replace( '/\-css$/', '', array_shift( $regexmatch[ 2 ] ) );
157
- $stylesheettheme = array_shift( $regexmatch[ 3 ] );
158
- $stylesheetpath = array_shift( $regexmatch[ 4 ] );
159
-
160
- $linktheme = $this->params[ 'template' ] == $stylesheettheme ? 'parnt' : 'child';
161
- $noid = 0;
162
- //console.log( 'stylesheetid: ' + stylesheetid + ' stylesheetpath: ' + stylesheetpath );
163
- // flag stylesheet links that have no id or are not in wp_styles
164
- if ( '' == $stylesheetid || !in_array( $stylesheetid, $this->analysis[ 'queue' ] ) ):
165
- $noid = 1;
166
- //console.log( 'no id for ' + stylesheetpath + '!' );
167
- elseif ( 0 === strpos( $stylesheetid, 'chld_thm_cfg' ) ): // handle ctc-generated links
168
- // console.log( 'ctc link detected: ' + stylesheetid + ' themeloaded: ' + themeloaded );
169
- if ( preg_match( '/^ctc\-style([\-\.]min)?\.css$/', $stylesheetpath ) ):
170
- //console.log( 'separate stylesheet detected' );
171
- $themeloaded = 1;
172
- $this->analysis[ 'signals' ][ 'ctc_sep_loaded' ] = 1; // flag that separate stylesheet has been detected
173
- elseif ( preg_match( '/^ctc\-genesis([\-\.]min)?\.css$/', $stylesheetpath ) ):
174
- //console.log( 'genesis stylesheet detected' );
175
- $themeloaded = 1;
176
- $this->analysis[ 'signals' ][ 'ctc_gen_loaded' ] = 1; // flag that genesis "parent" has been detected
177
- elseif ( preg_match( '/^chld_thm_cfg_ext/', $stylesheetid ) ):
178
- $this->analysis[ 'signals' ][ 'ctc_ext_loaded' ] = 1; // flag that external stylesheet link detected
179
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( $stylesheetid, $stylesheetpath );
180
- elseif ( 'chld_thm_cfg_child' == $stylesheetid ):
181
- $this->analysis[ 'signals' ][ 'ctc_child_loaded' ] = 1; // flag that ctc child stylesheet link detected
182
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( $stylesheetid, $stylesheetpath );
183
- elseif ( 'chld_thm_cfg_parent' == $stylesheetid ):
184
- $this->analysis[ 'signals' ][ 'ctc_parnt_loaded' ] = 1; // flag that ctc parent stylesheet link detected
185
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( $stylesheetid, $stylesheetpath );
186
- if ( $themeloaded )
187
- //console.log( 'parent link out of sequence' );
188
- $this->analysis[ 'signals' ][ 'ctc_parnt_reorder' ] = 1; // flag that ctc parent stylesheet link out of order
189
- endif;
190
- continue;
191
- endif;
192
- // flag main theme stylesheet link
193
- if ( preg_match( '/^style([\-\.]min)?\.css$/', $stylesheetpath ) ):
194
- //console.log( linktheme + ' theme stylesheet detected: ' + stylesheettheme + '/' + stylesheetpath );
195
- $themeloaded = 1; // flag that main theme stylesheet has been detected
196
- // if main theme stylesheet link has no id then it is unregistered ( hard-wired )
197
- if ( 'parnt' == $linktheme ):
198
- if ( $noid ):
199
- $this->analysis[ 'signals' ][ 'thm_parnt_loaded' ] = 'thm_unregistered';
200
- else:
201
- $this->analysis[ 'signals' ][ 'thm_parnt_loaded' ] = $stylesheetid;
202
- // check that parent stylesheet is loaded before child stylesheet
203
- if ( 'child' == $themetype && $this->analysis[ 'signals' ][ 'thm_child_loaded' ] ):
204
- $this->analysis[ 'signals' ][ 'ctc_parnt_reorder' ] = 1;
205
- endif;
206
- endif;
207
- else:
208
- $this->analysis[ 'signals' ][ 'thm_child_loaded' ] = $noid ? 'thm_unregistered' : $stylesheetid;
209
- endif;
210
- if ( $noid ):
211
- if ( $testloaded ):
212
- $this->analysis[ 'signals' ][ 'thm_past_wphead' ] = 1;
213
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( 'thm_past_wphead', $stylesheetpath );
214
- //console.log( 'Unreachable theme stylesheet detected' );
215
- else:
216
- $this->analysis[ 'signals' ][ 'thm_unregistered' ] = 1;
217
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( 'thm_unregistered', $stylesheetpath );
218
- //console.log( 'Unregistered theme stylesheet detected' );
219
- endif;
220
- else:
221
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( $stylesheetid, $stylesheetpath );
222
- //console.log( 'Theme stylesheet OK!' );
223
- endif;
224
-
225
- elseif ( 'ctc-test.css' == $stylesheetpath ): // flag test stylesheet link
226
- //console.log( 'end of queue reached' );
227
- $testloaded = 1; // flag that test queue has been detected ( end of wp_head )
228
- else:
229
- $err = NULL;
230
- // if stylesheet link has id and loads before main theme stylesheet, add it as a dependency
231
- // otherwise add it as a parse option
232
- if ( $noid )
233
- $err = 'dep_unregistered';
234
-
235
- if ( $testloaded ):
236
- if ( $themeloaded ):
237
- //console.log( 'Unreachable stylesheet detected!' + stylesheetpath );
238
- $err = 'css_past_wphead';
239
- else:
240
- $err = 'dep_past_wphead';
241
- endif;
242
- endif;
243
- // Flag stylesheet links that have no id and are loaded after main theme stylesheet.
244
- // This indicates loading outside of wp_head()
245
- if ( $err ):
246
- $this->analysis[ 'signals' ][ $err ] = 1;
247
- $stylesheetid = $err;
248
- else:
249
- // add to no force options
250
- $this->analysis[ 'dependencies' ][ $stylesheetid ] = 1;
251
- endif;
252
- $this->analysis[ 'deps' ][ $themeloaded ][] = array( $stylesheetid, $stylesheetpath );
253
- endif;
254
- endforeach;
255
- if ( ! $themeloaded )
256
- $this->analysis[ 'signals' ][ 'thm_notheme' ] = 1; // flag that no theme stylesheet has been detected
257
-
258
  }
259
 
260
  function get_analysis(){
28
  'preview_ctc' => wp_create_nonce(),
29
  'now' => time(),
30
  );
31
+ $this->analysis = array();
32
  }
33
 
 
 
 
 
 
 
34
  function is_child(){
35
  return $this->params[ 'template' ] !== $this->params[ 'stylesheet' ];
36
  }
37
 
38
  function fetch_page(){
39
+ $this->url = home_url( '/' ) . '?' . build_query( $this->params ); //get_home_url()
40
  $args = array(
41
+ 'cookies' => $_COOKIE,
42
+ 'user-agent' => $_SERVER[ 'HTTP_USER_AGENT' ],
43
+ 'sslverify' => apply_filters( 'https_local_ssl_verify', false )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  );
45
+ $this->response = wp_remote_get( $this->url, $args );
46
  if ( is_wp_error( $this->response ) ):
47
+ $this->analysis[ 'signals' ][ 'httperr' ] = $this->response->get_error_message();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  else:
49
+ $this->analysis[ 'signals' ] = array();
50
+ $this->analysis[ 'body' ] = $this->response[ 'body' ];
 
 
51
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
  function get_analysis(){
includes/classes/CSS.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
6
  Class: ChildThemeConfiguratorCSS
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Handles all CSS input, output, parsing, normalization and storage
9
- Version: 2.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -167,7 +167,7 @@ class ChildThemeConfiguratorCSS {
167
  $this->parnt = '';
168
  $this->ignoreparnt = 0;
169
  $this->qpriority = 10;
170
- $this->version = '2.2.2';
171
 
172
  // do not set enqueue, not being set is used to flag old versions
173
 
6
  Class: ChildThemeConfiguratorCSS
7
  Plugin URI: http://www.childthemeconfigurator.com/
8
  Description: Handles all CSS input, output, parsing, normalization and storage
9
+ Version: 2.2.3
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
167
  $this->parnt = '';
168
  $this->ignoreparnt = 0;
169
  $this->qpriority = 10;
170
+ $this->version = '2.2.3';
171
 
172
  // do not set enqueue, not being set is used to flag old versions
173
 
includes/classes/Core.php CHANGED
@@ -14,7 +14,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
14
  define( 'LILAEAMEDIA_URL', "http://www.lilaeamedia.com" );
15
  defined( 'CHLD_THM_CFG_DOCS_URL' ) or
16
  define( 'CHLD_THM_CFG_DOCS_URL', "http://www.childthemeconfigurator.com" );
17
- define( 'CHLD_THM_CFG_VERSION', '2.2.2' );
18
  define( 'CHLD_THM_CFG_PREV_VERSION', '1.7.9.1' );
19
  define( 'CHLD_THM_CFG_MIN_WP_VERSION', '3.7' );
20
  define( 'CHLD_THM_CFG_PRO_MIN_VERSION', '2.2.0' );
14
  define( 'LILAEAMEDIA_URL', "http://www.lilaeamedia.com" );
15
  defined( 'CHLD_THM_CFG_DOCS_URL' ) or
16
  define( 'CHLD_THM_CFG_DOCS_URL', "http://www.childthemeconfigurator.com" );
17
+ define( 'CHLD_THM_CFG_VERSION', '2.2.3' );
18
  define( 'CHLD_THM_CFG_PREV_VERSION', '1.7.9.1' );
19
  define( 'CHLD_THM_CFG_MIN_WP_VERSION', '3.7' );
20
  define( 'CHLD_THM_CFG_PRO_MIN_VERSION', '2.2.0' );
includes/classes/UI.php CHANGED
@@ -5,7 +5,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
5
  Class: ChildThemeConfiguratorUI
6
  Plugin URI: http://www.childthemeconfigurator.com/
7
  Description: Handles the plugin User Interface
8
- Version: 2.2.2
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
@@ -183,7 +183,6 @@ class ChildThemeConfiguratorUI {
183
  endif;
184
  if ( isset( $sidebar[ 1 ] ) )
185
  $screen->set_help_sidebar( $sidebar[ 1 ] );
186
- //die( print_r( $screen, TRUE ) );
187
  endif;
188
  }
189
 
@@ -251,7 +250,7 @@ class ChildThemeConfiguratorUI {
251
  $localize_array = apply_filters( 'chld_thm_cfg_localize_script', array(
252
  'converted' => $this->css()->get_prop( 'converted' ),
253
  'ssl' => is_ssl(),
254
- 'homeurl' => get_home_url() . '?preview_ctc=' . wp_create_nonce(),
255
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
256
  'theme_uri' => get_theme_root_uri(),
257
  'page' => CHLD_THM_CFG_MENU,
@@ -323,7 +322,7 @@ class ChildThemeConfiguratorUI {
323
  'anlz27_txt' => __( "This theme does not require the parent theme's <code>style.css</code> file for its appearance.", 'child-theme-configurator' ),
324
  'anlz28_txt' => __( "This Child Theme was configured with an earlier version.", 'child-theme-configurator' ),
325
  'anlz29_txt' => __( '<p>The selected stylesheet handling method is no longer used. Please update the configuration using the "Repair header template" option (see step 6, "Additional handling options", below).</p>', 'child-theme-configurator' ),
326
- 'anlz30_txt' => __( 'Click to show/hide analysis data. Please include contents below with any support requests.', 'child-theme-configurator' ),
327
  'anlz31_txt' => __( 'This child theme was configured using the CTC Pro "Genesis stylesheet handling" method.', 'child-theme-configurator' ),
328
  'anlz32_txt' => __( '<p>This method has been replaced by the "Separate stylesheet" and "Ignore Parent Theme" options ( selected below ) for broader framework compatability.</p>', 'child-theme-configurator' ),
329
  'anlz33_txt' => __( '<p>%1Click Here%2 to view the theme as viewed by the Analyzer.</p>', 'child-theme-configurator' ),
5
  Class: ChildThemeConfiguratorUI
6
  Plugin URI: http://www.childthemeconfigurator.com/
7
  Description: Handles the plugin User Interface
8
+ Version: 2.2.3
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
183
  endif;
184
  if ( isset( $sidebar[ 1 ] ) )
185
  $screen->set_help_sidebar( $sidebar[ 1 ] );
 
186
  endif;
187
  }
188
 
250
  $localize_array = apply_filters( 'chld_thm_cfg_localize_script', array(
251
  'converted' => $this->css()->get_prop( 'converted' ),
252
  'ssl' => is_ssl(),
253
+ 'homeurl' => home_url( '/' ) . '?preview_ctc=' . wp_create_nonce(),
254
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
255
  'theme_uri' => get_theme_root_uri(),
256
  'page' => CHLD_THM_CFG_MENU,
322
  'anlz27_txt' => __( "This theme does not require the parent theme's <code>style.css</code> file for its appearance.", 'child-theme-configurator' ),
323
  'anlz28_txt' => __( "This Child Theme was configured with an earlier version.", 'child-theme-configurator' ),
324
  'anlz29_txt' => __( '<p>The selected stylesheet handling method is no longer used. Please update the configuration using the "Repair header template" option (see step 6, "Additional handling options", below).</p>', 'child-theme-configurator' ),
325
+ 'anlz30_txt' => __( 'Click to show/hide raw analysis data. Please include contents below with any support requests.', 'child-theme-configurator' ),
326
  'anlz31_txt' => __( 'This child theme was configured using the CTC Pro "Genesis stylesheet handling" method.', 'child-theme-configurator' ),
327
  'anlz32_txt' => __( '<p>This method has been replaced by the "Separate stylesheet" and "Ignore Parent Theme" options ( selected below ) for broader framework compatability.</p>', 'child-theme-configurator' ),
328
  'anlz33_txt' => __( '<p>%1Click Here%2 to view the theme as viewed by the Analyzer.</p>', 'child-theme-configurator' ),
includes/forms/parent-child.php CHANGED
@@ -209,7 +209,7 @@ if ( !defined( 'ABSPATH' ) )exit;
209
  <?php _e( 'Separate Stylesheet', 'child-theme-configurator' ); ?>
210
  </strong>
211
  <p class="howto indent">
212
- <?php _e( 'Save new custom styles to a separate stylesheet and use any existing child theme styles as a baseline. Select this option if you want to preserve the original child theme styles instead of overwriting them. This option also allows you to customize stylesheets that load after the primary stylesheet.', 'child-theme-configurator' ); ?>
213
  </p>
214
  </label>
215
 
@@ -299,7 +299,7 @@ if ( !defined( 'ABSPATH' ) )exit;
299
  <?php _e( 'Remove stylesheet dependencies', 'child-theme-configurator' ); ?>
300
  </strong>
301
  <p class="howto indent">
302
- <?php _e( 'By default, the order of stylesheets that load prior to the primary stylesheet is preserved by treating them as dependencies. In rare cases, stylesheets are detected in the preview that are not used site-wide. If necessary, dependency can be removed for specific stylesheets below.', 'child-theme-configurator' ); ?>
303
  </p>
304
  <div id="ctc_dependencies"></div>
305
  </div>
@@ -307,14 +307,13 @@ if ( !defined( 'ABSPATH' ) )exit;
307
  <?php //do_action( 'chld_thm_cfg_enqueue_options' ); // removed for ctc 2.0 ?>
308
  </div>
309
  <div class="ctc-input-row clearfix ctc-themeonly-container<?php echo $disabledclass; ?>" id="ctc_child_header_parameters" style="display:none">
310
- <div class="ctc-input-cell ctc-section-toggle" id="ctc_theme_attributes" title="<?php _e( 'Click to toggle form', 'child-theme-configurator' ); ?>"><span class="ctc-step ctc-step-number">7</span>
311
  <strong>
312
  <?php _e( 'Customize the Child Theme Name, Description, Author, Version, etc.:', 'child-theme-configurator' ); ?>
313
  </strong>
314
- <span class="howto">
315
- <?php _e( '(Click to toggle form)', 'child-theme-configurator' ); ?>
316
- </span>
317
  </div>
 
 
318
  <div class="ctc-clear ctc-section-toggle-content" id="ctc_theme_attributes_content">
319
  <div class="ctc-input-row clearfix ctc-themeonly-container<?php echo $disabledclass; ?>" id="input_row_child_name">
320
  <div class="ctc-input-cell">
209
  <?php _e( 'Separate Stylesheet', 'child-theme-configurator' ); ?>
210
  </strong>
211
  <p class="howto indent">
212
+ <?php _e( 'Save new custom styles to a separate stylesheet and combine any existing child theme styles with the parent to form baseline. Select this option if you want to preserve the existing child theme styles instead of overwriting them. This option also allows you to customize stylesheets that load after the primary stylesheet.', 'child-theme-configurator' ); ?>
213
  </p>
214
  </label>
215
 
299
  <?php _e( 'Remove stylesheet dependencies', 'child-theme-configurator' ); ?>
300
  </strong>
301
  <p class="howto indent">
302
+ <?php _e( 'By default, the order of stylesheets that load prior to the primary stylesheet is preserved by treating them as dependencies. In some cases, stylesheets are detected in the preview that are not used site-wide. If necessary, dependency can be removed for specific stylesheets below.', 'child-theme-configurator' ); ?>
303
  </p>
304
  <div id="ctc_dependencies"></div>
305
  </div>
307
  <?php //do_action( 'chld_thm_cfg_enqueue_options' ); // removed for ctc 2.0 ?>
308
  </div>
309
  <div class="ctc-input-row clearfix ctc-themeonly-container<?php echo $disabledclass; ?>" id="ctc_child_header_parameters" style="display:none">
310
+ <div class="ctc-input-cell" ><span class="ctc-step ctc-step-number">7</span>
311
  <strong>
312
  <?php _e( 'Customize the Child Theme Name, Description, Author, Version, etc.:', 'child-theme-configurator' ); ?>
313
  </strong>
 
 
 
314
  </div>
315
+ <div class="ctc-input-cell">
316
+ <input type="button" class="ctc-section-toggle button-secondary" value="<?php _e( 'Show/Hide Child Theme Attributes', 'child-theme-configurator' ); ?>" id="ctc_theme_attributes" title="<?php _e( 'Click to toggle form', 'child-theme-configurator' ); ?>" /></div>
317
  <div class="ctc-clear ctc-section-toggle-content" id="ctc_theme_attributes_content">
318
  <div class="ctc-input-row clearfix ctc-themeonly-container<?php echo $disabledclass; ?>" id="input_row_child_name">
319
  <div class="ctc-input-cell">
js/chldthmcfg.js CHANGED
@@ -2,7 +2,7 @@
2
  * Script: chldthmcfg.js
3
  * Plugin URI: http://www.childthemeconfigurator.com/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 2.2.2
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
@@ -20,7 +20,7 @@
20
  //console.log( 'executing main function' );
21
  escquo: function( str ) {
22
  var self = this;
23
- return self.is_empty( str ) ? str : str.toString().replace( /"/g, '"' );
24
  },
25
 
26
  getxt: function( key, merge ){
@@ -909,22 +909,6 @@
909
  $( '.ctc-analyze-theme, .ctc-analyze-howto' ).show();
910
  $( '#ctc_load_styles' ).val( 'Create New Child Theme' );
911
  }
912
- /* 2.0.0 maybe necessary?
913
- // disable copy theme options if parent not allowed
914
- // console.log( window.ctcAjax.themes );
915
- // console.log( self.currparnt );
916
- if ( window.ctcAjax.themes.parnt[ self.currparnt ].allowed ){
917
- // console.log( 'allowed' );
918
- $( '#ctc_copy_theme_mods' ).slideDown( 'fast' );
919
- $( '#ctc_parent_mods' ).prop( 'disabled', false );
920
-
921
- } else {
922
- // console.log( 'not allowed' );
923
- $( '#ctc_parent_mods' ).prop( 'disabled', true ).prop( 'checked', false );
924
- $( '#ctc_copy_theme_mods' ).slideUp( 'fast' );
925
- }
926
- */
927
-
928
  },
929
  set_notice: function( noticearr ) {
930
  var self = this,
@@ -1716,7 +1700,14 @@
1716
 
1717
  };
1718
  $.chldthmanalyze = {
 
 
 
1719
 
 
 
 
 
1720
  show_loading: function( resubmit, text ) {
1721
  var themetype = $.chldthmcfg.existing ? 'child' : 'parnt',
1722
  name = text ? text : $.chldthmcfg.getname( themetype ),
@@ -1729,61 +1720,245 @@
1729
  hide_loading: function() {
1730
  $( '.ctc_analyze_loading' ).fadeTo( 200, 0, function(){ $( this ).slideUp( 200, function() { $( this ).remove(); } ); } );
1731
  },
1732
- /* these are legacy functions required by Pro 2.2.0 */
1733
  setssl: function( url ){
1734
  return url.replace( /^https?/, window.ctcAjax.ssl ? 'https' : 'http' );
1735
  },
1736
- escrgx: function( str ) {
1737
- return str.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
1738
- },
1739
- trmcss: function( str ) {
1740
- //console.log( 'trmcss: ' + str );
1741
- return 'undefined' === typeof str ? '' : str.replace( /\-css$/, '' );
1742
- },
1743
- /* end of legacy functions */
1744
  /**
1745
  * Fetch website home page and parse <head> for linked stylesheets
1746
  * Use this to store dependencies and to mark them to be parsed as "default" stylesheets
1747
  * Detects other signals for configuration heuristics during child theme setup.
 
 
1748
  */
1749
  analyze_theme: function( themetype ) {
1750
  //console.log( 'analyze_theme' );
1751
  var self = this,
1752
- template = $.chldthmcfg.currparnt,
1753
- stylesheet = ( 'child' === themetype ? $.chldthmcfg.currchild : $.chldthmcfg.currparnt );
 
 
 
 
 
1754
 
 
 
 
1755
  //console.log( 'Fetching home page: ' + url );
1756
-
1757
- $.ajax( {
1758
- url: window.ctcAjax.ajaxurl,
1759
- data: {
1760
- action: 'ctc_analyze',
1761
- stylesheet: stylesheet,
1762
- template: template,
1763
- _wpnonce: $( '#_wpnonce' ).val(),
1764
- },
1765
- dataType: 'json',
1766
- type: 'POST'
1767
- } ).done( function( data ) {
1768
- // console.log( data );
1769
- self.analysis[ themetype ] = data;
1770
- $.each( data.dependencies, function( ndx, el ){
1771
- self.dependencies[ ndx ] = el;
1772
- });
1773
  $( document ).trigger( 'analysisdone' );
1774
  } ).fail( function( xhr, status, err ){
 
 
1775
  //console.log( xhr );
1776
- var analysis = {
1777
- 'signals': {
1778
- 'failure': 1,
1779
- 'xhrerr': err
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1780
  }
1781
- };
1782
- self.analysis[ themetype ] = analysis;
1783
- $( document ).trigger( 'analysisdone' );
 
 
 
 
 
 
 
1784
  } );
1785
  },
1786
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1787
  /**
1788
  * Uses analysis data to auto configure form, pass parameters
1789
  * for child theme setup and display results to user.
@@ -1810,18 +1985,18 @@
1810
 
1811
  if ( self.analysis[ themetype ].signals.failure ||
1812
  ( self.analysis[ themetype ].signals.thm_noqueue && !self.phperr[ themetype ].length ) ) {
1813
- if ( $( '#ctc_is_debug' ).is( ':checked' ) ) {
1814
  debugtxt = $.chldthmcfg.getxt( 'anlz33' ).replace(/%1/, '<a href="' + self.analysis[ themetype ].url + '" target="_new">' ).replace( /%2/, '</a>' );
1815
- }
1816
  notice.notices.push( {
1817
  headline: $.chldthmcfg.getxt( 'anlz4', name ),
1818
- msg: $.chldthmcfg.getxt( 'anlz5' ) + debugtxt + ( self.analysis[ themetype ].signals.failure ? self.analysis[ themetype ].signals.xhrerr : '' ),
1819
  style: 'notice-warning'
1820
  } );
1821
  } else {
1822
  // test errors
1823
- if ( self.analysis[ themetype ].errors.length ) {
1824
- $.each( self.analysis[ themetype ].errors, function( index, err ) {
1825
  if ( err.match( /Fatal error/i ) ) {
1826
  errnotice.style = 'error';
1827
  errnotice.headline = $.chldthmcfg.getxt( 'anlz8', name );
@@ -2031,7 +2206,7 @@
2031
  $out.hide().appendTo( '#' + themetype + '_analysis_notice' ).slideDown();
2032
  } );
2033
 
2034
- if ( $( '#ctc_is_debug' ).is( ':checked' ) ) {
2035
  anlz = '<div style="background-color:#ddd;padding:6px">' +
2036
  '<div class="ctc-section-toggle" id="ctc_analysis_obj">' +
2037
  $.chldthmcfg.getxt( 'anlz30' ) +
@@ -2043,7 +2218,7 @@
2043
 
2044
  $( anlz ).appendTo( '#' + themetype + '_analysis_notice' );
2045
 
2046
- }
2047
 
2048
  // v2.1.3 remove stylesheet dependencies
2049
  dep_inputs = '';
@@ -2115,7 +2290,24 @@
2115
  },
2116
  do_analysis: function() {
2117
  var self = this;
2118
- self.analysis = { parnt: {}, child: {} };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2119
  self.phperr = { parnt: [], child: [] };
2120
  self.dependencies = {};
2121
  self.done = 0;
2
  * Script: chldthmcfg.js
3
  * Plugin URI: http://www.childthemeconfigurator.com/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 2.2.3
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
20
  //console.log( 'executing main function' );
21
  escquo: function( str ) {
22
  var self = this;
23
+ return self.is_empty( str ) ? str : str.toString().replace( /"/g, '&quot;' );
24
  },
25
 
26
  getxt: function( key, merge ){
909
  $( '.ctc-analyze-theme, .ctc-analyze-howto' ).show();
910
  $( '#ctc_load_styles' ).val( 'Create New Child Theme' );
911
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  },
913
  set_notice: function( noticearr ) {
914
  var self = this,
1700
 
1701
  };
1702
  $.chldthmanalyze = {
1703
+ escrgx: function( str ) {
1704
+ return str.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
1705
+ },
1706
 
1707
+ trmcss: function( str ) {
1708
+ //console.log( 'trmcss: ' + str );
1709
+ return 'undefined' === typeof str ? '' : str.replace( /\-css$/, '' );
1710
+ },
1711
  show_loading: function( resubmit, text ) {
1712
  var themetype = $.chldthmcfg.existing ? 'child' : 'parnt',
1713
  name = text ? text : $.chldthmcfg.getname( themetype ),
1720
  hide_loading: function() {
1721
  $( '.ctc_analyze_loading' ).fadeTo( 200, 0, function(){ $( this ).slideUp( 200, function() { $( this ).remove(); } ); } );
1722
  },
 
1723
  setssl: function( url ){
1724
  return url.replace( /^https?/, window.ctcAjax.ssl ? 'https' : 'http' );
1725
  },
 
 
 
 
 
 
 
 
1726
  /**
1727
  * Fetch website home page and parse <head> for linked stylesheets
1728
  * Use this to store dependencies and to mark them to be parsed as "default" stylesheets
1729
  * Detects other signals for configuration heuristics during child theme setup.
1730
+ * If the initial ajax get requst fails, attempt request via a WordPress ajax call,
1731
+ * which executes an http request on the server side. If both methods fail, notify user.
1732
  */
1733
  analyze_theme: function( themetype ) {
1734
  //console.log( 'analyze_theme' );
1735
  var self = this,
1736
+ now = Math.floor( $.now() / 1000 ),
1737
+ stylesheet = ( 'child' === themetype ? $.chldthmcfg.currchild : $.chldthmcfg.currparnt ),
1738
+ testparams = '&template=' + $.chldthmcfg.currparnt + '&stylesheet=' + stylesheet + '&now=' + now,
1739
+ homeurl = self.setssl( window.ctcAjax.homeurl ), // window.ctcAjax.homeurl, //
1740
+ url = homeurl + testparams;
1741
+
1742
+ self.analysis[ themetype ].url = url;
1743
 
1744
+ /**
1745
+ * First, try to fetch home page using ajax get
1746
+ */
1747
  //console.log( 'Fetching home page: ' + url );
1748
+ $.get( url, function( data ) {
1749
+ self.parse_page( themetype, data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1750
  $( document ).trigger( 'analysisdone' );
1751
  } ).fail( function( xhr, status, err ){
1752
+ //console.log( status );
1753
+ //console.log( err );
1754
  //console.log( xhr );
1755
+ /**
1756
+ * if this fails due to cross domain or other issue,
1757
+ * try fetching using ajax call that requests page on server side.
1758
+ */
1759
+ self.analysis[ themetype ].signals.xhrgeterr = err;
1760
+ $.ajax( {
1761
+ url: window.ctcAjax.ajaxurl,
1762
+ data: {
1763
+ action: 'ctc_analyze',
1764
+ stylesheet: stylesheet,
1765
+ template: $.chldthmcfg.currparnt,
1766
+ _wpnonce: $( '#_wpnonce' ).val(),
1767
+ },
1768
+ dataType: 'json',
1769
+ type: 'POST'
1770
+ } ).done( function( data ) {
1771
+ if ( data.signals.httperr ) {
1772
+ /**
1773
+ * if both methods fail, there is a problem.
1774
+ */
1775
+ self.analysis[ themetype ].signals.failure = 1;
1776
+ self.analysis[ themetype ].signals.httperr = data.signals.httperr;
1777
+ } else {
1778
+ self.parse_page( themetype, data.body );
1779
  }
1780
+ $( document ).trigger( 'analysisdone' );
1781
+ } ).fail( function( xhr, status, err ){
1782
+ /**
1783
+ * if xhr fails both times there is a bigger problem.
1784
+ */
1785
+ //console.log( xhr );
1786
+ self.analysis[ themetype ].signals.failure = 1;
1787
+ self.analysis[ themetype ].signals.xhrajaxerr = err;
1788
+ $( document ).trigger( 'analysisdone' );
1789
+ } );
1790
  } );
1791
  },
1792
+ parse_page: function( themetype, body ){
1793
+
1794
+ var self = this,
1795
+ themepath = window.ctcAjax.theme_uri.replace( /^https?:\/\//, '' ),
1796
+ stylesheet = ( 'child' === themetype ? $.chldthmcfg.currchild : $.chldthmcfg.currparnt ),
1797
+ escaped = self.escrgx( $.chldthmcfg.currparnt ) + ( 'child' === themetype ? '|' + self.escrgx( stylesheet ) : '' ),
1798
+ regex_link = new RegExp( "<link( rel=[\"']stylesheet[\"'] id=['\"]([^'\"]+?)['\"])?[^>]+?" +
1799
+ self.escrgx( themepath ) + '/(' + escaped + ')/([^"\']+\\.css)(\\?[^"\']+)?["\'][^>]+>', 'gi' ),
1800
+ regex_err = /<br \/>\n[^\n]+?(fatal|strict|notice|warning|error)[\s\S]+?<br \/>/gi,
1801
+ themeloaded = 0, // flag when style.css link is detected
1802
+ testloaded = 0, // flag when test link is detected
1803
+ msg,
1804
+ queue,
1805
+ csslink;
1806
+
1807
+ if ( 'child' === themetype ) {
1808
+ //console.log( body );
1809
+ }
1810
+ // retrieve enqueued stylesheet ids
1811
+ if ( ( queue = body.match( /BEGIN WP QUEUE\n([\s\S]*?)\nEND WP QUEUE/ ) ) ) {
1812
+ self.analysis[ themetype ].queue = queue[ 1 ].split(/\n/);
1813
+ //console.log( 'QUEUE:' );
1814
+ //console.log( self.analysis[ themetype ].queue );
1815
+ } else {
1816
+ self.analysis[ themetype ].queue = [];
1817
+ self.analysis[ themetype ].signals.thm_noqueue = 1;
1818
+ //self.analysis[ themetype ].signals.failure = 1;
1819
+ //console.log( 'NO QUEUE' );
1820
+ }
1821
+ if ( ( queue = body.match( /BEGIN CTC IRREGULAR\n([\s\S]*?)\nEND CTC IRREGULAR/ ) ) ) {
1822
+ self.analysis[ themetype ].irreg = queue[ 1 ].split(/\n/);
1823
+ } else {
1824
+ self.analysis[ themetype ].irreg = [];
1825
+ }
1826
+ if ( body.match( /CHLD_THM_CFG_IGNORE_PARENT/ ) ) {
1827
+ self.analysis[ themetype ].signals.thm_ignoreparnt = 1;
1828
+ //console.log( 'thm_ignoreparnt' );
1829
+ }
1830
+ if ( body.match( /IS_CTC_THEME/ ) ) {
1831
+ self.analysis[ themetype ].signals.thm_is_ctc = 1;
1832
+ //console.log( 'thm_is_ctc' );
1833
+ }
1834
+
1835
+ if ( body.match( /NO_CTC_STYLES/ ) ) {
1836
+ self.analysis[ themetype ].signals.thm_no_styles = 1;
1837
+ //console.log( 'thm_no_styles' );
1838
+ }
1839
+ if ( body.match( /HAS_CTC_IMPORT/ ) ) {
1840
+ self.analysis[ themetype ].signals.thm_has_import = 1;
1841
+ //console.log( 'thm_has_import' );
1842
+ }
1843
+
1844
+ // remove comments to avoid flagging conditional stylesheets ( IE compatability, etc. )
1845
+ body = body.replace( /<!\-\-[\s\S]*?\-\->/g, '' );
1846
+ //console.log( 'PARSE:' );
1847
+ while ( ( msg = regex_err.exec( body ) ) ) {
1848
+ var errstr = msg[ 0 ].replace( /<.*?>/g, '' );
1849
+ self.phperr[ themetype ].push( errstr );
1850
+ self.analysis[ themetype ].signals.err_php = 1;
1851
+ if ( errstr.match( /Fatal error/i ) ) {
1852
+ self.analysis[ themetype ].signals.err_fatal = 1;
1853
+ }
1854
+ //else if ( errstr.match( /(FileNotFoundException|Failed opening|failed to open stream)/i ) ) {
1855
+ //analysis.signals.err_fnf = 1;
1856
+ //}
1857
+ }
1858
+ while ( ( csslink = regex_link.exec( body ) ) ) {
1859
+ var stylesheetid = self.trmcss( csslink[ 2 ] ),
1860
+ stylesheettheme = csslink[ 3 ],
1861
+ stylesheetpath = csslink[ 4 ],
1862
+ linktheme = $.chldthmcfg.currparnt === stylesheettheme ? 'parnt' : 'child',
1863
+ noid = 0;
1864
+ //console.log( 'stylesheetid: ' + stylesheetid + ' stylesheetpath: ' + stylesheetpath );
1865
+ // flag stylesheet links that have no id or are not in wp_styles
1866
+ if ( '' === stylesheetid || -1 === $.inArray( stylesheetid, self.analysis[ themetype ].queue ) ) {
1867
+ noid = 1;
1868
+ //console.log( 'no id for ' + stylesheetpath + '!' );
1869
+ } else if ( 0 === stylesheetid.indexOf( 'chld_thm_cfg' ) ) { // handle ctc-generated links
1870
+ // console.log( 'ctc link detected: ' + stylesheetid + ' themeloaded: ' + themeloaded );
1871
+ if ( stylesheetpath.match( /^ctc\-style([\-\.]min)?\.css$/ ) ) {
1872
+ //console.log( 'separate stylesheet detected' );
1873
+ themeloaded = 1;
1874
+ self.analysis[ themetype ].signals.ctc_sep_loaded = 1; // flag that separate stylesheet has been detected
1875
+ } else if ( stylesheetpath.match( /^ctc\-genesis([\-\.]min)?\.css$/ ) ) {
1876
+ //console.log( 'genesis stylesheet detected' );
1877
+ themeloaded = 1;
1878
+ self.analysis[ themetype ].signals.ctc_gen_loaded = 1; // flag that genesis "parent" has been detected
1879
+ } else if ( stylesheetid.match( /$chld_thm_cfg_ext/ ) ) {
1880
+ self.analysis[ themetype ].signals.ctc_ext_loaded = 1; // flag that external stylesheet link detected
1881
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ stylesheetid, stylesheetpath ] );
1882
+ } else if ( 'chld_thm_cfg_child' === stylesheetid ) {
1883
+ self.analysis[ themetype ].signals.ctc_child_loaded = 1; // flag that ctc child stylesheet link detected
1884
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ stylesheetid, stylesheetpath ] );
1885
+ } else if ( 'chld_thm_cfg_parent' === stylesheetid ) {
1886
+ self.analysis[ themetype ].signals.ctc_parnt_loaded = 1; // flag that ctc parent stylesheet link detected
1887
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ stylesheetid, stylesheetpath ] );
1888
+ if ( themeloaded ){
1889
+ //console.log( 'parent link out of sequence' );
1890
+ self.analysis[ themetype ].signals.ctc_parnt_reorder = 1; // flag that ctc parent stylesheet link out of order
1891
+ }
1892
+ }
1893
+ continue;
1894
+ }
1895
+ // flag main theme stylesheet link
1896
+ if ( stylesheetpath.match( /^style([\-\.]min)?\.css$/ ) ) {
1897
+ //console.log( linktheme + ' theme stylesheet detected: ' + stylesheettheme + '/' + stylesheetpath );
1898
+ themeloaded = 1; // flag that main theme stylesheet has been detected
1899
+ // if main theme stylesheet link has no id then it is unregistered ( hard-wired )
1900
+ if ( 'parnt' === linktheme ) {
1901
+ if ( noid ) {
1902
+ self.analysis[ themetype ].signals.thm_parnt_loaded = 'thm_unregistered';
1903
+ } else {
1904
+ self.analysis[ themetype ].signals.thm_parnt_loaded = stylesheetid;
1905
+ // check that parent stylesheet is loaded before child stylesheet
1906
+ if ( 'child' === themetype && self.analysis[ themetype ].signals.thm_child_loaded ) {
1907
+ self.analysis[ themetype ].signals.ctc_parnt_reorder = 1;
1908
+ }
1909
+ }
1910
+ } else {
1911
+ self.analysis[ themetype ].signals.thm_child_loaded = noid ? 'thm_unregistered' : stylesheetid;
1912
+ }
1913
+ if ( noid ) {
1914
+ if ( testloaded ) {
1915
+ self.analysis[ themetype ].signals.thm_past_wphead = 1;
1916
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ 'thm_past_wphead', stylesheetpath ] );
1917
+ //console.log( 'Unreachable theme stylesheet detected' );
1918
+ } else {
1919
+ self.analysis[ themetype ].signals.thm_unregistered = 1;
1920
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ 'thm_unregistered', stylesheetpath ] );
1921
+ //console.log( 'Unregistered theme stylesheet detected' );
1922
+ }
1923
+ } else {
1924
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ stylesheetid, stylesheetpath ] );
1925
+ //console.log( 'Theme stylesheet OK!' );
1926
+ }
1927
+
1928
+ } else if ( 'ctc-test.css' === stylesheetpath ) { // flag test stylesheet link
1929
+ //console.log( 'end of queue reached' );
1930
+ testloaded = 1; // flag that test queue has been detected ( end of wp_head )
1931
+ } else {
1932
+ var err = null;
1933
+ // if stylesheet link has id and loads before main theme stylesheet, add it as a dependency
1934
+ // otherwise add it as a parse option
1935
+ if ( noid ) {
1936
+ err = 'dep_unregistered';
1937
+ }
1938
+ if ( testloaded ) {
1939
+ if ( themeloaded ) {
1940
+ //console.log( 'Unreachable stylesheet detected!' + stylesheetpath );
1941
+ err = 'css_past_wphead';
1942
+ } else {
1943
+ err = 'dep_past_wphead';
1944
+ }
1945
+ }
1946
+ // Flag stylesheet links that have no id and are loaded after main theme stylesheet.
1947
+ // This indicates loading outside of wp_head()
1948
+ if ( err ) {
1949
+ self.analysis[ themetype ].signals[ err ] = 1;
1950
+ stylesheetid = err;
1951
+ } else {
1952
+ self.dependencies[ stylesheetid ] = stylesheetpath;
1953
+ }
1954
+ self.analysis[ themetype ].deps[ themeloaded ].push( [ stylesheetid, stylesheetpath ] );
1955
+ }
1956
+ }
1957
+ if ( ! themeloaded ){
1958
+ self.analysis[ themetype ].signals.thm_notheme = 1; // flag that no theme stylesheet has been detected
1959
+ }
1960
+ },
1961
+
1962
  /**
1963
  * Uses analysis data to auto configure form, pass parameters
1964
  * for child theme setup and display results to user.
1985
 
1986
  if ( self.analysis[ themetype ].signals.failure ||
1987
  ( self.analysis[ themetype ].signals.thm_noqueue && !self.phperr[ themetype ].length ) ) {
1988
+ //if ( $( '#ctc_is_debug' ).is( ':checked' ) ) {
1989
  debugtxt = $.chldthmcfg.getxt( 'anlz33' ).replace(/%1/, '<a href="' + self.analysis[ themetype ].url + '" target="_new">' ).replace( /%2/, '</a>' );
1990
+ //}
1991
  notice.notices.push( {
1992
  headline: $.chldthmcfg.getxt( 'anlz4', name ),
1993
+ msg: $.chldthmcfg.getxt( 'anlz5' ) + debugtxt,
1994
  style: 'notice-warning'
1995
  } );
1996
  } else {
1997
  // test errors
1998
+ if ( self.phperr[ themetype ].length ) {
1999
+ $.each( self.phperr[ themetype ], function( index, err ) {
2000
  if ( err.match( /Fatal error/i ) ) {
2001
  errnotice.style = 'error';
2002
  errnotice.headline = $.chldthmcfg.getxt( 'anlz8', name );
2206
  $out.hide().appendTo( '#' + themetype + '_analysis_notice' ).slideDown();
2207
  } );
2208
 
2209
+ //if ( $( '#ctc_is_debug' ).is( ':checked' ) ) {
2210
  anlz = '<div style="background-color:#ddd;padding:6px">' +
2211
  '<div class="ctc-section-toggle" id="ctc_analysis_obj">' +
2212
  $.chldthmcfg.getxt( 'anlz30' ) +
2218
 
2219
  $( anlz ).appendTo( '#' + themetype + '_analysis_notice' );
2220
 
2221
+ //}
2222
 
2223
  // v2.1.3 remove stylesheet dependencies
2224
  dep_inputs = '';
2290
  },
2291
  do_analysis: function() {
2292
  var self = this;
2293
+ self.analysis = {
2294
+ parnt: {
2295
+ deps: [[],[]],
2296
+ signals: {
2297
+ failure: 0
2298
+ },
2299
+ queue: [],
2300
+ irreg: []
2301
+ },
2302
+ child: {
2303
+ deps: [[],[]],
2304
+ signals: {
2305
+ failure: 0
2306
+ },
2307
+ queue: [],
2308
+ irreg: []
2309
+ }
2310
+ };
2311
  self.phperr = { parnt: [], child: [] };
2312
  self.dependencies = {};
2313
  self.done = 0;
js/chldthmcfg.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e){"use strict";e.chldthmcfg={escquo:function(e){var t=this;return t.is_empty(e)?e:e.toString().replace(/"/g,'"')},getxt:function(e,t){var c=window.ctcAjax[e+"_txt"];return c?(t&&(c=c.replace(/%s/,t)),c):""},getname:function(t){var c="child"===t?e.chldthmcfg.currchild:e.chldthmcfg.currparnt;return window.ctcAjax.themes[t][c].Name},frascii:function(e){var t=parseInt(e),c=String.fromCharCode(t);return c},toascii:function(e){var t=e.charCodeAt(0);return t},is_empty:function(e,t){if("undefined"==typeof e||!1===e||null===e||""===e)return!0;if("undefined"!=typeof t&&"0"===e||0===e)return!0;if(!0===e||"string"==typeof e||"number"==typeof e)return!1;if("object"==typeof e){for(var c in e)if(e.hasOwnProperty(c))return!1;return!0}return!1},theme_exists:function(t,c){var n=!1;return e.each(window.ctcAjax.themes,function(i,a){return e.each(a,function(e,a){return a=null,e.toLowerCase()!==t.toLowerCase()||"parnt"!==i&&"new"!==c?void 0:(n=!0,!1)}),n?!1:void 0}),n},validate:function(){var t=this,c=/[^\w\-]/,n=e("#ctc_child_template").length?e("#ctc_child_template").val().toString().replace(c):"",i=e("#ctc_theme_child").length?e("#ctc_theme_child").val().toString().replace(c):n,a=e("input[name=ctc_child_type]:checked").val(),s=[];return"new"===a&&(i=n),t.theme_exists(i,a)&&s.push(t.getxt("theme_exists").toString().replace(/%s/,i)),t.is_empty(i)&&s.push(t.getxt("inval_theme")),s.length?(t.set_notice({error:s}),!1):"reset"===a?!!confirm(t.getxt("load")):!0},autogen_slugs:function(){if(e("#ctc_theme_parnt").length){for(var t=this,c=e("#ctc_theme_parnt").val(),n=e("#ctc_theme_child").length?e("#ctc_theme_child").val():"",i=""!==n&&e("#ctc_child_type_duplicate").is(":checked")?n:c+"-child",a=i,s=""!==n&&e("#ctc_child_type_duplicate").is(":checked")?e.chldthmcfg.getname("child"):e.chldthmcfg.getname("parnt")+" Child",l="",r="",o="00";t.theme_exists(a,"new");)l=t.is_empty(l)?2:l+1,r=o.substring(0,o.length-l.toString().length)+l.toString(),a=i+r;t.testslug=a,t.testname=s+(r.length?" "+r:"")}},focus_panel:function(t){var c=t+"_panel";e(".nav-tab").removeClass("nav-tab-active"),e(".ctc-option-panel").removeClass("ctc-option-panel-active"),e(t).addClass("nav-tab-active"),e(".ctc-option-panel-container").scrollTop(0),e(c).addClass("ctc-option-panel-active")},selector_input_toggle:function(t){var c,n=this;e("#ctc_rewrite_selector").length?(c=e("#ctc_rewrite_selector_orig").val(),e("#ctc_sel_ovrd_selector_selected").text(c),e(t).text(n.getxt("rename"))):(c=e("#ctc_sel_ovrd_selector_selected").text(),e("#ctc_sel_ovrd_selector_selected").html('<textarea id="ctc_rewrite_selector" name="ctc_rewrite_selector" autocomplete="off"></textarea><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'+n.escquo(c)+'"/>'),e("#ctc_rewrite_selector").val(c),e(t).text(n.getxt("cancel")))},coalesce_inputs:function(t){var c=this,n=e(t).attr("id"),i=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+?)(_(\d+))?)(_\w+)?$/,a=e(t).parents(".ctc-selector-row, .ctc-parent-row").first(),s=a.find(".ctc-swatch").first(),l={parent:{},child:{}},r={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},o={child:!1,parent:!1},_={};return a.find(".ctc-parent-value, .ctc-child-value").each(function(){var t,a,s=e(this).attr("id"),d=s.toString().match(i),u=d[2],h=d[3],p="undefined"==typeof d[4]?"":d[4],m=d[7],g=d[5],f="undefined"==typeof d[7]?"":d[8],v="parent"===h?e(this).text().replace(/!$/,""):"seq"!==p&&"ctc_delete_query_selector"===n?"":e(this).val(),y="seq"===p?!1:"ctc_"+u+"_child_"+p+"_i_"+g+"_"+m;if("child"===h&&(c.is_empty(e(this).data("color"))||(v=c.color_text(e(this).data("color")),e(this).data("color",null)),_[s]=v,y&&(_[y]=e("#"+y).is(":checked")?1:0)),""!==v)if(c.is_empty(f))if(t=p.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!v.match(/none/)){var w=new RegExp(c.border_regx+c.color_regx,"i");a=v.toString().match(w),c.is_empty(a)||(a.shift(),l[h][p+"-width"]=a.shift()||"",a.shift(),l[h][p+"-style"]=a.shift()||"",l[h][p+"-color"]=a.shift()||"")}else if("background-image"!==p||v.match(/none/))"seq"!==p&&(l[h][p]=v);else if(v.toString().match(/url\(/))l[h]["background-image"]=c.image_url(h,v);else{var x=new RegExp(c.grad_regx+c.color_regx+c.color_regx,"i");a=v.toString().match(x),!c.is_empty(a)&&a.length>2?(a.shift(),r[h].origin=a.shift()||"top",r[h].start=a.shift()||"transparent",r[h].end=a.shift()||"transparent",o[h]=!0):l[h]["background-image"]=v}else switch(f){case"_border_width":l[h][p+"-width"]="none"===v?0:v;break;case"_border_style":l[h][p+"-style"]=v;break;case"_border_color":l[h][p+"-color"]=v;break;case"_background_url":l[h]["background-image"]=c.image_url(h,v);break;case"_background_color":l[h]["background-color"]=v;break;case"_background_color1":r[h].start=v,o[h]=!0;break;case"_background_color2":r[h].end=v,o[h]=!0;break;case"_background_origin":r[h].origin=v,o[h]=!0}}),"undefined"==typeof s||c.is_empty(s.attr("id"))||(s.removeAttr("style"),o.parent&&s.ctcgrad(r.parent.origin,[r.parent.start,r.parent.end]),s.css(l.parent),s.attr("id").toString().match(/parent/)||(o.child&&s.ctcgrad(r.child.origin,[r.child.start,r.child.end]),s.css(l.child)),s.css({"z-index":-1})),_},decode_value:function(e,t){t="undefined"==typeof t?"":t;var c,n=this,i={orig:t,names:[""],values:[t]};if(e.toString().match(/^border(\-(top|right|bottom|left))?$/)){var a,s=new RegExp(n.border_regx+"("+n.color_regx+")?","i");c=t.toString().match(s),n.is_empty(c)&&(c=[]),i.names=["_border_width","_border_style","_border_color"],a=c.shift(),i.values[0]=c.shift()||"",c.shift(),i.values[1]=c.shift()||"",c.shift(),i.values[2]=c.shift()||""}else if(e.toString().match(/^background\-image/))if(i.names=["_background_url","_background_origin","_background_color1","_background_color2"],i.values=["","","",""],n.is_empty(t)||t.toString().match(/(url|none)/))i.values[0]=t;else{var l,r;c=t.toString().split(/:/),i.values[1]=c.shift()||"",i.values[2]=c.shift()||"",l=c.shift()||"",i.values[3]=c.shift()||"",r=c.shift()||"",i.orig=[i.values[1],i.values[2],i.values[3]].join(" ")}return i},image_url:function(e,t){var c,n=this,i=t.toString().match(/url\(['" ]*(.+?)['" ]*\)/),a=n.is_empty(i)?null:i[1],s=window.ctcAjax.theme_uri+"/"+("parent"===e?window.ctcAjax.parnt:window.ctcAjax.child)+"/";return a?c=a.toString().match(/^(data:|https?:|\/)/)?t:"url("+s+a+")":!1},setup_menus:function(){var e=this;e.setup_query_menu(),e.setup_selector_menu(),e.setup_rule_menu(),e.setup_new_rule_menu(),e.load_queries(),e.load_rules(),e.set_query(e.currquery)},load_queries:function(){var e=this;e.query_css("queries",null)},load_selectors:function(){var e=this;e.query_css("selectors",e.currquery)},load_rules:function(){var e=this;e.query_css("rules",null)},load_selector_values:function(){var e=this;e.query_css("qsid",e.currqsid)},get_queries:function(t,c){var n=[],i=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){i.test(t)&&n.push({label:t,value:t})}),c(n)},get_selectors:function(t,c){var n=[],i=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){i.test(e)&&n.push({label:e,value:t})}),c(n)},get_rules:function(t,c){var n=[],i=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){i.test(e)&&n.push({label:e,value:t})}),c(n)},get_filtered_rules:function(t,c){var n=[],i=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.each(e("#ctc_rule_menu").data("menu"),function(e,t){i.test(e)&&n.push({label:e,value:t})}),c(n)},merge_ruleval_arrays:function(t,c,n){var i=this,a={},s=n?c.child.pop():null;return e.each(["parnt","child"],function(t,l){i.is_empty(c[l])||e.each(c[l],function(e,t){n?parseInt(t[2])>=parseInt(s[2])&&(s[2]=parseInt(t[2])+1):(i.is_empty(a[t[2]])&&(a[t[2]]={}),a[t[2]][l]=t)})}),n&&(a[s[2]]={parnt:[],child:s}),a},input_row:function(t,c,n,i,a){var s=this,l="";if(!s.is_empty(i)&&!s.is_empty(i.value)&&!s.is_empty(i.value[c])){var r=i.value[c],o=s.merge_ruleval_arrays(c,r,a);e.each(o,function(a,r){var o=s.decode_value(c,s.is_empty(r.parnt)?"":r.parnt[0]),_=s.is_empty(r.parnt)||s.is_empty(r.parnt[1],1)?0:1,d=s.decode_value(c,s.is_empty(r.child)?"":r.child[0]),u=s.is_empty(r.child)||s.is_empty(r.child[1],1)?0:1;if(l+='<div class="ctc-'+("ovrd"===n?"input":"selector")+'-row clearfix"><div class="ctc-input-cell">',l+="ovrd"===n?c.replace(/\d+/g,s.frascii):i.selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+t+'" >'+s.getxt("edit")+"</a> "+(s.is_empty(o.orig)?s.getxt("child_only"):""),l+='</div><div class="ctc-parent-value ctc-input-cell"'+("ovrd"!==n?' style="display:none"':"")+' id="ctc_'+n+"_parent_"+c+"_"+t+"_"+a+'">'+(s.is_empty(o.orig)?"[no value]":o.orig+(_?s.getxt("important"):""))+'</div><div class="ctc-input-cell">',!s.is_empty(o.names)){e.each(o.names,function(e,i){i=s.is_empty(i)?"":i,l+='<div class="ctc-child-input-cell ctc-clear">';var r,o="ctc_"+n+"_child_"+c+"_"+t+"_"+a+i;!1===(r=d.values.shift())&&(r=""),l+=(s.is_empty(i)?"":s.getxt(i)+":<br/>")+'<input type="text" id="'+o+'" name="'+o+'" class="ctc-child-value'+((i+c).toString().match(/color/)?" color-picker":"")+(i.toString().match(/url/)?" ctc-input-wide":"")+'" value="'+s.escquo(r)+'" /></div>'});var h="ctc_"+n+"_child_"+c+"_i_"+t+"_"+a;l+='<label for="'+h+'"><input type="checkbox" id="'+h+'" name="'+h+'" value="1" '+(u?"checked":"")+" />"+s.getxt("important")+"</label>"}l+="</div>","ovrd"!==n&&(l+='<div class="ctc-swatch ctc-specific" id="ctc_child_'+c+"_"+t+"_"+a+'_swatch">'+s.getxt("swatch")+'</div><div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+c+"_"+t+"_"+a+'_cell"><input type="button" class="button ctc-save-input" id="ctc_save_'+c+"_"+t+"_"+a+'" name="ctc_save_'+c+"_"+t+"_"+a+'" value="Save" /></div>'),l+="</div><!-- end input row -->\n"})}return l},scrolltop:function(){e("html, body, .ctc-option-panel-container").animate({scrollTop:0})},css_preview:function(e){var t=this;(e=e.match(/(child|parnt)/)[1])||(e="child"),t.query_css("preview",e)},setup_iris:function(e){var t=this;t.setup_spectrum(e)},setup_spectrum:function(t){var c=this,n=!c.is_empty(window.ctcAjax.palette);try{e(t).spectrum({showInput:!0,allowEmpty:!0,showAlpha:!0,showInitial:!0,preferredFormat:"hex",clickoutFiresChange:!0,move:function(n){e(t).data("color",n),c.coalesce_inputs(t)},showPalette:!!n,showSelectionPalette:!!n,palette:[],maxSelectionSize:36,localStorageKey:"ctc-palette."+window.ctcAjax.child,hideAfterPaletteSelect:!0}).on("change",function(){c.coalesce_inputs(this)}).on("keyup",function(){var t=this,n=c.addhash(e(this).val());e(t).val(n),clearTimeout(e(this).data("spectrumTimer")),e(this).data("spectrumTimer",setTimeout(function(){c.coalesce_inputs(t),e(t).spectrum("set",n)},500))})}catch(i){c.jquery_exception(i,"Spectrum Color Picker")}},addhash:function(e){return e.replace(/^#?([a-f0-9]{3,6}.*)/,"#$1")},color_text:function(e){var t=this;return t.is_empty(e)?"":e.getAlpha()<1?e.toRgbString():e.toHexString()},setup_query_menu:function(){var t=this;try{e("#ctc_sel_ovrd_query").autocomplete({source:t.get_queries,minLength:0,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_query(c.item.value),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Query Menu")}},setup_selector_menu:function(){var t=this;try{e("#ctc_sel_ovrd_selector").autocomplete({source:t.get_selectors,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_selector(c.item.value,c.item.label),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Selector Menu")}},setup_rule_menu:function(){var t=this;try{e("#ctc_rule_menu").autocomplete({source:t.get_rules,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_rule(c.item.value,c.item.label),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Property Menu")}},setup_new_rule_menu:function(){var t=this;try{e("#ctc_new_rule_menu").autocomplete({source:t.get_filtered_rules,selectFirst:!0,autoFocus:!0,select:function(c,n){c.preventDefault();var i,a,s=n.item.label.replace(/[^\w\-]/g,t.toascii);return t.is_empty(t.currdata.value)&&(t.currdata.value={}),t.is_empty(t.currdata.value[n.item.label])&&(t.currdata.value[n.item.label]={}),t.is_empty(t.currdata.value[n.item.label].child)&&(t.currdata.value[n.item.label].child=[]),t.currdata.value[n.item.label].child.push(["",0,1,1]),i=e(t.input_row(t.currqsid,s,"ovrd",t.currdata,!0)),e("#ctc_sel_ovrd_rule_inputs").append(i),e("#ctc_new_rule_menu").val(""),i.find('input[type="text"]').each(function(c,n){a||(a=n),e(n).hasClass("color-picker")&&t.setup_spectrum(n)}),a&&e(a).focus(),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"New Property Menu")}},set_theme_params:function(t,c){e("#ctc_child_author").val(window.ctcAjax.themes[t][c].Author),e("#ctc_child_version").val(window.ctcAjax.themes[t][c].Version),e("#ctc_child_authoruri").val(window.ctcAjax.themes[t][c].AuthorURI),e("#ctc_child_themeuri").val(window.ctcAjax.themes[t][c].ThemeURI),e("#ctc_child_descr").val(window.ctcAjax.themes[t][c].Descr),e("#ctc_child_tags").val(window.ctcAjax.themes[t][c].Tags)},update_form:function(){var t,c=this;e("#input_row_stylesheet_handling_container,#input_row_parent_handling_container,#ctc_additional_css_files_container,#input_row_new_theme_slug,#input_row_duplicate_theme_slug,#ctc_copy_theme_mods,#ctc_child_header_parameters,#ctc_configure_submit,#input_row_theme_slug").slideUp("fast"),e("#ctc_configure_submit .ctc-step").text("9"),e("#ctc_theme_child").length&&!e("#ctc_child_type_new").is(":checked")?(t=e("#ctc_theme_child").val(),c.existing=1,c.currparnt=window.ctcAjax.themes.child[t].Template,c.autogen_slugs(),e("#ctc_theme_parnt").val(c.currparnt),e("#ctc_theme_parnt-button .ui-selectmenu-text").text(c.getname("parnt")),c.set_theme_params("child",t),e("#ctc_child_type_duplicate").is(":checked")?(e("#ctc_child_template").val(c.testslug),e("#ctc_child_name").val(c.testname),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_load_styles").val("Duplicate Child Theme")):e("#ctc_child_type_reset").is(":checked")?(e("#ctc_configure_submit .ctc-step").text("3"),e("#ctc_configure_submit").slideDown("fast"),e("#theme_slug_container").text(t),e(".ctc-analyze-theme, .ctc-analyze-howto").hide(),e("#ctc_enqueue_none").prop("checked",!0),e("#ctc_load_styles").val("Reset Child Theme to Previous State")):(e("#ctc_child_template").val(""),e("#theme_slug_container").text(t),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_child_name").val(c.getname("child")),e("#ctc_load_styles").val("Configure Child Theme")),e("#input_row_existing_theme_option").slideDown("fast"),e("#input_row_new_theme_option").slideUp("fast")):(c.existing=0,c.autogen_slugs(),e("#ctc_theme_parnt").val(c.currparnt),e("#ctc_theme_parnt-button .ui-selectmenu-text").text(e.chldthmcfg.getname("parnt")),c.set_theme_params("parnt",c.currparnt),e("#input_row_existing_theme_option,#input_row_duplicate_theme_container,#input_row_theme_slug").slideUp("fast"),e("#input_row_new_theme_option").slideDown("fast"),e("#ctc_child_name").val(c.testname),e("#ctc_child_template").val(c.testslug),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_load_styles").val("Create New Child Theme"))},set_notice:function(t){var c,n=this,i="";n.is_empty(t)||e.each(t,function(t,c){i+='<div class="'+t+' notice is-dismissible dashicons-before"><ul>\n',e(c).each(function(e,t){i+="<li>"+t.toString()+"</li>\n"}),i+="</ul></div>"}),c=e(i),e("#ctc_error_notice").html(c),n.bind_dismiss(c),e("html, body").animate({scrollTop:0},"slow")},set_parent_menu:function(e){var t=this;t.currparnt=e.value,t.update_form()},set_child_menu:function(e){var t=this;t.currchild=e.value,t.update_form()},set_query:function(t){var c=this;return c.is_empty(t)?!1:(c.currquery=t,e("#ctc_sel_ovrd_query").val(""),e("#ctc_sel_ovrd_query_selected").text(t),e("#ctc_sel_ovrd_selector").val(""),e("#ctc_sel_ovrd_selector_selected").html("&nbsp;"),c.load_selectors(),void c.scrolltop())},set_selector:function(t,c){var n=this;return c=null,n.is_empty(t)?!1:(e("#ctc_sel_ovrd_selector").val(""),n.currqsid=t,n.reload=!1,n.load_selector_values(),void n.scrolltop())},set_rule:function(t,c){var n=this;return n.is_empty(t)?!1:(e("#ctc_rule_menu").val(""),e("#ctc_rule_menu_selected").text(c),e(".ctc-rewrite-toggle").text(n.getxt("rename")),e("#ctc_rule_value_inputs, #ctc_input_row_rule_header").show(),n.query_css("rule_val",t),void n.scrolltop())},set_qsid:function(t){var c=this;c.currqsid=e(t).attr("id").match(/_(\d+)$/)[1],c.focus_panel("#query_selector_options"),c.reload=!0,c.load_selector_values()},query_css:function(t,c,n){var i=this,a={ctc_query_obj:t,ctc_query_key:c},s="#ctc_status_"+t+("val_qry"===t?"_"+c:"");"object"==typeof n&&e.each(n,function(e,t){a["ctc_query_"+e]=t}),e(".query-icon,.ctc-status-icon").remove(),e(s+" .ctc-status-icon").remove(),e(s).append('<span class="ctc-status-icon spinner is-active query-icon"></span>'),a.action=i.is_empty(e("#ctc_action").val())||"plugin"!==e("#ctc_action").val()?"ctc_query":"ctc_plgqry",a._wpnonce=e("#_wpnonce").val(),i.ajax_post(t,a)},save:function(t){var c,n,i,a,s,l=this,r={},o=e(t).attr("id");e(t).prop("disabled",!0),e(".ctc-query-icon,.ctc-status-icon").remove(),e(t).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner save-icon"></span>'),o.match(/ctc_configtype/)?(e(t).parents(".ctc-input-row").first().append('<span class="ctc-status-icon spinner save-icon"></span>'),r.ctc_configtype=e(t).val()):(c=e("#ctc_new_selectors"))&&"ctc_save_new_selectors"===e(t).attr("id")?(r.ctc_new_selectors=c.val(),(n=e("#ctc_sel_ovrd_query_selected"))&&(r.ctc_sel_ovrd_query=n.text()),l.reload=!0):(i=e("#ctc_child_imports"))&&"ctc_save_imports"===o?r.ctc_child_imports=i.val():"ctc_is_debug"===o?r.ctc_is_debug=e("#ctc_is_debug").is(":checked")?1:0:r=l.coalesce_inputs(t),e(".save-icon").addClass("is-active"),e("#ctc_sel_ovrd_selector_selected").find("#ctc_rewrite_selector").each(function(){a=e("#ctc_rewrite_selector").val(),s=e("#ctc_rewrite_selector_orig").val(),l.is_empty(a)||!a.toString().match(/\w/)?a=s:(r.ctc_rewrite_selector=a,l.reload=!0),e(".ctc-rewrite-toggle").text(l.getxt("rename")),e("#ctc_sel_ovrd_selector_selected").html(a)}),r.action=l.is_empty(e("#ctc_action").val())||"plugin"!==e("#ctc_action").val()?"ctc_update":"ctc_plugin",r._wpnonce=e("#_wpnonce").val(),l.ajax_post("qsid",r)},ajax_post:function(t,c,n){var i=this;e.ajax({url:window.ctcAjax.ajaxurl,data:c,dataType:i.is_empty(n)?"json":n,type:"POST"}).done(function(e){i.handle_success(t,e)}).fail(function(){i.handle_failure(t)}).always(function(){i.jqueryerr.length&&i.jquery_notice()})},handle_failure:function(t){var c=this;e(".query-icon, .save-icon").removeClass("spinner").addClass("failure"),e("input[type=submit], input[type=button], input[type=checkbox],.ctc-delete-input").prop("disabled",!1),e(".ajax-pending").removeClass("ajax-pending"),"preview"===t&&e("#view_parnt_options_panel,#view_child_options_panel").text(c.getxt("css_fail"))},handle_success:function(t,c){var n=this;e(".query-icon, .save-icon").removeClass("spinner"),e(".ajax-pending").removeClass("ajax-pending"),n.is_empty(c)?n.handle_failure(t):(e("#ctc_new_selectors").val(""),e(".query-icon, .save-icon").addClass("success"),e("input[type=submit], input[type=button], input[type=checkbox],.ctc-delete-input").prop("disabled",!1),e(c).each(function(){"function"==typeof n.update[this.obj]&&n.update[this.obj].call(n,this)}))},jquery_exception:function(e,t){var c=this,n=c.is_empty(e.lineNumber)?"":" line: "+e.lineNumber,i=c.is_empty(e.fileName)?"":" "+e.fileName.split(/\?/)[0];c.jqueryerr.push("<code><small>"+t+": "+e.message+i+n+"</small></code>")},jquery_notice:function(t){t=null;var c=this,n=[],i=[];c.jqueryerr.length&&(e("input[type=submit], input[type=button]").prop("disabled",!0),e("script").each(function(){var t=e(this).prop("src");c.is_empty(t)||!t.match(/jquery(\.min|\.js|\-?ui)/i)||t.match(/load\-scripts.php/)||n.push("<code><small>"+t.split(/\?/)[0]+"</small></code>")}),i.push("<strong>"+c.getxt("js")+"</strong> "+c.getxt("contact")),i.push(c.jqueryerr.join("<br/>")),n.length&&i.push(c.getxt("jquery")+"<br/>"+n.join("<br/>")),i.push(c.getxt("plugin"))),c.set_notice({error:i})},update:{qsid:function(t){var c,n,i,a,s=this;s.currqsid=t.key,s.currdata=t.data,e("#ctc_sel_ovrd_qsid").val(s.currqsid),s.is_empty(s.currdata.seq)?e("#ctc_child_load_order_container").empty():(c="ctc_ovrd_child_seq_"+s.currqsid,i=parseInt(s.currdata.seq),n='<input type="text" id="'+c+'" name="'+c+'" class="ctc-child-value" value="'+i+'" />',e("#ctc_child_load_order_container").html(n)),s.is_empty(s.currdata.value)?(a=!0,e("#ctc_sel_ovrd_rule_inputs").empty()):(a=!1,n="",e.each(s.currdata.value,function(e,t){t=null,n+=s.input_row(s.currqsid,e,"ovrd",s.currdata)}),e("#ctc_sel_ovrd_rule_inputs").html(n).find(".color-picker").each(function(){s.setup_spectrum(this)}),s.coalesce_inputs("#ctc_child_all_0_swatch")),s.reload&&(s.load_queries(),s.set_query(s.currdata.query),s.load_rules()),e("#ctc_sel_ovrd_selector_selected").text(s.currdata.selector),e(".ctc-rewrite-toggle").text(s.getxt("rename")),e(".ctc-rewrite-toggle").show(),a?e("#ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_new_rule,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").hide():e("#ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_new_rule,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").show()},rule_val:function(t){var c=this,n=e("#ctc_rule_menu_selected").text(),i='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+n+'">\n';c.is_empty(t.data)||(e.each(t.data,function(e,t){var a=c.decode_value(n,t);i+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+n+"_"+e+'">\n<div class="ctc-input-cell ctc-parent-value" id="ctc_'+e+"_parent_"+n+"_"+e+'">'+a.orig+'</div>\n<div class="ctc-input-cell">\n<div class="ctc-swatch ctc-specific" id="ctc_'+e+"_parent_"+n+"_"+e+'_swatch">'+c.getxt("swatch")+'</div></div>\n<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+n+"_"+e+'">'+c.getxt("selector")+'</a></div>\n<div id="ctc_selector_'+n+"_"+e+'_container" class="ctc-selector-container">\n<a href="#" id="ctc_selector_'+n+"_"+e+'_close" class="ctc-selector-handle ctc-exit" title="'+c.getxt("close")+'"></a><div id="ctc_selector_'+n+"_"+e+'_inner_container" class="ctc-selector-inner-container clearfix">\n<div id="ctc_status_val_qry_'+e+'"></div>\n<div id="ctc_selector_'+n+"_"+e+'_rows"></div>\n</div></div></div>\n'}),i+="</div>\n"),e("#ctc_rule_value_inputs").html(i).find(".ctc-swatch").each(function(){c.coalesce_inputs(this)})},val_qry:function(t){var c,n,i=this,a="";i.is_empty(t.data)||e.each(t.data,function(n,s){c=n,e.each(s,function(c,s){a+='<h4 class="ctc-query-heading">'+c+"</h4>\n",i.is_empty(s)||e.each(s,function(e,c){a+=i.input_row(e,n,t.key,c)})})}),n="#ctc_selector_"+c+"_"+t.key+"_rows",e(n).html(a).find(".color-picker").each(function(){i.setup_spectrum(this)}),e(n).find(".ctc-swatch").each(function(){i.coalesce_inputs(this)})},queries:function(t){e("#ctc_sel_ovrd_query").data("menu",t.data)},selectors:function(t){e("#ctc_sel_ovrd_selector").data("menu",t.data)},rules:function(t){e("#ctc_rule_menu").data("menu",t.data)},debug:function(t){e("#ctc_debug_box").val(e("#ctc_debug_box").val()+t.data)},preview:function(t){e("#view_"+t.key+"_options_panel").text(t.data)},dismiss:function(){}},bind_dismiss:function(t){var c=this,n=e(t),i=e('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'),a=window.commonL10n.dismiss||"";i.find(".screen-reader-text").text(a),n.append(i),i.on("click.wp-dismiss-notice",function(e){e.preventDefault(),c.dismiss_notice(t)})},dismiss_notice:function(t){e(t).fadeTo(100,0,function(){e(this).slideUp(100,function(){e(this).remove()})})},reset_handling:function(){e("#parnt_analysis_notice .notice, #child_analysis_notice .notice").slideUp(),e("#ctc_enqueue_enqueue").prop("checked",!0),e("#ctc_handling_primary").prop("checked",!0),e("#ctc_ignoreparnt").prop("checked",!1),e("#ctc_repairheader").prop("checked",!1)},init:function(){var t=this;if(!e("#ctc_theme_parnt").is("input")){try{e.widget("ctc.themeMenu",e.ui.selectmenu,{_renderItem:function(t,c){var n=e("<li>"),i=c.value.replace(/[^\w\-]/,"");return e("#ctc_theme_option_"+i).detach().appendTo(n),n.appendTo(t)}})}catch(c){t.jquery_exception(c,"Theme Menu")}try{e("#ctc_theme_parnt").themeMenu({select:function(e,c){t.reset_handling(),t.set_parent_menu(c.item)}})}catch(c){"function"==typeof themeMenu?e("#ctc_theme_parnt").themeMenu("destroy"):e("#ctc_theme_parnt-button").remove(),t.jquery_exception(c,"Parent Theme Menu")}if(t.is_empty(window.ctcAjax.themes.child))e("#ctc_child_name").length&&(e("#ctc_child_name").val(t.testname),e("#ctc_child_template").val(t.testslug));else try{e("#ctc_theme_child").themeMenu({select:function(e,c){t.reset_handling(),t.set_child_menu(c.item)}})}catch(c){"function"==typeof themeMenu?e("#ctc_theme_child").themeMenu("destroy"):e("#ctc_theme_child-button").remove(),t.jquery_exception(c,"Child Theme Menu")}}t.currparnt=e("#ctc_theme_parnt").val(),t.currchild=e("#ctc_theme_child").length?e("#ctc_theme_child").val():"",e("#ctc_main").on("click",".ctc-section-toggle",function(t){t.preventDefault(),e(this).parents(".ctc-input-row, .notice-warning, .updated, .error").first().find(".ctc-section-toggle").each(function(){e(this).toggleClass("open")});var c=e(this).attr("id").replace(/\d$/,"")+"_content";return e("#"+c).stop().slideToggle("fast"),!1}),e("#ctc_main").on("click",".ctc-upgrade-notice .notice-dismiss",function(){var c={action:"ctc_dismiss",_wpnonce:e("#_wpnonce").val()};t.ajax_post("dismiss",c)}),t.is_empty(t.jqueryerr)&&(e("#ctc_main").on("click",".ctc-selector-handle",function(c){if(c.preventDefault(),e(this).hasClass("ajax-pending"))return!1;e(this).addClass("ajax-pending");var n,i,a=e(this).attr("id").toString().replace("_close",""),s=a.toString().match(/_([^_]+)_(\d+)$/);e("#"+a+"_container").is(":hidden")&&(t.is_empty(s[1])||t.is_empty(s[2])||(n=s[1],i=s[2],t.query_css("val_qry",i,{rule:n}))),e("#"+a+"_container").fadeToggle("fast"),e(".ctc-selector-container").not("#"+a+"_container").fadeOut("fast")}),e("#ctc_main").on("click",".ctc-save-input[type=button], .ctc-delete-input",function(c){return c.preventDefault(),e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),t.save(this),!1)}),e("#ctc_main").on("keydown",".ctc-selector-container .ctc-child-value[type=text]",function(c){if(13===c.which){var n=e(this).parents(".ctc-selector-row").find(".ctc-save-input[type=button]").first();if(n.length)return c.preventDefault(),n.hasClass("ajax-pending")?!1:(n.addClass("ajax-pending"),t.save(n),!1)}}),e("#ctc_main").on("click",".ctc-selector-edit",function(c){return c.preventDefault(),e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),void t.set_qsid(this))}),e("#ctc_main").on("click",".ctc-rewrite-toggle",function(e){e.preventDefault(),t.selector_input_toggle(this)}),e("#ctc_main").on("click","#ctc_copy_selector",function(){var c=e("#ctc_sel_ovrd_selector_selected").text().trim();t.is_empty(c)||e("#ctc_new_selectors").val(e("#ctc_new_selectors").val()+"\n"+c+" {\n\n}")}),e("#ctc_main").on("click",".ctc-backup-theme",function(c){c.preventDefault(),t.existing?e("#ctc_export_theme").val(t.currchild):e("#ctc_export_theme").val(t.currparnt),e("#ctc_export_theme_form").submit()}),e("#ctc_configtype").on("change",function(){var c=e(this).val();if(t.is_empty(c)||"theme"===c){e(".ctc-theme-only, .ctc-themeonly-container").removeClass("ctc-disabled"),e(".ctc-theme-only, .ctc-themeonly-container input").prop("disabled",!1);try{e("#ctc_theme_parnt, #ctc_theme_child").themeMenu("enable")}catch(n){t.jquery_exception(n,"Theme Menu")}}else{e(".ctc-theme-only, .ctc-themeonly-container").addClass("ctc-disabled"),e(".ctc-theme-only, .ctc-themeonly-container input").prop("disabled",!0);try{e("#ctc_theme_parnt, #ctc_theme_child").themeMenu("disable")}catch(n){t.jquery_exception(n,"Theme Menu")}}}),e(".nav-tab").on("click",function(c){c.preventDefault(),e(".ctc-query-icon,.ctc-status-icon").remove();var n="#"+e(this).attr("id");t.focus_panel(n)}),e("#view_child_options, #view_parnt_options").on("click",function(){return e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),void t.css_preview(e(this).attr("id")))}),e("#ctc_load_form").on("submit",function(){return t.validate()}),e("#ctc_query_selector_form").on("submit",function(c){c.preventDefault();var n=e("#ctc_save_query_selector");return n.hasClass("ajax-pending")?!1:(n.addClass("ajax-pending"),t.save(n),!1)}),e("#ctc_rule_value_form").on("submit",function(e){return e.preventDefault(),!1}),e("#ctc_child_type_new,#ctc_child_type_existing,#ctc_child_type_duplicate,#ctc_child_type_reset").on("focus click",function(){t.reset_handling(),t.update_form()}),e("#ctc_is_debug").on("change",function(){e(this).is(":checked")?e("#ctc_debug_box").length||e("#ctc_debug_container").html('<textarea id="ctc_debug_box"></textarea>'):e("#ctc_debug_box").remove(),t.save(this)}),e(".ctc-live-preview").on("click",function(t){return t.stopImmediatePropagation(),t.preventDefault(),document.location=e(this).prop("href"),!1}),t.setup_menus(),e("input[type=submit], input[type=button]").prop("disabled",!1),t.scrolltop(),t.update_form()),t.jqueryerr.length&&t.jquery_notice()},testslug:"",testname:"",reload:!1,currquery:"base",currqsid:null,currdata:{},currparnt:"",currchild:"",existing:!1,jqueryerr:[],color_regx:"\\s+(\\#[a-f0-9]{3,6}|rgba?\\([\\d., ]+?\\)|hsla?\\([\\d%., ]+?\\)|[a-z]+)",border_regx:"(\\w+)(\\s+(\\w+))?",grad_regx:"(\\w+)"},e.chldthmanalyze={show_loading:function(t,c){var n=e.chldthmcfg.existing?"child":"parnt",i=c?c:e.chldthmcfg.getname(n),a='<strong class="ctc_analyze_loading"><span class="spinner is-active"></span>'+e.chldthmcfg.getxt(t?"anlz1":"anlz2")+" "+i+"...</strong>";self.noticediv="",e("#"+n+"_analysis_notice").html(a)},hide_loading:function(){e(".ctc_analyze_loading").fadeTo(200,0,function(){e(this).slideUp(200,function(){e(this).remove()})})},setssl:function(e){return e.replace(/^https?/,window.ctcAjax.ssl?"https":"http")},escrgx:function(e){return e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},trmcss:function(e){return"undefined"==typeof e?"":e.replace(/\-css$/,"")},analyze_theme:function(t){var c=this,n=e.chldthmcfg.currparnt,i="child"===t?e.chldthmcfg.currchild:e.chldthmcfg.currparnt;e.ajax({url:window.ctcAjax.ajaxurl,data:{action:"ctc_analyze",stylesheet:i,template:n,_wpnonce:e("#_wpnonce").val()},dataType:"json",type:"POST"}).done(function(n){c.analysis[t]=n,e.each(n.dependencies,function(e,t){c.dependencies[e]=t}),e(document).trigger("analysisdone")}).fail(function(n,i,a){var s={signals:{failure:1,xhrerr:a}};c.analysis[t]=s,e(document).trigger("analysisdone")})},css_notice:function(){var t,c,n=this,i=e.chldthmcfg.existing?"child":"parnt",a=e.chldthmcfg.getname(i),s="",l={notices:[]},r={style:"notice-warning",headline:e.chldthmcfg.getxt("anlz3",a),errlist:""},o=0,_={},d="";if(n.analysis[i].signals.failure||n.analysis[i].signals.thm_noqueue&&!n.phperr[i].length)e("#ctc_is_debug").is(":checked")&&(d=e.chldthmcfg.getxt("anlz33").replace(/%1/,'<a href="'+n.analysis[i].url+'" target="_new">').replace(/%2/,"</a>")),l.notices.push({headline:e.chldthmcfg.getxt("anlz4",a),msg:e.chldthmcfg.getxt("anlz5")+d+(n.analysis[i].signals.failure?n.analysis[i].signals.xhrerr:""),style:"notice-warning"});else{if(n.analysis[i].errors.length&&(e.each(n.analysis[i].errors,function(t,c){c.match(/Fatal error/i)&&(r.style="error",
2
- r.headline=e.chldthmcfg.getxt("anlz8",a)),r.errlist+=c+"\n"}),r.msg='<div style="background-color:#ffeebb;padding:6px"><div class="ctc-section-toggle" id="ctc_analysis_errs">'+e.chldthmcfg.getxt("anlz6")+'</div><div id="ctc_analysis_errs_content" style="display:none"><textarea>'+r.errlist+"</textarea></div></div>"+e.chldthmcfg.getxt("anlz7"),l.notices.push(r)),(n.analysis[i].signals.thm_past_wphead||n.analysis[i].signals.dep_past_wphead)&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz9"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz10")}),e("#ctc_repairheader").prop("checked",!0),e("#ctc_repairheader_container").show()),n.analysis[i].signals.thm_unregistered&&(n.analysis[i].signals.ctc_child_loaded||n.analysis[i].signals.ctc_sep_loaded||(l.notices.push({headline:e.chldthmcfg.getxt("anlz11"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz12")}),e("#ctc_repairheader_container").show(),e("#ctc_repairheader").prop("checked",!0))),"child"===i&&(n.analysis.child.signals.ctc_parnt_reorder&&(o=1),n.analysis.child.signals.ctc_child_loaded||n.analysis.child.signals.ctc_sep_loaded||n.analysis.child.signals.thm_child_loaded||(l.notices.push({headline:e.chldthmcfg.getxt("anlz13"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz14")}),o=1),n.analysis[i].signals.ctc_gen_loaded&&l.notices.push({headline:e.chldthmcfg.getxt("anlz31"),msg:e.chldthmcfg.getxt("anlz32"),style:"notice-warning"}),n.analysis.parnt.signals.thm_no_styles||n.analysis.child.signals.ctc_gen_loaded||n.analysis.child.signals.thm_parnt_loaded||n.analysis.child.signals.ctc_parnt_loaded||n.analysis.child.signals.thm_ignoreparnt||n.analysis.child.signals.thm_has_import||(l.notices.push({headline:e.chldthmcfg.getxt("anlz15"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz16")}),o=1),n.analysis.child.signals.thm_unregistered&&n.analysis.child.signals.thm_child_loaded&&"thm_unregistered"===n.analysis.child.signals.thm_child_loaded&&n.analysis.child.signals.ctc_child_loaded&&n.analysis.child.signals.ctc_parnt_loaded&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz28"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz29")}),e("#ctc_repairheader_container").show(),e("#ctc_repairheader").prop("checked",!0)),n.analysis.child.signals.thm_is_ctc||e("#ctc_child_type_duplicate").is(":checked")||l.notices.push({headline:e.chldthmcfg.getxt("anlz19"),msg:e.chldthmcfg.getxt("anlz20"),style:"notice-warning"})),(n.analysis[i].signals.ctc_sep_loaded||n.analysis[i].signals.ctc_gen_loaded)&&e("#ctc_handling_separate").prop("checked",!0),l.notices.length||l.notices.push({headline:""+("child"===i?e.chldthmcfg.getxt("anlz17"):e.chldthmcfg.getxt("anlz18")),style:"updated",msg:""}),"child"===i&&n.analysis.child.signals.thm_has_import&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz21"),msg:e.chldthmcfg.getxt("anlz22"),style:"notice-warning"}),e("#ctc_enqueue_import").prop("checked",!0)),n.analysis[i].signals.thm_ignoreparnt||n.analysis[i].signals.ctc_gen_loaded?(e("#ctc_ignoreparnt").prop("checked",!0),e("#ctc_enqueue_none").is(":checked")||(e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none")):e("#ctc_ignoreparnt").prop("checked",!1),!n.analysis[i].signals.ctc_sep_loaded&&!n.analysis[i].signals.ctc_gen_loaded&&!n.analysis[i].signals.ctc_child_loaded&&!n.analysis[i].signals.thm_unregistered&&!n.analysis[i].signals.thm_past_wphead&&n.analysis[i].deps[1].length){var u="";e.each(n.analysis[i].deps[1],function(e,t){t[1].match(/^style([\-\.]min)?\.css$/)||(u+="<li>"+t[1]+"</li>\n")}),""!==u&&(u="<ul class='howto' style='padding-left:1em'>\n"+u+"</ul>\n",l.notices.push({headline:e.chldthmcfg.getxt("anlz23"),msg:u+e.chldthmcfg.getxt("anlz24"),style:"updated"}))}"child"===i&&n.analysis[i].signals.thm_parnt_loaded&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz25"),msg:e.chldthmcfg.getxt("anlz26"),style:"updated"}),e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none"),n.analysis.parnt.signals.thm_no_styles&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz27"),msg:e.chldthmcfg.getxt("anlz26"),style:"updated"}),e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none")}return s=encodeURIComponent(JSON.stringify(n.analysis)),e('input[name="ctc_analysis"]').val(s),_.ctc_analysis=s,n.is_success()&&o&&!n.resubmitting?(n.resubmitting=1,void n.resubmit(_)):(n.resubmitting=0,n.hide_loading(),e.each(l.notices,function(t,c){var n=e('<div class="'+c.style+' notice is-dismissible dashicons-before" ><h4>'+c.headline+"</h4>"+c.msg+"</div>");e.chldthmcfg.bind_dismiss(n),n.hide().appendTo("#"+i+"_analysis_notice").slideDown()}),e("#ctc_is_debug").is(":checked")&&(t='<div style="background-color:#ddd;padding:6px"><div class="ctc-section-toggle" id="ctc_analysis_obj">'+e.chldthmcfg.getxt("anlz30")+'</div><div id="ctc_analysis_obj_content" style="display:none"><textarea style="font-family:monospace;font-size:10px">'+JSON.stringify(n.analysis,null,2)+"</textarea></div></div>",e(t).appendTo("#"+i+"_analysis_notice")),c="",e.each(n.dependencies,function(t,n){n&&(c+='<label><input class="ctc_checkbox ctc-themeonly" id="ctc_forcedep_'+t+'" name="ctc_forcedep[]" type="checkbox" value="'+t+'" autocomplete="off" '+(-1!==e.inArray(t,window.ctcAjax.forcedep)?"checked":"")+" />"+t+"</label><br/>\n")}),c.length?(e("#ctc_dependencies").html(c),e("#ctc_dependencies_container").show()):(e("#ctc_dependencies").empty(),e("#ctc_dependencies_container").hide()),e("#ctc_child_type_reset").is(":checked")||(e("#input_row_stylesheet_handling_container,#input_row_parent_handling_container,#ctc_child_header_parameters,#ctc_configure_submit").slideDown("fast"),e("#ctc_child_type_duplicate").is(":checked")?(e("#ctc_configure_submit .ctc-step").text("8"),e("#ctc_copy_theme_mods").find("input").prop("checked",!1)):(e("#ctc_configure_submit .ctc-step").text("9"),e("#ctc_copy_theme_mods").slideDown("fast")),e("#ctc_child_type_duplicate").is(":checked")||e("#ctc_child_type_new").is(":checked")?(e("#input_row_theme_slug").hide(),e("#input_row_new_theme_slug").slideDown("fast")):(e("#input_row_new_theme_slug").hide(),e("#input_row_theme_slug").slideDown("fast"))),void 0)},resubmit:function(t){var c=this;c.hide_loading(),c.show_loading(!0),t.action="ctc_update",t._wpnonce=e("#_wpnonce").val(),e.ajax({url:window.ctcAjax.ajaxurl,data:t,type:"POST"}).done(function(){c.hide_loading(),c.do_analysis()}).fail(function(){c.hide_loading()})},do_analysis:function(){var t=this;t.analysis={parnt:{},child:{}},t.phperr={parnt:[],child:[]},t.dependencies={},t.done=0,t.show_loading(!1),t.analyze_theme("parnt"),e.chldthmcfg.existing&&t.analyze_theme("child")},init:function(){var t=this;e(document).on("analysisdone",function(){t.done++,t.done>e.chldthmcfg.existing&&(t.done=0,t.css_notice())}),e("#ctc_main").on("click",".ctc-analyze-theme",function(){t.is_success()&&e.chldthmcfg.dismiss_notice(e(".ctc-success-response").parent(".notice")),t.do_analysis()}),t.is_success()&&!window.ctcAjax.pluginmode&&t.do_analysis()},analysis:{},done:0,resubmitting:0,dependencies:{},is_success:function(){return e(".ctc-success-response").length}},e("#request-filesystem-credentials-form").length||(e.chldthmcfg.init(),e.chldthmanalyze.init())}(jQuery);
1
+ !function(e){"use strict";e.chldthmcfg={escquo:function(e){var t=this;return t.is_empty(e)?e:e.toString().replace(/"/g,"&quot;")},getxt:function(e,t){var c=window.ctcAjax[e+"_txt"];return c?(t&&(c=c.replace(/%s/,t)),c):""},getname:function(t){var c="child"===t?e.chldthmcfg.currchild:e.chldthmcfg.currparnt;return window.ctcAjax.themes[t][c].Name},frascii:function(e){var t=parseInt(e),c=String.fromCharCode(t);return c},toascii:function(e){var t=e.charCodeAt(0);return t},is_empty:function(e,t){if("undefined"==typeof e||!1===e||null===e||""===e)return!0;if("undefined"!=typeof t&&"0"===e||0===e)return!0;if(!0===e||"string"==typeof e||"number"==typeof e)return!1;if("object"==typeof e){for(var c in e)if(e.hasOwnProperty(c))return!1;return!0}return!1},theme_exists:function(t,c){var n=!1;return e.each(window.ctcAjax.themes,function(a,i){return e.each(i,function(e,i){return i=null,e.toLowerCase()!==t.toLowerCase()||"parnt"!==a&&"new"!==c?void 0:(n=!0,!1)}),n?!1:void 0}),n},validate:function(){var t=this,c=/[^\w\-]/,n=e("#ctc_child_template").length?e("#ctc_child_template").val().toString().replace(c):"",a=e("#ctc_theme_child").length?e("#ctc_theme_child").val().toString().replace(c):n,i=e("input[name=ctc_child_type]:checked").val(),s=[];return"new"===i&&(a=n),t.theme_exists(a,i)&&s.push(t.getxt("theme_exists").toString().replace(/%s/,a)),t.is_empty(a)&&s.push(t.getxt("inval_theme")),s.length?(t.set_notice({error:s}),!1):"reset"===i?!!confirm(t.getxt("load")):!0},autogen_slugs:function(){if(e("#ctc_theme_parnt").length){for(var t=this,c=e("#ctc_theme_parnt").val(),n=e("#ctc_theme_child").length?e("#ctc_theme_child").val():"",a=""!==n&&e("#ctc_child_type_duplicate").is(":checked")?n:c+"-child",i=a,s=""!==n&&e("#ctc_child_type_duplicate").is(":checked")?e.chldthmcfg.getname("child"):e.chldthmcfg.getname("parnt")+" Child",l="",r="",o="00";t.theme_exists(i,"new");)l=t.is_empty(l)?2:l+1,r=o.substring(0,o.length-l.toString().length)+l.toString(),i=a+r;t.testslug=i,t.testname=s+(r.length?" "+r:"")}},focus_panel:function(t){var c=t+"_panel";e(".nav-tab").removeClass("nav-tab-active"),e(".ctc-option-panel").removeClass("ctc-option-panel-active"),e(t).addClass("nav-tab-active"),e(".ctc-option-panel-container").scrollTop(0),e(c).addClass("ctc-option-panel-active")},selector_input_toggle:function(t){var c,n=this;e("#ctc_rewrite_selector").length?(c=e("#ctc_rewrite_selector_orig").val(),e("#ctc_sel_ovrd_selector_selected").text(c),e(t).text(n.getxt("rename"))):(c=e("#ctc_sel_ovrd_selector_selected").text(),e("#ctc_sel_ovrd_selector_selected").html('<textarea id="ctc_rewrite_selector" name="ctc_rewrite_selector" autocomplete="off"></textarea><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'+n.escquo(c)+'"/>'),e("#ctc_rewrite_selector").val(c),e(t).text(n.getxt("cancel")))},coalesce_inputs:function(t){var c=this,n=e(t).attr("id"),a=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+?)(_(\d+))?)(_\w+)?$/,i=e(t).parents(".ctc-selector-row, .ctc-parent-row").first(),s=i.find(".ctc-swatch").first(),l={parent:{},child:{}},r={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},o={child:!1,parent:!1},_={};return i.find(".ctc-parent-value, .ctc-child-value").each(function(){var t,i,s=e(this).attr("id"),d=s.toString().match(a),u=d[2],h=d[3],p="undefined"==typeof d[4]?"":d[4],m=d[7],g=d[5],f="undefined"==typeof d[7]?"":d[8],y="parent"===h?e(this).text().replace(/!$/,""):"seq"!==p&&"ctc_delete_query_selector"===n?"":e(this).val(),v="seq"===p?!1:"ctc_"+u+"_child_"+p+"_i_"+g+"_"+m;if("child"===h&&(c.is_empty(e(this).data("color"))||(y=c.color_text(e(this).data("color")),e(this).data("color",null)),_[s]=y,v&&(_[v]=e("#"+v).is(":checked")?1:0)),""!==y)if(c.is_empty(f))if(t=p.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!y.match(/none/)){var w=new RegExp(c.border_regx+c.color_regx,"i");i=y.toString().match(w),c.is_empty(i)||(i.shift(),l[h][p+"-width"]=i.shift()||"",i.shift(),l[h][p+"-style"]=i.shift()||"",l[h][p+"-color"]=i.shift()||"")}else if("background-image"!==p||y.match(/none/))"seq"!==p&&(l[h][p]=y);else if(y.toString().match(/url\(/))l[h]["background-image"]=c.image_url(h,y);else{var x=new RegExp(c.grad_regx+c.color_regx+c.color_regx,"i");i=y.toString().match(x),!c.is_empty(i)&&i.length>2?(i.shift(),r[h].origin=i.shift()||"top",r[h].start=i.shift()||"transparent",r[h].end=i.shift()||"transparent",o[h]=!0):l[h]["background-image"]=y}else switch(f){case"_border_width":l[h][p+"-width"]="none"===y?0:y;break;case"_border_style":l[h][p+"-style"]=y;break;case"_border_color":l[h][p+"-color"]=y;break;case"_background_url":l[h]["background-image"]=c.image_url(h,y);break;case"_background_color":l[h]["background-color"]=y;break;case"_background_color1":r[h].start=y,o[h]=!0;break;case"_background_color2":r[h].end=y,o[h]=!0;break;case"_background_origin":r[h].origin=y,o[h]=!0}}),"undefined"==typeof s||c.is_empty(s.attr("id"))||(s.removeAttr("style"),o.parent&&s.ctcgrad(r.parent.origin,[r.parent.start,r.parent.end]),s.css(l.parent),s.attr("id").toString().match(/parent/)||(o.child&&s.ctcgrad(r.child.origin,[r.child.start,r.child.end]),s.css(l.child)),s.css({"z-index":-1})),_},decode_value:function(e,t){t="undefined"==typeof t?"":t;var c,n=this,a={orig:t,names:[""],values:[t]};if(e.toString().match(/^border(\-(top|right|bottom|left))?$/)){var i,s=new RegExp(n.border_regx+"("+n.color_regx+")?","i");c=t.toString().match(s),n.is_empty(c)&&(c=[]),a.names=["_border_width","_border_style","_border_color"],i=c.shift(),a.values[0]=c.shift()||"",c.shift(),a.values[1]=c.shift()||"",c.shift(),a.values[2]=c.shift()||""}else if(e.toString().match(/^background\-image/))if(a.names=["_background_url","_background_origin","_background_color1","_background_color2"],a.values=["","","",""],n.is_empty(t)||t.toString().match(/(url|none)/))a.values[0]=t;else{var l,r;c=t.toString().split(/:/),a.values[1]=c.shift()||"",a.values[2]=c.shift()||"",l=c.shift()||"",a.values[3]=c.shift()||"",r=c.shift()||"",a.orig=[a.values[1],a.values[2],a.values[3]].join(" ")}return a},image_url:function(e,t){var c,n=this,a=t.toString().match(/url\(['" ]*(.+?)['" ]*\)/),i=n.is_empty(a)?null:a[1],s=window.ctcAjax.theme_uri+"/"+("parent"===e?window.ctcAjax.parnt:window.ctcAjax.child)+"/";return i?c=i.toString().match(/^(data:|https?:|\/)/)?t:"url("+s+i+")":!1},setup_menus:function(){var e=this;e.setup_query_menu(),e.setup_selector_menu(),e.setup_rule_menu(),e.setup_new_rule_menu(),e.load_queries(),e.load_rules(),e.set_query(e.currquery)},load_queries:function(){var e=this;e.query_css("queries",null)},load_selectors:function(){var e=this;e.query_css("selectors",e.currquery)},load_rules:function(){var e=this;e.query_css("rules",null)},load_selector_values:function(){var e=this;e.query_css("qsid",e.currqsid)},get_queries:function(t,c){var n=[],a=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){a.test(t)&&n.push({label:t,value:t})}),c(n)},get_selectors:function(t,c){var n=[],a=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){a.test(e)&&n.push({label:e,value:t})}),c(n)},get_rules:function(t,c){var n=[],a=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.chldthmcfg.is_empty(this.element.data("menu"))?n.push({label:window.ctcAjax.nosels_txt,value:null}):e.each(this.element.data("menu"),function(e,t){a.test(e)&&n.push({label:e,value:t})}),c(n)},get_filtered_rules:function(t,c){var n=[],a=new RegExp(e.ui.autocomplete.escapeRegex(t.term),"i");e.each(e("#ctc_rule_menu").data("menu"),function(e,t){a.test(e)&&n.push({label:e,value:t})}),c(n)},merge_ruleval_arrays:function(t,c,n){var a=this,i={},s=n?c.child.pop():null;return e.each(["parnt","child"],function(t,l){a.is_empty(c[l])||e.each(c[l],function(e,t){n?parseInt(t[2])>=parseInt(s[2])&&(s[2]=parseInt(t[2])+1):(a.is_empty(i[t[2]])&&(i[t[2]]={}),i[t[2]][l]=t)})}),n&&(i[s[2]]={parnt:[],child:s}),i},input_row:function(t,c,n,a,i){var s=this,l="";if(!s.is_empty(a)&&!s.is_empty(a.value)&&!s.is_empty(a.value[c])){var r=a.value[c],o=s.merge_ruleval_arrays(c,r,i);e.each(o,function(i,r){var o=s.decode_value(c,s.is_empty(r.parnt)?"":r.parnt[0]),_=s.is_empty(r.parnt)||s.is_empty(r.parnt[1],1)?0:1,d=s.decode_value(c,s.is_empty(r.child)?"":r.child[0]),u=s.is_empty(r.child)||s.is_empty(r.child[1],1)?0:1;if(l+='<div class="ctc-'+("ovrd"===n?"input":"selector")+'-row clearfix"><div class="ctc-input-cell">',l+="ovrd"===n?c.replace(/\d+/g,s.frascii):a.selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+t+'" >'+s.getxt("edit")+"</a> "+(s.is_empty(o.orig)?s.getxt("child_only"):""),l+='</div><div class="ctc-parent-value ctc-input-cell"'+("ovrd"!==n?' style="display:none"':"")+' id="ctc_'+n+"_parent_"+c+"_"+t+"_"+i+'">'+(s.is_empty(o.orig)?"[no value]":o.orig+(_?s.getxt("important"):""))+'</div><div class="ctc-input-cell">',!s.is_empty(o.names)){e.each(o.names,function(e,a){a=s.is_empty(a)?"":a,l+='<div class="ctc-child-input-cell ctc-clear">';var r,o="ctc_"+n+"_child_"+c+"_"+t+"_"+i+a;!1===(r=d.values.shift())&&(r=""),l+=(s.is_empty(a)?"":s.getxt(a)+":<br/>")+'<input type="text" id="'+o+'" name="'+o+'" class="ctc-child-value'+((a+c).toString().match(/color/)?" color-picker":"")+(a.toString().match(/url/)?" ctc-input-wide":"")+'" value="'+s.escquo(r)+'" /></div>'});var h="ctc_"+n+"_child_"+c+"_i_"+t+"_"+i;l+='<label for="'+h+'"><input type="checkbox" id="'+h+'" name="'+h+'" value="1" '+(u?"checked":"")+" />"+s.getxt("important")+"</label>"}l+="</div>","ovrd"!==n&&(l+='<div class="ctc-swatch ctc-specific" id="ctc_child_'+c+"_"+t+"_"+i+'_swatch">'+s.getxt("swatch")+'</div><div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+c+"_"+t+"_"+i+'_cell"><input type="button" class="button ctc-save-input" id="ctc_save_'+c+"_"+t+"_"+i+'" name="ctc_save_'+c+"_"+t+"_"+i+'" value="Save" /></div>'),l+="</div><!-- end input row -->\n"})}return l},scrolltop:function(){e("html, body, .ctc-option-panel-container").animate({scrollTop:0})},css_preview:function(e){var t=this;(e=e.match(/(child|parnt)/)[1])||(e="child"),t.query_css("preview",e)},setup_iris:function(e){var t=this;t.setup_spectrum(e)},setup_spectrum:function(t){var c=this,n=!c.is_empty(window.ctcAjax.palette);try{e(t).spectrum({showInput:!0,allowEmpty:!0,showAlpha:!0,showInitial:!0,preferredFormat:"hex",clickoutFiresChange:!0,move:function(n){e(t).data("color",n),c.coalesce_inputs(t)},showPalette:!!n,showSelectionPalette:!!n,palette:[],maxSelectionSize:36,localStorageKey:"ctc-palette."+window.ctcAjax.child,hideAfterPaletteSelect:!0}).on("change",function(){c.coalesce_inputs(this)}).on("keyup",function(){var t=this,n=c.addhash(e(this).val());e(t).val(n),clearTimeout(e(this).data("spectrumTimer")),e(this).data("spectrumTimer",setTimeout(function(){c.coalesce_inputs(t),e(t).spectrum("set",n)},500))})}catch(a){c.jquery_exception(a,"Spectrum Color Picker")}},addhash:function(e){return e.replace(/^#?([a-f0-9]{3,6}.*)/,"#$1")},color_text:function(e){var t=this;return t.is_empty(e)?"":e.getAlpha()<1?e.toRgbString():e.toHexString()},setup_query_menu:function(){var t=this;try{e("#ctc_sel_ovrd_query").autocomplete({source:t.get_queries,minLength:0,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_query(c.item.value),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Query Menu")}},setup_selector_menu:function(){var t=this;try{e("#ctc_sel_ovrd_selector").autocomplete({source:t.get_selectors,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_selector(c.item.value,c.item.label),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Selector Menu")}},setup_rule_menu:function(){var t=this;try{e("#ctc_rule_menu").autocomplete({source:t.get_rules,selectFirst:!0,autoFocus:!0,select:function(e,c){return t.set_rule(c.item.value,c.item.label),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"Property Menu")}},setup_new_rule_menu:function(){var t=this;try{e("#ctc_new_rule_menu").autocomplete({source:t.get_filtered_rules,selectFirst:!0,autoFocus:!0,select:function(c,n){c.preventDefault();var a,i,s=n.item.label.replace(/[^\w\-]/g,t.toascii);return t.is_empty(t.currdata.value)&&(t.currdata.value={}),t.is_empty(t.currdata.value[n.item.label])&&(t.currdata.value[n.item.label]={}),t.is_empty(t.currdata.value[n.item.label].child)&&(t.currdata.value[n.item.label].child=[]),t.currdata.value[n.item.label].child.push(["",0,1,1]),a=e(t.input_row(t.currqsid,s,"ovrd",t.currdata,!0)),e("#ctc_sel_ovrd_rule_inputs").append(a),e("#ctc_new_rule_menu").val(""),a.find('input[type="text"]').each(function(c,n){i||(i=n),e(n).hasClass("color-picker")&&t.setup_spectrum(n)}),i&&e(i).focus(),!1},focus:function(e){e.preventDefault()}}).data("menu",{})}catch(c){t.jquery_exception(c,"New Property Menu")}},set_theme_params:function(t,c){e("#ctc_child_author").val(window.ctcAjax.themes[t][c].Author),e("#ctc_child_version").val(window.ctcAjax.themes[t][c].Version),e("#ctc_child_authoruri").val(window.ctcAjax.themes[t][c].AuthorURI),e("#ctc_child_themeuri").val(window.ctcAjax.themes[t][c].ThemeURI),e("#ctc_child_descr").val(window.ctcAjax.themes[t][c].Descr),e("#ctc_child_tags").val(window.ctcAjax.themes[t][c].Tags)},update_form:function(){var t,c=this;e("#input_row_stylesheet_handling_container,#input_row_parent_handling_container,#ctc_additional_css_files_container,#input_row_new_theme_slug,#input_row_duplicate_theme_slug,#ctc_copy_theme_mods,#ctc_child_header_parameters,#ctc_configure_submit,#input_row_theme_slug").slideUp("fast"),e("#ctc_configure_submit .ctc-step").text("9"),e("#ctc_theme_child").length&&!e("#ctc_child_type_new").is(":checked")?(t=e("#ctc_theme_child").val(),c.existing=1,c.currparnt=window.ctcAjax.themes.child[t].Template,c.autogen_slugs(),e("#ctc_theme_parnt").val(c.currparnt),e("#ctc_theme_parnt-button .ui-selectmenu-text").text(c.getname("parnt")),c.set_theme_params("child",t),e("#ctc_child_type_duplicate").is(":checked")?(e("#ctc_child_template").val(c.testslug),e("#ctc_child_name").val(c.testname),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_load_styles").val("Duplicate Child Theme")):e("#ctc_child_type_reset").is(":checked")?(e("#ctc_configure_submit .ctc-step").text("3"),e("#ctc_configure_submit").slideDown("fast"),e("#theme_slug_container").text(t),e(".ctc-analyze-theme, .ctc-analyze-howto").hide(),e("#ctc_enqueue_none").prop("checked",!0),e("#ctc_load_styles").val("Reset Child Theme to Previous State")):(e("#ctc_child_template").val(""),e("#theme_slug_container").text(t),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_child_name").val(c.getname("child")),e("#ctc_load_styles").val("Configure Child Theme")),e("#input_row_existing_theme_option").slideDown("fast"),e("#input_row_new_theme_option").slideUp("fast")):(c.existing=0,c.autogen_slugs(),e("#ctc_theme_parnt").val(c.currparnt),e("#ctc_theme_parnt-button .ui-selectmenu-text").text(e.chldthmcfg.getname("parnt")),c.set_theme_params("parnt",c.currparnt),e("#input_row_existing_theme_option,#input_row_duplicate_theme_container,#input_row_theme_slug").slideUp("fast"),e("#input_row_new_theme_option").slideDown("fast"),e("#ctc_child_name").val(c.testname),e("#ctc_child_template").val(c.testslug),e(".ctc-analyze-theme, .ctc-analyze-howto").show(),e("#ctc_load_styles").val("Create New Child Theme"))},set_notice:function(t){var c,n=this,a="";n.is_empty(t)||e.each(t,function(t,c){a+='<div class="'+t+' notice is-dismissible dashicons-before"><ul>\n',e(c).each(function(e,t){a+="<li>"+t.toString()+"</li>\n"}),a+="</ul></div>"}),c=e(a),e("#ctc_error_notice").html(c),n.bind_dismiss(c),e("html, body").animate({scrollTop:0},"slow")},set_parent_menu:function(e){var t=this;t.currparnt=e.value,t.update_form()},set_child_menu:function(e){var t=this;t.currchild=e.value,t.update_form()},set_query:function(t){var c=this;return c.is_empty(t)?!1:(c.currquery=t,e("#ctc_sel_ovrd_query").val(""),e("#ctc_sel_ovrd_query_selected").text(t),e("#ctc_sel_ovrd_selector").val(""),e("#ctc_sel_ovrd_selector_selected").html("&nbsp;"),c.load_selectors(),void c.scrolltop())},set_selector:function(t,c){var n=this;return c=null,n.is_empty(t)?!1:(e("#ctc_sel_ovrd_selector").val(""),n.currqsid=t,n.reload=!1,n.load_selector_values(),void n.scrolltop())},set_rule:function(t,c){var n=this;return n.is_empty(t)?!1:(e("#ctc_rule_menu").val(""),e("#ctc_rule_menu_selected").text(c),e(".ctc-rewrite-toggle").text(n.getxt("rename")),e("#ctc_rule_value_inputs, #ctc_input_row_rule_header").show(),n.query_css("rule_val",t),void n.scrolltop())},set_qsid:function(t){var c=this;c.currqsid=e(t).attr("id").match(/_(\d+)$/)[1],c.focus_panel("#query_selector_options"),c.reload=!0,c.load_selector_values()},query_css:function(t,c,n){var a=this,i={ctc_query_obj:t,ctc_query_key:c},s="#ctc_status_"+t+("val_qry"===t?"_"+c:"");"object"==typeof n&&e.each(n,function(e,t){i["ctc_query_"+e]=t}),e(".query-icon,.ctc-status-icon").remove(),e(s+" .ctc-status-icon").remove(),e(s).append('<span class="ctc-status-icon spinner is-active query-icon"></span>'),i.action=a.is_empty(e("#ctc_action").val())||"plugin"!==e("#ctc_action").val()?"ctc_query":"ctc_plgqry",i._wpnonce=e("#_wpnonce").val(),a.ajax_post(t,i)},save:function(t){var c,n,a,i,s,l=this,r={},o=e(t).attr("id");e(t).prop("disabled",!0),e(".ctc-query-icon,.ctc-status-icon").remove(),e(t).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner save-icon"></span>'),o.match(/ctc_configtype/)?(e(t).parents(".ctc-input-row").first().append('<span class="ctc-status-icon spinner save-icon"></span>'),r.ctc_configtype=e(t).val()):(c=e("#ctc_new_selectors"))&&"ctc_save_new_selectors"===e(t).attr("id")?(r.ctc_new_selectors=c.val(),(n=e("#ctc_sel_ovrd_query_selected"))&&(r.ctc_sel_ovrd_query=n.text()),l.reload=!0):(a=e("#ctc_child_imports"))&&"ctc_save_imports"===o?r.ctc_child_imports=a.val():"ctc_is_debug"===o?r.ctc_is_debug=e("#ctc_is_debug").is(":checked")?1:0:r=l.coalesce_inputs(t),e(".save-icon").addClass("is-active"),e("#ctc_sel_ovrd_selector_selected").find("#ctc_rewrite_selector").each(function(){i=e("#ctc_rewrite_selector").val(),s=e("#ctc_rewrite_selector_orig").val(),l.is_empty(i)||!i.toString().match(/\w/)?i=s:(r.ctc_rewrite_selector=i,l.reload=!0),e(".ctc-rewrite-toggle").text(l.getxt("rename")),e("#ctc_sel_ovrd_selector_selected").html(i)}),r.action=l.is_empty(e("#ctc_action").val())||"plugin"!==e("#ctc_action").val()?"ctc_update":"ctc_plugin",r._wpnonce=e("#_wpnonce").val(),l.ajax_post("qsid",r)},ajax_post:function(t,c,n){var a=this;e.ajax({url:window.ctcAjax.ajaxurl,data:c,dataType:a.is_empty(n)?"json":n,type:"POST"}).done(function(e){a.handle_success(t,e)}).fail(function(){a.handle_failure(t)}).always(function(){a.jqueryerr.length&&a.jquery_notice()})},handle_failure:function(t){var c=this;e(".query-icon, .save-icon").removeClass("spinner").addClass("failure"),e("input[type=submit], input[type=button], input[type=checkbox],.ctc-delete-input").prop("disabled",!1),e(".ajax-pending").removeClass("ajax-pending"),"preview"===t&&e("#view_parnt_options_panel,#view_child_options_panel").text(c.getxt("css_fail"))},handle_success:function(t,c){var n=this;e(".query-icon, .save-icon").removeClass("spinner"),e(".ajax-pending").removeClass("ajax-pending"),n.is_empty(c)?n.handle_failure(t):(e("#ctc_new_selectors").val(""),e(".query-icon, .save-icon").addClass("success"),e("input[type=submit], input[type=button], input[type=checkbox],.ctc-delete-input").prop("disabled",!1),e(c).each(function(){"function"==typeof n.update[this.obj]&&n.update[this.obj].call(n,this)}))},jquery_exception:function(e,t){var c=this,n=c.is_empty(e.lineNumber)?"":" line: "+e.lineNumber,a=c.is_empty(e.fileName)?"":" "+e.fileName.split(/\?/)[0];c.jqueryerr.push("<code><small>"+t+": "+e.message+a+n+"</small></code>")},jquery_notice:function(t){t=null;var c=this,n=[],a=[];c.jqueryerr.length&&(e("input[type=submit], input[type=button]").prop("disabled",!0),e("script").each(function(){var t=e(this).prop("src");c.is_empty(t)||!t.match(/jquery(\.min|\.js|\-?ui)/i)||t.match(/load\-scripts.php/)||n.push("<code><small>"+t.split(/\?/)[0]+"</small></code>")}),a.push("<strong>"+c.getxt("js")+"</strong> "+c.getxt("contact")),a.push(c.jqueryerr.join("<br/>")),n.length&&a.push(c.getxt("jquery")+"<br/>"+n.join("<br/>")),a.push(c.getxt("plugin"))),c.set_notice({error:a})},update:{qsid:function(t){var c,n,a,i,s=this;s.currqsid=t.key,s.currdata=t.data,e("#ctc_sel_ovrd_qsid").val(s.currqsid),s.is_empty(s.currdata.seq)?e("#ctc_child_load_order_container").empty():(c="ctc_ovrd_child_seq_"+s.currqsid,a=parseInt(s.currdata.seq),n='<input type="text" id="'+c+'" name="'+c+'" class="ctc-child-value" value="'+a+'" />',e("#ctc_child_load_order_container").html(n)),s.is_empty(s.currdata.value)?(i=!0,e("#ctc_sel_ovrd_rule_inputs").empty()):(i=!1,n="",e.each(s.currdata.value,function(e,t){t=null,n+=s.input_row(s.currqsid,e,"ovrd",s.currdata)}),e("#ctc_sel_ovrd_rule_inputs").html(n).find(".color-picker").each(function(){s.setup_spectrum(this)}),s.coalesce_inputs("#ctc_child_all_0_swatch")),s.reload&&(s.load_queries(),s.set_query(s.currdata.query),s.load_rules()),e("#ctc_sel_ovrd_selector_selected").text(s.currdata.selector),e(".ctc-rewrite-toggle").text(s.getxt("rename")),e(".ctc-rewrite-toggle").show(),i?e("#ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_new_rule,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").hide():e("#ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_new_rule,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").show()},rule_val:function(t){var c=this,n=e("#ctc_rule_menu_selected").text(),a='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+n+'">\n';c.is_empty(t.data)||(e.each(t.data,function(e,t){var i=c.decode_value(n,t);a+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+n+"_"+e+'">\n<div class="ctc-input-cell ctc-parent-value" id="ctc_'+e+"_parent_"+n+"_"+e+'">'+i.orig+'</div>\n<div class="ctc-input-cell">\n<div class="ctc-swatch ctc-specific" id="ctc_'+e+"_parent_"+n+"_"+e+'_swatch">'+c.getxt("swatch")+'</div></div>\n<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+n+"_"+e+'">'+c.getxt("selector")+'</a></div>\n<div id="ctc_selector_'+n+"_"+e+'_container" class="ctc-selector-container">\n<a href="#" id="ctc_selector_'+n+"_"+e+'_close" class="ctc-selector-handle ctc-exit" title="'+c.getxt("close")+'"></a><div id="ctc_selector_'+n+"_"+e+'_inner_container" class="ctc-selector-inner-container clearfix">\n<div id="ctc_status_val_qry_'+e+'"></div>\n<div id="ctc_selector_'+n+"_"+e+'_rows"></div>\n</div></div></div>\n'}),a+="</div>\n"),e("#ctc_rule_value_inputs").html(a).find(".ctc-swatch").each(function(){c.coalesce_inputs(this)})},val_qry:function(t){var c,n,a=this,i="";a.is_empty(t.data)||e.each(t.data,function(n,s){c=n,e.each(s,function(c,s){i+='<h4 class="ctc-query-heading">'+c+"</h4>\n",a.is_empty(s)||e.each(s,function(e,c){i+=a.input_row(e,n,t.key,c)})})}),n="#ctc_selector_"+c+"_"+t.key+"_rows",e(n).html(i).find(".color-picker").each(function(){a.setup_spectrum(this)}),e(n).find(".ctc-swatch").each(function(){a.coalesce_inputs(this)})},queries:function(t){e("#ctc_sel_ovrd_query").data("menu",t.data)},selectors:function(t){e("#ctc_sel_ovrd_selector").data("menu",t.data)},rules:function(t){e("#ctc_rule_menu").data("menu",t.data)},debug:function(t){e("#ctc_debug_box").val(e("#ctc_debug_box").val()+t.data)},preview:function(t){e("#view_"+t.key+"_options_panel").text(t.data)},dismiss:function(){}},bind_dismiss:function(t){var c=this,n=e(t),a=e('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'),i=window.commonL10n.dismiss||"";a.find(".screen-reader-text").text(i),n.append(a),a.on("click.wp-dismiss-notice",function(e){e.preventDefault(),c.dismiss_notice(t)})},dismiss_notice:function(t){e(t).fadeTo(100,0,function(){e(this).slideUp(100,function(){e(this).remove()})})},reset_handling:function(){e("#parnt_analysis_notice .notice, #child_analysis_notice .notice").slideUp(),e("#ctc_enqueue_enqueue").prop("checked",!0),e("#ctc_handling_primary").prop("checked",!0),e("#ctc_ignoreparnt").prop("checked",!1),e("#ctc_repairheader").prop("checked",!1)},init:function(){var t=this;if(!e("#ctc_theme_parnt").is("input")){try{e.widget("ctc.themeMenu",e.ui.selectmenu,{_renderItem:function(t,c){var n=e("<li>"),a=c.value.replace(/[^\w\-]/,"");return e("#ctc_theme_option_"+a).detach().appendTo(n),n.appendTo(t)}})}catch(c){t.jquery_exception(c,"Theme Menu")}try{e("#ctc_theme_parnt").themeMenu({select:function(e,c){t.reset_handling(),t.set_parent_menu(c.item)}})}catch(c){"function"==typeof themeMenu?e("#ctc_theme_parnt").themeMenu("destroy"):e("#ctc_theme_parnt-button").remove(),t.jquery_exception(c,"Parent Theme Menu")}if(t.is_empty(window.ctcAjax.themes.child))e("#ctc_child_name").length&&(e("#ctc_child_name").val(t.testname),e("#ctc_child_template").val(t.testslug));else try{e("#ctc_theme_child").themeMenu({select:function(e,c){t.reset_handling(),t.set_child_menu(c.item)}})}catch(c){"function"==typeof themeMenu?e("#ctc_theme_child").themeMenu("destroy"):e("#ctc_theme_child-button").remove(),t.jquery_exception(c,"Child Theme Menu")}}t.currparnt=e("#ctc_theme_parnt").val(),t.currchild=e("#ctc_theme_child").length?e("#ctc_theme_child").val():"",e("#ctc_main").on("click",".ctc-section-toggle",function(t){t.preventDefault(),e(this).parents(".ctc-input-row, .notice-warning, .updated, .error").first().find(".ctc-section-toggle").each(function(){e(this).toggleClass("open")});var c=e(this).attr("id").replace(/\d$/,"")+"_content";return e("#"+c).stop().slideToggle("fast"),!1}),e("#ctc_main").on("click",".ctc-upgrade-notice .notice-dismiss",function(){var c={action:"ctc_dismiss",_wpnonce:e("#_wpnonce").val()};t.ajax_post("dismiss",c)}),t.is_empty(t.jqueryerr)&&(e("#ctc_main").on("click",".ctc-selector-handle",function(c){if(c.preventDefault(),e(this).hasClass("ajax-pending"))return!1;e(this).addClass("ajax-pending");var n,a,i=e(this).attr("id").toString().replace("_close",""),s=i.toString().match(/_([^_]+)_(\d+)$/);e("#"+i+"_container").is(":hidden")&&(t.is_empty(s[1])||t.is_empty(s[2])||(n=s[1],a=s[2],t.query_css("val_qry",a,{rule:n}))),e("#"+i+"_container").fadeToggle("fast"),e(".ctc-selector-container").not("#"+i+"_container").fadeOut("fast")}),e("#ctc_main").on("click",".ctc-save-input[type=button], .ctc-delete-input",function(c){return c.preventDefault(),e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),t.save(this),!1)}),e("#ctc_main").on("keydown",".ctc-selector-container .ctc-child-value[type=text]",function(c){if(13===c.which){var n=e(this).parents(".ctc-selector-row").find(".ctc-save-input[type=button]").first();if(n.length)return c.preventDefault(),n.hasClass("ajax-pending")?!1:(n.addClass("ajax-pending"),t.save(n),!1)}}),e("#ctc_main").on("click",".ctc-selector-edit",function(c){return c.preventDefault(),e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),void t.set_qsid(this))}),e("#ctc_main").on("click",".ctc-rewrite-toggle",function(e){e.preventDefault(),t.selector_input_toggle(this)}),e("#ctc_main").on("click","#ctc_copy_selector",function(){var c=e("#ctc_sel_ovrd_selector_selected").text().trim();t.is_empty(c)||e("#ctc_new_selectors").val(e("#ctc_new_selectors").val()+"\n"+c+" {\n\n}")}),e("#ctc_main").on("click",".ctc-backup-theme",function(c){c.preventDefault(),t.existing?e("#ctc_export_theme").val(t.currchild):e("#ctc_export_theme").val(t.currparnt),e("#ctc_export_theme_form").submit()}),e("#ctc_configtype").on("change",function(){var c=e(this).val();if(t.is_empty(c)||"theme"===c){e(".ctc-theme-only, .ctc-themeonly-container").removeClass("ctc-disabled"),e(".ctc-theme-only, .ctc-themeonly-container input").prop("disabled",!1);try{e("#ctc_theme_parnt, #ctc_theme_child").themeMenu("enable")}catch(n){t.jquery_exception(n,"Theme Menu")}}else{e(".ctc-theme-only, .ctc-themeonly-container").addClass("ctc-disabled"),e(".ctc-theme-only, .ctc-themeonly-container input").prop("disabled",!0);try{e("#ctc_theme_parnt, #ctc_theme_child").themeMenu("disable")}catch(n){t.jquery_exception(n,"Theme Menu")}}}),e(".nav-tab").on("click",function(c){c.preventDefault(),e(".ctc-query-icon,.ctc-status-icon").remove();var n="#"+e(this).attr("id");t.focus_panel(n)}),e("#view_child_options, #view_parnt_options").on("click",function(){return e(this).hasClass("ajax-pending")?!1:(e(this).addClass("ajax-pending"),void t.css_preview(e(this).attr("id")))}),e("#ctc_load_form").on("submit",function(){return t.validate()}),e("#ctc_query_selector_form").on("submit",function(c){c.preventDefault();var n=e("#ctc_save_query_selector");return n.hasClass("ajax-pending")?!1:(n.addClass("ajax-pending"),t.save(n),!1)}),e("#ctc_rule_value_form").on("submit",function(e){return e.preventDefault(),!1}),e("#ctc_child_type_new,#ctc_child_type_existing,#ctc_child_type_duplicate,#ctc_child_type_reset").on("focus click",function(){t.reset_handling(),t.update_form()}),e("#ctc_is_debug").on("change",function(){e(this).is(":checked")?e("#ctc_debug_box").length||e("#ctc_debug_container").html('<textarea id="ctc_debug_box"></textarea>'):e("#ctc_debug_box").remove(),t.save(this)}),e(".ctc-live-preview").on("click",function(t){return t.stopImmediatePropagation(),t.preventDefault(),document.location=e(this).prop("href"),!1}),t.setup_menus(),e("input[type=submit], input[type=button]").prop("disabled",!1),t.scrolltop(),t.update_form()),t.jqueryerr.length&&t.jquery_notice()},testslug:"",testname:"",reload:!1,currquery:"base",currqsid:null,currdata:{},currparnt:"",currchild:"",existing:!1,jqueryerr:[],color_regx:"\\s+(\\#[a-f0-9]{3,6}|rgba?\\([\\d., ]+?\\)|hsla?\\([\\d%., ]+?\\)|[a-z]+)",border_regx:"(\\w+)(\\s+(\\w+))?",grad_regx:"(\\w+)"},e.chldthmanalyze={escrgx:function(e){return e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},trmcss:function(e){return"undefined"==typeof e?"":e.replace(/\-css$/,"")},show_loading:function(t,c){var n=e.chldthmcfg.existing?"child":"parnt",a=c?c:e.chldthmcfg.getname(n),i='<strong class="ctc_analyze_loading"><span class="spinner is-active"></span>'+e.chldthmcfg.getxt(t?"anlz1":"anlz2")+" "+a+"...</strong>";self.noticediv="",e("#"+n+"_analysis_notice").html(i)},hide_loading:function(){e(".ctc_analyze_loading").fadeTo(200,0,function(){e(this).slideUp(200,function(){e(this).remove()})})},setssl:function(e){return e.replace(/^https?/,window.ctcAjax.ssl?"https":"http")},analyze_theme:function(t){var c=this,n=Math.floor(e.now()/1e3),a="child"===t?e.chldthmcfg.currchild:e.chldthmcfg.currparnt,i="&template="+e.chldthmcfg.currparnt+"&stylesheet="+a+"&now="+n,s=c.setssl(window.ctcAjax.homeurl),l=s+i;c.analysis[t].url=l,e.get(l,function(n){c.parse_page(t,n),e(document).trigger("analysisdone")}).fail(function(n,i,s){c.analysis[t].signals.xhrgeterr=s,e.ajax({url:window.ctcAjax.ajaxurl,data:{action:"ctc_analyze",stylesheet:a,template:e.chldthmcfg.currparnt,_wpnonce:e("#_wpnonce").val()},dataType:"json",type:"POST"}).done(function(n){n.signals.httperr?(c.analysis[t].signals.failure=1,c.analysis[t].signals.httperr=n.signals.httperr):c.parse_page(t,n.body),e(document).trigger("analysisdone")}).fail(function(n,a,i){c.analysis[t].signals.failure=1,c.analysis[t].signals.xhrajaxerr=i,e(document).trigger("analysisdone")})})},parse_page:function(t,c){var n,a,i,s=this,l=window.ctcAjax.theme_uri.replace(/^https?:\/\//,""),r="child"===t?e.chldthmcfg.currchild:e.chldthmcfg.currparnt,o=s.escrgx(e.chldthmcfg.currparnt)+("child"===t?"|"+s.escrgx(r):""),_=new RegExp("<link( rel=[\"']stylesheet[\"'] id=['\"]([^'\"]+?)['\"])?[^>]+?"+s.escrgx(l)+"/("+o+")/([^\"']+\\.css)(\\?[^\"']+)?[\"'][^>]+>","gi"),d=/<br \/>\n[^\n]+?(fatal|strict|notice|warning|error)[\s\S]+?<br \/>/gi,u=0,h=0;
2
+ for((a=c.match(/BEGIN WP QUEUE\n([\s\S]*?)\nEND WP QUEUE/))?s.analysis[t].queue=a[1].split(/\n/):(s.analysis[t].queue=[],s.analysis[t].signals.thm_noqueue=1),(a=c.match(/BEGIN CTC IRREGULAR\n([\s\S]*?)\nEND CTC IRREGULAR/))?s.analysis[t].irreg=a[1].split(/\n/):s.analysis[t].irreg=[],c.match(/CHLD_THM_CFG_IGNORE_PARENT/)&&(s.analysis[t].signals.thm_ignoreparnt=1),c.match(/IS_CTC_THEME/)&&(s.analysis[t].signals.thm_is_ctc=1),c.match(/NO_CTC_STYLES/)&&(s.analysis[t].signals.thm_no_styles=1),c.match(/HAS_CTC_IMPORT/)&&(s.analysis[t].signals.thm_has_import=1),c=c.replace(/<!\-\-[\s\S]*?\-\->/g,"");n=d.exec(c);){var p=n[0].replace(/<.*?>/g,"");s.phperr[t].push(p),s.analysis[t].signals.err_php=1,p.match(/Fatal error/i)&&(s.analysis[t].signals.err_fatal=1)}for(;i=_.exec(c);){var m=s.trmcss(i[2]),g=i[3],f=i[4],y=e.chldthmcfg.currparnt===g?"parnt":"child",v=0;if(""===m||-1===e.inArray(m,s.analysis[t].queue))v=1;else if(0===m.indexOf("chld_thm_cfg")){f.match(/^ctc\-style([\-\.]min)?\.css$/)?(u=1,s.analysis[t].signals.ctc_sep_loaded=1):f.match(/^ctc\-genesis([\-\.]min)?\.css$/)?(u=1,s.analysis[t].signals.ctc_gen_loaded=1):m.match(/$chld_thm_cfg_ext/)?(s.analysis[t].signals.ctc_ext_loaded=1,s.analysis[t].deps[u].push([m,f])):"chld_thm_cfg_child"===m?(s.analysis[t].signals.ctc_child_loaded=1,s.analysis[t].deps[u].push([m,f])):"chld_thm_cfg_parent"===m&&(s.analysis[t].signals.ctc_parnt_loaded=1,s.analysis[t].deps[u].push([m,f]),u&&(s.analysis[t].signals.ctc_parnt_reorder=1));continue}if(f.match(/^style([\-\.]min)?\.css$/))u=1,"parnt"===y?v?s.analysis[t].signals.thm_parnt_loaded="thm_unregistered":(s.analysis[t].signals.thm_parnt_loaded=m,"child"===t&&s.analysis[t].signals.thm_child_loaded&&(s.analysis[t].signals.ctc_parnt_reorder=1)):s.analysis[t].signals.thm_child_loaded=v?"thm_unregistered":m,v?h?(s.analysis[t].signals.thm_past_wphead=1,s.analysis[t].deps[u].push(["thm_past_wphead",f])):(s.analysis[t].signals.thm_unregistered=1,s.analysis[t].deps[u].push(["thm_unregistered",f])):s.analysis[t].deps[u].push([m,f]);else if("ctc-test.css"===f)h=1;else{var w=null;v&&(w="dep_unregistered"),h&&(w=u?"css_past_wphead":"dep_past_wphead"),w?(s.analysis[t].signals[w]=1,m=w):s.dependencies[m]=f,s.analysis[t].deps[u].push([m,f])}}u||(s.analysis[t].signals.thm_notheme=1)},css_notice:function(){var t,c,n=this,a=e.chldthmcfg.existing?"child":"parnt",i=e.chldthmcfg.getname(a),s="",l={notices:[]},r={style:"notice-warning",headline:e.chldthmcfg.getxt("anlz3",i),errlist:""},o=0,_={},d="";if(n.analysis[a].signals.failure||n.analysis[a].signals.thm_noqueue&&!n.phperr[a].length)d=e.chldthmcfg.getxt("anlz33").replace(/%1/,'<a href="'+n.analysis[a].url+'" target="_new">').replace(/%2/,"</a>"),l.notices.push({headline:e.chldthmcfg.getxt("anlz4",i),msg:e.chldthmcfg.getxt("anlz5")+d,style:"notice-warning"});else{if(n.phperr[a].length&&(e.each(n.phperr[a],function(t,c){c.match(/Fatal error/i)&&(r.style="error",r.headline=e.chldthmcfg.getxt("anlz8",i)),r.errlist+=c+"\n"}),r.msg='<div style="background-color:#ffeebb;padding:6px"><div class="ctc-section-toggle" id="ctc_analysis_errs">'+e.chldthmcfg.getxt("anlz6")+'</div><div id="ctc_analysis_errs_content" style="display:none"><textarea>'+r.errlist+"</textarea></div></div>"+e.chldthmcfg.getxt("anlz7"),l.notices.push(r)),(n.analysis[a].signals.thm_past_wphead||n.analysis[a].signals.dep_past_wphead)&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz9"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz10")}),e("#ctc_repairheader").prop("checked",!0),e("#ctc_repairheader_container").show()),n.analysis[a].signals.thm_unregistered&&(n.analysis[a].signals.ctc_child_loaded||n.analysis[a].signals.ctc_sep_loaded||(l.notices.push({headline:e.chldthmcfg.getxt("anlz11"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz12")}),e("#ctc_repairheader_container").show(),e("#ctc_repairheader").prop("checked",!0))),"child"===a&&(n.analysis.child.signals.ctc_parnt_reorder&&(o=1),n.analysis.child.signals.ctc_child_loaded||n.analysis.child.signals.ctc_sep_loaded||n.analysis.child.signals.thm_child_loaded||(l.notices.push({headline:e.chldthmcfg.getxt("anlz13"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz14")}),o=1),n.analysis[a].signals.ctc_gen_loaded&&l.notices.push({headline:e.chldthmcfg.getxt("anlz31"),msg:e.chldthmcfg.getxt("anlz32"),style:"notice-warning"}),n.analysis.parnt.signals.thm_no_styles||n.analysis.child.signals.ctc_gen_loaded||n.analysis.child.signals.thm_parnt_loaded||n.analysis.child.signals.ctc_parnt_loaded||n.analysis.child.signals.thm_ignoreparnt||n.analysis.child.signals.thm_has_import||(l.notices.push({headline:e.chldthmcfg.getxt("anlz15"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz16")}),o=1),n.analysis.child.signals.thm_unregistered&&n.analysis.child.signals.thm_child_loaded&&"thm_unregistered"===n.analysis.child.signals.thm_child_loaded&&n.analysis.child.signals.ctc_child_loaded&&n.analysis.child.signals.ctc_parnt_loaded&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz28"),style:"notice-warning",msg:e.chldthmcfg.getxt("anlz29")}),e("#ctc_repairheader_container").show(),e("#ctc_repairheader").prop("checked",!0)),n.analysis.child.signals.thm_is_ctc||e("#ctc_child_type_duplicate").is(":checked")||l.notices.push({headline:e.chldthmcfg.getxt("anlz19"),msg:e.chldthmcfg.getxt("anlz20"),style:"notice-warning"})),(n.analysis[a].signals.ctc_sep_loaded||n.analysis[a].signals.ctc_gen_loaded)&&e("#ctc_handling_separate").prop("checked",!0),l.notices.length||l.notices.push({headline:""+("child"===a?e.chldthmcfg.getxt("anlz17"):e.chldthmcfg.getxt("anlz18")),style:"updated",msg:""}),"child"===a&&n.analysis.child.signals.thm_has_import&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz21"),msg:e.chldthmcfg.getxt("anlz22"),style:"notice-warning"}),e("#ctc_enqueue_import").prop("checked",!0)),n.analysis[a].signals.thm_ignoreparnt||n.analysis[a].signals.ctc_gen_loaded?(e("#ctc_ignoreparnt").prop("checked",!0),e("#ctc_enqueue_none").is(":checked")||(e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none")):e("#ctc_ignoreparnt").prop("checked",!1),!n.analysis[a].signals.ctc_sep_loaded&&!n.analysis[a].signals.ctc_gen_loaded&&!n.analysis[a].signals.ctc_child_loaded&&!n.analysis[a].signals.thm_unregistered&&!n.analysis[a].signals.thm_past_wphead&&n.analysis[a].deps[1].length){var u="";e.each(n.analysis[a].deps[1],function(e,t){t[1].match(/^style([\-\.]min)?\.css$/)||(u+="<li>"+t[1]+"</li>\n")}),""!==u&&(u="<ul class='howto' style='padding-left:1em'>\n"+u+"</ul>\n",l.notices.push({headline:e.chldthmcfg.getxt("anlz23"),msg:u+e.chldthmcfg.getxt("anlz24"),style:"updated"}))}"child"===a&&n.analysis[a].signals.thm_parnt_loaded&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz25"),msg:e.chldthmcfg.getxt("anlz26"),style:"updated"}),e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none"),n.analysis.parnt.signals.thm_no_styles&&(l.notices.push({headline:e.chldthmcfg.getxt("anlz27"),msg:e.chldthmcfg.getxt("anlz26"),style:"updated"}),e("#ctc_enqueue_none").prop("checked",!0),o=1,_.ctc_enqueue="none")}return s=encodeURIComponent(JSON.stringify(n.analysis)),e('input[name="ctc_analysis"]').val(s),_.ctc_analysis=s,n.is_success()&&o&&!n.resubmitting?(n.resubmitting=1,void n.resubmit(_)):(n.resubmitting=0,n.hide_loading(),e.each(l.notices,function(t,c){var n=e('<div class="'+c.style+' notice is-dismissible dashicons-before" ><h4>'+c.headline+"</h4>"+c.msg+"</div>");e.chldthmcfg.bind_dismiss(n),n.hide().appendTo("#"+a+"_analysis_notice").slideDown()}),t='<div style="background-color:#ddd;padding:6px"><div class="ctc-section-toggle" id="ctc_analysis_obj">'+e.chldthmcfg.getxt("anlz30")+'</div><div id="ctc_analysis_obj_content" style="display:none"><textarea style="font-family:monospace;font-size:10px">'+JSON.stringify(n.analysis,null,2)+"</textarea></div></div>",e(t).appendTo("#"+a+"_analysis_notice"),c="",e.each(n.dependencies,function(t,n){n&&(c+='<label><input class="ctc_checkbox ctc-themeonly" id="ctc_forcedep_'+t+'" name="ctc_forcedep[]" type="checkbox" value="'+t+'" autocomplete="off" '+(-1!==e.inArray(t,window.ctcAjax.forcedep)?"checked":"")+" />"+t+"</label><br/>\n")}),c.length?(e("#ctc_dependencies").html(c),e("#ctc_dependencies_container").show()):(e("#ctc_dependencies").empty(),e("#ctc_dependencies_container").hide()),e("#ctc_child_type_reset").is(":checked")||(e("#input_row_stylesheet_handling_container,#input_row_parent_handling_container,#ctc_child_header_parameters,#ctc_configure_submit").slideDown("fast"),e("#ctc_child_type_duplicate").is(":checked")?(e("#ctc_configure_submit .ctc-step").text("8"),e("#ctc_copy_theme_mods").find("input").prop("checked",!1)):(e("#ctc_configure_submit .ctc-step").text("9"),e("#ctc_copy_theme_mods").slideDown("fast")),e("#ctc_child_type_duplicate").is(":checked")||e("#ctc_child_type_new").is(":checked")?(e("#input_row_theme_slug").hide(),e("#input_row_new_theme_slug").slideDown("fast")):(e("#input_row_new_theme_slug").hide(),e("#input_row_theme_slug").slideDown("fast"))),void 0)},resubmit:function(t){var c=this;c.hide_loading(),c.show_loading(!0),t.action="ctc_update",t._wpnonce=e("#_wpnonce").val(),e.ajax({url:window.ctcAjax.ajaxurl,data:t,type:"POST"}).done(function(){c.hide_loading(),c.do_analysis()}).fail(function(){c.hide_loading()})},do_analysis:function(){var t=this;t.analysis={parnt:{deps:[[],[]],signals:{failure:0},queue:[],irreg:[]},child:{deps:[[],[]],signals:{failure:0},queue:[],irreg:[]}},t.phperr={parnt:[],child:[]},t.dependencies={},t.done=0,t.show_loading(!1),t.analyze_theme("parnt"),e.chldthmcfg.existing&&t.analyze_theme("child")},init:function(){var t=this;e(document).on("analysisdone",function(){t.done++,t.done>e.chldthmcfg.existing&&(t.done=0,t.css_notice())}),e("#ctc_main").on("click",".ctc-analyze-theme",function(){t.is_success()&&e.chldthmcfg.dismiss_notice(e(".ctc-success-response").parent(".notice")),t.do_analysis()}),t.is_success()&&!window.ctcAjax.pluginmode&&t.do_analysis()},analysis:{},done:0,resubmitting:0,dependencies:{},is_success:function(){return e(".ctc-success-response").length}},e("#request-filesystem-credentials-form").length||(e.chldthmcfg.init(),e.chldthmanalyze.init())}(jQuery);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: child, theme, child theme, child themes, custom styles, customize styles, customize theme, css, responsive, css editor, child theme editor, child theme generator, child theme creator, style, stylesheet, customizer, childtheme, childthemes
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 2.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -287,8 +287,10 @@ https://www.youtube.com/watch?v=iBiiAgsK4G4
287
  7. Files tab
288
 
289
  == Changelog ==
290
- = 2.2.2 =
291
- * Fix in Analyzer to help debugging
 
 
292
 
293
  = 2.2.1 =
294
  * Fix in javascript affecting Pro users
4
  Tags: child, theme, child theme, child themes, custom styles, customize styles, customize theme, css, responsive, css editor, child theme editor, child theme generator, child theme creator, style, stylesheet, customizer, childtheme, childthemes
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
287
  7. Files tab
288
 
289
  == Changelog ==
290
+ = 2.2.3 =
291
+ * Show raw results after Analysis to help debugging
292
+ * Fix javascript not escaping quotes in input fields
293
+ * Restored original ajax preview and added fallback method for cross-domain preview
294
 
295
  = 2.2.1 =
296
  * Fix in javascript affecting Pro users