wp/wp-admin/theme-editor.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
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>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
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. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.' ) . '</p>
0
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>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
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.'), __('https://codex.wordpress.org/Child_Themes') ) . '</p>' .
0
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>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
	'<p>' . __('<a href="https://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
	'<p>' . __('<a href="https://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
	'<p>' . __('<a href="https://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
	'<p>' . __('<a href="https://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
0
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 ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
		// is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
0
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	update_recently_edited( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
	if ( ! is_file( $file ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		$error = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	$content = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	if ( ! $error && filesize( $file ) > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
		$f = fopen($file, 'r');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		$content = fread($f, filesize($file));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
		if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
			$functions = wp_doc_link_parse( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			$docs_select = '<select name="docs-list" id="docs-list">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			$docs_select .= '<option value="">' . esc_attr__( 'Function Name&hellip;' ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			foreach ( $functions as $function ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
			$docs_select .= '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
		$content = esc_textarea( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
	if ( isset( $_GET['updated'] ) ) : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   125
 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
$description = get_file_description( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
$file_show = array_search( $file, array_filter( $allowed_files ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
if ( $description != $file_show )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
	$description .= ' <span>(' . $file_show . ')</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
<h2><?php echo esc_html( $title ); ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
<div class="fileedit-sub">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
<div class="alignleft">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
<h3><?php echo $theme->display('Name'); if ( $description ) echo ': ' . $description; ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
<div class="alignright">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
	<form action="theme-editor.php" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
		<strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
		<select name="theme" id="theme">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
	if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
		continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
	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
   151
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
if ( $theme->errors() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
	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
   162
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
	<div id="templateside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
if ( $allowed_files ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	if ( $has_templates || $theme->parent() ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
	<h3><?php _e('Templates'); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	<?php if ( $theme->parent() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
	<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
   171
	<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
	foreach ( $allowed_files as $filename => $absolute_filename ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		if ( 'style.css' == $filename )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
			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
   179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		$file_description = get_file_description( $absolute_filename );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		if ( $file_description != basename( $filename ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
			$file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		if ( $absolute_filename == $file )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
			$file_description = '<span class="highlight">' . $file_description . '</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
		<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
   188
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
<?php if ( $error ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	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
   196
else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
	<form name="template" id="template" action="theme-editor.php" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	<?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
		<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
   200
		<input type="hidden" name="action" value="update" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
		<input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
		<input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
		<input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	<?php if ( ! empty( $functions ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
		<div id="documentation" class="hide-if-no-js">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		<label for="docs-list"><?php _e('Documentation:') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		<?php echo $docs_select; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		<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
   210
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
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 if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
			<p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
			<?php _e( 'This is a file in your current parent theme.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
	if ( is_writeable( $file ) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		submit_button( __( 'Update File' ), 'primary', 'submit', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
	else : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
<p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="https://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
endif; // $error
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
jQuery(document).ready(function($){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
	$('#newcontent').scrollTop( $('#scrollto').val() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
break;
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
include(ABSPATH . 'wp-admin/admin-footer.php' );