Child Theme Creator by Orbisius - Version 1.3.0

Version Description

  • Happy new year!
  • Copying parent theme's options (if any).
  • Tested with WP 4.4.
Download this release

Release Info

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

Code changes from version 1.2.9 to 1.3.0

nbproject/private/private.xml CHANGED
@@ -5,37 +5,37 @@
5
  <url>orbisius-child-theme-creator.php</url>
6
  <bookmark id="6">
7
  <name/>
8
- <line>1580</line>
9
  <key/>
10
  </bookmark>
11
  <bookmark id="12">
12
  <name/>
13
- <line>2055</line>
14
  <key/>
15
  </bookmark>
16
  <bookmark id="9">
17
  <name/>
18
- <line>2060</line>
19
  <key/>
20
  </bookmark>
21
  <bookmark id="5">
22
  <name/>
23
- <line>2102</line>
24
  <key/>
25
  </bookmark>
26
  <bookmark id="4">
27
  <name/>
28
- <line>2254</line>
29
  <key/>
30
  </bookmark>
31
  <bookmark id="13">
32
  <name/>
33
- <line>2460</line>
34
  <key/>
35
  </bookmark>
36
  <bookmark id="3">
37
  <name/>
38
- <line>2504</line>
39
  <key/>
40
  </bookmark>
41
  </file>
@@ -51,7 +51,7 @@
51
  <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
52
  <group>
53
  <file>file:/C:/Copy/Dropbox/cloud/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/orbisius-child-theme-creator.php</file>
54
- <file>file:/C:/Copy/Dropbox/cloud/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/readme.txt</file>
55
  </group>
 
56
  </open-files>
57
  </project-private>
5
  <url>orbisius-child-theme-creator.php</url>
6
  <bookmark id="6">
7
  <name/>
8
+ <line>1582</line>
9
  <key/>
10
  </bookmark>
11
  <bookmark id="12">
12
  <name/>
13
+ <line>2057</line>
14
  <key/>
15
  </bookmark>
16
  <bookmark id="9">
17
  <name/>
18
+ <line>2062</line>
19
  <key/>
20
  </bookmark>
21
  <bookmark id="5">
22
  <name/>
23
+ <line>2104</line>
24
  <key/>
25
  </bookmark>
26
  <bookmark id="4">
27
  <name/>
28
+ <line>2256</line>
29
  <key/>
30
  </bookmark>
31
  <bookmark id="13">
32
  <name/>
33
+ <line>2462</line>
34
  <key/>
35
  </bookmark>
36
  <bookmark id="3">
37
  <name/>
38
+ <line>2506</line>
39
  <key/>
40
  </bookmark>
41
  </file>
51
  <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
52
  <group>
53
  <file>file:/C:/Copy/Dropbox/cloud/projects/default/htdocs/wordpress313/wp-content/plugins/orbisius-child-theme-creator/orbisius-child-theme-creator.php</file>
 
54
  </group>
55
+ <group name="qsandbox"/>
56
  </open-files>
