author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
19 | 3 |
* Theme file editor administration panel. |
0 | 4 |
* |
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
16 | 10 |
require_once __DIR__ . '/admin.php'; |
0 | 11 |
|
12 |
if ( is_multisite() && ! is_network_admin() ) { |
|
13 |
wp_redirect( network_admin_url( 'theme-editor.php' ) ); |
|
16 | 14 |
exit; |
0 | 15 |
} |
16 |
||
9 | 17 |
if ( ! current_user_can( 'edit_themes' ) ) { |
18 |
wp_die( '<p>' . __( 'Sorry, you are not allowed to edit templates for this site.' ) . '</p>' ); |
|
19 |
} |
|
0 | 20 |
|
19 | 21 |
// Used in the HTML title tag. |
9 | 22 |
$title = __( 'Edit Themes' ); |
0 | 23 |
$parent_file = 'themes.php'; |
24 |
||
9 | 25 |
get_current_screen()->add_help_tab( |
26 |
array( |
|
27 |
'id' => 'overview', |
|
28 |
'title' => __( 'Overview' ), |
|
29 |
'content' => |
|
19 | 30 |
'<p>' . __( 'You can use the theme file editor to edit the individual CSS and PHP files which make up your theme.' ) . '</p>' . |
9 | 31 |
'<p>' . __( '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.' ) . '</p>' . |
19 | 32 |
'<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>' . |
9 | 33 |
'<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' . |
34 |
'<ul>' . |
|
35 |
'<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' . |
|
36 |
'<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' . |
|
37 |
'<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' . |
|
38 |
'</ul>' . |
|
39 |
'<p>' . __( 'After typing in your edits, click Update File.' ) . '</p>' . |
|
40 |
'<p>' . __( '<strong>Advice:</strong> Think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '</p>' . |
|
41 |
'<p>' . sprintf( |
|
16 | 42 |
/* translators: %s: Link to documentation on child themes. */ |
9 | 43 |
__( 'Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s">child theme</a> instead.' ), |
44 |
__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) |
|
45 |
) . '</p>' . |
|
46 |
( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ), |
|
47 |
) |
|
48 |
); |
|
0 | 49 |
|
50 |
get_current_screen()->set_help_sidebar( |
|
9 | 51 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 52 |
'<p>' . __( '<a href="https://developer.wordpress.org/themes/">Documentation on Theme Development</a>' ) . '</p>' . |
19 | 53 |
'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-editor-screen/">Documentation on Editing Themes</a>' ) . '</p>' . |
16 | 54 |
'<p>' . __( '<a href="https://wordpress.org/support/article/editing-files/">Documentation on Editing Files</a>' ) . '</p>' . |
55 |
'<p>' . __( '<a href="https://developer.wordpress.org/themes/basics/template-tags/">Documentation on Template Tags</a>' ) . '</p>' . |
|
9 | 56 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 57 |
); |
58 |
||
59 |
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) ); |
|
60 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
if ( $theme ) { |
0 | 62 |
$stylesheet = $theme; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
} else { |
0 | 64 |
$stylesheet = get_stylesheet(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
} |
0 | 66 |
|
67 |
$theme = wp_get_theme( $stylesheet ); |
|
68 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
if ( ! $theme->exists() ) { |
0 | 70 |
wp_die( __( 'The requested theme does not exist.' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
} |
0 | 72 |
|
16 | 73 |
if ( $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code() ) { |
0 | 74 |
wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
|
16 | 77 |
$allowed_files = array(); |
78 |
$style_files = array(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
$file_types = wp_get_theme_file_editable_extensions( $theme ); |
0 | 81 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
foreach ( $file_types as $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
switch ( $type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
case 'php': |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
$allowed_files += $theme->get_files( 'php', -1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
case 'css': |
9 | 88 |
$style_files = $theme->get_files( 'css', -1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
$allowed_files['style.css'] = $style_files['style.css']; |
9 | 90 |
$allowed_files += $style_files; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
$allowed_files += $theme->get_files( $type, -1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
// Move functions.php and style.css to the top. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
if ( isset( $allowed_files['functions.php'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
$allowed_files = array( 'functions.php' => $allowed_files['functions.php'] ) + $allowed_files; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
if ( isset( $allowed_files['style.css'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
$allowed_files = array( 'style.css' => $allowed_files['style.css'] ) + $allowed_files; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
} |
0 | 105 |
|
106 |
if ( empty( $file ) ) { |
|
107 |
$relative_file = 'style.css'; |
|
9 | 108 |
$file = $allowed_files['style.css']; |
0 | 109 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
$relative_file = wp_unslash( $file ); |
9 | 111 |
$file = $theme->get_stylesheet_directory() . '/' . $relative_file; |
0 | 112 |
} |
113 |
||
114 |
validate_file_to_edit( $file, $allowed_files ); |
|
115 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
// Handle fallback editing of file when JavaScript is not available. |
9 | 117 |
$edit_error = null; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
$posted_content = null; |
16 | 119 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
$r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
if ( is_wp_error( $r ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
$edit_error = $r; |
9 | 124 |
if ( check_ajax_referer( 'edit-theme_' . $stylesheet . '_' . $relative_file, 'nonce', false ) && isset( $_POST['newcontent'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
$posted_content = wp_unslash( $_POST['newcontent'] ); |
0 | 126 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
} else { |
9 | 128 |
wp_redirect( |
129 |
add_query_arg( |
|
130 |
array( |
|
131 |
'a' => 1, // This means "success" for some reason. |
|
132 |
'theme' => $stylesheet, |
|
133 |
'file' => $relative_file, |
|
134 |
), |
|
135 |
admin_url( 'theme-editor.php' ) |
|
136 |
) |
|
137 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
exit; |
0 | 139 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
} |
0 | 141 |
|
16 | 142 |
$settings = array( |
143 |
'codeEditor' => wp_enqueue_code_editor( compact( 'file' ) ), |
|
144 |
); |
|
145 |
wp_enqueue_script( 'wp-theme-plugin-editor' ); |
|
146 |
wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); |
|
147 |
wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' ); |
|
148 |
||
149 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
150 |
||
151 |
update_recently_edited( $file ); |
|
152 |
||
153 |
if ( ! is_file( $file ) ) { |
|
154 |
$error = true; |
|
155 |
} |
|
0 | 156 |
|
16 | 157 |
$content = ''; |
158 |
if ( ! empty( $posted_content ) ) { |
|
159 |
$content = $posted_content; |
|
160 |
} elseif ( ! $error && filesize( $file ) > 0 ) { |
|
161 |
$f = fopen( $file, 'r' ); |
|
162 |
$content = fread( $f, filesize( $file ) ); |
|
0 | 163 |
|
16 | 164 |
if ( '.php' === substr( $file, strrpos( $file, '.' ) ) ) { |
165 |
$functions = wp_doc_link_parse( $content ); |
|
0 | 166 |
|
16 | 167 |
$docs_select = '<select name="docs-list" id="docs-list">'; |
168 |
$docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; |
|
169 |
foreach ( $functions as $function ) { |
|
170 |
$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; |
|
171 |
} |
|
172 |
$docs_select .= '</select>'; |
|
9 | 173 |
} |
0 | 174 |
|
16 | 175 |
$content = esc_textarea( $content ); |
176 |
} |
|
0 | 177 |
|
16 | 178 |
$file_description = get_file_description( $relative_file ); |
179 |
$file_show = array_search( $file, array_filter( $allowed_files ), true ); |
|
180 |
$description = esc_html( $file_description ); |
|
181 |
if ( $file_description !== $file_show ) { |
|
182 |
$description .= ' <span>(' . esc_html( $file_show ) . ')</span>'; |
|
183 |
} |
|
184 |
?> |
|
0 | 185 |
<div class="wrap"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
<h1><?php echo esc_html( $title ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
<?php if ( isset( $_GET['a'] ) ) : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
<div id="message" class="updated notice is-dismissible"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
<p><?php _e( 'File edited successfully.' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
<?php elseif ( is_wp_error( $edit_error ) ) : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
<div id="message" class="notice notice-error"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
<p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
<pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
<?php endif; ?> |
16 | 198 |
|
19 | 199 |
<?php if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
<div id="message" class="notice-info notice"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
<p><strong><?php _e( 'Did you know?' ); ?></strong></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
<?php |
16 | 204 |
printf( |
205 |
/* translators: %s: Link to Custom CSS section in the Customizer. */ |
|
19 | 206 |
__( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
<?php endif; ?> |
0 | 213 |
|
214 |
<div class="fileedit-sub"> |
|
215 |
<div class="alignleft"> |
|
9 | 216 |
<h2> |
16 | 217 |
<?php |
218 |
echo $theme->display( 'Name' ); |
|
219 |
if ( $description ) { |
|
220 |
echo ': ' . $description;} |
|
221 |
?> |
|
9 | 222 |
</h2> |
0 | 223 |
</div> |
224 |
<div class="alignright"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
<form action="theme-editor.php" method="get"> |
18 | 226 |
<label for="theme" id="theme-plugin-editor-selector"><?php _e( 'Select theme to edit:' ); ?> </label> |
0 | 227 |
<select name="theme" id="theme"> |
16 | 228 |
<?php |
229 |
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { |
|
230 |
if ( $a_theme->errors() && 'theme_no_stylesheet' === $a_theme->errors()->get_error_code() ) { |
|
231 |
continue; |
|
232 |
} |
|
0 | 233 |
|
16 | 234 |
$selected = ( $a_stylesheet === $stylesheet ) ? ' selected="selected"' : ''; |
235 |
echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display( 'Name' ) . '</option>'; |
|
236 |
} |
|
237 |
?> |
|
0 | 238 |
</select> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
<?php submit_button( __( 'Select' ), '', 'Submit', false ); ?> |
0 | 240 |
</form> |
241 |
</div> |
|
242 |
<br class="clear" /> |
|
243 |
</div> |
|
16 | 244 |
|
0 | 245 |
<?php |
9 | 246 |
if ( $theme->errors() ) { |
0 | 247 |
echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; |
9 | 248 |
} |
0 | 249 |
?> |
16 | 250 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
<div id="templateside"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
<h2 id="theme-files-label"><?php _e( 'Theme Files' ); ?></h2> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
<ul role="tree" aria-labelledby="theme-files-label"> |
16 | 254 |
<?php if ( $theme->parent() ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
<li class="howto"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
<?php |
16 | 257 |
printf( |
258 |
/* translators: %s: Link to edit parent theme. */ |
|
9 | 259 |
__( 'This child theme inherits templates from a parent theme, %s.' ), |
260 |
sprintf( |
|
261 |
'<a href="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
$theme->parent()->display( 'Name' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
<?php endif; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
<li role="treeitem" tabindex="-1" aria-expanded="true" aria-level="1" aria-posinset="1" aria-setsize="1"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
<ul role="group"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
<?php wp_print_theme_file_tree( wp_make_theme_file_tree( $allowed_files ) ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
</div> |
0 | 276 |
|
9 | 277 |
<?php |
278 |
if ( $error ) : |
|
16 | 279 |
echo '<div class="error"><p>' . __( 'File does not exist! Please double check the name and try again.' ) . '</p></div>'; |
9 | 280 |
else : |
281 |
?> |
|
0 | 282 |
<form name="template" id="template" action="theme-editor.php" method="post"> |
9 | 283 |
<?php wp_nonce_field( 'edit-theme_' . $stylesheet . '_' . $relative_file, 'nonce' ); ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
<div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
<label for="newcontent" id="theme-plugin-editor-label"><?php _e( 'Selected file content:' ); ?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
<textarea cols="70" rows="30" name="newcontent" id="newcontent" aria-describedby="editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"><?php echo $content; ?></textarea> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
<input type="hidden" name="action" value="update" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
<input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
<input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" /> |
0 | 290 |
</div> |
16 | 291 |
|
292 |
<?php if ( ! empty( $functions ) ) : ?> |
|
293 |
<div id="documentation" class="hide-if-no-js"> |
|
294 |
<label for="docs-list"><?php _e( 'Documentation:' ); ?></label> |
|
295 |
<?php echo $docs_select; ?> |
|
296 |
<input disabled id="docs-lookup" type="button" class="button" value="<?php esc_attr_e( 'Look Up' ); ?>" onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_user_locale() ); ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&redirect=true'); }" /> |
|
297 |
</div> |
|
298 |
<?php endif; ?> |
|
0 | 299 |
|
16 | 300 |
<div> |
301 |
<div class="editor-notices"> |
|
302 |
<?php if ( is_child_theme() && $theme->get_stylesheet() === get_template() ) : ?> |
|
303 |
<div class="notice notice-warning inline"> |
|
304 |
<p> |
|
18 | 305 |
<?php if ( is_writable( $file ) ) : ?> |
16 | 306 |
<strong><?php _e( 'Caution:' ); ?></strong> |
307 |
<?php endif; ?> |
|
308 |
<?php _e( 'This is a file in your current parent theme.' ); ?> |
|
309 |
</p> |
|
310 |
</div> |
|
311 |
<?php endif; ?> |
|
312 |
</div> |
|
18 | 313 |
<?php if ( is_writable( $file ) ) : ?> |
16 | 314 |
<p class="submit"> |
315 |
<?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> |
|
316 |
<span class="spinner"></span> |
|
317 |
</p> |
|
318 |
<?php else : ?> |
|
18 | 319 |
<p> |
16 | 320 |
<?php |
321 |
printf( |
|
322 |
/* translators: %s: Documentation URL. */ |
|
323 |
__( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ), |
|
324 |
__( 'https://wordpress.org/support/article/changing-file-permissions/' ) |
|
325 |
); |
|
326 |
?> |
|
18 | 327 |
</p> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
<?php endif; ?> |
0 | 329 |
</div> |
16 | 330 |
|
331 |
<?php wp_print_file_editor_templates(); ?> |
|
0 | 332 |
</form> |
9 | 333 |
<?php |
16 | 334 |
endif; // End if $error. |
0 | 335 |
?> |
336 |
<br class="clear" /> |
|
337 |
</div> |
|
338 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
$dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) : |
16 | 341 |
// Get a back URL. |
342 |
$referer = wp_get_referer(); |
|
343 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
$excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
|
19 | 346 |
$return_url = admin_url( '/' ); |
347 |
if ( $referer ) { |
|
348 |
$referer_path = parse_url( $referer, PHP_URL_PATH ); |
|
349 |
if ( is_string( $referer_path ) && ! in_array( basename( $referer_path ), $excluded_referer_basenames, true ) ) { |
|
350 |
$return_url = $referer; |
|
351 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
} |
9 | 353 |
?> |
16 | 354 |
<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden"> |
355 |
<div class="notification-dialog-background"></div> |
|
356 |
<div class="notification-dialog"> |
|
357 |
<div class="file-editor-warning-content"> |
|
358 |
<div class="file-editor-warning-message"> |
|
359 |
<h1><?php _e( 'Heads up!' ); ?></h1> |
|
360 |
<p> |
|
361 |
<?php |
|
19 | 362 |
_e( 'You appear to be making direct edits to your theme in the WordPress dashboard. It is not recommended! Editing your theme directly could break your site and your changes may be lost in future updates.' ); |
16 | 363 |
?> |
364 |
</p> |
|
365 |
<?php |
|
366 |
if ( ! $theme->parent() ) { |
|
367 |
echo '<p>'; |
|
368 |
printf( |
|
369 |
/* translators: %s: Link to documentation on child themes. */ |
|
370 |
__( 'If you need to tweak more than your theme’s CSS, you might want to try <a href="%s">making a child theme</a>.' ), |
|
371 |
esc_url( __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) ) |
|
372 |
); |
|
373 |
echo '</p>'; |
|
374 |
} |
|
375 |
?> |
|
376 |
<p><?php _e( 'If you decide to go ahead with direct edits anyway, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p> |
|
377 |
</div> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
<p> |
16 | 379 |
<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> |
380 |
<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
</div> |
9 | 385 |
<?php |
16 | 386 |
endif; // Editor warning notice. |
0 | 387 |
|
16 | 388 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |