Child Theme Creator by Orbisius - Version 1.0.5

Version Description

  • Tested under WordPress Multisite environment
  • Added menus in WordPress Multisite environment
  • Added an option for network wide theme activation (which is mutually exclusive with make theme active).
  • Added double editor for easy theme editing.
  • Added Orbisius: Edit to the theme list
  • Show a notice in the plugins area to let the user know how to work with the plugin. On multisite the message is shown only on the network site.
  • Aded minimized versions for main css and js
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

assets/main.css CHANGED
@@ -100,4 +100,19 @@
100
 
101
  .orbisius_child_theme_creator_container .saving_action {
102
  background: #ccc;
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  .orbisius_child_theme_creator_container .saving_action {
102
  background: #ccc;
103
+ }
104
+
105
+ /* Theme Editor */
106
+ .orbisius_ctc_theme_editor_container .highlight {
107
+ background: #FFFF33;
108
+ }
109
+
110
+ .orbisius_ctc_theme_editor_container .app-dialog-button-ok {
111
+ background: green !important;
112
+ color: white !important;
113
+ }
114
+
115
+ .orbisius_ctc_theme_editor_container .app-dialog-button-cancel {
116
+ background: red !important;
117
+ color: white !important;
118
+ }
assets/main.js CHANGED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Theme Editor Code */
2
+ jQuery(document).ready(function($) {
3
+ orbisius_ctc_theme_editor_setup();
4
+ });
5
+
6
+ /**
7
+ * This is called when on doc ready.
8
+ * It setups the actoins that we want to handle e.g. what happens when
9
+ * somebody selects something from the dropdowns.
10
+ * @returns {undefined}
11
+ */
12
+ function orbisius_ctc_theme_editor_setup() {
13
+ var $ = jQuery;
14
+
15
+ var current_theme_dir = $('#theme_1').val();
16
+
17
+ if (current_theme_dir != '') {
18
+ // prefill dropdown files with the current theme's files.
19
+ app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
20
+ }
21
+
22
+ // Change theme selection
23
+ $('#theme_1').on("change", function () {
24
+ app_load('#orbisius_ctc_theme_editor_theme_1_form', 'generate_dropdown', '#theme_1_file', app_handle_theme_change);
25
+ });
26
+
27
+ $('#orbisius_ctc_theme_editor_theme_1_form').submit(function () {
28
+ app_load('#orbisius_ctc_theme_editor_theme_1_form', 'save_file', '#theme_1_file_contents');
29
+
30
+ return false;
31
+ });
32
+
33
+ var current_theme_dir = $('#theme_2').val();
34
+
35
+ if (current_theme_dir != '') {
36
+ app_load('#orbisius_ctc_theme_editor_theme_2_form', 'generate_dropdown', '#theme_2_file', app_handle_theme_change);
37
+ }
38
+
39
+ // Change theme selection
40
+ $('#theme_2').on("change", function () {
41
+ app_load('#orbisius_ctc_theme_editor_theme_2_form', 'generate_dropdown', '#theme_2_file', app_handle_theme_change);
42
+ });
43
+
44
+ $('#orbisius_ctc_theme_editor_theme_2_form').submit(function () {
45
+ app_load('#orbisius_ctc_theme_editor_theme_2_form', 'save_file', '#theme_2_file_contents');
46
+
47
+ return false;
48
+ });
49
+ }
50
+
51
+ /**
52
+ * When the theme is selected we need to check if there is a file selected so we can load it.
53
+ * When the file dropdown is changed/selected we'll load the selected file.
54
+ *
55
+ * @returns {undefined}
56
+ */
57
+ function app_handle_theme_change(form_id, action, target_container, result) {
58
+ var form_prefix = jQuery(form_id) ? jQuery(form_id).attr('id') : ''; // orbisius_ctc_theme_editor_theme_1_form
59
+ form_prefix = form_prefix.replace(/.+(theme[-_]*\d+).*/, '$1');
60
+ form_prefix = '#' + form_prefix + '_'; // jQuery ID prefix. Res: #theme_2_
61
+
62
+ var cur_file = jQuery(form_prefix + '_file').val();
63
+
64
+ if (cur_file !== '') {
65
+ app_load(form_id, 'load_file', form_prefix + 'file_contents');
66
+ }
67
+
68
+ jQuery(form_prefix + 'file').on("change", function () {
69
+ app_load(form_id, 'load_file', form_prefix + 'file_contents');
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Sends ajax call to WP. Different requests append sub_cmd because WP is used key: 'action'.
75
+ * Depending on the target element a different method for setting the value is used.
76
+ *
77
+ * @param {type} form_id
78
+ * @param {type} action
79
+ * @param {type} target_container
80
+ * @param {type} callback
81
+ * @returns {undefined}
82
+ */
83
+ function app_load(form_id, action, target_container, callback) {
84
+ var result = 'Loading...';
85
+ var undo_readonly = 0;
86
+
87
+ if (action.indexOf('save') >= 0) { // save action
88
+ if (jQuery(target_container).is("input,textarea")) {
89
+ jQuery(target_container).attr('readonly', 'readonly');
90
+ jQuery(target_container).addClass('saving_action');
91
+ }
92
+
93
+ jQuery('.status', jQuery(target_container).parent()).html(result);
94
+ } else {
95
+ if (jQuery(target_container).is("input,textarea")) {
96
+ jQuery(target_container).val(result);
97
+ jQuery(target_container).addClass('saving_action');
98
+ } else if (jQuery(target_container).is("select")) { // for loading. we want to override options of the select
99
+ jQuery(target_container + ' option').text(result);
100
+ } else {
101
+ jQuery(target_container).html(result);
102
+ }
103
+ }
104
+
105
+ jQuery.ajax({
106
+ type : "post",
107
+ //dataType : "json",
108
+ url : ajaxurl, // contains all the necessary params
109
+ data : jQuery(form_id).serialize() + '&action=orbisius_ctc_theme_editor_ajax&sub_cmd=' + escape(action),
110
+
111
+ success : function (result) {
112
+ if (jQuery(target_container).is("input,textarea")) {
113
+ jQuery(target_container).val(result);
114
+ } else {
115
+ jQuery(target_container).html(result);
116
+ }
117
+
118
+ if (typeof callback != 'undefined') {
119
+ callback(form_id, action, target_container, result);
120
+ }
121
+ },
122
+
123
+ complete : function (result) { // this is always called
124
+ jQuery(target_container).removeClass('saving_action');
125
+
126
+ if (action.indexOf('save') >= 0) { // save action
127
+ if (jQuery(target_container).is("input,textarea")) {
128
+ jQuery(target_container).removeAttr('readonly');
129
+
130
+ // http://stackoverflow.com/questions/2432749/jquery-delay-not-delaying
131
+ jQuery('.status', jQuery(target_container).parent()).html('Saved.');
132
+
133
+ setTimeout(function () {
134
+ jQuery('.status', jQuery(target_container).parent()).empty();
135
+ }, 2000);
136
+ }
137
+ }
138
+ }
139
+ });
140
+ }
assets/main.min.css ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .orbisius_child_theme_creator_container .app-hide{display:none}
2
+ .orbisius_child_theme_creator_container .app-hide-force{display:none!important}
3
+ .orbisius_child_theme_creator_container .app-form-field-error{border-color:red}
4
+ .orbisius_child_theme_creator_container .app-serious-notice{color:red;font-weight:700}
5
+ .orbisius_child_theme_creator_container .app-alert-error{background:#D54E21;border:1px solid #eee;color:#FFF;text-align:center;padding:3px}
6
+ .orbisius_child_theme_creator_container .app-alert-success{background:green;border:1px solid #eee;color:#FFF;text-align:center;padding:3px}
7
+ .orbisius_child_theme_creator_container .app-alert-success a{color:#FFF}
8
+ .orbisius_child_theme_creator_container .app-alert-notice{background:#FFEC8B;border:1px solid #eee;text-align:center;padding:3px}
9
+ .orbisius_child_theme_creator_container .app-button-positive{background:green;color:#FFF;text-decoration:none;padding:3px}
10
+ .orbisius_child_theme_creator_container .app-button-negative{background:red;color:#FFF;text-decoration:none;padding:3px}
11
+ .orbisius_child_theme_creator_container .app-button-left,.app-align-left{float:left}
12
+ .orbisius_child_theme_creator_container .app-button-right,.orbisius_child_theme_creator_container .app-align-right{float:right}
13
+ .orbisius_child_theme_creator_container .app-button-container{background:#ccc;margin-top:15px;margin-bottom:15px;padding:10px}
14
+ .orbisius_child_theme_creator_container .available-theme{border:2px solid #FFF;padding:10px}
15
+ .orbisius_child_theme_creator_container .available-theme:hover{border:2px solid #444;background:#ccc}
16
+ .orbisius_child_theme_creator_container .saving_action{background:#ccc}
17
+ .orbisius_child_theme_creator_container .highlight,.orbisius_ctc_theme_editor_container .highlight{background:#FF3}
18
+ .orbisius_child_theme_creator_container .app-dialog-button-ok,.orbisius_ctc_theme_editor_container .app-dialog-button-ok{background:green!important;color:#FFF!important}
19
+ .orbisius_child_theme_creator_container .app-dialog-button-cancel,.orbisius_ctc_theme_editor_container .app-dialog-button-cancel{background:red!important;color:#FFF!important}
assets/main.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function orbisius_ctc_theme_editor_setup(){var e=jQuery;var t=e("#theme_1").val();if(t!=""){app_load("#orbisius_ctc_theme_editor_theme_1_form","generate_dropdown","#theme_1_file",app_handle_theme_change)}e("#theme_1").on("change",function(){app_load("#orbisius_ctc_theme_editor_theme_1_form","generate_dropdown","#theme_1_file",app_handle_theme_change)});e("#orbisius_ctc_theme_editor_theme_1_form").submit(function(){app_load("#orbisius_ctc_theme_editor_theme_1_form","save_file","#theme_1_file_contents");return false});var t=e("#theme_2").val();if(t!=""){app_load("#orbisius_ctc_theme_editor_theme_2_form","generate_dropdown","#theme_2_file",app_handle_theme_change)}e("#theme_2").on("change",function(){app_load("#orbisius_ctc_theme_editor_theme_2_form","generate_dropdown","#theme_2_file",app_handle_theme_change)});e("#orbisius_ctc_theme_editor_theme_2_form").submit(function(){app_load("#orbisius_ctc_theme_editor_theme_2_form","save_file","#theme_2_file_contents");return false})}function app_handle_theme_change(e,t,n,r){var i=jQuery(e)?jQuery(e).attr("id"):"";i=i.replace(/.+(theme[-_]*\d+).*/,"$1");i="#"+i+"_";var s=jQuery(i+"_file").val();if(s!==""){app_load(e,"load_file",i+"file_contents")}jQuery(i+"file").on("change",function(){app_load(e,"load_file",i+"file_contents")})}function app_load(e,t,n,r){var i="Loading...";var s=0;if(t.indexOf("save")>=0){if(jQuery(n).is("input,textarea")){jQuery(n).attr("readonly","readonly");jQuery(n).addClass("saving_action")}jQuery(".status",jQuery(n).parent()).html(i)}else{if(jQuery(n).is("input,textarea")){jQuery(n).val(i);jQuery(n).addClass("saving_action")}else if(jQuery(n).is("select")){jQuery(n+" option").text(i)}else{jQuery(n).html(i)}}jQuery.ajax({type:"post",url:ajaxurl,data:jQuery(e).serialize()+"&action=orbisius_ctc_theme_editor_ajax&sub_cmd="+escape(t),success:function(i){if(jQuery(n).is("input,textarea")){jQuery(n).val(i)}else{jQuery(n).html(i)}if(typeof r!="undefined"){r(e,t,n,i)}},complete:function(e){jQuery(n).removeClass("saving_action");if(t.indexOf("save")>=0){if(jQuery(n).is("input,textarea")){jQuery(n).removeAttr("readonly");jQuery(".status",jQuery(n).parent()).html("Saved.");setTimeout(function(){jQuery(".status",jQuery(n).parent()).empty()},2e3)}}}})}jQuery(document).ready(function(e){orbisius_ctc_theme_editor_setup()})
nbproject/private/private.xml CHANGED
@@ -10,4 +10,9 @@
10
  </bookmark>
11
  </file>
12
  </editor-bookmarks>
 
 
 
 
 
13
  </project-private>
10
  </bookmark>
11
  </file>
12
  </editor-bookmarks>
13
+ <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
14
+ <file>file:/C:/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/readme.txt</file>
15
+ <file>file:/C:/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/assets/main.css</file>
16
+ <file>file:/C:/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/orbisius-child-theme-creator.php</file>
17
+ </open-files>
18
  </project-private>
orbisius-child-theme-creator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Orbisius Child Theme Creator
4
  Plugin URI: http://club.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.0.4
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
@@ -28,25 +28,31 @@
28
  // Set up plugin
29
  add_action('admin_init', 'orbisius_child_theme_creator_admin_init');
30
  add_action('admin_menu', 'orbisius_child_theme_creator_setup_admin');
 
31
  add_action('wp_footer', 'orbisius_child_theme_creator_add_plugin_credits', 1000); // be the last in the footer
32
  add_action('admin_notices', 'orbisius_child_theme_creator_admin_notice_message');
 
 
 
 
33
 
34
  /**
35
- * Show a notice in the admin if the chat hasn't been installed yet.
 
36
  */
37
  function orbisius_child_theme_creator_admin_notice_message() {
38
- $plugin_data = get_plugin_data(__FILE__);
 
 
39
  $name = $plugin_data['Name'];
 
40
 
41
- $upload_dir_rec = wp_upload_dir();
42
- $chat_installed = file_exists($upload_dir_rec['basedir'] . '.ht-orbisius-child_theme_creator');
43
-
44
- // show it everywhere but not on our page.
45
- //if (stripos($_SERVER['REQUEST_URI'], basename(__FILE__)) === false) {
46
- if (!$chat_installed && (stripos($_SERVER['REQUEST_URI'], 'plugins.php') !== false)) {
47
- $just_link = 'tools.php?page=' . plugin_basename(__FILE__);
48
  echo "<div class='updated'><p>$name has been installed. To create a child theme go to
49
- <a href='$just_link'><strong>Tools &rarr; $name</strong></a></p></div>";
50
  }
51
  }
52
 
@@ -60,14 +66,14 @@ function orbisius_child_theme_creator_admin_notice_message() {
60
  function orbisius_child_theme_creator_admin_init() {
61
  $suffix = '';
62
  $dev = empty($_SERVER['DEV_ENV']) ? 0 : 1;
63
- //$suffix = $dev ? '' : '.min';
64
 
65
  wp_register_style('orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.css", __FILE__), false);
66
  wp_enqueue_style('orbisius_child_theme_creator');
67
 
68
- /* wp_enqueue_script( 'jquery' );
69
- wp_register_script( 'orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery', ), '1.0', true);
70
- wp_enqueue_script( 'orbisius_child_theme_creator' ); */
71
  }
72
 
73
  /**
@@ -77,26 +83,45 @@ function orbisius_child_theme_creator_admin_init() {
77
  * @since 0.1
78
  */
79
  function orbisius_child_theme_creator_setup_admin() {
80
- add_options_page('Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', __FILE__, 'orbisius_child_theme_creator_settings_page');
81
- add_theme_page('Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', __FILE__, 'orbisius_child_theme_creator_tools_action');
82
-
83
- add_submenu_page('tools.php', 'Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', __FILE__, 'orbisius_child_theme_creator_tools_action');
84
 
85
  // when plugins are show add a settings link near my plugin for a quick access to the settings page.
86
  add_filter('plugin_action_links', 'orbisius_child_theme_creator_add_plugin_settings_link', 10, 2);
 
 
 
 
87
  }
88
 
89
  // Add the ? settings link in Plugins page very good
90
  function orbisius_child_theme_creator_add_plugin_settings_link($links, $file) {
91
  if ($file == plugin_basename(__FILE__)) {
92
- $prefix = 'tools.php?page=' . plugin_basename(__FILE__);
93
- $dashboard_link = "<a href=\"{$prefix}\">" . 'Create a Child Theme' . '</a>';
94
- array_unshift($links, $dashboard_link);
 
95
  }
96
 
97
  return $links;
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  // Generates Options for the plugin
101
  function orbisius_child_theme_creator_settings_page() {
102
  ?>
@@ -116,7 +141,7 @@ function orbisius_child_theme_creator_settings_page() {
116
  </p></div>
117
 
118
  <div class="updated0"><p>
119
- This plugin doesn't currently have any configuration options. To use it go to <strong>Tools &rarr; Orbisius Child Theme Creator</strong>
120
  </p></div>
121
 
122
  <h2>Video Demo</h2>
@@ -264,11 +289,14 @@ function orbisius_child_theme_creator_tools_action() {
264
  wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
265
  }
266
 
267
- if ( is_multisite() && ! is_network_admin() ) {
268
- $next_url = network_admin_url( 'theme-install.php' );
 
 
269
 
270
  if (headers_sent()) {
271
- $success = "You need more permissions. <a href='$next_url'>Continue</a>";
 
272
  wp_die($success);
273
  } else {
274
  wp_redirect($next_url);
@@ -312,7 +340,7 @@ function orbisius_child_theme_creator_tools_action() {
312
  $success[] = "The child theme has been successfully created.";
313
  $success[] = $installer->get_details();
314
 
315
- if (!empty($_REQUEST['switch'])) {
316
  $child_theme_base_dir = $installer->get_child_base_dir();
317
  $theme = wp_get_theme($child_theme_base_dir);
318
 
@@ -329,6 +357,12 @@ function orbisius_child_theme_creator_tools_action() {
329
  wp_safe_redirect($next_url);
330
  exit;
331
  }
 
 
 
 
 
 
332
  }
333
  } catch (Exception $e) {
334
  $errors[] = "There was an error during the chat installation.";
@@ -341,9 +375,9 @@ function orbisius_child_theme_creator_tools_action() {
341
  }
342
  }
343
 
344
- if ( is_multisite() ) {
345
  $msg .= orbisius_child_theme_creator_util::msg("You are running WordPress in MultiSite configuration.
346
- Orbisius Child Theme Creator hasn't been tested in WordPress multisite setup.", 2);
347
  }
348
 
349
  if (!empty($errors)) {
@@ -358,20 +392,18 @@ function orbisius_child_theme_creator_tools_action() {
358
  <h2>Orbisius Child Theme Creator
359
 
360
  <div class="" style="float: right;padding: 3px; _border: 1px solid #D54E21;">
361
- Cool Links:
362
- <a href="http://club.orbisius.com/products/wordpress-plugins/orbisius-theme-editor/?utm_source=orbisius-child-theme-creator&utm_medium=action_screen&utm_campaign=product"
363
- target="_blank" title="Opens in new tab/window. This plugin allows you to quickly edit two theme files at once and copy snippets from each one. Try it.">Orbisius Theme Editor</a>
364
-
365
- | <a href="http://qsandbox.com/?utm_source=orbisius-child-theme-creator&utm_medium=action_screen&utm_campaign=product"
366
  target="_blank" title="Opens in new tab/window. qSandbox is a FREE service that allows you to setup a test/sandbox WordPress site in 2 seconds. No technical knowledge is required.
367
- Test themes and plugins before you actually put them on your site">Free Test WordPress Site</a> (2sec)
368
 
369
- | <a href="#help" title="[new window]">Help</a>
 
370
 
 
371
  </div>
372
  </h2>
373
 
374
- <hr />
375
  <?php echo $msg; ?>
376
  <div class="updated">
377
  <p>
@@ -415,6 +447,11 @@ Test themes and plugins before you actually put them on your site">Free Test Wor
415
  ? $author_name
416
  : "<a title='Visit author homepage' href='$author_uri' target='_blank'>$author_name</a>";
417
 
 
 
 
 
 
418
  $buff .= "<div class='available-theme'>\n";
419
  $buff .= "<form action='$create_url' method='post'>\n";
420
  $buff .= "<img class='screenshot' src='$src' alt='' />\n";
@@ -430,24 +467,43 @@ Test themes and plugins before you actually put them on your site">Free Test Wor
430
  $adv_container_id = md5($src);
431
 
432
  $buff .= "
433
- <li><a href='javascript:void(0)' onclick='jQuery(\"#orbisius_ctc_act_adv_$adv_container_id\").slideToggle(\"slow\");'>+ Advanced</a> (show/hide)
434
- <div id='orbisius_ctc_act_adv_$adv_container_id' class='app-hide'>
435
- <label><input type='checkbox' id='orbisius_child_theme_creator_copy_functions_php' name='copy_functions_php' value='1' /> Copy functons.php
436
- (<span class='app-serious-notice'><strong>Danger</strong>: if the theme doesn't support
437
- <a href='http://wp.tutsplus.com/tutorials/creative-coding/understanding-wordpress-pluggable-functions-and-their-usage/'
438
- target='_blank'>pluggable functions</a> this <strong>will crash your site</strong>.</span>)</label>
439
- </li>\n
440
- ";
 
 
 
 
 
 
 
 
441
  }
442
 
443
- $buff .= "<li><label><input type='checkbox' id='orbisius_child_theme_creator_switch' name='switch' value='1' /> Switch theme to the new theme after it is created</label></li>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  $buff .= "<li> <button type='submit' class='button button-primary'>Create Child Theme</button> </li>\n";
445
  } else {
446
- $buff .= "<li>&nbsp;</li>\n";
447
  $buff .= "<li>[child theme]</li>\n";
448
  }
449
-
450
- $buff .= "<li>Version: $theme_obj->Version</li>\n";
451
  $buff .= "</ul>\n";
452
  $buff .= "</div> <!-- /action-links -->\n";
453
  $buff .= "</form> <!-- /form -->\n";
@@ -459,8 +515,6 @@ Test themes and plugins before you actually put them on your site">Free Test Wor
459
  echo $buff;
460
  ?>
461
 
462
- <hr />
463
-
464
  <a name="help"></a>
465
  <h2>Support &amp; Premium Plugins</h2>
466
  <div class="updated">
@@ -471,7 +525,7 @@ Test themes and plugins before you actually put them on your site">Free Test Wor
471
  </div>
472
  <?php if (1) : ?>
473
  <?php
474
- $plugin_data = get_plugin_data(__FILE__);
475
 
476
  $app_link = urlencode($plugin_data['PluginURI']);
477
  $app_title = urlencode($plugin_data['Name']);
@@ -758,6 +812,45 @@ class orbisius_child_theme_creator {
758
  * Util funcs
759
  */
760
  class orbisius_child_theme_creator_util {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
  /**
762
  * Recursive function to copy (all subdirectories and contents).
763
  * It doesn't create folder in the target folder.
@@ -795,7 +888,7 @@ class orbisius_child_theme_creator_util {
795
  copy($src, $dest);
796
  }
797
  }
798
-
799
  /**
800
  * Loads files from a directory but skips . and ..
801
  */
@@ -886,6 +979,9 @@ class orbisius_child_theme_creator_html {
886
  $selected .= ' disabled="disabled" ';
887
  }
888
 
 
 
 
889
  if (preg_match('#__sys_([\w-]+)#si', $label, $matches)) {
890
  $label = str_replace($matches[0], '', $label);
891
  $selected .= " class='$matches[1]' ";
@@ -899,5 +995,247 @@ class orbisius_child_theme_creator_html {
899
 
900
  return $html;
901
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
 
903
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Orbisius Child Theme Creator
4
  Plugin URI: http://club.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.0.5
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
28
  // Set up plugin
29
  add_action('admin_init', 'orbisius_child_theme_creator_admin_init');
30
  add_action('admin_menu', 'orbisius_child_theme_creator_setup_admin');
31
+ add_action('network_admin_menu', 'orbisius_child_theme_creator_setup_admin');
32
  add_action('wp_footer', 'orbisius_child_theme_creator_add_plugin_credits', 1000); // be the last in the footer
33
  add_action('admin_notices', 'orbisius_child_theme_creator_admin_notice_message');
34
+ add_action('network_admin_notices', 'orbisius_child_theme_creator_admin_notice_message');
35
+
36
+ add_action( 'wp_ajax_orbisius_ctc_theme_editor_ajax', 'orbisius_ctc_theme_editor_ajax');
37
+ add_action( 'wp_ajax_nopriv_orbisius_ctc_theme_editor_ajax', 'orbisius_ctc_theme_editor_ajax');
38
 
39
  /**
40
+ * Show a notice in the plugins area to let the user know how to work with the plugin.
41
+ * On multisite the message is shown only on the network site.
42
  */
43
  function orbisius_child_theme_creator_admin_notice_message() {
44
+ global $pagenow;
45
+
46
+ $plugin_data = orbisius_child_theme_creator_get_plugin_data();
47
  $name = $plugin_data['Name'];
48
+ $show_notice = 1; // todo check cfg for dismiss
49
 
50
+ if ($show_notice
51
+ && ( stripos($pagenow, 'plugins.php') !== false )
52
+ && ( !is_multisite() || ( is_multisite() && is_network_admin() ) ) ) {
53
+ $just_link = orbisius_child_theme_creator_util::get_create_child_pages_link();
 
 
 
54
  echo "<div class='updated'><p>$name has been installed. To create a child theme go to
55
+ <a href='$just_link'><strong>Appearance &rarr; $name</strong></a></p></div>";
56
  }
57
  }
58
 
66
  function orbisius_child_theme_creator_admin_init() {
67
  $suffix = '';
68
  $dev = empty($_SERVER['DEV_ENV']) ? 0 : 1;
69
+ $suffix = $dev ? '' : '.min';
70
 
71
  wp_register_style('orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.css", __FILE__), false);
72
  wp_enqueue_style('orbisius_child_theme_creator');
73
 
74
+ wp_enqueue_script( 'jquery' );
75
+ wp_register_script( 'orbisius_child_theme_creator', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery', ), '1.0', true);
76
+ wp_enqueue_script( 'orbisius_child_theme_creator' );
77
  }
78
 
79
  /**
83
  * @since 0.1
84
  */
85
  function orbisius_child_theme_creator_setup_admin() {
86
+ add_options_page('Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', 'orbisius_child_theme_creator_settings_page', 'orbisius_child_theme_creator_settings_page');
87
+ add_theme_page('Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', 'orbisius_child_theme_creator_themes_action', 'orbisius_child_theme_creator_tools_action');
88
+ add_submenu_page('tools.php', 'Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', 'orbisius_child_theme_creator_tools_action', 'orbisius_child_theme_creator_tools_action');
 
89
 
90
  // when plugins are show add a settings link near my plugin for a quick access to the settings page.
91
  add_filter('plugin_action_links', 'orbisius_child_theme_creator_add_plugin_settings_link', 10, 2);
92
+
93
+ // Theme Editor
94
+ add_theme_page( 'Orbisius Theme Editor', 'Orbisius Theme Editor', 'manage_options', 'orbisius_ctc_theme_editor_action', 'orbisius_ctc_theme_editor' );
95
+ add_filter('theme_action_links', 'orbisius_child_theme_creator_add_edit_theme_link', 50, 2);
96
  }
97
 
98
  // Add the ? settings link in Plugins page very good
99
  function orbisius_child_theme_creator_add_plugin_settings_link($links, $file) {
100
  if ($file == plugin_basename(__FILE__)) {
101
+ $link = orbisius_child_theme_creator_util::get_create_child_pages_link();
102
+
103
+ $link_html = "<a href='$link'>Create a Child Theme</a>";
104
+ array_unshift($links, $link_html);
105
  }
106
 
107
  return $links;
108
  }
109
 
110
+ /**
111
+ * This adds an edit button in Apperance under each theme.
112
+ * @param array $actions
113
+ * @param WP_Theme/string Obj $theme
114
+ * @return array
115
+ */
116
+ function orbisius_child_theme_creator_add_edit_theme_link($actions, $theme) {
117
+ $link = orbisius_child_theme_creator_util::get_theme_editor_link( array( 'theme_1' => is_scalar($theme) ? $theme : $theme->get_template()) );
118
+ $link_html = "<a href='$link' title='Opens this theme in Orbisius Theme Editor which features double textx editor.'>Orbisius: Edit</a>";
119
+
120
+ $actions['orb_ctc_editor'] = $link_html;
121
+
122
+ return $actions;
123
+ }
124
+
125
  // Generates Options for the plugin
126
  function orbisius_child_theme_creator_settings_page() {
127
  ?>
141
  </p></div>
142
 
143
  <div class="updated0"><p>
144
+ This plugin doesn't currently have any configuration options. To use it go to <strong>Appearance &rarr; Orbisius Child Theme Creator</strong>
145
  </p></div>
146
 
147
  <h2>Video Demo</h2>
289
  wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
290
  }
291
 
292
+ $multi_site = is_multisite();
293
+
294
+ if ( $multi_site && ! is_network_admin() ) {
295
+ $next_url = orbisius_child_theme_creator_util::get_create_child_pages_link();
296
 
297
  if (headers_sent()) {
298
+ $success = "In order to create a child theme in a multisite WordPress environment you must do it from Network Admin &gt; Apperance"
299
+ . "<br/><a href='$next_url' class='button button-primary'>Continue</a>";
300
  wp_die($success);
301
  } else {
302
  wp_redirect($next_url);
340
  $success[] = "The child theme has been successfully created.";
341
  $success[] = $installer->get_details();
342
 
343
+ if (!$multi_site && !empty($_REQUEST['switch'])) {
344
  $child_theme_base_dir = $installer->get_child_base_dir();
345
  $theme = wp_get_theme($child_theme_base_dir);
346
 
357
  wp_safe_redirect($next_url);
358
  exit;
359
  }
360
+ } elseif ($multi_site && !empty($_REQUEST['orbisius_child_theme_creator_make_network_wide_available'])) {
361
+ // Make child theme an allowed theme (network enable theme)
362
+ $allowed_themes = get_site_option( 'allowedthemes' );
363
+ $new_theme_name = $installer->get_child_base_dir();
364
+ $allowed_themes[ $new_theme_name ] = true;
365
+ update_site_option( 'allowedthemes', $allowed_themes );
366
  }
367
  } catch (Exception $e) {
368
  $errors[] = "There was an error during the chat installation.";
375
  }
376
  }
377
 
378
+ if ( 0&&$multi_site ) {
379
  $msg .= orbisius_child_theme_creator_util::msg("You are running WordPress in MultiSite configuration.
380
+ Please report any glitches that you may find.", 2);
381
  }
382
 
383
  if (!empty($errors)) {
392
  <h2>Orbisius Child Theme Creator
393
 
394
  <div class="" style="float: right;padding: 3px; _border: 1px solid #D54E21;">
395
+ Links:
396
+ <a href="http://qsandbox.com/?utm_source=orbisius-child-theme-creator&utm_medium=action_screen&utm_campaign=product"
 
 
 
397
  target="_blank" title="Opens in new tab/window. qSandbox is a FREE service that allows you to setup a test/sandbox WordPress site in 2 seconds. No technical knowledge is required.
398
+ Test themes and plugins before you actually put them on your site">Free Test Site</a> <small>(2 sec setup)</small>
399
 
400
+ | <a href="http://orbisius.com/page/free-quote/?utm_source=child-theme-creator&utm_medium=plugin-linksutm_campaign=plugin-update"
401
+ title="If you want a custom web/mobile app or a plugin developed contact us. This opens in a new window/tab">Hire Us</a>
402
 
403
+ | <a href="#help" title="[new window]">Help</a>
404
  </div>
405
  </h2>
406
 
 
407
  <?php echo $msg; ?>
408
  <div class="updated">
409
  <p>
447
  ? $author_name
448
  : "<a title='Visit author homepage' href='$author_uri' target='_blank'>$author_name</a>";
449
 
450
+ $author_line .= " | Ver.$theme_obj->Version\n";
451
+
452
+ $edit_theme_link = orbisius_child_theme_creator_util::get_theme_editor_link( array('theme_1' => $theme_basedir_name) );
453
+ $author_line .= " | <a href='$edit_theme_link' title='Edit with Orbisius Theme Editor'>Edit</a>\n";
454
+
455
  $buff .= "<div class='available-theme'>\n";
456
  $buff .= "<form action='$create_url' method='post'>\n";
457
  $buff .= "<img class='screenshot' src='$src' alt='' />\n";
467
  $adv_container_id = md5($src);
468
 
469
  $buff .= "
470
+ <li>
471
+ <a href='javascript:void(0)' onclick='jQuery(\"#orbisius_ctc_act_adv_$adv_container_id\").slideToggle(\"slow\");'>+ Advanced</a> (show/hide)
472
+ <div id='orbisius_ctc_act_adv_$adv_container_id' class='app-hide'>";
473
+
474
+ $buff .= "<div>
475
+ <label>
476
+ <input type='checkbox' id='orbisius_child_theme_creator_copy_functions_php' name='copy_functions_php' value='1' /> Copy functons.php
477
+ (<span class='app-serious-notice'><strong>Danger</strong>: if the theme doesn't support
478
+ <a href='http://wp.tutsplus.com/tutorials/creative-coding/understanding-wordpress-pluggable-functions-and-their-usage/'
479
+ target='_blank'>pluggable functions</a> this <strong>will crash your site</strong>. Make a backup is highly recommended.</span>)
480
+ </label>
481
+ </div>";
482
+
483
+ $buff .= "
484
+ </div> <!-- /orbisius_ctc_act_adv_$adv_container_id -->
485
+ </li>\n";
486
  }
487
 
488
+ // Let's allow the user to make that theme network wide usable
489
+ if ($multi_site) {
490
+ $buff .= "<li>
491
+ <div>
492
+ <label>
493
+ <input type='checkbox' id='orbisius_child_theme_creator_make_network_wide_available'
494
+ name='orbisius_child_theme_creator_make_network_wide_available' value='1' /> Make the new theme network wide available
495
+ </label>
496
+ </div></li>\n";
497
+ } else {
498
+ $buff .= "<li><label><input type='checkbox' id='orbisius_child_theme_creator_switch' name='switch' value='1' /> "
499
+ . "Switch theme to the new theme after it is created</label></li>\n";
500
+ }
501
+
502
  $buff .= "<li> <button type='submit' class='button button-primary'>Create Child Theme</button> </li>\n";
503
  } else {
 
504
  $buff .= "<li>[child theme]</li>\n";
505
  }
506
+
 
507
  $buff .= "</ul>\n";
508
  $buff .= "</div> <!-- /action-links -->\n";
509
  $buff .= "</form> <!-- /form -->\n";
515
  echo $buff;
516
  ?>
517
 
 
 
518
  <a name="help"></a>
519
  <h2>Support &amp; Premium Plugins</h2>
520
  <div class="updated">
525
  </div>
526
  <?php if (1) : ?>
527
  <?php
528
+ $plugin_data = orbisius_child_theme_creator_get_plugin_data();
529
 
530
  $app_link = urlencode($plugin_data['PluginURI']);
531
  $app_title = urlencode($plugin_data['Name']);
812
  * Util funcs
813
  */
814
  class orbisius_child_theme_creator_util {
815
+ /**
816
+ * Returns a link to appearance. Taking into account multisite.
817
+ *
818
+ * @param array $params
819
+ * @return string
820
+ */
821
+ static public function get_create_child_pages_link($params = array()) {
822
+ $rel_path = 'themes.php?page=orbisius_child_theme_creator_themes_action';
823
+
824
+ if (!empty($params)) {
825
+ $rel_path = orbisius_child_theme_creator_html::add_url_params($rel_path, $params);
826
+ }
827
+
828
+ $create_child_themes_page_link = is_multisite()
829
+ ? network_admin_url($rel_path)
830
+ : admin_url($rel_path);
831
+
832
+ return $create_child_themes_page_link;
833
+ }
834
+
835
+ /**
836
+ * Returns the link to the Theme Editor e.g. when a theme_1 or theme_2 is supplied.
837
+ * @param type $params
838
+ * @return string
839
+ */
840
+ static public function get_theme_editor_link($params = array()) {
841
+ $rel_path = 'themes.php?page=orbisius_ctc_theme_editor_action';
842
+
843
+ if (!empty($params)) {
844
+ $rel_path = orbisius_child_theme_creator_html::add_url_params($rel_path, $params);
845
+ }
846
+
847
+ $link = is_multisite()
848
+ ? network_admin_url($rel_path)
849
+ : admin_url($rel_path);
850
+
851
+ return $link;
852
+ }
853
+
854
  /**
855
  * Recursive function to copy (all subdirectories and contents).
856
  * It doesn't create folder in the target folder.
888
  copy($src, $dest);
889
  }
890
  }
891
+
892
  /**
893
  * Loads files from a directory but skips . and ..
894
  */
979
  $selected .= ' disabled="disabled" ';
980
  }
981
 
982
+ // This makes certain options to have certain CSS class
983
+ // which can be used to highlight the row
984
+ // the key must start with __sys_CLASS_NAME
985
  if (preg_match('#__sys_([\w-]+)#si', $label, $matches)) {
986
  $label = str_replace($matches[0], '', $label);
987
  $selected .= " class='$matches[1]' ";
995
 
996
  return $html;
997
  }
998
+ }
999
+
1000
+ /**
1001
+ * This method creates 2 panes that the user is able to use to edit theme files.
1002
+ * Everythin happens with AJAX
1003
+ */
1004
+ function orbisius_ctc_theme_editor() {
1005
+ if ( is_multisite() && ! is_network_admin() ) {
1006
+ $next_url = orbisius_child_theme_creator_util::get_create_child_pages_link();
1007
+
1008
+ if (headers_sent()) {
1009
+ $success = "In order to edit a theme in a multisite WordPress environment you must do it from Network Admin &gt; Apperance"
1010
+ . "<br/><a href='$next_url' class='button button-primary'>Continue</a>";
1011
+ wp_die($success);
1012
+ } else {
1013
+ wp_redirect($next_url);
1014
+ }
1015
+
1016
+ exit();
1017
+ }
1018
+
1019
+ $msg = 'Pick any two themes and copy snippets from one to the other.';
1020
+
1021
+ $plugin_data = orbisius_child_theme_creator_get_plugin_data();
1022
+
1023
+ ?>
1024
+ <div class="wrap orbisius_child_theme_creator_container orbisius_ctc_theme_editor_container">
1025
+ <h2>Orbisius Theme Editor <small>(Part of <a href='<?php echo $plugin_data['url'];?>' target="_blank">Orbisius Child Theme Creator</a>)</small></h2>
1026
+
1027
+ <div class="updated"><p><?php echo $msg; ?></p></div>
1028
+
1029
+ <?php
1030
+ $buff = $theme_1_file = $theme_2_file = '';
1031
+ $req = orbisius_ctc_theme_editor_get_request();
1032
+
1033
+ $html_dropdown_themes = array('' => '== SELECT THEME ==');
1034
 
1035
+ $theme_1 = empty($req['theme_1']) ? '' : $req['theme_1'];
1036
+ $theme_2 = empty($req['theme_2']) ? '' : $req['theme_2'];
1037
+
1038
+ $theme_load_args = array();
1039
+ $themes = wp_get_themes( $theme_load_args );
1040
+
1041
+ $current_theme = wp_get_theme();
1042
+
1043
+ // we use the same CSS as in WP's appearances but put only the buttons we want.
1044
+ foreach ($themes as $theme_basedir_name => $theme_obj) {
1045
+ $theme_name = $theme_obj->Name;
1046
+
1047
+ $theme_dir = $theme_basedir_name;
1048
+
1049
+ $parent_theme = $theme_obj->get('Template');
1050
+
1051
+ // Is this a child theme?
1052
+ if ( !empty($parent_theme) ) {
1053
+ $theme_name .= " (child of $parent_theme)";
1054
+ }
1055
+
1056
+ // Is this the current theme?
1057
+ if ($theme_basedir_name == $current_theme->get_stylesheet()) {
1058
+ $theme_name .= ' (site theme) __sys_highlight';
1059
+ }
1060
+
1061
+ $html_dropdown_themes[$theme_dir] = $theme_name;
1062
+ }
1063
+
1064
+ $html_dropdown_theme_1_files = array(
1065
+ '' => '<== SELECT THEME ==',
1066
+ );
1067
+
1068
+ ?>
1069
+
1070
+ <table class="widefat">
1071
+ <tr>
1072
+ <td width="50%">
1073
+ <form id="orbisius_ctc_theme_editor_theme_1_form" class="orbisius_ctc_theme_editor_theme_1_form">
1074
+ <strong>Theme #1:</strong>
1075
+ <?php echo orbisius_child_theme_creator_html::html_select('theme_1', $theme_1, $html_dropdown_themes); ?>
1076
+
1077
+ <span class="theme_1_file_container">
1078
+ | <strong>File:</strong>
1079
+ <?php echo orbisius_child_theme_creator_html::html_select('theme_1_file', $theme_1_file, $html_dropdown_theme_1_files); ?>
1080
+ </span>
1081
+
1082
+ <textarea id="theme_1_file_contents" name="theme_1_file_contents" rows="30" class="widefat"></textarea>
1083
+ <div>
1084
+ <button type='submit' class='button button-primary' id="theme_1_submit" name="theme_1_submit">Update</button>
1085
+ <span class="status"></span>
1086
+ </div>
1087
+ </form>
1088
+ </td>
1089
+ <td width="50%">
1090
+ <form id="orbisius_ctc_theme_editor_theme_2_form" class="orbisius_ctc_theme_editor_theme_2_form">
1091
+ <strong>Theme #2:</strong>
1092
+ <?php echo orbisius_child_theme_creator_html::html_select('theme_2', $theme_2, $html_dropdown_themes); ?>
1093
+
1094
+ <span class="theme_2_file_container">
1095
+ | <strong>File:</strong>
1096
+ <?php echo orbisius_child_theme_creator_html::html_select('theme_2_file', $theme_2_file, $html_dropdown_theme_1_files); ?>
1097
+ </span>
1098
+
1099
+ <textarea id="theme_2_file_contents" name="theme_2_file_contents" rows="30" class="widefat"></textarea>
1100
+ <div>
1101
+ <button type='submit' class='button button-primary' id="theme_2_submit" name="theme_2_submit">Update</button>
1102
+ <span class="status"></span>
1103
+ </div>
1104
+ </form>
1105
+ </td>
1106
+ </tr>
1107
+ </table>
1108
+ <?php
1109
+ }
1110
+
1111
+ /**
1112
+ * This is called via ajax. Depending on the sub_cmd param a different method will be called.
1113
+ *
1114
+ */
1115
+ function orbisius_ctc_theme_editor_ajax() {
1116
+ $buff = 'INVALID AJAX SUB_CMD';
1117
+
1118
+ $req = orbisius_ctc_theme_editor_get_request();
1119
+ $sub_cmd = empty($req['sub_cmd']) ? '' : $req['sub_cmd'];
1120
+
1121
+ switch ($sub_cmd) {
1122
+ case 'generate_dropdown':
1123
+ $buff = orbisius_ctc_theme_editor_generate_dropdown();
1124
+
1125
+ break;
1126
+
1127
+ case 'load_file':
1128
+ $buff = orbisius_ctc_theme_editor_manage_file(1);
1129
+ break;
1130
+
1131
+ case 'save_file':
1132
+ $buff = orbisius_ctc_theme_editor_manage_file(2);
1133
+
1134
+ break;
1135
+
1136
+ default:
1137
+ break;
1138
+ }
1139
+
1140
+
1141
+ die($buff);
1142
+ }
1143
+
1144
+ /**
1145
+ * It seems WP intentionally adds slashes for consistency with php.
1146
+ * Please note: WordPress Core and most plugins will still be expecting slashes, and the above code will confuse and break them.
1147
+ * If you must unslash, consider only doing it to your own data which isn't used by others:
1148
+ * @see http://codex.wordpress.org/Function_Reference/stripslashes_deep
1149
+ */
1150
+ function orbisius_ctc_theme_editor_get_request() {
1151
+ $req = $_REQUEST;
1152
+ $req = stripslashes_deep( $req );
1153
+
1154
+ return $req;
1155
+ }
1156
+
1157
+ /**
1158
+ * This returns an HTML select with the selected theme's files.
1159
+ * the name/id of that select must be either theme_1_file or theme_2_file
1160
+ * @return string
1161
+ */
1162
+ function orbisius_ctc_theme_editor_generate_dropdown() {
1163
+ $theme_base_dir = $theme_1_file = '';
1164
+ $req = orbisius_ctc_theme_editor_get_request();
1165
+
1166
+ $select_name = 'theme_1_file';
1167
+
1168
+ if (!empty($req['theme_1'])) {
1169
+ $theme_base_dir = empty($req['theme_1']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_1']);
1170
+ $theme_1_file = empty($req['theme_1_file']) ? 'style.css' : $req['theme_1_file'];
1171
+ } elseif (!empty($req['theme_2'])) {
1172
+ $theme_base_dir = empty($req['theme_2']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_2']);
1173
+ $theme_1_file = empty($req['theme_2_file']) ? 'style.css' : $req['theme_2_file'];
1174
+ $select_name = 'theme_2_file';
1175
+ } else {
1176
+ return 'Invalid params.';
1177
+ }
1178
+
1179
+ $theme_dir = get_theme_root() . "/$theme_base_dir/";
1180
+
1181
+ if (empty($theme_base_dir) || !is_dir($theme_dir)) {
1182
+ return 'Selected theme is invalid.';
1183
+ }
1184
+
1185
+ $files = array();
1186
+ $all_files = orbisius_child_theme_creator_util::load_files($theme_dir);
1187
+
1188
+ foreach ($all_files as $file) {
1189
+ if (preg_match('#\.(php|css|js|txt)$#si', $file)) {
1190
+ $files[] = $file;
1191
+ }
1192
+ }
1193
+
1194
+ // we're going to make values to be keys as well.
1195
+ $html_dropdown_theme_1_files = array_combine($files, $files);
1196
+ $buff = orbisius_child_theme_creator_html::html_select($select_name, $theme_1_file, $html_dropdown_theme_1_files);
1197
+
1198
+ return $buff;
1199
+ }
1200
+
1201
+ /**
1202
+ * Reads or writes contents to a file
1203
+ * @param type $read
1204
+ * @return string
1205
+ */
1206
+ function orbisius_ctc_theme_editor_manage_file($read = 1) {
1207
+ $buff = $theme_base_dir = $theme_file = '';
1208
+
1209
+ $req = orbisius_ctc_theme_editor_get_request();
1210
+
1211
+ if (!empty($req['theme_1']) && !empty($req['theme_1_file'])) {
1212
+ $theme_base_dir = empty($req['theme_1']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_1']);
1213
+ $theme_file = empty($req['theme_1_file']) ? 'style.css' : sanitize_file_name($req['theme_1_file']);
1214
+ $theme_file_contents = empty($req['theme_1_file_contents']) ? '' : $req['theme_1_file_contents'];
1215
+ } elseif (!empty($req['theme_2']) && !empty($req['theme_2_file'])) {
1216
+ $theme_base_dir = empty($req['theme_2']) ? '' : preg_replace('#[^\w-]#si', '', $req['theme_2']);
1217
+ $theme_file = empty($req['theme_2_file']) ? 'style.css' : sanitize_file_name($req['theme_2_file']);
1218
+ $theme_file_contents = empty($req['theme_2_file_contents']) ? '' : $req['theme_2_file_contents'];
1219
+ } else {
1220
+ return 'Missing data!';
1221
+ }
1222
+
1223
+ $theme_dir = get_theme_root() . "/$theme_base_dir/";
1224
+
1225
+ if (empty($theme_base_dir) || !is_dir($theme_dir)) {
1226
+ return 'Selected theme is invalid.';
1227
+ } elseif (!file_exists($theme_dir . $theme_file)) {
1228
+ return 'Selected file is invalid.';
1229
+ }
1230
+
1231
+ $theme_file = $theme_dir . $theme_file;
1232
+
1233
+ if ($read == 1) {
1234
+ $buff = file_get_contents($theme_file);
1235
+ } elseif ($read == 2) {
1236
+ file_put_contents($theme_file, $theme_file_contents);
1237
+ $buff = $theme_file_contents;
1238
+ }
1239
+
1240
+ return $buff;
1241
+ }
readme.txt CHANGED
@@ -1,11 +1,12 @@
1
  === Orbisius Child Theme Creator ===
2
- Contributors: lordspace
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
4
  Tags: child theme, childtheme,childthemes,child themes,CSS, styling,resposive design,design,custom themeing, shared hosting, theme,themes,wp,wordpress,orbisius,theme creator
5
  Requires at least: 3.0
6
  Tested up to: 3.6.1
7
- Stable tag: 1.0.4
8
  License: GPLv2 or later
 
9
 
10
  This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
11
 
@@ -18,10 +19,10 @@ This plugin allows you to quickly create child themes from any theme that you ha
18
  This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
19
  It also creates rtl.css if exists in the parent theme.
20
 
21
- = New and Important =
22
- We have noticed that some child themes created by this plugin do not work as expected.
23
- This is not a bug in this plugin but could be caused by theme authors using custom theme frameworks and/or do not using WordPress'
24
- recommended functions for themes supporting child themes.
25
 
26
  We have launched a **FREE** service that allows you to setup a test/sandbox WordPress site in seconds. No technical knowledge is required.
27
  Join today and test themes and plugins before you actually put them on your live site. For more info go to:
@@ -33,9 +34,22 @@ Join today and test themes and plugins before you actually put them on your live
33
  * Easy to use interface
34
  * When moving through the themes the currently looked one will have a nice background & border
35
  * Create *unlimited* child themes from a parent theme. The plugin will add Child 01, Child 02 etc.
 
36
 
37
- = Usage =
38
- Go to Admin > Tools > Orbisius Child Theme Creator then click on the theme you like and the child theme will be created for you.
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  = Demo =
41
 
@@ -50,13 +64,20 @@ http://www.youtube.com/watch?v=BZUVq6ZTv-o
50
  Do you need an amazing plugin created especially for your needs? Contact me.
51
  Svetoslav Marinov (Slavi) | <a href="http://orbisius.com" title="Custom Web Programming, Web Design, e-commerce, e-store, Wordpress Plugin Development, Facebook and Mobile App Development in Niagara Falls, St. Catharines, Ontario, Canada" target="_blank">Custom Web and Mobile Programming by Orbisius.com</a>
52
 
 
 
 
 
 
 
53
  == Upgrade Notice ==
54
  n/a
55
 
56
  == Screenshots ==
57
  1. Plugin page after installation
58
- 2. Orbisius Child Theme Creator in Tools > Orbisius Child Theme Creator - before creating a child theme
59
- 3. Orbisius Child Theme Creator in Tools > Orbisius Child Theme Creator - after creating a child theme
 
60
 
61
  == Installation ==
62
 
@@ -66,7 +87,7 @@ n/a
66
  == Frequently Asked Questions ==
67
 
68
  = How to use this plugin? =
69
- Just install the plugin and activate it. Then go to Admin > Tools > Orbisius Child Theme Creator.
70
  Then click on a theme and the plugin will create a child theme for you.
71
 
72
  = Troubleshooting =
@@ -87,6 +108,15 @@ Go to http://club.orbisius.com and post suggestions in our forum for new feature
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
 
 
 
 
90
  = 1.0.4 =
91
  * Tested with wp 3.6.1
92
  * Added a link in the Appearance
1
  === Orbisius Child Theme Creator ===
2
+ Contributors: lordspace,orbisius
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7APYDVPBCSY9A
4
  Tags: child theme, childtheme,childthemes,child themes,CSS, styling,resposive design,design,custom themeing, shared hosting, theme,themes,wp,wordpress,orbisius,theme creator
5
  Requires at least: 3.0
6
  Tested up to: 3.6.1
7
+ Stable tag: 1.0.5
8
  License: GPLv2 or later
9
+ Network:true
10
 
11
  This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
12
 
19
  This plugin allows you to quickly create child themes from any theme that you have currently installed on your site/blog.
20
  It also creates rtl.css if exists in the parent theme.
21
 
22
+ = Important =
23
+ > We have noticed that some child themes created by this plugin do not work as expected.
24
+ > This is not a bug in this plugin but could be caused by theme authors using custom theme frameworks and/or do not using WordPress' recommended functions for themes that support child themes.
25
+ > Please check with the created of the theme first to see if their theme supports child themes.
26
 
27
  We have launched a **FREE** service that allows you to setup a test/sandbox WordPress site in seconds. No technical knowledge is required.
28
  Join today and test themes and plugins before you actually put them on your live site. For more info go to:
34
  * Easy to use interface
35
  * When moving through the themes the currently looked one will have a nice background & border
36
  * Create *unlimited* child themes from a parent theme. The plugin will add Child 01, Child 02 etc.
37
+ * Edit theme files with our double theme editor.
38
 
39
+ This plugin allows you to quickly edit theme files from Appearance &gt; Orbisius Theme Editor (entry added by the same plugin)
40
+ It features two editors and you can pick snippets from one theme and paste into another.
41
+
42
+ = Features =
43
+ * Edit two theme files at the same time
44
+ * Ajax -> No page refresh
45
+ * Easy to use interface
46
+ * Supports WordPress Multisite
47
+
48
+ = Usage : To create a child theme go to =
49
+ Go to Admin > Appearance > Orbisius Child Theme Creator then click on the theme you like and the child theme will be created for you.
50
+
51
+ = Usage : To edit themes files go to =
52
+ Go to Admin > Appearance > Orbisius Theme Editor then click on the theme you like and the child theme will be created for you.
53
 
54
  = Demo =
55
 
64
  Do you need an amazing plugin created especially for your needs? Contact me.
65
  Svetoslav Marinov (Slavi) | <a href="http://orbisius.com" title="Custom Web Programming, Web Design, e-commerce, e-store, Wordpress Plugin Development, Facebook and Mobile App Development in Niagara Falls, St. Catharines, Ontario, Canada" target="_blank">Custom Web and Mobile Programming by Orbisius.com</a>
66
 
67
+ = Hire Us =
68
+ Do you need any WordPress work done? e.g. WordPress tweaks, new plugin development or existing plugin improvements.
69
+
70
+ Do you need a trusted <a href="http://orbisius.com/page/free-quote/?utm_source=child-theme-creator&utm_medium=plugin-linksutm_campaign=plugin-update"
71
+ title="If you want a custom web/mobile app or a plugin developed contact us. This opens in a new window/tab">WordPress Developer</a> to hire?
72
+
73
  == Upgrade Notice ==
74
  n/a
75
 
76
  == Screenshots ==
77
  1. Plugin page after installation
78
+ 2. Orbisius Child Theme Creator in Appearance > Orbisius Child Theme Creator - before creating a child theme
79
+ 3. Orbisius Child Theme Creator in Appearance > Orbisius Child Theme Creator - after creating a child theme
80
+ 4. Orbisius Theme Editor in Action from Admin > Appearance > Orbisius Theme Editor
81
 
82
  == Installation ==
83
 
87
  == Frequently Asked Questions ==
88
 
89
  = How to use this plugin? =
90
+ Just install the plugin and activate it. Then go to Admin > Appearance > Orbisius Child Theme Creator.
91
  Then click on a theme and the plugin will create a child theme for you.
92
 
93
  = Troubleshooting =
108
 
109
  == Changelog ==
110
 
111
+ = 1.0.5 =
112
+ * Tested under WordPress Multisite environment
113
+ * Added menus in WordPress Multisite environment
114
+ * Added an option for network wide theme activation (which is mutually exclusive with make theme active).
115
+ * Added double editor for easy theme editing.
116
+ * Added Orbisius: Edit to the theme list
117
+ * Show a notice in the plugins area to let the user know how to work with the plugin. On multisite the message is shown only on the network site.
118
+ * Aded minimized versions for main css and js
119
+
120
  = 1.0.4 =
121
  * Tested with wp 3.6.1
122
  * Added a link in the Appearance
screenshot-4.png ADDED
Binary file