wp/wp-admin/theme-editor.php
author ymh <ymh.work@gmail.com>
Thu, 07 Nov 2013 00:08:07 +0000
changeset 1 f6eb5a861d2f
parent 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
remove unnessary files. Make timthumb work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Theme editor administration panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/** WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
if ( is_multisite() && ! is_network_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
	wp_redirect( network_admin_url( 'theme-editor.php' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
if ( !current_user_can('edit_themes') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
$title = __("Edit Themes");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
$parent_file = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
'id'		=> 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
'title'		=> __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
'content'	=>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	'<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	<p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list then appears of all the template files. Clicking once on any file name causes the file to appear in the large Editor box.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
	<p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Look Up takes you to a web page with reference material about that particular function.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	<p id="newcontent-description">' . __('In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	<p>' . __('After typing in your edits, click Update File.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	<p>' . sprintf( __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s" target="_blank">child theme</a> instead.'), __('http://codex.wordpress.org/Child_Themes') ) . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	'<p><strong>' . __('For more information:') . '</strong></p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	'<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
	'<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	'<p>' . __('<a href="http://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	'<p>' . __('<a href="http://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
if ( $theme )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	$stylesheet = $theme;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
	$stylesheet = get_stylesheet();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
$theme = wp_get_theme( $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
if ( ! $theme->exists() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
	wp_die( __( 'The requested theme does not exist.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
	wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
$allowed_files = $theme->get_files( 'php', 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
$has_templates = ! empty( $allowed_files );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
$style_files = $theme->get_files( 'css' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
$allowed_files['style.css'] = $style_files['style.css'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
$allowed_files += $style_files;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
if ( empty( $file ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	$relative_file = 'style.css';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$file = $allowed_files['style.css'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	$relative_file = $file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	$file = $theme->get_stylesheet_directory() . '/' . $relative_file;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
validate_file_to_edit( $file, $allowed_files );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
$scrollto = isset( $_REQUEST['scrollto'] ) ? (int) $_REQUEST['scrollto'] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
switch( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
case 'update':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	check_admin_referer( 'edit-theme_' . $file . $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	$newcontent = wp_unslash( $_POST['newcontent'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
	$location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
	if ( is_writeable( $file ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
		//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		$f = fopen( $file, 'w+' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		if ( $f !== false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
			fwrite( $f, $newcontent );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			fclose( $f );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
			$location .= '&updated=true';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
			$theme->cache_delete();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	wp_redirect( $location );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
	exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
	require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
	update_recently_edited( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
	if ( ! is_file( $file ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	$content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	if ( ! $error && filesize( $file ) > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		$f = fopen($file, 'r');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
		$content = fread($f, filesize($file));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
		if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
			$functions = wp_doc_link_parse( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			$docs_select = '<select name="docs-list" id="docs-list">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			$docs_select .= '<option value="">' . esc_attr__( 'Function Name&hellip;' ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
			foreach ( $functions as $function ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
				$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
			$docs_select .= '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		$content = esc_textarea( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
<?php if ( isset( $_GET['updated'] ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
 <div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
$description = get_file_description( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
$file_show = array_search( $file, array_filter( $allowed_files ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
if ( $description != $file_show )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
	$description .= ' <span>(' . $file_show . ')</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
<?php screen_icon(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
<h2><?php echo esc_html( $title ); ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
<div class="fileedit-sub">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
<div class="alignleft">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
<h3><?php echo $theme->display('Name'); if ( $description ) echo ': ' . $description; ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
<div class="alignright">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
	<form action="theme-editor.php" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
		<strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
		<select name="theme" id="theme">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
		continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
	$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
	echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
		</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
if ( $theme->errors() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	<div id="templateside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
if ( $allowed_files ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	if ( $has_templates || $theme->parent() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	<h3><?php _e('Templates'); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	<?php if ( $theme->parent() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
	<p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), '<a href="' . self_admin_url('theme-editor.php?theme=' . urlencode( $theme->get_template() ) ) . '">' . $theme->parent()->display('Name') . '</a>' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
	<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
	<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
	foreach ( $allowed_files as $filename => $absolute_filename ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		if ( 'style.css' == $filename )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
			echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		$file_description = get_file_description( $absolute_filename );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		if ( $file_description != basename( $filename ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
			$file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
		if ( $absolute_filename == $file )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
			$file_description = '<span class="highlight">' . $file_description . '</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		<li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&amp;theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
<?php if ( $error ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	<form name="template" id="template" action="theme-editor.php" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
	<?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
		<div><textarea cols="70" rows="30" name="newcontent" id="newcontent" aria-describedby="newcontent-description"><?php echo $content; ?></textarea>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		<input type="hidden" name="action" value="update" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		<input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		<input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
		<input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	<?php if ( ! empty( $functions ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		<div id="documentation" class="hide-if-no-js">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		<label for="docs-list"><?php _e('Documentation:') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		<?php echo $docs_select; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		<input type="button" class="button" value=" <?php esc_attr_e( 'Look Up' ); ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
	<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
		<div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
		<?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
			<p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
			<?php _e( 'This is a file in your current parent theme.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
	if ( is_writeable( $file ) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		submit_button( __( 'Update File' ), 'primary', 'submit', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
	else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
endif; // $error
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
/* <![CDATA[ */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
jQuery(document).ready(function($){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
	$('#newcontent').scrollTop( $('#scrollto').val() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
/* ]]> */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
include(ABSPATH . 'wp-admin/admin-footer.php' );