27 if ( empty( $plugins ) ) { |
27 if ( empty( $plugins ) ) { |
28 require_once ABSPATH . 'wp-admin/admin-header.php'; |
28 require_once ABSPATH . 'wp-admin/admin-header.php'; |
29 ?> |
29 ?> |
30 <div class="wrap"> |
30 <div class="wrap"> |
31 <h1><?php echo esc_html( $title ); ?></h1> |
31 <h1><?php echo esc_html( $title ); ?></h1> |
32 <div id="message" class="error"><p><?php _e( 'No plugins are currently available.' ); ?></p></div> |
32 <?php |
|
33 wp_admin_notice( |
|
34 __( 'No plugins are currently available.' ), |
|
35 array( |
|
36 'id' => 'message', |
|
37 'additional_classes' => array( 'error' ), |
|
38 ) |
|
39 ); |
|
40 ?> |
33 </div> |
41 </div> |
34 <?php |
42 <?php |
35 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
43 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
36 exit; |
44 exit; |
37 } |
45 } |
138 ) |
146 ) |
139 ); |
147 ); |
140 |
148 |
141 get_current_screen()->set_help_sidebar( |
149 get_current_screen()->set_help_sidebar( |
142 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
150 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
143 '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-editor-screen/">Documentation on Editing Plugins</a>' ) . '</p>' . |
151 '<p>' . __( '<a href="https://developer.wordpress.org/advanced-administration/plugins/editor-screen/">Documentation on Editing Plugins</a>' ) . '</p>' . |
144 '<p>' . __( '<a href="https://developer.wordpress.org/plugins/">Documentation on Writing Plugins</a>' ) . '</p>' . |
152 '<p>' . __( '<a href="https://developer.wordpress.org/plugins/">Documentation on Writing Plugins</a>' ) . '</p>' . |
145 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
153 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' |
146 ); |
154 ); |
147 |
155 |
148 $settings = array( |
156 $settings = array( |
149 'codeEditor' => wp_enqueue_code_editor( array( 'file' => $real_file ) ), |
157 'codeEditor' => wp_enqueue_code_editor( array( 'file' => $real_file ) ), |
150 ); |
158 ); |
160 $content = $posted_content; |
168 $content = $posted_content; |
161 } else { |
169 } else { |
162 $content = file_get_contents( $real_file ); |
170 $content = file_get_contents( $real_file ); |
163 } |
171 } |
164 |
172 |
165 if ( '.php' === substr( $real_file, strrpos( $real_file, '.' ) ) ) { |
173 if ( str_ends_with( $real_file, '.php' ) ) { |
166 $functions = wp_doc_link_parse( $content ); |
174 $functions = wp_doc_link_parse( $content ); |
167 |
175 |
168 if ( ! empty( $functions ) ) { |
176 if ( ! empty( $functions ) ) { |
169 $docs_select = '<select name="docs-list" id="docs-list">'; |
177 $docs_select = '<select name="docs-list" id="docs-list">'; |
170 $docs_select .= '<option value="">' . __( 'Function Name…' ) . '</option>'; |
178 $docs_select .= '<option value="">' . esc_html__( 'Function Name…' ) . '</option>'; |
|
179 |
171 foreach ( $functions as $function ) { |
180 foreach ( $functions as $function ) { |
172 $docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>'; |
181 $docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>'; |
173 } |
182 } |
|
183 |
174 $docs_select .= '</select>'; |
184 $docs_select .= '</select>'; |
175 } |
185 } |
176 } |
186 } |
177 |
187 |
178 $content = esc_textarea( $content ); |
188 $content = esc_textarea( $content ); |
179 ?> |
189 ?> |
180 <div class="wrap"> |
190 <div class="wrap"> |
181 <h1><?php echo esc_html( $title ); ?></h1> |
191 <h1><?php echo esc_html( $title ); ?></h1> |
182 |
192 |
183 <?php if ( isset( $_GET['a'] ) ) : ?> |
193 <?php |
184 <div id="message" class="updated notice is-dismissible"> |
194 if ( isset( $_GET['a'] ) ) : |
185 <p><?php _e( 'File edited successfully.' ); ?></p> |
195 wp_admin_notice( |
186 </div> |
196 __( 'File edited successfully.' ), |
187 <?php elseif ( is_wp_error( $edit_error ) ) : ?> |
197 array( |
188 <div id="message" class="notice notice-error"> |
198 'additional_classes' => array( 'updated', 'is-dismissible' ), |
189 <p><?php _e( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ); ?></p> |
199 'id' => 'message', |
190 <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre> |
200 ) |
191 </div> |
201 ); |
192 <?php endif; ?> |
202 elseif ( is_wp_error( $edit_error ) ) : |
|
203 $error = esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); |
|
204 $message = '<p>' . __( 'There was an error while trying to update the file. You may need to fix something and try updating again.' ) . '</p> |
|
205 <pre>' . $error . '</pre>'; |
|
206 wp_admin_notice( |
|
207 $message, |
|
208 array( |
|
209 'type' => 'error', |
|
210 'id' => 'message', |
|
211 'paragraph_wrap' => false, |
|
212 ) |
|
213 ); |
|
214 endif; |
|
215 ?> |
193 |
216 |
194 <div class="fileedit-sub"> |
217 <div class="fileedit-sub"> |
195 <div class="alignleft"> |
218 <div class="alignleft"> |
196 <h2> |
219 <h2> |
197 <?php |
220 <?php |
270 |
293 |
271 <?php if ( ! empty( $docs_select ) ) : ?> |
294 <?php if ( ! empty( $docs_select ) ) : ?> |
272 <div id="documentation" class="hide-if-no-js"> |
295 <div id="documentation" class="hide-if-no-js"> |
273 <label for="docs-list"><?php _e( 'Documentation:' ); ?></label> |
296 <label for="docs-list"><?php _e( 'Documentation:' ); ?></label> |
274 <?php echo $docs_select; ?> |
297 <?php echo $docs_select; ?> |
275 <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'); }" /> |
298 <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'); }" /> |
276 </div> |
299 </div> |
277 <?php endif; ?> |
300 <?php endif; ?> |
278 |
301 |
279 <?php if ( is_writable( $real_file ) ) : ?> |
302 <?php if ( is_writable( $real_file ) ) : ?> |
280 <div class="editor-notices"> |
303 <div class="editor-notices"> |
281 <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?> |
304 <?php |
282 <div class="notice notice-warning inline active-plugin-edit-warning"> |
305 if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { |
283 <p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p> |
306 wp_admin_notice( |
284 </div> |
307 __( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ), |
285 <?php } ?> |
308 array( |
|
309 'type' => 'warning', |
|
310 'additional_classes' => array( 'inline', 'active-plugin-edit-warning' ), |
|
311 ) |
|
312 ); |
|
313 } |
|
314 ?> |
286 </div> |
315 </div> |
287 <p class="submit"> |
316 <p class="submit"> |
288 <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> |
317 <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> |
289 <span class="spinner"></span> |
318 <span class="spinner"></span> |
290 </p> |
319 </p> |