wp/wp-admin/theme-editor.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    25 'title'		=> __('Overview'),
    25 'title'		=> __('Overview'),
    26 'content'	=>
    26 'content'	=>
    27 	'<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>
    27 	'<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>
    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>
    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>
    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>
    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>
    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>
    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>
    31 	<p>' . __('After typing in your edits, click Update File.') . '</p>
    31 	<p>' . __('After typing in your edits, click Update File.') . '</p>
    32 	<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>
    32 	<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>
    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>' .
    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>' .
    34 	( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
    34 	( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
    35 ) );
    35 ) );
    36 
    36 
    37 get_current_screen()->set_help_sidebar(
    37 get_current_screen()->set_help_sidebar(
    38 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    38 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    39 	'<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>' .
    39 	'<p>' . __('<a href="https://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>' .
    40 	'<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
    40 	'<p>' . __('<a href="https://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
    41 	'<p>' . __('<a href="http://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>' .
    41 	'<p>' . __('<a href="https://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>' .
    42 	'<p>' . __('<a href="http://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>' .
    42 	'<p>' . __('<a href="https://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>' .
    43 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    43 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    44 );
    44 );
    45 
    45 
    46 wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
    46 wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
    47 
    47 
    48 if ( $theme )
    48 if ( $theme )
    79 case 'update':
    79 case 'update':
    80 	check_admin_referer( 'edit-theme_' . $file . $stylesheet );
    80 	check_admin_referer( 'edit-theme_' . $file . $stylesheet );
    81 	$newcontent = wp_unslash( $_POST['newcontent'] );
    81 	$newcontent = wp_unslash( $_POST['newcontent'] );
    82 	$location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
    82 	$location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
    83 	if ( is_writeable( $file ) ) {
    83 	if ( is_writeable( $file ) ) {
    84 		//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
    84 		// is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
    85 		$f = fopen( $file, 'w+' );
    85 		$f = fopen( $file, 'w+' );
    86 		if ( $f !== false ) {
    86 		if ( $f !== false ) {
    87 			fwrite( $f, $newcontent );
    87 			fwrite( $f, $newcontent );
    88 			fclose( $f );
    88 			fclose( $f );
    89 			$location .= '&updated=true';
    89 			$location .= '&updated=true';
    90 			$theme->cache_delete();
    90 			$theme->cache_delete();
    91 		}
    91 		}
    92 	}
    92 	}
    93 	wp_redirect( $location );
    93 	wp_redirect( $location );
    94 	exit;
    94 	exit;
    95 break;
       
    96 
    95 
    97 default:
    96 default:
    98 
    97 
    99 	require_once( ABSPATH . 'wp-admin/admin-header.php' );
    98 	require_once( ABSPATH . 'wp-admin/admin-header.php' );
   100 
    99 
   120 		}
   119 		}
   121 
   120 
   122 		$content = esc_textarea( $content );
   121 		$content = esc_textarea( $content );
   123 	}
   122 	}
   124 
   123 
   125 	?>
   124 	if ( isset( $_GET['updated'] ) ) : ?>
   126 <?php if ( isset( $_GET['updated'] ) ) : ?>
   125  <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div>
   127  <div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div>
       
   128 <?php endif;
   126 <?php endif;
   129 
   127 
   130 $description = get_file_description( $file );
   128 $description = get_file_description( $file );
   131 $file_show = array_search( $file, array_filter( $allowed_files ) );
   129 $file_show = array_search( $file, array_filter( $allowed_files ) );
   132 if ( $description != $file_show )
   130 if ( $description != $file_show )
   133 	$description .= ' <span>(' . $file_show . ')</span>';
   131 	$description .= ' <span>(' . $file_show . ')</span>';
   134 ?>
   132 ?>
   135 <div class="wrap">
   133 <div class="wrap">
   136 <?php screen_icon(); ?>
       
   137 <h2><?php echo esc_html( $title ); ?></h2>
   134 <h2><?php echo esc_html( $title ); ?></h2>
   138 
   135 
   139 <div class="fileedit-sub">
   136 <div class="fileedit-sub">
   140 <div class="alignleft">
   137 <div class="alignleft">
   141 <h3><?php echo $theme->display('Name'); if ( $description ) echo ': ' . $description; ?></h3>
   138 <h3><?php echo $theme->display('Name'); if ( $description ) echo ': ' . $description; ?></h3>
   220 		<?php endif; ?>
   217 		<?php endif; ?>
   221 <?php
   218 <?php
   222 	if ( is_writeable( $file ) ) :
   219 	if ( is_writeable( $file ) ) :
   223 		submit_button( __( 'Update File' ), 'primary', 'submit', true );
   220 		submit_button( __( 'Update File' ), 'primary', 'submit', true );
   224 	else : ?>
   221 	else : ?>
   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>
   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>
   226 <?php endif; ?>
   223 <?php endif; ?>
   227 		</div>
   224 		</div>
   228 	</form>
   225 	</form>
   229 <?php
   226 <?php
   230 endif; // $error
   227 endif; // $error
   231 ?>
   228 ?>
   232 <br class="clear" />
   229 <br class="clear" />
   233 </div>
   230 </div>
   234 <script type="text/javascript">
   231 <script type="text/javascript">
   235 /* <![CDATA[ */
       
   236 jQuery(document).ready(function($){
   232 jQuery(document).ready(function($){
   237 	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
   233 	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
   238 	$('#newcontent').scrollTop( $('#scrollto').val() );
   234 	$('#newcontent').scrollTop( $('#scrollto').val() );
   239 });
   235 });
   240 /* ]]> */
       
   241 </script>
   236 </script>
   242 <?php
   237 <?php
   243 break;
   238 break;
   244 }
   239 }
   245 
   240