' . __( 'You can use the theme file editor to edit the individual CSS and PHP files which make up your theme.' ) . '
' .
'' . __( 'Begin by choosing a theme to edit from the dropdown menu and clicking the Select button. A list then appears of the theme’s template files. Clicking once on any file name causes the file to appear in the large Editor box.' ) . '
' .
'' . __( '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.' ) . '
' .
'' . __( 'When using a keyboard to navigate:' ) . '
' .
'' . __( 'After typing in your edits, click Update File.' ) . '
' .
'' . __( 'Advice: Think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '
' .
'' . sprintf(
/* translators: %s: Link to documentation on child themes. */
__( 'Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a child theme instead.' ),
__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' )
) . '
' .
( is_network_admin() ? '' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '
' : '' ),
)
);
get_current_screen()->set_help_sidebar(
'
'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
)
);
} elseif ( is_wp_error( $edit_error ) ) {
$error_code = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() );
$message = '
' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '
' . $error_code . '
';
wp_admin_notice(
$message,
array(
'type' => 'error',
'id' => 'message',
)
);
}
if ( preg_match( '/\.css$/', $file ) ) {
if ( ! wp_is_block_theme() && current_user_can( 'customize' ) ) {
$message = '
' . __( 'Did you know?' ) . '
' . sprintf(
/* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */
__( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ),
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) )
) . '
';
wp_admin_notice(
$message,
array(
'type' => 'info',
'id' => 'message',
)
);
} elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) {
$site_editor_url = admin_url(
add_query_arg(
urlencode_deep(
array(
'p' => '/styles',
'section' => '/css',
)
),
'site-editor.php'
)
);
$message = '
' . __( 'Did you know?' ) . '
' . sprintf(
/* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */
__( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ),
esc_url( $site_editor_url )
) . '
';
wp_admin_notice(
$message,
array(
'type' => 'info',
'id' => 'message',
)
);
}
if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) {
$message = '
' . __( 'There is a minified version of this stylesheet.' ) . '
' .
__( 'It is likely that this unminified stylesheet will not be served to visitors.' ) . '
';
wp_admin_notice(
$message,
array(
'type' => 'warning',
'id' => 'wp-css-min-warning',
)
);
}
}
?>
get( 'Name' ) === $theme->display( 'Name' ) ) {
/* translators: %s: Theme name. */
printf( __( 'Editing %s (active)' ), '' . $theme->display( 'Name' ) . '' );
} else {
/* translators: %s: Theme name. */
printf( __( 'Editing %s (inactive)' ), '' . $theme->display( 'Name' ) . '' );
}
?>
' . __( 'File: %s' ) . '',
esc_html( $file_show )
);
?>
errors() ) {
wp_admin_notice(
'
' . __( 'This theme is broken.' ) . ' ' . $theme->errors()->get_error_message(),
array(
'additional_classes' => array( 'error' ),
)
);
}
?>
parent() ) : ?>
-
%s',
self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ),
$theme->parent()->display( 'Name' )
)
);
?>
-
array( 'error' ),
)
);
else :
?>