wp/wp-admin/theme-editor.php
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 18:28:13 +0200
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
permissions -rw-r--r--
upgrade wordpress to 5.2.3
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
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    17
if ( ! current_user_can( 'edit_themes' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    18
	wp_die( '<p>' . __( 'Sorry, you are not allowed to edit templates for this site.' ) . '</p>' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    19
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    21
$title       = __( 'Edit Themes' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
$parent_file = 'themes.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    24
get_current_screen()->add_help_tab(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    25
	array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    26
		'id'      => 'overview',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    27
		'title'   => __( 'Overview' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    28
		'content' =>
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    29
				'<p>' . __( 'You can use the theme editor to edit the individual CSS and PHP files which make up your theme.' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    30
				'<p>' . __( 'Begin by choosing a theme to edit from the dropdown menu and clicking the Select button. A list then appears of the theme&#8217;s template files. Clicking once on any file name causes the file to appear in the large Editor box.' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    31
				'<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>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    32
				'<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    33
				'<ul>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    34
				'<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    35
				'<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    36
				'<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    37
				'</ul>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    38
				'<p>' . __( 'After typing in your edits, click Update File.' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    39
				'<p>' . __( '<strong>Advice:</strong> Think very carefully about your site crashing if you are live-editing the theme currently in use.' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    40
				'<p>' . sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    41
					/* translators: %s: link to documentation on child themes */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    42
					__( '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.' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    43
					__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    44
				) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
				( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    46
	)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
get_current_screen()->set_help_sidebar(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    50
	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
	'<p>' . __( '<a href="https://codex.wordpress.org/Theme_Development">Documentation on Theme Development</a>' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    52
	'<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
	'<p>' . __( '<a href="https://codex.wordpress.org/Editing_Files">Documentation on Editing Files</a>' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
	'<p>' . __( '<a href="https://codex.wordpress.org/Template_Tags">Documentation on Template Tags</a>' ) . '</p>' .
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    55
	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    60
if ( $theme ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	$stylesheet = $theme;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	$stylesheet = get_stylesheet();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    64
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
$theme = wp_get_theme( $stylesheet );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    68
if ( ! $theme->exists() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	wp_die( __( 'The requested theme does not exist.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    70
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    72
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	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
    74
}
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
$allowed_files = $style_files = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    77
$has_templates = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    78
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    79
$file_types = wp_get_theme_file_editable_extensions( $theme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
foreach ( $file_types as $type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    82
	switch ( $type ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    83
		case 'php':
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    84
			$allowed_files += $theme->get_files( 'php', -1 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
			$has_templates  = ! empty( $allowed_files );
7
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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
if ( empty( $file ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
	$relative_file = 'style.css';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   108
	$file          = $allowed_files['style.css'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   111
	$file          = $theme->get_stylesheet_directory() . '/' . $relative_file;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
validate_file_to_edit( $file, $allowed_files );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   117
$edit_error     = null;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   118
$posted_content = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   119
if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   120
	$r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   121
	if ( is_wp_error( $r ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   122
		$edit_error = $r;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   123
		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
   124
			$posted_content = wp_unslash( $_POST['newcontent'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   126
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
		wp_redirect(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
			add_query_arg(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   129
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   130
					'a'     => 1, // This means "success" for some reason.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   131
					'theme' => $stylesheet,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   132
					'file'  => $relative_file,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   133
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   134
				admin_url( 'theme-editor.php' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   135
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   136
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   137
		exit;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   139
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   141
	$settings = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   142
		'codeEditor' => wp_enqueue_code_editor( compact( 'file' ) ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   143
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   144
	wp_enqueue_script( 'wp-theme-plugin-editor' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   145
	wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   146
	wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
	require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
	update_recently_edited( $file );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   152
	if ( ! is_file( $file ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		$error = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   154
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
	$content = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   157
	if ( ! empty( $posted_content ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   158
		$content = $posted_content;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   159
	} elseif ( ! $error && filesize( $file ) > 0 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   160
		$f       = fopen( $file, 'r' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   161
		$content = fread( $f, filesize( $file ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			$functions = wp_doc_link_parse( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   166
			$docs_select  = '<select name="docs-list" id="docs-list">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			$docs_select .= '<option value="">' . esc_attr__( 'Function Name&hellip;' ) . '</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			foreach ( $functions as $function ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
				$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
			$docs_select .= '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		$content = esc_textarea( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   177
	$file_description = get_file_description( $relative_file );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   178
	$file_show        = array_search( $file, array_filter( $allowed_files ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   179
	$description      = esc_html( $file_description );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   180
	if ( $file_description != $file_show ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   181
		$description .= ' <span>(' . esc_html( $file_show ) . ')</span>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   182
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   183
	?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
<div class="wrap">
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   185
<h1><?php echo esc_html( $title ); ?></h1>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   186
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   187
<?php if ( isset( $_GET['a'] ) ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   188
	<div id="message" class="updated notice is-dismissible">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   189
		<p><?php _e( 'File edited successfully.' ); ?></p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   190
	</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   191
<?php elseif ( is_wp_error( $edit_error ) ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   192
	<div id="message" class="notice notice-error">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   193
		<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
   194
		<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
   195
	</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   196
<?php endif; ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   197
<?php if ( preg_match( '/\.css$/', $file ) ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   198
	<div id="message" class="notice-info notice">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   199
		<p><strong><?php _e( 'Did you know?' ); ?></strong></p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   200
		<p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   201
			<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   202
			echo sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   203
				/* translators: %s: link to Custom CSS section in the Customizer */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   204
				__( 'There&#8217;s no need to change your CSS here &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   205
				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
   206
			);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   207
			?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   208
		</p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   209
	</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   210
<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
<div class="fileedit-sub">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
<div class="alignleft">
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   214
<h2>
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   215
<?php
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   216
echo $theme->display( 'Name' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   217
if ( $description ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   218
	echo ': ' . $description;}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   219
?>
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   220
</h2>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
<div class="alignright">
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   223
	<form action="theme-editor.php" method="get">
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   224
		<strong><label for="theme"><?php _e( 'Select theme to edit:' ); ?> </label></strong>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		<select name="theme" id="theme">
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
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   228
	if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
		continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   230
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
	$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   233
	echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display( 'Name' ) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
		</select>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
		<?php submit_button( __( 'Select' ), '', 'Submit', false ); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
	</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
<?php
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   243
if ( $theme->errors() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
	echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   245
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
?>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   247
<div id="templateside">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   248
	<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
   249
	<ul role="tree" aria-labelledby="theme-files-label">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   250
		<?php if ( ( $has_templates || $theme->parent() ) && $theme->parent() ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   251
			<li class="howto">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   252
				<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   253
				/* translators: %s: link to edit parent theme */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   254
				echo sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   255
					__( 'This child theme inherits templates from a parent theme, %s.' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   256
					sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   257
						'<a href="%s">%s</a>',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   258
						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
   259
						$theme->parent()->display( 'Name' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   260
					)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   261
				);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   262
				?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   263
			</li>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   264
		<?php endif; ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   265
		<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
   266
			<ul role="group">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   267
				<?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
   268
			</ul>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   269
		</li>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   270
	</ul>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   271
</div>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   273
<?php
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   274
if ( $error ) :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   275
	echo '<div class="error"><p>' . __( 'Oops, no such file exists! Double check the name and try again, merci.' ) . '</p></div>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   276
else :
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   277
	?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
	<form name="template" id="template" action="theme-editor.php" method="post">
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   279
		<?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
   280
		<div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   281
			<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
   282
			<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
   283
			<input type="hidden" name="action" value="update" />
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   284
			<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
   285
			<input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	<?php if ( ! empty( $functions ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		<div id="documentation" class="hide-if-no-js">
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   289
		<label for="docs-list"><?php _e( 'Documentation:' ); ?></label>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
		<?php echo $docs_select; ?>
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   291
		<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() ) + '&amp;locale=<?php echo urlencode( get_user_locale() ); ?>&amp;version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&amp;redirect=true'); }" />
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   295
	<div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   296
		<div class="editor-notices">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   297
			<?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
				<div class="notice notice-warning inline">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   299
					<p>
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   300
						<?php
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   301
						if ( is_writeable( $file ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   302
							?>
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   303
						<strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   304
						<?php _e( 'This is a file in your current parent theme.' ); ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   305
					</p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   306
				</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   307
			<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		</div>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
	<?php if ( is_writeable( $file ) ) : ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   310
		<p class="submit">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   311
			<?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   312
			<span class="spinner"></span>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   313
		</p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   314
	<?php else : ?>
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   315
		<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>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   316
	<?php endif; ?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   317
	</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   318
	<?php wp_print_file_editor_templates(); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
	</form>
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   320
	<?php
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
endif; // $error
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
<?php
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   326
$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
   327
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   328
	// Get a back URL
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   329
	$referer                    = wp_get_referer();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   330
	$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
   331
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   332
	if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   333
		$return_url = $referer;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   334
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   335
		$return_url = admin_url( '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   336
	}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   337
	?>
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   338
<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   339
	<div class="notification-dialog-background"></div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   340
	<div class="notification-dialog">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   341
		<div class="file-editor-warning-content">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   342
			<div class="file-editor-warning-message">
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   343
				<h1><?php _e( 'Heads up!' ); ?></h1>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   344
				<p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   345
					<?php
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   346
					echo sprintf(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   347
						/* translators: %s: link to documentation on child themes */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   348
						__( 'You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don&#8217;t! Editing your theme directly could break your site and your changes may be lost in future updates. If you need to tweak more than your theme&#8217;s CSS, you might want to try <a href="%s">making a child theme</a>.' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   349
						esc_url( __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   350
					);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   351
					?>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   352
				</p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   353
				<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>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   354
			</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   355
			<p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   356
				<a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   357
				<button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   358
			</p>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   359
		</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   360
	</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   361
</div>
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
	<?php
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   363
endif; // editor warning notice
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   365
include( ABSPATH . 'wp-admin/admin-footer.php' );