Child Theme Creator by Orbisius - Version 1.0.0

Version Description

n/a

Download this release

Release Info

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

Version 1.0.0

assets/main.css ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Product of Orbisius.com. Visit http://club.orbisius.com/ */
2
+ .orbisius-child_theme_creator-container .app-hide {
3
+ display: none;
4
+ }
5
+
6
+ .orbisius-child_theme_creator-container .app-hide-force {
7
+ display: none !important;
8
+ }
9
+
10
+ .orbisius-child_theme_creator-container .app-form-field-error {
11
+ border-color: red;
12
+ }
13
+
14
+ .orbisius-child_theme_creator-container .app-serious-notice {
15
+ color: red;
16
+ font-weight: bold;
17
+ }
18
+
19
+ /* Common */
20
+ .orbisius-child_theme_creator-container .app-alert-error {
21
+ background: #D54E21;
22
+ border: 1px solid #eee;
23
+ color: white;
24
+ padding: 3px;
25
+ text-align: center;
26
+ }
27
+
28
+ .orbisius-child_theme_creator-container .app-alert-success {
29
+ background: green;
30
+ border: 1px solid #eee;
31
+ color: white;
32
+ padding: 3px;
33
+ text-align: center;
34
+ }
35
+
36
+ .orbisius-child_theme_creator-container .app-alert-success a {
37
+ color: white;
38
+ }
39
+
40
+ .orbisius-child_theme_creator-container .app-alert-notice {
41
+ background: #FFEC8B;
42
+ border: 1px solid #eee;
43
+ padding: 3px;
44
+ text-align: center;
45
+ }
46
+
47
+ .orbisius-child_theme_creator-container .app-button-positive {
48
+ background: green;
49
+ color: white;
50
+ padding: 3px;
51
+ text-decoration: none;
52
+ }
53
+
54
+ .orbisius-child_theme_creator-container .app-button-negative {
55
+ background: red;
56
+ color: white;
57
+ padding: 3px;
58
+ text-decoration: none;
59
+ }
60
+
61
+ /* dlg button colouring */
62
+ .orbisius-child_theme_creator-container .app-dialog-button-ok {
63
+ background: green !important;
64
+ color: white !important;
65
+ }
66
+
67
+ .orbisius-child_theme_creator-container .app-dialog-button-cancel {
68
+ background: red !important;
69
+ color: white !important;
70
+ }
71
+
72
+ .orbisius-child_theme_creator-container .app-button-left, .app-align-left{
73
+ float: left;
74
+ }
75
+
76
+ .orbisius-child_theme_creator-container .app-button-right, .orbisius-child_theme_creator-container .app-align-right {
77
+ float: right;
78
+ }
79
+
80
+ .orbisius-child_theme_creator-container .app-button-container {
81
+ padding:10px;
82
+ background: #ccc;
83
+ margin-top: 15px;
84
+ margin-bottom: 15px;
85
+ }
86
+
87
+ .orbisius-child_theme_creator-container .available-theme {
88
+ padding:10px;
89
+ border: 2px solid white; /* we need this because there is a shift otherwise on hover. */
90
+ }
91
+
92
+ .orbisius-child_theme_creator-container .available-theme:hover {
93
+ border: 2px solid #444;
94
+ background: #ccc;
95
+ }
i/guNzr.qr.16.png ADDED
Binary file
i/guNzr.qr.2.png ADDED
Binary file
nbproject/private/config.properties ADDED
File without changes
nbproject/private/private.properties ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ copy.src.files=false
2
+ copy.src.target=
3
+ index.file=orbisius-child-theme-creator.php
4
+ run.as=LOCAL
5
+ url=http://localhost/wordpress313/
nbproject/private/private.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="2">
4
+ <file>
5
+ <url>orbisius-child_theme_creator.php</url>
6
+ <bookmark id="2">
7
+ <name/>
8
+ <line>379</line>
9
+ <key/>
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/orbisius-child-theme-creator.php</file>
16
+ </open-files>
17
+ </project-private>
nbproject/project.properties ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ include.path=${php.global.include.path}
2
+ php.version=PHP_54
3
+ source.encoding=UTF-8
4
+ src.dir=.
5
+ tags.asp=false
6
+ tags.short=true
7
+ web.root=.
nbproject/project.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.php.project</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/php-project/1">
6
+ <name>orbisius-child_theme_creator</name>
7
+ </data>
8
+ </configuration>
9
+ </project>
orbisius-child-theme-creator.php ADDED
@@ -0,0 +1,535 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.0
7
+ Author: Svetoslav Marinov (Slavi)
8
+ Author URI: http://orbisius.com
9
+ */
10
+
11
+ /* Copyright 2012 Svetoslav Marinov (Slavi) <slavi@orbisius.com>
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
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
47
+ && (stripos($_SERVER['REQUEST_URI'], 'plugins.php') !== false)) {
48
+ $just_link = 'tools.php?page=' . plugin_basename(__FILE__);
49
+ echo "<div class='updated'><p>$name has been installed. To create a child theme go to <a href='$just_link'><strong>Tools &rarr; $name</strong></a></p></div>";
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @package Orbisius Child Theme Creator
55
+ * @since 1.0
56
+ *
57
+ * Searches through posts to see if any matches the REQUEST_URI.
58
+ * Also searches tags
59
+ */
60
+ function orbisius_child_theme_creator_admin_init() {
61
+ wp_register_style(dirname(__FILE__), plugins_url('/assets/main.css', __FILE__), false);
62
+ wp_enqueue_style(dirname(__FILE__));
63
+ }
64
+
65
+ /**
66
+ * Set up administration
67
+ *
68
+ * @package Orbisius Child Theme Creator
69
+ * @since 0.1
70
+ */
71
+ function orbisius_child_theme_creator_setup_admin() {
72
+ add_submenu_page( 'tools.php', 'Orbisius Child Theme Creator', 'Orbisius Child Theme Creator', 'manage_options', __FILE__,
73
+ 'orbisius_child_theme_creator_tools_action');
74
+
75
+ // when plugins are show add a settings link near my plugin for a quick access to the settings page.
76
+ add_filter('plugin_action_links', 'orbisius_child_theme_creator_add_plugin_settings_link', 10, 2);
77
+ }
78
+
79
+ // Add the ? settings link in Plugins page very good
80
+ function orbisius_child_theme_creator_add_plugin_settings_link($links, $file) {
81
+ if ($file == plugin_basename(__FILE__)) {
82
+ $prefix = 'tools.php?page=' . plugin_basename(__FILE__);
83
+ $dashboard_link = "<a href=\"{$prefix}\">" . 'Create a Child Theme' . '</a>';
84
+ array_unshift($links, $dashboard_link);
85
+ }
86
+
87
+ return $links;
88
+ }
89
+
90
+ /**
91
+ * Upload page.
92
+ * Ask the user to upload a file
93
+ * Preview
94
+ * Process
95
+ *
96
+ * @package Permalinks to Category/Permalinks
97
+ * @since 1.0
98
+ */
99
+ function orbisius_child_theme_creator_tools_action() {
100
+ $msg = '';
101
+ $errors = $success = array();
102
+ $parent_theme_base_dirname = empty($_REQUEST['parent_theme_base_dirname']) ? '' : wp_kses($_REQUEST['parent_theme_base_dirname'], array());
103
+ $orbisius_child_theme_creator_nonce = empty($_REQUEST['orbisius_child_theme_creator_nonce']) ? '' : $_REQUEST['orbisius_child_theme_creator_nonce'];
104
+
105
+ $parent_theme_base_dirname = trim($parent_theme_base_dirname);
106
+ $parent_theme_base_dirname = preg_replace('#[^\w-]#si', '-', $parent_theme_base_dirname);
107
+ $parent_theme_base_dirname = preg_replace('#[_-]+#si', '-', $parent_theme_base_dirname);
108
+
109
+ if (!empty($_POST) || !empty($parent_theme_base_dirname)) {
110
+ if (!wp_verify_nonce($orbisius_child_theme_creator_nonce, basename(__FILE__) . '-action')) {
111
+ $errors[] = "Invalid action";
112
+ } elseif (empty($parent_theme_base_dirname) || !preg_match('#^[\w-]+$#si', $parent_theme_base_dirname)) {
113
+ $errors[] = "Parent theme's directory is invalid. May contain only [a-z0-9-]";
114
+ } elseif (strlen($parent_theme_base_dirname) > 70) {
115
+ $errors[] = "Parent theme's directory should be fewer than 70 characters long.";
116
+ }
117
+
118
+ if (empty($errors)) {
119
+ try {
120
+ $installer = new orbisius_child_theme_creator($parent_theme_base_dirname);
121
+
122
+ $installer->check_permissions();
123
+ $installer->copy_main_files();
124
+ $installer->generate_style();
125
+
126
+ $success[] = "The child theme has been successfully created.";
127
+ $success[] = $installer->get_details();
128
+ } catch (Exception $e) {
129
+ $errors[] = "There was an error during the chat installation.";
130
+ $errors[] = $e->getMessage();
131
+
132
+ if (is_object($installer->result)) {
133
+ $errors[] = var_export($installer->result);
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ if (!empty($errors)) {
140
+ $msg = orbisius_child_theme_creator_util::msg($errors);
141
+ } elseif (!empty($success)) {
142
+ $msg = orbisius_child_theme_creator_util::msg($success, 1);
143
+ }
144
+
145
+ ?>
146
+ <div class="wrap orbisius-child_theme_creator-container">
147
+ <h2>Orbisius Child Theme Creator</h2>
148
+
149
+ <hr />
150
+ <?php echo $msg; ?>
151
+
152
+ <form id="orbisius_child_theme_creator_form" class="orbisius_child_theme_creator_form" method="post">
153
+ <?php //wp_nonce_field( basename(__FILE__) . '-action', 'orbisius_child_theme_creator_nonce' ); ?>
154
+ <div class="updated">
155
+ <p>Choose a parent theme from the list below and click on the <strong>Create Child Theme</strong> button.</p>
156
+ </div>
157
+
158
+ <?php
159
+ $buff = '';
160
+ $buff .= "<div id='availablethemes' class='theme_container'>\n";
161
+ $nonce = wp_create_nonce( basename(__FILE__) . '-action');
162
+
163
+ $args = array();
164
+ $themes = wp_get_themes( $args );
165
+
166
+ // we use the same CSS as in WP's appearances but put only the buttons we want.
167
+ foreach ($themes as $theme_basedir_name => $theme_obj) {
168
+ // get the web uri for the current theme and go 1 level up
169
+ $src = dirname(get_template_directory_uri()) . "/$theme_basedir_name/screenshot.png";
170
+ $parent_theme_base_dirname_fmt = urlencode($theme_basedir_name);
171
+ $create_url = $_SERVER['REQUEST_URI'];
172
+
173
+ // cleanup old links or refreshes.
174
+ $create_url = preg_replace('#&parent_theme_base_dirname=[\w-]+#si', '', $create_url);
175
+ $create_url = preg_replace('#&orbisius_child_theme_creator_nonce=[\w-]+#si', '', $create_url);
176
+
177
+ $create_url .= '&parent_theme_base_dirname=' . $parent_theme_base_dirname_fmt;
178
+ $create_url .= '&orbisius_child_theme_creator_nonce=' . $nonce;
179
+
180
+ $buff .= "<div class='available-theme'>\n";
181
+ $buff .= "<img class='screenshot' src='$src' alt='' />\n";
182
+ $buff .= "<h3>$theme_obj->Name</h3>\n";
183
+ $buff .= "<div class='theme-author'>By <a title='Visit author homepage' "
184
+ . "href='$theme_obj->AuthorURI' target='_blank'>$theme_obj->Author</a></div>\n";
185
+ $buff .= "<div class='action-links'>\n";
186
+ $buff .= "<ul>\n";
187
+ $buff .= "<li><a href='$create_url' class='button button-primary'>Create Child Theme</a></li>\n";
188
+ $buff .= "<li>Version: $theme_obj->Version</li>\n";
189
+ $buff .= "</ul>\n";
190
+ $buff .= "</div> <!-- /action-links -->\n";
191
+ $buff .= "</div> <!-- /available-theme -->\n";
192
+ }
193
+
194
+ $buff .= "</div> <!-- /availablethemes -->\n";
195
+ //var_dump($themes);
196
+ echo $buff;
197
+ ?>
198
+ </form>
199
+
200
+ <hr />
201
+
202
+ <h2>Want to hear about future plugins? Join our mailing List! (no spam)</h2>
203
+ <p>
204
+ Get the latest news and updates about this and future cool <a href="http://profiles.wordpress.org/lordspace/"
205
+ target="_blank" title="Opens a page with the pugins we developed. [New Window/Tab]">plugins we develop</a>.
206
+ </p>
207
+
208
+ <p>
209
+ <!-- // MAILCHIMP SUBSCRIBE CODE \\ -->
210
+ 1) Subscribe by going to <a href="http://eepurl.com/guNzr" target="_blank">http://eepurl.com/guNzr</a>
211
+ <!-- \\ MAILCHIMP SUBSCRIBE CODE // -->
212
+ OR
213
+ 2) by using our QR code. [Scan it with your mobile device].<br/>
214
+ <img src="<?php echo plugin_dir_url(__FILE__); ?>/i/guNzr.qr.2.png" alt="" />
215
+ </p>
216
+
217
+ <?php if (1) : ?>
218
+ <?php
219
+ $plugin_data = get_plugin_data(__FILE__);
220
+
221
+ $app_link = urlencode($plugin_data['PluginURI']);
222
+ $app_title = urlencode($plugin_data['Name']);
223
+ $app_descr = urlencode($plugin_data['Description']);
224
+ ?>
225
+ <h2>Share with friends</h2>
226
+ <p>
227
+ <!-- AddThis Button BEGIN -->
228
+ <div class="addthis_toolbox addthis_default_style addthis_32x32_style">
229
+ <a class="addthis_button_facebook" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
230
+ <a class="addthis_button_twitter" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
231
+ <a class="addthis_button_google_plusone" g:plusone:count="false" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
232
+ <a class="addthis_button_linkedin" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
233
+ <a class="addthis_button_email" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
234
+ <a class="addthis_button_myspace" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
235
+ <a class="addthis_button_google" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
236
+ <a class="addthis_button_digg" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
237
+ <a class="addthis_button_delicious" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
238
+ <a class="addthis_button_stumbleupon" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
239
+ <a class="addthis_button_tumblr" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
240
+ <a class="addthis_button_favorites" addthis:url="<?php echo $app_link?>" addthis:title="<?php echo $app_title?>" addthis:description="<?php echo $app_descr?>"></a>
241
+ <a class="addthis_button_compact"></a>
242
+ </div>
243
+ <!-- The JS code is in the footer -->
244
+
245
+ <script type="text/javascript">
246
+ var addthis_config = {"data_track_clickback":true};
247
+ var addthis_share = {
248
+ templates: { twitter: 'Check out {{title}} #wordpress #plugin at {{lurl}} (via @orbisius)' }
249
+ }
250
+ </script>
251
+ <!-- AddThis Button START part2 -->
252
+ <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
253
+ <!-- AddThis Button END part2 -->
254
+ </p>
255
+ <?php endif ?>
256
+
257
+ <h2>Support &amp; Premium Plugins</h2>
258
+ <div class="app-alert-notice">
259
+ <p>
260
+ ** NOTE: ** We have launched our Club Orbisius site: <a href="http://club.orbisius.com/" target="_blank" title="[new window]">http://club.orbisius.com/</a>
261
+ which offers lots of free and premium plugins, video tutorials and more. The support is handled there as well.
262
+ <br/>Please do NOT use the WordPress forums or other places to seek support.
263
+ </p>
264
+ </div>
265
+ </div>
266
+ <?php
267
+ }
268
+
269
+ /**
270
+ * adds some HTML comments in the page so people would know that this plugin powers their site.
271
+ */
272
+ function orbisius_child_theme_creator_add_plugin_credits() {
273
+ // pull only these vars
274
+ $default_headers = array(
275
+ 'Name' => 'Plugin Name',
276
+ 'PluginURI' => 'Plugin URI',
277
+ );
278
+
279
+ $plugin_data = get_file_data(__FILE__, $default_headers, 'plugin');
280
+
281
+ $url = $plugin_data['PluginURI'];
282
+ $name = $plugin_data['Name'];
283
+
284
+ printf(PHP_EOL . PHP_EOL . '<!-- ' . "Powered by $name | URL: $url " . '-->' . PHP_EOL . PHP_EOL);
285
+ }
286
+
287
+ /**
288
+ */
289
+ class orbisius_child_theme_creator {
290
+ public $result = null;
291
+ public $target_dir_path; // /var/www/vhosts/domain.com/www/wp-content/themes/Parent-Theme-child-01/
292
+
293
+ /**
294
+ * Sets up the params.
295
+ * directories contain trailing slashes.
296
+ *
297
+ * @param str $parent_theme_basedir
298
+ */
299
+ public function __construct($parent_theme_basedir = '') {
300
+ $all_themes_root = get_theme_root();
301
+
302
+ $this->parent_theme_basedir = $parent_theme_basedir;
303
+ $this->parent_theme_dir = $all_themes_root . '/' . $parent_theme_basedir . '/';
304
+
305
+ $i = 0;
306
+
307
+ // Let's create multiple folders in case the script is run multiple times.
308
+ do {
309
+ $i++;
310
+ $target_dir = $all_themes_root . '/' . $parent_theme_basedir . '-child-' . sprintf("%02d", $i) . '/';
311
+ } while (is_dir($target_dir));
312
+
313
+ $this->target_dir_path = $target_dir;
314
+ $this->target_base_dirname = dirname($target_dir);
315
+
316
+ // this is appended to the new theme's name
317
+ $this->target_name_suffix = 'Child ' . sprintf("%02d", $i);
318
+ }
319
+
320
+ /**
321
+ * Loads files from a directory but skips . and ..
322
+ */
323
+ public function load_files($dir) {
324
+ $files = array();
325
+ $all_files = scandir($dir);
326
+
327
+ foreach ($all_files as $file) {
328
+ if ($file == '.' || $file == '..') {
329
+ continue;
330
+ }
331
+
332
+ $files[] = $file;
333
+ }
334
+
335
+ return $files;
336
+ }
337
+
338
+ private $info_result = 'n/a';
339
+ private $data_file = '.ht_orbisius_child_theme_creator.json';
340
+
341
+ /**
342
+ * Checks for correct permissions by trying to create a file in the target dir
343
+ * Also it checks if there are files in the target directory in case it exists.
344
+ */
345
+ public function check_permissions() {
346
+ $target_dir_path = $this->target_dir_path;
347
+
348
+ if (!is_dir($target_dir_path)) {
349
+ if (!mkdir($target_dir_path, 0775)) {
350
+ throw new Exception("Target child theme directory cannot be created. This is probably a permission error. Cannot continue.");
351
+ }
352
+ } else { // let's see if there will be files in that folder.
353
+ $files = $this->load_files($target_dir_path);
354
+
355
+ if (count($files) > 0) {
356
+ throw new Exception("Target folder already exists and has file(s) in it. Cannot continue. Files: ["
357
+ . join(',', array_slice($files, 0, 5)) . ' ... ]' );
358
+ }
359
+ }
360
+
361
+ // test if we can create the folder and then delete it.
362
+ if (!touch($target_dir_path . $this->data_file)) {
363
+ throw new Exception("Target directory is not writable.");
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Copy some files from the parent theme.
369
+ * @return bool success
370
+ */
371
+ public function copy_main_files() {
372
+ $stats = 0;
373
+ $main_files = array('screenshot.png', 'footer.php', 'license.txt');
374
+
375
+ foreach ($main_files as $file) {
376
+ if (!file_exists($this->parent_theme_dir . $file)) {
377
+ continue;
378
+ }
379
+
380
+ $stat = copy($this->parent_theme_dir . $file, $this->target_dir_path . $file);
381
+ $stat = intval($stat);
382
+ $stats += $stat;
383
+ }
384
+ }
385
+
386
+ /**
387
+ *
388
+ * @return bool success
389
+ * @see http://codex.wordpress.org/Child_Themes
390
+ */
391
+ public function generate_style() {
392
+ global $wp_version;
393
+
394
+ $plugin_data = get_plugin_data(__FILE__);
395
+ $app_link = $plugin_data['PluginURI'];
396
+ $app_title = $plugin_data['Name'];
397
+
398
+ $parent_theme_data = version_compare($wp_version, '3.4', '>=')
399
+ ? wp_get_theme($this->parent_theme_basedir)
400
+ : (object) get_theme_data($this->target_dir_path . 'style.css');
401
+
402
+ $buff = '';
403
+ $buff .= "/*\n";
404
+ $buff .= "Theme Name: $parent_theme_data->Name $this->target_name_suffix\n";
405
+ $buff .= "Theme URI: $parent_theme_data->ThemeURI\n";
406
+ $buff .= "Description: $this->target_name_suffix theme for the $parent_theme_data->Name theme\n";
407
+ $buff .= "Author: $parent_theme_data->Author\n";
408
+ $buff .= "Author URI: $parent_theme_data->AuthorURI\n";
409
+ $buff .= "Template: $this->parent_theme_basedir\n";
410
+ $buff .= "Version: $parent_theme_data->Version\n";
411
+ $buff .= "*/\n";
412
+
413
+ $buff .= "\n/* Generated by $app_title ($app_link) on " . date('r') . " */ \n\n";
414
+
415
+ $buff .= "@import url('../$this->parent_theme_basedir/style.css');\n";
416
+
417
+ file_put_contents($this->target_dir_path . 'style.css', $buff);
418
+
419
+ // RTL langs; make rtl.css to point to the parent file as well
420
+ if (file_exists($this->parent_theme_dir . 'rtl.css')) {
421
+ $rtl_buff .= "/*\n";
422
+ $rtl_buff .= "Theme Name: $parent_theme_data->Name $this->target_name_suffix\n";
423
+ $rtl_buff .= "Template: $this->parent_theme_basedir\n";
424
+ $rtl_buff .= "*/\n";
425
+
426
+ $rtl_buff .= "\n/* Generated by $app_title ($app_link) on " . date('r') . " */ \n\n";
427
+
428
+ $rtl_buff .= "@import url('../$this->parent_theme_basedir/rtl.css');\n";
429
+
430
+ file_put_contents($this->target_dir_path . 'rtl.css', $rtl_buff);
431
+ }
432
+
433
+ $this->info_result = "$parent_theme_data->Name " . $this->target_name_suffix . ' has been created in ' . $this->target_dir_path
434
+ . ' based on ' . $parent_theme_data->Name . ' theme.'
435
+ . "\n<br/>Next Go to Appearance > Themes and Activate the new theme.";
436
+ }
437
+
438
+ /**
439
+ *
440
+ * @return string
441
+ */
442
+ public function get_details() {
443
+ return $this->info_result;
444
+ }
445
+
446
+ /**
447
+ *
448
+ * @return bool success
449
+ */
450
+ public function install() {
451
+ $src = dirname(__FILE__) . '/dist/mibew164.zip';
452
+ $target_chat_dir_path = $this->target_dir_path;
453
+
454
+ // extract files
455
+ WP_Filesystem(); // we need to call this so we can use the unzip_file function
456
+ $res = unzip_file($src, $target_chat_dir_path); // wp func
457
+
458
+ $this->status = is_wp_error($res) ? 0 : 1;
459
+ $this->result = $res;
460
+
461
+ if (!$this->status) {
462
+ throw new Exception("There was an error with the mibew zip package.");
463
+ }
464
+ }
465
+
466
+ /**
467
+ *
468
+ * @param type $filename
469
+ */
470
+ function log($msg) {
471
+ error_log($msg . "\n", 3, ini_get('error_log'));
472
+ }
473
+
474
+ /**
475
+ * This saves the settings in the chat's config file: chat_dir/libs/config.php
476
+ */
477
+ public function update_chat_config() {
478
+ // let's create the db tables.
479
+ $cfg_data = $this->read_wp_config();
480
+
481
+ $target_chat_dir_path = $this->target_dir_path;
482
+ $chat_config_buff = file_get_contents($target_chat_dir_path . '/libs/config.php');
483
+ /*
484
+ $webimroot = "/chat";
485
+ $mysqlhost = "localhost";
486
+ $mysqldb = "orbisius_installer_db";
487
+ $mysqllogin = "root";
488
+ $mysqlpass = "aaaaaa";
489
+ $mysqlprefix = "orbisius_installer_";
490
+ */
491
+ $chat_config_buff = preg_replace('#(webimroot\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . '/' . $this->chat_web_dir . '$3', $chat_config_buff);
492
+ $chat_config_buff = preg_replace('#(mysqlhost\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . $cfg_data['db_host'] . '$3', $chat_config_buff);
493
+ $chat_config_buff = preg_replace('#(mysqldb\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . $cfg_data['db_name'] . '$3', $chat_config_buff);
494
+ $chat_config_buff = preg_replace('#(mysqllogin\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . $cfg_data['db_user'] . '$3', $chat_config_buff);
495
+ $chat_config_buff = preg_replace('#(mysqlpass\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . $cfg_data['db_pass'] . '$3', $chat_config_buff);
496
+ $chat_config_buff = preg_replace('#(mysqlprefix\s*=\s*["\'])(.*?)(["\']\s*;\s*)#si', '$1' . $cfg_data['db_prefix']
497
+ . $this->get_chat_db_suffix() . '$3', $chat_config_buff);
498
+
499
+ file_put_contents($target_chat_dir_path . '/libs/config.php', $chat_config_buff);
500
+ }
501
+ }
502
+
503
+ class orbisius_child_theme_creator_util {
504
+ /**
505
+ * Returns the main site's URL. no subdirectories
506
+ */
507
+ function get_site_url($main_site_url = '') {
508
+ // we need to install the chat at the main location
509
+ // e.g. site.com/chat
510
+ // WP will return a link with /blog or a subdirectory.
511
+ $main_site_url = preg_replace('#(http?://[\w\.-]+).*#si', '$1', $main_site_url);
512
+ $main_site_url = rtrim($main_site_url, '/') . '/';
513
+
514
+ return $main_site_url;
515
+ }
516
+
517
+ /**
518
+ * Outputs a message (adds some paragraphs).
519
+ */
520
+ function msg($msg, $status = 0) {
521
+ $msg = join("<br/>\n", (array) $msg);
522
+
523
+ if (empty($status)) {
524
+ $cls = 'app-alert-error';
525
+ } elseif ($status == 1) {
526
+ $cls = 'app-alert-success';
527
+ } else {
528
+ $cls = 'app-alert-notice';
529
+ }
530
+
531
+ $str = "<div class='$cls'><p>$msg</p></div>";
532
+
533
+ return $str;
534
+ }
535
+ }
readme.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, CSS, styling,resposive design,design,custom themeing, shared hosting, theme,themes,wp,wordpress,orbisius
5
+ Requires at least: 3.0
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.0.0
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
+
12
+ == Description ==
13
+
14
+ = Support =
15
+ > Support is handled on our site: <a href="http://club.orbisius.com/" target="_blank" title="[new window]">http://club.orbisius.com/</a>
16
+ > Please do NOT use the WordPress forums or other places to seek support.
17
+
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
+ = Features =
22
+ * Create a theme with one click of a button
23
+ * Never forget what files to copy and what to skip when creating child themes.
24
+ * Easy to use interface
25
+ * When moving through the themes the currently looked one will have a nice background & border
26
+ * Create *unlimited* child themes from a parent theme. The plugin will add Child 01, Child 02 etc.
27
+
28
+ = Usage =
29
+
30
+ Go to Admin > Tools > Orbisius Child Theme Creator then click on the theme you like and the child theme will be created for you.
31
+
32
+ = Support =
33
+ * Support is handled on our site: <a href="http://club.orbisius.com/support/" target="_blank" title="[new window]">http://club.orbisius.com/support/</a>
34
+ * Please do NOT use the WordPress forums or other places to seek support.
35
+
36
+ = Author =
37
+
38
+ Do you need an amazing plugin created especially for your needs? Contact me.
39
+ 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>
40
+
41
+ == Upgrade Notice ==
42
+ n/a
43
+
44
+ == Screenshots ==
45
+ 1. Plugin page after installation
46
+ 2. Orbisius Child Theme Creator in Tools > Orbisius Child Theme Creator - before creating a child theme
47
+ 3. Orbisius Child Theme Creator in Tools > Orbisius Child Theme Creator - after creating a child theme
48
+
49
+ == Installation ==
50
+
51
+ 1. Unzip the package, and upload `orbisius-child-theme-creator` to the `/wp-content/plugins/` directory
52
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
53
+
54
+ == Frequently Asked Questions ==
55
+
56
+ = How to use this plugin? =
57
+ Just install the plugin and activate it. Then go to Admin > Tools > Orbisius Child Theme Creator.
58
+ Then click on a theme and the plugin will create a child theme for you.
59
+
60
+ = What to do next? =
61
+
62
+ Go to http://club.orbisius.com and post suggestions in our forum for new features that you'd like to see in this plugin or its extensions.
63
+
64
+ == Changelog ==
65
+
66
+ = 1.0.0 =
67
+ Initial release
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file