57
  </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.2.9
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
@@ -753,6 +753,7 @@ function orbisius_child_theme_creator_tools_action() {
753
  $installer->check_permissions();
754
  $installer->copy_main_files();
755
  $installer->generate_style();
 
756
 
757
  // Does the user want to copy the functions.php?
758
  if (!empty($_REQUEST['create_blank_functions_file'])) {
@@ -1538,6 +1539,97 @@ class orbisius_child_theme_creator {
1538
  . "or <a href='$edit_new_theme_url'>edit the new theme</a>.";
1539
  }
1540
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1541
  /**
1542
  *
1543
  * @return string
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.3.0
7
  Author: Svetoslav Marinov (Slavi)
8
  Author URI: http://orbisius.com
9
  */
753
  $installer->check_permissions();
754
  $installer->copy_main_files();
755
  $installer->generate_style();
756
+ $installer->copy_parent_themes_options();
757
 
758
  // Does the user want to copy the functions.php?
759
  if (!empty($_REQUEST['create_blank_functions_file'])) {
1539
  . "or <a href='$edit_new_theme_url'>edit the new theme</a>.";
1540
  }
1541
 
1542
+ /**
1543
+ *
1544
+ * @param str $parent_theme_slug
1545
+ * @return boolean
1546
+ */
1547
+ function get_parent_themes_options( $parent_theme_slug = '' ) {
1548
+ global $wpdb;
1549
+ $theme = wp_get_theme( $parent_theme_slug );
1550
+
1551
+ // Do we have a theme? We should!
1552
+ if ( empty( $theme ) || ! $theme->exists() ) {
1553
+ return false;
1554
+ }
1555
+
1556
+ // The parent theme's folder will be
1557
+ // e.g. twentysixteen and we'll use that to look in the db
1558
+ // for any settings (if any).
1559
+ $tpl_dir = get_template_directory();
1560
+ $theme_slug = basename( $tpl_dir );
1561
+ $text_domain = $theme->get( 'TextDomain' );
1562
+
1563
+ $where_arr = $bind_params = array();
1564
+ $where_arr[] = " `option_name` = '%s' "; // exact match; twentysixteen
1565
+ $where_arr[] = " `option_name` LIKE '%%%s' "; // the match must be trailing theme_mods_twentysixteen
1566
+ $bind_params[] = $theme_slug;
1567
+ $bind_params[] = $theme_slug;
1568
+
1569
+ if ( ! empty( $text_domain ) && $text_domain != $theme_slug ) {
1570
+ $where_arr[] = " `option_name` = '%s' "; // exact match; twentysixteen
1571
+ $where_arr[] = " `option_name` LIKE '%%%s'"; // the match must be trailing theme_mods_twentysixteen
1572
+ $bind_params[] = $text_domain;
1573
+ $bind_params[] = $text_domain;
1574
+ }
1575
+
1576
+ // http://wordpress.stackexchange.com/questions/67292/how-to-use-wildcards-in-wpdb-queries-using-wpdb-get-results-wpdb-prepare
1577
+ $sql_prep = $wpdb->prepare("
1578
+ SELECT option_name
1579
+ FROM {$wpdb->prefix}options
1580
+ WHERE ( " . join( ' OR ', $where_arr ) . " )
1581
+ LIMIT 25",
1582
+ $bind_params
1583
+ );
1584
+
1585
+ $opts = array();
1586
+ $results = $wpdb->get_results( $sql_prep, ARRAY_A );
1587
+
1588
+ foreach ( $results as $rec ) {
1589
+ $option_name = $rec['option_name'];
1590
+ $option_val = get_option( $option_name );
1591
+ $opts[ $option_name ] = $option_val;
1592
+ }
1593
+
1594
+ $result = array(
1595
+ 'options' => $opts,
1596
+ 'parent_theme_slug' => $theme_slug,
1597
+ 'parent_theme_text_domain' => $text_domain,
1598
+ );
1599
+
1600
+ return $result;
1601
+ }
1602
+
1603
+ /**
1604
+ * Searches the options table for option names that match the slug of the current theme.
1605
+ * We'll prefix them with the child theme's folder so it has some data.
1606
+ * @global obj $wpdb
1607
+ * @param str $theme
1608
+ */
1609
+ function copy_parent_themes_options( $child_theme_slug = '' ) {
1610
+ $child_theme_slug = empty( $child_theme_slug ) ? $this->target_base_dirname : $child_theme_slug;
1611
+ $result = $this->get_parent_themes_options();
1612
+
1613
+ foreach ( $result['options'] as $option_name => $option_val ) {
1614
+ // boxed-wp or theme_mods_boxed-wp
1615
+ if ( ! empty( $result['parent_theme_slug'] ) ) {
1616
+ $child_theme_option_name = str_ireplace( $result['parent_theme_slug'], $child_theme_slug, $option_name );
1617
+ }
1618
+
1619
+ if ( ! empty( $result['parent_theme_text_domain'] ) ) {
1620
+ $child_theme_option_name = str_ireplace( $result['parent_theme_text_domain'], $child_theme_slug, $option_name );
1621
+ }
1622
+
1623
+ $child_theme_val = get_option( $child_theme_option_name );
1624
+
1625
+ if ( ( $child_theme_val === false ) && ( $option_val !== false ) ) {
1626
+ update_option( $child_theme_option_name, $option_val );
1627
+ }
1628
+ }
1629
+
1630
+ return true;
1631
+ }
1632
+
1633
  /**
1634
  *
1635
  * @return string
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.3.1
7
  Stable tag: 1.2.9
8
  License: GPLv2 or later
9
 
@@ -141,8 +141,18 @@ Let's talk.
141
  title="If you want a custom web/mobile app/plugin developed contact us. This opens in a new window/tab"
142
  class="button-primary" target="_blank">Get a Free Quote</a>
143
 
 
 
 
 
 
144
  == Changelog ==
145
 
 
 
 
 
 
146
  = 1.2.9 =
147
  * Added a link in the plugin's settings page to point to Appearance → Orbisius Child Theme Creator ( to save 1-2 seconds to the user :) )
148
  * Removed the Free test from qSandbox as there is no longer a free plan.
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.4
7
  Stable tag: 1.2.9
8
  License: GPLv2 or later
9
 
141
  title="If you want a custom web/mobile app/plugin developed contact us. This opens in a new window/tab"
142
  class="button-primary" target="_blank">Get a Free Quote</a>
143
 
144
+ Todo
145
+ - Add buttons in the WP's Theme listing page near Customize
146
+ - Orbisius Create
147
+ - Orbisius Edit
148
+
149
  == Changelog ==
150
 
151
+ = 1.3.0 =
152
+ * Happy new year!
153
+ * Copying parent theme's options (if any).
154
+ * Tested with WP 4.4.
155
+
156
  = 1.2.9 =
157
  * Added a link in the plugin's settings page to point to Appearance → Orbisius Child Theme Creator ( to save 1-2 seconds to the user :) )
158
  * Removed the Free test from qSandbox as there is no longer a free plan.