Child Theme Creator by Orbisius - Version 1.4.9

Version Description

  • Tested with WP 5.1
  • Refactored syntax check. Don't create a temp file if exec functions are not available
Download this release

Release Info

Developer lordspace
Plugin Icon wp plugin Child Theme Creator by Orbisius
Version 1.4.9
Comparing to
See all releases

Code changes from version 1.4.8 to 1.4.9

Files changed (2) hide show
  1. orbisius-child-theme-creator.php +33 -30
  2. readme.txt +6 -2
orbisius-child-theme-creator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Orbisius Child Theme Creator
4
  Plugin URI: http://orbisius.com/products/wordpress-plugins/orbisius-child-theme-creator/
5
  Description: This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
6
- Version: 1.4.8
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
@@ -2698,51 +2698,54 @@ function orbisius_ctc_theme_editor_check_syntax($theme_file_contents) {
2698
  $status_rec = array(
2699
  'msg' => '',
2700
  'status' => 0,
 
2701
  );
2702
 
2703
  // Not a php file so don't do a syntax check.
2704
  if (stripos($theme_file_contents, '<?') === false) {
2705
  $status_rec['msg'] = 'Syntax OK.';
2706
  $status_rec['status'] = 1;
 
2707
  return $status_rec;
2708
  }
2709
 
 
 
 
 
 
 
 
2710
  $temp = tmpfile();
2711
  fwrite($temp, $theme_file_contents);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2712
 
2713
- if (function_exists('shell_exec') || function_exists('exec')) {
2714
- $ok = 0;
2715
- $meta_data = stream_get_meta_data($temp);
2716
- $file = $meta_data['uri'];
2717
- $file = escapeshellarg($file);
2718
- $cmd = "php -l $file";
2719
-
2720
- // we're relying on exec's return value so we can tell
2721
- // if the syntax is OK
2722
- if (function_exists('exec')) {
2723
- $exit_code = $output = 0;
2724
- $last_line = exec($cmd, $output, $exit_code);
2725
- $output = join('', $output); // this is an array with multiple lines including new lines
2726
-
2727
- $ok = empty($exit_code); // in linux 0 means success
2728
- } else { // this relies on parsing the php output but if a non-english locale is used this will fail.
2729
- $output = shell_exec($cmd . " 2>&1");
2730
- $ok = stripos($output, 'No syntax errors detected') !== false;
2731
- }
2732
-
2733
- $error = $output;
2734
 
2735
- if ($ok) {
2736
- $status_rec['status'] = 1;
2737
- $status_rec['msg'] = 'Syntax OK.';
2738
- } else {
2739
- $status_rec['msg'] = 'Syntax check failed. Error: ' . $error;
2740
- }
2741
- $status_rec['syntax_check_ran'] = 1;
2742
  } else {
2743
- $status_rec['msg'] = 'Syntax check: n/a. functiona: exec() and shell_exec() are not available.';
2744
  }
2745
 
 
 
2746
  fclose($temp); // this removes the file
2747
 
2748
  return $status_rec;
3
  Plugin Name: Orbisius Child Theme Creator
4
  Plugin URI: http://orbisius.com/products/wordpress-plugins/orbisius-child-theme-creator/
5
  Description: This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
6
+ Version: 1.4.9
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
2698
  $status_rec = array(
2699
  'msg' => '',
2700
  'status' => 0,
2701
+ 'syntax_check_ran' => 0,
2702
  );
2703
 
2704
  // Not a php file so don't do a syntax check.
2705
  if (stripos($theme_file_contents, '<?') === false) {
2706
  $status_rec['msg'] = 'Syntax OK.';
2707
  $status_rec['status'] = 1;
2708
+ $status_rec['non_php_file'] = 1;
2709
  return $status_rec;
2710
  }
2711
 
2712
+ if (function_exists('shell_exec') || function_exists('exec')) {
2713
+ // OK
2714
+ } else {
2715
+ $status_rec['msg'] = 'Syntax check: n/a. function: exec() and shell_exec() are not available.';
2716
+ return $status_rec;
2717
+ }
2718
+
2719
  $temp = tmpfile();
2720
  fwrite($temp, $theme_file_contents);
2721
+ $meta_data = stream_get_meta_data($temp);
2722
+ $file = $meta_data['uri'];
2723
+ $file = escapeshellarg($file);
2724
+ $cmd = "php -l $file"; // what about different binaries (cpanel or other control panel)? some of them are slow or hang for 5sec
2725
+
2726
+ // we're relying on exec's return value so we can tell
2727
+ // if the syntax is OK
2728
+ if (function_exists('exec')) {
2729
+ $exit_code = $output = 0;
2730
+ $last_line = exec($cmd, $output, $exit_code);
2731
+ $output = join('', $output); // this is an array with multiple lines including new lines
2732
+ $ok = empty($exit_code); // in linux 0 means success
2733
+ } else { // this relies on parsing the php output but if a non-english locale is used this will fail.
2734
+ $output = shell_exec($cmd . " 2>&1");
2735
+ $ok = stripos($output, 'No syntax errors detected') !== false;
2736
+ }
2737
 
2738
+ $error = $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2739
 
2740
+ if ($ok) {
2741
+ $status_rec['status'] = 1;
2742
+ $status_rec['msg'] = 'Syntax OK.';
 
 
 
 
2743
  } else {
2744
+ $status_rec['msg'] = 'Syntax check failed. Error: ' . $error;
2745
  }
2746
 
2747
+ $status_rec['syntax_check_ran'] = 1;
2748
+
2749
  fclose($temp); // this removes the file
2750
 
2751
  return $status_rec;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: lordspace,orbisius
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
4
  Tags: theme,child theme,childtheme,childthemes,parent theme,child themes,CSS,styling,resposive design,design,custom themeing, shared hosting,theme editor theme,themes,wp,wordpress,orbisius,theme creator,custom theme,theme generator,css,css editor
5
  Requires at least: 3.4
6
- Tested up to: 4.9
7
- Stable tag: 1.4.8
8
  License: GPLv2 or later
9
 
10
  Create Child Themes quickly and easily from any theme that you have currently installed on your site/blog.
@@ -166,6 +166,10 @@ Todo
166
 
167
  == Changelog ==
168
 
 
 
 
 
169
  = 1.4.8 =
170
  * Fixed missing image for themes that provide screenshots in other than .png format. Thanks Nick Greaves for reporting this.
171
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
4
  Tags: theme,child theme,childtheme,childthemes,parent theme,child themes,CSS,styling,resposive design,design,custom themeing, shared hosting,theme editor theme,themes,wp,wordpress,orbisius,theme creator,custom theme,theme generator,css,css editor
5
  Requires at least: 3.4
6
+ Tested up to: 5.1
7
+ Stable tag: 1.4.9
8
  License: GPLv2 or later
9
 
10
  Create Child Themes quickly and easily from any theme that you have currently installed on your site/blog.
166
 
167
  == Changelog ==
168
 
169
+ = 1.4.9 =
170
+ * Tested with WP 5.1
171
+ * Refactored syntax check. Don't create a temp file if exec functions are not available
172
+
173
  = 1.4.8 =
174
  * Fixed missing image for themes that provide screenshots in other than .png format. Thanks Nick Greaves for reporting this.
175