@@ -9,8 +9,9 @@ |
||
9 | 9 | * @subpackage Administration |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! isset( $_GET['inline'] ) ) |
|
12 | +if ( ! isset( $_GET['inline'] ) ) { |
|
13 | 13 | define( 'IFRAME_REQUEST' , true ); |
14 | +} |
|
14 | 15 | |
15 | 16 | /** Load WordPress Administration Bootstrap */ |
16 | 17 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
@@ -9,47 +9,47 @@ discard block |
||
9 | 9 | * @subpackage Administration |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! isset( $_GET['inline'] ) ) |
|
13 | - define( 'IFRAME_REQUEST' , true ); |
|
12 | +if ( ! isset($_GET['inline'])) |
|
13 | + define('IFRAME_REQUEST', true); |
|
14 | 14 | |
15 | 15 | /** Load WordPress Administration Bootstrap */ |
16 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
16 | +require_once(dirname(__FILE__).'/admin.php'); |
|
17 | 17 | |
18 | -if ( ! current_user_can( 'upload_files' ) ) { |
|
19 | - wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 ); |
|
18 | +if ( ! current_user_can('upload_files')) { |
|
19 | + wp_die(__('Sorry, you are not allowed to upload files.'), 403); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | wp_enqueue_script('plupload-handlers'); |
23 | 23 | wp_enqueue_script('image-edit'); |
24 | -wp_enqueue_script('set-post-thumbnail' ); |
|
24 | +wp_enqueue_script('set-post-thumbnail'); |
|
25 | 25 | wp_enqueue_style('imgareaselect'); |
26 | -wp_enqueue_script( 'media-gallery' ); |
|
26 | +wp_enqueue_script('media-gallery'); |
|
27 | 27 | |
28 | -@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); |
|
28 | +@header('Content-Type: '.get_option('html_type').'; charset='.get_option('blog_charset')); |
|
29 | 29 | |
30 | 30 | // IDs should be integers |
31 | 31 | $ID = isset($ID) ? (int) $ID : 0; |
32 | -$post_id = isset($post_id)? (int) $post_id : 0; |
|
32 | +$post_id = isset($post_id) ? (int) $post_id : 0; |
|
33 | 33 | |
34 | 34 | // Require an ID for the edit screen. |
35 | -if ( isset( $action ) && $action == 'edit' && !$ID ) { |
|
35 | +if (isset($action) && $action == 'edit' && ! $ID) { |
|
36 | 36 | wp_die( |
37 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
38 | - '<p>' . __( 'Invalid item ID.' ) . '</p>', |
|
37 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
38 | + '<p>'.__('Invalid item ID.').'</p>', |
|
39 | 39 | 403 |
40 | 40 | ); |
41 | 41 | } |
42 | 42 | |
43 | -if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) ) { |
|
43 | +if ( ! empty($_REQUEST['post_id']) && ! current_user_can('edit_post', $_REQUEST['post_id'])) { |
|
44 | 44 | wp_die( |
45 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
46 | - '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
|
45 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
46 | + '<p>'.__('Sorry, you are not allowed to edit this item.').'</p>', |
|
47 | 47 | 403 |
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | 51 | // Upload type: image, video, file, ..? |
52 | -if ( isset($_GET['type']) ) { |
|
52 | +if (isset($_GET['type'])) { |
|
53 | 53 | $type = strval($_GET['type']); |
54 | 54 | } else { |
55 | 55 | /** |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * @param string $type The default media upload type. Possible values include |
61 | 61 | * 'image', 'audio', 'video', 'file', etc. Default 'file'. |
62 | 62 | */ |
63 | - $type = apply_filters( 'media_upload_default_type', 'file' ); |
|
63 | + $type = apply_filters('media_upload_default_type', 'file'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Tab: gallery, library, or type-specific. |
67 | -if ( isset($_GET['tab']) ) { |
|
67 | +if (isset($_GET['tab'])) { |
|
68 | 68 | $tab = strval($_GET['tab']); |
69 | 69 | } else { |
70 | 70 | /** |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param string $type The default media popup tab. Default 'type' (From Computer). |
76 | 76 | */ |
77 | - $tab = apply_filters( 'media_upload_default_tab', 'type' ); |
|
77 | + $tab = apply_filters('media_upload_default_tab', 'type'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $body_id = 'media-upload'; |
81 | 81 | |
82 | 82 | // Let the action code decide how to handle the request. |
83 | -if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) ) { |
|
83 | +if ($tab == 'type' || $tab == 'type_url' || ! array_key_exists($tab, media_upload_tabs())) { |
|
84 | 84 | /** |
85 | 85 | * Fires inside specific upload-type views in the legacy (pre-3.5.0) |
86 | 86 | * media popup based on the current tab. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @since 2.5.0 |
97 | 97 | */ |
98 | - do_action( "media_upload_{$type}" ); |
|
98 | + do_action("media_upload_{$type}"); |
|
99 | 99 | } else { |
100 | 100 | /** |
101 | 101 | * Fires inside limited and specific upload-tab views in the legacy |
@@ -107,6 +107,6 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @since 2.5.0 |
109 | 109 | */ |
110 | - do_action( "media_upload_{$tab}" ); |
|
110 | + do_action("media_upload_{$tab}"); |
|
111 | 111 | } |
112 | 112 |
@@ -62,8 +62,10 @@ discard block |
||
62 | 62 | echo '<h3 class="wp-people-group">' . esc_html( $title ) . "</h3>\n"; |
63 | 63 | } |
64 | 64 | |
65 | - if ( ! empty( $group_data['shuffle'] ) ) |
|
66 | - shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. |
|
65 | + if ( ! empty( $group_data['shuffle'] ) ) { |
|
66 | + shuffle( $group_data['data'] ); |
|
67 | + } |
|
68 | + // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. |
|
67 | 69 | |
68 | 70 | switch ( $group_data['type'] ) { |
69 | 71 | case 'list' : |
@@ -87,8 +89,9 @@ discard block |
||
87 | 89 | $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) ); |
88 | 90 | echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n"; |
89 | 91 | echo esc_html( $person_data[0] ) . "</a>\n\t"; |
90 | - if ( ! $compact ) |
|
91 | - echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n"; |
|
92 | + if ( ! $compact ) { |
|
93 | + echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n"; |
|
94 | + } |
|
92 | 95 | echo "</li>\n"; |
93 | 96 | } |
94 | 97 | echo "</ul>\n"; |
@@ -7,89 +7,89 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 | -require_once( dirname( __FILE__ ) . '/includes/credits.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | +require_once(dirname(__FILE__).'/includes/credits.php'); |
|
12 | 12 | |
13 | -$title = __( 'Credits' ); |
|
13 | +$title = __('Credits'); |
|
14 | 14 | |
15 | -list( $display_version ) = explode( '-', get_bloginfo( 'version' ) ); |
|
15 | +list($display_version) = explode('-', get_bloginfo('version')); |
|
16 | 16 | |
17 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
17 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
18 | 18 | ?> |
19 | 19 | <div class="wrap about-wrap"> |
20 | 20 | |
21 | -<h1><?php printf( __( 'Welcome to WordPress %s' ), $display_version ); ?></h1> |
|
21 | +<h1><?php printf(__('Welcome to WordPress %s'), $display_version); ?></h1> |
|
22 | 22 | |
23 | -<p class="about-text"><?php printf( __( 'Thank you for updating to the latest version! WordPress %s helps you get your site set up the way you want it.' ), $display_version ); ?></p> |
|
23 | +<p class="about-text"><?php printf(__('Thank you for updating to the latest version! WordPress %s helps you get your site set up the way you want it.'), $display_version); ?></p> |
|
24 | 24 | |
25 | -<div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div> |
|
25 | +<div class="wp-badge"><?php printf(__('Version %s'), $display_version); ?></div> |
|
26 | 26 | |
27 | 27 | <h2 class="nav-tab-wrapper wp-clearfix"> |
28 | - <a href="about.php" class="nav-tab"><?php _e( 'What’s New' ); ?></a> |
|
29 | - <a href="credits.php" class="nav-tab nav-tab-active"><?php _e( 'Credits' ); ?></a> |
|
30 | - <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a> |
|
28 | + <a href="about.php" class="nav-tab"><?php _e('What’s New'); ?></a> |
|
29 | + <a href="credits.php" class="nav-tab nav-tab-active"><?php _e('Credits'); ?></a> |
|
30 | + <a href="freedoms.php" class="nav-tab"><?php _e('Freedoms'); ?></a> |
|
31 | 31 | </h2> |
32 | 32 | |
33 | 33 | <?php |
34 | 34 | |
35 | 35 | $credits = wp_credits(); |
36 | 36 | |
37 | -if ( ! $credits ) { |
|
37 | +if ( ! $credits) { |
|
38 | 38 | echo '<p class="about-description">'; |
39 | 39 | /* translators: 1: https://wordpress.org/about/, 2: https://make.wordpress.org/ */ |
40 | - printf( __( 'WordPress is created by a <a href="%1$s">worldwide team</a> of passionate individuals. <a href="%2$s">Get involved in WordPress</a>.' ), |
|
40 | + printf(__('WordPress is created by a <a href="%1$s">worldwide team</a> of passionate individuals. <a href="%2$s">Get involved in WordPress</a>.'), |
|
41 | 41 | 'https://wordpress.org/about/', |
42 | - __( 'https://make.wordpress.org/' ) |
|
42 | + __('https://make.wordpress.org/') |
|
43 | 43 | ); |
44 | 44 | echo '</p>'; |
45 | 45 | echo '</div>'; |
46 | - include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
46 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
47 | 47 | exit; |
48 | 48 | } |
49 | 49 | |
50 | -echo '<p class="about-description">' . __( 'WordPress is created by a worldwide team of passionate individuals.' ) . "</p>\n"; |
|
50 | +echo '<p class="about-description">'.__('WordPress is created by a worldwide team of passionate individuals.')."</p>\n"; |
|
51 | 51 | |
52 | -foreach ( $credits['groups'] as $group_slug => $group_data ) { |
|
53 | - if ( $group_data['name'] ) { |
|
54 | - if ( 'Translators' == $group_data['name'] ) { |
|
52 | +foreach ($credits['groups'] as $group_slug => $group_data) { |
|
53 | + if ($group_data['name']) { |
|
54 | + if ('Translators' == $group_data['name']) { |
|
55 | 55 | // Considered a special slug in the API response. (Also, will never be returned for en_US.) |
56 | - $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' ); |
|
57 | - } elseif ( isset( $group_data['placeholders'] ) ) { |
|
58 | - $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] ); |
|
56 | + $title = _x('Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section'); |
|
57 | + } elseif (isset($group_data['placeholders'])) { |
|
58 | + $title = vsprintf(translate($group_data['name']), $group_data['placeholders']); |
|
59 | 59 | } else { |
60 | - $title = translate( $group_data['name'] ); |
|
60 | + $title = translate($group_data['name']); |
|
61 | 61 | } |
62 | 62 | |
63 | - echo '<h3 class="wp-people-group">' . esc_html( $title ) . "</h3>\n"; |
|
63 | + echo '<h3 class="wp-people-group">'.esc_html($title)."</h3>\n"; |
|
64 | 64 | } |
65 | 65 | |
66 | - if ( ! empty( $group_data['shuffle'] ) ) |
|
67 | - shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. |
|
66 | + if ( ! empty($group_data['shuffle'])) |
|
67 | + shuffle($group_data['data']); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. |
|
68 | 68 | |
69 | - switch ( $group_data['type'] ) { |
|
69 | + switch ($group_data['type']) { |
|
70 | 70 | case 'list' : |
71 | - array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] ); |
|
72 | - echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; |
|
71 | + array_walk($group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles']); |
|
72 | + echo '<p class="wp-credits-list">'.wp_sprintf('%l.', $group_data['data'])."</p>\n\n"; |
|
73 | 73 | break; |
74 | 74 | case 'libraries' : |
75 | - array_walk( $group_data['data'], '_wp_credits_build_object_link' ); |
|
76 | - echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; |
|
75 | + array_walk($group_data['data'], '_wp_credits_build_object_link'); |
|
76 | + echo '<p class="wp-credits-list">'.wp_sprintf('%l.', $group_data['data'])."</p>\n\n"; |
|
77 | 77 | break; |
78 | 78 | default: |
79 | 79 | $compact = 'compact' == $group_data['type']; |
80 | - $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' ); |
|
81 | - echo '<ul class="' . $classes . '" id="wp-people-group-' . $group_slug . '">' . "\n"; |
|
82 | - foreach ( $group_data['data'] as $person_data ) { |
|
83 | - echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t"; |
|
84 | - echo '<a href="' . esc_url( sprintf( $credits['data']['profiles'], $person_data[2] ) ) . '" class="web">'; |
|
80 | + $classes = 'wp-people-group '.($compact ? 'compact' : ''); |
|
81 | + echo '<ul class="'.$classes.'" id="wp-people-group-'.$group_slug.'">'."\n"; |
|
82 | + foreach ($group_data['data'] as $person_data) { |
|
83 | + echo '<li class="wp-person" id="wp-person-'.esc_attr($person_data[2]).'">'."\n\t"; |
|
84 | + echo '<a href="'.esc_url(sprintf($credits['data']['profiles'], $person_data[2])).'" class="web">'; |
|
85 | 85 | $size = 'compact' == $group_data['type'] ? 30 : 60; |
86 | - $data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) ); |
|
86 | + $data = get_avatar_data($person_data[1].'@md5.gravatar.com', array('size' => $size)); |
|
87 | 87 | $size *= 2; |
88 | - $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) ); |
|
89 | - echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n"; |
|
90 | - echo esc_html( $person_data[0] ) . "</a>\n\t"; |
|
91 | - if ( ! $compact ) |
|
92 | - echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n"; |
|
88 | + $data2x = get_avatar_data($person_data[1].'@md5.gravatar.com', array('size' => $size)); |
|
89 | + echo '<img src="'.esc_url($data['url']).'" srcset="'.esc_url($data2x['url']).' 2x" class="gravatar" alt="" />'."\n"; |
|
90 | + echo esc_html($person_data[0])."</a>\n\t"; |
|
91 | + if ( ! $compact) |
|
92 | + echo '<span class="title">'.translate($person_data[3])."</span>\n"; |
|
93 | 93 | echo "</li>\n"; |
94 | 94 | } |
95 | 95 | echo "</ul>\n"; |
@@ -100,26 +100,26 @@ discard block |
||
100 | 100 | ?> |
101 | 101 | <p class="clear"><?php |
102 | 102 | /* translators: %s: https://make.wordpress.org/ */ |
103 | - printf( __( 'Want to see your name in lights on this page? <a href="%s">Get involved in WordPress</a>.' ), |
|
104 | - __( 'https://make.wordpress.org/' ) |
|
103 | + printf(__('Want to see your name in lights on this page? <a href="%s">Get involved in WordPress</a>.'), |
|
104 | + __('https://make.wordpress.org/') |
|
105 | 105 | ); |
106 | 106 | ?></p> |
107 | 107 | |
108 | 108 | </div> |
109 | 109 | <?php |
110 | 110 | |
111 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
111 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
|
112 | 112 | |
113 | 113 | return; |
114 | 114 | |
115 | 115 | // These are strings returned by the API that we want to be translatable |
116 | -__( 'Project Leaders' ); |
|
117 | -__( 'Core Contributors to WordPress %s' ); |
|
118 | -__( 'Contributing Developers' ); |
|
119 | -__( 'Cofounder, Project Lead' ); |
|
120 | -__( 'Lead Developer' ); |
|
121 | -__( 'Release Lead' ); |
|
122 | -__( 'Release Design Lead' ); |
|
123 | -__( 'Release Deputy' ); |
|
124 | -__( 'Core Developer' ); |
|
125 | -__( 'External Libraries' ); |
|
116 | +__('Project Leaders'); |
|
117 | +__('Core Contributors to WordPress %s'); |
|
118 | +__('Contributing Developers'); |
|
119 | +__('Cofounder, Project Lead'); |
|
120 | +__('Lead Developer'); |
|
121 | +__('Release Lead'); |
|
122 | +__('Release Design Lead'); |
|
123 | +__('Release Deputy'); |
|
124 | +__('Core Developer'); |
|
125 | +__('External Libraries'); |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | /** WordPress Translation Install API */ |
13 | 13 | require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
14 | 14 | |
15 | -if ( ! current_user_can( 'manage_options' ) ) |
|
15 | +if ( ! current_user_can( 'manage_options' ) ) { |
|
16 | 16 | wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) ); |
17 | +} |
|
17 | 18 | |
18 | 19 | $title = __('General Settings'); |
19 | 20 | $parent_file = 'options-general.php'; |
@@ -68,13 +69,19 @@ discard block |
||
68 | 69 | <?php if ( !is_multisite() ) { ?> |
69 | 70 | <tr> |
70 | 71 | <th scope="row"><label for="siteurl"><?php _e('WordPress Address (URL)') ?></label></th> |
71 | -<td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" /></td> |
|
72 | +<td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) { |
|
73 | + echo ' disabled' ?>" /></td> |
|
72 | 74 | </tr> |
73 | 75 | <tr> |
74 | 76 | <th scope="row"><label for="home"><?php _e('Site Address (URL)') ?></label></th> |
75 | -<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" /> |
|
77 | +<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); |
|
78 | +} |
|
79 | +?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) { |
|
80 | + echo ' disabled' ?>" /> |
|
76 | 81 | <?php if ( ! defined( 'WP_HOME' ) ) : ?> |
77 | -<p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); ?></p></td> |
|
82 | +<p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); |
|
83 | +} |
|
84 | +?></p></td> |
|
78 | 85 | <?php endif; ?> |
79 | 86 | </tr> |
80 | 87 | <tr> |
@@ -129,18 +136,20 @@ discard block |
||
129 | 136 | $check_zone_info = true; |
130 | 137 | |
131 | 138 | // Remove old Etc mappings. Fallback to gmt_offset. |
132 | -if ( false !== strpos($tzstring,'Etc/GMT') ) |
|
139 | +if ( false !== strpos($tzstring,'Etc/GMT') ) { |
|
133 | 140 | $tzstring = ''; |
141 | +} |
|
134 | 142 | |
135 | 143 | if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists |
136 | 144 | $check_zone_info = false; |
137 | - if ( 0 == $current_offset ) |
|
138 | - $tzstring = 'UTC+0'; |
|
139 | - elseif ($current_offset < 0) |
|
140 | - $tzstring = 'UTC' . $current_offset; |
|
141 | - else |
|
142 | - $tzstring = 'UTC+' . $current_offset; |
|
143 | -} |
|
145 | + if ( 0 == $current_offset ) { |
|
146 | + $tzstring = 'UTC+0'; |
|
147 | + } elseif ($current_offset < 0) { |
|
148 | + $tzstring = 'UTC' . $current_offset; |
|
149 | + } else { |
|
150 | + $tzstring = 'UTC+' . $current_offset; |
|
151 | + } |
|
152 | + } |
|
144 | 153 | |
145 | 154 | ?> |
146 | 155 | <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th> |
@@ -177,10 +186,11 @@ discard block |
||
177 | 186 | // Set TZ so localtime works. |
178 | 187 | date_default_timezone_set($tzstring); |
179 | 188 | $now = localtime(time(), true); |
180 | - if ( $now['tm_isdst'] ) |
|
181 | - _e('This timezone is currently in daylight saving time.'); |
|
182 | - else |
|
183 | - _e('This timezone is currently in standard time.'); |
|
189 | + if ( $now['tm_isdst'] ) { |
|
190 | + _e('This timezone is currently in daylight saving time.'); |
|
191 | + } else { |
|
192 | + _e('This timezone is currently in standard time.'); |
|
193 | + } |
|
184 | 194 | ?> |
185 | 195 | <br /> |
186 | 196 | <?php |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $right_now = time(); |
194 | 194 | foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) { |
195 | 195 | if ( $tr['ts'] > $right_now ) { |
196 | - $found = true; |
|
196 | + $found = true; |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend> |
232 | 232 | <?php |
233 | 233 | /** |
234 | - * Filters the default date formats. |
|
235 | - * |
|
236 | - * @since 2.7.0 |
|
237 | - * @since 4.0.0 Added ISO date standard YYYY-MM-DD format. |
|
238 | - * |
|
239 | - * @param array $default_date_formats Array of default date formats. |
|
240 | - */ |
|
234 | + * Filters the default date formats. |
|
235 | + * |
|
236 | + * @since 2.7.0 |
|
237 | + * @since 4.0.0 Added ISO date standard YYYY-MM-DD format. |
|
238 | + * |
|
239 | + * @param array $default_date_formats Array of default date formats. |
|
240 | + */ |
|
241 | 241 | $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) ); |
242 | 242 | |
243 | 243 | $custom = true; |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend> |
269 | 269 | <?php |
270 | 270 | /** |
271 | - * Filters the default time formats. |
|
272 | - * |
|
273 | - * @since 2.7.0 |
|
274 | - * |
|
275 | - * @param array $default_time_formats Array of default time formats. |
|
276 | - */ |
|
271 | + * Filters the default time formats. |
|
272 | + * |
|
273 | + * @since 2.7.0 |
|
274 | + * |
|
275 | + * @param array $default_time_formats Array of default time formats. |
|
276 | + */ |
|
277 | 277 | $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) ); |
278 | 278 | |
279 | 279 | $custom = true; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | 12 | /** WordPress Translation Install API */ |
13 | -require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
13 | +require_once(ABSPATH.'wp-admin/includes/translation-install.php'); |
|
14 | 14 | |
15 | -if ( ! current_user_can( 'manage_options' ) ) |
|
16 | - wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
|
15 | +if ( ! current_user_can('manage_options')) |
|
16 | + wp_die(__('Sorry, you are not allowed to manage options for this site.')); |
|
17 | 17 | |
18 | 18 | $title = __('General Settings'); |
19 | 19 | $parent_file = 'options-general.php'; |
@@ -22,35 +22,35 @@ discard block |
||
22 | 22 | |
23 | 23 | add_action('admin_head', 'options_general_add_js'); |
24 | 24 | |
25 | -$options_help = '<p>' . __('The fields on this screen determine some of the basics of your site setup.') . '</p>' . |
|
26 | - '<p>' . __('Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.') . '</p>'; |
|
25 | +$options_help = '<p>'.__('The fields on this screen determine some of the basics of your site setup.').'</p>'. |
|
26 | + '<p>'.__('Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.').'</p>'; |
|
27 | 27 | |
28 | -if ( ! is_multisite() ) { |
|
29 | - $options_help .= '<p>' . __('The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.') . '</p>' . |
|
30 | - '<p>' . __('If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.') . '</p>'; |
|
28 | +if ( ! is_multisite()) { |
|
29 | + $options_help .= '<p>'.__('The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.').'</p>'. |
|
30 | + '<p>'.__('If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.').'</p>'; |
|
31 | 31 | } |
32 | 32 | |
33 | -$options_help .= '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' . |
|
34 | - '<p>' . __( 'UTC means Coordinated Universal Time.' ) . '</p>' . |
|
35 | - '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>'; |
|
33 | +$options_help .= '<p>'.__('You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).').'</p>'. |
|
34 | + '<p>'.__('UTC means Coordinated Universal Time.').'</p>'. |
|
35 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>'; |
|
36 | 36 | |
37 | -get_current_screen()->add_help_tab( array( |
|
37 | +get_current_screen()->add_help_tab(array( |
|
38 | 38 | 'id' => 'overview', |
39 | 39 | 'title' => __('Overview'), |
40 | 40 | 'content' => $options_help, |
41 | -) ); |
|
41 | +)); |
|
42 | 42 | |
43 | 43 | get_current_screen()->set_help_sidebar( |
44 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
45 | - '<p>' . __('<a href="https://codex.wordpress.org/Settings_General_Screen">Documentation on General Settings</a>') . '</p>' . |
|
46 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
44 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
45 | + '<p>'.__('<a href="https://codex.wordpress.org/Settings_General_Screen">Documentation on General Settings</a>').'</p>'. |
|
46 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
47 | 47 | ); |
48 | 48 | |
49 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
49 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
50 | 50 | ?> |
51 | 51 | |
52 | 52 | <div class="wrap"> |
53 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
53 | +<h1><?php echo esc_html($title); ?></h1> |
|
54 | 54 | |
55 | 55 | <form method="post" action="options.php" novalidate="novalidate"> |
56 | 56 | <?php settings_fields('general'); ?> |
@@ -63,24 +63,24 @@ discard block |
||
63 | 63 | <tr> |
64 | 64 | <th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th> |
65 | 65 | <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option('blogdescription'); ?>" class="regular-text" /> |
66 | -<p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ) ?></p></td> |
|
66 | +<p class="description" id="tagline-description"><?php _e('In a few words, explain what this site is about.') ?></p></td> |
|
67 | 67 | </tr> |
68 | -<?php if ( !is_multisite() ) { ?> |
|
68 | +<?php if ( ! is_multisite()) { ?> |
|
69 | 69 | <tr> |
70 | 70 | <th scope="row"><label for="siteurl"><?php _e('WordPress Address (URL)') ?></label></th> |
71 | -<td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" /></td> |
|
71 | +<td><input name="siteurl" type="url" id="siteurl" value="<?php form_option('siteurl'); ?>"<?php disabled(defined('WP_SITEURL')); ?> class="regular-text code<?php if (defined('WP_SITEURL')) echo ' disabled' ?>" /></td> |
|
72 | 72 | </tr> |
73 | 73 | <tr> |
74 | 74 | <th scope="row"><label for="home"><?php _e('Site Address (URL)') ?></label></th> |
75 | -<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" /> |
|
76 | -<?php if ( ! defined( 'WP_HOME' ) ) : ?> |
|
77 | -<p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); ?></p></td> |
|
75 | +<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option('home'); ?>"<?php disabled(defined('WP_HOME')); ?> class="regular-text code<?php if (defined('WP_HOME')) echo ' disabled' ?>" /> |
|
76 | +<?php if ( ! defined('WP_HOME')) : ?> |
|
77 | +<p class="description" id="home-description"><?php _e('Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>'); ?></p></td> |
|
78 | 78 | <?php endif; ?> |
79 | 79 | </tr> |
80 | 80 | <tr> |
81 | 81 | <th scope="row"><label for="admin_email"><?php _e('Email Address') ?> </label></th> |
82 | -<td><input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" /> |
|
83 | -<p class="description" id="admin-email-description"><?php _e( 'This address is used for admin purposes, like new user notification.' ) ?></p></td> |
|
82 | +<td><input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-description" value="<?php form_option('admin_email'); ?>" class="regular-text ltr" /> |
|
83 | +<p class="description" id="admin-email-description"><?php _e('This address is used for admin purposes, like new user notification.') ?></p></td> |
|
84 | 84 | </tr> |
85 | 85 | <tr> |
86 | 86 | <th scope="row"><?php _e('Membership') ?></th> |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | <tr> |
93 | 93 | <th scope="row"><label for="default_role"><?php _e('New User Default Role') ?></label></th> |
94 | 94 | <td> |
95 | -<select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select> |
|
95 | +<select name="default_role" id="default_role"><?php wp_dropdown_roles(get_option('default_role')); ?></select> |
|
96 | 96 | </td> |
97 | 97 | </tr> |
98 | 98 | <?php } else { ?> |
99 | 99 | <tr> |
100 | 100 | <th scope="row"><label for="new_admin_email"><?php _e('Email Address') ?> </label></th> |
101 | -<td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" /> |
|
102 | -<p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ) ?></p> |
|
101 | +<td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option('admin_email'); ?>" class="regular-text ltr" /> |
|
102 | +<p class="description" id="new-admin-email-description"><?php _e('This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></p> |
|
103 | 103 | <?php |
104 | -$new_admin_email = get_option( 'new_admin_email' ); |
|
105 | -if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?> |
|
104 | +$new_admin_email = get_option('new_admin_email'); |
|
105 | +if ($new_admin_email && $new_admin_email != get_option('admin_email')) : ?> |
|
106 | 106 | <div class="updated inline"> |
107 | 107 | <p><?php |
108 | 108 | printf( |
109 | 109 | /* translators: %s: new admin email */ |
110 | - __( 'There is a pending change of the admin email to %s.' ), |
|
111 | - '<code>' . esc_html( $new_admin_email ) . '</code>' |
|
110 | + __('There is a pending change of the admin email to %s.'), |
|
111 | + '<code>'.esc_html($new_admin_email).'</code>' |
|
112 | 112 | ); |
113 | 113 | printf( |
114 | 114 | ' <a href="%1$s">%2$s</a>', |
115 | - esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), |
|
116 | - __( 'Cancel' ) |
|
115 | + esc_url(wp_nonce_url(admin_url('options.php?dismiss=new_admin_email'), 'dismiss-'.get_current_blog_id().'-new_admin_email')), |
|
116 | + __('Cancel') |
|
117 | 117 | ); |
118 | 118 | ?></p> |
119 | 119 | </div> |
@@ -129,17 +129,17 @@ discard block |
||
129 | 129 | $check_zone_info = true; |
130 | 130 | |
131 | 131 | // Remove old Etc mappings. Fallback to gmt_offset. |
132 | -if ( false !== strpos($tzstring,'Etc/GMT') ) |
|
132 | +if (false !== strpos($tzstring, 'Etc/GMT')) |
|
133 | 133 | $tzstring = ''; |
134 | 134 | |
135 | -if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists |
|
135 | +if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists |
|
136 | 136 | $check_zone_info = false; |
137 | - if ( 0 == $current_offset ) |
|
137 | + if (0 == $current_offset) |
|
138 | 138 | $tzstring = 'UTC+0'; |
139 | 139 | elseif ($current_offset < 0) |
140 | - $tzstring = 'UTC' . $current_offset; |
|
140 | + $tzstring = 'UTC'.$current_offset; |
|
141 | 141 | else |
142 | - $tzstring = 'UTC+' . $current_offset; |
|
142 | + $tzstring = 'UTC+'.$current_offset; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | ?> |
@@ -147,37 +147,37 @@ discard block |
||
147 | 147 | <td> |
148 | 148 | |
149 | 149 | <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description"> |
150 | - <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?> |
|
150 | + <?php echo wp_timezone_choice($tzstring, get_user_locale()); ?> |
|
151 | 151 | </select> |
152 | 152 | |
153 | -<p class="description" id="timezone-description"><?php _e( 'Choose either a city in the same timezone as you or a UTC timezone offset.' ); ?></p> |
|
153 | +<p class="description" id="timezone-description"><?php _e('Choose either a city in the same timezone as you or a UTC timezone offset.'); ?></p> |
|
154 | 154 | |
155 | 155 | <p class="timezone-info"> |
156 | 156 | <span id="utc-time"><?php |
157 | 157 | /* translators: 1: UTC abbreviation, 2: UTC time */ |
158 | - printf( __( 'Universal time (%1$s) is %2$s.' ), |
|
159 | - '<abbr>' . __( 'UTC' ) . '</abbr>', |
|
160 | - '<code>' . date_i18n( $timezone_format, false, true ) . '</code>' |
|
158 | + printf(__('Universal time (%1$s) is %2$s.'), |
|
159 | + '<abbr>'.__('UTC').'</abbr>', |
|
160 | + '<code>'.date_i18n($timezone_format, false, true).'</code>' |
|
161 | 161 | ); |
162 | 162 | ?></span> |
163 | -<?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?> |
|
163 | +<?php if (get_option('timezone_string') || ! empty($current_offset)) : ?> |
|
164 | 164 | <span id="local-time"><?php |
165 | 165 | /* translators: %s: local time */ |
166 | - printf( __( 'Local time is %s.' ), |
|
167 | - '<code>' . date_i18n( $timezone_format ) . '</code>' |
|
166 | + printf(__('Local time is %s.'), |
|
167 | + '<code>'.date_i18n($timezone_format).'</code>' |
|
168 | 168 | ); |
169 | 169 | ?></span> |
170 | 170 | <?php endif; ?> |
171 | 171 | </p> |
172 | 172 | |
173 | -<?php if ( $check_zone_info && $tzstring ) : ?> |
|
173 | +<?php if ($check_zone_info && $tzstring) : ?> |
|
174 | 174 | <p class="timezone-info"> |
175 | 175 | <span> |
176 | 176 | <?php |
177 | 177 | // Set TZ so localtime works. |
178 | 178 | date_default_timezone_set($tzstring); |
179 | 179 | $now = localtime(time(), true); |
180 | - if ( $now['tm_isdst'] ) |
|
180 | + if ($now['tm_isdst']) |
|
181 | 181 | _e('This timezone is currently in daylight saving time.'); |
182 | 182 | else |
183 | 183 | _e('This timezone is currently in standard time.'); |
@@ -186,34 +186,33 @@ discard block |
||
186 | 186 | <?php |
187 | 187 | $allowed_zones = timezone_identifiers_list(); |
188 | 188 | |
189 | - if ( in_array( $tzstring, $allowed_zones) ) { |
|
189 | + if (in_array($tzstring, $allowed_zones)) { |
|
190 | 190 | $found = false; |
191 | 191 | $date_time_zone_selected = new DateTimeZone($tzstring); |
192 | 192 | $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
193 | 193 | $right_now = time(); |
194 | - foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
195 | - if ( $tr['ts'] > $right_now ) { |
|
194 | + foreach (timezone_transitions_get($date_time_zone_selected) as $tr) { |
|
195 | + if ($tr['ts'] > $right_now) { |
|
196 | 196 | $found = true; |
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if ( $found ) { |
|
201 | + if ($found) { |
|
202 | 202 | echo ' '; |
203 | 203 | $message = $tr['isdst'] ? |
204 | 204 | /* translators: %s: date and time */ |
205 | - __( 'Daylight saving time begins on: %s.') : |
|
206 | - /* translators: %s: date and time */ |
|
207 | - __( 'Standard time begins on: %s.' ); |
|
205 | + __('Daylight saving time begins on: %s.') : /* translators: %s: date and time */ |
|
206 | + __('Standard time begins on: %s.'); |
|
208 | 207 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
209 | - printf( $message, |
|
210 | - '<code>' . date_i18n( |
|
211 | - __( 'F j, Y' ) . ' ' . __( 'g:i a' ), |
|
212 | - $tr['ts'] + ( $tz_offset - $tr['offset'] ) |
|
213 | - ) . '</code>' |
|
208 | + printf($message, |
|
209 | + '<code>'.date_i18n( |
|
210 | + __('F j, Y').' '.__('g:i a'), |
|
211 | + $tr['ts'] + ($tz_offset - $tr['offset']) |
|
212 | + ).'</code>' |
|
214 | 213 | ); |
215 | 214 | } else { |
216 | - _e( 'This timezone does not observe daylight saving time.' ); |
|
215 | + _e('This timezone does not observe daylight saving time.'); |
|
217 | 216 | } |
218 | 217 | } |
219 | 218 | // Set back to UTC. |
@@ -238,25 +237,25 @@ discard block |
||
238 | 237 | * |
239 | 238 | * @param array $default_date_formats Array of default date formats. |
240 | 239 | */ |
241 | - $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) ); |
|
240 | + $date_formats = array_unique(apply_filters('date_formats', array(__('F j, Y'), 'Y-m-d', 'm/d/Y', 'd/m/Y'))); |
|
242 | 241 | |
243 | 242 | $custom = true; |
244 | 243 | |
245 | - foreach ( $date_formats as $format ) { |
|
246 | - echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'"; |
|
247 | - if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "===" |
|
244 | + foreach ($date_formats as $format) { |
|
245 | + echo "\t<label><input type='radio' name='date_format' value='".esc_attr($format)."'"; |
|
246 | + if (get_option('date_format') === $format) { // checked() uses "==" rather than "===" |
|
248 | 247 | echo " checked='checked'"; |
249 | 248 | $custom = false; |
250 | 249 | } |
251 | - echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; |
|
250 | + echo ' /> <span class="date-time-text format-i18n">'.date_i18n($format).'</span><code>'.esc_html($format)."</code></label><br />\n"; |
|
252 | 251 | } |
253 | 252 | |
254 | 253 | echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; |
255 | - checked( $custom ); |
|
256 | - echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom date format in the following field' ) . '</span></label>' . |
|
257 | - '<label for="date_format_custom" class="screen-reader-text">' . __( 'Custom date format:' ) . '</label>' . |
|
258 | - '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" /></span>' . |
|
259 | - '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' . |
|
254 | + checked($custom); |
|
255 | + echo '/> <span class="date-time-text date-time-custom-text">'.__('Custom:').'<span class="screen-reader-text"> '.__('enter a custom date format in the following field').'</span></label>'. |
|
256 | + '<label for="date_format_custom" class="screen-reader-text">'.__('Custom date format:').'</label>'. |
|
257 | + '<input type="text" name="date_format_custom" id="date_format_custom" value="'.esc_attr(get_option('date_format')).'" class="small-text" /></span>'. |
|
258 | + '<span class="screen-reader-text">'.__('example:').' </span> <span class="example">'.date_i18n(get_option('date_format')).'</span>'. |
|
260 | 259 | "<span class='spinner'></span>\n"; |
261 | 260 | ?> |
262 | 261 | </fieldset> |
@@ -274,28 +273,28 @@ discard block |
||
274 | 273 | * |
275 | 274 | * @param array $default_time_formats Array of default time formats. |
276 | 275 | */ |
277 | - $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) ); |
|
276 | + $time_formats = array_unique(apply_filters('time_formats', array(__('g:i a'), 'g:i A', 'H:i'))); |
|
278 | 277 | |
279 | 278 | $custom = true; |
280 | 279 | |
281 | - foreach ( $time_formats as $format ) { |
|
282 | - echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'"; |
|
283 | - if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "===" |
|
280 | + foreach ($time_formats as $format) { |
|
281 | + echo "\t<label><input type='radio' name='time_format' value='".esc_attr($format)."'"; |
|
282 | + if (get_option('time_format') === $format) { // checked() uses "==" rather than "===" |
|
284 | 283 | echo " checked='checked'"; |
285 | 284 | $custom = false; |
286 | 285 | } |
287 | - echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; |
|
286 | + echo ' /> <span class="date-time-text format-i18n">'.date_i18n($format).'</span><code>'.esc_html($format)."</code></label><br />\n"; |
|
288 | 287 | } |
289 | 288 | |
290 | 289 | echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; |
291 | - checked( $custom ); |
|
292 | - echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom time format in the following field' ) . '</span></label>' . |
|
293 | - '<label for="time_format_custom" class="screen-reader-text">' . __( 'Custom time format:' ) . '</label>' . |
|
294 | - '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" /></span>' . |
|
295 | - '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' . |
|
290 | + checked($custom); |
|
291 | + echo '/> <span class="date-time-text date-time-custom-text">'.__('Custom:').'<span class="screen-reader-text"> '.__('enter a custom time format in the following field').'</span></label>'. |
|
292 | + '<label for="time_format_custom" class="screen-reader-text">'.__('Custom time format:').'</label>'. |
|
293 | + '<input type="text" name="time_format_custom" id="time_format_custom" value="'.esc_attr(get_option('time_format')).'" class="small-text" /></span>'. |
|
294 | + '<span class="screen-reader-text">'.__('example:').' </span> <span class="example">'.date_i18n(get_option('time_format')).'</span>'. |
|
296 | 295 | "<span class='spinner'></span>\n"; |
297 | 296 | |
298 | - echo "\t<p class='date-time-doc'>" . __('<a href="https://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.') . "</p>\n"; |
|
297 | + echo "\t<p class='date-time-doc'>".__('<a href="https://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.')."</p>\n"; |
|
299 | 298 | ?> |
300 | 299 | </fieldset> |
301 | 300 | </td> |
@@ -311,7 +310,7 @@ discard block |
||
311 | 310 | |
312 | 311 | for ($day_index = 0; $day_index <= 6; $day_index++) : |
313 | 312 | $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : ''; |
314 | - echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; |
|
313 | + echo "\n\t<option value='".esc_attr($day_index)."' $selected>".$wp_locale->get_weekday($day_index).'</option>'; |
|
315 | 314 | endfor; |
316 | 315 | ?> |
317 | 316 | </select></td> |
@@ -321,39 +320,39 @@ discard block |
||
321 | 320 | <?php |
322 | 321 | $languages = get_available_languages(); |
323 | 322 | $translations = wp_get_available_translations(); |
324 | -if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { |
|
323 | +if ( ! is_multisite() && defined('WPLANG') && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array(WPLANG, $languages)) { |
|
325 | 324 | $languages[] = WPLANG; |
326 | 325 | } |
327 | -if ( ! empty( $languages ) || ! empty( $translations ) ) { |
|
326 | +if ( ! empty($languages) || ! empty($translations)) { |
|
328 | 327 | ?> |
329 | 328 | <tr> |
330 | - <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th> |
|
329 | + <th width="33%" scope="row"><label for="WPLANG"><?php _e('Site Language'); ?></label></th> |
|
331 | 330 | <td> |
332 | 331 | <?php |
333 | 332 | $locale = get_locale(); |
334 | - if ( ! in_array( $locale, $languages ) ) { |
|
333 | + if ( ! in_array($locale, $languages)) { |
|
335 | 334 | $locale = ''; |
336 | 335 | } |
337 | 336 | |
338 | - wp_dropdown_languages( array( |
|
337 | + wp_dropdown_languages(array( |
|
339 | 338 | 'name' => 'WPLANG', |
340 | 339 | 'id' => 'WPLANG', |
341 | 340 | 'selected' => $locale, |
342 | 341 | 'languages' => $languages, |
343 | 342 | 'translations' => $translations, |
344 | - 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(), |
|
345 | - ) ); |
|
343 | + 'show_available_translations' => ( ! is_multisite() || is_super_admin()) && wp_can_install_language_pack(), |
|
344 | + )); |
|
346 | 345 | |
347 | 346 | // Add note about deprecated WPLANG constant. |
348 | - if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) { |
|
349 | - if ( is_super_admin() ) { |
|
347 | + if (defined('WPLANG') && ('' !== WPLANG) && $locale !== WPLANG) { |
|
348 | + if (is_super_admin()) { |
|
350 | 349 | ?> |
351 | 350 | <p class="description"> |
352 | - <strong><?php _e( 'Note:' ); ?></strong> <?php printf( __( 'The %s constant in your %s file is no longer needed.' ), '<code>WPLANG</code>', '<code>wp-config.php</code>' ); ?> |
|
351 | + <strong><?php _e('Note:'); ?></strong> <?php printf(__('The %s constant in your %s file is no longer needed.'), '<code>WPLANG</code>', '<code>wp-config.php</code>'); ?> |
|
353 | 352 | </p> |
354 | 353 | <?php |
355 | 354 | } |
356 | - _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) ); |
|
355 | + _deprecated_argument('define()', '4.0.0', sprintf(__('The %s constant in your %s file is no longer needed.'), 'WPLANG', 'wp-config.php')); |
|
357 | 356 | } |
358 | 357 | ?> |
359 | 358 | </td> |
@@ -370,4 +369,4 @@ discard block |
||
370 | 369 | |
371 | 370 | </div> |
372 | 371 | |
373 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
372 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -41,21 +41,23 @@ discard block |
||
41 | 41 | nocache_headers(); |
42 | 42 | |
43 | 43 | // Support wp-config-sample.php one level up, for the develop repo. |
44 | -if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
|
44 | +if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) { |
|
45 | 45 | $config_file = file( ABSPATH . 'wp-config-sample.php' ); |
46 | -elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) |
|
46 | +} elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) { |
|
47 | 47 | $config_file = file( dirname( ABSPATH ) . '/wp-config-sample.php' ); |
48 | -else |
|
48 | +} else { |
|
49 | 49 | wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file to your WordPress installation.' ) ); |
50 | +} |
|
50 | 51 | |
51 | 52 | // Check if wp-config.php has been created |
52 | -if ( file_exists( ABSPATH . 'wp-config.php' ) ) |
|
53 | +if ( file_exists( ABSPATH . 'wp-config.php' ) ) { |
|
53 | 54 | wp_die( '<p>' . sprintf( |
54 | 55 | /* translators: %s: install.php */ |
55 | 56 | __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), |
56 | 57 | 'install.php' |
57 | 58 | ) . '</p>' |
58 | 59 | ); |
60 | +} |
|
59 | 61 | |
60 | 62 | // Check if wp-config.php exists above the root directory but is not part of another install |
61 | 63 | if ( @file_exists( ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) ) { |
@@ -90,7 +92,10 @@ discard block |
||
90 | 92 | header( 'Content-Type: text/html; charset=utf-8' ); |
91 | 93 | ?> |
92 | 94 | <!DOCTYPE html> |
93 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
95 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) { |
|
96 | + echo ' dir="rtl"'; |
|
97 | +} |
|
98 | +?>> |
|
94 | 99 | <head> |
95 | 100 | <meta name="viewport" content="width=device-width" /> |
96 | 101 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
@@ -246,12 +251,14 @@ discard block |
||
246 | 251 | |
247 | 252 | $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>'; |
248 | 253 | |
249 | - if ( empty( $prefix ) ) |
|
250 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
|
254 | + if ( empty( $prefix ) ) { |
|
255 | + wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
|
256 | + } |
|
251 | 257 | |
252 | 258 | // Validate $prefix: it can only contain letters, numbers and underscores. |
253 | - if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) |
|
254 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); |
|
259 | + if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) { |
|
260 | + wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); |
|
261 | + } |
|
255 | 262 | |
256 | 263 | // Test the db connection. |
257 | 264 | /**#@+ |
@@ -273,8 +280,9 @@ discard block |
||
273 | 280 | */ |
274 | 281 | $wpdb->db_connect(); |
275 | 282 | |
276 | - if ( ! empty( $wpdb->error ) ) |
|
277 | - wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
|
283 | + if ( ! empty( $wpdb->error ) ) { |
|
284 | + wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
|
285 | + } |
|
278 | 286 | |
279 | 287 | // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password(). |
280 | 288 | try { |
@@ -315,8 +323,9 @@ discard block |
||
315 | 323 | continue; |
316 | 324 | } |
317 | 325 | |
318 | - if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) |
|
319 | - continue; |
|
326 | + if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) { |
|
327 | + continue; |
|
328 | + } |
|
320 | 329 | |
321 | 330 | $constant = $match[1]; |
322 | 331 | $padding = $match[2]; |
@@ -375,15 +384,18 @@ discard block |
||
375 | 384 | })(); |
376 | 385 | </script> |
377 | 386 | <?php |
378 | - else : |
|
387 | + else { |
|
388 | + : |
|
379 | 389 | /* |
380 | 390 | * If this file doesn't exist, then we are using the wp-config-sample.php |
381 | 391 | * file one level up, which is for the develop repo. |
382 | 392 | */ |
383 | 393 | if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
384 | 394 | $path_to_wp_config = ABSPATH . 'wp-config.php'; |
385 | - else |
|
386 | - $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; |
|
395 | + } |
|
396 | + else { |
|
397 | + $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; |
|
398 | + } |
|
387 | 399 | |
388 | 400 | $handle = fopen( $path_to_wp_config, 'w' ); |
389 | 401 | foreach ( $config_file as $line ) { |
@@ -111,37 +111,37 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | switch($step) { |
114 | - case -1: |
|
115 | - if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { |
|
116 | - setup_config_display_header( 'language-chooser' ); |
|
117 | - echo '<h1 class="screen-reader-text">Select a default language</h1>'; |
|
118 | - echo '<form id="setup" method="post" action="?step=0">'; |
|
119 | - wp_install_language_form( $languages ); |
|
120 | - echo '</form>'; |
|
121 | - break; |
|
122 | - } |
|
114 | + case -1: |
|
115 | + if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { |
|
116 | + setup_config_display_header( 'language-chooser' ); |
|
117 | + echo '<h1 class="screen-reader-text">Select a default language</h1>'; |
|
118 | + echo '<form id="setup" method="post" action="?step=0">'; |
|
119 | + wp_install_language_form( $languages ); |
|
120 | + echo '</form>'; |
|
121 | + break; |
|
122 | + } |
|
123 | 123 | |
124 | - // Deliberately fall through if we can't reach the translations API. |
|
124 | + // Deliberately fall through if we can't reach the translations API. |
|
125 | 125 | |
126 | - case 0: |
|
127 | - if ( ! empty( $language ) ) { |
|
128 | - $loaded_language = wp_download_language_pack( $language ); |
|
129 | - if ( $loaded_language ) { |
|
130 | - load_default_textdomain( $loaded_language ); |
|
131 | - $GLOBALS['wp_locale'] = new WP_Locale(); |
|
126 | + case 0: |
|
127 | + if ( ! empty( $language ) ) { |
|
128 | + $loaded_language = wp_download_language_pack( $language ); |
|
129 | + if ( $loaded_language ) { |
|
130 | + load_default_textdomain( $loaded_language ); |
|
131 | + $GLOBALS['wp_locale'] = new WP_Locale(); |
|
132 | + } |
|
132 | 133 | } |
133 | - } |
|
134 | 134 | |
135 | - setup_config_display_header(); |
|
136 | - $step_1 = 'setup-config.php?step=1'; |
|
137 | - if ( isset( $_REQUEST['noapi'] ) ) { |
|
138 | - $step_1 .= '&noapi'; |
|
139 | - } |
|
140 | - if ( ! empty( $loaded_language ) ) { |
|
141 | - $step_1 .= '&language=' . $loaded_language; |
|
142 | - } |
|
143 | -?> |
|
144 | -<h1 class="screen-reader-text"><?php _e( 'Before getting started' ) ?></h1> |
|
135 | + setup_config_display_header(); |
|
136 | + $step_1 = 'setup-config.php?step=1'; |
|
137 | + if ( isset( $_REQUEST['noapi'] ) ) { |
|
138 | + $step_1 .= '&noapi'; |
|
139 | + } |
|
140 | + if ( ! empty( $loaded_language ) ) { |
|
141 | + $step_1 .= '&language=' . $loaded_language; |
|
142 | + } |
|
143 | + ?> |
|
144 | + <h1 class="screen-reader-text"><?php _e( 'Before getting started' ) ?></h1> |
|
145 | 145 | <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p> |
146 | 146 | <ol> |
147 | 147 | <li><?php _e( 'Database name' ); ?></li> |
@@ -151,37 +151,37 @@ discard block |
||
151 | 151 | <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li> |
152 | 152 | </ol> |
153 | 153 | <p><?php |
154 | - /* translators: %s: wp-config.php */ |
|
155 | - printf( __( 'We’re going to use this information to create a %s file.' ), |
|
156 | - '<code>wp-config.php</code>' |
|
157 | - ); |
|
158 | - ?> |
|
159 | - <strong><?php |
|
160 | - /* translators: 1: wp-config-sample.php, 2: wp-config.php */ |
|
161 | - printf( __( 'If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.' ), |
|
162 | - '<code>wp-config-sample.php</code>', |
|
154 | + /* translators: %s: wp-config.php */ |
|
155 | + printf( __( 'We’re going to use this information to create a %s file.' ), |
|
163 | 156 | '<code>wp-config.php</code>' |
164 | 157 | ); |
165 | - ?></strong> |
|
158 | + ?> |
|
159 | + <strong><?php |
|
160 | + /* translators: 1: wp-config-sample.php, 2: wp-config.php */ |
|
161 | + printf( __( 'If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.' ), |
|
162 | + '<code>wp-config-sample.php</code>', |
|
163 | + '<code>wp-config.php</code>' |
|
164 | + ); |
|
165 | + ?></strong> |
|
166 | 166 | <?php |
167 | - /* translators: %s: Codex URL */ |
|
168 | - printf( __( 'Need more help? <a href="%s">We got it</a>.' ), |
|
169 | - __( 'https://codex.wordpress.org/Editing_wp-config.php' ) |
|
170 | - ); |
|
171 | -?></p> |
|
167 | + /* translators: %s: Codex URL */ |
|
168 | + printf( __( 'Need more help? <a href="%s">We got it</a>.' ), |
|
169 | + __( 'https://codex.wordpress.org/Editing_wp-config.php' ) |
|
170 | + ); |
|
171 | + ?></p> |
|
172 | 172 | <p><?php _e( 'In all likelihood, these items were supplied to you by your Web Host. If you don’t have this information, then you will need to contact them before you can continue. If you’re all ready…' ); ?></p> |
173 | 173 | |
174 | 174 | <p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p> |
175 | -<?php |
|
176 | - break; |
|
175 | + <?php |
|
176 | + break; |
|
177 | 177 | |
178 | - case 1: |
|
179 | - load_default_textdomain( $language ); |
|
180 | - $GLOBALS['wp_locale'] = new WP_Locale(); |
|
178 | + case 1: |
|
179 | + load_default_textdomain( $language ); |
|
180 | + $GLOBALS['wp_locale'] = new WP_Locale(); |
|
181 | 181 | |
182 | - setup_config_display_header(); |
|
183 | - ?> |
|
184 | -<h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ) ?></h1> |
|
182 | + setup_config_display_header(); |
|
183 | + ?> |
|
184 | + <h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ) ?></h1> |
|
185 | 185 | <form method="post" action="setup-config.php?step=2"> |
186 | 186 | <p><?php _e( 'Below you should enter your database connection details. If you’re not sure about these, contact your host.' ); ?></p> |
187 | 187 | <table class="form-table"> |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | <th scope="row"><label for="dbhost"><?php _e( 'Database Host' ); ?></label></th> |
205 | 205 | <td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td> |
206 | 206 | <td><?php |
207 | - /* translators: %s: localhost */ |
|
208 | - printf( __( 'You should be able to get this info from your web host, if %s doesn’t work.' ),'<code>localhost</code>' ); |
|
209 | - ?></td> |
|
207 | + /* translators: %s: localhost */ |
|
208 | + printf( __( 'You should be able to get this info from your web host, if %s doesn’t work.' ),'<code>localhost</code>' ); |
|
209 | + ?></td> |
|
210 | 210 | </tr> |
211 | 211 | <tr> |
212 | 212 | <th scope="row"><label for="prefix"><?php _e( 'Table Prefix' ); ?></label></th> |
@@ -215,118 +215,118 @@ discard block |
||
215 | 215 | </tr> |
216 | 216 | </table> |
217 | 217 | <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> |
218 | - <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" /> |
|
218 | + <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" /> |
|
219 | 219 | <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p> |
220 | 220 | </form> |
221 | 221 | <?php |
222 | - break; |
|
222 | + break; |
|
223 | 223 | |
224 | - case 2: |
|
225 | - load_default_textdomain( $language ); |
|
226 | - $GLOBALS['wp_locale'] = new WP_Locale(); |
|
224 | + case 2: |
|
225 | + load_default_textdomain( $language ); |
|
226 | + $GLOBALS['wp_locale'] = new WP_Locale(); |
|
227 | 227 | |
228 | - $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) ); |
|
229 | - $uname = trim( wp_unslash( $_POST[ 'uname' ] ) ); |
|
230 | - $pwd = trim( wp_unslash( $_POST[ 'pwd' ] ) ); |
|
231 | - $dbhost = trim( wp_unslash( $_POST[ 'dbhost' ] ) ); |
|
232 | - $prefix = trim( wp_unslash( $_POST[ 'prefix' ] ) ); |
|
228 | + $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) ); |
|
229 | + $uname = trim( wp_unslash( $_POST[ 'uname' ] ) ); |
|
230 | + $pwd = trim( wp_unslash( $_POST[ 'pwd' ] ) ); |
|
231 | + $dbhost = trim( wp_unslash( $_POST[ 'dbhost' ] ) ); |
|
232 | + $prefix = trim( wp_unslash( $_POST[ 'prefix' ] ) ); |
|
233 | 233 | |
234 | - $step_1 = 'setup-config.php?step=1'; |
|
235 | - $install = 'install.php'; |
|
236 | - if ( isset( $_REQUEST['noapi'] ) ) { |
|
237 | - $step_1 .= '&noapi'; |
|
238 | - } |
|
234 | + $step_1 = 'setup-config.php?step=1'; |
|
235 | + $install = 'install.php'; |
|
236 | + if ( isset( $_REQUEST['noapi'] ) ) { |
|
237 | + $step_1 .= '&noapi'; |
|
238 | + } |
|
239 | 239 | |
240 | - if ( ! empty( $language ) ) { |
|
241 | - $step_1 .= '&language=' . $language; |
|
242 | - $install .= '?language=' . $language; |
|
243 | - } else { |
|
244 | - $install .= '?language=en_US'; |
|
245 | - } |
|
240 | + if ( ! empty( $language ) ) { |
|
241 | + $step_1 .= '&language=' . $language; |
|
242 | + $install .= '?language=' . $language; |
|
243 | + } else { |
|
244 | + $install .= '?language=en_US'; |
|
245 | + } |
|
246 | 246 | |
247 | - $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>'; |
|
247 | + $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>'; |
|
248 | 248 | |
249 | - if ( empty( $prefix ) ) |
|
250 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
|
249 | + if ( empty( $prefix ) ) |
|
250 | + wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
|
251 | 251 | |
252 | - // Validate $prefix: it can only contain letters, numbers and underscores. |
|
253 | - if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) |
|
254 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); |
|
252 | + // Validate $prefix: it can only contain letters, numbers and underscores. |
|
253 | + if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) |
|
254 | + wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); |
|
255 | 255 | |
256 | - // Test the db connection. |
|
257 | - /**#@+ |
|
256 | + // Test the db connection. |
|
257 | + /**#@+ |
|
258 | 258 | * @ignore |
259 | 259 | */ |
260 | - define('DB_NAME', $dbname); |
|
261 | - define('DB_USER', $uname); |
|
262 | - define('DB_PASSWORD', $pwd); |
|
263 | - define('DB_HOST', $dbhost); |
|
264 | - /**#@-*/ |
|
260 | + define('DB_NAME', $dbname); |
|
261 | + define('DB_USER', $uname); |
|
262 | + define('DB_PASSWORD', $pwd); |
|
263 | + define('DB_HOST', $dbhost); |
|
264 | + /**#@-*/ |
|
265 | 265 | |
266 | - // Re-construct $wpdb with these new values. |
|
267 | - unset( $wpdb ); |
|
268 | - require_wp_db(); |
|
266 | + // Re-construct $wpdb with these new values. |
|
267 | + unset( $wpdb ); |
|
268 | + require_wp_db(); |
|
269 | 269 | |
270 | - /* |
|
270 | + /* |
|
271 | 271 | * The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must |
272 | 272 | * fire this manually. We'll fail here if the values are no good. |
273 | 273 | */ |
274 | - $wpdb->db_connect(); |
|
274 | + $wpdb->db_connect(); |
|
275 | 275 | |
276 | - if ( ! empty( $wpdb->error ) ) |
|
277 | - wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
|
276 | + if ( ! empty( $wpdb->error ) ) |
|
277 | + wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
|
278 | 278 | |
279 | - $wpdb->query( "SELECT $prefix" ); |
|
280 | - if ( ! $wpdb->last_error ) { |
|
281 | - // MySQL was able to parse the prefix as a value, which we don't want. Bail. |
|
282 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid.' ) ); |
|
283 | - } |
|
284 | - |
|
285 | - // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password(). |
|
286 | - try { |
|
287 | - $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; |
|
288 | - $max = strlen($chars) - 1; |
|
289 | - for ( $i = 0; $i < 8; $i++ ) { |
|
290 | - $key = ''; |
|
291 | - for ( $j = 0; $j < 64; $j++ ) { |
|
292 | - $key .= substr( $chars, random_int( 0, $max ), 1 ); |
|
293 | - } |
|
294 | - $secret_keys[] = $key; |
|
279 | + $wpdb->query( "SELECT $prefix" ); |
|
280 | + if ( ! $wpdb->last_error ) { |
|
281 | + // MySQL was able to parse the prefix as a value, which we don't want. Bail. |
|
282 | + wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid.' ) ); |
|
295 | 283 | } |
296 | - } catch ( Exception $ex ) { |
|
297 | - $no_api = isset( $_POST['noapi'] ); |
|
298 | 284 | |
299 | - if ( ! $no_api ) { |
|
300 | - $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
|
301 | - } |
|
302 | - |
|
303 | - if ( $no_api || is_wp_error( $secret_keys ) ) { |
|
304 | - $secret_keys = array(); |
|
285 | + // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password(). |
|
286 | + try { |
|
287 | + $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; |
|
288 | + $max = strlen($chars) - 1; |
|
305 | 289 | for ( $i = 0; $i < 8; $i++ ) { |
306 | - $secret_keys[] = wp_generate_password( 64, true, true ); |
|
290 | + $key = ''; |
|
291 | + for ( $j = 0; $j < 64; $j++ ) { |
|
292 | + $key .= substr( $chars, random_int( 0, $max ), 1 ); |
|
293 | + } |
|
294 | + $secret_keys[] = $key; |
|
307 | 295 | } |
308 | - } else { |
|
309 | - $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); |
|
310 | - foreach ( $secret_keys as $k => $v ) { |
|
311 | - $secret_keys[$k] = substr( $v, 28, 64 ); |
|
296 | + } catch ( Exception $ex ) { |
|
297 | + $no_api = isset( $_POST['noapi'] ); |
|
298 | + |
|
299 | + if ( ! $no_api ) { |
|
300 | + $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
|
312 | 301 | } |
313 | - } |
|
314 | - } |
|
315 | 302 | |
316 | - $key = 0; |
|
317 | - foreach ( $config_file as $line_num => $line ) { |
|
318 | - if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { |
|
319 | - $config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; |
|
320 | - continue; |
|
303 | + if ( $no_api || is_wp_error( $secret_keys ) ) { |
|
304 | + $secret_keys = array(); |
|
305 | + for ( $i = 0; $i < 8; $i++ ) { |
|
306 | + $secret_keys[] = wp_generate_password( 64, true, true ); |
|
307 | + } |
|
308 | + } else { |
|
309 | + $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); |
|
310 | + foreach ( $secret_keys as $k => $v ) { |
|
311 | + $secret_keys[$k] = substr( $v, 28, 64 ); |
|
312 | + } |
|
313 | + } |
|
321 | 314 | } |
322 | 315 | |
323 | - if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) |
|
324 | - continue; |
|
316 | + $key = 0; |
|
317 | + foreach ( $config_file as $line_num => $line ) { |
|
318 | + if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { |
|
319 | + $config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; |
|
320 | + continue; |
|
321 | + } |
|
325 | 322 | |
326 | - $constant = $match[1]; |
|
327 | - $padding = $match[2]; |
|
323 | + if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) |
|
324 | + continue; |
|
328 | 325 | |
329 | - switch ( $constant ) { |
|
326 | + $constant = $match[1]; |
|
327 | + $padding = $match[2]; |
|
328 | + |
|
329 | + switch ( $constant ) { |
|
330 | 330 | case 'DB_NAME' : |
331 | 331 | case 'DB_USER' : |
332 | 332 | case 'DB_PASSWORD' : |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | case 'NONCE_SALT' : |
349 | 349 | $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n"; |
350 | 350 | break; |
351 | - } |
|
351 | + } |
|
352 | 352 | } |
353 | 353 | unset( $line ); |
354 | 354 |
@@ -26,48 +26,48 @@ discard block |
||
26 | 26 | */ |
27 | 27 | error_reporting(0); |
28 | 28 | |
29 | -if ( ! defined( 'ABSPATH' ) ) { |
|
30 | - define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
|
29 | +if ( ! defined('ABSPATH')) { |
|
30 | + define('ABSPATH', dirname(dirname(__FILE__)).'/'); |
|
31 | 31 | } |
32 | 32 | |
33 | -require( ABSPATH . 'wp-settings.php' ); |
|
33 | +require(ABSPATH.'wp-settings.php'); |
|
34 | 34 | |
35 | 35 | /** Load WordPress Administration Upgrade API */ |
36 | -require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
36 | +require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
37 | 37 | |
38 | 38 | /** Load WordPress Translation Install API */ |
39 | -require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
39 | +require_once(ABSPATH.'wp-admin/includes/translation-install.php'); |
|
40 | 40 | |
41 | 41 | nocache_headers(); |
42 | 42 | |
43 | 43 | // Support wp-config-sample.php one level up, for the develop repo. |
44 | -if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
|
45 | - $config_file = file( ABSPATH . 'wp-config-sample.php' ); |
|
46 | -elseif ( file_exists( dirname( ABSPATH ) . '/wp-config-sample.php' ) ) |
|
47 | - $config_file = file( dirname( ABSPATH ) . '/wp-config-sample.php' ); |
|
44 | +if (file_exists(ABSPATH.'wp-config-sample.php')) |
|
45 | + $config_file = file(ABSPATH.'wp-config-sample.php'); |
|
46 | +elseif (file_exists(dirname(ABSPATH).'/wp-config-sample.php')) |
|
47 | + $config_file = file(dirname(ABSPATH).'/wp-config-sample.php'); |
|
48 | 48 | else |
49 | - wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file to your WordPress installation.' ) ); |
|
49 | + wp_die(__('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file to your WordPress installation.')); |
|
50 | 50 | |
51 | 51 | // Check if wp-config.php has been created |
52 | -if ( file_exists( ABSPATH . 'wp-config.php' ) ) |
|
53 | - wp_die( '<p>' . sprintf( |
|
52 | +if (file_exists(ABSPATH.'wp-config.php')) |
|
53 | + wp_die('<p>'.sprintf( |
|
54 | 54 | /* translators: %s: install.php */ |
55 | - __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), |
|
55 | + __("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>."), |
|
56 | 56 | 'install.php' |
57 | - ) . '</p>' |
|
57 | + ).'</p>' |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | // Check if wp-config.php exists above the root directory but is not part of another install |
61 | -if ( @file_exists( ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) ) { |
|
62 | - wp_die( '<p>' . sprintf( |
|
61 | +if (@file_exists(ABSPATH.'../wp-config.php') && ! @file_exists(ABSPATH.'../wp-settings.php')) { |
|
62 | + wp_die('<p>'.sprintf( |
|
63 | 63 | /* translators: %s: install.php */ |
64 | - __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>." ), |
|
64 | + __("The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='%s'>installing now</a>."), |
|
65 | 65 | 'install.php' |
66 | - ) . '</p>' |
|
66 | + ).'</p>' |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
70 | -$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : -1; |
|
70 | +$step = isset($_GET['step']) ? (int) $_GET['step'] : -1; |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Display setup wp-config.php file header. |
@@ -80,43 +80,43 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param string|array $body_classes |
82 | 82 | */ |
83 | -function setup_config_display_header( $body_classes = array() ) { |
|
83 | +function setup_config_display_header($body_classes = array()) { |
|
84 | 84 | $body_classes = (array) $body_classes; |
85 | 85 | $body_classes[] = 'wp-core-ui'; |
86 | - if ( is_rtl() ) { |
|
86 | + if (is_rtl()) { |
|
87 | 87 | $body_classes[] = 'rtl'; |
88 | 88 | } |
89 | 89 | |
90 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
90 | + header('Content-Type: text/html; charset=utf-8'); |
|
91 | 91 | ?> |
92 | 92 | <!DOCTYPE html> |
93 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
93 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>> |
|
94 | 94 | <head> |
95 | 95 | <meta name="viewport" content="width=device-width" /> |
96 | 96 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
97 | 97 | <meta name="robots" content="noindex,nofollow" /> |
98 | - <title><?php _e( 'WordPress › Setup Configuration File' ); ?></title> |
|
99 | - <?php wp_admin_css( 'install', true ); ?> |
|
98 | + <title><?php _e('WordPress › Setup Configuration File'); ?></title> |
|
99 | + <?php wp_admin_css('install', true); ?> |
|
100 | 100 | </head> |
101 | -<body class="<?php echo implode( ' ', $body_classes ); ?>"> |
|
102 | -<p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></p> |
|
101 | +<body class="<?php echo implode(' ', $body_classes); ?>"> |
|
102 | +<p id="logo"><a href="<?php echo esc_url(__('https://wordpress.org/')); ?>" tabindex="-1"><?php _e('WordPress'); ?></a></p> |
|
103 | 103 | <?php |
104 | 104 | } // end function setup_config_display_header(); |
105 | 105 | |
106 | 106 | $language = ''; |
107 | -if ( ! empty( $_REQUEST['language'] ) ) { |
|
108 | - $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); |
|
109 | -} elseif ( isset( $GLOBALS['wp_local_package'] ) ) { |
|
107 | +if ( ! empty($_REQUEST['language'])) { |
|
108 | + $language = preg_replace('/[^a-zA-Z_]/', '', $_REQUEST['language']); |
|
109 | +} elseif (isset($GLOBALS['wp_local_package'])) { |
|
110 | 110 | $language = $GLOBALS['wp_local_package']; |
111 | 111 | } |
112 | 112 | |
113 | -switch($step) { |
|
113 | +switch ($step) { |
|
114 | 114 | case -1: |
115 | - if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) { |
|
116 | - setup_config_display_header( 'language-chooser' ); |
|
115 | + if (wp_can_install_language_pack() && empty($language) && ($languages = wp_get_available_translations())) { |
|
116 | + setup_config_display_header('language-chooser'); |
|
117 | 117 | echo '<h1 class="screen-reader-text">Select a default language</h1>'; |
118 | 118 | echo '<form id="setup" method="post" action="?step=0">'; |
119 | - wp_install_language_form( $languages ); |
|
119 | + wp_install_language_form($languages); |
|
120 | 120 | echo '</form>'; |
121 | 121 | break; |
122 | 122 | } |
@@ -124,134 +124,134 @@ discard block |
||
124 | 124 | // Deliberately fall through if we can't reach the translations API. |
125 | 125 | |
126 | 126 | case 0: |
127 | - if ( ! empty( $language ) ) { |
|
128 | - $loaded_language = wp_download_language_pack( $language ); |
|
129 | - if ( $loaded_language ) { |
|
130 | - load_default_textdomain( $loaded_language ); |
|
127 | + if ( ! empty($language)) { |
|
128 | + $loaded_language = wp_download_language_pack($language); |
|
129 | + if ($loaded_language) { |
|
130 | + load_default_textdomain($loaded_language); |
|
131 | 131 | $GLOBALS['wp_locale'] = new WP_Locale(); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 135 | setup_config_display_header(); |
136 | 136 | $step_1 = 'setup-config.php?step=1'; |
137 | - if ( isset( $_REQUEST['noapi'] ) ) { |
|
137 | + if (isset($_REQUEST['noapi'])) { |
|
138 | 138 | $step_1 .= '&noapi'; |
139 | 139 | } |
140 | - if ( ! empty( $loaded_language ) ) { |
|
141 | - $step_1 .= '&language=' . $loaded_language; |
|
140 | + if ( ! empty($loaded_language)) { |
|
141 | + $step_1 .= '&language='.$loaded_language; |
|
142 | 142 | } |
143 | 143 | ?> |
144 | -<h1 class="screen-reader-text"><?php _e( 'Before getting started' ) ?></h1> |
|
145 | -<p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p> |
|
144 | +<h1 class="screen-reader-text"><?php _e('Before getting started') ?></h1> |
|
145 | +<p><?php _e('Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.') ?></p> |
|
146 | 146 | <ol> |
147 | - <li><?php _e( 'Database name' ); ?></li> |
|
148 | - <li><?php _e( 'Database username' ); ?></li> |
|
149 | - <li><?php _e( 'Database password' ); ?></li> |
|
150 | - <li><?php _e( 'Database host' ); ?></li> |
|
151 | - <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li> |
|
147 | + <li><?php _e('Database name'); ?></li> |
|
148 | + <li><?php _e('Database username'); ?></li> |
|
149 | + <li><?php _e('Database password'); ?></li> |
|
150 | + <li><?php _e('Database host'); ?></li> |
|
151 | + <li><?php _e('Table prefix (if you want to run more than one WordPress in a single database)'); ?></li> |
|
152 | 152 | </ol> |
153 | 153 | <p><?php |
154 | 154 | /* translators: %s: wp-config.php */ |
155 | - printf( __( 'We’re going to use this information to create a %s file.' ), |
|
155 | + printf(__('We’re going to use this information to create a %s file.'), |
|
156 | 156 | '<code>wp-config.php</code>' |
157 | 157 | ); |
158 | 158 | ?> |
159 | 159 | <strong><?php |
160 | 160 | /* translators: 1: wp-config-sample.php, 2: wp-config.php */ |
161 | - printf( __( 'If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.' ), |
|
161 | + printf(__('If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open %1$s in a text editor, fill in your information, and save it as %2$s.'), |
|
162 | 162 | '<code>wp-config-sample.php</code>', |
163 | 163 | '<code>wp-config.php</code>' |
164 | 164 | ); |
165 | 165 | ?></strong> |
166 | 166 | <?php |
167 | 167 | /* translators: %s: Codex URL */ |
168 | - printf( __( 'Need more help? <a href="%s">We got it</a>.' ), |
|
169 | - __( 'https://codex.wordpress.org/Editing_wp-config.php' ) |
|
168 | + printf(__('Need more help? <a href="%s">We got it</a>.'), |
|
169 | + __('https://codex.wordpress.org/Editing_wp-config.php') |
|
170 | 170 | ); |
171 | 171 | ?></p> |
172 | -<p><?php _e( 'In all likelihood, these items were supplied to you by your Web Host. If you don’t have this information, then you will need to contact them before you can continue. If you’re all ready…' ); ?></p> |
|
172 | +<p><?php _e('In all likelihood, these items were supplied to you by your Web Host. If you don’t have this information, then you will need to contact them before you can continue. If you’re all ready…'); ?></p> |
|
173 | 173 | |
174 | -<p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p> |
|
174 | +<p class="step"><a href="<?php echo $step_1; ?>" class="button button-large"><?php _e('Let’s go!'); ?></a></p> |
|
175 | 175 | <?php |
176 | 176 | break; |
177 | 177 | |
178 | 178 | case 1: |
179 | - load_default_textdomain( $language ); |
|
179 | + load_default_textdomain($language); |
|
180 | 180 | $GLOBALS['wp_locale'] = new WP_Locale(); |
181 | 181 | |
182 | 182 | setup_config_display_header(); |
183 | 183 | ?> |
184 | -<h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ) ?></h1> |
|
184 | +<h1 class="screen-reader-text"><?php _e('Set up your database connection') ?></h1> |
|
185 | 185 | <form method="post" action="setup-config.php?step=2"> |
186 | - <p><?php _e( 'Below you should enter your database connection details. If you’re not sure about these, contact your host.' ); ?></p> |
|
186 | + <p><?php _e('Below you should enter your database connection details. If you’re not sure about these, contact your host.'); ?></p> |
|
187 | 187 | <table class="form-table"> |
188 | 188 | <tr> |
189 | - <th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th> |
|
189 | + <th scope="row"><label for="dbname"><?php _e('Database Name'); ?></label></th> |
|
190 | 190 | <td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td> |
191 | - <td><?php _e( 'The name of the database you want to use with WordPress.' ); ?></td> |
|
191 | + <td><?php _e('The name of the database you want to use with WordPress.'); ?></td> |
|
192 | 192 | </tr> |
193 | 193 | <tr> |
194 | - <th scope="row"><label for="uname"><?php _e( 'Username' ); ?></label></th> |
|
195 | - <td><input name="uname" id="uname" type="text" size="25" value="<?php echo htmlspecialchars( _x( 'username', 'example username' ), ENT_QUOTES ); ?>" /></td> |
|
196 | - <td><?php _e( 'Your database username.' ); ?></td> |
|
194 | + <th scope="row"><label for="uname"><?php _e('Username'); ?></label></th> |
|
195 | + <td><input name="uname" id="uname" type="text" size="25" value="<?php echo htmlspecialchars(_x('username', 'example username'), ENT_QUOTES); ?>" /></td> |
|
196 | + <td><?php _e('Your database username.'); ?></td> |
|
197 | 197 | </tr> |
198 | 198 | <tr> |
199 | - <th scope="row"><label for="pwd"><?php _e( 'Password' ); ?></label></th> |
|
200 | - <td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo htmlspecialchars( _x( 'password', 'example password' ), ENT_QUOTES ); ?>" autocomplete="off" /></td> |
|
201 | - <td><?php _e( 'Your database password.' ); ?></td> |
|
199 | + <th scope="row"><label for="pwd"><?php _e('Password'); ?></label></th> |
|
200 | + <td><input name="pwd" id="pwd" type="text" size="25" value="<?php echo htmlspecialchars(_x('password', 'example password'), ENT_QUOTES); ?>" autocomplete="off" /></td> |
|
201 | + <td><?php _e('Your database password.'); ?></td> |
|
202 | 202 | </tr> |
203 | 203 | <tr> |
204 | - <th scope="row"><label for="dbhost"><?php _e( 'Database Host' ); ?></label></th> |
|
204 | + <th scope="row"><label for="dbhost"><?php _e('Database Host'); ?></label></th> |
|
205 | 205 | <td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td> |
206 | 206 | <td><?php |
207 | 207 | /* translators: %s: localhost */ |
208 | - printf( __( 'You should be able to get this info from your web host, if %s doesn’t work.' ),'<code>localhost</code>' ); |
|
208 | + printf(__('You should be able to get this info from your web host, if %s doesn’t work.'), '<code>localhost</code>'); |
|
209 | 209 | ?></td> |
210 | 210 | </tr> |
211 | 211 | <tr> |
212 | - <th scope="row"><label for="prefix"><?php _e( 'Table Prefix' ); ?></label></th> |
|
212 | + <th scope="row"><label for="prefix"><?php _e('Table Prefix'); ?></label></th> |
|
213 | 213 | <td><input name="prefix" id="prefix" type="text" value="wp_" size="25" /></td> |
214 | - <td><?php _e( 'If you want to run multiple WordPress installations in a single database, change this.' ); ?></td> |
|
214 | + <td><?php _e('If you want to run multiple WordPress installations in a single database, change this.'); ?></td> |
|
215 | 215 | </tr> |
216 | 216 | </table> |
217 | - <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> |
|
218 | - <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" /> |
|
219 | - <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p> |
|
217 | + <?php if (isset($_GET['noapi'])) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> |
|
218 | + <input type="hidden" name="language" value="<?php echo esc_attr($language); ?>" /> |
|
219 | + <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars(__('Submit'), ENT_QUOTES); ?>" class="button button-large" /></p> |
|
220 | 220 | </form> |
221 | 221 | <?php |
222 | 222 | break; |
223 | 223 | |
224 | 224 | case 2: |
225 | - load_default_textdomain( $language ); |
|
225 | + load_default_textdomain($language); |
|
226 | 226 | $GLOBALS['wp_locale'] = new WP_Locale(); |
227 | 227 | |
228 | - $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) ); |
|
229 | - $uname = trim( wp_unslash( $_POST[ 'uname' ] ) ); |
|
230 | - $pwd = trim( wp_unslash( $_POST[ 'pwd' ] ) ); |
|
231 | - $dbhost = trim( wp_unslash( $_POST[ 'dbhost' ] ) ); |
|
232 | - $prefix = trim( wp_unslash( $_POST[ 'prefix' ] ) ); |
|
228 | + $dbname = trim(wp_unslash($_POST['dbname'])); |
|
229 | + $uname = trim(wp_unslash($_POST['uname'])); |
|
230 | + $pwd = trim(wp_unslash($_POST['pwd'])); |
|
231 | + $dbhost = trim(wp_unslash($_POST['dbhost'])); |
|
232 | + $prefix = trim(wp_unslash($_POST['prefix'])); |
|
233 | 233 | |
234 | 234 | $step_1 = 'setup-config.php?step=1'; |
235 | 235 | $install = 'install.php'; |
236 | - if ( isset( $_REQUEST['noapi'] ) ) { |
|
236 | + if (isset($_REQUEST['noapi'])) { |
|
237 | 237 | $step_1 .= '&noapi'; |
238 | 238 | } |
239 | 239 | |
240 | - if ( ! empty( $language ) ) { |
|
241 | - $step_1 .= '&language=' . $language; |
|
242 | - $install .= '?language=' . $language; |
|
240 | + if ( ! empty($language)) { |
|
241 | + $step_1 .= '&language='.$language; |
|
242 | + $install .= '?language='.$language; |
|
243 | 243 | } else { |
244 | 244 | $install .= '?language=en_US'; |
245 | 245 | } |
246 | 246 | |
247 | - $tryagain_link = '</p><p class="step"><a href="' . $step_1 . '" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>'; |
|
247 | + $tryagain_link = '</p><p class="step"><a href="'.$step_1.'" onclick="javascript:history.go(-1);return false;" class="button button-large">'.__('Try again').'</a>'; |
|
248 | 248 | |
249 | - if ( empty( $prefix ) ) |
|
250 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) ); |
|
249 | + if (empty($prefix)) |
|
250 | + wp_die(__('<strong>ERROR</strong>: "Table Prefix" must not be empty.'.$tryagain_link)); |
|
251 | 251 | |
252 | 252 | // Validate $prefix: it can only contain letters, numbers and underscores. |
253 | - if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) |
|
254 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) ); |
|
253 | + if (preg_match('|[^a-z0-9_]|i', $prefix)) |
|
254 | + wp_die(__('<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.'.$tryagain_link)); |
|
255 | 255 | |
256 | 256 | // Test the db connection. |
257 | 257 | /**#@+ |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | /**#@-*/ |
265 | 265 | |
266 | 266 | // Re-construct $wpdb with these new values. |
267 | - unset( $wpdb ); |
|
267 | + unset($wpdb); |
|
268 | 268 | require_wp_db(); |
269 | 269 | |
270 | 270 | /* |
@@ -273,69 +273,69 @@ discard block |
||
273 | 273 | */ |
274 | 274 | $wpdb->db_connect(); |
275 | 275 | |
276 | - if ( ! empty( $wpdb->error ) ) |
|
277 | - wp_die( $wpdb->error->get_error_message() . $tryagain_link ); |
|
276 | + if ( ! empty($wpdb->error)) |
|
277 | + wp_die($wpdb->error->get_error_message().$tryagain_link); |
|
278 | 278 | |
279 | - $wpdb->query( "SELECT $prefix" ); |
|
280 | - if ( ! $wpdb->last_error ) { |
|
279 | + $wpdb->query("SELECT $prefix"); |
|
280 | + if ( ! $wpdb->last_error) { |
|
281 | 281 | // MySQL was able to parse the prefix as a value, which we don't want. Bail. |
282 | - wp_die( __( '<strong>ERROR</strong>: "Table Prefix" is invalid.' ) ); |
|
282 | + wp_die(__('<strong>ERROR</strong>: "Table Prefix" is invalid.')); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // Generate keys and salts using secure CSPRNG; fallback to API if enabled; further fallback to original wp_generate_password(). |
286 | 286 | try { |
287 | 287 | $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; |
288 | 288 | $max = strlen($chars) - 1; |
289 | - for ( $i = 0; $i < 8; $i++ ) { |
|
289 | + for ($i = 0; $i < 8; $i++) { |
|
290 | 290 | $key = ''; |
291 | - for ( $j = 0; $j < 64; $j++ ) { |
|
292 | - $key .= substr( $chars, random_int( 0, $max ), 1 ); |
|
291 | + for ($j = 0; $j < 64; $j++) { |
|
292 | + $key .= substr($chars, random_int(0, $max), 1); |
|
293 | 293 | } |
294 | 294 | $secret_keys[] = $key; |
295 | 295 | } |
296 | - } catch ( Exception $ex ) { |
|
297 | - $no_api = isset( $_POST['noapi'] ); |
|
296 | + } catch (Exception $ex) { |
|
297 | + $no_api = isset($_POST['noapi']); |
|
298 | 298 | |
299 | - if ( ! $no_api ) { |
|
300 | - $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); |
|
299 | + if ( ! $no_api) { |
|
300 | + $secret_keys = wp_remote_get('https://api.wordpress.org/secret-key/1.1/salt/'); |
|
301 | 301 | } |
302 | 302 | |
303 | - if ( $no_api || is_wp_error( $secret_keys ) ) { |
|
303 | + if ($no_api || is_wp_error($secret_keys)) { |
|
304 | 304 | $secret_keys = array(); |
305 | - for ( $i = 0; $i < 8; $i++ ) { |
|
306 | - $secret_keys[] = wp_generate_password( 64, true, true ); |
|
305 | + for ($i = 0; $i < 8; $i++) { |
|
306 | + $secret_keys[] = wp_generate_password(64, true, true); |
|
307 | 307 | } |
308 | 308 | } else { |
309 | - $secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) ); |
|
310 | - foreach ( $secret_keys as $k => $v ) { |
|
311 | - $secret_keys[$k] = substr( $v, 28, 64 ); |
|
309 | + $secret_keys = explode("\n", wp_remote_retrieve_body($secret_keys)); |
|
310 | + foreach ($secret_keys as $k => $v) { |
|
311 | + $secret_keys[$k] = substr($v, 28, 64); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | 316 | $key = 0; |
317 | - foreach ( $config_file as $line_num => $line ) { |
|
318 | - if ( '$table_prefix =' == substr( $line, 0, 16 ) ) { |
|
319 | - $config_file[ $line_num ] = '$table_prefix = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n"; |
|
317 | + foreach ($config_file as $line_num => $line) { |
|
318 | + if ('$table_prefix =' == substr($line, 0, 16)) { |
|
319 | + $config_file[$line_num] = '$table_prefix = \''.addcslashes($prefix, "\\'")."';\r\n"; |
|
320 | 320 | continue; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) |
|
323 | + if ( ! preg_match('/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match)) |
|
324 | 324 | continue; |
325 | 325 | |
326 | 326 | $constant = $match[1]; |
327 | 327 | $padding = $match[2]; |
328 | 328 | |
329 | - switch ( $constant ) { |
|
329 | + switch ($constant) { |
|
330 | 330 | case 'DB_NAME' : |
331 | 331 | case 'DB_USER' : |
332 | 332 | case 'DB_PASSWORD' : |
333 | 333 | case 'DB_HOST' : |
334 | - $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n"; |
|
334 | + $config_file[$line_num] = "define('".$constant."',".$padding."'".addcslashes(constant($constant), "\\'")."');\r\n"; |
|
335 | 335 | break; |
336 | 336 | case 'DB_CHARSET' : |
337 | - if ( 'utf8mb4' === $wpdb->charset || ( ! $wpdb->charset && $wpdb->has_cap( 'utf8mb4' ) ) ) { |
|
338 | - $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'utf8mb4');\r\n"; |
|
337 | + if ('utf8mb4' === $wpdb->charset || ( ! $wpdb->charset && $wpdb->has_cap('utf8mb4'))) { |
|
338 | + $config_file[$line_num] = "define('".$constant."',".$padding."'utf8mb4');\r\n"; |
|
339 | 339 | } |
340 | 340 | break; |
341 | 341 | case 'AUTH_KEY' : |
@@ -346,30 +346,30 @@ discard block |
||
346 | 346 | case 'SECURE_AUTH_SALT' : |
347 | 347 | case 'LOGGED_IN_SALT' : |
348 | 348 | case 'NONCE_SALT' : |
349 | - $config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n"; |
|
349 | + $config_file[$line_num] = "define('".$constant."',".$padding."'".$secret_keys[$key++]."');\r\n"; |
|
350 | 350 | break; |
351 | 351 | } |
352 | 352 | } |
353 | - unset( $line ); |
|
353 | + unset($line); |
|
354 | 354 | |
355 | - if ( ! is_writable(ABSPATH) ) : |
|
355 | + if ( ! is_writable(ABSPATH)) : |
|
356 | 356 | setup_config_display_header(); |
357 | 357 | ?> |
358 | 358 | <p><?php |
359 | 359 | /* translators: %s: wp-config.php */ |
360 | - printf( __( 'Sorry, but I can’t write the %s file.' ), '<code>wp-config.php</code>' ); |
|
360 | + printf(__('Sorry, but I can’t write the %s file.'), '<code>wp-config.php</code>'); |
|
361 | 361 | ?></p> |
362 | 362 | <p><?php |
363 | 363 | /* translators: %s: wp-config.php */ |
364 | - printf( __( 'You can create the %s manually and paste the following text into it.' ), '<code>wp-config.php</code>' ); |
|
364 | + printf(__('You can create the %s manually and paste the following text into it.'), '<code>wp-config.php</code>'); |
|
365 | 365 | ?></p> |
366 | 366 | <textarea id="wp-config" cols="98" rows="15" class="code" readonly="readonly"><?php |
367 | - foreach ( $config_file as $line ) { |
|
367 | + foreach ($config_file as $line) { |
|
368 | 368 | echo htmlentities($line, ENT_COMPAT, 'UTF-8'); |
369 | 369 | } |
370 | 370 | ?></textarea> |
371 | -<p><?php _e( 'After you’ve done that, click “Run the install.”' ); ?></p> |
|
372 | -<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the install' ); ?></a></p> |
|
371 | +<p><?php _e('After you’ve done that, click “Run the install.”'); ?></p> |
|
372 | +<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e('Run the install'); ?></a></p> |
|
373 | 373 | <script> |
374 | 374 | (function(){ |
375 | 375 | if ( ! /iPad|iPod|iPhone/.test( navigator.userAgent ) ) { |
@@ -385,28 +385,28 @@ discard block |
||
385 | 385 | * If this file doesn't exist, then we are using the wp-config-sample.php |
386 | 386 | * file one level up, which is for the develop repo. |
387 | 387 | */ |
388 | - if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) |
|
389 | - $path_to_wp_config = ABSPATH . 'wp-config.php'; |
|
388 | + if (file_exists(ABSPATH.'wp-config-sample.php')) |
|
389 | + $path_to_wp_config = ABSPATH.'wp-config.php'; |
|
390 | 390 | else |
391 | - $path_to_wp_config = dirname( ABSPATH ) . '/wp-config.php'; |
|
391 | + $path_to_wp_config = dirname(ABSPATH).'/wp-config.php'; |
|
392 | 392 | |
393 | - $handle = fopen( $path_to_wp_config, 'w' ); |
|
394 | - foreach ( $config_file as $line ) { |
|
395 | - fwrite( $handle, $line ); |
|
393 | + $handle = fopen($path_to_wp_config, 'w'); |
|
394 | + foreach ($config_file as $line) { |
|
395 | + fwrite($handle, $line); |
|
396 | 396 | } |
397 | - fclose( $handle ); |
|
398 | - chmod( $path_to_wp_config, 0666 ); |
|
397 | + fclose($handle); |
|
398 | + chmod($path_to_wp_config, 0666); |
|
399 | 399 | setup_config_display_header(); |
400 | 400 | ?> |
401 | -<h1 class="screen-reader-text"><?php _e( 'Successful database connection' ) ?></h1> |
|
402 | -<p><?php _e( 'All right, sparky! You’ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…' ); ?></p> |
|
401 | +<h1 class="screen-reader-text"><?php _e('Successful database connection') ?></h1> |
|
402 | +<p><?php _e('All right, sparky! You’ve made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…'); ?></p> |
|
403 | 403 | |
404 | -<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e( 'Run the install' ); ?></a></p> |
|
404 | +<p class="step"><a href="<?php echo $install; ?>" class="button button-large"><?php _e('Run the install'); ?></a></p> |
|
405 | 405 | <?php |
406 | 406 | endif; |
407 | 407 | break; |
408 | 408 | } |
409 | 409 | ?> |
410 | -<?php wp_print_scripts( 'language-chooser' ); ?> |
|
410 | +<?php wp_print_scripts('language-chooser'); ?> |
|
411 | 411 | </body> |
412 | 412 | </html> |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | /** Load WordPress Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( !current_user_can('export') ) |
|
12 | +if ( !current_user_can('export') ) { |
|
13 | 13 | wp_die(__('You do not have sufficient permissions to export the content of this site.')); |
14 | +} |
|
14 | 15 | |
15 | 16 | /** Load WordPress export API */ |
16 | 17 | require_once( ABSPATH . 'wp-admin/includes/export.php' ); |
@@ -64,32 +65,37 @@ discard block |
||
64 | 65 | } elseif ( 'posts' == $_GET['content'] ) { |
65 | 66 | $args['content'] = 'post'; |
66 | 67 | |
67 | - if ( $_GET['cat'] ) |
|
68 | - $args['category'] = (int) $_GET['cat']; |
|
68 | + if ( $_GET['cat'] ) { |
|
69 | + $args['category'] = (int) $_GET['cat']; |
|
70 | + } |
|
69 | 71 | |
70 | - if ( $_GET['post_author'] ) |
|
71 | - $args['author'] = (int) $_GET['post_author']; |
|
72 | + if ( $_GET['post_author'] ) { |
|
73 | + $args['author'] = (int) $_GET['post_author']; |
|
74 | + } |
|
72 | 75 | |
73 | 76 | if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { |
74 | 77 | $args['start_date'] = $_GET['post_start_date']; |
75 | 78 | $args['end_date'] = $_GET['post_end_date']; |
76 | 79 | } |
77 | 80 | |
78 | - if ( $_GET['post_status'] ) |
|
79 | - $args['status'] = $_GET['post_status']; |
|
81 | + if ( $_GET['post_status'] ) { |
|
82 | + $args['status'] = $_GET['post_status']; |
|
83 | + } |
|
80 | 84 | } elseif ( 'pages' == $_GET['content'] ) { |
81 | 85 | $args['content'] = 'page'; |
82 | 86 | |
83 | - if ( $_GET['page_author'] ) |
|
84 | - $args['author'] = (int) $_GET['page_author']; |
|
87 | + if ( $_GET['page_author'] ) { |
|
88 | + $args['author'] = (int) $_GET['page_author']; |
|
89 | + } |
|
85 | 90 | |
86 | 91 | if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { |
87 | 92 | $args['start_date'] = $_GET['page_start_date']; |
88 | 93 | $args['end_date'] = $_GET['page_end_date']; |
89 | 94 | } |
90 | 95 | |
91 | - if ( $_GET['page_status'] ) |
|
92 | - $args['status'] = $_GET['page_status']; |
|
96 | + if ( $_GET['page_status'] ) { |
|
97 | + $args['status'] = $_GET['page_status']; |
|
98 | + } |
|
93 | 99 | } elseif ( 'attachment' == $_GET['content'] ) { |
94 | 100 | $args['content'] = 'attachment'; |
95 | 101 | |
@@ -97,8 +103,7 @@ discard block |
||
97 | 103 | $args['start_date'] = $_GET['attachment_start_date']; |
98 | 104 | $args['end_date'] = $_GET['attachment_end_date']; |
99 | 105 | } |
100 | - } |
|
101 | - else { |
|
106 | + } else { |
|
102 | 107 | $args['content'] = $_GET['content']; |
103 | 108 | } |
104 | 109 | |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | ", $post_type ) ); |
139 | 144 | |
140 | 145 | $month_count = count( $months ); |
141 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
142 | - return; |
|
146 | + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
|
147 | + return; |
|
148 | + } |
|
143 | 149 | |
144 | 150 | foreach ( $months as $date ) { |
145 | - if ( 0 == $date->year ) |
|
146 | - continue; |
|
151 | + if ( 0 == $date->year ) { |
|
152 | + continue; |
|
153 | + } |
|
147 | 154 | |
148 | 155 | $month = zeroise( $date->month, 2 ); |
149 | 156 | echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>'; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** Load WordPress Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( !current_user_can('export') ) |
|
12 | +if ( ! current_user_can('export')) |
|
13 | 13 | wp_die(__('Sorry, you are not allowed to export the content of this site.')); |
14 | 14 | |
15 | 15 | /** Load WordPress export API */ |
16 | -require_once( ABSPATH . 'wp-admin/includes/export.php' ); |
|
16 | +require_once(ABSPATH.'wp-admin/includes/export.php'); |
|
17 | 17 | $title = __('Export'); |
18 | 18 | |
19 | 19 | /** |
@@ -40,60 +40,60 @@ discard block |
||
40 | 40 | </script> |
41 | 41 | <?php |
42 | 42 | } |
43 | -add_action( 'admin_head', 'export_add_js' ); |
|
43 | +add_action('admin_head', 'export_add_js'); |
|
44 | 44 | |
45 | -get_current_screen()->add_help_tab( array( |
|
45 | +get_current_screen()->add_help_tab(array( |
|
46 | 46 | 'id' => 'overview', |
47 | 47 | 'title' => __('Overview'), |
48 | - 'content' => '<p>' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '</p>' . |
|
49 | - '<p>' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '</p>', |
|
50 | -) ); |
|
48 | + 'content' => '<p>'.__('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.').'</p>'. |
|
49 | + '<p>'.__('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.').'</p>', |
|
50 | +)); |
|
51 | 51 | |
52 | 52 | get_current_screen()->set_help_sidebar( |
53 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
54 | - '<p>' . __('<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>') . '</p>' . |
|
55 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
53 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
54 | + '<p>'.__('<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>').'</p>'. |
|
55 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | // If the 'download' URL parameter is set, a WXR export file is baked and returned. |
59 | -if ( isset( $_GET['download'] ) ) { |
|
59 | +if (isset($_GET['download'])) { |
|
60 | 60 | $args = array(); |
61 | 61 | |
62 | - if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { |
|
62 | + if ( ! isset($_GET['content']) || 'all' == $_GET['content']) { |
|
63 | 63 | $args['content'] = 'all'; |
64 | - } elseif ( 'posts' == $_GET['content'] ) { |
|
64 | + } elseif ('posts' == $_GET['content']) { |
|
65 | 65 | $args['content'] = 'post'; |
66 | 66 | |
67 | - if ( $_GET['cat'] ) |
|
67 | + if ($_GET['cat']) |
|
68 | 68 | $args['category'] = (int) $_GET['cat']; |
69 | 69 | |
70 | - if ( $_GET['post_author'] ) |
|
70 | + if ($_GET['post_author']) |
|
71 | 71 | $args['author'] = (int) $_GET['post_author']; |
72 | 72 | |
73 | - if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { |
|
73 | + if ($_GET['post_start_date'] || $_GET['post_end_date']) { |
|
74 | 74 | $args['start_date'] = $_GET['post_start_date']; |
75 | 75 | $args['end_date'] = $_GET['post_end_date']; |
76 | 76 | } |
77 | 77 | |
78 | - if ( $_GET['post_status'] ) |
|
78 | + if ($_GET['post_status']) |
|
79 | 79 | $args['status'] = $_GET['post_status']; |
80 | - } elseif ( 'pages' == $_GET['content'] ) { |
|
80 | + } elseif ('pages' == $_GET['content']) { |
|
81 | 81 | $args['content'] = 'page'; |
82 | 82 | |
83 | - if ( $_GET['page_author'] ) |
|
83 | + if ($_GET['page_author']) |
|
84 | 84 | $args['author'] = (int) $_GET['page_author']; |
85 | 85 | |
86 | - if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { |
|
86 | + if ($_GET['page_start_date'] || $_GET['page_end_date']) { |
|
87 | 87 | $args['start_date'] = $_GET['page_start_date']; |
88 | 88 | $args['end_date'] = $_GET['page_end_date']; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $_GET['page_status'] ) |
|
91 | + if ($_GET['page_status']) |
|
92 | 92 | $args['status'] = $_GET['page_status']; |
93 | - } elseif ( 'attachment' == $_GET['content'] ) { |
|
93 | + } elseif ('attachment' == $_GET['content']) { |
|
94 | 94 | $args['content'] = 'attachment'; |
95 | 95 | |
96 | - if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { |
|
96 | + if ($_GET['attachment_start_date'] || $_GET['attachment_end_date']) { |
|
97 | 97 | $args['start_date'] = $_GET['attachment_start_date']; |
98 | 98 | $args['end_date'] = $_GET['attachment_end_date']; |
99 | 99 | } |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param array $args The arguments to send to the exporter. |
111 | 111 | */ |
112 | - $args = apply_filters( 'export_args', $args ); |
|
112 | + $args = apply_filters('export_args', $args); |
|
113 | 113 | |
114 | - export_wp( $args ); |
|
114 | + export_wp($args); |
|
115 | 115 | die(); |
116 | 116 | } |
117 | 117 | |
118 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
118 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Create the date options fields for exporting a given post type. |
@@ -127,151 +127,151 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @param string $post_type The post type. Default 'post'. |
129 | 129 | */ |
130 | -function export_date_options( $post_type = 'post' ) { |
|
130 | +function export_date_options($post_type = 'post') { |
|
131 | 131 | global $wpdb, $wp_locale; |
132 | 132 | |
133 | - $months = $wpdb->get_results( $wpdb->prepare( " |
|
133 | + $months = $wpdb->get_results($wpdb->prepare(" |
|
134 | 134 | SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
135 | 135 | FROM $wpdb->posts |
136 | 136 | WHERE post_type = %s AND post_status != 'auto-draft' |
137 | 137 | ORDER BY post_date DESC |
138 | - ", $post_type ) ); |
|
138 | + ", $post_type)); |
|
139 | 139 | |
140 | - $month_count = count( $months ); |
|
141 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
140 | + $month_count = count($months); |
|
141 | + if ( ! $month_count || (1 == $month_count && 0 == $months[0]->month)) |
|
142 | 142 | return; |
143 | 143 | |
144 | - foreach ( $months as $date ) { |
|
145 | - if ( 0 == $date->year ) |
|
144 | + foreach ($months as $date) { |
|
145 | + if (0 == $date->year) |
|
146 | 146 | continue; |
147 | 147 | |
148 | - $month = zeroise( $date->month, 2 ); |
|
149 | - echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>'; |
|
148 | + $month = zeroise($date->month, 2); |
|
149 | + echo '<option value="'.$date->year.'-'.$month.'">'.$wp_locale->get_month($month).' '.$date->year.'</option>'; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | ?> |
153 | 153 | |
154 | 154 | <div class="wrap"> |
155 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
155 | +<h1><?php echo esc_html($title); ?></h1> |
|
156 | 156 | |
157 | 157 | <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p> |
158 | 158 | <p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p> |
159 | 159 | <p><?php _e('Once you’ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p> |
160 | 160 | |
161 | -<h2><?php _e( 'Choose what to export' ); ?></h2> |
|
161 | +<h2><?php _e('Choose what to export'); ?></h2> |
|
162 | 162 | <form method="get" id="export-filters"> |
163 | 163 | <fieldset> |
164 | -<legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend> |
|
164 | +<legend class="screen-reader-text"><?php _e('Content to export'); ?></legend> |
|
165 | 165 | <input type="hidden" name="download" value="true" /> |
166 | -<p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p> |
|
167 | -<p class="description" id="all-content-desc"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.' ); ?></p> |
|
166 | +<p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e('All content'); ?></label></p> |
|
167 | +<p class="description" id="all-content-desc"><?php _e('This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.'); ?></p> |
|
168 | 168 | |
169 | -<p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p> |
|
169 | +<p><label><input type="radio" name="content" value="posts" /> <?php _e('Posts'); ?></label></p> |
|
170 | 170 | <ul id="post-filters" class="export-filters"> |
171 | 171 | <li> |
172 | - <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> |
|
173 | - <?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?> |
|
172 | + <label><span class="label-responsive"><?php _e('Categories:'); ?></span> |
|
173 | + <?php wp_dropdown_categories(array('show_option_all' => __('All'))); ?> |
|
174 | 174 | </label> |
175 | 175 | </li> |
176 | 176 | <li> |
177 | - <label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span> |
|
177 | + <label><span class="label-responsive"><?php _e('Authors:'); ?></span> |
|
178 | 178 | <?php |
179 | - $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" ); |
|
180 | - wp_dropdown_users( array( |
|
179 | + $authors = $wpdb->get_col("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'"); |
|
180 | + wp_dropdown_users(array( |
|
181 | 181 | 'include' => $authors, |
182 | 182 | 'name' => 'post_author', |
183 | 183 | 'multi' => true, |
184 | - 'show_option_all' => __( 'All' ), |
|
184 | + 'show_option_all' => __('All'), |
|
185 | 185 | 'show' => 'display_name_with_login', |
186 | - ) ); ?> |
|
186 | + )); ?> |
|
187 | 187 | </label> |
188 | 188 | </li> |
189 | 189 | <li> |
190 | 190 | <fieldset> |
191 | - <legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend> |
|
192 | - <label for="post-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label> |
|
191 | + <legend class="screen-reader-text"><?php _e('Date range:'); ?></legend> |
|
192 | + <label for="post-start-date" class="label-responsive"><?php _e('Start date:'); ?></label> |
|
193 | 193 | <select name="post_start_date" id="post-start-date"> |
194 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
194 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
195 | 195 | <?php export_date_options(); ?> |
196 | 196 | </select> |
197 | - <label for="post-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label> |
|
197 | + <label for="post-end-date" class="label-responsive"><?php _e('End date:'); ?></label> |
|
198 | 198 | <select name="post_end_date" id="post-end-date"> |
199 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
199 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
200 | 200 | <?php export_date_options(); ?> |
201 | 201 | </select> |
202 | 202 | </fieldset> |
203 | 203 | </li> |
204 | 204 | <li> |
205 | - <label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label> |
|
205 | + <label for="post-status" class="label-responsive"><?php _e('Status:'); ?></label> |
|
206 | 206 | <select name="post_status" id="post-status"> |
207 | - <option value="0"><?php _e( 'All' ); ?></option> |
|
208 | - <?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' ); |
|
209 | - foreach ( $post_stati as $status ) : ?> |
|
210 | - <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option> |
|
207 | + <option value="0"><?php _e('All'); ?></option> |
|
208 | + <?php $post_stati = get_post_stati(array('internal' => false), 'objects'); |
|
209 | + foreach ($post_stati as $status) : ?> |
|
210 | + <option value="<?php echo esc_attr($status->name); ?>"><?php echo esc_html($status->label); ?></option> |
|
211 | 211 | <?php endforeach; ?> |
212 | 212 | </select> |
213 | 213 | </li> |
214 | 214 | </ul> |
215 | 215 | |
216 | -<p><label><input type="radio" name="content" value="pages" /> <?php _e( 'Pages' ); ?></label></p> |
|
216 | +<p><label><input type="radio" name="content" value="pages" /> <?php _e('Pages'); ?></label></p> |
|
217 | 217 | <ul id="page-filters" class="export-filters"> |
218 | 218 | <li> |
219 | - <label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span> |
|
219 | + <label><span class="label-responsive"><?php _e('Authors:'); ?></span> |
|
220 | 220 | <?php |
221 | - $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" ); |
|
222 | - wp_dropdown_users( array( |
|
221 | + $authors = $wpdb->get_col("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'"); |
|
222 | + wp_dropdown_users(array( |
|
223 | 223 | 'include' => $authors, |
224 | 224 | 'name' => 'page_author', |
225 | 225 | 'multi' => true, |
226 | - 'show_option_all' => __( 'All' ), |
|
226 | + 'show_option_all' => __('All'), |
|
227 | 227 | 'show' => 'display_name_with_login', |
228 | - ) ); ?> |
|
228 | + )); ?> |
|
229 | 229 | </label> |
230 | 230 | </li> |
231 | 231 | <li> |
232 | 232 | <fieldset> |
233 | - <legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend> |
|
234 | - <label for="page-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label> |
|
233 | + <legend class="screen-reader-text"><?php _e('Date range:'); ?></legend> |
|
234 | + <label for="page-start-date" class="label-responsive"><?php _e('Start date:'); ?></label> |
|
235 | 235 | <select name="page_start_date" id="page-start-date"> |
236 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
237 | - <?php export_date_options( 'page' ); ?> |
|
236 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
237 | + <?php export_date_options('page'); ?> |
|
238 | 238 | </select> |
239 | - <label for="page-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label> |
|
239 | + <label for="page-end-date" class="label-responsive"><?php _e('End date:'); ?></label> |
|
240 | 240 | <select name="page_end_date" id="page-end-date"> |
241 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
242 | - <?php export_date_options( 'page' ); ?> |
|
241 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
242 | + <?php export_date_options('page'); ?> |
|
243 | 243 | </select> |
244 | 244 | </fieldset> |
245 | 245 | </li> |
246 | 246 | <li> |
247 | - <label for="page-status" class="label-responsive"><?php _e( 'Status:' ); ?></label> |
|
247 | + <label for="page-status" class="label-responsive"><?php _e('Status:'); ?></label> |
|
248 | 248 | <select name="page_status" id="page-status"> |
249 | - <option value="0"><?php _e( 'All' ); ?></option> |
|
250 | - <?php foreach ( $post_stati as $status ) : ?> |
|
251 | - <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option> |
|
249 | + <option value="0"><?php _e('All'); ?></option> |
|
250 | + <?php foreach ($post_stati as $status) : ?> |
|
251 | + <option value="<?php echo esc_attr($status->name); ?>"><?php echo esc_html($status->label); ?></option> |
|
252 | 252 | <?php endforeach; ?> |
253 | 253 | </select> |
254 | 254 | </li> |
255 | 255 | </ul> |
256 | 256 | |
257 | -<?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> |
|
258 | -<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p> |
|
257 | +<?php foreach (get_post_types(array('_builtin' => false, 'can_export' => true), 'objects') as $post_type) : ?> |
|
258 | +<p><label><input type="radio" name="content" value="<?php echo esc_attr($post_type->name); ?>" /> <?php echo esc_html($post_type->label); ?></label></p> |
|
259 | 259 | <?php endforeach; ?> |
260 | 260 | |
261 | -<p><label><input type="radio" name="content" value="attachment" /> <?php _e( 'Media' ); ?></label></p> |
|
261 | +<p><label><input type="radio" name="content" value="attachment" /> <?php _e('Media'); ?></label></p> |
|
262 | 262 | <ul id="attachment-filters" class="export-filters"> |
263 | 263 | <li> |
264 | 264 | <fieldset> |
265 | - <legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend> |
|
266 | - <label for="attachment-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label> |
|
265 | + <legend class="screen-reader-text"><?php _e('Date range:'); ?></legend> |
|
266 | + <label for="attachment-start-date" class="label-responsive"><?php _e('Start date:'); ?></label> |
|
267 | 267 | <select name="attachment_start_date" id="attachment-start-date"> |
268 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
269 | - <?php export_date_options( 'attachment' ); ?> |
|
268 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
269 | + <?php export_date_options('attachment'); ?> |
|
270 | 270 | </select> |
271 | - <label for="attachment-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label> |
|
271 | + <label for="attachment-end-date" class="label-responsive"><?php _e('End date:'); ?></label> |
|
272 | 272 | <select name="attachment_end_date" id="attachment-end-date"> |
273 | - <option value="0"><?php _e( '— Select —' ); ?></option> |
|
274 | - <?php export_date_options( 'attachment' ); ?> |
|
273 | + <option value="0"><?php _e('— Select —'); ?></option> |
|
274 | + <?php export_date_options('attachment'); ?> |
|
275 | 275 | </select> |
276 | 276 | </fieldset> |
277 | 277 | </li> |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @since 3.5.0 |
286 | 286 | */ |
287 | -do_action( 'export_filters' ); |
|
287 | +do_action('export_filters'); |
|
288 | 288 | ?> |
289 | 289 | |
290 | -<?php submit_button( __('Download Export File') ); ?> |
|
290 | +<?php submit_button(__('Download Export File')); ?> |
|
291 | 291 | </form> |
292 | 292 | </div> |
293 | 293 | |
294 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
294 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -13,28 +13,32 @@ discard block |
||
13 | 13 | |
14 | 14 | $user_id = (int) $user_id; |
15 | 15 | $current_user = wp_get_current_user(); |
16 | -if ( ! defined( 'IS_PROFILE_PAGE' ) ) |
|
16 | +if ( ! defined( 'IS_PROFILE_PAGE' ) ) { |
|
17 | 17 | define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); |
18 | +} |
|
18 | 19 | |
19 | -if ( ! $user_id && IS_PROFILE_PAGE ) |
|
20 | +if ( ! $user_id && IS_PROFILE_PAGE ) { |
|
20 | 21 | $user_id = $current_user->ID; |
21 | -elseif ( ! $user_id && ! IS_PROFILE_PAGE ) |
|
22 | +} elseif ( ! $user_id && ! IS_PROFILE_PAGE ) { |
|
22 | 23 | wp_die(__( 'Invalid user ID.' ) ); |
23 | -elseif ( ! get_userdata( $user_id ) ) |
|
24 | +} elseif ( ! get_userdata( $user_id ) ) { |
|
24 | 25 | wp_die( __('Invalid user ID.') ); |
26 | +} |
|
25 | 27 | |
26 | 28 | wp_enqueue_script('user-profile'); |
27 | 29 | |
28 | 30 | $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User'); |
29 | -if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) |
|
31 | +if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) { |
|
30 | 32 | $submenu_file = 'users.php'; |
31 | -else |
|
33 | +} else { |
|
32 | 34 | $submenu_file = 'profile.php'; |
35 | +} |
|
33 | 36 | |
34 | -if ( current_user_can('edit_users') && !is_user_admin() ) |
|
37 | +if ( current_user_can('edit_users') && !is_user_admin() ) { |
|
35 | 38 | $parent_file = 'users.php'; |
36 | -else |
|
39 | +} else { |
|
37 | 40 | $parent_file = 'profile.php'; |
41 | +} |
|
38 | 42 | |
39 | 43 | $profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . |
40 | 44 | '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . |
@@ -108,8 +112,9 @@ discard block |
||
108 | 112 | |
109 | 113 | check_admin_referer('update-user_' . $user_id); |
110 | 114 | |
111 | -if ( !current_user_can('edit_user', $user_id) ) |
|
115 | +if ( !current_user_can('edit_user', $user_id) ) { |
|
112 | 116 | wp_die(__('You do not have permission to edit this user.')); |
117 | +} |
|
113 | 118 | |
114 | 119 | if ( IS_PROFILE_PAGE ) { |
115 | 120 | /** |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | |
153 | 158 | if ( !is_wp_error( $errors ) ) { |
154 | 159 | $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); |
155 | - if ( $wp_http_referer ) |
|
156 | - $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
|
160 | + if ( $wp_http_referer ) { |
|
161 | + $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
|
162 | + } |
|
157 | 163 | wp_redirect($redirect); |
158 | 164 | exit; |
159 | 165 | } |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | default: |
162 | 168 | $profileuser = get_user_to_edit($user_id); |
163 | 169 | |
164 | -if ( !current_user_can('edit_user', $user_id) ) |
|
170 | +if ( !current_user_can('edit_user', $user_id) ) { |
|
165 | 171 | wp_die(__('You do not have permission to edit this user.')); |
172 | +} |
|
166 | 173 | |
167 | 174 | $sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); |
168 | 175 | |
@@ -176,9 +183,12 @@ discard block |
||
176 | 183 | <div id="message" class="updated notice is-dismissible"> |
177 | 184 | <?php if ( IS_PROFILE_PAGE ) : ?> |
178 | 185 | <p><strong><?php _e('Profile updated.') ?></strong></p> |
179 | - <?php else: ?> |
|
186 | + <?php else { |
|
187 | + : ?> |
|
180 | 188 | <p><strong><?php _e('User updated.') ?></strong></p> |
181 | - <?php endif; ?> |
|
189 | + <?php endif; |
|
190 | +} |
|
191 | +?> |
|
182 | 192 | <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?> |
183 | 193 | <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p> |
184 | 194 | <?php endif; ?> |
@@ -230,7 +240,10 @@ discard block |
||
230 | 240 | <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> |
231 | 241 | <tr class="user-rich-editing-wrap"> |
232 | 242 | <th scope="row"><?php _e( 'Visual Editor' ); ?></th> |
233 | - <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
243 | + <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) { |
|
244 | + checked( 'false', $profileuser->rich_editing ); |
|
245 | +} |
|
246 | +?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
234 | 247 | </tr> |
235 | 248 | <?php endif; ?> |
236 | 249 | <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> |
@@ -256,7 +269,10 @@ discard block |
||
256 | 269 | if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> |
257 | 270 | <tr class="user-comment-shortcuts-wrap"> |
258 | 271 | <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> |
259 | -<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
272 | +<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) { |
|
273 | + checked( 'true', $profileuser->comment_shortcuts ); |
|
274 | +} |
|
275 | +?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
260 | 276 | </tr> |
261 | 277 | <?php endif; ?> |
262 | 278 | <tr class="show-admin-bar user-admin-bar-front-wrap"> |
@@ -315,10 +331,11 @@ discard block |
||
315 | 331 | wp_dropdown_roles($user_role); |
316 | 332 | |
317 | 333 | // print the 'no role' option. Make it selected if the user has no role yet. |
318 | -if ( $user_role ) |
|
334 | +if ( $user_role ) { |
|
319 | 335 | echo '<option value="">' . __('— No role for this site —') . '</option>'; |
320 | -else |
|
336 | +} else { |
|
321 | 337 | echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; |
338 | +} |
|
322 | 339 | ?> |
323 | 340 | </select></td></tr> |
324 | 341 | <?php endif; //!IS_PROFILE_PAGE |
@@ -328,8 +345,11 @@ discard block |
||
328 | 345 | <td> |
329 | 346 | <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> |
330 | 347 | <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> |
331 | -<?php else : ?> |
|
332 | -<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> |
|
348 | +<?php else { |
|
349 | + : ?> |
|
350 | +<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); |
|
351 | +} |
|
352 | +?></p> |
|
333 | 353 | <?php endif; ?> |
334 | 354 | </td></tr> |
335 | 355 | <?php } ?> |
@@ -358,19 +378,23 @@ discard block |
||
358 | 378 | $public_display['display_nickname'] = $profileuser->nickname; |
359 | 379 | $public_display['display_username'] = $profileuser->user_login; |
360 | 380 | |
361 | - if ( !empty($profileuser->first_name) ) |
|
362 | - $public_display['display_firstname'] = $profileuser->first_name; |
|
381 | + if ( !empty($profileuser->first_name) ) { |
|
382 | + $public_display['display_firstname'] = $profileuser->first_name; |
|
383 | + } |
|
363 | 384 | |
364 | - if ( !empty($profileuser->last_name) ) |
|
365 | - $public_display['display_lastname'] = $profileuser->last_name; |
|
385 | + if ( !empty($profileuser->last_name) ) { |
|
386 | + $public_display['display_lastname'] = $profileuser->last_name; |
|
387 | + } |
|
366 | 388 | |
367 | 389 | if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
368 | 390 | $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
369 | 391 | $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
370 | 392 | } |
371 | 393 | |
372 | - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere |
|
394 | + if ( !in_array( $profileuser->display_name, $public_display ) ) { |
|
395 | + // Only add this if it isn't duplicated elsewhere |
|
373 | 396 | $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; |
397 | + } |
|
374 | 398 | |
375 | 399 | $public_display = array_map( 'trim', $public_display ); |
376 | 400 | $public_display = array_unique( $public_display ); |
@@ -623,8 +647,9 @@ discard block |
||
623 | 647 | $output = ''; |
624 | 648 | foreach ( $profileuser->caps as $cap => $value ) { |
625 | 649 | if ( ! $wp_roles->is_role( $cap ) ) { |
626 | - if ( '' != $output ) |
|
627 | - $output .= ', '; |
|
650 | + if ( '' != $output ) { |
|
651 | + $output .= ', '; |
|
652 | + } |
|
628 | 653 | $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); |
629 | 654 | } |
630 | 655 | } |
@@ -51,9 +51,9 @@ |
||
51 | 51 | ) ); |
52 | 52 | |
53 | 53 | get_current_screen()->set_help_sidebar( |
54 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
55 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' . |
|
56 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
54 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
55 | + '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' . |
|
56 | + '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer ); |
@@ -7,58 +7,58 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) ); |
|
12 | +wp_reset_vars(array('action', 'user_id', 'wp_http_referer')); |
|
13 | 13 | |
14 | 14 | $user_id = (int) $user_id; |
15 | 15 | $current_user = wp_get_current_user(); |
16 | -if ( ! defined( 'IS_PROFILE_PAGE' ) ) |
|
17 | - define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); |
|
16 | +if ( ! defined('IS_PROFILE_PAGE')) |
|
17 | + define('IS_PROFILE_PAGE', ($user_id == $current_user->ID)); |
|
18 | 18 | |
19 | -if ( ! $user_id && IS_PROFILE_PAGE ) |
|
19 | +if ( ! $user_id && IS_PROFILE_PAGE) |
|
20 | 20 | $user_id = $current_user->ID; |
21 | -elseif ( ! $user_id && ! IS_PROFILE_PAGE ) |
|
22 | - wp_die(__( 'Invalid user ID.' ) ); |
|
23 | -elseif ( ! get_userdata( $user_id ) ) |
|
24 | - wp_die( __('Invalid user ID.') ); |
|
21 | +elseif ( ! $user_id && ! IS_PROFILE_PAGE) |
|
22 | + wp_die(__('Invalid user ID.')); |
|
23 | +elseif ( ! get_userdata($user_id)) |
|
24 | + wp_die(__('Invalid user ID.')); |
|
25 | 25 | |
26 | 26 | wp_enqueue_script('user-profile'); |
27 | 27 | |
28 | 28 | $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User'); |
29 | -if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) |
|
29 | +if (current_user_can('edit_users') && ! IS_PROFILE_PAGE) |
|
30 | 30 | $submenu_file = 'users.php'; |
31 | 31 | else |
32 | 32 | $submenu_file = 'profile.php'; |
33 | 33 | |
34 | -if ( current_user_can('edit_users') && !is_user_admin() ) |
|
34 | +if (current_user_can('edit_users') && ! is_user_admin()) |
|
35 | 35 | $parent_file = 'users.php'; |
36 | 36 | else |
37 | 37 | $parent_file = 'profile.php'; |
38 | 38 | |
39 | -$profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . |
|
40 | - '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . |
|
41 | - '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . |
|
42 | - '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' . |
|
43 | - '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' . |
|
44 | - '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' . |
|
45 | - '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>'; |
|
39 | +$profile_help = '<p>'.__('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.').'</p>'. |
|
40 | + '<p>'.__('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.').'</p>'. |
|
41 | + '<p>'.__('You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.').'</p>'. |
|
42 | + '<p>'.__('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.').'</p>'. |
|
43 | + '<p>'.__('You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.').'</p>'. |
|
44 | + '<p>'.__('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.').'</p>'. |
|
45 | + '<p>'.__('Remember to click the Update Profile button when you are finished.').'</p>'; |
|
46 | 46 | |
47 | -get_current_screen()->add_help_tab( array( |
|
47 | +get_current_screen()->add_help_tab(array( |
|
48 | 48 | 'id' => 'overview', |
49 | 49 | 'title' => __('Overview'), |
50 | 50 | 'content' => $profile_help, |
51 | -) ); |
|
51 | +)); |
|
52 | 52 | |
53 | 53 | get_current_screen()->set_help_sidebar( |
54 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
55 | - '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' . |
|
56 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
54 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
55 | + '<p>'.__('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>').'</p>'. |
|
56 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
57 | 57 | ); |
58 | 58 | |
59 | -$wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer ); |
|
59 | +$wp_http_referer = remove_query_arg(array('update', 'delete_count', 'user_id'), $wp_http_referer); |
|
60 | 60 | |
61 | -$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ); |
|
61 | +$user_can_edit = current_user_can('edit_posts') || current_user_can('edit_pages'); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Filters whether to allow administrators on Multisite to edit every user. |
@@ -73,47 +73,47 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param bool $allow Whether to allow editing of any user. Default true. |
75 | 75 | */ |
76 | -if ( is_multisite() |
|
77 | - && ! current_user_can( 'manage_network_users' ) |
|
76 | +if (is_multisite() |
|
77 | + && ! current_user_can('manage_network_users') |
|
78 | 78 | && $user_id != $current_user->ID |
79 | - && ! apply_filters( 'enable_edit_any_user_configuration', true ) |
|
79 | + && ! apply_filters('enable_edit_any_user_configuration', true) |
|
80 | 80 | ) { |
81 | - wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); |
|
81 | + wp_die(__('Sorry, you are not allowed to edit this user.')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | // Execute confirmed email change. See send_confirmation_on_profile_email(). |
85 | -if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) { |
|
86 | - $new_email = get_user_meta( $current_user->ID, '_new_email', true ); |
|
87 | - if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) { |
|
85 | +if (is_multisite() && IS_PROFILE_PAGE && isset($_GET['newuseremail']) && $current_user->ID) { |
|
86 | + $new_email = get_user_meta($current_user->ID, '_new_email', true); |
|
87 | + if ($new_email && hash_equals($new_email['hash'], $_GET['newuseremail'])) { |
|
88 | 88 | $user = new stdClass; |
89 | 89 | $user->ID = $current_user->ID; |
90 | - $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) ); |
|
91 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { |
|
92 | - $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); |
|
90 | + $user->user_email = esc_html(trim($new_email['newemail'])); |
|
91 | + if ($wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login))) { |
|
92 | + $wpdb->query($wpdb->prepare("UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login)); |
|
93 | 93 | } |
94 | - wp_update_user( $user ); |
|
95 | - delete_user_meta( $current_user->ID, '_new_email' ); |
|
96 | - wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); |
|
94 | + wp_update_user($user); |
|
95 | + delete_user_meta($current_user->ID, '_new_email'); |
|
96 | + wp_redirect(add_query_arg(array('updated' => 'true'), self_admin_url('profile.php'))); |
|
97 | 97 | die(); |
98 | 98 | } else { |
99 | - wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) ); |
|
99 | + wp_redirect(add_query_arg(array('error' => 'new-email'), self_admin_url('profile.php'))); |
|
100 | 100 | } |
101 | -} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) { |
|
102 | - check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' ); |
|
103 | - delete_user_meta( $current_user->ID, '_new_email' ); |
|
104 | - wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) ); |
|
101 | +} elseif (is_multisite() && IS_PROFILE_PAGE && ! empty($_GET['dismiss']) && $current_user->ID.'_new_email' === $_GET['dismiss']) { |
|
102 | + check_admin_referer('dismiss-'.$current_user->ID.'_new_email'); |
|
103 | + delete_user_meta($current_user->ID, '_new_email'); |
|
104 | + wp_redirect(add_query_arg(array('updated' => 'true'), self_admin_url('profile.php'))); |
|
105 | 105 | die(); |
106 | 106 | } |
107 | 107 | |
108 | 108 | switch ($action) { |
109 | 109 | case 'update': |
110 | 110 | |
111 | -check_admin_referer('update-user_' . $user_id); |
|
111 | +check_admin_referer('update-user_'.$user_id); |
|
112 | 112 | |
113 | -if ( !current_user_can('edit_user', $user_id) ) |
|
113 | +if ( ! current_user_can('edit_user', $user_id)) |
|
114 | 114 | wp_die(__('Sorry, you are not allowed to edit this user.')); |
115 | 115 | |
116 | -if ( IS_PROFILE_PAGE ) { |
|
116 | +if (IS_PROFILE_PAGE) { |
|
117 | 117 | /** |
118 | 118 | * Fires before the page loads on the 'Your Profile' editing screen. |
119 | 119 | * |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param int $user_id The user ID. |
125 | 125 | */ |
126 | - do_action( 'personal_options_update', $user_id ); |
|
126 | + do_action('personal_options_update', $user_id); |
|
127 | 127 | } else { |
128 | 128 | /** |
129 | 129 | * Fires before the page loads on the 'Edit User' screen. |
@@ -132,29 +132,29 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param int $user_id The user ID. |
134 | 134 | */ |
135 | - do_action( 'edit_user_profile_update', $user_id ); |
|
135 | + do_action('edit_user_profile_update', $user_id); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Update the email address in signups, if present. |
139 | -if ( is_multisite() ) { |
|
140 | - $user = get_userdata( $user_id ); |
|
139 | +if (is_multisite()) { |
|
140 | + $user = get_userdata($user_id); |
|
141 | 141 | |
142 | - if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { |
|
143 | - $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) ); |
|
142 | + if ($user->user_login && isset($_POST['email']) && is_email($_POST['email']) && $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login))) { |
|
143 | + $wpdb->query($wpdb->prepare("UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login)); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Update the user. |
148 | -$errors = edit_user( $user_id ); |
|
148 | +$errors = edit_user($user_id); |
|
149 | 149 | |
150 | 150 | // Grant or revoke super admin status if requested. |
151 | -if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) { |
|
152 | - empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); |
|
151 | +if (is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can('manage_network_options') && ! isset($super_admins) && empty($_POST['super_admin']) == is_super_admin($user_id)) { |
|
152 | + empty($_POST['super_admin']) ? revoke_super_admin($user_id) : grant_super_admin($user_id); |
|
153 | 153 | } |
154 | 154 | |
155 | -if ( !is_wp_error( $errors ) ) { |
|
156 | - $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); |
|
157 | - if ( $wp_http_referer ) |
|
155 | +if ( ! is_wp_error($errors)) { |
|
156 | + $redirect = add_query_arg('updated', true, get_edit_user_link($user_id)); |
|
157 | + if ($wp_http_referer) |
|
158 | 158 | $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); |
159 | 159 | wp_redirect($redirect); |
160 | 160 | exit; |
@@ -163,67 +163,67 @@ discard block |
||
163 | 163 | default: |
164 | 164 | $profileuser = get_user_to_edit($user_id); |
165 | 165 | |
166 | -if ( !current_user_can('edit_user', $user_id) ) |
|
166 | +if ( ! current_user_can('edit_user', $user_id)) |
|
167 | 167 | wp_die(__('Sorry, you are not allowed to edit this user.')); |
168 | 168 | |
169 | -$sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); |
|
169 | +$sessions = WP_Session_Tokens::get_instance($profileuser->ID); |
|
170 | 170 | |
171 | -include(ABSPATH . 'wp-admin/admin-header.php'); |
|
171 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
172 | 172 | ?> |
173 | 173 | |
174 | -<?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?> |
|
174 | +<?php if ( ! IS_PROFILE_PAGE && is_super_admin($profileuser->ID) && current_user_can('manage_network_options')) { ?> |
|
175 | 175 | <div class="notice notice-info"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div> |
176 | 176 | <?php } ?> |
177 | -<?php if ( isset($_GET['updated']) ) : ?> |
|
177 | +<?php if (isset($_GET['updated'])) : ?> |
|
178 | 178 | <div id="message" class="updated notice is-dismissible"> |
179 | - <?php if ( IS_PROFILE_PAGE ) : ?> |
|
179 | + <?php if (IS_PROFILE_PAGE) : ?> |
|
180 | 180 | <p><strong><?php _e('Profile updated.') ?></strong></p> |
181 | 181 | <?php else: ?> |
182 | 182 | <p><strong><?php _e('User updated.') ?></strong></p> |
183 | 183 | <?php endif; ?> |
184 | - <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?> |
|
185 | - <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('← Back to Users'); ?></a></p> |
|
184 | + <?php if ($wp_http_referer && false === strpos($wp_http_referer, 'user-new.php') && ! IS_PROFILE_PAGE) : ?> |
|
185 | + <p><a href="<?php echo esc_url($wp_http_referer); ?>"><?php _e('← Back to Users'); ?></a></p> |
|
186 | 186 | <?php endif; ?> |
187 | 187 | </div> |
188 | 188 | <?php endif; ?> |
189 | -<?php if ( isset( $_GET['error'] ) ) : ?> |
|
189 | +<?php if (isset($_GET['error'])) : ?> |
|
190 | 190 | <div class="notice notice-error"> |
191 | - <?php if ( 'new-email' == $_GET['error'] ) : ?> |
|
192 | - <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p> |
|
191 | + <?php if ('new-email' == $_GET['error']) : ?> |
|
192 | + <p><?php _e('Error while saving the new email address. Please try again.'); ?></p> |
|
193 | 193 | <?php endif; ?> |
194 | 194 | </div> |
195 | 195 | <?php endif; ?> |
196 | -<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?> |
|
197 | -<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div> |
|
196 | +<?php if (isset($errors) && is_wp_error($errors)) : ?> |
|
197 | +<div class="error"><p><?php echo implode("</p>\n<p>", $errors->get_error_messages()); ?></p></div> |
|
198 | 198 | <?php endif; ?> |
199 | 199 | |
200 | 200 | <div class="wrap" id="profile-page"> |
201 | 201 | <h1 class="wp-heading-inline"><?php |
202 | -echo esc_html( $title ); |
|
202 | +echo esc_html($title); |
|
203 | 203 | ?></h1> |
204 | 204 | |
205 | 205 | <?php |
206 | -if ( ! IS_PROFILE_PAGE ) { |
|
207 | - if ( current_user_can( 'create_users' ) ) { ?> |
|
208 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> |
|
209 | - <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
|
210 | - <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> |
|
206 | +if ( ! IS_PROFILE_PAGE) { |
|
207 | + if (current_user_can('create_users')) { ?> |
|
208 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add New', 'user'); ?></a> |
|
209 | + <?php } elseif (is_multisite() && current_user_can('promote_users')) { ?> |
|
210 | + <a href="user-new.php" class="page-title-action"><?php echo esc_html_x('Add Existing', 'user'); ?></a> |
|
211 | 211 | <?php } |
212 | 212 | } |
213 | 213 | ?> |
214 | 214 | |
215 | 215 | <hr class="wp-header-end"> |
216 | 216 | |
217 | -<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"<?php |
|
217 | +<form id="your-profile" action="<?php echo esc_url(self_admin_url(IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php')); ?>" method="post" novalidate="novalidate"<?php |
|
218 | 218 | /** |
219 | 219 | * Fires inside the your-profile form tag on the user editing screen. |
220 | 220 | * |
221 | 221 | * @since 3.0.0 |
222 | 222 | */ |
223 | - do_action( 'user_edit_form_tag' ); |
|
223 | + do_action('user_edit_form_tag'); |
|
224 | 224 | ?>> |
225 | -<?php wp_nonce_field('update-user_' . $user_id) ?> |
|
226 | -<?php if ( $wp_http_referer ) : ?> |
|
225 | +<?php wp_nonce_field('update-user_'.$user_id) ?> |
|
226 | +<?php if ($wp_http_referer) : ?> |
|
227 | 227 | <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> |
228 | 228 | <?php endif; ?> |
229 | 229 | <p> |
@@ -231,16 +231,16 @@ discard block |
||
231 | 231 | <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" /> |
232 | 232 | </p> |
233 | 233 | |
234 | -<h2><?php _e( 'Personal Options' ); ?></h2> |
|
234 | +<h2><?php _e('Personal Options'); ?></h2> |
|
235 | 235 | |
236 | 236 | <table class="form-table"> |
237 | -<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> |
|
237 | +<?php if ( ! (IS_PROFILE_PAGE && ! $user_can_edit)) : ?> |
|
238 | 238 | <tr class="user-rich-editing-wrap"> |
239 | - <th scope="row"><?php _e( 'Visual Editor' ); ?></th> |
|
240 | - <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td> |
|
239 | + <th scope="row"><?php _e('Visual Editor'); ?></th> |
|
240 | + <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty($profileuser->rich_editing)) checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td> |
|
241 | 241 | </tr> |
242 | 242 | <?php endif; ?> |
243 | -<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> |
|
243 | +<?php if (count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker')) : ?> |
|
244 | 244 | <tr class="user-admin-color-wrap"> |
245 | 245 | <th scope="row"><?php _e('Admin Color Scheme')?></th> |
246 | 246 | <td><?php |
@@ -255,53 +255,53 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @param int $user_id The user ID. |
257 | 257 | */ |
258 | - do_action( 'admin_color_scheme_picker', $user_id ); |
|
258 | + do_action('admin_color_scheme_picker', $user_id); |
|
259 | 259 | ?></td> |
260 | 260 | </tr> |
261 | 261 | <?php |
262 | 262 | endif; // $_wp_admin_css_colors |
263 | -if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> |
|
263 | +if ( ! (IS_PROFILE_PAGE && ! $user_can_edit)) : ?> |
|
264 | 264 | <tr class="user-comment-shortcuts-wrap"> |
265 | -<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> |
|
266 | -<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
265 | +<th scope="row"><?php _e('Keyboard Shortcuts'); ?></th> |
|
266 | +<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty($profileuser->comment_shortcuts)) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> |
|
267 | 267 | </tr> |
268 | 268 | <?php endif; ?> |
269 | 269 | <tr class="show-admin-bar user-admin-bar-front-wrap"> |
270 | -<th scope="row"><?php _e( 'Toolbar' ); ?></th> |
|
270 | +<th scope="row"><?php _e('Toolbar'); ?></th> |
|
271 | 271 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend> |
272 | 272 | <label for="admin_bar_front"> |
273 | -<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> |
|
274 | -<?php _e( 'Show Toolbar when viewing site' ); ?></label><br /> |
|
273 | +<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked(_get_admin_bar_pref('front', $profileuser->ID)); ?> /> |
|
274 | +<?php _e('Show Toolbar when viewing site'); ?></label><br /> |
|
275 | 275 | </fieldset> |
276 | 276 | </td> |
277 | 277 | </tr> |
278 | 278 | |
279 | 279 | <?php |
280 | 280 | $languages = get_available_languages(); |
281 | -if ( $languages ) : ?> |
|
281 | +if ($languages) : ?> |
|
282 | 282 | <tr class="user-language-wrap"> |
283 | 283 | <th scope="row"> |
284 | 284 | <?php /* translators: The user language selection field label */ ?> |
285 | - <label for="locale"><?php _e( 'Language' ); ?></label> |
|
285 | + <label for="locale"><?php _e('Language'); ?></label> |
|
286 | 286 | </th> |
287 | 287 | <td> |
288 | 288 | <?php |
289 | 289 | $user_locale = $profileuser->locale; |
290 | 290 | |
291 | - if ( 'en_US' === $user_locale ) { |
|
291 | + if ('en_US' === $user_locale) { |
|
292 | 292 | $user_locale = ''; |
293 | - } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) { |
|
293 | + } elseif ('' === $user_locale || ! in_array($user_locale, $languages, true)) { |
|
294 | 294 | $user_locale = 'site-default'; |
295 | 295 | } |
296 | 296 | |
297 | - wp_dropdown_languages( array( |
|
297 | + wp_dropdown_languages(array( |
|
298 | 298 | 'name' => 'locale', |
299 | 299 | 'id' => 'locale', |
300 | 300 | 'selected' => $user_locale, |
301 | 301 | 'languages' => $languages, |
302 | 302 | 'show_available_translations' => false, |
303 | 303 | 'show_option_site_default' => true |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | ?> |
306 | 306 | </td> |
307 | 307 | </tr> |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @param WP_User $profileuser The current WP_User object. |
319 | 319 | */ |
320 | -do_action( 'personal_options', $profileuser ); |
|
320 | +do_action('personal_options', $profileuser); |
|
321 | 321 | ?> |
322 | 322 | |
323 | 323 | </table> |
324 | 324 | <?php |
325 | - if ( IS_PROFILE_PAGE ) { |
|
325 | + if (IS_PROFILE_PAGE) { |
|
326 | 326 | /** |
327 | 327 | * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen. |
328 | 328 | * |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param WP_User $profileuser The current WP_User object. |
334 | 334 | */ |
335 | - do_action( 'profile_personal_options', $profileuser ); |
|
335 | + do_action('profile_personal_options', $profileuser); |
|
336 | 336 | } |
337 | 337 | ?> |
338 | 338 | |
339 | -<h2><?php _e( 'Name' ); ?></h2> |
|
339 | +<h2><?php _e('Name'); ?></h2> |
|
340 | 340 | |
341 | 341 | <table class="form-table"> |
342 | 342 | <tr class="user-user-login-wrap"> |
@@ -344,33 +344,33 @@ discard block |
||
344 | 344 | <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td> |
345 | 345 | </tr> |
346 | 346 | |
347 | -<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> |
|
347 | +<?php if ( ! IS_PROFILE_PAGE && ! is_network_admin()) : ?> |
|
348 | 348 | <tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th> |
349 | 349 | <td><select name="role" id="role"> |
350 | 350 | <?php |
351 | 351 | // Compare user role against currently editable roles |
352 | -$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); |
|
353 | -$user_role = reset( $user_roles ); |
|
352 | +$user_roles = array_intersect(array_values($profileuser->roles), array_keys(get_editable_roles())); |
|
353 | +$user_role = reset($user_roles); |
|
354 | 354 | |
355 | 355 | // print the full list of roles with the primary one selected. |
356 | 356 | wp_dropdown_roles($user_role); |
357 | 357 | |
358 | 358 | // print the 'no role' option. Make it selected if the user has no role yet. |
359 | -if ( $user_role ) |
|
360 | - echo '<option value="">' . __('— No role for this site —') . '</option>'; |
|
359 | +if ($user_role) |
|
360 | + echo '<option value="">'.__('— No role for this site —').'</option>'; |
|
361 | 361 | else |
362 | - echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; |
|
362 | + echo '<option value="" selected="selected">'.__('— No role for this site —').'</option>'; |
|
363 | 363 | ?> |
364 | 364 | </select></td></tr> |
365 | 365 | <?php endif; //!IS_PROFILE_PAGE |
366 | 366 | |
367 | -if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> |
|
367 | +if (is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can('manage_network_options') && ! isset($super_admins)) { ?> |
|
368 | 368 | <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th> |
369 | 369 | <td> |
370 | -<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> |
|
371 | -<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> |
|
370 | +<?php if ($profileuser->user_email != get_site_option('admin_email') || ! is_super_admin($profileuser->ID)) : ?> |
|
371 | +<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked(is_super_admin($profileuser->ID)); ?> /> <?php _e('Grant this user super admin privileges for the Network.'); ?></label></p> |
|
372 | 372 | <?php else : ?> |
373 | -<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> |
|
373 | +<p><?php _e('Super admin privileges cannot be removed because this user has the network admin email.'); ?></p> |
|
374 | 374 | <?php endif; ?> |
375 | 375 | </td></tr> |
376 | 376 | <?php } ?> |
@@ -399,26 +399,26 @@ discard block |
||
399 | 399 | $public_display['display_nickname'] = $profileuser->nickname; |
400 | 400 | $public_display['display_username'] = $profileuser->user_login; |
401 | 401 | |
402 | - if ( !empty($profileuser->first_name) ) |
|
402 | + if ( ! empty($profileuser->first_name)) |
|
403 | 403 | $public_display['display_firstname'] = $profileuser->first_name; |
404 | 404 | |
405 | - if ( !empty($profileuser->last_name) ) |
|
405 | + if ( ! empty($profileuser->last_name)) |
|
406 | 406 | $public_display['display_lastname'] = $profileuser->last_name; |
407 | 407 | |
408 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
409 | - $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
410 | - $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
408 | + if ( ! empty($profileuser->first_name) && ! empty($profileuser->last_name)) { |
|
409 | + $public_display['display_firstlast'] = $profileuser->first_name.' '.$profileuser->last_name; |
|
410 | + $public_display['display_lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name; |
|
411 | 411 | } |
412 | 412 | |
413 | - if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere |
|
414 | - $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; |
|
413 | + if ( ! in_array($profileuser->display_name, $public_display)) // Only add this if it isn't duplicated elsewhere |
|
414 | + $public_display = array('display_displayname' => $profileuser->display_name) + $public_display; |
|
415 | 415 | |
416 | - $public_display = array_map( 'trim', $public_display ); |
|
417 | - $public_display = array_unique( $public_display ); |
|
416 | + $public_display = array_map('trim', $public_display); |
|
417 | + $public_display = array_unique($public_display); |
|
418 | 418 | |
419 | - foreach ( $public_display as $id => $item ) { |
|
419 | + foreach ($public_display as $id => $item) { |
|
420 | 420 | ?> |
421 | - <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option> |
|
421 | + <option <?php selected($profileuser->display_name, $item); ?>><?php echo $item; ?></option> |
|
422 | 422 | <?php |
423 | 423 | } |
424 | 424 | ?> |
@@ -427,26 +427,26 @@ discard block |
||
427 | 427 | </tr> |
428 | 428 | </table> |
429 | 429 | |
430 | -<h2><?php _e( 'Contact Info' ); ?></h2> |
|
430 | +<h2><?php _e('Contact Info'); ?></h2> |
|
431 | 431 | |
432 | 432 | <table class="form-table"> |
433 | 433 | <tr class="user-email-wrap"> |
434 | 434 | <th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> |
435 | - <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" /> |
|
435 | + <td><input type="email" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text ltr" /> |
|
436 | 436 | <?php |
437 | - $new_email = get_user_meta( $current_user->ID, '_new_email', true ); |
|
438 | - if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?> |
|
437 | + $new_email = get_user_meta($current_user->ID, '_new_email', true); |
|
438 | + if ($new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID) : ?> |
|
439 | 439 | <div class="updated inline"> |
440 | 440 | <p><?php |
441 | 441 | printf( |
442 | 442 | /* translators: %s: new email */ |
443 | - __( 'There is a pending change of your email to %s.' ), |
|
444 | - '<code>' . esc_html( $new_email['newemail'] ) . '</code>' |
|
443 | + __('There is a pending change of your email to %s.'), |
|
444 | + '<code>'.esc_html($new_email['newemail']).'</code>' |
|
445 | 445 | ); |
446 | 446 | printf( |
447 | 447 | ' <a href="%1$s">%2$s</a>', |
448 | - esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ), |
|
449 | - __( 'Cancel' ) |
|
448 | + esc_url(wp_nonce_url(self_admin_url('profile.php?dismiss='.$current_user->ID.'_new_email'), 'dismiss-'.$current_user->ID.'_new_email')), |
|
449 | + __('Cancel') |
|
450 | 450 | ); |
451 | 451 | ?></p> |
452 | 452 | </div> |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | |
457 | 457 | <tr class="user-url-wrap"> |
458 | 458 | <th><label for="url"><?php _e('Website') ?></label></th> |
459 | - <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td> |
|
459 | + <td><input type="url" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td> |
|
460 | 460 | </tr> |
461 | 461 | |
462 | 462 | <?php |
463 | - foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { |
|
463 | + foreach (wp_get_user_contact_methods($profileuser) as $name => $desc) { |
|
464 | 464 | ?> |
465 | 465 | <tr class="user-<?php echo $name; ?>-wrap"> |
466 | 466 | <th><label for="<?php echo $name; ?>"> |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @param string $desc The translatable label for the contactmethod. |
477 | 477 | */ |
478 | - echo apply_filters( "user_{$name}_label", $desc ); |
|
478 | + echo apply_filters("user_{$name}_label", $desc); |
|
479 | 479 | ?> |
480 | 480 | </label></th> |
481 | 481 | <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | ?> |
486 | 486 | </table> |
487 | 487 | |
488 | -<h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> |
|
488 | +<h2><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h2> |
|
489 | 489 | |
490 | 490 | <table class="form-table"> |
491 | 491 | <tr class="user-description-wrap"> |
@@ -494,16 +494,16 @@ discard block |
||
494 | 494 | <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td> |
495 | 495 | </tr> |
496 | 496 | |
497 | -<?php if ( get_option( 'show_avatars' ) ) : ?> |
|
497 | +<?php if (get_option('show_avatars')) : ?> |
|
498 | 498 | <tr class="user-profile-picture"> |
499 | - <th><?php _e( 'Profile Picture' ); ?></th> |
|
499 | + <th><?php _e('Profile Picture'); ?></th> |
|
500 | 500 | <td> |
501 | - <?php echo get_avatar( $user_id ); ?> |
|
501 | + <?php echo get_avatar($user_id); ?> |
|
502 | 502 | <p class="description"><?php |
503 | - if ( IS_PROFILE_PAGE ) { |
|
503 | + if (IS_PROFILE_PAGE) { |
|
504 | 504 | /* translators: %s: Gravatar URL */ |
505 | - $description = sprintf( __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ), |
|
506 | - __( 'https://en.gravatar.com/' ) |
|
505 | + $description = sprintf(__('You can change your profile picture on <a href="%s">Gravatar</a>.'), |
|
506 | + __('https://en.gravatar.com/') |
|
507 | 507 | ); |
508 | 508 | } else { |
509 | 509 | $description = ''; |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @param string $description The description that will be printed. |
519 | 519 | * @param WP_User $profileuser The current WP_User object. |
520 | 520 | */ |
521 | - echo apply_filters( 'user_profile_picture_description', $description, $profileuser ); |
|
521 | + echo apply_filters('user_profile_picture_description', $description, $profileuser); |
|
522 | 522 | ?></p> |
523 | 523 | </td> |
524 | 524 | </tr> |
@@ -535,80 +535,80 @@ discard block |
||
535 | 535 | * @param bool $show Whether to show the password fields. Default true. |
536 | 536 | * @param WP_User $profileuser User object for the current user to edit. |
537 | 537 | */ |
538 | -if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) : |
|
538 | +if ($show_password_fields = apply_filters('show_password_fields', true, $profileuser)) : |
|
539 | 539 | ?> |
540 | 540 | </table> |
541 | 541 | |
542 | -<h2><?php _e( 'Account Management' ); ?></h2> |
|
542 | +<h2><?php _e('Account Management'); ?></h2> |
|
543 | 543 | <table class="form-table"> |
544 | 544 | <tr id="password" class="user-pass1-wrap"> |
545 | - <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> |
|
545 | + <th><label for="pass1"><?php _e('New Password'); ?></label></th> |
|
546 | 546 | <td> |
547 | 547 | <input class="hidden" value=" " /><!-- #24364 workaround --> |
548 | - <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button> |
|
548 | + <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e('Generate Password'); ?></button> |
|
549 | 549 | <div class="wp-pwd hide-if-js"> |
550 | 550 | <span class="password-input-wrapper"> |
551 | - <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> |
|
551 | + <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr(wp_generate_password(24)); ?>" aria-describedby="pass-strength-result" /> |
|
552 | 552 | </span> |
553 | - <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> |
|
553 | + <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Hide password'); ?>"> |
|
554 | 554 | <span class="dashicons dashicons-hidden"></span> |
555 | - <span class="text"><?php _e( 'Hide' ); ?></span> |
|
555 | + <span class="text"><?php _e('Hide'); ?></span> |
|
556 | 556 | </button> |
557 | - <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> |
|
558 | - <span class="text"><?php _e( 'Cancel' ); ?></span> |
|
557 | + <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e('Cancel password change'); ?>"> |
|
558 | + <span class="text"><?php _e('Cancel'); ?></span> |
|
559 | 559 | </button> |
560 | 560 | <div style="display:none" id="pass-strength-result" aria-live="polite"></div> |
561 | 561 | </div> |
562 | 562 | </td> |
563 | 563 | </tr> |
564 | 564 | <tr class="user-pass2-wrap hide-if-js"> |
565 | - <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> |
|
565 | + <th scope="row"><label for="pass2"><?php _e('Repeat New Password'); ?></label></th> |
|
566 | 566 | <td> |
567 | 567 | <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> |
568 | - <p class="description"><?php _e( 'Type your new password again.' ); ?></p> |
|
568 | + <p class="description"><?php _e('Type your new password again.'); ?></p> |
|
569 | 569 | </td> |
570 | 570 | </tr> |
571 | 571 | <tr class="pw-weak"> |
572 | - <th><?php _e( 'Confirm Password' ); ?></th> |
|
572 | + <th><?php _e('Confirm Password'); ?></th> |
|
573 | 573 | <td> |
574 | 574 | <label> |
575 | 575 | <input type="checkbox" name="pw_weak" class="pw-checkbox" /> |
576 | - <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span> |
|
576 | + <span id="pw-weak-text-label"><?php _e('Confirm use of potentially weak password'); ?></span> |
|
577 | 577 | </label> |
578 | 578 | </td> |
579 | 579 | </tr> |
580 | 580 | <?php endif; ?> |
581 | 581 | |
582 | 582 | <?php |
583 | -if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> |
|
583 | +if (IS_PROFILE_PAGE && count($sessions->get_all()) === 1) : ?> |
|
584 | 584 | <tr class="user-sessions-wrap hide-if-no-js"> |
585 | - <th><?php _e( 'Sessions' ); ?></th> |
|
585 | + <th><?php _e('Sessions'); ?></th> |
|
586 | 586 | <td aria-live="assertive"> |
587 | - <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> |
|
587 | + <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e('Log Out Everywhere Else'); ?></button></div> |
|
588 | 588 | <p class="description"> |
589 | - <?php _e( 'You are only logged in at this location.' ); ?> |
|
589 | + <?php _e('You are only logged in at this location.'); ?> |
|
590 | 590 | </p> |
591 | 591 | </td> |
592 | 592 | </tr> |
593 | -<?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> |
|
593 | +<?php elseif (IS_PROFILE_PAGE && count($sessions->get_all()) > 1) : ?> |
|
594 | 594 | <tr class="user-sessions-wrap hide-if-no-js"> |
595 | - <th><?php _e( 'Sessions' ); ?></th> |
|
595 | + <th><?php _e('Sessions'); ?></th> |
|
596 | 596 | <td aria-live="assertive"> |
597 | - <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> |
|
597 | + <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e('Log Out Everywhere Else'); ?></button></div> |
|
598 | 598 | <p class="description"> |
599 | - <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?> |
|
599 | + <?php _e('Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.'); ?> |
|
600 | 600 | </p> |
601 | 601 | </td> |
602 | 602 | </tr> |
603 | -<?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> |
|
603 | +<?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all()) : ?> |
|
604 | 604 | <tr class="user-sessions-wrap hide-if-no-js"> |
605 | - <th><?php _e( 'Sessions' ); ?></th> |
|
605 | + <th><?php _e('Sessions'); ?></th> |
|
606 | 606 | <td> |
607 | - <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> |
|
607 | + <p><button type="button" class="button" id="destroy-sessions"><?php _e('Log Out Everywhere'); ?></button></p> |
|
608 | 608 | <p class="description"> |
609 | 609 | <?php |
610 | 610 | /* translators: 1: User's display name. */ |
611 | - printf( __( 'Log %s out of all locations.' ), $profileuser->display_name ); |
|
611 | + printf(__('Log %s out of all locations.'), $profileuser->display_name); |
|
612 | 612 | ?> |
613 | 613 | </p> |
614 | 614 | </td> |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | </table> |
619 | 619 | |
620 | 620 | <?php |
621 | - if ( IS_PROFILE_PAGE ) { |
|
621 | + if (IS_PROFILE_PAGE) { |
|
622 | 622 | /** |
623 | 623 | * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen. |
624 | 624 | * |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param WP_User $profileuser The current WP_User object. |
630 | 630 | */ |
631 | - do_action( 'show_user_profile', $profileuser ); |
|
631 | + do_action('show_user_profile', $profileuser); |
|
632 | 632 | } else { |
633 | 633 | /** |
634 | 634 | * Fires after the 'About the User' settings table on the 'Edit User' screen. |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | * |
638 | 638 | * @param WP_User $profileuser The current WP_User object. |
639 | 639 | */ |
640 | - do_action( 'edit_user_profile', $profileuser ); |
|
640 | + do_action('edit_user_profile', $profileuser); |
|
641 | 641 | } |
642 | 642 | ?> |
643 | 643 | |
@@ -654,21 +654,21 @@ discard block |
||
654 | 654 | * @param bool $enable Whether to display the capabilities. Default true. |
655 | 655 | * @param WP_User $profileuser The current WP_User object. |
656 | 656 | */ |
657 | -if ( count( $profileuser->caps ) > count( $profileuser->roles ) |
|
658 | - && apply_filters( 'additional_capabilities_display', true, $profileuser ) |
|
657 | +if (count($profileuser->caps) > count($profileuser->roles) |
|
658 | + && apply_filters('additional_capabilities_display', true, $profileuser) |
|
659 | 659 | ) : ?> |
660 | -<h2><?php _e( 'Additional Capabilities' ); ?></h2> |
|
660 | +<h2><?php _e('Additional Capabilities'); ?></h2> |
|
661 | 661 | <table class="form-table"> |
662 | 662 | <tr class="user-capabilities-wrap"> |
663 | - <th scope="row"><?php _e( 'Capabilities' ); ?></th> |
|
663 | + <th scope="row"><?php _e('Capabilities'); ?></th> |
|
664 | 664 | <td> |
665 | 665 | <?php |
666 | 666 | $output = ''; |
667 | - foreach ( $profileuser->caps as $cap => $value ) { |
|
668 | - if ( ! $wp_roles->is_role( $cap ) ) { |
|
669 | - if ( '' != $output ) |
|
667 | + foreach ($profileuser->caps as $cap => $value) { |
|
668 | + if ( ! $wp_roles->is_role($cap)) { |
|
669 | + if ('' != $output) |
|
670 | 670 | $output .= ', '; |
671 | - $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); |
|
671 | + $output .= $value ? $cap : sprintf(__('Denied: %s'), $cap); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | echo $output; |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | <input type="hidden" name="action" value="update" /> |
682 | 682 | <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" /> |
683 | 683 | |
684 | -<?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?> |
|
684 | +<?php submit_button(IS_PROFILE_PAGE ? __('Update Profile') : __('Update User')); ?> |
|
685 | 685 | |
686 | 686 | </form> |
687 | 687 | </div> |
@@ -695,4 +695,4 @@ discard block |
||
695 | 695 | } |
696 | 696 | </script> |
697 | 697 | <?php |
698 | -include( ABSPATH . 'wp-admin/admin-footer.php'); |
|
698 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | // Load all the nav menu interface functions |
16 | 16 | require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' ); |
17 | 17 | |
18 | -if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) ) |
|
18 | +if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) ) { |
|
19 | 19 | wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); |
20 | +} |
|
20 | 21 | |
21 | 22 | // Permissions Check |
22 | 23 | if ( ! current_user_can( 'edit_theme_options' ) ) { |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | wp_enqueue_script( 'nav-menu' ); |
31 | 32 | |
32 | -if ( wp_is_mobile() ) |
|
33 | +if ( wp_is_mobile() ) { |
|
33 | 34 | wp_enqueue_script( 'jquery-touch-punch' ); |
35 | +} |
|
34 | 36 | |
35 | 37 | // Container for any messages displayed to the user |
36 | 38 | $messages = array(); |
@@ -76,10 +78,11 @@ discard block |
||
76 | 78 | switch ( $action ) { |
77 | 79 | case 'add-menu-item': |
78 | 80 | check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
79 | - if ( isset( $_REQUEST['nav-menu-locations'] ) ) |
|
80 | - set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) ); |
|
81 | - elseif ( isset( $_REQUEST['menu-item'] ) ) |
|
82 | - wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); |
|
81 | + if ( isset( $_REQUEST['nav-menu-locations'] ) ) { |
|
82 | + set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) ); |
|
83 | + } elseif ( isset( $_REQUEST['menu-item'] ) ) { |
|
84 | + wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); |
|
85 | + } |
|
83 | 86 | break; |
84 | 87 | case 'move-down-menu-item' : |
85 | 88 | |
@@ -214,10 +217,11 @@ discard block |
||
214 | 217 | ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) |
215 | 218 | ) { |
216 | 219 | $_possible_parent_id = (int) get_post_meta( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1], '_menu_item_menu_item_parent', true); |
217 | - if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) ) |
|
218 | - $menu_item_data['menu_item_parent'] = $_possible_parent_id; |
|
219 | - else |
|
220 | - $menu_item_data['menu_item_parent'] = 0; |
|
220 | + if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) ) { |
|
221 | + $menu_item_data['menu_item_parent'] = $_possible_parent_id; |
|
222 | + } else { |
|
223 | + $menu_item_data['menu_item_parent'] = 0; |
|
224 | + } |
|
221 | 225 | |
222 | 226 | // Else there isn't something before the parent. |
223 | 227 | } else { |
@@ -259,8 +263,9 @@ discard block |
||
259 | 263 | |
260 | 264 | check_admin_referer( 'delete-menu_item_' . $menu_item_id ); |
261 | 265 | |
262 | - if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) |
|
263 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; |
|
266 | + if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) { |
|
267 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; |
|
268 | + } |
|
264 | 269 | break; |
265 | 270 | |
266 | 271 | case 'delete': |
@@ -273,20 +278,23 @@ discard block |
||
273 | 278 | unset( $_REQUEST['menu'] ); |
274 | 279 | } |
275 | 280 | |
276 | - if ( ! isset( $deletion ) ) |
|
277 | - break; |
|
281 | + if ( ! isset( $deletion ) ) { |
|
282 | + break; |
|
283 | + } |
|
278 | 284 | |
279 | - if ( is_wp_error( $deletion ) ) |
|
280 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
|
281 | - else |
|
282 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>'; |
|
285 | + if ( is_wp_error( $deletion ) ) { |
|
286 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
|
287 | + } else { |
|
288 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>'; |
|
289 | + } |
|
283 | 290 | break; |
284 | 291 | |
285 | 292 | case 'delete_menus': |
286 | 293 | check_admin_referer( 'nav_menus_bulk_actions' ); |
287 | 294 | foreach ( $_REQUEST['delete_menus'] as $menu_id_to_delete ) { |
288 | - if ( ! is_nav_menu( $menu_id_to_delete ) ) |
|
289 | - continue; |
|
295 | + if ( ! is_nav_menu( $menu_id_to_delete ) ) { |
|
296 | + continue; |
|
297 | + } |
|
290 | 298 | |
291 | 299 | $deletion = wp_delete_nav_menu( $menu_id_to_delete ); |
292 | 300 | if ( is_wp_error( $deletion ) ) { |
@@ -295,8 +303,9 @@ discard block |
||
295 | 303 | } |
296 | 304 | } |
297 | 305 | |
298 | - if ( empty( $deletion_error ) ) |
|
299 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>'; |
|
306 | + if ( empty( $deletion_error ) ) { |
|
307 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>'; |
|
308 | + } |
|
300 | 309 | break; |
301 | 310 | |
302 | 311 | case 'update': |
@@ -304,8 +313,9 @@ discard block |
||
304 | 313 | |
305 | 314 | // Remove menu locations that have been unchecked. |
306 | 315 | foreach ( $locations as $location => $description ) { |
307 | - if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) |
|
308 | - unset( $menu_locations[ $location ] ); |
|
316 | + if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) { |
|
317 | + unset( $menu_locations[ $location ] ); |
|
318 | + } |
|
309 | 319 | } |
310 | 320 | |
311 | 321 | // Merge new and existing menu locations if any new ones are set. |
@@ -330,8 +340,9 @@ discard block |
||
330 | 340 | $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
331 | 341 | $nav_menu_selected_id = $_nav_menu_selected_id; |
332 | 342 | $nav_menu_selected_title = $_menu_object->name; |
333 | - if ( isset( $_REQUEST['menu-item'] ) ) |
|
334 | - wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); |
|
343 | + if ( isset( $_REQUEST['menu-item'] ) ) { |
|
344 | + wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); |
|
345 | + } |
|
335 | 346 | if ( isset( $_REQUEST['zero-menu-state'] ) ) { |
336 | 347 | // If there are menu items, add them |
337 | 348 | wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); |
@@ -346,8 +357,9 @@ discard block |
||
346 | 357 | if ( isset( $_REQUEST['use-location'] ) ) { |
347 | 358 | $locations = get_registered_nav_menus(); |
348 | 359 | $menu_locations = get_nav_menu_locations(); |
349 | - if ( isset( $locations[ $_REQUEST['use-location'] ] ) ) |
|
350 | - $menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id; |
|
360 | + if ( isset( $locations[ $_REQUEST['use-location'] ] ) ) { |
|
361 | + $menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id; |
|
362 | + } |
|
351 | 363 | set_theme_mod( 'nav_menu_locations', $menu_locations ); |
352 | 364 | } |
353 | 365 | |
@@ -454,21 +466,25 @@ discard block |
||
454 | 466 | * Redirect to add screen if there are no menus and this users has either zero, |
455 | 467 | * or more than 1 theme locations. |
456 | 468 | */ |
457 | -if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) |
|
469 | +if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) { |
|
458 | 470 | wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); |
471 | +} |
|
459 | 472 | |
460 | 473 | // Get recently edited nav menu. |
461 | 474 | $recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
462 | -if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) |
|
475 | +if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) { |
|
463 | 476 | $recently_edited = $nav_menu_selected_id; |
477 | +} |
|
464 | 478 | |
465 | 479 | // Use $recently_edited if none are selected. |
466 | -if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) |
|
480 | +if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) { |
|
467 | 481 | $nav_menu_selected_id = $recently_edited; |
482 | +} |
|
468 | 483 | |
469 | 484 | // On deletion of menu, if another menu exists, show it. |
470 | -if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) |
|
485 | +if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) { |
|
471 | 486 | $nav_menu_selected_id = $nav_menus[0]->term_id; |
487 | +} |
|
472 | 488 | |
473 | 489 | // Set $nav_menu_selected_id to 0 if no menus. |
474 | 490 | if ( $one_theme_location_no_menus ) { |
@@ -479,8 +495,9 @@ discard block |
||
479 | 495 | } |
480 | 496 | |
481 | 497 | // Update the user's setting. |
482 | -if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) |
|
498 | +if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) { |
|
483 | 499 | update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); |
500 | +} |
|
484 | 501 | |
485 | 502 | // If there's a menu, get its name. |
486 | 503 | if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { |
@@ -531,8 +548,9 @@ discard block |
||
531 | 548 | wp_nav_menu_setup(); |
532 | 549 | wp_initial_nav_menu_meta_boxes(); |
533 | 550 | |
534 | -if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) |
|
551 | +if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) { |
|
535 | 552 | $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'Your theme does not natively support menus, but you can use them in sidebars by adding a “Custom Menu” widget on the <a href="%s">Widgets</a> screen.' ), admin_url( 'widgets.php' ) ) . '</p></div>'; |
553 | +} |
|
536 | 554 | |
537 | 555 | if ( ! $locations_screen ) : // Main tab |
538 | 556 | $overview = '<p>' . __( 'This screen is used for managing your custom navigation menus.' ) . '</p>'; |
@@ -570,8 +588,10 @@ discard block |
||
570 | 588 | 'title' => __( 'Editing Menus' ), |
571 | 589 | 'content' => $editing_menus |
572 | 590 | ) ); |
573 | -else : // Locations Tab. |
|
591 | +else { |
|
592 | + : // Locations Tab. |
|
574 | 593 | $locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; |
594 | +} |
|
575 | 595 | $locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>' ) . '</li>'; |
576 | 596 | $locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; |
577 | 597 | $locations_overview .= '<li>' . __( 'To add a new menu instead of assigning an existing one, <strong>click the ’Use new menu’ link</strong>. Your new menu will be automatically assigned to that theme location' ) . '</li></ul>'; |
@@ -609,9 +629,15 @@ discard block |
||
609 | 629 | ?> |
610 | 630 | </h1> |
611 | 631 | <h2 class="nav-tab-wrapper wp-clearfix"> |
612 | - <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a> |
|
632 | + <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) { |
|
633 | + echo ' nav-tab-active'; |
|
634 | +} |
|
635 | +?>"><?php esc_html_e( 'Edit Menus' ); ?></a> |
|
613 | 636 | <?php if ( $num_locations && $menu_count ) : ?> |
614 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a> |
|
637 | + <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) { |
|
638 | + echo ' nav-tab-active'; |
|
639 | +} |
|
640 | +?>"><?php esc_html_e( 'Manage Locations' ); ?></a> |
|
615 | 641 | <?php |
616 | 642 | endif; |
617 | 643 | ?> |
@@ -647,7 +673,10 @@ discard block |
||
647 | 673 | <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> |
648 | 674 | <?php foreach ( $nav_menus as $menu ) : ?> |
649 | 675 | <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?> |
650 | - <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
676 | + <option <?php if ( $selected ) { |
|
677 | + echo 'data-orig="true"'; |
|
678 | +} |
|
679 | +?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
651 | 680 | <?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?> |
652 | 681 | </option> |
653 | 682 | <?php endforeach; ?> |
@@ -683,14 +712,20 @@ discard block |
||
683 | 712 | * @since 3.6.0 |
684 | 713 | */ |
685 | 714 | do_action( 'after_menu_locations_table' ); ?> |
686 | - <?php else : ?> |
|
715 | + <?php else { |
|
716 | + : ?> |
|
687 | 717 | <div class="manage-menus"> |
688 | 718 | <?php if ( $menu_count < 2 ) : ?> |
689 | 719 | <span class="add-edit-menu-action"> |
690 | - <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> |
|
720 | + <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); |
|
721 | +} |
|
722 | +?> |
|
691 | 723 | </span><!-- /add-edit-menu-action --> |
692 | - <?php else : ?> |
|
693 | - <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> |
|
724 | + <?php else { |
|
725 | + : ?> |
|
726 | + <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); |
|
727 | +} |
|
728 | +?>"> |
|
694 | 729 | <input type="hidden" name="action" value="edit" /> |
695 | 730 | <label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> |
696 | 731 | <select name="menu" id="select-menu-to-edit"> |
@@ -754,7 +789,10 @@ discard block |
||
754 | 789 | <div id="menu-management-liquid"> |
755 | 790 | <div id="menu-management"> |
756 | 791 | <form id="update-nav-menu" method="post" enctype="multipart/form-data"> |
757 | - <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>"> |
|
792 | + <div class="menu-edit <?php if ( $add_new_screen ) { |
|
793 | + echo 'blank-slate'; |
|
794 | +} |
|
795 | +?>"> |
|
758 | 796 | <input type="hidden" name="nav-menu-data"> |
759 | 797 | <?php |
760 | 798 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
@@ -808,12 +846,13 @@ discard block |
||
808 | 846 | <?php |
809 | 847 | if ( ! isset( $auto_add ) ) { |
810 | 848 | $auto_add = get_option( 'nav_menu_options' ); |
811 | - if ( ! isset( $auto_add['auto_add'] ) ) |
|
812 | - $auto_add = false; |
|
813 | - elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) |
|
814 | - $auto_add = true; |
|
815 | - else |
|
816 | - $auto_add = false; |
|
849 | + if ( ! isset( $auto_add['auto_add'] ) ) { |
|
850 | + $auto_add = false; |
|
851 | + } elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) { |
|
852 | + $auto_add = true; |
|
853 | + } else { |
|
854 | + $auto_add = false; |
|
855 | + } |
|
817 | 856 | } ?> |
818 | 857 | |
819 | 858 | <dl class="auto-add-pages"> |
@@ -10,27 +10,27 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | /** Load WordPress Administration Bootstrap */ |
13 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
13 | +require_once(dirname(__FILE__).'/admin.php'); |
|
14 | 14 | |
15 | 15 | // Load all the nav menu interface functions |
16 | -require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' ); |
|
16 | +require_once(ABSPATH.'wp-admin/includes/nav-menu.php'); |
|
17 | 17 | |
18 | -if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) ) |
|
19 | - wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); |
|
18 | +if ( ! current_theme_supports('menus') && ! current_theme_supports('widgets')) |
|
19 | + wp_die(__('Your theme does not support navigation menus or widgets.')); |
|
20 | 20 | |
21 | 21 | // Permissions Check |
22 | -if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
22 | +if ( ! current_user_can('edit_theme_options')) { |
|
23 | 23 | wp_die( |
24 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
25 | - '<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>', |
|
24 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
25 | + '<p>'.__('Sorry, you are not allowed to edit theme options on this site.').'</p>', |
|
26 | 26 | 403 |
27 | 27 | ); |
28 | 28 | } |
29 | 29 | |
30 | -wp_enqueue_script( 'nav-menu' ); |
|
30 | +wp_enqueue_script('nav-menu'); |
|
31 | 31 | |
32 | -if ( wp_is_mobile() ) |
|
33 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
32 | +if (wp_is_mobile()) |
|
33 | + wp_enqueue_script('jquery-touch-punch'); |
|
34 | 34 | |
35 | 35 | // Container for any messages displayed to the user |
36 | 36 | $messages = array(); |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | $nav_menu_selected_title = ''; |
40 | 40 | |
41 | 41 | // The menu id of the current menu being edited |
42 | -$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0; |
|
42 | +$nav_menu_selected_id = isset($_REQUEST['menu']) ? (int) $_REQUEST['menu'] : 0; |
|
43 | 43 | |
44 | 44 | // Get existing menu locations assignments |
45 | 45 | $locations = get_registered_nav_menus(); |
46 | 46 | $menu_locations = get_nav_menu_locations(); |
47 | -$num_locations = count( array_keys( $locations ) ); |
|
47 | +$num_locations = count(array_keys($locations)); |
|
48 | 48 | |
49 | 49 | // Allowed actions: add, update, delete |
50 | -$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; |
|
50 | +$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'edit'; |
|
51 | 51 | |
52 | 52 | /* |
53 | 53 | * If a JSON blob of navigation menu data is found, expand it and inject it |
@@ -55,32 +55,32 @@ discard block |
||
55 | 55 | */ |
56 | 56 | _wp_expand_nav_menu_post_data(); |
57 | 57 | |
58 | -switch ( $action ) { |
|
58 | +switch ($action) { |
|
59 | 59 | case 'add-menu-item': |
60 | - check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' ); |
|
61 | - if ( isset( $_REQUEST['nav-menu-locations'] ) ) |
|
62 | - set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) ); |
|
63 | - elseif ( isset( $_REQUEST['menu-item'] ) ) |
|
64 | - wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] ); |
|
60 | + check_admin_referer('add-menu_item', 'menu-settings-column-nonce'); |
|
61 | + if (isset($_REQUEST['nav-menu-locations'])) |
|
62 | + set_theme_mod('nav_menu_locations', array_map('absint', $_REQUEST['menu-locations'])); |
|
63 | + elseif (isset($_REQUEST['menu-item'])) |
|
64 | + wp_save_nav_menu_items($nav_menu_selected_id, $_REQUEST['menu-item']); |
|
65 | 65 | break; |
66 | 66 | case 'move-down-menu-item' : |
67 | 67 | |
68 | 68 | // Moving down a menu item is the same as moving up the next in order. |
69 | - check_admin_referer( 'move-menu_item' ); |
|
70 | - $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0; |
|
71 | - if ( is_nav_menu_item( $menu_item_id ) ) { |
|
72 | - $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) ); |
|
73 | - if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) { |
|
69 | + check_admin_referer('move-menu_item'); |
|
70 | + $menu_item_id = isset($_REQUEST['menu-item']) ? (int) $_REQUEST['menu-item'] : 0; |
|
71 | + if (is_nav_menu_item($menu_item_id)) { |
|
72 | + $menus = isset($_REQUEST['menu']) ? array((int) $_REQUEST['menu']) : wp_get_object_terms($menu_item_id, 'nav_menu', array('fields' => 'ids')); |
|
73 | + if ( ! is_wp_error($menus) && ! empty($menus[0])) { |
|
74 | 74 | $menu_id = (int) $menus[0]; |
75 | - $ordered_menu_items = wp_get_nav_menu_items( $menu_id ); |
|
76 | - $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) ); |
|
75 | + $ordered_menu_items = wp_get_nav_menu_items($menu_id); |
|
76 | + $menu_item_data = (array) wp_setup_nav_menu_item(get_post($menu_item_id)); |
|
77 | 77 | |
78 | 78 | // Set up the data we need in one pass through the array of menu items. |
79 | 79 | $dbids_to_orders = array(); |
80 | 80 | $orders_to_dbids = array(); |
81 | - foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { |
|
82 | - if ( isset( $ordered_menu_item_object->ID ) ) { |
|
83 | - if ( isset( $ordered_menu_item_object->menu_order ) ) { |
|
81 | + foreach ((array) $ordered_menu_items as $ordered_menu_item_object) { |
|
82 | + if (isset($ordered_menu_item_object->ID)) { |
|
83 | + if (isset($ordered_menu_item_object->menu_order)) { |
|
84 | 84 | $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order; |
85 | 85 | $orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID; |
86 | 86 | } |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | |
90 | 90 | // Get next in order. |
91 | 91 | if ( |
92 | - isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1] ) |
|
92 | + isset($orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1]) |
|
93 | 93 | ) { |
94 | 94 | $next_item_id = $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1]; |
95 | - $next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) ); |
|
95 | + $next_item_data = (array) wp_setup_nav_menu_item(get_post($next_item_id)); |
|
96 | 96 | |
97 | 97 | // If not siblings of same parent, bubble menu item up but keep order. |
98 | 98 | if ( |
99 | - ! empty( $menu_item_data['menu_item_parent'] ) && |
|
99 | + ! empty($menu_item_data['menu_item_parent']) && |
|
100 | 100 | ( |
101 | - empty( $next_item_data['menu_item_parent'] ) || |
|
101 | + empty($next_item_data['menu_item_parent']) || |
|
102 | 102 | $next_item_data['menu_item_parent'] != $menu_item_data['menu_item_parent'] |
103 | 103 | ) |
104 | 104 | ) { |
105 | 105 | |
106 | - $parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0; |
|
106 | + $parent_db_id = in_array($menu_item_data['menu_item_parent'], $orders_to_dbids) ? (int) $menu_item_data['menu_item_parent'] : 0; |
|
107 | 107 | |
108 | - $parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) ); |
|
108 | + $parent_object = wp_setup_nav_menu_item(get_post($parent_db_id)); |
|
109 | 109 | |
110 | - if ( ! is_wp_error( $parent_object ) ) { |
|
110 | + if ( ! is_wp_error($parent_object)) { |
|
111 | 111 | $parent_data = (array) $parent_object; |
112 | 112 | $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent']; |
113 | - update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
113 | + update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1; |
121 | 121 | |
122 | 122 | $menu_item_data['menu_item_parent'] = $next_item_data['ID']; |
123 | - update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
123 | + update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); |
|
124 | 124 | |
125 | 125 | wp_update_post($menu_item_data); |
126 | 126 | wp_update_post($next_item_data); |
@@ -128,32 +128,32 @@ discard block |
||
128 | 128 | |
129 | 129 | // The item is last but still has a parent, so bubble up. |
130 | 130 | } elseif ( |
131 | - ! empty( $menu_item_data['menu_item_parent'] ) && |
|
132 | - in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) |
|
131 | + ! empty($menu_item_data['menu_item_parent']) && |
|
132 | + in_array($menu_item_data['menu_item_parent'], $orders_to_dbids) |
|
133 | 133 | ) { |
134 | - $menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true); |
|
135 | - update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
134 | + $menu_item_data['menu_item_parent'] = (int) get_post_meta($menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true); |
|
135 | + update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | 140 | break; |
141 | 141 | case 'move-up-menu-item' : |
142 | - check_admin_referer( 'move-menu_item' ); |
|
143 | - $menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0; |
|
144 | - if ( is_nav_menu_item( $menu_item_id ) ) { |
|
145 | - $menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) ); |
|
146 | - if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) { |
|
142 | + check_admin_referer('move-menu_item'); |
|
143 | + $menu_item_id = isset($_REQUEST['menu-item']) ? (int) $_REQUEST['menu-item'] : 0; |
|
144 | + if (is_nav_menu_item($menu_item_id)) { |
|
145 | + $menus = isset($_REQUEST['menu']) ? array((int) $_REQUEST['menu']) : wp_get_object_terms($menu_item_id, 'nav_menu', array('fields' => 'ids')); |
|
146 | + if ( ! is_wp_error($menus) && ! empty($menus[0])) { |
|
147 | 147 | $menu_id = (int) $menus[0]; |
148 | - $ordered_menu_items = wp_get_nav_menu_items( $menu_id ); |
|
149 | - $menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) ); |
|
148 | + $ordered_menu_items = wp_get_nav_menu_items($menu_id); |
|
149 | + $menu_item_data = (array) wp_setup_nav_menu_item(get_post($menu_item_id)); |
|
150 | 150 | |
151 | 151 | // Set up the data we need in one pass through the array of menu items. |
152 | 152 | $dbids_to_orders = array(); |
153 | 153 | $orders_to_dbids = array(); |
154 | - foreach ( (array) $ordered_menu_items as $ordered_menu_item_object ) { |
|
155 | - if ( isset( $ordered_menu_item_object->ID ) ) { |
|
156 | - if ( isset( $ordered_menu_item_object->menu_order ) ) { |
|
154 | + foreach ((array) $ordered_menu_items as $ordered_menu_item_object) { |
|
155 | + if (isset($ordered_menu_item_object->ID)) { |
|
156 | + if (isset($ordered_menu_item_object->menu_order)) { |
|
157 | 157 | $dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order; |
158 | 158 | $orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID; |
159 | 159 | } |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | // If this menu item is not first. |
164 | - if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) { |
|
164 | + if ( ! empty($dbids_to_orders[$menu_item_id]) && ! empty($orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1])) { |
|
165 | 165 | |
166 | 166 | // If this menu item is a child of the previous. |
167 | 167 | if ( |
168 | - ! empty( $menu_item_data['menu_item_parent'] ) && |
|
169 | - in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) && |
|
170 | - isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) && |
|
171 | - ( $menu_item_data['menu_item_parent'] == $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) |
|
168 | + ! empty($menu_item_data['menu_item_parent']) && |
|
169 | + in_array($menu_item_data['menu_item_parent'], array_keys($dbids_to_orders)) && |
|
170 | + isset($orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]) && |
|
171 | + ($menu_item_data['menu_item_parent'] == $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]) |
|
172 | 172 | ) { |
173 | - $parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0; |
|
174 | - $parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) ); |
|
173 | + $parent_db_id = in_array($menu_item_data['menu_item_parent'], $orders_to_dbids) ? (int) $menu_item_data['menu_item_parent'] : 0; |
|
174 | + $parent_object = wp_setup_nav_menu_item(get_post($parent_db_id)); |
|
175 | 175 | |
176 | - if ( ! is_wp_error( $parent_object ) ) { |
|
176 | + if ( ! is_wp_error($parent_object)) { |
|
177 | 177 | $parent_data = (array) $parent_object; |
178 | 178 | |
179 | 179 | /* |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * make menu item a child also of it. |
182 | 182 | */ |
183 | 183 | if ( |
184 | - ! empty( $dbids_to_orders[$parent_db_id] ) && |
|
185 | - ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) && |
|
186 | - ! empty( $parent_data['menu_item_parent'] ) |
|
184 | + ! empty($dbids_to_orders[$parent_db_id]) && |
|
185 | + ! empty($orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1]) && |
|
186 | + ! empty($parent_data['menu_item_parent']) |
|
187 | 187 | ) { |
188 | 188 | $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent']; |
189 | 189 | |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | * make menu item a child of that something's parent |
193 | 193 | */ |
194 | 194 | } elseif ( |
195 | - ! empty( $dbids_to_orders[$parent_db_id] ) && |
|
196 | - ! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) |
|
195 | + ! empty($dbids_to_orders[$parent_db_id]) && |
|
196 | + ! empty($orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1]) |
|
197 | 197 | ) { |
198 | - $_possible_parent_id = (int) get_post_meta( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1], '_menu_item_menu_item_parent', true); |
|
199 | - if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) ) |
|
198 | + $_possible_parent_id = (int) get_post_meta($orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1], '_menu_item_menu_item_parent', true); |
|
199 | + if (in_array($_possible_parent_id, array_keys($dbids_to_orders))) |
|
200 | 200 | $menu_item_data['menu_item_parent'] = $_possible_parent_id; |
201 | 201 | else |
202 | 202 | $menu_item_data['menu_item_parent'] = 0; |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1; |
214 | 214 | |
215 | 215 | // Save changes. |
216 | - update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
216 | + update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); |
|
217 | 217 | wp_update_post($menu_item_data); |
218 | 218 | wp_update_post($parent_data); |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Else this menu item is not a child of the previous. |
222 | 222 | } elseif ( |
223 | - empty( $menu_item_data['menu_order'] ) || |
|
224 | - empty( $menu_item_data['menu_item_parent'] ) || |
|
225 | - ! in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) || |
|
226 | - empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) || |
|
223 | + empty($menu_item_data['menu_order']) || |
|
224 | + empty($menu_item_data['menu_item_parent']) || |
|
225 | + ! in_array($menu_item_data['menu_item_parent'], array_keys($dbids_to_orders)) || |
|
226 | + empty($orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]) || |
|
227 | 227 | $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent'] |
228 | 228 | ) { |
229 | 229 | // Just make it a child of the previous; keep the order. |
230 | 230 | $menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1]; |
231 | - update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] ); |
|
231 | + update_post_meta($menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent']); |
|
232 | 232 | wp_update_post($menu_item_data); |
233 | 233 | } |
234 | 234 | } |
@@ -239,244 +239,244 @@ discard block |
||
239 | 239 | case 'delete-menu-item': |
240 | 240 | $menu_item_id = (int) $_REQUEST['menu-item']; |
241 | 241 | |
242 | - check_admin_referer( 'delete-menu_item_' . $menu_item_id ); |
|
242 | + check_admin_referer('delete-menu_item_'.$menu_item_id); |
|
243 | 243 | |
244 | - if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) |
|
245 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('The menu item has been successfully deleted.') . '</p></div>'; |
|
244 | + if (is_nav_menu_item($menu_item_id) && wp_delete_post($menu_item_id, true)) |
|
245 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('The menu item has been successfully deleted.').'</p></div>'; |
|
246 | 246 | break; |
247 | 247 | |
248 | 248 | case 'delete': |
249 | - check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); |
|
250 | - if ( is_nav_menu( $nav_menu_selected_id ) ) { |
|
251 | - $deletion = wp_delete_nav_menu( $nav_menu_selected_id ); |
|
249 | + check_admin_referer('delete-nav_menu-'.$nav_menu_selected_id); |
|
250 | + if (is_nav_menu($nav_menu_selected_id)) { |
|
251 | + $deletion = wp_delete_nav_menu($nav_menu_selected_id); |
|
252 | 252 | } else { |
253 | 253 | // Reset the selected menu. |
254 | 254 | $nav_menu_selected_id = 0; |
255 | - unset( $_REQUEST['menu'] ); |
|
255 | + unset($_REQUEST['menu']); |
|
256 | 256 | } |
257 | 257 | |
258 | - if ( ! isset( $deletion ) ) |
|
258 | + if ( ! isset($deletion)) |
|
259 | 259 | break; |
260 | 260 | |
261 | - if ( is_wp_error( $deletion ) ) |
|
262 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
|
261 | + if (is_wp_error($deletion)) |
|
262 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.$deletion->get_error_message().'</p></div>'; |
|
263 | 263 | else |
264 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'The menu has been successfully deleted.' ) . '</p></div>'; |
|
264 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('The menu has been successfully deleted.').'</p></div>'; |
|
265 | 265 | break; |
266 | 266 | |
267 | 267 | case 'delete_menus': |
268 | - check_admin_referer( 'nav_menus_bulk_actions' ); |
|
269 | - foreach ( $_REQUEST['delete_menus'] as $menu_id_to_delete ) { |
|
270 | - if ( ! is_nav_menu( $menu_id_to_delete ) ) |
|
268 | + check_admin_referer('nav_menus_bulk_actions'); |
|
269 | + foreach ($_REQUEST['delete_menus'] as $menu_id_to_delete) { |
|
270 | + if ( ! is_nav_menu($menu_id_to_delete)) |
|
271 | 271 | continue; |
272 | 272 | |
273 | - $deletion = wp_delete_nav_menu( $menu_id_to_delete ); |
|
274 | - if ( is_wp_error( $deletion ) ) { |
|
275 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $deletion->get_error_message() . '</p></div>'; |
|
273 | + $deletion = wp_delete_nav_menu($menu_id_to_delete); |
|
274 | + if (is_wp_error($deletion)) { |
|
275 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.$deletion->get_error_message().'</p></div>'; |
|
276 | 276 | $deletion_error = true; |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | - if ( empty( $deletion_error ) ) |
|
281 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Selected menus have been successfully deleted.' ) . '</p></div>'; |
|
280 | + if (empty($deletion_error)) |
|
281 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('Selected menus have been successfully deleted.').'</p></div>'; |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | case 'update': |
285 | - check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
285 | + check_admin_referer('update-nav_menu', 'update-nav-menu-nonce'); |
|
286 | 286 | |
287 | 287 | // Remove menu locations that have been unchecked. |
288 | - foreach ( $locations as $location => $description ) { |
|
289 | - if ( ( empty( $_POST['menu-locations'] ) || empty( $_POST['menu-locations'][ $location ] ) ) && isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ) |
|
290 | - unset( $menu_locations[ $location ] ); |
|
288 | + foreach ($locations as $location => $description) { |
|
289 | + if ((empty($_POST['menu-locations']) || empty($_POST['menu-locations'][$location])) && isset($menu_locations[$location]) && $menu_locations[$location] == $nav_menu_selected_id) |
|
290 | + unset($menu_locations[$location]); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // Merge new and existing menu locations if any new ones are set. |
294 | - if ( isset( $_POST['menu-locations'] ) ) { |
|
295 | - $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
296 | - $menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
|
294 | + if (isset($_POST['menu-locations'])) { |
|
295 | + $new_menu_locations = array_map('absint', $_POST['menu-locations']); |
|
296 | + $menu_locations = array_merge($menu_locations, $new_menu_locations); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | // Set menu locations. |
300 | - set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
300 | + set_theme_mod('nav_menu_locations', $menu_locations); |
|
301 | 301 | |
302 | 302 | // Add Menu. |
303 | - if ( 0 == $nav_menu_selected_id ) { |
|
304 | - $new_menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
|
303 | + if (0 == $nav_menu_selected_id) { |
|
304 | + $new_menu_title = trim(esc_html($_POST['menu-name'])); |
|
305 | 305 | |
306 | - if ( $new_menu_title ) { |
|
307 | - $_nav_menu_selected_id = wp_update_nav_menu_object( 0, array('menu-name' => $new_menu_title) ); |
|
306 | + if ($new_menu_title) { |
|
307 | + $_nav_menu_selected_id = wp_update_nav_menu_object(0, array('menu-name' => $new_menu_title)); |
|
308 | 308 | |
309 | - if ( is_wp_error( $_nav_menu_selected_id ) ) { |
|
310 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
|
309 | + if (is_wp_error($_nav_menu_selected_id)) { |
|
310 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.$_nav_menu_selected_id->get_error_message().'</p></div>'; |
|
311 | 311 | } else { |
312 | - $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
|
312 | + $_menu_object = wp_get_nav_menu_object($_nav_menu_selected_id); |
|
313 | 313 | $nav_menu_selected_id = $_nav_menu_selected_id; |
314 | 314 | $nav_menu_selected_title = $_menu_object->name; |
315 | - if ( isset( $_REQUEST['menu-item'] ) ) |
|
316 | - wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); |
|
317 | - if ( isset( $_REQUEST['zero-menu-state'] ) ) { |
|
315 | + if (isset($_REQUEST['menu-item'])) |
|
316 | + wp_save_nav_menu_items($nav_menu_selected_id, absint($_REQUEST['menu-item'])); |
|
317 | + if (isset($_REQUEST['zero-menu-state'])) { |
|
318 | 318 | // If there are menu items, add them |
319 | - wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); |
|
319 | + wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title); |
|
320 | 320 | // Auto-save nav_menu_locations |
321 | 321 | $locations = get_nav_menu_locations(); |
322 | - foreach ( $locations as $location => $menu_id ) { |
|
323 | - $locations[ $location ] = $nav_menu_selected_id; |
|
322 | + foreach ($locations as $location => $menu_id) { |
|
323 | + $locations[$location] = $nav_menu_selected_id; |
|
324 | 324 | break; // There should only be 1 |
325 | 325 | } |
326 | - set_theme_mod( 'nav_menu_locations', $locations ); |
|
326 | + set_theme_mod('nav_menu_locations', $locations); |
|
327 | 327 | } |
328 | - if ( isset( $_REQUEST['use-location'] ) ) { |
|
328 | + if (isset($_REQUEST['use-location'])) { |
|
329 | 329 | $locations = get_registered_nav_menus(); |
330 | 330 | $menu_locations = get_nav_menu_locations(); |
331 | - if ( isset( $locations[ $_REQUEST['use-location'] ] ) ) |
|
332 | - $menu_locations[ $_REQUEST['use-location'] ] = $nav_menu_selected_id; |
|
333 | - set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
331 | + if (isset($locations[$_REQUEST['use-location']])) |
|
332 | + $menu_locations[$_REQUEST['use-location']] = $nav_menu_selected_id; |
|
333 | + set_theme_mod('nav_menu_locations', $menu_locations); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | // $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%s</strong> has been created.' ), $nav_menu_selected_title ) . '</p></div>'; |
337 | - wp_redirect( admin_url( 'nav-menus.php?menu=' . $_nav_menu_selected_id ) ); |
|
337 | + wp_redirect(admin_url('nav-menus.php?menu='.$_nav_menu_selected_id)); |
|
338 | 338 | exit(); |
339 | 339 | } |
340 | 340 | } else { |
341 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
|
341 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.__('Please enter a valid menu name.').'</p></div>'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Update existing menu. |
345 | 345 | } else { |
346 | 346 | |
347 | - $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
|
347 | + $_menu_object = wp_get_nav_menu_object($nav_menu_selected_id); |
|
348 | 348 | |
349 | - $menu_title = trim( esc_html( $_POST['menu-name'] ) ); |
|
350 | - if ( ! $menu_title ) { |
|
351 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __( 'Please enter a valid menu name.' ) . '</p></div>'; |
|
349 | + $menu_title = trim(esc_html($_POST['menu-name'])); |
|
350 | + if ( ! $menu_title) { |
|
351 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.__('Please enter a valid menu name.').'</p></div>'; |
|
352 | 352 | $menu_title = $_menu_object->name; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ! is_wp_error( $_menu_object ) ) { |
|
356 | - $_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) ); |
|
357 | - if ( is_wp_error( $_nav_menu_selected_id ) ) { |
|
355 | + if ( ! is_wp_error($_menu_object)) { |
|
356 | + $_nav_menu_selected_id = wp_update_nav_menu_object($nav_menu_selected_id, array('menu-name' => $menu_title)); |
|
357 | + if (is_wp_error($_nav_menu_selected_id)) { |
|
358 | 358 | $_menu_object = $_nav_menu_selected_id; |
359 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>'; |
|
359 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>'.$_nav_menu_selected_id->get_error_message().'</p></div>'; |
|
360 | 360 | } else { |
361 | - $_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id ); |
|
361 | + $_menu_object = wp_get_nav_menu_object($_nav_menu_selected_id); |
|
362 | 362 | $nav_menu_selected_title = $_menu_object->name; |
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | 366 | // Update menu items. |
367 | - if ( ! is_wp_error( $_menu_object ) ) { |
|
368 | - $messages = array_merge( $messages, wp_nav_menu_update_menu_items( $_nav_menu_selected_id, $nav_menu_selected_title ) ); |
|
367 | + if ( ! is_wp_error($_menu_object)) { |
|
368 | + $messages = array_merge($messages, wp_nav_menu_update_menu_items($_nav_menu_selected_id, $nav_menu_selected_title)); |
|
369 | 369 | |
370 | 370 | // If the menu ID changed, redirect to the new URL. |
371 | - if ( $nav_menu_selected_id != $_nav_menu_selected_id ) { |
|
372 | - wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) ); |
|
371 | + if ($nav_menu_selected_id != $_nav_menu_selected_id) { |
|
372 | + wp_redirect(admin_url('nav-menus.php?menu='.intval($_nav_menu_selected_id))); |
|
373 | 373 | exit(); |
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
377 | 377 | break; |
378 | 378 | case 'locations': |
379 | - if ( ! $num_locations ) { |
|
380 | - wp_redirect( admin_url( 'nav-menus.php' ) ); |
|
379 | + if ( ! $num_locations) { |
|
380 | + wp_redirect(admin_url('nav-menus.php')); |
|
381 | 381 | exit(); |
382 | 382 | } |
383 | 383 | |
384 | - add_filter( 'screen_options_show_screen', '__return_false' ); |
|
384 | + add_filter('screen_options_show_screen', '__return_false'); |
|
385 | 385 | |
386 | - if ( isset( $_POST['menu-locations'] ) ) { |
|
387 | - check_admin_referer( 'save-menu-locations' ); |
|
386 | + if (isset($_POST['menu-locations'])) { |
|
387 | + check_admin_referer('save-menu-locations'); |
|
388 | 388 | |
389 | - $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); |
|
390 | - $menu_locations = array_merge( $menu_locations, $new_menu_locations ); |
|
389 | + $new_menu_locations = array_map('absint', $_POST['menu-locations']); |
|
390 | + $menu_locations = array_merge($menu_locations, $new_menu_locations); |
|
391 | 391 | // Set menu locations |
392 | - set_theme_mod( 'nav_menu_locations', $menu_locations ); |
|
392 | + set_theme_mod('nav_menu_locations', $menu_locations); |
|
393 | 393 | |
394 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; |
|
394 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'.__('Menu locations updated.').'</p></div>'; |
|
395 | 395 | } |
396 | 396 | break; |
397 | 397 | } |
398 | 398 | |
399 | 399 | // Get all nav menus. |
400 | 400 | $nav_menus = wp_get_nav_menus(); |
401 | -$menu_count = count( $nav_menus ); |
|
401 | +$menu_count = count($nav_menus); |
|
402 | 402 | |
403 | 403 | // Are we on the add new screen? |
404 | -$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false; |
|
404 | +$add_new_screen = (isset($_GET['menu']) && 0 == $_GET['menu']) ? true : false; |
|
405 | 405 | |
406 | -$locations_screen = ( isset( $_GET['action'] ) && 'locations' == $_GET['action'] ) ? true : false; |
|
406 | +$locations_screen = (isset($_GET['action']) && 'locations' == $_GET['action']) ? true : false; |
|
407 | 407 | |
408 | 408 | /* |
409 | 409 | * If we have one theme location, and zero menus, we take them right |
410 | 410 | * into editing their first menu. |
411 | 411 | */ |
412 | -$page_count = wp_count_posts( 'page' ); |
|
413 | -$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false; |
|
412 | +$page_count = wp_count_posts('page'); |
|
413 | +$one_theme_location_no_menus = (1 == count(get_registered_nav_menus()) && ! $add_new_screen && empty($nav_menus) && ! empty($page_count->publish)) ? true : false; |
|
414 | 414 | |
415 | 415 | $nav_menus_l10n = array( |
416 | 416 | 'oneThemeLocationNoMenus' => $one_theme_location_no_menus, |
417 | - 'moveUp' => __( 'Move up one' ), |
|
418 | - 'moveDown' => __( 'Move down one' ), |
|
419 | - 'moveToTop' => __( 'Move to the top' ), |
|
417 | + 'moveUp' => __('Move up one'), |
|
418 | + 'moveDown' => __('Move down one'), |
|
419 | + 'moveToTop' => __('Move to the top'), |
|
420 | 420 | /* translators: %s: previous item name */ |
421 | - 'moveUnder' => __( 'Move under %s' ), |
|
421 | + 'moveUnder' => __('Move under %s'), |
|
422 | 422 | /* translators: %s: previous item name */ |
423 | - 'moveOutFrom' => __( 'Move out from under %s' ), |
|
423 | + 'moveOutFrom' => __('Move out from under %s'), |
|
424 | 424 | /* translators: %s: previous item name */ |
425 | - 'under' => __( 'Under %s' ), |
|
425 | + 'under' => __('Under %s'), |
|
426 | 426 | /* translators: %s: previous item name */ |
427 | - 'outFrom' => __( 'Out from under %s' ), |
|
427 | + 'outFrom' => __('Out from under %s'), |
|
428 | 428 | /* translators: 1: item name, 2: item position, 3: total number of items */ |
429 | - 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), |
|
429 | + 'menuFocus' => __('%1$s. Menu item %2$d of %3$d.'), |
|
430 | 430 | /* translators: 1: item name, 2: item position, 3: parent item name */ |
431 | - 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), |
|
431 | + 'subMenuFocus' => __('%1$s. Sub item number %2$d under %3$s.'), |
|
432 | 432 | ); |
433 | -wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
|
433 | +wp_localize_script('nav-menu', 'menus', $nav_menus_l10n); |
|
434 | 434 | |
435 | 435 | /* |
436 | 436 | * Redirect to add screen if there are no menus and this users has either zero, |
437 | 437 | * or more than 1 theme locations. |
438 | 438 | */ |
439 | -if ( 0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus ) |
|
440 | - wp_redirect( admin_url( 'nav-menus.php?action=edit&menu=0' ) ); |
|
439 | +if (0 == $menu_count && ! $add_new_screen && ! $one_theme_location_no_menus) |
|
440 | + wp_redirect(admin_url('nav-menus.php?action=edit&menu=0')); |
|
441 | 441 | |
442 | 442 | // Get recently edited nav menu. |
443 | -$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) ); |
|
444 | -if ( empty( $recently_edited ) && is_nav_menu( $nav_menu_selected_id ) ) |
|
443 | +$recently_edited = absint(get_user_option('nav_menu_recently_edited')); |
|
444 | +if (empty($recently_edited) && is_nav_menu($nav_menu_selected_id)) |
|
445 | 445 | $recently_edited = $nav_menu_selected_id; |
446 | 446 | |
447 | 447 | // Use $recently_edited if none are selected. |
448 | -if ( empty( $nav_menu_selected_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) |
|
448 | +if (empty($nav_menu_selected_id) && ! isset($_GET['menu']) && is_nav_menu($recently_edited)) |
|
449 | 449 | $nav_menu_selected_id = $recently_edited; |
450 | 450 | |
451 | 451 | // On deletion of menu, if another menu exists, show it. |
452 | -if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) |
|
452 | +if ( ! $add_new_screen && 0 < $menu_count && isset($_GET['action']) && 'delete' == $_GET['action']) |
|
453 | 453 | $nav_menu_selected_id = $nav_menus[0]->term_id; |
454 | 454 | |
455 | 455 | // Set $nav_menu_selected_id to 0 if no menus. |
456 | -if ( $one_theme_location_no_menus ) { |
|
456 | +if ($one_theme_location_no_menus) { |
|
457 | 457 | $nav_menu_selected_id = 0; |
458 | -} elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) { |
|
458 | +} elseif (empty($nav_menu_selected_id) && ! empty($nav_menus) && ! $add_new_screen) { |
|
459 | 459 | // if we have no selection yet, and we have menus, set to the first one in the list. |
460 | 460 | $nav_menu_selected_id = $nav_menus[0]->term_id; |
461 | 461 | } |
462 | 462 | |
463 | 463 | // Update the user's setting. |
464 | -if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) ) |
|
465 | - update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id ); |
|
464 | +if ($nav_menu_selected_id != $recently_edited && is_nav_menu($nav_menu_selected_id)) |
|
465 | + update_user_meta($current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id); |
|
466 | 466 | |
467 | 467 | // If there's a menu, get its name. |
468 | -if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) { |
|
469 | - $_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id ); |
|
470 | - $nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : ''; |
|
468 | +if ( ! $nav_menu_selected_title && is_nav_menu($nav_menu_selected_id)) { |
|
469 | + $_menu_object = wp_get_nav_menu_object($nav_menu_selected_id); |
|
470 | + $nav_menu_selected_title = ! is_wp_error($_menu_object) ? $_menu_object->name : ''; |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Generate truncated menu names. |
474 | -foreach ( (array) $nav_menus as $key => $_nav_menu ) { |
|
475 | - $nav_menus[$key]->truncated_name = wp_html_excerpt( $_nav_menu->name, 40, '…' ); |
|
474 | +foreach ((array) $nav_menus as $key => $_nav_menu) { |
|
475 | + $nav_menus[$key]->truncated_name = wp_html_excerpt($_nav_menu->name, 40, '…'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // Retrieve menu locations. |
479 | -if ( current_theme_supports( 'menus' ) ) { |
|
479 | +if (current_theme_supports('menus')) { |
|
480 | 480 | $locations = get_registered_nav_menus(); |
481 | 481 | $menu_locations = get_nav_menu_locations(); |
482 | 482 | } |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | $_wp_nav_menu_max_depth = 0; |
492 | 492 | |
493 | 493 | // Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth. |
494 | -if ( is_nav_menu( $nav_menu_selected_id ) ) { |
|
495 | - $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'post_status' => 'any' ) ); |
|
496 | - $edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id ); |
|
494 | +if (is_nav_menu($nav_menu_selected_id)) { |
|
495 | + $menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('post_status' => 'any')); |
|
496 | + $edit_markup = wp_get_nav_menu_to_edit($nav_menu_selected_id); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @param string $classes |
504 | 504 | * @return string |
505 | 505 | */ |
506 | -function wp_nav_menu_max_depth( $classes ) { |
|
506 | +function wp_nav_menu_max_depth($classes) { |
|
507 | 507 | global $_wp_nav_menu_max_depth; |
508 | 508 | return "$classes menu-max-depth-$_wp_nav_menu_max_depth"; |
509 | 509 | } |
@@ -513,80 +513,80 @@ discard block |
||
513 | 513 | wp_nav_menu_setup(); |
514 | 514 | wp_initial_nav_menu_meta_boxes(); |
515 | 515 | |
516 | -if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) |
|
517 | - $messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'Your theme does not natively support menus, but you can use them in sidebars by adding a “Custom Menu” widget on the <a href="%s">Widgets</a> screen.' ), admin_url( 'widgets.php' ) ) . '</p></div>'; |
|
516 | +if ( ! current_theme_supports('menus') && ! $num_locations) |
|
517 | + $messages[] = '<div id="message" class="updated"><p>'.sprintf(__('Your theme does not natively support menus, but you can use them in sidebars by adding a “Custom Menu” widget on the <a href="%s">Widgets</a> screen.'), admin_url('widgets.php')).'</p></div>'; |
|
518 | 518 | |
519 | -if ( ! $locations_screen ) : // Main tab |
|
520 | - $overview = '<p>' . __( 'This screen is used for managing your custom navigation menus.' ) . '</p>'; |
|
519 | +if ( ! $locations_screen) : // Main tab |
|
520 | + $overview = '<p>'.__('This screen is used for managing your custom navigation menus.').'</p>'; |
|
521 | 521 | /* translators: 1: Widgets admin screen URL, 2 and 3: The name of the default themes */ |
522 | - $overview .= '<p>' . sprintf( __( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a “Custom Menu” widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the custom menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ), admin_url( 'widgets.php' ), 'Twenty Sixteen', 'Twenty Seventeen' ) . '</p>'; |
|
523 | - $overview .= '<p>' . __( 'From this screen you can:' ) . '</p>'; |
|
524 | - $overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>'; |
|
525 | - $overview .= '<li>' . __( 'Add, organize, and modify individual menu items' ) . '</li></ul>'; |
|
522 | + $overview .= '<p>'.sprintf(__('Menus can be displayed in locations defined by your theme, even used in sidebars by adding a “Custom Menu” widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the custom menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.'), admin_url('widgets.php'), 'Twenty Sixteen', 'Twenty Seventeen').'</p>'; |
|
523 | + $overview .= '<p>'.__('From this screen you can:').'</p>'; |
|
524 | + $overview .= '<ul><li>'.__('Create, edit, and delete menus').'</li>'; |
|
525 | + $overview .= '<li>'.__('Add, organize, and modify individual menu items').'</li></ul>'; |
|
526 | 526 | |
527 | - get_current_screen()->add_help_tab( array( |
|
527 | + get_current_screen()->add_help_tab(array( |
|
528 | 528 | 'id' => 'overview', |
529 | - 'title' => __( 'Overview' ), |
|
529 | + 'title' => __('Overview'), |
|
530 | 530 | 'content' => $overview |
531 | - ) ); |
|
531 | + )); |
|
532 | 532 | |
533 | - $menu_management = '<p>' . __( 'The menu management box at the top of the screen is used to control which menu is opened in the editor below.' ) . '</p>'; |
|
534 | - $menu_management .= '<ul><li>' . __( 'To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>' ) . '</li>'; |
|
535 | - $menu_management .= '<li>' . __( 'If you haven’t yet created any menus, <strong>click the ’create a new menu’ link</strong> to get started' ) . '</li></ul>'; |
|
536 | - $menu_management .= '<p>' . __( 'You can assign theme locations to individual menus by <strong>selecting the desired settings</strong> at the bottom of the menu editor. To assign menus to all theme locations at once, <strong>visit the Manage Locations tab</strong> at the top of the screen.' ) . '</p>'; |
|
533 | + $menu_management = '<p>'.__('The menu management box at the top of the screen is used to control which menu is opened in the editor below.').'</p>'; |
|
534 | + $menu_management .= '<ul><li>'.__('To edit an existing menu, <strong>choose a menu from the drop down and click Select</strong>').'</li>'; |
|
535 | + $menu_management .= '<li>'.__('If you haven’t yet created any menus, <strong>click the ’create a new menu’ link</strong> to get started').'</li></ul>'; |
|
536 | + $menu_management .= '<p>'.__('You can assign theme locations to individual menus by <strong>selecting the desired settings</strong> at the bottom of the menu editor. To assign menus to all theme locations at once, <strong>visit the Manage Locations tab</strong> at the top of the screen.').'</p>'; |
|
537 | 537 | |
538 | - get_current_screen()->add_help_tab( array( |
|
538 | + get_current_screen()->add_help_tab(array( |
|
539 | 539 | 'id' => 'menu-management', |
540 | - 'title' => __( 'Menu Management' ), |
|
540 | + 'title' => __('Menu Management'), |
|
541 | 541 | 'content' => $menu_management |
542 | - ) ); |
|
542 | + )); |
|
543 | 543 | |
544 | - $editing_menus = '<p>' . __( 'Each custom menu may contain a mix of links to pages, categories, custom URLs or other content types. Menu links are added by selecting items from the expanding boxes in the left-hand column below.' ) . '</p>'; |
|
545 | - $editing_menus .= '<p>' . __( '<strong>Clicking the arrow to the right of any menu item</strong> in the editor will reveal a standard group of settings. Additional settings such as link target, CSS classes, link relationships, and link descriptions can be enabled and disabled via the Screen Options tab.' ) . '</p>'; |
|
546 | - $editing_menus .= '<ul><li>' . __( 'Add one or several items at once by <strong>selecting the checkbox next to each item and clicking Add to Menu</strong>' ) . '</li>'; |
|
547 | - $editing_menus .= '<li>' . __( 'To add a custom link, <strong>expand the Custom Links section, enter a URL and link text, and click Add to Menu</strong>' ) .'</li>'; |
|
548 | - $editing_menus .= '<li>' . __( 'To reorganize menu items, <strong>drag and drop items with your mouse or use your keyboard</strong>. Drag or move a menu item a little to the right to make it a submenu' ) . '</li>'; |
|
549 | - $editing_menus .= '<li>' . __( 'Delete a menu item by <strong>expanding it and clicking the Remove link</strong>' ) . '</li></ul>'; |
|
544 | + $editing_menus = '<p>'.__('Each custom menu may contain a mix of links to pages, categories, custom URLs or other content types. Menu links are added by selecting items from the expanding boxes in the left-hand column below.').'</p>'; |
|
545 | + $editing_menus .= '<p>'.__('<strong>Clicking the arrow to the right of any menu item</strong> in the editor will reveal a standard group of settings. Additional settings such as link target, CSS classes, link relationships, and link descriptions can be enabled and disabled via the Screen Options tab.').'</p>'; |
|
546 | + $editing_menus .= '<ul><li>'.__('Add one or several items at once by <strong>selecting the checkbox next to each item and clicking Add to Menu</strong>').'</li>'; |
|
547 | + $editing_menus .= '<li>'.__('To add a custom link, <strong>expand the Custom Links section, enter a URL and link text, and click Add to Menu</strong>').'</li>'; |
|
548 | + $editing_menus .= '<li>'.__('To reorganize menu items, <strong>drag and drop items with your mouse or use your keyboard</strong>. Drag or move a menu item a little to the right to make it a submenu').'</li>'; |
|
549 | + $editing_menus .= '<li>'.__('Delete a menu item by <strong>expanding it and clicking the Remove link</strong>').'</li></ul>'; |
|
550 | 550 | |
551 | - get_current_screen()->add_help_tab( array( |
|
551 | + get_current_screen()->add_help_tab(array( |
|
552 | 552 | 'id' => 'editing-menus', |
553 | - 'title' => __( 'Editing Menus' ), |
|
553 | + 'title' => __('Editing Menus'), |
|
554 | 554 | 'content' => $editing_menus |
555 | - ) ); |
|
555 | + )); |
|
556 | 556 | else : // Locations Tab. |
557 | - $locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; |
|
558 | - $locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>' ) . '</li>'; |
|
559 | - $locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; |
|
560 | - $locations_overview .= '<li>' . __( 'To add a new menu instead of assigning an existing one, <strong>click the ’Use new menu’ link</strong>. Your new menu will be automatically assigned to that theme location' ) . '</li></ul>'; |
|
557 | + $locations_overview = '<p>'.__('This screen is used for globally assigning menus to locations defined by your theme.').'</p>'; |
|
558 | + $locations_overview .= '<ul><li>'.__('To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>').'</li>'; |
|
559 | + $locations_overview .= '<li>'.__('To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>').'</li>'; |
|
560 | + $locations_overview .= '<li>'.__('To add a new menu instead of assigning an existing one, <strong>click the ’Use new menu’ link</strong>. Your new menu will be automatically assigned to that theme location').'</li></ul>'; |
|
561 | 561 | |
562 | - get_current_screen()->add_help_tab( array( |
|
562 | + get_current_screen()->add_help_tab(array( |
|
563 | 563 | 'id' => 'locations-overview', |
564 | - 'title' => __( 'Overview' ), |
|
564 | + 'title' => __('Overview'), |
|
565 | 565 | 'content' => $locations_overview |
566 | - ) ); |
|
566 | + )); |
|
567 | 567 | endif; |
568 | 568 | |
569 | 569 | get_current_screen()->set_help_sidebar( |
570 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
571 | - '<p>' . __('<a href="https://codex.wordpress.org/Appearance_Menus_Screen">Documentation on Menus</a>') . '</p>' . |
|
572 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
570 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
571 | + '<p>'.__('<a href="https://codex.wordpress.org/Appearance_Menus_Screen">Documentation on Menus</a>').'</p>'. |
|
572 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
573 | 573 | ); |
574 | 574 | |
575 | 575 | // Get the admin header. |
576 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
576 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
577 | 577 | ?> |
578 | 578 | <div class="wrap"> |
579 | - <h1 class="wp-heading-inline"><?php echo esc_html( __( 'Menus' ) ); ?></h1> |
|
579 | + <h1 class="wp-heading-inline"><?php echo esc_html(__('Menus')); ?></h1> |
|
580 | 580 | <?php |
581 | - if ( current_user_can( 'customize' ) ) : |
|
582 | - $focus = $locations_screen ? array( 'section' => 'menu_locations' ) : array( 'panel' => 'nav_menus' ); |
|
581 | + if (current_user_can('customize')) : |
|
582 | + $focus = $locations_screen ? array('section' => 'menu_locations') : array('panel' => 'nav_menus'); |
|
583 | 583 | printf( |
584 | 584 | ' <a class="page-title-action hide-if-no-customize" href="%1$s">%2$s</a>', |
585 | - esc_url( add_query_arg( array( |
|
586 | - array( 'autofocus' => $focus ), |
|
587 | - 'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
588 | - ), admin_url( 'customize.php' ) ) ), |
|
589 | - __( 'Manage with Live Preview' ) |
|
585 | + esc_url(add_query_arg(array( |
|
586 | + array('autofocus' => $focus), |
|
587 | + 'return' => urlencode(wp_unslash($_SERVER['REQUEST_URI'])), |
|
588 | + ), admin_url('customize.php'))), |
|
589 | + __('Manage with Live Preview') |
|
590 | 590 | ); |
591 | 591 | endif; |
592 | 592 | ?> |
@@ -594,60 +594,60 @@ discard block |
||
594 | 594 | <hr class="wp-header-end"> |
595 | 595 | |
596 | 596 | <h2 class="nav-tab-wrapper wp-clearfix"> |
597 | - <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php if ( ! isset( $_GET['action'] ) || isset( $_GET['action'] ) && 'locations' != $_GET['action'] ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Edit Menus' ); ?></a> |
|
598 | - <?php if ( $num_locations && $menu_count ) : ?> |
|
599 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>" class="nav-tab<?php if ( $locations_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Manage Locations' ); ?></a> |
|
597 | + <a href="<?php echo admin_url('nav-menus.php'); ?>" class="nav-tab<?php if ( ! isset($_GET['action']) || isset($_GET['action']) && 'locations' != $_GET['action']) echo ' nav-tab-active'; ?>"><?php esc_html_e('Edit Menus'); ?></a> |
|
598 | + <?php if ($num_locations && $menu_count) : ?> |
|
599 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'locations'), admin_url('nav-menus.php'))); ?>" class="nav-tab<?php if ($locations_screen) echo ' nav-tab-active'; ?>"><?php esc_html_e('Manage Locations'); ?></a> |
|
600 | 600 | <?php |
601 | 601 | endif; |
602 | 602 | ?> |
603 | 603 | </h2> |
604 | 604 | <?php |
605 | - foreach ( $messages as $message ) : |
|
606 | - echo $message . "\n"; |
|
605 | + foreach ($messages as $message) : |
|
606 | + echo $message."\n"; |
|
607 | 607 | endforeach; |
608 | 608 | ?> |
609 | 609 | <?php |
610 | - if ( $locations_screen ) : |
|
611 | - if ( 1 == $num_locations ) { |
|
612 | - echo '<p>' . __( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>'; |
|
610 | + if ($locations_screen) : |
|
611 | + if (1 == $num_locations) { |
|
612 | + echo '<p>'.__('Your theme supports one menu. Select which menu you would like to use.').'</p>'; |
|
613 | 613 | } else { |
614 | - echo '<p>' . sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . '</p>'; |
|
614 | + echo '<p>'.sprintf(_n('Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations), number_format_i18n($num_locations)).'</p>'; |
|
615 | 615 | } |
616 | 616 | ?> |
617 | 617 | <div id="menu-locations-wrap"> |
618 | - <form method="post" action="<?php echo esc_url( add_query_arg( array( 'action' => 'locations' ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
618 | + <form method="post" action="<?php echo esc_url(add_query_arg(array('action' => 'locations'), admin_url('nav-menus.php'))); ?>"> |
|
619 | 619 | <table class="widefat fixed" id="menu-locations-table"> |
620 | 620 | <thead> |
621 | 621 | <tr> |
622 | - <th scope="col" class="manage-column column-locations"><?php _e( 'Theme Location' ); ?></th> |
|
623 | - <th scope="col" class="manage-column column-menus"><?php _e( 'Assigned Menu' ); ?></th> |
|
622 | + <th scope="col" class="manage-column column-locations"><?php _e('Theme Location'); ?></th> |
|
623 | + <th scope="col" class="manage-column column-menus"><?php _e('Assigned Menu'); ?></th> |
|
624 | 624 | </tr> |
625 | 625 | </thead> |
626 | 626 | <tbody class="menu-locations"> |
627 | - <?php foreach ( $locations as $_location => $_name ) { ?> |
|
627 | + <?php foreach ($locations as $_location => $_name) { ?> |
|
628 | 628 | <tr class="menu-locations-row"> |
629 | 629 | <td class="menu-location-title"><label for="locations-<?php echo $_location; ?>"><?php echo $_name; ?></label></td> |
630 | 630 | <td class="menu-location-menus"> |
631 | 631 | <select name="menu-locations[<?php echo $_location; ?>]" id="locations-<?php echo $_location; ?>"> |
632 | - <option value="0"><?php printf( '— %s —', esc_html__( 'Select a Menu' ) ); ?></option> |
|
633 | - <?php foreach ( $nav_menus as $menu ) : ?> |
|
634 | - <?php $selected = isset( $menu_locations[$_location] ) && $menu_locations[$_location] == $menu->term_id; ?> |
|
635 | - <option <?php if ( $selected ) echo 'data-orig="true"'; ?> <?php selected( $selected ); ?> value="<?php echo $menu->term_id; ?>"> |
|
636 | - <?php echo wp_html_excerpt( $menu->name, 40, '…' ); ?> |
|
632 | + <option value="0"><?php printf('— %s —', esc_html__('Select a Menu')); ?></option> |
|
633 | + <?php foreach ($nav_menus as $menu) : ?> |
|
634 | + <?php $selected = isset($menu_locations[$_location]) && $menu_locations[$_location] == $menu->term_id; ?> |
|
635 | + <option <?php if ($selected) echo 'data-orig="true"'; ?> <?php selected($selected); ?> value="<?php echo $menu->term_id; ?>"> |
|
636 | + <?php echo wp_html_excerpt($menu->name, 40, '…'); ?> |
|
637 | 637 | </option> |
638 | 638 | <?php endforeach; ?> |
639 | 639 | </select> |
640 | 640 | <div class="locations-row-links"> |
641 | - <?php if ( isset( $menu_locations[ $_location ] ) && 0 != $menu_locations[ $_location ] ) : ?> |
|
641 | + <?php if (isset($menu_locations[$_location]) && 0 != $menu_locations[$_location]) : ?> |
|
642 | 642 | <span class="locations-edit-menu-link"> |
643 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => $menu_locations[$_location] ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
644 | - <span aria-hidden="true"><?php _ex( 'Edit', 'menu' ); ?></span><span class="screen-reader-text"><?php _e( 'Edit selected menu' ); ?></span> |
|
643 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'edit', 'menu' => $menu_locations[$_location]), admin_url('nav-menus.php'))); ?>"> |
|
644 | + <span aria-hidden="true"><?php _ex('Edit', 'menu'); ?></span><span class="screen-reader-text"><?php _e('Edit selected menu'); ?></span> |
|
645 | 645 | </a> |
646 | 646 | </span> |
647 | 647 | <?php endif; ?> |
648 | 648 | <span class="locations-add-menu-link"> |
649 | - <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0, 'use-location' => $_location ), admin_url( 'nav-menus.php' ) ) ); ?>"> |
|
650 | - <?php _ex( 'Use new menu', 'menu' ); ?> |
|
649 | + <a href="<?php echo esc_url(add_query_arg(array('action' => 'edit', 'menu' => 0, 'use-location' => $_location), admin_url('nav-menus.php'))); ?>"> |
|
650 | + <?php _ex('Use new menu', 'menu'); ?> |
|
651 | 651 | </a> |
652 | 652 | </span> |
653 | 653 | </div><!-- .locations-row-links --> |
@@ -656,9 +656,9 @@ discard block |
||
656 | 656 | <?php } // foreach ?> |
657 | 657 | </tbody> |
658 | 658 | </table> |
659 | - <p class="button-controls wp-clearfix"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> |
|
660 | - <?php wp_nonce_field( 'save-menu-locations' ); ?> |
|
661 | - <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
659 | + <p class="button-controls wp-clearfix"><?php submit_button(__('Save Changes'), 'primary left', 'nav-menu-locations', false); ?></p> |
|
660 | + <?php wp_nonce_field('save-menu-locations'); ?> |
|
661 | + <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr($nav_menu_selected_id); ?>" /> |
|
662 | 662 | </form> |
663 | 663 | </div><!-- #menu-locations-wrap --> |
664 | 664 | <?php |
@@ -667,31 +667,31 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @since 3.6.0 |
669 | 669 | */ |
670 | - do_action( 'after_menu_locations_table' ); ?> |
|
670 | + do_action('after_menu_locations_table'); ?> |
|
671 | 671 | <?php else : ?> |
672 | 672 | <div class="manage-menus"> |
673 | - <?php if ( $menu_count < 2 ) : ?> |
|
673 | + <?php if ($menu_count < 2) : ?> |
|
674 | 674 | <span class="add-edit-menu-action"> |
675 | - <?php printf( __( 'Edit your menu below, or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> |
|
675 | + <?php printf(__('Edit your menu below, or <a href="%s">create a new menu</a>.'), esc_url(add_query_arg(array('action' => 'edit', 'menu' => 0), admin_url('nav-menus.php')))); ?> |
|
676 | 676 | </span><!-- /add-edit-menu-action --> |
677 | 677 | <?php else : ?> |
678 | - <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>"> |
|
678 | + <form method="get" action="<?php echo admin_url('nav-menus.php'); ?>"> |
|
679 | 679 | <input type="hidden" name="action" value="edit" /> |
680 | - <label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label> |
|
680 | + <label for="select-menu-to-edit" class="selected-menu"><?php _e('Select a menu to edit:'); ?></label> |
|
681 | 681 | <select name="menu" id="select-menu-to-edit"> |
682 | - <?php if ( $add_new_screen ) : ?> |
|
683 | - <option value="0" selected="selected"><?php _e( '— Select —' ); ?></option> |
|
682 | + <?php if ($add_new_screen) : ?> |
|
683 | + <option value="0" selected="selected"><?php _e('— Select —'); ?></option> |
|
684 | 684 | <?php endif; ?> |
685 | - <?php foreach ( (array) $nav_menus as $_nav_menu ) : ?> |
|
686 | - <option value="<?php echo esc_attr( $_nav_menu->term_id ); ?>" <?php selected( $_nav_menu->term_id, $nav_menu_selected_id ); ?>> |
|
685 | + <?php foreach ((array) $nav_menus as $_nav_menu) : ?> |
|
686 | + <option value="<?php echo esc_attr($_nav_menu->term_id); ?>" <?php selected($_nav_menu->term_id, $nav_menu_selected_id); ?>> |
|
687 | 687 | <?php |
688 | - echo esc_html( $_nav_menu->truncated_name ) ; |
|
688 | + echo esc_html($_nav_menu->truncated_name); |
|
689 | 689 | |
690 | - if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) { |
|
690 | + if ( ! empty($menu_locations) && in_array($_nav_menu->term_id, $menu_locations)) { |
|
691 | 691 | $locations_assigned_to_this_menu = array(); |
692 | - foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) { |
|
693 | - if ( isset( $locations[ $menu_location_key ] ) ) { |
|
694 | - $locations_assigned_to_this_menu[] = $locations[ $menu_location_key ]; |
|
692 | + foreach (array_keys($menu_locations, $_nav_menu->term_id) as $menu_location_key) { |
|
693 | + if (isset($locations[$menu_location_key])) { |
|
694 | + $locations_assigned_to_this_menu[] = $locations[$menu_location_key]; |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
@@ -702,13 +702,13 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @param int $locations Number of menu locations to list. Default 3. |
704 | 704 | */ |
705 | - $assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) ); |
|
705 | + $assigned_locations = array_slice($locations_assigned_to_this_menu, 0, absint(apply_filters('wp_nav_locations_listed_per_menu', 3))); |
|
706 | 706 | |
707 | 707 | // Adds ellipses following the number of locations defined in $assigned_locations. |
708 | - if ( ! empty( $assigned_locations ) ) { |
|
709 | - printf( ' (%1$s%2$s)', |
|
710 | - implode( ', ', $assigned_locations ), |
|
711 | - count( $locations_assigned_to_this_menu ) > count( $assigned_locations ) ? ' …' : '' |
|
708 | + if ( ! empty($assigned_locations)) { |
|
709 | + printf(' (%1$s%2$s)', |
|
710 | + implode(', ', $assigned_locations), |
|
711 | + count($locations_assigned_to_this_menu) > count($assigned_locations) ? ' …' : '' |
|
712 | 712 | ); |
713 | 713 | } |
714 | 714 | } |
@@ -716,111 +716,111 @@ discard block |
||
716 | 716 | </option> |
717 | 717 | <?php endforeach; ?> |
718 | 718 | </select> |
719 | - <span class="submit-btn"><input type="submit" class="button" value="<?php esc_attr_e( 'Select' ); ?>"></span> |
|
719 | + <span class="submit-btn"><input type="submit" class="button" value="<?php esc_attr_e('Select'); ?>"></span> |
|
720 | 720 | <span class="add-new-menu-action"> |
721 | - <?php printf( __( 'or <a href="%s">create a new menu</a>.' ), esc_url( add_query_arg( array( 'action' => 'edit', 'menu' => 0 ), admin_url( 'nav-menus.php' ) ) ) ); ?> |
|
721 | + <?php printf(__('or <a href="%s">create a new menu</a>.'), esc_url(add_query_arg(array('action' => 'edit', 'menu' => 0), admin_url('nav-menus.php')))); ?> |
|
722 | 722 | </span><!-- /add-new-menu-action --> |
723 | 723 | </form> |
724 | 724 | <?php endif; ?> |
725 | 725 | </div><!-- /manage-menus --> |
726 | 726 | <div id="nav-menus-frame" class="wp-clearfix"> |
727 | - <div id="menu-settings-column" class="metabox-holder<?php if ( isset( $_GET['menu'] ) && '0' == $_GET['menu'] ) { echo ' metabox-holder-disabled'; } ?>"> |
|
727 | + <div id="menu-settings-column" class="metabox-holder<?php if (isset($_GET['menu']) && '0' == $_GET['menu']) { echo ' metabox-holder-disabled'; } ?>"> |
|
728 | 728 | |
729 | 729 | <div class="clear"></div> |
730 | 730 | |
731 | 731 | <form id="nav-menu-meta" class="nav-menu-meta" method="post" enctype="multipart/form-data"> |
732 | - <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
732 | + <input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr($nav_menu_selected_id); ?>" /> |
|
733 | 733 | <input type="hidden" name="action" value="add-menu-item" /> |
734 | - <?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?> |
|
735 | - <?php do_accordion_sections( 'nav-menus', 'side', null ); ?> |
|
734 | + <?php wp_nonce_field('add-menu_item', 'menu-settings-column-nonce'); ?> |
|
735 | + <?php do_accordion_sections('nav-menus', 'side', null); ?> |
|
736 | 736 | </form> |
737 | 737 | |
738 | 738 | </div><!-- /#menu-settings-column --> |
739 | 739 | <div id="menu-management-liquid"> |
740 | 740 | <div id="menu-management"> |
741 | 741 | <form id="update-nav-menu" method="post" enctype="multipart/form-data"> |
742 | - <div class="menu-edit <?php if ( $add_new_screen ) echo 'blank-slate'; ?>"> |
|
742 | + <div class="menu-edit <?php if ($add_new_screen) echo 'blank-slate'; ?>"> |
|
743 | 743 | <input type="hidden" name="nav-menu-data"> |
744 | 744 | <?php |
745 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
746 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
747 | - wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' ); |
|
745 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
746 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
747 | + wp_nonce_field('update-nav_menu', 'update-nav-menu-nonce'); |
|
748 | 748 | |
749 | 749 | $menu_name_aria_desc = $add_new_screen ? ' aria-describedby="menu-name-desc"' : ''; |
750 | 750 | |
751 | - if ( $one_theme_location_no_menus ) { |
|
752 | - $menu_name_val = 'value="' . esc_attr( 'Menu 1' ) . '"'; |
|
751 | + if ($one_theme_location_no_menus) { |
|
752 | + $menu_name_val = 'value="'.esc_attr('Menu 1').'"'; |
|
753 | 753 | ?> |
754 | 754 | <input type="hidden" name="zero-menu-state" value="true" /> |
755 | 755 | <?php } else { |
756 | - $menu_name_val = 'value="' . esc_attr( $nav_menu_selected_title ) . '"'; |
|
756 | + $menu_name_val = 'value="'.esc_attr($nav_menu_selected_title).'"'; |
|
757 | 757 | } ?> |
758 | 758 | <input type="hidden" name="action" value="update" /> |
759 | - <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
759 | + <input type="hidden" name="menu" id="menu" value="<?php echo esc_attr($nav_menu_selected_id); ?>" /> |
|
760 | 760 | <div id="nav-menu-header"> |
761 | 761 | <div class="major-publishing-actions wp-clearfix"> |
762 | - <label class="menu-name-label" for="menu-name"><?php _e( 'Menu Name' ); ?></label> |
|
763 | - <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox" <?php echo $menu_name_val . $menu_name_aria_desc; ?> /> |
|
762 | + <label class="menu-name-label" for="menu-name"><?php _e('Menu Name'); ?></label> |
|
763 | + <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox" <?php echo $menu_name_val.$menu_name_aria_desc; ?> /> |
|
764 | 764 | <div class="publishing-action"> |
765 | - <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'primary large menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?> |
|
765 | + <?php submit_button(empty($nav_menu_selected_id) ? __('Create Menu') : __('Save Menu'), 'primary large menu-save', 'save_menu', false, array('id' => 'save_menu_header')); ?> |
|
766 | 766 | </div><!-- END .publishing-action --> |
767 | 767 | </div><!-- END .major-publishing-actions --> |
768 | 768 | </div><!-- END .nav-menu-header --> |
769 | 769 | <div id="post-body"> |
770 | 770 | <div id="post-body-content" class="wp-clearfix"> |
771 | - <?php if ( ! $add_new_screen ) : ?> |
|
772 | - <h3><?php _e( 'Menu Structure' ); ?></h3> |
|
773 | - <?php $starter_copy = ( $one_theme_location_no_menus ) ? __( 'Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.' ) : __( 'Drag each item into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.' ); ?> |
|
774 | - <div class="drag-instructions post-body-plain" <?php if ( isset( $menu_items ) && 0 == count( $menu_items ) ) { ?>style="display: none;"<?php } ?>> |
|
771 | + <?php if ( ! $add_new_screen) : ?> |
|
772 | + <h3><?php _e('Menu Structure'); ?></h3> |
|
773 | + <?php $starter_copy = ($one_theme_location_no_menus) ? __('Edit your default menu by adding or removing items. Drag each item into the order you prefer. Click Create Menu to save your changes.') : __('Drag each item into the order you prefer. Click the arrow on the right of the item to reveal additional configuration options.'); ?> |
|
774 | + <div class="drag-instructions post-body-plain" <?php if (isset($menu_items) && 0 == count($menu_items)) { ?>style="display: none;"<?php } ?>> |
|
775 | 775 | <p><?php echo $starter_copy; ?></p> |
776 | 776 | </div> |
777 | 777 | <?php |
778 | - if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) { |
|
778 | + if (isset($edit_markup) && ! is_wp_error($edit_markup)) { |
|
779 | 779 | echo $edit_markup; |
780 | 780 | } else { |
781 | 781 | ?> |
782 | 782 | <ul class="menu" id="menu-to-edit"></ul> |
783 | 783 | <?php } ?> |
784 | 784 | <?php endif; ?> |
785 | - <?php if ( $add_new_screen ) : ?> |
|
786 | - <p class="post-body-plain" id="menu-name-desc"><?php _e( 'Give your menu a name, then click Create Menu.' ); ?></p> |
|
787 | - <?php if ( isset( $_GET['use-location'] ) ) : ?> |
|
788 | - <input type="hidden" name="use-location" value="<?php echo esc_attr( $_GET['use-location'] ); ?>" /> |
|
785 | + <?php if ($add_new_screen) : ?> |
|
786 | + <p class="post-body-plain" id="menu-name-desc"><?php _e('Give your menu a name, then click Create Menu.'); ?></p> |
|
787 | + <?php if (isset($_GET['use-location'])) : ?> |
|
788 | + <input type="hidden" name="use-location" value="<?php echo esc_attr($_GET['use-location']); ?>" /> |
|
789 | 789 | <?php endif; ?> |
790 | 790 | <?php endif; ?> |
791 | - <div class="menu-settings" <?php if ( $one_theme_location_no_menus ) { ?>style="display: none;"<?php } ?>> |
|
792 | - <h3><?php _e( 'Menu Settings' ); ?></h3> |
|
791 | + <div class="menu-settings" <?php if ($one_theme_location_no_menus) { ?>style="display: none;"<?php } ?>> |
|
792 | + <h3><?php _e('Menu Settings'); ?></h3> |
|
793 | 793 | <?php |
794 | - if ( ! isset( $auto_add ) ) { |
|
795 | - $auto_add = get_option( 'nav_menu_options' ); |
|
796 | - if ( ! isset( $auto_add['auto_add'] ) ) |
|
794 | + if ( ! isset($auto_add)) { |
|
795 | + $auto_add = get_option('nav_menu_options'); |
|
796 | + if ( ! isset($auto_add['auto_add'])) |
|
797 | 797 | $auto_add = false; |
798 | - elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) |
|
798 | + elseif (false !== array_search($nav_menu_selected_id, $auto_add['auto_add'])) |
|
799 | 799 | $auto_add = true; |
800 | 800 | else |
801 | 801 | $auto_add = false; |
802 | 802 | } ?> |
803 | 803 | |
804 | 804 | <fieldset class="menu-settings-group auto-add-pages"> |
805 | - <legend class="menu-settings-group-name howto"><?php _e( 'Auto add pages' ); ?></legend> |
|
805 | + <legend class="menu-settings-group-name howto"><?php _e('Auto add pages'); ?></legend> |
|
806 | 806 | <div class="menu-settings-input checkbox-input"> |
807 | - <input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" id="auto-add-pages" value="1" /> <label for="auto-add-pages"><?php printf( __('Automatically add new top-level pages to this menu' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label> |
|
807 | + <input type="checkbox"<?php checked($auto_add); ?> name="auto-add-pages" id="auto-add-pages" value="1" /> <label for="auto-add-pages"><?php printf(__('Automatically add new top-level pages to this menu'), esc_url(admin_url('edit.php?post_type=page'))); ?></label> |
|
808 | 808 | </div> |
809 | 809 | </fieldset> |
810 | 810 | |
811 | - <?php if ( current_theme_supports( 'menus' ) ) : ?> |
|
811 | + <?php if (current_theme_supports('menus')) : ?> |
|
812 | 812 | |
813 | 813 | <fieldset class="menu-settings-group menu-theme-locations"> |
814 | - <legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend> |
|
815 | - <?php foreach ( $locations as $location => $description ) : ?> |
|
814 | + <legend class="menu-settings-group-name howto"><?php _e('Display location'); ?></legend> |
|
815 | + <?php foreach ($locations as $location => $description) : ?> |
|
816 | 816 | <div class="menu-settings-input checkbox-input"> |
817 | - <input type="checkbox"<?php checked( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $nav_menu_selected_id ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" /> |
|
818 | - <label for="locations-<?php echo esc_attr( $location ); ?>"><?php echo $description; ?></label> |
|
819 | - <?php if ( ! empty( $menu_locations[ $location ] ) && $menu_locations[ $location ] != $nav_menu_selected_id ) : ?> |
|
817 | + <input type="checkbox"<?php checked(isset($menu_locations[$location]) && $menu_locations[$location] == $nav_menu_selected_id); ?> name="menu-locations[<?php echo esc_attr($location); ?>]" id="locations-<?php echo esc_attr($location); ?>" value="<?php echo esc_attr($nav_menu_selected_id); ?>" /> |
|
818 | + <label for="locations-<?php echo esc_attr($location); ?>"><?php echo $description; ?></label> |
|
819 | + <?php if ( ! empty($menu_locations[$location]) && $menu_locations[$location] != $nav_menu_selected_id) : ?> |
|
820 | 820 | <span class="theme-location-set"><?php |
821 | 821 | /* translators: %s: menu name */ |
822 | - printf( _x( '(Currently set to: %s)', 'menu location' ), |
|
823 | - wp_get_nav_menu_object( $menu_locations[ $location ] )->name |
|
822 | + printf(_x('(Currently set to: %s)', 'menu location'), |
|
823 | + wp_get_nav_menu_object($menu_locations[$location])->name |
|
824 | 824 | ); |
825 | 825 | ?></span> |
826 | 826 | <?php endif; ?> |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | </div><!-- /#post-body --> |
836 | 836 | <div id="nav-menu-footer"> |
837 | 837 | <div class="major-publishing-actions wp-clearfix"> |
838 | - <?php if ( 0 != $menu_count && ! $add_new_screen ) : ?> |
|
838 | + <?php if (0 != $menu_count && ! $add_new_screen) : ?> |
|
839 | 839 | <span class="delete-action"> |
840 | - <a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'menu' => $nav_menu_selected_id ), admin_url( 'nav-menus.php' ) ), 'delete-nav_menu-' . $nav_menu_selected_id) ); ?>"><?php _e('Delete Menu'); ?></a> |
|
840 | + <a class="submitdelete deletion menu-delete" href="<?php echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'delete', 'menu' => $nav_menu_selected_id), admin_url('nav-menus.php')), 'delete-nav_menu-'.$nav_menu_selected_id)); ?>"><?php _e('Delete Menu'); ?></a> |
|
841 | 841 | </span><!-- END .delete-action --> |
842 | 842 | <?php endif; ?> |
843 | 843 | <div class="publishing-action"> |
844 | - <?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'primary large menu-save', 'save_menu', false, array( 'id' => 'save_menu_footer' ) ); ?> |
|
844 | + <?php submit_button(empty($nav_menu_selected_id) ? __('Create Menu') : __('Save Menu'), 'primary large menu-save', 'save_menu', false, array('id' => 'save_menu_footer')); ?> |
|
845 | 845 | </div><!-- END .publishing-action --> |
846 | 846 | </div><!-- END .major-publishing-actions --> |
847 | 847 | </div><!-- /#nav-menu-footer --> |
@@ -852,4 +852,4 @@ discard block |
||
852 | 852 | </div><!-- /#nav-menus-frame --> |
853 | 853 | <?php endif; ?> |
854 | 854 | </div><!-- /.wrap--> |
855 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
855 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | exit(); |
15 | 15 | } |
16 | 16 | |
17 | -if ( !current_user_can('edit_themes') ) |
|
17 | +if ( !current_user_can('edit_themes') ) { |
|
18 | 18 | wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); |
19 | +} |
|
19 | 20 | |
20 | 21 | $title = __("Edit Themes"); |
21 | 22 | $parent_file = 'themes.php'; |
@@ -130,8 +131,9 @@ discard block |
||
130 | 131 | |
131 | 132 | update_recently_edited( $file ); |
132 | 133 | |
133 | - if ( ! is_file( $file ) ) |
|
134 | - $error = true; |
|
134 | + if ( ! is_file( $file ) ) { |
|
135 | + $error = true; |
|
136 | + } |
|
135 | 137 | |
136 | 138 | $content = ''; |
137 | 139 | if ( ! $error && filesize( $file ) > 0 ) { |
@@ -158,15 +160,19 @@ discard block |
||
158 | 160 | |
159 | 161 | $description = get_file_description( $relative_file ); |
160 | 162 | $file_show = array_search( $file, array_filter( $allowed_files ) ); |
161 | -if ( $description != $file_show ) |
|
163 | +if ( $description != $file_show ) { |
|
162 | 164 | $description .= ' <span>(' . $file_show . ')</span>'; |
165 | +} |
|
163 | 166 | ?> |
164 | 167 | <div class="wrap"> |
165 | 168 | <h1><?php echo esc_html( $title ); ?></h1> |
166 | 169 | |
167 | 170 | <div class="fileedit-sub"> |
168 | 171 | <div class="alignleft"> |
169 | -<h2><?php echo $theme->display( 'Name' ); if ( $description ) echo ': ' . $description; ?></h2> |
|
172 | +<h2><?php echo $theme->display( 'Name' ); if ( $description ) { |
|
173 | + echo ': ' . $description; |
|
174 | +} |
|
175 | +?></h2> |
|
170 | 176 | </div> |
171 | 177 | <div class="alignright"> |
172 | 178 | <form action="theme-editor.php" method="post"> |
@@ -174,8 +180,9 @@ discard block |
||
174 | 180 | <select name="theme" id="theme"> |
175 | 181 | <?php |
176 | 182 | foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { |
177 | - if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) |
|
178 | - continue; |
|
183 | + if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) { |
|
184 | + continue; |
|
185 | + } |
|
179 | 186 | |
180 | 187 | $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; |
181 | 188 | echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>'; |
@@ -188,8 +195,9 @@ discard block |
||
188 | 195 | <br class="clear" /> |
189 | 196 | </div> |
190 | 197 | <?php |
191 | -if ( $theme->errors() ) |
|
198 | +if ( $theme->errors() ) { |
|
192 | 199 | echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; |
200 | +} |
|
193 | 201 | ?> |
194 | 202 | <div id="templateside"> |
195 | 203 | <?php |
@@ -250,9 +258,12 @@ discard block |
||
250 | 258 | </div> |
251 | 259 | <?php if ( $error ) : |
252 | 260 | echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>'; |
253 | -else : ?> |
|
261 | +else { |
|
262 | + : ?> |
|
254 | 263 | <form name="template" id="template" action="theme-editor.php" method="post"> |
255 | - <?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?> |
|
264 | + <?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); |
|
265 | +} |
|
266 | +?> |
|
256 | 267 | <div><textarea cols="70" rows="30" name="newcontent" id="newcontent" aria-describedby="newcontent-description"><?php echo $content; ?></textarea> |
257 | 268 | <input type="hidden" name="action" value="update" /> |
258 | 269 | <input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" /> |
@@ -275,8 +286,11 @@ discard block |
||
275 | 286 | <?php |
276 | 287 | if ( is_writeable( $file ) ) : |
277 | 288 | submit_button( __( 'Update File' ), 'primary', 'submit', true ); |
278 | - else : ?> |
|
279 | -<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> |
|
289 | + else { |
|
290 | + : ?> |
|
291 | +<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.'); |
|
292 | + } |
|
293 | + ?></em></p> |
|
280 | 294 | <?php endif; ?> |
281 | 295 | </div> |
282 | 296 | </form> |
@@ -107,60 +107,60 @@ discard block |
||
107 | 107 | $scrollto = isset( $_REQUEST['scrollto'] ) ? (int) $_REQUEST['scrollto'] : 0; |
108 | 108 | |
109 | 109 | switch( $action ) { |
110 | -case 'update': |
|
111 | - check_admin_referer( 'edit-theme_' . $file . $stylesheet ); |
|
112 | - $newcontent = wp_unslash( $_POST['newcontent'] ); |
|
113 | - $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto; |
|
114 | - if ( is_writeable( $file ) ) { |
|
115 | - // is_writable() not always reliable, check return value. see comments @ https://secure.php.net/is_writable |
|
116 | - $f = fopen( $file, 'w+' ); |
|
117 | - if ( $f !== false ) { |
|
118 | - fwrite( $f, $newcontent ); |
|
119 | - fclose( $f ); |
|
120 | - $location .= '&updated=true'; |
|
121 | - $theme->cache_delete(); |
|
110 | + case 'update': |
|
111 | + check_admin_referer( 'edit-theme_' . $file . $stylesheet ); |
|
112 | + $newcontent = wp_unslash( $_POST['newcontent'] ); |
|
113 | + $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto; |
|
114 | + if ( is_writeable( $file ) ) { |
|
115 | + // is_writable() not always reliable, check return value. see comments @ https://secure.php.net/is_writable |
|
116 | + $f = fopen( $file, 'w+' ); |
|
117 | + if ( $f !== false ) { |
|
118 | + fwrite( $f, $newcontent ); |
|
119 | + fclose( $f ); |
|
120 | + $location .= '&updated=true'; |
|
121 | + $theme->cache_delete(); |
|
122 | + } |
|
122 | 123 | } |
123 | - } |
|
124 | - wp_redirect( $location ); |
|
125 | - exit; |
|
124 | + wp_redirect( $location ); |
|
125 | + exit; |
|
126 | 126 | |
127 | -default: |
|
127 | + default: |
|
128 | 128 | |
129 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
129 | + require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
130 | 130 | |
131 | - update_recently_edited( $file ); |
|
131 | + update_recently_edited( $file ); |
|
132 | 132 | |
133 | - if ( ! is_file( $file ) ) |
|
134 | - $error = true; |
|
133 | + if ( ! is_file( $file ) ) |
|
134 | + $error = true; |
|
135 | 135 | |
136 | - $content = ''; |
|
137 | - if ( ! $error && filesize( $file ) > 0 ) { |
|
138 | - $f = fopen($file, 'r'); |
|
139 | - $content = fread($f, filesize($file)); |
|
136 | + $content = ''; |
|
137 | + if ( ! $error && filesize( $file ) > 0 ) { |
|
138 | + $f = fopen($file, 'r'); |
|
139 | + $content = fread($f, filesize($file)); |
|
140 | 140 | |
141 | - if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { |
|
142 | - $functions = wp_doc_link_parse( $content ); |
|
141 | + if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { |
|
142 | + $functions = wp_doc_link_parse( $content ); |
|
143 | 143 | |
144 | - $docs_select = '<select name="docs-list" id="docs-list">'; |
|
145 | - $docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; |
|
146 | - foreach ( $functions as $function ) { |
|
147 | - $docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; |
|
144 | + $docs_select = '<select name="docs-list" id="docs-list">'; |
|
145 | + $docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; |
|
146 | + foreach ( $functions as $function ) { |
|
147 | + $docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; |
|
148 | + } |
|
149 | + $docs_select .= '</select>'; |
|
148 | 150 | } |
149 | - $docs_select .= '</select>'; |
|
150 | - } |
|
151 | 151 | |
152 | - $content = esc_textarea( $content ); |
|
153 | - } |
|
152 | + $content = esc_textarea( $content ); |
|
153 | + } |
|
154 | 154 | |
155 | - if ( isset( $_GET['updated'] ) ) : ?> |
|
156 | - <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div> |
|
157 | -<?php endif; |
|
155 | + if ( isset( $_GET['updated'] ) ) : ?> |
|
156 | + <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div> |
|
157 | + <?php endif; |
|
158 | 158 | |
159 | -$description = get_file_description( $relative_file ); |
|
160 | -$file_show = array_search( $file, array_filter( $allowed_files ) ); |
|
161 | -if ( $description != $file_show ) |
|
162 | - $description .= ' <span>(' . $file_show . ')</span>'; |
|
163 | -?> |
|
159 | + $description = get_file_description( $relative_file ); |
|
160 | + $file_show = array_search( $file, array_filter( $allowed_files ) ); |
|
161 | + if ( $description != $file_show ) |
|
162 | + $description .= ' <span>(' . $file_show . ')</span>'; |
|
163 | + ?> |
|
164 | 164 | <div class="wrap"> |
165 | 165 | <h1><?php echo esc_html( $title ); ?></h1> |
166 | 166 | |
@@ -173,38 +173,38 @@ discard block |
||
173 | 173 | <strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong> |
174 | 174 | <select name="theme" id="theme"> |
175 | 175 | <?php |
176 | -foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { |
|
177 | - if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) |
|
178 | - continue; |
|
176 | + foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { |
|
177 | + if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) |
|
178 | + continue; |
|
179 | 179 | |
180 | - $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; |
|
181 | - echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>'; |
|
180 | + $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; |
|
181 | + echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>'; |
|
182 | 182 | } |
183 | -?> |
|
184 | - </select> |
|
183 | + ?> |
|
184 | + </select> |
|
185 | 185 | <?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?> |
186 | 186 | </form> |
187 | 187 | </div> |
188 | 188 | <br class="clear" /> |
189 | 189 | </div> |
190 | 190 | <?php |
191 | -if ( $theme->errors() ) |
|
192 | - echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; |
|
193 | -?> |
|
194 | - <div id="templateside"> |
|
195 | -<?php |
|
196 | -if ( $allowed_files ) : |
|
197 | - $previous_file_type = ''; |
|
198 | - |
|
199 | - foreach ( $allowed_files as $filename => $absolute_filename ) : |
|
200 | - $file_type = substr( $filename, strrpos( $filename, '.' ) ); |
|
201 | - |
|
202 | - if ( $file_type !== $previous_file_type ) { |
|
203 | - if ( '' !== $previous_file_type ) { |
|
204 | - echo "\t</ul>\n"; |
|
205 | - } |
|
206 | - |
|
207 | - switch ( $file_type ) { |
|
191 | + if ( $theme->errors() ) |
|
192 | + echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; |
|
193 | + ?> |
|
194 | + <div id="templateside"> |
|
195 | + <?php |
|
196 | + if ( $allowed_files ) : |
|
197 | + $previous_file_type = ''; |
|
198 | + |
|
199 | + foreach ( $allowed_files as $filename => $absolute_filename ) : |
|
200 | + $file_type = substr( $filename, strrpos( $filename, '.' ) ); |
|
201 | + |
|
202 | + if ( $file_type !== $previous_file_type ) { |
|
203 | + if ( '' !== $previous_file_type ) { |
|
204 | + echo "\t</ul>\n"; |
|
205 | + } |
|
206 | + |
|
207 | + switch ( $file_type ) { |
|
208 | 208 | case '.php': |
209 | 209 | if ( $has_templates || $theme->parent() ) : |
210 | 210 | echo "\t<h2>" . __( 'Templates' ) . "</h2>\n"; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | /* translators: %s: file extension */ |
226 | 226 | echo "\t<h2>" . sprintf( __( '%s files' ), $file_type ) . "</h2>\n"; |
227 | 227 | break; |
228 | - } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | echo "\t<ul>\n"; |
231 | 231 | } |
@@ -7,63 +7,63 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( is_multisite() && ! is_network_admin() ) { |
|
13 | - wp_redirect( network_admin_url( 'theme-editor.php' ) ); |
|
12 | +if (is_multisite() && ! is_network_admin()) { |
|
13 | + wp_redirect(network_admin_url('theme-editor.php')); |
|
14 | 14 | exit(); |
15 | 15 | } |
16 | 16 | |
17 | -if ( !current_user_can('edit_themes') ) |
|
17 | +if ( ! current_user_can('edit_themes')) |
|
18 | 18 | wp_die('<p>'.__('Sorry, you are not allowed to edit templates for this site.').'</p>'); |
19 | 19 | |
20 | 20 | $title = __("Edit Themes"); |
21 | 21 | $parent_file = 'themes.php'; |
22 | 22 | |
23 | -get_current_screen()->add_help_tab( array( |
|
23 | +get_current_screen()->add_help_tab(array( |
|
24 | 24 | 'id' => 'overview', |
25 | 25 | 'title' => __('Overview'), |
26 | 26 | 'content' => |
27 | - '<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p> |
|
28 | - <p>' . __( 'Begin by choosing a theme to edit from the dropdown menu and clicking 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> |
|
29 | - <p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Look Up takes you to a web page with reference material about that particular function.') . '</p> |
|
30 | - <p id="newcontent-description">' . __( 'In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.' ) . '</p> |
|
31 | - <p>' . __('After typing in your edits, click Update File.') . '</p> |
|
32 | - <p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p> |
|
33 | - <p>' . sprintf( __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s">child theme</a> instead.'), __('https://codex.wordpress.org/Child_Themes') ) . '</p>' . |
|
34 | - ( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' ) |
|
35 | -) ); |
|
27 | + '<p>'.__('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.').'</p> |
|
28 | + <p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking 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> |
|
29 | + <p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Look Up takes you to a web page with reference material about that particular function.').'</p> |
|
30 | + <p id="newcontent-description">' . __('In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.').'</p> |
|
31 | + <p>' . __('After typing in your edits, click Update File.').'</p> |
|
32 | + <p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.').'</p> |
|
33 | + <p>' . sprintf(__('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="%s">child theme</a> instead.'), __('https://codex.wordpress.org/Child_Themes')).'</p>'. |
|
34 | + (is_network_admin() ? '<p>'.__('Any edits to files from this screen will be reflected on all sites in the network.').'</p>' : '') |
|
35 | +)); |
|
36 | 36 | |
37 | 37 | get_current_screen()->set_help_sidebar( |
38 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
39 | - '<p>' . __('<a href="https://codex.wordpress.org/Theme_Development">Documentation on Theme Development</a>') . '</p>' . |
|
40 | - '<p>' . __('<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>') . '</p>' . |
|
41 | - '<p>' . __('<a href="https://codex.wordpress.org/Editing_Files">Documentation on Editing Files</a>') . '</p>' . |
|
42 | - '<p>' . __('<a href="https://codex.wordpress.org/Template_Tags">Documentation on Template Tags</a>') . '</p>' . |
|
43 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
38 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
39 | + '<p>'.__('<a href="https://codex.wordpress.org/Theme_Development">Documentation on Theme Development</a>').'</p>'. |
|
40 | + '<p>'.__('<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>').'</p>'. |
|
41 | + '<p>'.__('<a href="https://codex.wordpress.org/Editing_Files">Documentation on Editing Files</a>').'</p>'. |
|
42 | + '<p>'.__('<a href="https://codex.wordpress.org/Template_Tags">Documentation on Template Tags</a>').'</p>'. |
|
43 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
44 | 44 | ); |
45 | 45 | |
46 | -wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) ); |
|
46 | +wp_reset_vars(array('action', 'error', 'file', 'theme')); |
|
47 | 47 | |
48 | -if ( $theme ) { |
|
48 | +if ($theme) { |
|
49 | 49 | $stylesheet = $theme; |
50 | 50 | } else { |
51 | 51 | $stylesheet = get_stylesheet(); |
52 | 52 | } |
53 | 53 | |
54 | -$theme = wp_get_theme( $stylesheet ); |
|
54 | +$theme = wp_get_theme($stylesheet); |
|
55 | 55 | |
56 | -if ( ! $theme->exists() ) { |
|
57 | - wp_die( __( 'The requested theme does not exist.' ) ); |
|
56 | +if ( ! $theme->exists()) { |
|
57 | + wp_die(__('The requested theme does not exist.')); |
|
58 | 58 | } |
59 | 59 | |
60 | -if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) { |
|
61 | - wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() ); |
|
60 | +if ($theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code()) { |
|
61 | + wp_die(__('The requested theme does not exist.').' '.$theme->errors()->get_error_message()); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $allowed_files = $style_files = array(); |
65 | 65 | $has_templates = false; |
66 | -$default_types = array( 'php', 'css' ); |
|
66 | +$default_types = array('php', 'css'); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Filters the list of file types allowed for editing in the Theme editor. |
@@ -73,208 +73,208 @@ discard block |
||
73 | 73 | * @param array $default_types List of file types. Default types include 'php' and 'css'. |
74 | 74 | * @param WP_Theme $theme The current Theme object. |
75 | 75 | */ |
76 | -$file_types = apply_filters( 'wp_theme_editor_filetypes', $default_types, $theme ); |
|
76 | +$file_types = apply_filters('wp_theme_editor_filetypes', $default_types, $theme); |
|
77 | 77 | |
78 | 78 | // Ensure that default types are still there. |
79 | -$file_types = array_unique( array_merge( $file_types, $default_types ) ); |
|
79 | +$file_types = array_unique(array_merge($file_types, $default_types)); |
|
80 | 80 | |
81 | -foreach ( $file_types as $type ) { |
|
82 | - switch ( $type ) { |
|
81 | +foreach ($file_types as $type) { |
|
82 | + switch ($type) { |
|
83 | 83 | case 'php': |
84 | - $allowed_files += $theme->get_files( 'php', 1 ); |
|
85 | - $has_templates = ! empty( $allowed_files ); |
|
84 | + $allowed_files += $theme->get_files('php', 1); |
|
85 | + $has_templates = ! empty($allowed_files); |
|
86 | 86 | break; |
87 | 87 | case 'css': |
88 | - $style_files = $theme->get_files( 'css' ); |
|
88 | + $style_files = $theme->get_files('css'); |
|
89 | 89 | $allowed_files['style.css'] = $style_files['style.css']; |
90 | 90 | $allowed_files += $style_files; |
91 | 91 | break; |
92 | 92 | default: |
93 | - $allowed_files += $theme->get_files( $type ); |
|
93 | + $allowed_files += $theme->get_files($type); |
|
94 | 94 | break; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | -if ( empty( $file ) ) { |
|
98 | +if (empty($file)) { |
|
99 | 99 | $relative_file = 'style.css'; |
100 | 100 | $file = $allowed_files['style.css']; |
101 | 101 | } else { |
102 | 102 | $relative_file = $file; |
103 | - $file = $theme->get_stylesheet_directory() . '/' . $relative_file; |
|
103 | + $file = $theme->get_stylesheet_directory().'/'.$relative_file; |
|
104 | 104 | } |
105 | 105 | |
106 | -validate_file_to_edit( $file, $allowed_files ); |
|
107 | -$scrollto = isset( $_REQUEST['scrollto'] ) ? (int) $_REQUEST['scrollto'] : 0; |
|
106 | +validate_file_to_edit($file, $allowed_files); |
|
107 | +$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0; |
|
108 | 108 | |
109 | -switch( $action ) { |
|
109 | +switch ($action) { |
|
110 | 110 | case 'update': |
111 | - check_admin_referer( 'edit-theme_' . $file . $stylesheet ); |
|
112 | - $newcontent = wp_unslash( $_POST['newcontent'] ); |
|
113 | - $location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto; |
|
114 | - if ( is_writeable( $file ) ) { |
|
111 | + check_admin_referer('edit-theme_'.$file.$stylesheet); |
|
112 | + $newcontent = wp_unslash($_POST['newcontent']); |
|
113 | + $location = 'theme-editor.php?file='.urlencode($relative_file).'&theme='.urlencode($stylesheet).'&scrollto='.$scrollto; |
|
114 | + if (is_writeable($file)) { |
|
115 | 115 | // is_writable() not always reliable, check return value. see comments @ https://secure.php.net/is_writable |
116 | - $f = fopen( $file, 'w+' ); |
|
117 | - if ( $f !== false ) { |
|
118 | - fwrite( $f, $newcontent ); |
|
119 | - fclose( $f ); |
|
116 | + $f = fopen($file, 'w+'); |
|
117 | + if ($f !== false) { |
|
118 | + fwrite($f, $newcontent); |
|
119 | + fclose($f); |
|
120 | 120 | $location .= '&updated=true'; |
121 | 121 | $theme->cache_delete(); |
122 | 122 | } |
123 | 123 | } |
124 | - wp_redirect( $location ); |
|
124 | + wp_redirect($location); |
|
125 | 125 | exit; |
126 | 126 | |
127 | 127 | default: |
128 | 128 | |
129 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
129 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
130 | 130 | |
131 | - update_recently_edited( $file ); |
|
131 | + update_recently_edited($file); |
|
132 | 132 | |
133 | - if ( ! is_file( $file ) ) |
|
133 | + if ( ! is_file($file)) |
|
134 | 134 | $error = true; |
135 | 135 | |
136 | 136 | $content = ''; |
137 | - if ( ! $error && filesize( $file ) > 0 ) { |
|
137 | + if ( ! $error && filesize($file) > 0) { |
|
138 | 138 | $f = fopen($file, 'r'); |
139 | 139 | $content = fread($f, filesize($file)); |
140 | 140 | |
141 | - if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { |
|
142 | - $functions = wp_doc_link_parse( $content ); |
|
141 | + if ('.php' == substr($file, strrpos($file, '.'))) { |
|
142 | + $functions = wp_doc_link_parse($content); |
|
143 | 143 | |
144 | 144 | $docs_select = '<select name="docs-list" id="docs-list">'; |
145 | - $docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; |
|
146 | - foreach ( $functions as $function ) { |
|
147 | - $docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; |
|
145 | + $docs_select .= '<option value="">'.esc_attr__('Function Name…').'</option>'; |
|
146 | + foreach ($functions as $function) { |
|
147 | + $docs_select .= '<option value="'.esc_attr(urlencode($function)).'">'.htmlspecialchars($function).'()</option>'; |
|
148 | 148 | } |
149 | 149 | $docs_select .= '</select>'; |
150 | 150 | } |
151 | 151 | |
152 | - $content = esc_textarea( $content ); |
|
152 | + $content = esc_textarea($content); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( isset( $_GET['updated'] ) ) : ?> |
|
156 | - <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div> |
|
155 | + if (isset($_GET['updated'])) : ?> |
|
156 | + <div id="message" class="updated notice is-dismissible"><p><?php _e('File edited successfully.') ?></p></div> |
|
157 | 157 | <?php endif; |
158 | 158 | |
159 | -$description = get_file_description( $relative_file ); |
|
160 | -$file_show = array_search( $file, array_filter( $allowed_files ) ); |
|
161 | -if ( $description != $file_show ) |
|
162 | - $description .= ' <span>(' . $file_show . ')</span>'; |
|
159 | +$description = get_file_description($relative_file); |
|
160 | +$file_show = array_search($file, array_filter($allowed_files)); |
|
161 | +if ($description != $file_show) |
|
162 | + $description .= ' <span>('.$file_show.')</span>'; |
|
163 | 163 | ?> |
164 | 164 | <div class="wrap"> |
165 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
165 | +<h1><?php echo esc_html($title); ?></h1> |
|
166 | 166 | |
167 | 167 | <div class="fileedit-sub"> |
168 | 168 | <div class="alignleft"> |
169 | -<h2><?php echo $theme->display( 'Name' ); if ( $description ) echo ': ' . $description; ?></h2> |
|
169 | +<h2><?php echo $theme->display('Name'); if ($description) echo ': '.$description; ?></h2> |
|
170 | 170 | </div> |
171 | 171 | <div class="alignright"> |
172 | 172 | <form action="theme-editor.php" method="post"> |
173 | 173 | <strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong> |
174 | 174 | <select name="theme" id="theme"> |
175 | 175 | <?php |
176 | -foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { |
|
177 | - if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) |
|
176 | +foreach (wp_get_themes(array('errors' => null)) as $a_stylesheet => $a_theme) { |
|
177 | + if ($a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code()) |
|
178 | 178 | continue; |
179 | 179 | |
180 | 180 | $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; |
181 | - echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>'; |
|
181 | + echo "\n\t".'<option value="'.esc_attr($a_stylesheet).'"'.$selected.'>'.$a_theme->display('Name').'</option>'; |
|
182 | 182 | } |
183 | 183 | ?> |
184 | 184 | </select> |
185 | - <?php submit_button( __( 'Select' ), '', 'Submit', false ); ?> |
|
185 | + <?php submit_button(__('Select'), '', 'Submit', false); ?> |
|
186 | 186 | </form> |
187 | 187 | </div> |
188 | 188 | <br class="clear" /> |
189 | 189 | </div> |
190 | 190 | <?php |
191 | -if ( $theme->errors() ) |
|
192 | - echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; |
|
191 | +if ($theme->errors()) |
|
192 | + echo '<div class="error"><p><strong>'.__('This theme is broken.').'</strong> '.$theme->errors()->get_error_message().'</p></div>'; |
|
193 | 193 | ?> |
194 | 194 | <div id="templateside"> |
195 | 195 | <?php |
196 | -if ( $allowed_files ) : |
|
196 | +if ($allowed_files) : |
|
197 | 197 | $previous_file_type = ''; |
198 | 198 | |
199 | - foreach ( $allowed_files as $filename => $absolute_filename ) : |
|
200 | - $file_type = substr( $filename, strrpos( $filename, '.' ) ); |
|
199 | + foreach ($allowed_files as $filename => $absolute_filename) : |
|
200 | + $file_type = substr($filename, strrpos($filename, '.')); |
|
201 | 201 | |
202 | - if ( $file_type !== $previous_file_type ) { |
|
203 | - if ( '' !== $previous_file_type ) { |
|
202 | + if ($file_type !== $previous_file_type) { |
|
203 | + if ('' !== $previous_file_type) { |
|
204 | 204 | echo "\t</ul>\n"; |
205 | 205 | } |
206 | 206 | |
207 | - switch ( $file_type ) { |
|
207 | + switch ($file_type) { |
|
208 | 208 | case '.php': |
209 | - if ( $has_templates || $theme->parent() ) : |
|
210 | - echo "\t<h2>" . __( 'Templates' ) . "</h2>\n"; |
|
211 | - if ( $theme->parent() ) { |
|
212 | - echo '<p class="howto">' . sprintf( __( 'This child theme inherits templates from a parent theme, %s.' ), |
|
213 | - sprintf( '<a href="%s">%s</a>', |
|
214 | - self_admin_url( 'theme-editor.php?theme=' . urlencode( $theme->get_template() ) ), |
|
215 | - $theme->parent()->display( 'Name' ) |
|
209 | + if ($has_templates || $theme->parent()) : |
|
210 | + echo "\t<h2>".__('Templates')."</h2>\n"; |
|
211 | + if ($theme->parent()) { |
|
212 | + echo '<p class="howto">'.sprintf(__('This child theme inherits templates from a parent theme, %s.'), |
|
213 | + sprintf('<a href="%s">%s</a>', |
|
214 | + self_admin_url('theme-editor.php?theme='.urlencode($theme->get_template())), |
|
215 | + $theme->parent()->display('Name') |
|
216 | 216 | ) |
217 | - ) . "</p>\n"; |
|
217 | + )."</p>\n"; |
|
218 | 218 | } |
219 | 219 | endif; |
220 | 220 | break; |
221 | 221 | case '.css': |
222 | - echo "\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n"; |
|
222 | + echo "\t<h2>"._x('Styles', 'Theme stylesheets in theme editor')."</h2>\n"; |
|
223 | 223 | break; |
224 | 224 | default: |
225 | 225 | /* translators: %s: file extension */ |
226 | - echo "\t<h2>" . sprintf( __( '%s files' ), $file_type ) . "</h2>\n"; |
|
226 | + echo "\t<h2>".sprintf(__('%s files'), $file_type)."</h2>\n"; |
|
227 | 227 | break; |
228 | 228 | } |
229 | 229 | |
230 | 230 | echo "\t<ul>\n"; |
231 | 231 | } |
232 | 232 | |
233 | - $file_description = get_file_description( $filename ); |
|
234 | - if ( $filename !== basename( $absolute_filename ) || $file_description !== $filename ) { |
|
235 | - $file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>'; |
|
233 | + $file_description = get_file_description($filename); |
|
234 | + if ($filename !== basename($absolute_filename) || $file_description !== $filename) { |
|
235 | + $file_description .= '<br /><span class="nonessential">('.$filename.')</span>'; |
|
236 | 236 | } |
237 | 237 | |
238 | - if ( $absolute_filename === $file ) { |
|
239 | - $file_description = '<span class="highlight">' . $file_description . '</span>'; |
|
238 | + if ($absolute_filename === $file) { |
|
239 | + $file_description = '<span class="highlight">'.$file_description.'</span>'; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $previous_file_type = $file_type; |
243 | 243 | ?> |
244 | - <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li> |
|
244 | + <li><a href="theme-editor.php?file=<?php echo urlencode($filename) ?>&theme=<?php echo urlencode($stylesheet) ?>"><?php echo $file_description; ?></a></li> |
|
245 | 245 | <?php |
246 | 246 | endforeach; |
247 | 247 | ?> |
248 | 248 | </ul> |
249 | 249 | <?php endif; ?> |
250 | 250 | </div> |
251 | -<?php if ( $error ) : |
|
252 | - echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>'; |
|
251 | +<?php if ($error) : |
|
252 | + echo '<div class="error"><p>'.__('Oops, no such file exists! Double check the name and try again, merci.').'</p></div>'; |
|
253 | 253 | else : ?> |
254 | 254 | <form name="template" id="template" action="theme-editor.php" method="post"> |
255 | - <?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?> |
|
255 | + <?php wp_nonce_field('edit-theme_'.$file.$stylesheet); ?> |
|
256 | 256 | <div><textarea cols="70" rows="30" name="newcontent" id="newcontent" aria-describedby="newcontent-description"><?php echo $content; ?></textarea> |
257 | 257 | <input type="hidden" name="action" value="update" /> |
258 | - <input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" /> |
|
259 | - <input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" /> |
|
258 | + <input type="hidden" name="file" value="<?php echo esc_attr($relative_file); ?>" /> |
|
259 | + <input type="hidden" name="theme" value="<?php echo esc_attr($theme->get_stylesheet()); ?>" /> |
|
260 | 260 | <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" /> |
261 | 261 | </div> |
262 | - <?php if ( ! empty( $functions ) ) : ?> |
|
262 | + <?php if ( ! empty($functions)) : ?> |
|
263 | 263 | <div id="documentation" class="hide-if-no-js"> |
264 | 264 | <label for="docs-list"><?php _e('Documentation:') ?></label> |
265 | 265 | <?php echo $docs_select; ?> |
266 | - <input 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'); }" /> |
|
266 | + <input 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'); }" /> |
|
267 | 267 | </div> |
268 | 268 | <?php endif; ?> |
269 | 269 | |
270 | 270 | <div> |
271 | - <?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?> |
|
272 | - <p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?> |
|
273 | - <?php _e( 'This is a file in your current parent theme.' ); ?></p> |
|
271 | + <?php if (is_child_theme() && $theme->get_stylesheet() == get_template()) : ?> |
|
272 | + <p><?php if (is_writeable($file)) { ?><strong><?php _e('Caution:'); ?></strong><?php } ?> |
|
273 | + <?php _e('This is a file in your current parent theme.'); ?></p> |
|
274 | 274 | <?php endif; ?> |
275 | 275 | <?php |
276 | - if ( is_writeable( $file ) ) : |
|
277 | - submit_button( __( 'Update File' ), 'primary', 'submit', true ); |
|
276 | + if (is_writeable($file)) : |
|
277 | + submit_button(__('Update File'), 'primary', 'submit', true); |
|
278 | 278 | else : ?> |
279 | 279 | <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> |
280 | 280 | <?php endif; ?> |
@@ -295,4 +295,4 @@ discard block |
||
295 | 295 | break; |
296 | 296 | } |
297 | 297 | |
298 | -include(ABSPATH . 'wp-admin/admin-footer.php' ); |
|
298 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -12,14 +12,16 @@ discard block |
||
12 | 12 | define( 'WPINC', 'wp-includes' ); |
13 | 13 | |
14 | 14 | $load = $_GET['load']; |
15 | -if ( is_array( $load ) ) |
|
15 | +if ( is_array( $load ) ) { |
|
16 | 16 | $load = implode( '', $load ); |
17 | +} |
|
17 | 18 | |
18 | 19 | $load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
19 | 20 | $load = array_unique( explode( ',', $load ) ); |
20 | 21 | |
21 | -if ( empty($load) ) |
|
22 | +if ( empty($load) ) { |
|
22 | 23 | exit; |
24 | +} |
|
23 | 25 | |
24 | 26 | require( ABSPATH . 'wp-admin/includes/noop.php' ); |
25 | 27 | require( ABSPATH . WPINC . '/script-loader.php' ); |
@@ -43,8 +45,9 @@ discard block |
||
43 | 45 | } |
44 | 46 | |
45 | 47 | foreach ( $load as $handle ) { |
46 | - if ( !array_key_exists($handle, $wp_scripts->registered) ) |
|
47 | - continue; |
|
48 | + if ( !array_key_exists($handle, $wp_scripts->registered) ) { |
|
49 | + continue; |
|
50 | + } |
|
48 | 51 | |
49 | 52 | $path = ABSPATH . $wp_scripts->registered[$handle]->src; |
50 | 53 | $out .= get_file($path) . "\n"; |
@@ -8,64 +8,64 @@ |
||
8 | 8 | error_reporting(0); |
9 | 9 | |
10 | 10 | /** Set ABSPATH for execution */ |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | - define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | + define('ABSPATH', dirname(dirname(__FILE__)).'/'); |
|
13 | 13 | } |
14 | 14 | |
15 | -define( 'WPINC', 'wp-includes' ); |
|
15 | +define('WPINC', 'wp-includes'); |
|
16 | 16 | |
17 | 17 | $load = $_GET['load']; |
18 | -if ( is_array( $load ) ) |
|
19 | - $load = implode( '', $load ); |
|
18 | +if (is_array($load)) |
|
19 | + $load = implode('', $load); |
|
20 | 20 | |
21 | -$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); |
|
22 | -$load = array_unique( explode( ',', $load ) ); |
|
21 | +$load = preg_replace('/[^a-z0-9,_-]+/i', '', $load); |
|
22 | +$load = array_unique(explode(',', $load)); |
|
23 | 23 | |
24 | -if ( empty($load) ) |
|
24 | +if (empty($load)) |
|
25 | 25 | exit; |
26 | 26 | |
27 | -require( ABSPATH . 'wp-admin/includes/noop.php' ); |
|
28 | -require( ABSPATH . WPINC . '/script-loader.php' ); |
|
29 | -require( ABSPATH . WPINC . '/version.php' ); |
|
27 | +require(ABSPATH.'wp-admin/includes/noop.php'); |
|
28 | +require(ABSPATH.WPINC.'/script-loader.php'); |
|
29 | +require(ABSPATH.WPINC.'/version.php'); |
|
30 | 30 | |
31 | -$compress = ( isset($_GET['c']) && $_GET['c'] ); |
|
32 | -$force_gzip = ( $compress && 'gzip' == $_GET['c'] ); |
|
31 | +$compress = (isset($_GET['c']) && $_GET['c']); |
|
32 | +$force_gzip = ($compress && 'gzip' == $_GET['c']); |
|
33 | 33 | $expires_offset = 31536000; // 1 year |
34 | 34 | $out = ''; |
35 | 35 | |
36 | 36 | $wp_scripts = new WP_Scripts(); |
37 | 37 | wp_default_scripts($wp_scripts); |
38 | 38 | |
39 | -if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) { |
|
39 | +if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) === $wp_version) { |
|
40 | 40 | $protocol = $_SERVER['SERVER_PROTOCOL']; |
41 | - if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
|
41 | + if ( ! in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) { |
|
42 | 42 | $protocol = 'HTTP/1.0'; |
43 | 43 | } |
44 | - header( "$protocol 304 Not Modified" ); |
|
44 | + header("$protocol 304 Not Modified"); |
|
45 | 45 | exit(); |
46 | 46 | } |
47 | 47 | |
48 | -foreach ( $load as $handle ) { |
|
49 | - if ( !array_key_exists($handle, $wp_scripts->registered) ) |
|
48 | +foreach ($load as $handle) { |
|
49 | + if ( ! array_key_exists($handle, $wp_scripts->registered)) |
|
50 | 50 | continue; |
51 | 51 | |
52 | - $path = ABSPATH . $wp_scripts->registered[$handle]->src; |
|
53 | - $out .= get_file($path) . "\n"; |
|
52 | + $path = ABSPATH.$wp_scripts->registered[$handle]->src; |
|
53 | + $out .= get_file($path)."\n"; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | header("Etag: $wp_version"); |
57 | 57 | header('Content-Type: application/javascript; charset=UTF-8'); |
58 | -header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT'); |
|
58 | +header('Expires: '.gmdate("D, d M Y H:i:s", time() + $expires_offset).' GMT'); |
|
59 | 59 | header("Cache-Control: public, max-age=$expires_offset"); |
60 | 60 | |
61 | -if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { |
|
61 | +if ($compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { |
|
62 | 62 | header('Vary: Accept-Encoding'); // Handle proxies |
63 | - if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) { |
|
63 | + if (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip) { |
|
64 | 64 | header('Content-Encoding: deflate'); |
65 | - $out = gzdeflate( $out, 3 ); |
|
66 | - } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) { |
|
65 | + $out = gzdeflate($out, 3); |
|
66 | + } elseif (false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode')) { |
|
67 | 67 | header('Content-Encoding: gzip'); |
68 | - $out = gzencode( $out, 3 ); |
|
68 | + $out = gzencode($out, 3); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 |