-
+ 81CB33EF33C091CC01D1A4600337F6CA5FD9696FD264452238A1002E1819E83CFA6A04058B9F3869ADF9DC449E199212A1A4BF5243F15B76587A7FABCE4BCA46
mp-wp/wp-admin/theme-editor.php
(0 . 0)(1 . 214)
57416 <?php
57417 /**
57418 * Theme editor administration panel.
57419 *
57420 * @package WordPress
57421 * @subpackage Administration
57422 */
57423
57424 /** WordPress Administration Bootstrap */
57425 require_once('admin.php');
57426
57427 $title = __("Edit Themes");
57428 $parent_file = 'themes.php';
57429
57430 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
57431
57432 wp_admin_css( 'theme-editor' );
57433
57434 $themes = get_themes();
57435
57436 if (empty($theme)) {
57437 $theme = get_current_theme();
57438 } else {
57439 $theme = stripslashes($theme);
57440 }
57441
57442
57443 if ( ! isset($themes[$theme]) )
57444 wp_die(__('The requested theme does not exist.'));
57445
57446 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
57447
57448 if (empty($file)) {
57449 $file = $allowed_files[0];
57450 }
57451
57452 $file = validate_file_to_edit($file, $allowed_files);
57453 $real_file = get_real_file_to_edit($file);
57454
57455 $file_show = basename( $file );
57456
57457 switch($action) {
57458
57459 case 'update':
57460
57461 check_admin_referer('edit-theme_' . $file . $theme);
57462
57463 if ( !current_user_can('edit_themes') )
57464 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
57465
57466 $newcontent = stripslashes($_POST['newcontent']);
57467 $theme = urlencode($theme);
57468 if (is_writeable($real_file)) {
57469 //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
57470 $f = fopen($real_file, 'w+');
57471 if ($f !== FALSE) {
57472 fwrite($f, $newcontent);
57473 fclose($f);
57474 $location = "theme-editor.php?file=$file&theme=$theme&a=te";
57475 } else {
57476 $location = "theme-editor.php?file=$file&theme=$theme";
57477 }
57478 } else {
57479 $location = "theme-editor.php?file=$file&theme=$theme";
57480 }
57481
57482 $location = wp_kses_no_null($location);
57483 $strip = array('%0d', '%0a');
57484 $location = str_replace($strip, '', $location);
57485 header("Location: $location");
57486 exit();
57487
57488 break;
57489
57490 default:
57491
57492 if ( !current_user_can('edit_themes') )
57493 wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
57494
57495 require_once('admin-header.php');
57496
57497 update_recently_edited($file);
57498
57499 if (!is_file($real_file))
57500 $error = 1;
57501
57502 if (!$error && filesize($real_file) > 0) {
57503 $f = fopen($real_file, 'r');
57504 $content = fread($f, filesize($real_file));
57505 $content = htmlspecialchars($content);
57506 }
57507
57508 ?>
57509 <?php if (isset($_GET['a'])) : ?>
57510 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
57511 <?php endif;
57512
57513 $description = get_file_description($file);
57514 $desc_header = ( $description != $file_show ) ? "$description</strong> (%s)" : "%s";
57515 ?>
57516 <div class="wrap">
57517 <?php screen_icon(); ?>
57518 <h2><?php echo wp_specialchars( $title ); ?></h2>
57519 <div class="bordertitle">
57520 <form id="themeselector" action="theme-editor.php" method="post">
57521 <strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
57522 <select name="theme" id="theme">
57523 <?php
57524 foreach ($themes as $a_theme) {
57525 $theme_name = $a_theme['Name'];
57526 if ($theme_name == $theme) $selected = " selected='selected'";
57527 else $selected = '';
57528 $theme_name = attribute_escape($theme_name);
57529 echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
57530 }
57531 ?>
57532 </select>
57533 <input type="submit" name="Submit" value="<?php _e('Select') ?>" class="button" />
57534 </form>
57535 </div>
57536 <div class="tablenav">
57537 <div class="alignleft">
57538 <big><strong><?php echo sprintf($desc_header, $file_show); ?></big>
57539 </div>
57540 <br class="clear" />
57541 </div>
57542 <br class="clear" />
57543 <div id="templateside">
57544 <h3 id="bordertitle"><?php _e("Theme Files"); ?></h3>
57545
57546 <?php
57547 if ($allowed_files) :
57548 ?>
57549 <h4><?php _e('Templates'); ?></h4>
57550 <ul>
57551 <?php
57552 $template_mapping = array();
57553 $template_dir = $themes[$theme]['Template Dir'];
57554 foreach($themes[$theme]['Template Files'] as $template_file) {
57555 $description = trim( get_file_description($template_file) );
57556 $template_show = basename($template_file);
57557 $filedesc = ( $description != $template_file ) ? "$description <span class='nonessential'>($template_show)</span>" : "$description";
57558 $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($template_show)</span></span>" : $filedesc;
57559
57560 // If we have two files of the same name prefer the one in the Template Directory
57561 // This means that we display the correct files for child themes which overload Templates as well as Styles
57562 if( array_key_exists($description, $template_mapping ) ) {
57563 if ( false !== strpos( $template_file, $template_dir ) ) {
57564 $template_mapping[ $description ] = array( $template_file, $filedesc );
57565 }
57566 } else {
57567 $template_mapping[ $description ] = array( $template_file, $filedesc );
57568 }
57569 }
57570 ksort( $template_mapping );
57571 while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
57572 ?>
57573 <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
57574 <?php endwhile; ?>
57575 </ul>
57576 <h4><?php echo _c('Styles|Theme stylesheets in theme editor'); ?></h4>
57577 <ul>
57578 <?php
57579 $template_mapping = array();
57580 foreach($themes[$theme]['Stylesheet Files'] as $style_file) {
57581 $description = trim( get_file_description($style_file) );
57582 $style_show = basename($style_file);
57583 $filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
57584 $filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
57585 $template_mapping[ $description ] = array( $style_file, $filedesc );
57586 }
57587 ksort( $template_mapping );
57588 while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
57589 ?>
57590 <li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
57591 <?php endwhile; ?>
57592 </ul>
57593 <?php endif; ?>
57594 </div>
57595 <?php
57596 if (!$error) {
57597 ?>
57598 <form name="template" id="template" action="theme-editor.php" method="post">
57599 <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
57600 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
57601 <input type="hidden" name="action" value="update" />
57602 <input type="hidden" name="file" value="<?php echo $file ?>" />
57603 <input type="hidden" name="theme" value="<?php echo $theme ?>" />
57604 </div>
57605
57606 <div>
57607 <?php if ( is_writeable($real_file) ) : ?>
57608 <p class="submit">
57609 <?php
57610 echo "<input type='submit' name='submit' class='button-primary' value='" . __('Update File') . "' tabindex='2' />";
57611 ?>
57612 </p>
57613 <?php else : ?>
57614 <p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
57615 <?php endif; ?>
57616 </div>
57617 </form>
57618 <?php
57619 } else {
57620 echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
57621 }
57622 ?>
57623 <div class="clear">   </div>
57624 </div>
57625 <?php
57626 break;
57627 }
57628
57629 include("admin-footer.php") ?>