Changeset 1122710
- Timestamp:
- 03/28/2015 01:44:15 PM (11 years ago)
- Location:
- one-click-child-theme/trunk
- Files:
-
- 4 edited
-
one-click-child-theme.php (modified) (9 diffs)
-
readme.txt (modified) (5 diffs)
-
templates/create_child_form.php (modified) (1 diff)
-
templates/is_child_already.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
one-click-child-theme/trunk/one-click-child-theme.php
r1119254 r1122710 1 <?php /* 1 <?php 2 /* 2 3 ************************************************************************** 3 4 4 5 Plugin Name: One-Click Child Theme 5 6 Plugin URI: http://terrychay.com/wordpress-plugins/one-click-child-theme 6 Version: 1.5 7 Description: Allows you to easily child theme any theme from the theme 8 options on the wp-admin instead of going into shell or 9 using FTP. 7 Version: 1.6 8 Description: Easily child theme any theme from wp-admin wp-admin without going into shell or using FTP. 10 9 Author: tychay 11 10 Author URI: http://terrychay.com/ 11 License: GPLv2 or later 12 License URI: https://www.gnu.org/licenses/gpl-2.0.html 13 Text Domain: one-click-child-theme 14 //Domain Path: 12 15 13 16 **************************************************************************/ … … 26 29 along with this program; if not, write to the Free Software 27 30 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 31 */ 32 /* 33 * Performance: One-Click Child Theme is only active in admin page 34 */ 35 if (!is_admin()) { return; } 36 /** 37 * The namespace for the One-Click Child Theme Plugin 28 38 */ 29 39 class OneClickChildTheme { 30 private $plugin_dir = ''; 31 function __construct() { 32 $this->plugin_dir = dirname(__FILE__); 40 /** 41 * @const string Used for id generation and language text domain. 42 */ 43 const _SLUG = 'one-click-child-theme'; 44 /** 45 * Used for loading in files 46 * @var string 47 */ 48 private $_pluginDir = ''; 49 /** 50 * This plugin's theme page 51 */ 52 private $_themePageUrl = ''; 53 /** 54 * Theme page name (menu slug) 55 * @var string 56 */ 57 private $_menuId = ''; 58 /** 59 * action for Create Child form 60 */ 61 private $_createChildFormId = ''; 62 /** 63 * action for Repair Child form 64 */ 65 private $_repairChildFormId = ''; 66 /** 67 * action for Copy Template form 68 */ 69 private $_copyTemplateFormId = ''; 70 /** 71 * action for screenshot generation 72 */ 73 private $_mshotSiteFormId = ''; 74 75 public function __construct() { 76 $this->_pluginDir = dirname(__FILE__); 77 $this->_menuId = self::_SLUG . '-page'; 78 $this->_themePageUrl = admin_url('themes.php?page='.$this->_menuId); 79 $this->_createChildFormId = self::_SLUG.'-create-child'; 80 $this->_repairChildFormId = self::_SLUG.'-repair-child'; 81 $this->_copyTemplateFormId = self::_SLUG.'-copy-template'; 82 $this->_mshotSiteFormId = self::_SLUG.'-mshot-site'; 83 33 84 // it has to be buried like this or you get an error: 34 85 // "You do not have sufficient permissions to access this page" 35 add_filter( 'admin_menu', array( $this, 'createMenu' ) ); 36 } 37 function createMenu() { 38 add_theme_page( 'Make a Child Theme', 'Child Theme', 'install_themes', 'one-click-child-theme-page', array( $this, 'showThemePage' ) ); 39 } 40 86 add_action( 'admin_menu', array($this,'createAdminMenu') ); 87 88 // form handling code 89 add_action( 'admin_post_'.$this->_createChildFormId, array($this,'processCreateForm') ); 90 add_action( 'admin_post_'.$this->_repairChildFormId, array($this,'processRepairChildForm') ); 91 add_action( 'admin_post_'.$this->_copyTemplateFormId, array($this,'processCopyTemplateForm') ); 92 add_action( 'admin_post_'.$this->_mshotSiteFormId, array($this,'processMShotSiteForm') ); 93 // TODO: I could also use the $pagenow global, but is it still there? 94 if ( basename($_SERVER['PHP_SELF']) == 'themes.php' && !empty($_REQUEST['occt_error']) ) { 95 add_action( 'admin_notices', array($this,'showErrorNotice')); 96 } 97 } 98 /** 99 * Handle error and update notices for this theme 100 * 101 * There are now four types of notices: success (green), warning (orange), error (red), 102 * and info (blue). 103 * 104 * Put here because there is a redirect between all forms and error notifications and 105 * add_settings_error() only covers options API errors. 106 */ 107 public function showErrorNotice() 108 { 109 switch ($_GET['occt_error']) { 110 case 'child_created': //SUCCESS: child theme created 111 $type = 'updated'; //fade? 112 $msg = sprintf( 113 __('Theme switched! <a href="%s">Click here to edit the child stylesheet</a>.', self::_SLUG), 114 add_query_arg( 115 urlencode_deep(array( 116 'file' => 'style.css', 117 'theme' => get_stylesheet(), 118 )), 119 admin_url('theme-editor.php') 120 ) 121 ); 122 break; 123 case 'create_failed': //ERROR: create file failed (probably due to permissions) 124 $type = 'error'; 125 $msg = sprintf( 126 __('Failed to create file: %s', self::_SLUG), 127 esc_html($_GET['filename']) 128 ); 129 break; 130 case 'edit_failed': //ERROR: edit file failed (probably do to permissions) 131 $type = 'error'; 132 $msg = sprintf( 133 __('Failed to edit file: %s', self::_SLUG), 134 esc_html($_GET['filename']) 135 ); 136 break; 137 case 'repair_success': //SUCCESS: repaired child theme 138 $type = 'updated fade'; 139 $msg = __('Repaired child theme.', self::_SLUG); 140 break; 141 case 'no_template': //ERROR: template file not specified 142 $type = 'error'; 143 $msg = __('No template file specified.', self::_SLUG); 144 case 'missing_template': //ERROR: parent theme doesn't have template 145 $type = 'error'; 146 $msg = sprintf( 147 __('Template file %s does not exist in parent theme!', self::_SLUG), 148 esc_html($_GET['filename']) 149 ); 150 break; 151 case 'already_template': //ERROR: child theme already has template 152 $type = 'error'; 153 $msg = sprintf( 154 __('Template file %s already exists in child theme!', self::_SLUG), 155 esc_html($_GET['filename']) 156 ); 157 break; 158 case 'copy_failed': //ERROR: couldn't duplicate file for some reason 159 $type = 'error'; 160 $msg = sprintf( 161 __('Failed to duplicate file %s!', self::_SLUG), 162 esc_html($_GET['filename']) 163 ); 164 break; 165 case 'copy_success': //SUCCESS: template file created 166 $type = 'updated'; //fade? 167 $msg = sprintf( 168 __('<a href="%s">File %s created!</a>', self::_SLUG), 169 add_query_arg( 170 urlencode_deep(array( 171 'file' => $_GET['filename'], 172 'theme' => get_stylesheet(), 173 )), 174 admin_url('theme-editor.php') 175 ), 176 esc_html($_GET['filename']) 177 ); 178 break; 179 case 'delete_failed': //ERROR: couldn't delete file for some reason 180 $type = 'error'; 181 $msg = sprintf( 182 __('Failed to delete file %s!', self::_SLUG), 183 esc_html($_GET['filename']) 184 ); 185 break; 186 case 'mshot_404': //ERROR: couldn't find mshot 187 $type = 'error'; 188 $msg = sprintf( 189 __('404 File not found at %s!', self::_SLUG), 190 esc_html($_GET['url']) 191 ); 192 break; 193 case 'mshot_mime_wrong': //ERROR: couldn't find mshot 194 $type = 'error'; 195 $msg = sprintf( 196 __('Unrecognized mimetype at %s!', self::_SLUG), 197 esc_html($_GET['url']) 198 ); 199 break; 200 case 'mshot_nocreate': //ERROR: couldn't find mshot 201 $type = 'error'; 202 $msg = sprintf( 203 __('Failed to create file %s!', self::_SLUG), 204 esc_html($_GET['filename']) 205 ); 206 break; 207 case 'mshot_success': //SUCCESS: screenshot generated 208 $type = 'updated fade'; //fade? 209 $msg = __('Successfully changed screenshot.', self::_SLUG); 210 break; 211 default: //ERROR: it is a generic error message 212 $type = 'error'; 213 $msg = esc_html($_GET['occt_error']); 214 } 215 printf( 216 '<div class="%s"><p>%s</p></div>', 217 $type, 218 $msg 219 ); 220 } 221 /** 222 * Adds an admin menu for One Click Child Theme in Appearances 223 */ 224 public function createAdminMenu() { 225 add_theme_page( 226 __('Make a Child Theme', self::_SLUG), //page title 227 __('Child Theme', self::_SLUG), //menu title 228 'install_themes', //capability needed to view 229 $this->_menuId, //menu slug (and page query url) 230 array( $this, 'showThemePage' ) //callback function 231 ); 232 } 233 // 234 // SHOW THEME PAGE 235 // 41 236 /** 42 237 * Show the theme page which has a form allowing you to child theme 43 238 * currently selected theme. 44 */ 45 function showThemePage() { 46 47 if ( !empty($_POST['cmd'])) { 48 // Handle Make Child Theme form 49 if ( strcmp($_POST['cmd'],'create_child_theme') == 0 ) { 50 $this->_handle_create_child_form(); 51 return; 52 } 53 // Handle one-click repair form 54 if ( strcmp($_POST['cmd'],'repair_child_theme') == 0 ) { 55 $this->_handle_repair_child_theme(); 56 $this->_show_child_already_form( $this->_child_theme_needs_repair() ); 57 return; 58 } 59 // Handle child filing form 60 if ( strcmp($_POST['cmd'],'copy_template_file') == 0 ) { 61 $this->_handle_copy_template_file(); 62 $this->_show_child_already_form( $this->_child_theme_needs_repair() ); 63 return; 64 } 65 } 66 239 * 240 */ 241 public function showThemePage() 242 { 243 // Form is processed in the admin_post_* hooks 244 245 // Handle case where current theme is already a child 67 246 if ( is_child_theme() ) { 68 $this->_show_child_already_form( $this->_child_theme_needs_repair() ); 69 return; 70 } 71 72 // Default behavior: not a child, interested in child themeing 73 if ( !isset($theme_name) ) { $theme_name = ''; } 74 if ( !isset($description) ) { $description = ''; } 75 if ( empty($author) ) { 247 $this->_showFormAlreadyChild( $this->_child_theme_needs_repair() ); 248 return; 249 } 250 251 // Default behavior: We are not a child theme, but interested in creating one. 252 // Grab default values from a form fail 253 $theme_name = ( !empty($_GET['theme_name']) ) ? $_GET['theme_name'] : ''; 254 $description = ( !empty($_GET['description']) ) ? $_GET['description'] : ''; 255 if ( !empty($_GET['author_name']) ) { 256 $author = $_GET['author_name']; 257 } else { 76 258 global $current_user; 77 259 get_currentuserinfo(); 78 260 $author = $current_user->display_name; 79 261 } 80 require $this->plugin_dir.'/templates/create_child_form.php'; 262 // render default behaivor 263 require $this->_pluginDir.'/templates/create_child_form.php'; 81 264 } 82 265 … … 84 267 * Show the "is child already" template. 85 268 * @param boolean $child_needs_repair whether or not child theme needs repair 86 */ 87 private function _show_child_already_form($child_needs_repair) { 269 * @todo handle grandchildren 270 */ 271 private function _showFormAlreadyChild($child_needs_repair) { 272 // set template parameters 88 273 $current_theme = wp_get_theme(); 89 $filename='test.php'; 90 274 $child_theme_screenshot_url = ( $screenshot_filename = $this->_scanForScreenshot( get_stylesheet_directory() ) ) 275 ? get_stylesheet_directory_uri().'/'.$screenshot_filename 276 : ''; 277 $mshot_url = $this->_mshotUrl(); 91 278 // Search for template files. 92 279 // Note: since there can be files like {mimetype}.php, we must assume … … 104 291 } 105 292 } 106 require $this->plugin_dir.'/templates/is_child_already.php'; 107 //TODO: handle grandchildren 108 } 109 110 /** 111 * Handle the copy_template form. 112 */ 113 private function _handle_copy_template_file() { 114 $filename = ( empty($_POST['filename']) ) 115 ? '' 116 : $_POST['filename']; 117 if ( !$filename ) { 118 add_settings_error( 119 '', 120 'one-click-child-theme', 121 __('No template file specified.', 'one-click-child-theme'), 122 $result->get_error_message(), 123 'error' 124 ); 125 return; 126 } 127 $child_theme_dir = get_stylesheet_directory(); 128 $template_dir = get_template_directory(); 129 var_dump('bar'); 130 if ( !file_exists($template_dir.'/'.$filename) ) { 131 add_settings_error( 132 '', 133 'one-click-child-theme', 134 sprintf( __('Template file %s does not exist in parent theme!', 'one-click-child-theme'), 135 $filename 136 ), 137 $result->get_error_message(), 138 'error' 139 ); 140 return; 141 } 142 if ( file_exists($child_theme_dir.'/'.$filename) ) { 143 add_settings_error( 144 '', 145 'one-click-child-theme', 146 sprintf( __('Template file %s already exists in child theme!', 'one-click-child-theme'), 147 $filename 148 ), 149 $result->get_error_message(), 150 'error' 151 ); 152 return; 153 } 154 if ( !copy( $template_dir.'/'.$filename, $child_theme_dir.'/'.$filename ) ) { 155 add_settings_error( 156 '', 157 'one-click-child-theme', 158 sprintf( __('Failed to duplicate file %s!', 'one-click-child-theme'), 159 $filename 160 ), 161 $result->get_error_message(), 162 'error' 163 ); 164 } 165 add_settings_error( 166 '', 167 'one-click-child-theme', 168 sprintf(__('<a href="%s">File %s created!</a>', 'one-click-child-theme'), 169 admin_url( sprintf( 'theme-editor.php?file=%s&theme=%s', 170 urlencode($filename), 171 urlencode(get_stylesheet()) 172 )), 173 $filename 174 ), 175 'updated' 176 ); 177 return; 178 } 179 180 /** 181 * Handle the create_child_theme form. 182 */ 183 private function _handle_create_child_form() { 293 require $this->_pluginDir.'/templates/is_child_already.php'; 294 } 295 // 296 // FORM HANDLING 297 // 298 /** 299 * Handle the create child form. 300 */ 301 public function processCreateForm() { 302 check_admin_referer( $this->_createChildFormId . '-verify' ); 184 303 $theme_name = $_POST['theme_name']; 185 304 $description = ( empty($_POST['description']) ) … … 191 310 $result = $this->_make_child_theme( $theme_name, $description, $author_name ); 192 311 if ( is_wp_error( $result ) ) { 193 add_settings_error(194 '',195 'one-click-child-theme',312 // should show create child form again 313 $this->_redirect( 314 $this->_themePageUrl, 196 315 $result->get_error_message(), 197 'error' 198 ); 199 require $this->plugin_dir.'/templates/create_child_form.php'; 316 array( 317 'theme_name' => $theme_name, 318 'description' => $description, 319 'author_name' => $author_name, 320 ) 321 ); 322 return; 200 323 } else { 201 324 switch_theme( $result['parent_template'], $result['new_theme'] ); 202 add_settings_error( 203 '', 204 'one-click-child-theme', 205 sprintf(__('<a href="%s">Theme switched!</a>', 'one-click-child-theme'), admin_url( 'themes.php' ) ), 206 'updated' 207 ); 208 $this->_show_child_already_form(false); 209 // TODO: put a redirect in here somehow? 210 //wp_redirect( admin_url('themes.php') ); //buffer issue :-( 211 //exit; 212 } 213 } 214 215 /** 216 * Handle the repair_child_theme form. 217 */ 218 private function _handle_repair_child_theme() 325 // Redirect to themes page on success 326 $this->_redirect( 327 admin_url('themes.php'), 328 'child_created' 329 ); 330 } 331 } 332 /** 333 * Handle the repair_child_form form. 334 */ 335 public function processRepairChildForm() 219 336 { 337 check_admin_referer( $this->_repairChildFormId . '-verify' ); 220 338 $child_theme_dir = get_stylesheet_directory(); 221 339 $functions_file = $child_theme_dir.'/functions.php'; … … 225 343 if ( !file_exists($functions_file) ) { 226 344 if ( !touch($functions_file) ) { 227 add_settings_error( 228 '', 229 'one-click-child-theme', 230 sprintf( __('Failed to create file: %s', 'one-click-child-theme'), $functions_file ), 231 'error' 232 ); 233 // fixing is hopeless if we can't create the file 345 // fixing is hopeless if we can't create the file :-( 346 $this->_redirect( 347 $this->_themePageUrl, 348 'create_failed', 349 array( 'filename' => $functions_file ) 350 ); 234 351 return; 235 352 } … … 250 367 ); 251 368 if ( file_put_contents( $style_file, $style_text) === false ) { 252 add_settings_error( 253 '', 254 'one-click-child-theme', 255 sprintf( __('Failed edit to file: %s', 'one-click-child-theme'), $style_file ), 256 'error' 369 $this->_redirect( 370 $this->_themePageUrl, 371 'edit_failed', 372 array( 'filename' => $style_file ) 257 373 ); 258 374 return; … … 260 376 261 377 // modify functions.php to prepend new rules 262 $functions_text = file_get_contents( $this-> plugin_dir.'/templates/functions.php' );263 // ^^^ above file has no carriage return and ending comment so it should378 $functions_text = file_get_contents( $this->_pluginDir.'/templates/functions.php' ); 379 // ^^^ above file has no final carriage return and ending comment so it should 264 380 // "smash" the starting '<?php' string in any existing functions.php. 265 381 $functions_text .= file_get_contents( $functions_file ); 266 382 if ( file_put_contents( $functions_file, $functions_text ) === false ) { 267 add_settings_error( 268 '', 269 'one-click-child-theme', 270 sprintf( __('Failed edit to file: %s', 'one-click-child-theme'), $functions_file ), 271 'error' 272 ); 273 } 274 add_settings_error( 275 '', 276 'one-click-child-theme', 277 __('Repaired child theme.', 'one-click-child-theme'), 278 'updated' 383 $this->_redirect( 384 $this->_themePageUrl, 385 'edit_failed', 386 array( 'filename' => $functions_file ) 387 ); 388 return; 389 } 390 $this->_redirect( 391 $this->_themePageUrl, 392 'repair_success' 279 393 ); 280 return; 281 } 282 394 } 395 /** 396 * Handle the Copy Template form. 397 */ 398 public function processCopyTemplateForm() { 399 check_admin_referer( $this->_copyTemplateFormId . '-verify' ); 400 $filename = ( empty($_POST['filename']) ) 401 ? '' 402 : $_POST['filename']; 403 if ( !$filename ) { 404 $this->_redirect( 405 $this->_themePageUrl, 406 'no_template' 407 ); 408 return; 409 } 410 $child_theme_dir = get_stylesheet_directory(); 411 $template_dir = get_template_directory(); 412 var_dump('bar'); 413 if ( !file_exists($template_dir.'/'.$filename) ) { 414 $this->_redirect( 415 $this->_themePageUrl, 416 'missing_template', 417 array( 'filename' => $filename ) 418 ); 419 return; 420 } 421 if ( file_exists($child_theme_dir.'/'.$filename) ) { 422 $this->_redirect( 423 $this->_themePageUrl, 424 'already_template', 425 array( 'filename' => $filename ) 426 ); 427 return; 428 } 429 if ( !copy( $template_dir.'/'.$filename, $child_theme_dir.'/'.$filename ) ) { 430 $this->_redirect( 431 $this->_themePageUrl, 432 'copy_failed', 433 array( 'filename' => $filename ) 434 ); 435 } 436 $this->_redirect( 437 $this->_themePageUrl, 438 'copy_success', 439 array( 'filename' => $filename ) 440 ); 441 } 442 /** 443 * Handle the mshot Screenshot form 444 */ 445 public function processMShotSiteForm() 446 { 447 check_admin_referer( $this->_mshotSiteFormId . '-verify' ); 448 449 // delete existing screenshot if it exists 450 $child_theme_dir = get_stylesheet_directory(); 451 if ( $screenshot_filename = $this->_scanForScreenshot($child_theme_dir) ) { 452 $screenshot_path = $child_theme_dir.'/'.$screenshot_filename; 453 if ( !unlink($screenshot_path) ) { 454 // most likely a directory problem Fail with an error 455 $this->_redirect( 456 $this->_themePageUrl, 457 'delete_failed', 458 array( 'filename' => $screenshot_path ) 459 ); 460 return; 461 } 462 } 463 464 $mshot_url = $this->_mshotUrl(); 465 // Get the mshot 466 $response = wp_remote_get($mshot_url); 467 468 if ( $response['code'] == 404 ) { 469 // The 404 image is gorgeous nowadays, but (if wp.com correctly handled error 470 // codes for image generation) we'd not let them use it as a theme screenshot. 471 $this->_redirect( 472 $this->_themePageUrl, 473 'mshot_404', 474 array( 'url' => $mshot_url ) 475 ); 476 } 477 // Should be 'image/jpeg', but let's hedge our bets 478 switch ($response['headers']['content-type']) { 479 case 'image/jpeg': 480 $screenshot_filename = 'screenshot.jpg'; 481 break; 482 case 'image/png': 483 $screenshot_filename = 'screenshot.png'; 484 break; 485 case 'image/gif': 486 $screenshot_filename = 'screenshot.gif'; 487 break; 488 default: 489 $this->_redirect( 490 $this->_themePageUrl, 491 'mshot_mime_wrong', 492 array( 'url' => $mshot_url ) 493 ); 494 return; 495 } 496 $screenshot_path = $child_theme_dir.'/'.$screenshot_filename; 497 if ( file_put_contents($screenshot_path, $response['body']) === false ) { 498 $this->_redirect( 499 $this->_themePageUrl, 500 'mshot_nocreate', 501 array( 'filename' => $screenshot_path ) 502 ); 503 return; 504 } 505 506 $this->_redirect( 507 $this->_themePageUrl, 508 'mshot_success' 509 ); 510 } 511 512 // 513 // PRIVATE METHOD 514 // 515 /** 516 * Does the work to make a child theme based on the current theme. 517 * 518 * This currently supports the following files: 519 * 520 * 1. style.css: Follows the rules outlined in {@link http://codex.wordpress.org/Child_Themes the Codex} 521 * 2. functions.php: Followed the updated rules outlined in the Codex. Note 522 * that since WordPress ?.? functions.php hierarchy is automatically 523 * included. 524 * 3. rtl.css: right to left language support, if not avaialble in parent, it 525 * uses TwentyFifteen's rtl 526 * 4. screenshot.png: screenshot if available in the parent 527 * 528 * @author terry chay <[email protected]> 529 * @author Chris Robinson <http://contempographicdesign.com/> (for screenshot support). 530 * @return array|WP_Error If successful, it returns a hash contianing 531 * - new_theme: (directory) name of new theme 532 * - parent_template: (directory) name of parent template 533 * - parent_theme: (directory) name of parent theme 534 * - new_theme_path: full path to the directory cotnaining the new theme 535 * - new_theme_title: the name of the new theme 536 */ 537 private function _make_child_theme( $new_theme_title, $new_theme_description, $new_theme_author ) { 538 $parent_theme_title = get_current_theme(); 539 $parent_theme_template = get_template(); //Doesn't play nice with the grandkids 540 $parent_theme_name = get_stylesheet(); 541 $parent_theme_dir = get_stylesheet_directory(); 542 543 // Turn a theme name into a directory name 544 $new_theme_name = sanitize_title( $new_theme_title ); 545 $theme_root = get_theme_root(); 546 547 // Validate theme name 548 $new_theme_path = $theme_root.'/'.$new_theme_name; 549 if ( file_exists( $new_theme_path ) ) { 550 return new WP_Error( 'exists', __( 'Theme directory already exists!', self::_SLUG ) ); 551 } 552 553 mkdir( $new_theme_path ); 554 555 // Make style.css 556 ob_start(); 557 require $this->_pluginDir.'/templates/child-theme-css.php'; 558 $css = ob_get_clean(); 559 file_put_contents( $new_theme_path.'/style.css', $css ); 560 561 // "Generate" functions.php 562 copy( $this->_pluginDir.'/templates/functions.php', $new_theme_path.'/functions.php' ); 563 564 // RTL support 565 $rtl_theme = ( file_exists( $parent_theme_dir.'/rtl.css' ) ) 566 ? $parent_theme_name 567 : 'twentyfifteen'; //use the latest default theme rtl file 568 ob_start(); 569 require $this->_pluginDir.'/templates/rtl-css.php'; 570 $css = ob_get_clean(); 571 file_put_contents( $new_theme_path.'/rtl.css', $css ); 572 573 // Copy screenshot 574 if ( $screenshot_filename = $this->_scanForScreenshot( $parent_theme_dir ) ) { 575 copy( 576 $parent_theme_dir.'/'.$screenshot_filename, 577 $new_theme_path.'/'.$screenshot_filename 578 ); 579 } // removed grandfather screenshot check (use mshot instead, rly) 580 581 // Make child theme an allowed theme (network enable theme) 582 $allowed_themes = get_site_option( 'allowedthemes' ); 583 $allowed_themes[ $new_theme_name ] = true; 584 update_site_option( 'allowedthemes', $allowed_themes ); 585 586 return array( 587 'parent_template' => $parent_theme_template, 588 'parent_theme' => $parent_theme_name, 589 'new_theme' => $new_theme_name, 590 'new_theme_path' => $new_theme_path, 591 'new_theme_title' => $new_theme_title, 592 ); 593 } 594 // 595 // PRIVATE UTILITY FUNCTIONS 596 // 283 597 /** 284 598 * Detect if child theme needs repair. … … 311 625 return false; 312 626 } 313 314 /** 315 * Does the work to make a child theme based on the current theme. 316 * 317 * This currently supports the following files: 318 * 319 * 1. style.css: Follows the rules outlined in {@link http://codex.wordpress.org/Child_Themes the Codex} 320 * 2. functions.php: Followed the updated rules outlined in the Codex. Note 321 * that since WordPress ?.? functions.php hierarchy is automatically 322 * included. 323 * 3. rtl.css: right to left language support, if not avaialble in parent, it 324 * uses TwentyFifteen's rtl 325 * 4. screenshot.png: screenshot if available in the parent 326 * 327 * @author terry chay <[email protected]> 328 * @author Chris Robinson <http://contempographicdesign.com/> (for screenshot support). 329 * @return array|WP_Error If successful, it returns a hash contianing 330 * - new_theme: (directory) name of new theme 331 * - parent_template: (directory) name of parent template 332 * - parent_theme: (directory) name of parent theme 333 * - new_theme_path: full path to the directory cotnaining the new theme 334 * - new_theme_title: the name of the new theme 335 */ 336 private function _make_child_theme( $new_theme_title, $new_theme_description, $new_theme_author ) { 337 $parent_theme_title = get_current_theme(); 338 $parent_theme_template = get_template(); //Doesn't play nice with the grandkids 339 $parent_theme_name = get_stylesheet(); 340 341 // Turn a theme name into a directory name 342 $new_theme_name = sanitize_title( $new_theme_title ); 343 $theme_root = get_theme_root(); 344 345 // Validate theme name 346 $new_theme_path = $theme_root.'/'.$new_theme_name; 347 if ( file_exists( $new_theme_path ) ) { 348 return new WP_Error( 'exists', __( 'Theme directory already exists' ) ); 349 } 350 351 mkdir( $new_theme_path ); 352 353 // Make style.css 354 ob_start(); 355 require $this->plugin_dir.'/templates/child-theme-css.php'; 356 $css = ob_get_clean(); 357 file_put_contents( $new_theme_path.'/style.css', $css ); 358 359 // Copy functions.php 360 copy( $this->plugin_dir.'/templates/functions.php', $new_theme_path.'/functions.php' ); 361 362 // RTL support 363 $rtl_theme = ( file_exists( $theme_root.'/'.$parent_theme_name.'/rtl.css' ) ) 364 ? $parent_theme_name 365 : 'twentyfifteen'; //use the latest default theme rtl file 366 ob_start(); 367 require $this->plugin_dir.'/templates/rtl-css.php'; 368 $css = ob_get_clean(); 369 file_put_contents( $new_theme_path.'/rtl.css', $css ); 370 371 // Copy screenshot 372 $parent_theme_screenshot = $theme_root.'/'.$parent_theme_name.'/screenshot.png'; 373 if ( file_exists( $parent_theme_screenshot ) ) { 374 copy( $parent_theme_screenshot, $new_theme_path.'/screenshot.png' ); 375 } elseif (file_exists( $parent_theme_screenshot = $theme_root.'/'.$parent_theme_template.'/screenshot.png' ) ) { 376 copy( $parent_theme_screenshot, $new_theme_path.'/screenshot.png' ); 377 } 378 379 // Make child theme an allowed theme (network enable theme) 380 $allowed_themes = get_site_option( 'allowedthemes' ); 381 $allowed_themes[ $new_theme_name ] = true; 382 update_site_option( 'allowedthemes', $allowed_themes ); 383 384 return array( 385 'parent_template' => $parent_theme_template, 386 'parent_theme' => $parent_theme_name, 387 'new_theme' => $new_theme_name, 388 'new_theme_path' => $new_theme_path, 389 'new_theme_title' => $new_theme_title, 390 ); 391 627 /** 628 * Handle error redirects (for admin_notices generated by plugin) 629 * 630 * Note add_query_arg() is written like shit. Here are it's problems: 631 * 632 * 1. doesn't take advantage of built-in parse_url() 633 * 2. uses urlencode_deep() instead of an array_merge and built-in http_build_query() 634 * 3. doesn't urlencode() if $arg[0] is an array. 635 * 636 * The 3rd one is extremely non-intuitive, but fixing it, would break backward 637 * compatibility due to double-escaping. I'm hacking around that. :-( 638 * 639 * @param string $url The (base) url to redirect to, usually admin_url() 640 * @param string $error the error code to use 641 * @param string $args other arguments to add to the query string 642 * @return null 643 */ 644 private function _redirect($url, $error, $args = array()) { 645 $args['occt_error'] = $error; 646 $args = urlencode_deep($args); 647 wp_redirect( add_query_arg( $args, $url ) ); 648 } 649 /** 650 * Searches directory for a theme screenshot 651 * 652 * @param string $directory directory to search (a theme directory) 653 * @return string|false 'screenshot.png' (or whatever) or false if there is no screenshot 654 */ 655 private function _scanForScreenshot($directory) 656 { 657 $screenshots = glob( $directory.'/screenshot.{png,jpg,jpeg,gif}', GLOB_BRACE ); 658 return (empty($screenshots)) 659 ? false 660 : basename($screenshots[0]); 661 } 662 /** 663 * Generate mshot of wordpress homepage. 664 * 665 * Recommende image dimensions from https://codex.wordpress.org/Theme_Development#Screenshot 666 * @todo probably won't work correctly in multisite installs 667 * @todo remove debugging code 668 */ 669 private function _mshotUrl() 670 { 671 $scheme = (is_ssl()) ? 'https' : 'http'; 672 return $scheme . '://s.wordpress.com/mshots/v1/'. urlencode(get_site_url()) . '?w=880&h=660'; 392 673 } 393 674 -
one-click-child-theme/trunk/readme.txt
r1119254 r1122710 2 2 Contributors: tychay 3 3 Donate link: http://www.kiva.org/lender/tychay 4 Tags: theme, child theme, shared hosting, css, custom themeing4 Tags: theme, child theme, child theme creator, child theme creator, CSS, stylesheet, custom theme, customize theme, shared hosting 5 5 Requires at least: 3.0 6 Tested up to: 4.1 6 Tested up to: 4.1.1 7 7 Stable tag: trunk 8 8 … … 17 17 18 18 Ever since WordPress 3.0, you shouldn’t directly modify CSS of any downloaded 19 themes because if you update the theme, your changes will be destroyed. Instead, 20 it is recommended that you create a child theme and edit the CSS there, this way 21 updates to the parent theme will be inherited instead of destroy your changes. 22 The problem is that currently the only way to child theme something is edit 23 files on the filesystem. This is non-intuitive for shared-hosting sites with 24 one-click WordPress installs (it usually involves a “shell account” or learning 25 how to use FTP). 26 27 This attempts to get around that issue, by adding a button to the themes page to 28 allow you to child theme the page. (It’s not really one-click, though.) 19 themes because if you update the theme, your changes will be destroyed. Instead, it is recommended that you create a child theme and edit the CSS 20 there so that updates to the parent theme will be inherited instead of destroy 21 your changes. 22 23 The problem many run into is currently the only way to child theme something 24 is edit files on the filesystem. This is non-intuitive for shared-hosting 25 sites with one-click WordPress installs (it usually involves a “shell account” 26 or learning how to use FTP). 27 28 This attempts to get around that issue, by adding a button to the themes page 29 to allow you to child theme the page. (It’s not really one-click, though.) 29 30 30 31 Inspired by @janeforshort‘s and @designsimply's WordCamp SF 2011 talk on CSS … … 36 37 37 38 Extract all files from the ZIP file, making sure to keep the file structure 38 intact, and then upload it to `/wp-content/plugins/`. Then just visit your admin39 a rea and activate the plugin. That's it!39 intact, and then upload it to `/wp-content/plugins/`. Then just visit your 40 admin area and activate the plugin. That's it! 40 41 41 42 **See Also:** ["Installing Plugins" article on the WP Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) … … 59 60 You can wait for the theme to get updated and have it break it, of you can: 60 61 61 1. Go through the steps for installing and running the plugin above .62 1. Go through the steps for installing and running the plugin above to create a child theme 62 63 2. Click on the [Appearance > Editor](http://codex.wordpress.org/Appearance_Editor_SubPanel) in your admin dashboard menu (or network admin menu if multi-site). 63 64 3. Select the parent theme in the drop down on the right, click `Select` and make sure you are editing the file `style.css` (select on the right). … … 66 67 6. Paste your changes to the end of the file. 67 68 69 = Your plugin broken my site! = 70 71 I didn't think that's possible, but if so, I want to fix it! 72 73 First, check what really happened. Is your admin console broken, is the 74 theme broken (go to a new window and check your blog). If a theme fails to 75 work and for some reason I didn't catch that error, WordPress should restore 76 the previous theme (or whatever the default theme is) so your actual blog 77 should be okay and recoverable. If for some reason it didn't default to the 78 right theme, go into the Appearance menu and re-enable the parent theme. 79 80 Then go to the [support page](https://wordpress.org/support/plugin/one-click-child-theme), 81 describe what happened (screenshots help too) and anything else and we'll try 82 our best to help you. 83 84 = I can't find this Theme Option button you are alluding to in the documentation? = 85 86 I really need to update the screenshot. It's still there, but the location has 87 changed as WordPress has been upgraded. 88 89 1. Go to the `Appearance` tab 90 2. Click on the Active theme (it should say "Theme Details" when you mouseover) 91 3. An overlay appears. The Theme option button "Child Theme" is there 92 93 = When I go to the Child Theme menu, it says "X is already a child theme" and I can't create a child theme. = 94 95 Making grandchildren of themes is non-trivial, so I disabled the form if it is 96 already a child theme. Instead I offer the ability to repair the Child theme or 97 copy template files from the parent into the child for editing. 98 99 = Can the plugin be deleted after I create a Child Theme with it? = 100 101 Yes. The purpose of the plugin is fulfilled. Congratulations! Personally, I'd 102 disable it, instead of delete it. 103 104 Having said that, there are some things that it'll help with after your child 105 theme's birth. Think of it as a parenting guide for your new child theme. 106 107 = Features like? = 108 109 * Repair a child theme created in the old style. 110 * Copy templates over from your parent theme into your child theme. 111 * Replace the child theme screenshot with one of your site 112 113 When you have an active child theme, click on `Appearance > Child Theme` to 114 get to these functions. 115 68 116 = What does the "Repair Child Theme" button do? = 69 117 70 WordPress changed the [recommended way of handling parent references in child themes][http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme]. if this plugin detected 71 the child theme was done in the old style, it shows this button. Clicking on it 72 will make the plugin attempt a repair into the new style. 73 74 == TODO List == 75 76 * There is a buffering issue with form handling occurring so late, fix that. See https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action) 77 * The in theme button for childing is no longer there. Figure out if I can add it back. 78 * In some cases, settings_error() can be shown twice. Remove settings_error() after buffering fixed 79 * Better support for grandchildren (should copy the files over) 80 * Support for multiple theme directories [ may be fixed ] 81 * Error support is spotty at best 82 * Add a redirect to the theme page on completion (buffering issue needs fixed first) 83 * Use Theme_Upgrader/WP_Upgrader to figure out what files user may have trashed and ported them 118 WordPress changed the [recommended way of handling parent references in child themes][http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme]. 119 If this plugin detects your child theme was done in the old style, it shows 120 this button. Clicking on it will make the plugin attempt a repair into the 121 new style. 122 123 = How come the screenshot service just shows a big 404 = 124 125 The most likely scenario is your WordPress `site_url` isn't publicly 126 accessible from the web. 127 128 = What's with the debugging/error code on child theme creation? = 129 130 You have an old version of this plugin, please update to the latest one. 131 132 I wrote this plugin back **during** a talk at WordCamp SF 2011 about CSS 133 Themeing in order to help the person sitting next to me. I just didn't get to 134 some things… for years. Sorry about that! The debugging code didn't do affect any behavior, it was a sign of me being lazy and not realizing that the plugin 135 would have tens of thousands of avid users! :-( 136 137 = Why should I use your plugin and not [<insert competitor here> ](https://wordpress.org/plugins/search.php?q=child+theme) 138 139 What? People have forked my idea because I left Automattic (WordPress) for 140 Wikimedia (Wikipedia) three years ago? This means war! Other plugins, you're 141 going down! Steel yourself for the pent-up aggression of a pointy-haired boss 142 being kept away from the programming console for years. 143 144 As to why this plugin is the best, using anything else is like drinking 145 [New Coke](http://en.wikipedia.org/wiki/New_Coke) to OCCT's Coke Classic. 146 Experience the original plugin taste your parents knew and loved! Plus, I have 147 four-year old screenshots on my theme page, a way cooler plugin icon, and a 148 baby picture of me and my brother on the banner. Also, this plugin is free 149 (no "pro" version and not even a PayPal link), strikes the right balance of 150 features, and (now that I've figured out how to admin the plugin page), I've 151 been adding volunteers to support it even if I sucked into the vortex of 152 middle management again — isn't going to happen, that s--t is **EVIL**! 153 154 Which reminds me, if you want to help out, we're cool with that. Like WordPress 155 itself, this is a volunteer endeavor. 84 156 85 157 == ChangeLog == 86 158 159 **Version 1.6** 160 161 * Feature: Added ability to generate theme screenshots 162 * Feature: Redirect to theme page on child theme creation 163 * Feature: Successful child theme creation suggests you edit its `style.css` file 164 * Performance: Only run code in admin page 165 * Bug: Added in some missing gettext 166 * Bug: Removed the double errors/updates being displays 167 * Documentation: Make sure description is under 140 characters 168 * Documentation: Screenshots now display 169 * Documentation: Added banner image and plugin icon 170 * Documentation: Other minor tweaks including updated FAQ and license 171 87 172 **Version 1.5** 88 173 89 * Added ability to repair child theme90 * Added ability to copy any template file from parent theme.91 * Upgrade look of form to resemble most admin forms.92 * Properly shows a status message on success.93 * Added section for FAQ and Screenshots.94 * Some housecleaning of filesystem structure of plugin174 * Feature: Added ability to repair child theme 175 * Feature: Added ability to copy any template file from parent theme. 176 * Design: Upgrade look of form to resemble most admin forms. 177 * Bug Fix: Properly shows a status message on success. 178 * Documentation: Added section for FAQ and Screenshots. 179 * Documentation: Some housecleaning of filesystem structure of plugin 95 180 96 181 **Version 1.4** 97 182 98 * Modified to account for [changed best practice from using @import to function.php](http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)183 * Bug Fix: Modified to account for [changed best practice from using @import to function.php](http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme) 99 184 100 185 **Version 1.2** 101 186 102 * Remembers to network enable (activate) the theme after creation.103 * Added screenshot support (Thanks! Chris Robinson <http://contempographicdesign.com/>)104 * WP_Error handling105 * Refactored codebase187 * Bug Fix: Remembers to network enable (activate) the theme after creation. 188 * Feature: Added screenshot support (Thanks! Chris Robinson <http://contempographicdesign.com/>) 189 * Bug Fix: WP_Error handling 190 * Documentation: Refactored codebase 106 191 107 192 **Version 1.1** 108 193 109 * Added RTL support194 * Feature: Added RTL support 110 195 111 196 **Version 1.0.1** -
one-click-child-theme/trunk/templates/create_child_form.php
r1119236 r1122710 3 3 * Page for showing the child theme creation form. (In the Theme > Child Theme submenu.) 4 4 * 5 * Local Variables 6 * - $this/self: the OCCT object 7 * - $parent_theme_name: the human-readable name of the parent theme 8 * - $theme_name: form variable (if error) 9 * - $description: form variable (if error) 10 * - $author: form variable 5 11 * @author terry chay <[email protected]> 6 12 */ 7 settings_errors();8 13 ?> 9 14 <div class="wrap"> 10 15 11 <h2><?php _e('Create a Child Theme','one-click-child-theme') ?></h2>16 <h2><?php esc_html_e('Create a Child Theme', self::_SLUG) ?></h2> 12 17 13 <div class="copy"><?php printf( __( 'Fill out this form to create a child theme based on %s (your current theme).', 'one-click-child-theme'), $parent_theme_name ); ?></div>18 <div class="copy"><?php printf( __( 'Fill out this form to create a child theme based on %s (your current theme).', self::_SLUG ), $parent_theme_name ); ?></div> 14 19 15 <form action="<?php echo admin_url( 'themes.php?page=one-click-child-theme-page' ); ?>" method="post" id="create_child_form"> 16 <input type="hidden" name="cmd" value="create_child_theme" /> 20 <form action="admin-post.php" method="post" id="create_child_form"> 21 <input type="hidden" name="action" value="<?php echo $this->_createChildFormId; ?>" /> 22 <?php wp_nonce_field($this->_createChildFormId.'-verify'); ?> 17 23 <table class="form-table"> 18 24 <tr> 19 <th scope="row"><label for="create_child_theme_name"><?php _e( 'Theme Name', 'one-click-child-theme'); ?></label></th>25 <th scope="row"><label for="create_child_theme_name"><?php esc_html_e( 'Theme Name', self::_SLUG ); ?></label></th> 20 26 <td> 21 <input type="text" name="theme_name" value="<?php e cho $theme_name; ?>" id="create_child_theme_name" />22 <p class="description"><?php _e( 'Give your theme a name.', 'one-click-child-theme'); ?>27 <input type="text" name="theme_name" value="<?php esc_attr_e($theme_name); ?>" id="create_child_theme_name" /> 28 <p class="description"><?php esc_html_e( 'Give your theme a name.', self::_SLUG ); ?> 23 29 </td> 24 30 </tr> 25 31 <tr> 26 <th scope="row"><label for="create_child_description"><?php _e( 'Description', 'one-click-child-theme' ); ?></label></th>32 <th scope="row"><label for="create_child_description"><?php esc_html_e( 'Description', 'one-click-child-theme' ); ?></label></th> 27 33 <td> 28 <textarea name="description" value="<?php echo $description; ?>" rows="2" cols="40" id="create_child_description">< /textarea>29 <p class="description"><?php _e( 'Describe your theme.', 'one-click-child-theme'); ?>34 <textarea name="description" value="<?php echo $description; ?>" rows="2" cols="40" id="create_child_description"><?php esc_html_e($description); ?></textarea> 35 <p class="description"><?php esc_html_e( 'Describe your theme.', self::_SLUG ); ?> 30 36 </td> 31 37 </tr> 32 38 <tr> 33 <th scope="row"><label for="create_child_author_name"><?php _e( 'Author', 'one-click-child-theme'); ?></label></th>39 <th scope="row"><label for="create_child_author_name"><?php esc_html_e( 'Author', self::_SLUG ); ?></label></th> 34 40 <td> 35 <input name="author_name" value="<?php e cho $author; ?>" id="create_child_author_name" />36 <p class="description"><?php _e( 'Your name.', 'one-click-child-theme'); ?>41 <input name="author_name" value="<?php esc_attr_e($author); ?>" id="create_child_author_name" /> 42 <p class="description"><?php esc_html_e( 'Your name.', self::_SLUG ); ?> 37 43 </td> 38 44 </tr> 39 45 </table> 40 46 <p class="submit"> 41 <input type="submit" class="button button-primary" value="<?php _e( 'Create Child', 'one-click-child-theme'); ?>" />47 <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Create Child', self::_SLUG ); ?>" /> 42 48 </p> 43 49 </form> 44 50 </div> 45 -
one-click-child-theme/trunk/templates/is_child_already.php
r1119237 r1122710 6 6 */ 7 7 8 settings_errors();9 8 ?> 10 9 <div class="wrap"> 11 <h2><?php printf( __('%s is already a child theme','one-click-child-theme'), $current_theme->Name); ?></h2>10 <h2><?php esc_html_e( sprintf( __('%s is already a child theme', self::_SLUG), $current_theme->Name ) ); ?></h2> 12 11 <?php 13 12 if ( $child_needs_repair ) : 14 13 ?> 15 <h3><?php _e('Child theme needs repair', 'one-click-child-theme') ?></h3> 16 <div class="copy"><?php _e( 'Detected outdated child theme mechanism. Click the button below to attempt a one-click repair.', 'one-click-child-theme' ); ?></div> 17 <form action="<?php echo admin_url( 'themes.php?page=one-click-child-theme-page' ); ?>" method="post" id="repair_child_form"> 18 <input type="hidden" name="cmd" value="repair_child_theme" /> 14 <h3><?php esc_html_e('Child theme needs repair', self::_SLUG) ?></h3> 15 <div class="copy"><?php esc_html_e( 'Detected outdated child theme mechanism. Click the button below to attempt a one-click repair.', self::_SLUG ); ?></div> 16 <form action="admin-post.php" method="post" id="repair_child_form"> 17 <input type="hidden" name="action" value="<?php echo $this->_repairChildFormId; ?>" /> 18 <?php wp_nonce_field($this->_repairChildFormId.'-verify'); ?> 19 19 <p class="submit"> 20 <input type="submit" class="button button-primary" value="<?php _e( 'Repair Child Theme', 'one-click-child-theme'); ?>" />20 <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Repair Child Theme', self::_SLUG ); ?>" /> 21 21 </p> 22 22 </form> 23 23 24 <?php 24 25 endif; 25 26 if ( !empty($template_files) ) : 26 27 ?> 27 <h3><?php _e('Child files','one-click-child-theme') ?></h3> 28 <div class="copy"><?php _e( 'If you wish to modify the behavior of a template file, select it and click the "Copy Template" button below.', 'one-click-child-theme' ); ?></div> 29 <form action="<?php echo admin_url( 'themes.php?page=one-click-child-theme-page' ); ?>" method="post" id="copy_template_file_form"> 30 <input type="hidden" name="cmd" value="copy_template_file" /> 28 <h3><?php esc_html_e('Child files',self::_SLUG) ?></h3> 29 <div class="copy"><?php esc_html_e( 'If you wish to modify the behavior of a template file, select it and click the "Copy Template" button below.', self::_SLUG ); ?></div> 30 <form action="admin-post.php" method="post" id="copy_template_file_form"> 31 <input type="hidden" name="action" value="<?php echo $this->_copyTemplateFormId; ?>" /> 32 <?php wp_nonce_field($this->_copyTemplateFormId.'-verify'); ?> 31 33 <table class="form-table"> 32 34 <tr> 33 <th scope="row"><label for="copy_template_file_name"><?php _e( 'Template File', 'one-click-child-theme'); ?></label></th>35 <th scope="row"><label for="copy_template_file_name"><?php esc_html_e( 'Template File', self::_SLUG ); ?></label></th> 34 36 <td><select name="filename" id="copy_template_file_name"> 35 37 <?php … … 44 46 </table> 45 47 <p class="submit"> 46 <input type="submit" class="button button-primary" value="<?php _e( 'Copy Template', 'one-click-child-theme'); ?>" />48 <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Copy Template', self::_SLUG ); ?>" /> 47 49 </p> 48 50 </form> … … 50 52 endif; 51 53 ?> 52 <h3><?php _e('Grandchild theme?','one-click-child-theme') ?></h3> 53 <div class="copy"><?php _e( 'WordPress has no formal support for theme grandchildren. No other actions currently supported in One Click Child Theme.', 'one-click-child-theme' ); ?></div> 54 55 <h3><?php esc_html_e('Screenshot',self::_SLUG) ?></h3> 56 <div class="copy"><?php esc_html_e( 'By default One-Click Child theme uses the parent theme’s screenshot. You can use WordPress.com’s mshot service to replace the current child theme’s screenshot with a screenshot of your current web site’s homepage (if publicly accessible over the web).', self::_SLUG ); ?></div> 57 <form action="admin-post.php" method="post" id="mshot_homepage_form"> 58 <input type="hidden" name="action" value="<?php echo $this->_mshotSiteFormId; ?>" /> 59 <?php wp_nonce_field($this->_mshotSiteFormId.'-verify'); ?> 60 <div class="theme-browser"> 61 <div class="theme"> 62 <?php if ($child_theme_screenshot_url) : ?> 63 <div class="theme-screenshot"> 64 <img src="<?php echo $child_theme_screenshot_url ?>" /> 65 <p><?php esc_html_e('No screenshot', self::_SLUG); ?></p> 66 </div> 67 <?php else : ?> 68 <div class="theme-screenshot blank"></div> 69 <?php endif; ?> 70 <div class="theme-name"><?php esc_html_e('Current', self::_SLUG); ?></div> 71 </div> 72 <div class="theme"> 73 <div class="theme-screenshot"> 74 <img src="<?php echo $mshot_url ?>" /> 75 </div> 76 <div class="theme-name"><?php esc_html_e('mShot', self::_SLUG); ?></div> 77 </div> 78 </div> 79 <br clear="all" /> 80 <p class="submit"> 81 <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Replace Screenshot', self::_SLUG ); ?>" /> 82 </p> 83 </form> 84 85 <h3><?php esc_html_e('Grandchild theme?',self::_SLUG) ?></h3> 86 <div class="copy"><?php esc_html_e( 'WordPress has no formal support for theme grandchildren. No other actions currently supported in One Click Child Theme.', self::_SLUG ); ?></div> 54 87 </div>
Note: See TracChangeset
for help on using the changeset viewer.