Version Description
- Added a new feature to Customize title, description etc of the new child theme
Download this release
Release Info
Developer | lordspace |
Plugin | Child Theme Creator by Orbisius |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.1.0
- orbisius-child-theme-creator.php +152 -13
- readme.txt +3 -0
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
|
7 |
Author: Svetoslav Marinov (Slavi)
|
8 |
Author URI: http://orbisius.com
|
9 |
*/
|
@@ -324,6 +324,7 @@ function orbisius_child_theme_creator_tools_action() {
|
|
324 |
$errors = $success = array();
|
325 |
$parent_theme_base_dirname = empty($_REQUEST['parent_theme_base_dirname']) ? '' : wp_kses($_REQUEST['parent_theme_base_dirname'], array());
|
326 |
$orbisius_child_theme_creator_nonce = empty($_REQUEST['orbisius_child_theme_creator_nonce']) ? '' : $_REQUEST['orbisius_child_theme_creator_nonce'];
|
|
|
327 |
|
328 |
$parent_theme_base_dirname = trim($parent_theme_base_dirname);
|
329 |
$parent_theme_base_dirname = preg_replace('#[^\w-]#si', '-', $parent_theme_base_dirname);
|
@@ -342,6 +343,7 @@ function orbisius_child_theme_creator_tools_action() {
|
|
342 |
if (empty($errors)) {
|
343 |
try {
|
344 |
$installer = new orbisius_child_theme_creator($parent_theme_base_dirname);
|
|
|
345 |
|
346 |
// Does the user want to copy the functions.php?
|
347 |
if (!empty($_REQUEST['copy_functions_php'])) {
|
@@ -458,16 +460,27 @@ function orbisius_child_theme_creator_tools_action() {
|
|
458 |
), admin_url( 'themes.php' ) ) ); */
|
459 |
|
460 |
$author_name = $theme_obj->get('Author');
|
461 |
-
$author_name =
|
462 |
-
$author_name = trim($author_name);
|
463 |
$author_name = empty($author_name) ? 'n/a' : $author_name;
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
$author_uri = $theme_obj->get('AuthorURI');
|
|
|
|
|
466 |
$author_line = empty($author_uri)
|
467 |
? $author_name
|
468 |
: "<a title='Visit author homepage' href='$author_uri' target='_blank'>$author_name</a>";
|
469 |
|
470 |
-
$author_line .= " | Ver.$
|
471 |
|
472 |
$edit_theme_link = orbisius_child_theme_creator_util::get_theme_editor_link( array('theme_1' => $theme_basedir_name) );
|
473 |
$author_line .= " | <a href='$edit_theme_link' title='Edit with Orbisius Theme Editor'>Edit</a>\n";
|
@@ -475,7 +488,7 @@ function orbisius_child_theme_creator_tools_action() {
|
|
475 |
$buff .= "<div class='available-theme'>\n";
|
476 |
$buff .= "<form action='$create_url' method='post'>\n";
|
477 |
$buff .= "<img class='screenshot' src='$src' alt='' />\n";
|
478 |
-
$buff .= "<h3>$
|
479 |
$buff .= "<div class='theme-author'>By $author_line</div>\n";
|
480 |
$buff .= "<div class='action-links'>\n";
|
481 |
$buff .= "<ul>\n";
|
@@ -514,6 +527,55 @@ function orbisius_child_theme_creator_tools_action() {
|
|
514 |
. "Switch theme to the new theme after it is created</label></li>\n";
|
515 |
}
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
$buff .= "<li> <button type='submit' class='button button-primary'>Create Child Theme</button> </li>\n";
|
518 |
|
519 |
$buff .= "</ul>\n";
|
@@ -718,6 +780,28 @@ class orbisius_child_theme_creator {
|
|
718 |
return $this->target_base_dirname;
|
719 |
}
|
720 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
721 |
/**
|
722 |
* Loads files from a directory but skips . and ..
|
723 |
*/
|
@@ -808,15 +892,48 @@ class orbisius_child_theme_creator {
|
|
808 |
|
809 |
$parent_theme_data = version_compare($wp_version, '3.4', '>=') ? wp_get_theme($this->parent_theme_basedir) : (object) get_theme_data($this->target_dir_path . 'style.css');
|
810 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
$buff = '';
|
812 |
$buff .= "/*\n";
|
813 |
-
$buff .= "Theme Name: $
|
814 |
-
$buff .= "Theme URI: $
|
815 |
-
$buff .= "Description: $
|
816 |
-
$buff .= "Author: $
|
817 |
-
$buff .= "Author URI: $
|
818 |
$buff .= "Template: $this->parent_theme_basedir\n";
|
819 |
-
$buff .= "Version: $
|
820 |
$buff .= "*/\n";
|
821 |
|
822 |
$buff .= "\n/* Generated by $app_title ($app_link) on " . date('r') . " */ \n\n";
|
@@ -829,7 +946,7 @@ class orbisius_child_theme_creator {
|
|
829 |
if (file_exists($this->parent_theme_dir . 'rtl.css')) {
|
830 |
$rtl_buff = '';
|
831 |
$rtl_buff .= "/*\n";
|
832 |
-
$rtl_buff .= "Theme Name: $
|
833 |
$rtl_buff .= "Template: $this->parent_theme_basedir\n";
|
834 |
$rtl_buff .= "*/\n";
|
835 |
|
@@ -840,9 +957,11 @@ class orbisius_child_theme_creator {
|
|
840 |
file_put_contents($this->target_dir_path . 'rtl.css', $rtl_buff);
|
841 |
}
|
842 |
|
|
|
|
|
843 |
$this->info_result = "$parent_theme_data->Name " . $this->target_name_suffix . ' has been created in ' . $this->target_dir_path
|
844 |
. ' based on ' . $parent_theme_data->Name . ' theme.'
|
845 |
-
. "\n<br/>Next
|
846 |
}
|
847 |
|
848 |
/**
|
@@ -867,6 +986,26 @@ class orbisius_child_theme_creator {
|
|
867 |
* Util funcs
|
868 |
*/
|
869 |
class orbisius_child_theme_creator_util {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
870 |
/**
|
871 |
* Returns a link to appearance. Taking into account multisite.
|
872 |
*
|
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.1.0
|
7 |
Author: Svetoslav Marinov (Slavi)
|
8 |
Author URI: http://orbisius.com
|
9 |
*/
|
324 |
$errors = $success = array();
|
325 |
$parent_theme_base_dirname = empty($_REQUEST['parent_theme_base_dirname']) ? '' : wp_kses($_REQUEST['parent_theme_base_dirname'], array());
|
326 |
$orbisius_child_theme_creator_nonce = empty($_REQUEST['orbisius_child_theme_creator_nonce']) ? '' : $_REQUEST['orbisius_child_theme_creator_nonce'];
|
327 |
+
$child_custom_info = empty($_REQUEST['child_custom_info']) ? array() : $_REQUEST['child_custom_info'];
|
328 |
|
329 |
$parent_theme_base_dirname = trim($parent_theme_base_dirname);
|
330 |
$parent_theme_base_dirname = preg_replace('#[^\w-]#si', '-', $parent_theme_base_dirname);
|
343 |
if (empty($errors)) {
|
344 |
try {
|
345 |
$installer = new orbisius_child_theme_creator($parent_theme_base_dirname);
|
346 |
+
$installer->custom_info($child_custom_info);
|
347 |
|
348 |
// Does the user want to copy the functions.php?
|
349 |
if (!empty($_REQUEST['copy_functions_php'])) {
|
460 |
), admin_url( 'themes.php' ) ) ); */
|
461 |
|
462 |
$author_name = $theme_obj->get('Author');
|
463 |
+
$author_name = orbisius_child_theme_creator_util::sanitize_data($author_name);
|
|
|
464 |
$author_name = empty($author_name) ? 'n/a' : $author_name;
|
465 |
|
466 |
+
$ver = $theme_obj->get('Version');
|
467 |
+
$ver = orbisius_child_theme_creator_util::sanitize_data($ver);
|
468 |
+
$ver_esc = esc_attr($ver);
|
469 |
+
|
470 |
+
$theme_name = $theme_obj->get('Name');
|
471 |
+
$theme_name = orbisius_child_theme_creator_util::sanitize_data($theme_name);
|
472 |
+
|
473 |
+
$theme_uri = $theme_obj->get('ThemeURI');
|
474 |
+
$theme_uri = orbisius_child_theme_creator_util::sanitize_data($theme_uri);
|
475 |
+
|
476 |
$author_uri = $theme_obj->get('AuthorURI');
|
477 |
+
$author_uri = orbisius_child_theme_creator_util::sanitize_data($author_uri);
|
478 |
+
|
479 |
$author_line = empty($author_uri)
|
480 |
? $author_name
|
481 |
: "<a title='Visit author homepage' href='$author_uri' target='_blank'>$author_name</a>";
|
482 |
|
483 |
+
$author_line .= " | Ver.$ver_esc\n";
|
484 |
|
485 |
$edit_theme_link = orbisius_child_theme_creator_util::get_theme_editor_link( array('theme_1' => $theme_basedir_name) );
|
486 |
$author_line .= " | <a href='$edit_theme_link' title='Edit with Orbisius Theme Editor'>Edit</a>\n";
|
488 |
$buff .= "<div class='available-theme'>\n";
|
489 |
$buff .= "<form action='$create_url' method='post'>\n";
|
490 |
$buff .= "<img class='screenshot' src='$src' alt='' />\n";
|
491 |
+
$buff .= "<h3>$theme_name</h3>\n";
|
492 |
$buff .= "<div class='theme-author'>By $author_line</div>\n";
|
493 |
$buff .= "<div class='action-links'>\n";
|
494 |
$buff .= "<ul>\n";
|
527 |
. "Switch theme to the new theme after it is created</label></li>\n";
|
528 |
}
|
529 |
|
530 |
+
// This allows the users to specify title and description of the target child theme
|
531 |
+
$customize_info_container_id = 'orbisius_ctc_cust_info_' . md5($src);
|
532 |
+
|
533 |
+
$buff .= "<li><label><input type='checkbox' id='orbisius_child_theme_creator_customize_info' name='customize_info' value='1'"
|
534 |
+
. " onclick='jQuery(\"#$customize_info_container_id\").toggle(\"fast\");' /> "
|
535 |
+
. "Customize title, description etc.<br/></label></li>\n";
|
536 |
+
|
537 |
+
$cust_info_name = 'Child of ' . $theme_name;
|
538 |
+
$cust_info_name_esc = esc_attr($cust_info_name);
|
539 |
+
|
540 |
+
$cust_info_descr = $theme_obj->Description;
|
541 |
+
$cust_info_descr = wp_kses($cust_info_descr, array());
|
542 |
+
$cust_info_descr_esc = esc_attr($cust_info_descr);
|
543 |
+
|
544 |
+
$author_name_esc = esc_attr($author_name);
|
545 |
+
$author_uri_esc = esc_attr($author_uri);
|
546 |
+
$theme_uri_esc = esc_attr($theme_uri);
|
547 |
+
|
548 |
+
$buff .= "<div id='$customize_info_container_id' class='app-hide'>
|
549 |
+
<table class='form-table'>
|
550 |
+
<tr>
|
551 |
+
<td>Title</td>
|
552 |
+
<td><input type='text' id='cust_child_theme_title_$customize_info_container_id' name='child_custom_info[name]' value='' placeholder='$cust_info_name_esc' /></td>
|
553 |
+
</tr>
|
554 |
+
<tr>
|
555 |
+
<td>Description</td>
|
556 |
+
<td><textarea id='cust_child_theme_descr_$customize_info_container_id' name='child_custom_info[descr]' placeholder='$cust_info_descr_esc' rows='4'></textarea></td>
|
557 |
+
</tr>
|
558 |
+
<tr>
|
559 |
+
<td>Theme Site</td>
|
560 |
+
<td><input type='text' id='cust_child_theme_uri_$customize_info_container_id' name='child_custom_info[theme_uri]' value='' placeholder='$theme_uri_esc' /></td>
|
561 |
+
</tr>
|
562 |
+
<tr>
|
563 |
+
<td>Author Name</td>
|
564 |
+
<td><input type='text' id='cust_child_theme_author_$customize_info_container_id' name='child_custom_info[author]' value='' placeholder='$author_name_esc' /></td>
|
565 |
+
</tr>
|
566 |
+
<tr>
|
567 |
+
<td>Author Site</td>
|
568 |
+
<td><input type='text' id='cust_child_theme_author_site_$customize_info_container_id' name='child_custom_info[author_uri]' value='' placeholder='$author_uri_esc' /></td>
|
569 |
+
</tr>
|
570 |
+
<tr>
|
571 |
+
<td>Version</td>
|
572 |
+
<td><input type='text' id='cust_child_theme_ver_$customize_info_container_id' name='child_custom_info[ver]' value='' placeholder='$ver' /></td>
|
573 |
+
</tr>
|
574 |
+
</table>
|
575 |
+
</div> <!-- /$customize_info_container_id -->
|
576 |
+
";
|
577 |
+
// /This allows the users to specify title and description of the target child theme
|
578 |
+
|
579 |
$buff .= "<li> <button type='submit' class='button button-primary'>Create Child Theme</button> </li>\n";
|
580 |
|
581 |
$buff .= "</ul>\n";
|
780 |
return $this->target_base_dirname;
|
781 |
}
|
782 |
|
783 |
+
private $custom_info = array();
|
784 |
+
|
785 |
+
/**
|
786 |
+
* Get/sets custom info that is related to the child theme
|
787 |
+
* It accepts array or key val or just get all of the custom data
|
788 |
+
* @param void
|
789 |
+
* @return string returns the dirname (not abs) of the child theme
|
790 |
+
*/
|
791 |
+
public function custom_info($key = null, $value = null) {
|
792 |
+
if (!is_null($key)) {
|
793 |
+
if (is_array($key)) { // set array
|
794 |
+
$this->custom_info = orbisius_child_theme_creator_util::sanitize_data($key);
|
795 |
+
} else if (!is_null($value)) { // set scalar
|
796 |
+
$this->custom_info[$key] = orbisius_child_theme_creator_util::sanitize_data($value);
|
797 |
+
} else { // get for a key
|
798 |
+
return $this->custom_info[$key];
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
return $this->custom_info; // all custom info requested
|
803 |
+
}
|
804 |
+
|
805 |
/**
|
806 |
* Loads files from a directory but skips . and ..
|
807 |
*/
|
892 |
|
893 |
$parent_theme_data = version_compare($wp_version, '3.4', '>=') ? wp_get_theme($this->parent_theme_basedir) : (object) get_theme_data($this->target_dir_path . 'style.css');
|
894 |
|
895 |
+
$theme_name = "$parent_theme_data->Name $this->target_name_suffix";
|
896 |
+
$theme_uri = $parent_theme_data->ThemeURI;
|
897 |
+
$theme_descr = "$this->target_name_suffix theme for the $parent_theme_data->Name theme";
|
898 |
+
$theme_author = $parent_theme_data->Author;
|
899 |
+
$theme_author_uri = $parent_theme_data->AuthorURI;
|
900 |
+
$ver = $parent_theme_data->Version;
|
901 |
+
|
902 |
+
$custom_info = $this->custom_info();
|
903 |
+
|
904 |
+
if (!empty($custom_info['name'])) {
|
905 |
+
$theme_name = $custom_info['name'];
|
906 |
+
}
|
907 |
+
|
908 |
+
if (!empty($custom_info['theme_uri'])) {
|
909 |
+
$theme_uri = $custom_info['theme_uri'];
|
910 |
+
}
|
911 |
+
|
912 |
+
if (!empty($custom_info['descr'])) {
|
913 |
+
$theme_descr = $custom_info['descr'];
|
914 |
+
}
|
915 |
+
|
916 |
+
if (!empty($custom_info['author'])) {
|
917 |
+
$theme_author = $custom_info['author'];
|
918 |
+
}
|
919 |
+
|
920 |
+
if (!empty($custom_info['author_uri'])) {
|
921 |
+
$theme_author_uri = $custom_info['author_uri'];
|
922 |
+
}
|
923 |
+
|
924 |
+
if (!empty($custom_info['ver'])) {
|
925 |
+
$ver = $custom_info['ver'];
|
926 |
+
}
|
927 |
+
|
928 |
$buff = '';
|
929 |
$buff .= "/*\n";
|
930 |
+
$buff .= "Theme Name: $theme_name\n";
|
931 |
+
$buff .= "Theme URI: $theme_uri\n";
|
932 |
+
$buff .= "Description: $theme_descr\n";
|
933 |
+
$buff .= "Author: $theme_author\n";
|
934 |
+
$buff .= "Author URI: $theme_author_uri\n";
|
935 |
$buff .= "Template: $this->parent_theme_basedir\n";
|
936 |
+
$buff .= "Version: $ver\n";
|
937 |
$buff .= "*/\n";
|
938 |
|
939 |
$buff .= "\n/* Generated by $app_title ($app_link) on " . date('r') . " */ \n\n";
|
946 |
if (file_exists($this->parent_theme_dir . 'rtl.css')) {
|
947 |
$rtl_buff = '';
|
948 |
$rtl_buff .= "/*\n";
|
949 |
+
$rtl_buff .= "Theme Name: $theme_name\n";
|
950 |
$rtl_buff .= "Template: $this->parent_theme_basedir\n";
|
951 |
$rtl_buff .= "*/\n";
|
952 |
|
957 |
file_put_contents($this->target_dir_path . 'rtl.css', $rtl_buff);
|
958 |
}
|
959 |
|
960 |
+
$themes_url = admin_url('themes.php');
|
961 |
+
|
962 |
$this->info_result = "$parent_theme_data->Name " . $this->target_name_suffix . ' has been created in ' . $this->target_dir_path
|
963 |
. ' based on ' . $parent_theme_data->Name . ' theme.'
|
964 |
+
. "\n<br/>Next go to <a href='$themes_url'><strong>Appearance > Themes</strong></a> and Activate the new theme.";
|
965 |
}
|
966 |
|
967 |
/**
|
986 |
* Util funcs
|
987 |
*/
|
988 |
class orbisius_child_theme_creator_util {
|
989 |
+
/**
|
990 |
+
* Uses wp_kses to sanitize the data
|
991 |
+
* @param str/array $value
|
992 |
+
* @return mixed: str/array
|
993 |
+
* @throws Exception
|
994 |
+
*/
|
995 |
+
public static function sanitize_data($value = null) {
|
996 |
+
if (is_scalar($value)) {
|
997 |
+
$value = wp_kses($value, array());
|
998 |
+
$value = preg_replace('#\s+#si', ' ', $value);
|
999 |
+
$value = trim($value);
|
1000 |
+
} else if (is_array($value)) {
|
1001 |
+
$value = array_map(__METHOD__, $value);
|
1002 |
+
} else {
|
1003 |
+
throw new Exception(__METHOD__. " Cannot sanitize because of invalid input data.");
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
return $value;
|
1007 |
+
}
|
1008 |
+
|
1009 |
/**
|
1010 |
* Returns a link to appearance. Taking into account multisite.
|
1011 |
*
|
readme.txt
CHANGED
@@ -114,6 +114,9 @@ Go to http://club.orbisius.com and post suggestions in our forum for new feature
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
117 |
= 1.0.9 =
|
118 |
* Fixed: JS errors are cause errors with other plugins
|
119 |
* Loads plugin's JS/CSS files only on child theme creator pages (admin area)
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 1.1.0 =
|
118 |
+
* Added a new feature to Customize title, description etc of the new child theme
|
119 |
+
|
120 |
= 1.0.9 =
|
121 |
* Fixed: JS errors are cause errors with other plugins
|
122 |
* Loads plugin's JS/CSS files only on child theme creator pages (admin area)
|