@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | * @param WP_Upgrader $upgrader |
40 | 40 | */ |
41 | 41 | public function set_upgrader(&$upgrader) { |
42 | - if ( is_object($upgrader) ) |
|
43 | - $this->upgrader =& $upgrader; |
|
42 | + if ( is_object($upgrader) ) { |
|
43 | + $this->upgrader =& $upgrader; |
|
44 | + } |
|
44 | 45 | $this->add_strings(); |
45 | 46 | } |
46 | 47 | |
@@ -107,16 +108,18 @@ discard block |
||
107 | 108 | * @param string|WP_Error $errors |
108 | 109 | */ |
109 | 110 | public function error($errors) { |
110 | - if ( ! $this->done_header ) |
|
111 | - $this->header(); |
|
111 | + if ( ! $this->done_header ) { |
|
112 | + $this->header(); |
|
113 | + } |
|
112 | 114 | if ( is_string($errors) ) { |
113 | 115 | $this->feedback($errors); |
114 | 116 | } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { |
115 | 117 | foreach ( $errors->get_error_messages() as $message ) { |
116 | - if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) |
|
117 | - $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
118 | - else |
|
119 | - $this->feedback($message); |
|
118 | + if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) { |
|
119 | + $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
120 | + } else { |
|
121 | + $this->feedback($message); |
|
122 | + } |
|
120 | 123 | } |
121 | 124 | } |
122 | 125 | } |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | * @param string $string |
127 | 130 | */ |
128 | 131 | public function feedback($string) { |
129 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
130 | - $string = $this->upgrader->strings[$string]; |
|
132 | + if ( isset( $this->upgrader->strings[$string] ) ) { |
|
133 | + $string = $this->upgrader->strings[$string]; |
|
134 | + } |
|
131 | 135 | |
132 | 136 | if ( strpos($string, '%') !== false ) { |
133 | 137 | $args = func_get_args(); |
@@ -138,8 +142,9 @@ discard block |
||
138 | 142 | $string = vsprintf($string, $args); |
139 | 143 | } |
140 | 144 | } |
141 | - if ( empty($string) ) |
|
142 | - return; |
|
145 | + if ( empty($string) ) { |
|
146 | + return; |
|
147 | + } |
|
143 | 148 | show_message($string); |
144 | 149 | } |
145 | 150 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $args |
35 | 35 | */ |
36 | 36 | public function __construct($args = array()) { |
37 | - $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); |
|
37 | + $defaults = array('url' => '', 'nonce' => '', 'title' => '', 'context' => false); |
|
38 | 38 | $this->options = wp_parse_args($args, $defaults); |
39 | 39 | } |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param WP_Upgrader $upgrader |
43 | 43 | */ |
44 | 44 | public function set_upgrader(&$upgrader) { |
45 | - if ( is_object($upgrader) ) |
|
46 | - $this->upgrader =& $upgrader; |
|
45 | + if (is_object($upgrader)) |
|
46 | + $this->upgrader = & $upgrader; |
|
47 | 47 | $this->add_strings(); |
48 | 48 | } |
49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param string|bool|WP_Error $result The result of an upgrade. |
63 | 63 | */ |
64 | - public function set_result( $result ) { |
|
64 | + public function set_result($result) { |
|
65 | 65 | $this->result = $result; |
66 | 66 | } |
67 | 67 | |
@@ -81,37 +81,37 @@ discard block |
||
81 | 81 | * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
82 | 82 | * @return bool False on failure, true on success. |
83 | 83 | */ |
84 | - public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { |
|
84 | + public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false) { |
|
85 | 85 | $url = $this->options['url']; |
86 | - if ( ! $context ) { |
|
86 | + if ( ! $context) { |
|
87 | 87 | $context = $this->options['context']; |
88 | 88 | } |
89 | - if ( !empty($this->options['nonce']) ) { |
|
89 | + if ( ! empty($this->options['nonce'])) { |
|
90 | 90 | $url = wp_nonce_url($url, $this->options['nonce']); |
91 | 91 | } |
92 | 92 | |
93 | 93 | $extra_fields = array(); |
94 | 94 | |
95 | - return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
|
95 | + return request_filesystem_credentials($url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @access public |
100 | 100 | */ |
101 | 101 | public function header() { |
102 | - if ( $this->done_header ) { |
|
102 | + if ($this->done_header) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | $this->done_header = true; |
106 | 106 | echo '<div class="wrap">'; |
107 | - echo '<h1>' . $this->options['title'] . '</h1>'; |
|
107 | + echo '<h1>'.$this->options['title'].'</h1>'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @access public |
112 | 112 | */ |
113 | 113 | public function footer() { |
114 | - if ( $this->done_footer ) { |
|
114 | + if ($this->done_footer) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | $this->done_footer = true; |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | * @param string|WP_Error $errors |
124 | 124 | */ |
125 | 125 | public function error($errors) { |
126 | - if ( ! $this->done_header ) |
|
126 | + if ( ! $this->done_header) |
|
127 | 127 | $this->header(); |
128 | - if ( is_string($errors) ) { |
|
128 | + if (is_string($errors)) { |
|
129 | 129 | $this->feedback($errors); |
130 | - } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { |
|
131 | - foreach ( $errors->get_error_messages() as $message ) { |
|
132 | - if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) |
|
133 | - $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
130 | + } elseif (is_wp_error($errors) && $errors->get_error_code()) { |
|
131 | + foreach ($errors->get_error_messages() as $message) { |
|
132 | + if ($errors->get_error_data() && is_string($errors->get_error_data())) |
|
133 | + $this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data()))); |
|
134 | 134 | else |
135 | 135 | $this->feedback($message); |
136 | 136 | } |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $string |
143 | 143 | */ |
144 | 144 | public function feedback($string) { |
145 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
145 | + if (isset($this->upgrader->strings[$string])) |
|
146 | 146 | $string = $this->upgrader->strings[$string]; |
147 | 147 | |
148 | - if ( strpos($string, '%') !== false ) { |
|
148 | + if (strpos($string, '%') !== false) { |
|
149 | 149 | $args = func_get_args(); |
150 | 150 | $args = array_splice($args, 1); |
151 | - if ( $args ) { |
|
152 | - $args = array_map( 'strip_tags', $args ); |
|
153 | - $args = array_map( 'esc_html', $args ); |
|
151 | + if ($args) { |
|
152 | + $args = array_map('strip_tags', $args); |
|
153 | + $args = array_map('esc_html', $args); |
|
154 | 154 | $string = vsprintf($string, $args); |
155 | 155 | } |
156 | 156 | } |
157 | - if ( empty($string) ) |
|
157 | + if (empty($string)) |
|
158 | 158 | return; |
159 | 159 | show_message($string); |
160 | 160 | } |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | * @param string $type Type of update count to decrement. Likely values include 'plugin', |
178 | 178 | * 'theme', 'translation', etc. |
179 | 179 | */ |
180 | - protected function decrement_update_count( $type ) { |
|
181 | - if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) { |
|
180 | + protected function decrement_update_count($type) { |
|
181 | + if ( ! $this->result || is_wp_error($this->result) || 'up_to_date' === $this->result) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - if ( defined( 'IFRAME_REQUEST' ) ) { |
|
185 | + if (defined('IFRAME_REQUEST')) { |
|
186 | 186 | echo '<script type="text/javascript"> |
187 | 187 | if ( window.postMessage && JSON ) { |
188 | - window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname ); |
|
188 | + window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type.'" } ), window.location.protocol + "//" + window.location.hostname ); |
|
189 | 189 | } |
190 | 190 | </script>'; |
191 | 191 | } else { |
192 | 192 | echo '<script type="text/javascript"> |
193 | 193 | (function( wp ) { |
194 | 194 | if ( wp && wp.updates.decrementCount ) { |
195 | - wp.updates.decrementCount( "' . $type . '" ); |
|
195 | + wp.updates.decrementCount( "' . $type.'" ); |
|
196 | 196 | } |
197 | 197 | })( window.wp ); |
198 | 198 | </script>'; |
@@ -56,16 +56,18 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __construct( $form, $urlholder ) { |
58 | 58 | |
59 | - if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) |
|
60 | - wp_die(__('Please select a file')); |
|
59 | + if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) { |
|
60 | + wp_die(__('Please select a file')); |
|
61 | + } |
|
61 | 62 | |
62 | 63 | //Handle a newly uploaded file, Else assume it's already been uploaded |
63 | 64 | if ( ! empty($_FILES) ) { |
64 | 65 | $overrides = array( 'test_form' => false, 'test_type' => false ); |
65 | 66 | $file = wp_handle_upload( $_FILES[$form], $overrides ); |
66 | 67 | |
67 | - if ( isset( $file['error'] ) ) |
|
68 | - wp_die( $file['error'] ); |
|
68 | + if ( isset( $file['error'] ) ) { |
|
69 | + wp_die( $file['error'] ); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | $this->filename = $_FILES[$form]['name']; |
71 | 73 | $this->package = $file['file']; |
@@ -90,15 +92,17 @@ discard block |
||
90 | 92 | // Numeric Package = previously uploaded file, see above. |
91 | 93 | $this->id = (int) $_GET[$urlholder]; |
92 | 94 | $attachment = get_post( $this->id ); |
93 | - if ( empty($attachment) ) |
|
94 | - wp_die(__('Please select a file')); |
|
95 | + if ( empty($attachment) ) { |
|
96 | + wp_die(__('Please select a file')); |
|
97 | + } |
|
95 | 98 | |
96 | 99 | $this->filename = $attachment->post_title; |
97 | 100 | $this->package = get_attached_file( $attachment->ID ); |
98 | 101 | } else { |
99 | 102 | // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler. |
100 | - if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) |
|
101 | - wp_die( $uploads['error'] ); |
|
103 | + if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) { |
|
104 | + wp_die( $uploads['error'] ); |
|
105 | + } |
|
102 | 106 | |
103 | 107 | $this->filename = $_GET[$urlholder]; |
104 | 108 | $this->package = $uploads['basedir'] . '/' . $this->filename; |
@@ -114,11 +118,11 @@ discard block |
||
114 | 118 | * @return bool Whether the cleanup was successful. |
115 | 119 | */ |
116 | 120 | public function cleanup() { |
117 | - if ( $this->id ) |
|
118 | - wp_delete_attachment( $this->id ); |
|
119 | - |
|
120 | - elseif ( file_exists( $this->package ) ) |
|
121 | - return @unlink( $this->package ); |
|
121 | + if ( $this->id ) { |
|
122 | + wp_delete_attachment( $this->id ); |
|
123 | + } elseif ( file_exists( $this->package ) ) { |
|
124 | + return @unlink( $this->package ); |
|
125 | + } |
|
122 | 126 | |
123 | 127 | return true; |
124 | 128 | } |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | * @param string $form The name of the form the file was uploaded from. |
55 | 55 | * @param string $urlholder The name of the `GET` parameter that holds the filename. |
56 | 56 | */ |
57 | - public function __construct( $form, $urlholder ) { |
|
57 | + public function __construct($form, $urlholder) { |
|
58 | 58 | |
59 | - if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) ) |
|
59 | + if (empty($_FILES[$form]['name']) && empty($_GET[$urlholder])) |
|
60 | 60 | wp_die(__('Please select a file')); |
61 | 61 | |
62 | 62 | //Handle a newly uploaded file, Else assume it's already been uploaded |
63 | - if ( ! empty($_FILES) ) { |
|
64 | - $overrides = array( 'test_form' => false, 'test_type' => false ); |
|
65 | - $file = wp_handle_upload( $_FILES[$form], $overrides ); |
|
63 | + if ( ! empty($_FILES)) { |
|
64 | + $overrides = array('test_form' => false, 'test_type' => false); |
|
65 | + $file = wp_handle_upload($_FILES[$form], $overrides); |
|
66 | 66 | |
67 | - if ( isset( $file['error'] ) ) |
|
68 | - wp_die( $file['error'] ); |
|
67 | + if (isset($file['error'])) |
|
68 | + wp_die($file['error']); |
|
69 | 69 | |
70 | 70 | $this->filename = $_FILES[$form]['name']; |
71 | 71 | $this->package = $file['file']; |
@@ -81,30 +81,30 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Save the data. |
84 | - $this->id = wp_insert_attachment( $object, $file['file'] ); |
|
84 | + $this->id = wp_insert_attachment($object, $file['file']); |
|
85 | 85 | |
86 | 86 | // Schedule a cleanup for 2 hours from now in case of failed install. |
87 | - wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) ); |
|
87 | + wp_schedule_single_event(time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array($this->id)); |
|
88 | 88 | |
89 | - } elseif ( is_numeric( $_GET[$urlholder] ) ) { |
|
89 | + } elseif (is_numeric($_GET[$urlholder])) { |
|
90 | 90 | // Numeric Package = previously uploaded file, see above. |
91 | 91 | $this->id = (int) $_GET[$urlholder]; |
92 | - $attachment = get_post( $this->id ); |
|
93 | - if ( empty($attachment) ) |
|
92 | + $attachment = get_post($this->id); |
|
93 | + if (empty($attachment)) |
|
94 | 94 | wp_die(__('Please select a file')); |
95 | 95 | |
96 | 96 | $this->filename = $attachment->post_title; |
97 | - $this->package = get_attached_file( $attachment->ID ); |
|
97 | + $this->package = get_attached_file($attachment->ID); |
|
98 | 98 | } else { |
99 | 99 | // Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler. |
100 | - if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) |
|
101 | - wp_die( $uploads['error'] ); |
|
100 | + if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) |
|
101 | + wp_die($uploads['error']); |
|
102 | 102 | |
103 | - $this->filename = sanitize_file_name( $_GET[ $urlholder ] ); |
|
104 | - $this->package = $uploads['basedir'] . '/' . $this->filename; |
|
103 | + $this->filename = sanitize_file_name($_GET[$urlholder]); |
|
104 | + $this->package = $uploads['basedir'].'/'.$this->filename; |
|
105 | 105 | |
106 | - if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) { |
|
107 | - wp_die( __( 'Please select a file' ) ); |
|
106 | + if (0 !== strpos(realpath($this->package), realpath($uploads['basedir']))) { |
|
107 | + wp_die(__('Please select a file')); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @return bool Whether the cleanup was successful. |
119 | 119 | */ |
120 | 120 | public function cleanup() { |
121 | - if ( $this->id ) |
|
122 | - wp_delete_attachment( $this->id ); |
|
121 | + if ($this->id) |
|
122 | + wp_delete_attachment($this->id); |
|
123 | 123 | |
124 | - elseif ( file_exists( $this->package ) ) |
|
125 | - return @unlink( $this->package ); |
|
124 | + elseif (file_exists($this->package)) |
|
125 | + return @unlink($this->package); |
|
126 | 126 | |
127 | 127 | return true; |
128 | 128 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param array $args |
26 | 26 | */ |
27 | 27 | public function __construct($args = array()) { |
28 | - $defaults = array( 'url' => '', 'nonce' => '' ); |
|
28 | + $defaults = array('url' => '', 'nonce' => ''); |
|
29 | 29 | $args = wp_parse_args($args, $defaults); |
30 | 30 | |
31 | 31 | parent::__construct($args); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /* translators: 1: Title of an update */ |
42 | 42 | $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); |
43 | 43 | /* translators: 1: Title of an update */ |
44 | - $this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details' ) . '</span><span class="hidden">' . __( 'Hide Details' ) . '</span></a>'; |
|
44 | + $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span></a>'; |
|
45 | 45 | $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.'); |
46 | 46 | } |
47 | 47 | |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | * @param string $string |
50 | 50 | */ |
51 | 51 | public function feedback($string) { |
52 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
52 | + if (isset($this->upgrader->strings[$string])) |
|
53 | 53 | $string = $this->upgrader->strings[$string]; |
54 | 54 | |
55 | - if ( strpos($string, '%') !== false ) { |
|
55 | + if (strpos($string, '%') !== false) { |
|
56 | 56 | $args = func_get_args(); |
57 | 57 | $args = array_splice($args, 1); |
58 | - if ( $args ) { |
|
59 | - $args = array_map( 'strip_tags', $args ); |
|
60 | - $args = array_map( 'esc_html', $args ); |
|
58 | + if ($args) { |
|
59 | + $args = array_map('strip_tags', $args); |
|
60 | + $args = array_map('esc_html', $args); |
|
61 | 61 | $string = vsprintf($string, $args); |
62 | 62 | } |
63 | 63 | } |
64 | - if ( empty($string) ) |
|
64 | + if (empty($string)) |
|
65 | 65 | return; |
66 | - if ( $this->in_loop ) |
|
66 | + if ($this->in_loop) |
|
67 | 67 | echo "$string<br />\n"; |
68 | 68 | else |
69 | 69 | echo "<p>$string</p>\n"; |
@@ -88,20 +88,20 @@ discard block |
||
88 | 88 | * @param string|WP_Error $error |
89 | 89 | */ |
90 | 90 | public function error($error) { |
91 | - if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) |
|
91 | + if (is_string($error) && isset($this->upgrader->strings[$error])) |
|
92 | 92 | $this->error = $this->upgrader->strings[$error]; |
93 | 93 | |
94 | - if ( is_wp_error($error) ) { |
|
94 | + if (is_wp_error($error)) { |
|
95 | 95 | $messages = array(); |
96 | - foreach ( $error->get_error_messages() as $emessage ) { |
|
97 | - if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) |
|
98 | - $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
96 | + foreach ($error->get_error_messages() as $emessage) { |
|
97 | + if ($error->get_error_data() && is_string($error->get_error_data())) |
|
98 | + $messages[] = $emessage.' '.esc_html(strip_tags($error->get_error_data())); |
|
99 | 99 | else |
100 | 100 | $messages[] = $emessage; |
101 | 101 | } |
102 | 102 | $this->error = implode(', ', $messages); |
103 | 103 | } |
104 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
|
104 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').hide();</script>'; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function before($title = '') { |
126 | 126 | $this->in_loop = true; |
127 | - printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count ); |
|
128 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>'; |
|
129 | - echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>'; |
|
127 | + printf('<h2>'.$this->upgrader->strings['skin_before_update_header'].' <span class="spinner waiting-'.$this->upgrader->update_current.'"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count); |
|
128 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').css("display", "inline-block");</script>'; |
|
129 | + echo '<div class="update-messages hide-if-js" id="progress-'.esc_attr($this->upgrader->update_current).'"><p>'; |
|
130 | 130 | $this->flush_output(); |
131 | 131 | } |
132 | 132 | |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function after($title = '') { |
138 | 138 | echo '</p></div>'; |
139 | - if ( $this->error || ! $this->result ) { |
|
140 | - if ( $this->error ) { |
|
141 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>'; |
|
139 | + if ($this->error || ! $this->result) { |
|
140 | + if ($this->error) { |
|
141 | + echo '<div class="error"><p>'.sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>'.$this->error.'</strong>').'</p></div>'; |
|
142 | 142 | } else { |
143 | - echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>'; |
|
143 | + echo '<div class="error"><p>'.sprintf($this->upgrader->strings['skin_update_failed'], $title).'</p></div>'; |
|
144 | 144 | } |
145 | 145 | |
146 | - echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; |
|
146 | + echo '<script type="text/javascript">jQuery(\'#progress-'.esc_js($this->upgrader->update_current).'\').show();</script>'; |
|
147 | 147 | } |
148 | - if ( $this->result && ! is_wp_error( $this->result ) ) { |
|
149 | - if ( ! $this->error ) |
|
150 | - echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
151 | - echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
|
148 | + if ($this->result && ! is_wp_error($this->result)) { |
|
149 | + if ( ! $this->error) |
|
150 | + echo '<div class="updated"><p>'.sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-'.esc_js($this->upgrader->update_current).'\').toggle();jQuery(\'span\', this).toggle(); return false;').'</p></div>'; |
|
151 | + echo '<script type="text/javascript">jQuery(\'.waiting-'.esc_js($this->upgrader->update_current).'\').hide();</script>'; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $this->reset(); |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | * @param string $string |
50 | 50 | */ |
51 | 51 | public function feedback($string) { |
52 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
53 | - $string = $this->upgrader->strings[$string]; |
|
52 | + if ( isset( $this->upgrader->strings[$string] ) ) { |
|
53 | + $string = $this->upgrader->strings[$string]; |
|
54 | + } |
|
54 | 55 | |
55 | 56 | if ( strpos($string, '%') !== false ) { |
56 | 57 | $args = func_get_args(); |
@@ -61,12 +62,14 @@ discard block |
||
61 | 62 | $string = vsprintf($string, $args); |
62 | 63 | } |
63 | 64 | } |
64 | - if ( empty($string) ) |
|
65 | - return; |
|
66 | - if ( $this->in_loop ) |
|
67 | - echo "$string<br />\n"; |
|
68 | - else |
|
69 | - echo "<p>$string</p>\n"; |
|
65 | + if ( empty($string) ) { |
|
66 | + return; |
|
67 | + } |
|
68 | + if ( $this->in_loop ) { |
|
69 | + echo "$string<br />\n"; |
|
70 | + } else { |
|
71 | + echo "<p>$string</p>\n"; |
|
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | /** |
@@ -88,16 +91,18 @@ discard block |
||
88 | 91 | * @param string|WP_Error $error |
89 | 92 | */ |
90 | 93 | public function error($error) { |
91 | - if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) |
|
92 | - $this->error = $this->upgrader->strings[$error]; |
|
94 | + if ( is_string($error) && isset( $this->upgrader->strings[$error] ) ) { |
|
95 | + $this->error = $this->upgrader->strings[$error]; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ( is_wp_error($error) ) { |
95 | 99 | $messages = array(); |
96 | 100 | foreach ( $error->get_error_messages() as $emessage ) { |
97 | - if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) |
|
98 | - $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
99 | - else |
|
100 | - $messages[] = $emessage; |
|
101 | + if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) { |
|
102 | + $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) ); |
|
103 | + } else { |
|
104 | + $messages[] = $emessage; |
|
105 | + } |
|
101 | 106 | } |
102 | 107 | $this->error = implode(', ', $messages); |
103 | 108 | } |
@@ -146,8 +151,9 @@ discard block |
||
146 | 151 | echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>'; |
147 | 152 | } |
148 | 153 | if ( $this->result && ! is_wp_error( $this->result ) ) { |
149 | - if ( ! $this->error ) |
|
150 | - echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
154 | + if ( ! $this->error ) { |
|
155 | + echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>'; |
|
156 | + } |
|
151 | 157 | echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>'; |
152 | 158 | } |
153 | 159 |
@@ -94,10 +94,12 @@ discard block |
||
94 | 94 | * the latest sites with no paging in order to avoid expensive count queries. |
95 | 95 | */ |
96 | 96 | if ( !$s && wp_is_large_network() ) { |
97 | - if ( !isset($_REQUEST['orderby']) ) |
|
98 | - $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
99 | - if ( !isset($_REQUEST['order']) ) |
|
100 | - $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
97 | + if ( !isset($_REQUEST['orderby']) ) { |
|
98 | + $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
|
99 | + } |
|
100 | + if ( !isset($_REQUEST['order']) ) { |
|
101 | + $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
|
102 | + } |
|
101 | 103 | } |
102 | 104 | |
103 | 105 | $args = array( |
@@ -199,8 +201,9 @@ discard block |
||
199 | 201 | */ |
200 | 202 | protected function get_bulk_actions() { |
201 | 203 | $actions = array(); |
202 | - if ( current_user_can( 'delete_sites' ) ) |
|
203 | - $actions['delete'] = __( 'Delete' ); |
|
204 | + if ( current_user_can( 'delete_sites' ) ) { |
|
205 | + $actions['delete'] = __( 'Delete' ); |
|
206 | + } |
|
204 | 207 | $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
205 | 208 | $actions['notspam'] = _x( 'Not Spam', 'site' ); |
206 | 209 | |
@@ -217,8 +220,9 @@ discard block |
||
217 | 220 | |
218 | 221 | parent::pagination( $which ); |
219 | 222 | |
220 | - if ( 'top' === $which ) |
|
221 | - $this->view_switcher( $mode ); |
|
223 | + if ( 'top' === $which ) { |
|
224 | + $this->view_switcher( $mode ); |
|
225 | + } |
|
222 | 226 | } |
223 | 227 | |
224 | 228 | /** |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $args An associative array of arguments. |
38 | 38 | */ |
39 | - public function __construct( $args = array() ) { |
|
39 | + public function __construct($args = array()) { |
|
40 | 40 | $this->status_list = array( |
41 | - 'archived' => array( 'site-archived', __( 'Archived' ) ), |
|
42 | - 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), |
|
43 | - 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), |
|
44 | - 'mature' => array( 'site-mature', __( 'Mature' ) ) |
|
41 | + 'archived' => array('site-archived', __('Archived')), |
|
42 | + 'spam' => array('site-spammed', _x('Spam', 'site')), |
|
43 | + 'deleted' => array('site-deleted', __('Deleted')), |
|
44 | + 'mature' => array('site-mature', __('Mature')) |
|
45 | 45 | ); |
46 | 46 | |
47 | - parent::__construct( array( |
|
47 | + parent::__construct(array( |
|
48 | 48 | 'plural' => 'sites', |
49 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
50 | - ) ); |
|
49 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
50 | + )); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return bool |
56 | 56 | */ |
57 | 57 | public function ajax_user_can() { |
58 | - return current_user_can( 'manage_sites' ); |
|
58 | + return current_user_can('manage_sites'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | public function prepare_items() { |
71 | 71 | global $s, $mode, $wpdb; |
72 | 72 | |
73 | - if ( ! empty( $_REQUEST['mode'] ) ) { |
|
73 | + if ( ! empty($_REQUEST['mode'])) { |
|
74 | 74 | $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; |
75 | - set_user_setting( 'sites_list_mode', $mode ); |
|
75 | + set_user_setting('sites_list_mode', $mode); |
|
76 | 76 | } else { |
77 | - $mode = get_user_setting( 'sites_list_mode', 'list' ); |
|
77 | + $mode = get_user_setting('sites_list_mode', 'list'); |
|
78 | 78 | } |
79 | 79 | |
80 | - $per_page = $this->get_items_per_page( 'sites_network_per_page' ); |
|
80 | + $per_page = $this->get_items_per_page('sites_network_per_page'); |
|
81 | 81 | |
82 | 82 | $pagenum = $this->get_pagenum(); |
83 | 83 | |
84 | - $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : ''; |
|
84 | + $s = isset($_REQUEST['s']) ? wp_unslash(trim($_REQUEST['s'])) : ''; |
|
85 | 85 | $wild = ''; |
86 | - if ( false !== strpos($s, '*') ) { |
|
86 | + if (false !== strpos($s, '*')) { |
|
87 | 87 | $wild = '*'; |
88 | 88 | $s = trim($s, '*'); |
89 | 89 | } |
@@ -92,66 +92,66 @@ discard block |
||
92 | 92 | * If the network is large and a search is not being performed, show only |
93 | 93 | * the latest sites with no paging in order to avoid expensive count queries. |
94 | 94 | */ |
95 | - if ( !$s && wp_is_large_network() ) { |
|
96 | - if ( !isset($_REQUEST['orderby']) ) |
|
95 | + if ( ! $s && wp_is_large_network()) { |
|
96 | + if ( ! isset($_REQUEST['orderby'])) |
|
97 | 97 | $_GET['orderby'] = $_REQUEST['orderby'] = ''; |
98 | - if ( !isset($_REQUEST['order']) ) |
|
98 | + if ( ! isset($_REQUEST['order'])) |
|
99 | 99 | $_GET['order'] = $_REQUEST['order'] = 'DESC'; |
100 | 100 | } |
101 | 101 | |
102 | 102 | $args = array( |
103 | - 'number' => intval( $per_page ), |
|
104 | - 'offset' => intval( ( $pagenum - 1 ) * $per_page ), |
|
103 | + 'number' => intval($per_page), |
|
104 | + 'offset' => intval(($pagenum - 1) * $per_page), |
|
105 | 105 | 'network_id' => get_current_network_id(), |
106 | 106 | ); |
107 | 107 | |
108 | - if ( empty($s) ) { |
|
108 | + if (empty($s)) { |
|
109 | 109 | // Nothing to do. |
110 | - } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || |
|
111 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
112 | - preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || |
|
113 | - preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { |
|
110 | + } elseif (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s) || |
|
111 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
112 | + preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s) || |
|
113 | + preg_match('/^[0-9]{1,3}\.$/', $s)) { |
|
114 | 114 | // IPv4 address |
115 | - $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) ); |
|
116 | - $reg_blog_ids = $wpdb->get_col( $sql ); |
|
115 | + $sql = $wpdb->prepare("SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like($s).( ! empty($wild) ? '%' : '')); |
|
116 | + $reg_blog_ids = $wpdb->get_col($sql); |
|
117 | 117 | |
118 | - if ( $reg_blog_ids ) { |
|
118 | + if ($reg_blog_ids) { |
|
119 | 119 | $args['site__in'] = $reg_blog_ids; |
120 | 120 | } |
121 | - } elseif ( is_numeric( $s ) && empty( $wild ) ) { |
|
121 | + } elseif (is_numeric($s) && empty($wild)) { |
|
122 | 122 | $args['ID'] = $s; |
123 | 123 | } else { |
124 | 124 | $args['search'] = $s; |
125 | 125 | |
126 | - if ( ! is_subdomain_install() ) { |
|
127 | - $args['search_columns'] = array( 'path' ); |
|
126 | + if ( ! is_subdomain_install()) { |
|
127 | + $args['search_columns'] = array('path'); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; |
|
132 | - if ( 'registered' === $order_by ) { |
|
131 | + $order_by = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''; |
|
132 | + if ('registered' === $order_by) { |
|
133 | 133 | // registered is a valid field name. |
134 | - } elseif ( 'lastupdated' === $order_by ) { |
|
134 | + } elseif ('lastupdated' === $order_by) { |
|
135 | 135 | $order_by = 'last_updated'; |
136 | - } elseif ( 'blogname' === $order_by ) { |
|
137 | - if ( is_subdomain_install() ) { |
|
136 | + } elseif ('blogname' === $order_by) { |
|
137 | + if (is_subdomain_install()) { |
|
138 | 138 | $order_by = 'domain'; |
139 | 139 | } else { |
140 | 140 | $order_by = 'path'; |
141 | 141 | } |
142 | - } elseif ( 'blog_id' === $order_by ) { |
|
142 | + } elseif ('blog_id' === $order_by) { |
|
143 | 143 | $order_by = 'id'; |
144 | - } elseif ( ! $order_by ) { |
|
144 | + } elseif ( ! $order_by) { |
|
145 | 145 | $order_by = false; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $args['orderby'] = $order_by; |
149 | 149 | |
150 | - if ( $order_by ) { |
|
151 | - $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC"; |
|
150 | + if ($order_by) { |
|
151 | + $args['order'] = (isset($_REQUEST['order']) && 'DESC' === strtoupper($_REQUEST['order'])) ? "DESC" : "ASC"; |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( wp_is_large_network() ) { |
|
154 | + if (wp_is_large_network()) { |
|
155 | 155 | $args['no_found_rows'] = true; |
156 | 156 | } else { |
157 | 157 | $args['no_found_rows'] = false; |
@@ -164,32 +164,32 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param array $args An array of get_sites() arguments. |
166 | 166 | */ |
167 | - $args = apply_filters( 'ms_sites_list_table_query_args', $args ); |
|
167 | + $args = apply_filters('ms_sites_list_table_query_args', $args); |
|
168 | 168 | |
169 | - $_sites = get_sites( $args ); |
|
170 | - if ( is_array( $_sites ) ) { |
|
171 | - update_site_cache( $_sites ); |
|
169 | + $_sites = get_sites($args); |
|
170 | + if (is_array($_sites)) { |
|
171 | + update_site_cache($_sites); |
|
172 | 172 | |
173 | - $this->items = array_slice( $_sites, 0, $per_page ); |
|
173 | + $this->items = array_slice($_sites, 0, $per_page); |
|
174 | 174 | } |
175 | 175 | |
176 | - $total_sites = get_sites( array_merge( $args, array( |
|
176 | + $total_sites = get_sites(array_merge($args, array( |
|
177 | 177 | 'count' => true, |
178 | 178 | 'offset' => 0, |
179 | 179 | 'number' => 0, |
180 | - ) ) ); |
|
180 | + ))); |
|
181 | 181 | |
182 | - $this->set_pagination_args( array( |
|
182 | + $this->set_pagination_args(array( |
|
183 | 183 | 'total_items' => $total_sites, |
184 | 184 | 'per_page' => $per_page, |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @access public |
190 | 190 | */ |
191 | 191 | public function no_items() { |
192 | - _e( 'No sites found.' ); |
|
192 | + _e('No sites found.'); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function get_bulk_actions() { |
200 | 200 | $actions = array(); |
201 | - if ( current_user_can( 'delete_sites' ) ) |
|
202 | - $actions['delete'] = __( 'Delete' ); |
|
203 | - $actions['spam'] = _x( 'Mark as Spam', 'site' ); |
|
204 | - $actions['notspam'] = _x( 'Not Spam', 'site' ); |
|
201 | + if (current_user_can('delete_sites')) |
|
202 | + $actions['delete'] = __('Delete'); |
|
203 | + $actions['spam'] = _x('Mark as Spam', 'site'); |
|
204 | + $actions['notspam'] = _x('Not Spam', 'site'); |
|
205 | 205 | |
206 | 206 | return $actions; |
207 | 207 | } |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param string $which |
213 | 213 | */ |
214 | - protected function pagination( $which ) { |
|
214 | + protected function pagination($which) { |
|
215 | 215 | global $mode; |
216 | 216 | |
217 | - parent::pagination( $which ); |
|
217 | + parent::pagination($which); |
|
218 | 218 | |
219 | - if ( 'top' === $which ) |
|
220 | - $this->view_switcher( $mode ); |
|
219 | + if ('top' === $which) |
|
220 | + $this->view_switcher($mode); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | public function get_columns() { |
227 | 227 | $sites_columns = array( |
228 | 228 | 'cb' => '<input type="checkbox" />', |
229 | - 'blogname' => __( 'URL' ), |
|
230 | - 'lastupdated' => __( 'Last Updated' ), |
|
231 | - 'registered' => _x( 'Registered', 'site' ), |
|
232 | - 'users' => __( 'Users' ), |
|
229 | + 'blogname' => __('URL'), |
|
230 | + 'lastupdated' => __('Last Updated'), |
|
231 | + 'registered' => _x('Registered', 'site'), |
|
232 | + 'users' => __('Users'), |
|
233 | 233 | ); |
234 | 234 | |
235 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
236 | - $sites_columns['plugins'] = __( 'Actions' ); |
|
235 | + if (has_filter('wpmublogsaction')) { |
|
236 | + $sites_columns['plugins'] = __('Actions'); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param array $sites_columns An array of displayed site columns. Default 'cb', |
245 | 245 | * 'blogname', 'lastupdated', 'registered', 'users'. |
246 | 246 | */ |
247 | - return apply_filters( 'wpmu_blogs_columns', $sites_columns ); |
|
247 | + return apply_filters('wpmu_blogs_columns', $sites_columns); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @param array $blog Current site. |
268 | 268 | */ |
269 | - public function column_cb( $blog ) { |
|
270 | - if ( ! is_main_site( $blog['blog_id'] ) ) : |
|
271 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
269 | + public function column_cb($blog) { |
|
270 | + if ( ! is_main_site($blog['blog_id'])) : |
|
271 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
272 | 272 | ?> |
273 | 273 | <label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php |
274 | - printf( __( 'Select %s' ), $blogname ); |
|
274 | + printf(__('Select %s'), $blogname); |
|
275 | 275 | ?></label> |
276 | - <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> |
|
276 | + <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr($blog['blog_id']) ?>" /> |
|
277 | 277 | <?php endif; |
278 | 278 | } |
279 | 279 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param array $blog Current site. |
287 | 287 | */ |
288 | - public function column_id( $blog ) { |
|
288 | + public function column_id($blog) { |
|
289 | 289 | echo $blog['blog_id']; |
290 | 290 | } |
291 | 291 | |
@@ -299,41 +299,41 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param array $blog Current site. |
301 | 301 | */ |
302 | - public function column_blogname( $blog ) { |
|
302 | + public function column_blogname($blog) { |
|
303 | 303 | global $mode; |
304 | 304 | |
305 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
305 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
306 | 306 | $blog_states = array(); |
307 | - reset( $this->status_list ); |
|
307 | + reset($this->status_list); |
|
308 | 308 | |
309 | - foreach ( $this->status_list as $status => $col ) { |
|
310 | - if ( $blog[ $status ] == 1 ) { |
|
309 | + foreach ($this->status_list as $status => $col) { |
|
310 | + if ($blog[$status] == 1) { |
|
311 | 311 | $blog_states[] = $col[1]; |
312 | 312 | } |
313 | 313 | } |
314 | 314 | $blog_state = ''; |
315 | - if ( ! empty( $blog_states ) ) { |
|
316 | - $state_count = count( $blog_states ); |
|
315 | + if ( ! empty($blog_states)) { |
|
316 | + $state_count = count($blog_states); |
|
317 | 317 | $i = 0; |
318 | 318 | $blog_state .= ' - '; |
319 | - foreach ( $blog_states as $state ) { |
|
319 | + foreach ($blog_states as $state) { |
|
320 | 320 | ++$i; |
321 | - $sep = ( $i == $state_count ) ? '' : ', '; |
|
321 | + $sep = ($i == $state_count) ? '' : ', '; |
|
322 | 322 | $blog_state .= "<span class='post-state'>$state$sep</span>"; |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | 326 | ?> |
327 | - <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> |
|
327 | + <a href="<?php echo esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])); ?>" class="edit"><?php echo $blogname.$blog_state; ?></a> |
|
328 | 328 | <?php |
329 | - if ( 'list' !== $mode ) { |
|
330 | - switch_to_blog( $blog['blog_id'] ); |
|
329 | + if ('list' !== $mode) { |
|
330 | + switch_to_blog($blog['blog_id']); |
|
331 | 331 | echo '<p>'; |
332 | 332 | printf( |
333 | 333 | /* translators: 1: site name, 2: site tagline. */ |
334 | - __( '%1$s – %2$s' ), |
|
335 | - get_option( 'blogname' ), |
|
336 | - '<em>' . get_option( 'blogdescription ' ) . '</em>' |
|
334 | + __('%1$s – %2$s'), |
|
335 | + get_option('blogname'), |
|
336 | + '<em>'.get_option('blogdescription ').'</em>' |
|
337 | 337 | ); |
338 | 338 | echo '</p>'; |
339 | 339 | restore_current_blog(); |
@@ -348,16 +348,16 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param array $blog Current site. |
350 | 350 | */ |
351 | - public function column_lastupdated( $blog ) { |
|
351 | + public function column_lastupdated($blog) { |
|
352 | 352 | global $mode; |
353 | 353 | |
354 | - if ( 'list' === $mode ) { |
|
355 | - $date = __( 'Y/m/d' ); |
|
354 | + if ('list' === $mode) { |
|
355 | + $date = __('Y/m/d'); |
|
356 | 356 | } else { |
357 | - $date = __( 'Y/m/d g:i:s a' ); |
|
357 | + $date = __('Y/m/d g:i:s a'); |
|
358 | 358 | } |
359 | 359 | |
360 | - echo ( $blog['last_updated'] === '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); |
|
360 | + echo ($blog['last_updated'] === '0000-00-00 00:00:00') ? __('Never') : mysql2date($date, $blog['last_updated']); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -368,19 +368,19 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @param array $blog Current site. |
370 | 370 | */ |
371 | - public function column_registered( $blog ) { |
|
371 | + public function column_registered($blog) { |
|
372 | 372 | global $mode; |
373 | 373 | |
374 | - if ( 'list' === $mode ) { |
|
375 | - $date = __( 'Y/m/d' ); |
|
374 | + if ('list' === $mode) { |
|
375 | + $date = __('Y/m/d'); |
|
376 | 376 | } else { |
377 | - $date = __( 'Y/m/d g:i:s a' ); |
|
377 | + $date = __('Y/m/d g:i:s a'); |
|
378 | 378 | } |
379 | 379 | |
380 | - if ( $blog['registered'] === '0000-00-00 00:00:00' ) { |
|
380 | + if ($blog['registered'] === '0000-00-00 00:00:00') { |
|
381 | 381 | echo '—'; |
382 | 382 | } else { |
383 | - echo mysql2date( $date, $blog['registered'] ); |
|
383 | + echo mysql2date($date, $blog['registered']); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
@@ -392,19 +392,19 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @param array $blog Current site. |
394 | 394 | */ |
395 | - public function column_users( $blog ) { |
|
396 | - $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ); |
|
397 | - if ( ! $user_count ) { |
|
398 | - $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) ); |
|
399 | - $user_count = count( $blog_users ); |
|
400 | - unset( $blog_users ); |
|
401 | - wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS ); |
|
395 | + public function column_users($blog) { |
|
396 | + $user_count = wp_cache_get($blog['blog_id'].'_user_count', 'blog-details'); |
|
397 | + if ( ! $user_count) { |
|
398 | + $blog_users = get_users(array('blog_id' => $blog['blog_id'], 'fields' => 'ID')); |
|
399 | + $user_count = count($blog_users); |
|
400 | + unset($blog_users); |
|
401 | + wp_cache_set($blog['blog_id'].'_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | printf( |
405 | 405 | '<a href="%s">%s</a>', |
406 | - esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), |
|
407 | - number_format_i18n( $user_count ) |
|
406 | + esc_url(network_admin_url('site-users.php?id='.$blog['blog_id'])), |
|
407 | + number_format_i18n($user_count) |
|
408 | 408 | ); |
409 | 409 | } |
410 | 410 | |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @param array $blog Current site. |
418 | 418 | */ |
419 | - public function column_plugins( $blog ) { |
|
420 | - if ( has_filter( 'wpmublogsaction' ) ) { |
|
419 | + public function column_plugins($blog) { |
|
420 | + if (has_filter('wpmublogsaction')) { |
|
421 | 421 | /** |
422 | 422 | * Fires inside the auxiliary 'Actions' column of the Sites list table. |
423 | 423 | * |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @param int $blog_id The site ID. |
429 | 429 | */ |
430 | - do_action( 'wpmublogsaction', $blog['blog_id'] ); |
|
430 | + do_action('wpmublogsaction', $blog['blog_id']); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param array $blog Current site. |
441 | 441 | * @param string $column_name Current column name. |
442 | 442 | */ |
443 | - public function column_default( $blog, $column_name ) { |
|
443 | + public function column_default($blog, $column_name) { |
|
444 | 444 | /** |
445 | 445 | * Fires for each registered custom column in the Sites list table. |
446 | 446 | * |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @param string $column_name The name of the column to display. |
450 | 450 | * @param int $blog_id The site ID. |
451 | 451 | */ |
452 | - do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); |
|
452 | + do_action('manage_sites_custom_column', $column_name, $blog['blog_id']); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -457,20 +457,20 @@ discard block |
||
457 | 457 | * @global string $mode |
458 | 458 | */ |
459 | 459 | public function display_rows() { |
460 | - foreach ( $this->items as $blog ) { |
|
460 | + foreach ($this->items as $blog) { |
|
461 | 461 | $blog = $blog->to_array(); |
462 | 462 | $class = ''; |
463 | - reset( $this->status_list ); |
|
463 | + reset($this->status_list); |
|
464 | 464 | |
465 | - foreach ( $this->status_list as $status => $col ) { |
|
466 | - if ( $blog[ $status ] == 1 ) { |
|
465 | + foreach ($this->status_list as $status => $col) { |
|
466 | + if ($blog[$status] == 1) { |
|
467 | 467 | $class = " class='{$col[0]}'"; |
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
471 | 471 | echo "<tr{$class}>"; |
472 | 472 | |
473 | - $this->single_row_columns( $blog ); |
|
473 | + $this->single_row_columns($blog); |
|
474 | 474 | |
475 | 475 | echo '</tr>'; |
476 | 476 | } |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | * @param string $primary Primary column name. |
500 | 500 | * @return string Row actions output. |
501 | 501 | */ |
502 | - protected function handle_row_actions( $blog, $column_name, $primary ) { |
|
503 | - if ( $primary !== $column_name ) { |
|
502 | + protected function handle_row_actions($blog, $column_name, $primary) { |
|
503 | + if ($primary !== $column_name) { |
|
504 | 504 | return; |
505 | 505 | } |
506 | 506 | |
507 | - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); |
|
507 | + $blogname = untrailingslashit($blog['domain'].$blog['path']); |
|
508 | 508 | |
509 | 509 | // Preordered. |
510 | 510 | $actions = array( |
@@ -516,33 +516,33 @@ discard block |
||
516 | 516 | 'visit' => '', |
517 | 517 | ); |
518 | 518 | |
519 | - $actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>'; |
|
520 | - $actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>'; |
|
521 | - if ( get_network()->site_id != $blog['blog_id'] ) { |
|
522 | - if ( $blog['deleted'] == '1' ) { |
|
523 | - $actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>'; |
|
519 | + $actions['edit'] = '<a href="'.esc_url(network_admin_url('site-info.php?id='.$blog['blog_id'])).'">'.__('Edit').'</a>'; |
|
520 | + $actions['backend'] = "<a href='".esc_url(get_admin_url($blog['blog_id']))."' class='edit'>".__('Dashboard').'</a>'; |
|
521 | + if (get_network()->site_id != $blog['blog_id']) { |
|
522 | + if ($blog['deleted'] == '1') { |
|
523 | + $actions['activate'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=activateblog&id='.$blog['blog_id']), 'activateblog_'.$blog['blog_id'])).'">'.__('Activate').'</a>'; |
|
524 | 524 | } else { |
525 | - $actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>'; |
|
525 | + $actions['deactivate'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deactivateblog&id='.$blog['blog_id']), 'deactivateblog_'.$blog['blog_id'])).'">'.__('Deactivate').'</a>'; |
|
526 | 526 | } |
527 | 527 | |
528 | - if ( $blog['archived'] == '1' ) { |
|
529 | - $actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>'; |
|
528 | + if ($blog['archived'] == '1') { |
|
529 | + $actions['unarchive'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unarchiveblog&id='.$blog['blog_id']), 'unarchiveblog_'.$blog['blog_id'])).'">'.__('Unarchive').'</a>'; |
|
530 | 530 | } else { |
531 | - $actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>'; |
|
531 | + $actions['archive'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=archiveblog&id='.$blog['blog_id']), 'archiveblog_'.$blog['blog_id'])).'">'._x('Archive', 'verb; site').'</a>'; |
|
532 | 532 | } |
533 | 533 | |
534 | - if ( $blog['spam'] == '1' ) { |
|
535 | - $actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>'; |
|
534 | + if ($blog['spam'] == '1') { |
|
535 | + $actions['unspam'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=unspamblog&id='.$blog['blog_id']), 'unspamblog_'.$blog['blog_id'])).'">'._x('Not Spam', 'site').'</a>'; |
|
536 | 536 | } else { |
537 | - $actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>'; |
|
537 | + $actions['spam'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=spamblog&id='.$blog['blog_id']), 'spamblog_'.$blog['blog_id'])).'">'._x('Spam', 'site').'</a>'; |
|
538 | 538 | } |
539 | 539 | |
540 | - if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { |
|
541 | - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>'; |
|
540 | + if (current_user_can('delete_site', $blog['blog_id'])) { |
|
541 | + $actions['delete'] = '<a href="'.esc_url(wp_nonce_url(network_admin_url('sites.php?action=confirm&action2=deleteblog&id='.$blog['blog_id']), 'deleteblog_'.$blog['blog_id'])).'">'.__('Delete').'</a>'; |
|
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | - $actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a>'; |
|
545 | + $actions['visit'] = "<a href='".esc_url(get_home_url($blog['blog_id'], '/'))."' rel='permalink'>".__('Visit').'</a>'; |
|
546 | 546 | |
547 | 547 | /** |
548 | 548 | * Filters the action links displayed for each site in the Sites list table. |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * @param string $blogname Site path, formatted depending on whether it is a sub-domain |
560 | 560 | * or subdirectory multisite install. |
561 | 561 | */ |
562 | - $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); |
|
563 | - return $this->row_actions( $actions ); |
|
562 | + $actions = apply_filters('manage_sites_action_links', array_filter($actions), $blog['blog_id'], $blogname); |
|
563 | + return $this->row_actions($actions); |
|
564 | 564 | } |
565 | 565 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @param array $args |
23 | 23 | */ |
24 | 24 | public function __construct($args = array()) { |
25 | - $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); |
|
25 | + $defaults = array('type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => ''); |
|
26 | 26 | $args = wp_parse_args($args, $defaults); |
27 | 27 | |
28 | 28 | $this->type = $args['type']; |
@@ -35,49 +35,49 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function before() { |
38 | - if ( !empty($this->api) ) |
|
39 | - $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
38 | + if ( ! empty($this->api)) |
|
39 | + $this->upgrader->strings['process_success'] = sprintf($this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @access public |
44 | 44 | */ |
45 | 45 | public function after() { |
46 | - if ( empty($this->upgrader->result['destination_name']) ) |
|
46 | + if (empty($this->upgrader->result['destination_name'])) |
|
47 | 47 | return; |
48 | 48 | |
49 | 49 | $theme_info = $this->upgrader->theme_info(); |
50 | - if ( empty( $theme_info ) ) |
|
50 | + if (empty($theme_info)) |
|
51 | 51 | return; |
52 | 52 | |
53 | 53 | $name = $theme_info->display('Name'); |
54 | 54 | $stylesheet = $this->upgrader->result['destination_name']; |
55 | 55 | $template = $theme_info->get_template(); |
56 | 56 | |
57 | - $activate_link = add_query_arg( array( |
|
57 | + $activate_link = add_query_arg(array( |
|
58 | 58 | 'action' => 'activate', |
59 | - 'template' => urlencode( $template ), |
|
60 | - 'stylesheet' => urlencode( $stylesheet ), |
|
61 | - ), admin_url('themes.php') ); |
|
62 | - $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
|
59 | + 'template' => urlencode($template), |
|
60 | + 'stylesheet' => urlencode($stylesheet), |
|
61 | + ), admin_url('themes.php')); |
|
62 | + $activate_link = wp_nonce_url($activate_link, 'switch-theme_'.$stylesheet); |
|
63 | 63 | |
64 | 64 | $install_actions = array(); |
65 | 65 | |
66 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
67 | - $install_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; |
|
66 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
67 | + $install_actions['preview'] = '<a href="'.wp_customize_url($stylesheet).'" class="hide-if-no-customize load-customize"><span aria-hidden="true">'.__('Live Preview').'</span><span class="screen-reader-text">'.sprintf(__('Live Preview “%s”'), $name).'</span></a>'; |
|
68 | 68 | } |
69 | - $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
|
69 | + $install_actions['activate'] = '<a href="'.esc_url($activate_link).'" class="activatelink"><span aria-hidden="true">'.__('Activate').'</span><span class="screen-reader-text">'.sprintf(__('Activate “%s”'), $name).'</span></a>'; |
|
70 | 70 | |
71 | - if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
|
72 | - $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
71 | + if (is_network_admin() && current_user_can('manage_network_themes')) |
|
72 | + $install_actions['network_enable'] = '<a href="'.esc_url(wp_nonce_url('themes.php?action=enable&theme='.urlencode($stylesheet), 'enable-theme_'.$stylesheet)).'" target="_parent">'.__('Network Enable').'</a>'; |
|
73 | 73 | |
74 | - if ( $this->type == 'web' ) |
|
75 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
76 | - elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) |
|
77 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
74 | + if ($this->type == 'web') |
|
75 | + $install_actions['themes_page'] = '<a href="'.self_admin_url('theme-install.php').'" target="_parent">'.__('Return to Theme Installer').'</a>'; |
|
76 | + elseif (current_user_can('switch_themes') || current_user_can('edit_theme_options')) |
|
77 | + $install_actions['themes_page'] = '<a href="'.self_admin_url('themes.php').'" target="_parent">'.__('Return to Themes page').'</a>'; |
|
78 | 78 | |
79 | - if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) |
|
80 | - unset( $install_actions['activate'], $install_actions['preview'] ); |
|
79 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can('switch_themes')) |
|
80 | + unset($install_actions['activate'], $install_actions['preview']); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Filters the list of action links available following a single theme installation. |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param string $stylesheet Theme directory name. |
90 | 90 | * @param WP_Theme $theme_info Theme object. |
91 | 91 | */ |
92 | - $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); |
|
93 | - if ( ! empty($install_actions) ) |
|
94 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
92 | + $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info); |
|
93 | + if ( ! empty($install_actions)) |
|
94 | + $this->feedback(implode(' | ', (array) $install_actions)); |
|
95 | 95 | } |
96 | 96 | } |
@@ -35,20 +35,23 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function before() { |
38 | - if ( !empty($this->api) ) |
|
39 | - $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
38 | + if ( !empty($this->api) ) { |
|
39 | + $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); |
|
40 | + } |
|
40 | 41 | } |
41 | 42 | |
42 | 43 | /** |
43 | 44 | * @access public |
44 | 45 | */ |
45 | 46 | public function after() { |
46 | - if ( empty($this->upgrader->result['destination_name']) ) |
|
47 | - return; |
|
47 | + if ( empty($this->upgrader->result['destination_name']) ) { |
|
48 | + return; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | $theme_info = $this->upgrader->theme_info(); |
50 | - if ( empty( $theme_info ) ) |
|
51 | - return; |
|
52 | + if ( empty( $theme_info ) ) { |
|
53 | + return; |
|
54 | + } |
|
52 | 55 | |
53 | 56 | $name = $theme_info->display('Name'); |
54 | 57 | $stylesheet = $this->upgrader->result['destination_name']; |
@@ -68,16 +71,19 @@ discard block |
||
68 | 71 | } |
69 | 72 | $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; |
70 | 73 | |
71 | - if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) |
|
72 | - $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
74 | + if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) { |
|
75 | + $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; |
|
76 | + } |
|
73 | 77 | |
74 | - if ( $this->type == 'web' ) |
|
75 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
76 | - elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) |
|
77 | - $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
78 | + if ( $this->type == 'web' ) { |
|
79 | + $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; |
|
80 | + } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { |
|
81 | + $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; |
|
82 | + } |
|
78 | 83 | |
79 | - if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) |
|
80 | - unset( $install_actions['activate'], $install_actions['preview'] ); |
|
84 | + if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { |
|
85 | + unset( $install_actions['activate'], $install_actions['preview'] ); |
|
86 | + } |
|
81 | 87 | |
82 | 88 | /** |
83 | 89 | * Filters the list of action links available following a single theme installation. |
@@ -90,7 +96,8 @@ discard block |
||
90 | 96 | * @param WP_Theme $theme_info Theme object. |
91 | 97 | */ |
92 | 98 | $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); |
93 | - if ( ! empty($install_actions) ) |
|
94 | - $this->feedback(implode(' | ', (array)$install_actions)); |
|
99 | + if ( ! empty($install_actions) ) { |
|
100 | + $this->feedback(implode(' | ', (array)$install_actions)); |
|
101 | + } |
|
95 | 102 | } |
96 | 103 | } |
@@ -185,14 +185,14 @@ |
||
185 | 185 | $notify = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin'; |
186 | 186 | |
187 | 187 | /** |
188 | - * Fires after a new user has been created. |
|
189 | - * |
|
190 | - * @since 4.4.0 |
|
191 | - * |
|
192 | - * @param int $user_id ID of the newly created user. |
|
193 | - * @param string $notify Type of notification that should happen. See wp_send_new_user_notifications() |
|
194 | - * for more information on possible values. |
|
195 | - */ |
|
188 | + * Fires after a new user has been created. |
|
189 | + * |
|
190 | + * @since 4.4.0 |
|
191 | + * |
|
192 | + * @param int $user_id ID of the newly created user. |
|
193 | + * @param string $notify Type of notification that should happen. See wp_send_new_user_notifications() |
|
194 | + * for more information on possible values. |
|
195 | + */ |
|
196 | 196 | do_action( 'edit_user_created_user', $user_id, $notify ); |
197 | 197 | } |
198 | 198 | return $user_id; |
@@ -39,31 +39,37 @@ discard block |
||
39 | 39 | $update = false; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !$update && isset( $_POST['user_login'] ) ) |
|
43 | - $user->user_login = sanitize_user($_POST['user_login'], true); |
|
42 | + if ( !$update && isset( $_POST['user_login'] ) ) { |
|
43 | + $user->user_login = sanitize_user($_POST['user_login'], true); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | $pass1 = $pass2 = ''; |
46 | - if ( isset( $_POST['pass1'] ) ) |
|
47 | - $pass1 = $_POST['pass1']; |
|
48 | - if ( isset( $_POST['pass2'] ) ) |
|
49 | - $pass2 = $_POST['pass2']; |
|
47 | + if ( isset( $_POST['pass1'] ) ) { |
|
48 | + $pass1 = $_POST['pass1']; |
|
49 | + } |
|
50 | + if ( isset( $_POST['pass2'] ) ) { |
|
51 | + $pass2 = $_POST['pass2']; |
|
52 | + } |
|
50 | 53 | |
51 | 54 | if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { |
52 | 55 | $new_role = sanitize_text_field( $_POST['role'] ); |
53 | 56 | $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; |
54 | 57 | // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. |
55 | 58 | // Multisite super admins can freely edit their blog roles -- they possess all caps. |
56 | - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) |
|
57 | - $user->role = $new_role; |
|
59 | + if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) { |
|
60 | + $user->role = $new_role; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | // If the new role isn't editable by the logged-in user die with error |
60 | 64 | $editable_roles = get_editable_roles(); |
61 | - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) |
|
62 | - wp_die(__('You can’t give users that role.')); |
|
65 | + if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) { |
|
66 | + wp_die(__('You can’t give users that role.')); |
|
67 | + } |
|
63 | 68 | } |
64 | 69 | |
65 | - if ( isset( $_POST['email'] )) |
|
66 | - $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
70 | + if ( isset( $_POST['email'] )) { |
|
71 | + $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
72 | + } |
|
67 | 73 | if ( isset( $_POST['url'] ) ) { |
68 | 74 | if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
69 | 75 | $user->user_url = ''; |
@@ -73,21 +79,27 @@ discard block |
||
73 | 79 | $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
74 | 80 | } |
75 | 81 | } |
76 | - if ( isset( $_POST['first_name'] ) ) |
|
77 | - $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
78 | - if ( isset( $_POST['last_name'] ) ) |
|
79 | - $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
80 | - if ( isset( $_POST['nickname'] ) ) |
|
81 | - $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
82 | - if ( isset( $_POST['display_name'] ) ) |
|
83 | - $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
82 | + if ( isset( $_POST['first_name'] ) ) { |
|
83 | + $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
84 | + } |
|
85 | + if ( isset( $_POST['last_name'] ) ) { |
|
86 | + $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
87 | + } |
|
88 | + if ( isset( $_POST['nickname'] ) ) { |
|
89 | + $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
90 | + } |
|
91 | + if ( isset( $_POST['display_name'] ) ) { |
|
92 | + $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
93 | + } |
|
84 | 94 | |
85 | - if ( isset( $_POST['description'] ) ) |
|
86 | - $user->description = trim( $_POST['description'] ); |
|
95 | + if ( isset( $_POST['description'] ) ) { |
|
96 | + $user->description = trim( $_POST['description'] ); |
|
97 | + } |
|
87 | 98 | |
88 | 99 | foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { |
89 | - if ( isset( $_POST[$method] )) |
|
90 | - $user->$method = sanitize_text_field( $_POST[$method] ); |
|
100 | + if ( isset( $_POST[$method] )) { |
|
101 | + $user->$method = sanitize_text_field( $_POST[$method] ); |
|
102 | + } |
|
91 | 103 | } |
92 | 104 | |
93 | 105 | if ( $update ) { |
@@ -99,14 +111,16 @@ discard block |
||
99 | 111 | $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
100 | 112 | |
101 | 113 | $user->use_ssl = 0; |
102 | - if ( !empty($_POST['use_ssl']) ) |
|
103 | - $user->use_ssl = 1; |
|
114 | + if ( !empty($_POST['use_ssl']) ) { |
|
115 | + $user->use_ssl = 1; |
|
116 | + } |
|
104 | 117 | |
105 | 118 | $errors = new WP_Error(); |
106 | 119 | |
107 | 120 | /* checking that username has been typed */ |
108 | - if ( $user->user_login == '' ) |
|
109 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
121 | + if ( $user->user_login == '' ) { |
|
122 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
123 | + } |
|
110 | 124 | |
111 | 125 | /* checking that nickname has been typed */ |
112 | 126 | if ( $update && empty( $user->nickname ) ) { |
@@ -139,14 +153,17 @@ discard block |
||
139 | 153 | $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); |
140 | 154 | } |
141 | 155 | |
142 | - if ( !empty( $pass1 ) ) |
|
143 | - $user->user_pass = $pass1; |
|
156 | + if ( !empty( $pass1 ) ) { |
|
157 | + $user->user_pass = $pass1; |
|
158 | + } |
|
144 | 159 | |
145 | - if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) |
|
146 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
160 | + if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) { |
|
161 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
162 | + } |
|
147 | 163 | |
148 | - if ( !$update && username_exists( $user->user_login ) ) |
|
149 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
164 | + if ( !$update && username_exists( $user->user_login ) ) { |
|
165 | + $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
166 | + } |
|
150 | 167 | |
151 | 168 | /** This filter is documented in wp-includes/user.php */ |
152 | 169 | $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
@@ -175,8 +192,9 @@ discard block |
||
175 | 192 | */ |
176 | 193 | do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); |
177 | 194 | |
178 | - if ( $errors->get_error_codes() ) |
|
179 | - return $errors; |
|
195 | + if ( $errors->get_error_codes() ) { |
|
196 | + return $errors; |
|
197 | + } |
|
180 | 198 | |
181 | 199 | if ( $update ) { |
182 | 200 | $user_id = wp_update_user( $user ); |
@@ -240,8 +258,9 @@ discard block |
||
240 | 258 | function get_user_to_edit( $user_id ) { |
241 | 259 | $user = get_userdata( $user_id ); |
242 | 260 | |
243 | - if ( $user ) |
|
244 | - $user->filter = 'edit'; |
|
261 | + if ( $user ) { |
|
262 | + $user->filter = 'edit'; |
|
263 | + } |
|
245 | 264 | |
246 | 265 | return $user; |
247 | 266 | } |
@@ -297,8 +316,9 @@ discard block |
||
297 | 316 | $id = (int) $id; |
298 | 317 | $user = new WP_User( $id ); |
299 | 318 | |
300 | - if ( !$user->exists() ) |
|
301 | - return false; |
|
319 | + if ( !$user->exists() ) { |
|
320 | + return false; |
|
321 | + } |
|
302 | 322 | |
303 | 323 | // Normalize $reassign to null or a user ID. 'novalue' was an older default. |
304 | 324 | if ( 'novalue' === $reassign ) { |
@@ -340,29 +360,33 @@ discard block |
||
340 | 360 | $post_types_to_delete = implode( "', '", $post_types_to_delete ); |
341 | 361 | $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) ); |
342 | 362 | if ( $post_ids ) { |
343 | - foreach ( $post_ids as $post_id ) |
|
344 | - wp_delete_post( $post_id ); |
|
363 | + foreach ( $post_ids as $post_id ) { |
|
364 | + wp_delete_post( $post_id ); |
|
365 | + } |
|
345 | 366 | } |
346 | 367 | |
347 | 368 | // Clean links |
348 | 369 | $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
349 | 370 | |
350 | 371 | if ( $link_ids ) { |
351 | - foreach ( $link_ids as $link_id ) |
|
352 | - wp_delete_link($link_id); |
|
372 | + foreach ( $link_ids as $link_id ) { |
|
373 | + wp_delete_link($link_id); |
|
374 | + } |
|
353 | 375 | } |
354 | 376 | } else { |
355 | 377 | $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
356 | 378 | $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
357 | 379 | if ( ! empty( $post_ids ) ) { |
358 | - foreach ( $post_ids as $post_id ) |
|
359 | - clean_post_cache( $post_id ); |
|
380 | + foreach ( $post_ids as $post_id ) { |
|
381 | + clean_post_cache( $post_id ); |
|
382 | + } |
|
360 | 383 | } |
361 | 384 | $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
362 | 385 | $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
363 | 386 | if ( ! empty( $link_ids ) ) { |
364 | - foreach ( $link_ids as $link_id ) |
|
365 | - clean_bookmark_cache( $link_id ); |
|
387 | + foreach ( $link_ids as $link_id ) { |
|
388 | + clean_bookmark_cache( $link_id ); |
|
389 | + } |
|
366 | 390 | } |
367 | 391 | } |
368 | 392 | |
@@ -371,8 +395,9 @@ discard block |
||
371 | 395 | remove_user_from_blog( $id, get_current_blog_id() ); |
372 | 396 | } else { |
373 | 397 | $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
374 | - foreach ( $meta as $mid ) |
|
375 | - delete_metadata_by_mid( 'user', $mid ); |
|
398 | + foreach ( $meta as $mid ) { |
|
399 | + delete_metadata_by_mid( 'user', $mid ); |
|
400 | + } |
|
376 | 401 | |
377 | 402 | $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
378 | 403 | } |
@@ -417,8 +442,9 @@ discard block |
||
417 | 442 | function default_password_nag_handler($errors = false) { |
418 | 443 | global $user_ID; |
419 | 444 | // Short-circuit it. |
420 | - if ( ! get_user_option('default_password_nag') ) |
|
421 | - return; |
|
445 | + if ( ! get_user_option('default_password_nag') ) { |
|
446 | + return; |
|
447 | + } |
|
422 | 448 | |
423 | 449 | // get_user_setting = JS saved UI setting. else no-js-fallback code. |
424 | 450 | if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) { |
@@ -435,8 +461,9 @@ discard block |
||
435 | 461 | */ |
436 | 462 | function default_password_nag_edit_user($user_ID, $old_data) { |
437 | 463 | // Short-circuit it. |
438 | - if ( ! get_user_option('default_password_nag', $user_ID) ) |
|
439 | - return; |
|
464 | + if ( ! get_user_option('default_password_nag', $user_ID) ) { |
|
465 | + return; |
|
466 | + } |
|
440 | 467 | |
441 | 468 | $new_data = get_userdata($user_ID); |
442 | 469 | |
@@ -455,8 +482,9 @@ discard block |
||
455 | 482 | function default_password_nag() { |
456 | 483 | global $pagenow; |
457 | 484 | // Short-circuit it. |
458 | - if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) |
|
459 | - return; |
|
485 | + if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) { |
|
486 | + return; |
|
487 | + } |
|
460 | 488 | |
461 | 489 | echo '<div class="error default-password-nag">'; |
462 | 490 | echo '<p>'; |
@@ -27,82 +27,82 @@ discard block |
||
27 | 27 | * @param int $user_id Optional. User ID. |
28 | 28 | * @return int|WP_Error user id of the updated user |
29 | 29 | */ |
30 | -function edit_user( $user_id = 0 ) { |
|
30 | +function edit_user($user_id = 0) { |
|
31 | 31 | $wp_roles = wp_roles(); |
32 | 32 | $user = new stdClass; |
33 | - if ( $user_id ) { |
|
33 | + if ($user_id) { |
|
34 | 34 | $update = true; |
35 | 35 | $user->ID = (int) $user_id; |
36 | - $userdata = get_userdata( $user_id ); |
|
37 | - $user->user_login = wp_slash( $userdata->user_login ); |
|
36 | + $userdata = get_userdata($user_id); |
|
37 | + $user->user_login = wp_slash($userdata->user_login); |
|
38 | 38 | } else { |
39 | 39 | $update = false; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !$update && isset( $_POST['user_login'] ) ) |
|
42 | + if ( ! $update && isset($_POST['user_login'])) |
|
43 | 43 | $user->user_login = sanitize_user($_POST['user_login'], true); |
44 | 44 | |
45 | 45 | $pass1 = $pass2 = ''; |
46 | - if ( isset( $_POST['pass1'] ) ) |
|
46 | + if (isset($_POST['pass1'])) |
|
47 | 47 | $pass1 = $_POST['pass1']; |
48 | - if ( isset( $_POST['pass2'] ) ) |
|
48 | + if (isset($_POST['pass2'])) |
|
49 | 49 | $pass2 = $_POST['pass2']; |
50 | 50 | |
51 | - if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) { |
|
52 | - $new_role = sanitize_text_field( $_POST['role'] ); |
|
51 | + if (isset($_POST['role']) && current_user_can('edit_users')) { |
|
52 | + $new_role = sanitize_text_field($_POST['role']); |
|
53 | 53 | $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; |
54 | 54 | // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. |
55 | 55 | // Multisite super admins can freely edit their blog roles -- they possess all caps. |
56 | - if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) ) |
|
56 | + if ((is_multisite() && current_user_can('manage_sites')) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap('edit_users'))) |
|
57 | 57 | $user->role = $new_role; |
58 | 58 | |
59 | 59 | // If the new role isn't editable by the logged-in user die with error |
60 | 60 | $editable_roles = get_editable_roles(); |
61 | - if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) ) |
|
61 | + if ( ! empty($new_role) && empty($editable_roles[$new_role])) |
|
62 | 62 | wp_die(__('You can’t give users that role.')); |
63 | 63 | } |
64 | 64 | |
65 | - if ( isset( $_POST['email'] )) |
|
66 | - $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) ); |
|
67 | - if ( isset( $_POST['url'] ) ) { |
|
68 | - if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) { |
|
65 | + if (isset($_POST['email'])) |
|
66 | + $user->user_email = sanitize_text_field(wp_unslash($_POST['email'])); |
|
67 | + if (isset($_POST['url'])) { |
|
68 | + if (empty ($_POST['url']) || $_POST['url'] == 'http://') { |
|
69 | 69 | $user->user_url = ''; |
70 | 70 | } else { |
71 | - $user->user_url = esc_url_raw( $_POST['url'] ); |
|
72 | - $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); |
|
73 | - $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
|
71 | + $user->user_url = esc_url_raw($_POST['url']); |
|
72 | + $protocols = implode('|', array_map('preg_quote', wp_allowed_protocols())); |
|
73 | + $user->user_url = preg_match('/^('.$protocols.'):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; |
|
74 | 74 | } |
75 | 75 | } |
76 | - if ( isset( $_POST['first_name'] ) ) |
|
77 | - $user->first_name = sanitize_text_field( $_POST['first_name'] ); |
|
78 | - if ( isset( $_POST['last_name'] ) ) |
|
79 | - $user->last_name = sanitize_text_field( $_POST['last_name'] ); |
|
80 | - if ( isset( $_POST['nickname'] ) ) |
|
81 | - $user->nickname = sanitize_text_field( $_POST['nickname'] ); |
|
82 | - if ( isset( $_POST['display_name'] ) ) |
|
83 | - $user->display_name = sanitize_text_field( $_POST['display_name'] ); |
|
84 | - |
|
85 | - if ( isset( $_POST['description'] ) ) |
|
86 | - $user->description = trim( $_POST['description'] ); |
|
87 | - |
|
88 | - foreach ( wp_get_user_contact_methods( $user ) as $method => $name ) { |
|
89 | - if ( isset( $_POST[$method] )) |
|
90 | - $user->$method = sanitize_text_field( $_POST[$method] ); |
|
76 | + if (isset($_POST['first_name'])) |
|
77 | + $user->first_name = sanitize_text_field($_POST['first_name']); |
|
78 | + if (isset($_POST['last_name'])) |
|
79 | + $user->last_name = sanitize_text_field($_POST['last_name']); |
|
80 | + if (isset($_POST['nickname'])) |
|
81 | + $user->nickname = sanitize_text_field($_POST['nickname']); |
|
82 | + if (isset($_POST['display_name'])) |
|
83 | + $user->display_name = sanitize_text_field($_POST['display_name']); |
|
84 | + |
|
85 | + if (isset($_POST['description'])) |
|
86 | + $user->description = trim($_POST['description']); |
|
87 | + |
|
88 | + foreach (wp_get_user_contact_methods($user) as $method => $name) { |
|
89 | + if (isset($_POST[$method])) |
|
90 | + $user->$method = sanitize_text_field($_POST[$method]); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( $update ) { |
|
94 | - $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true'; |
|
95 | - $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh'; |
|
96 | - $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false'; |
|
93 | + if ($update) { |
|
94 | + $user->rich_editing = isset($_POST['rich_editing']) && 'false' == $_POST['rich_editing'] ? 'false' : 'true'; |
|
95 | + $user->admin_color = isset($_POST['admin_color']) ? sanitize_text_field($_POST['admin_color']) : 'fresh'; |
|
96 | + $user->show_admin_bar_front = isset($_POST['admin_bar_front']) ? 'true' : 'false'; |
|
97 | 97 | $user->locale = ''; |
98 | 98 | |
99 | - if ( isset( $_POST['locale'] ) ) { |
|
100 | - $locale = sanitize_text_field( $_POST['locale'] ); |
|
101 | - if ( 'site-default' === $locale ) { |
|
99 | + if (isset($_POST['locale'])) { |
|
100 | + $locale = sanitize_text_field($_POST['locale']); |
|
101 | + if ('site-default' === $locale) { |
|
102 | 102 | $locale = ''; |
103 | - } elseif ( '' === $locale ) { |
|
103 | + } elseif ('' === $locale) { |
|
104 | 104 | $locale = 'en_US'; |
105 | - } elseif ( ! in_array( $locale, get_available_languages(), true ) ) { |
|
105 | + } elseif ( ! in_array($locale, get_available_languages(), true)) { |
|
106 | 106 | $locale = ''; |
107 | 107 | } |
108 | 108 | |
@@ -110,21 +110,21 @@ discard block |
||
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
|
113 | + $user->comment_shortcuts = isset($_POST['comment_shortcuts']) && 'true' == $_POST['comment_shortcuts'] ? 'true' : ''; |
|
114 | 114 | |
115 | 115 | $user->use_ssl = 0; |
116 | - if ( !empty($_POST['use_ssl']) ) |
|
116 | + if ( ! empty($_POST['use_ssl'])) |
|
117 | 117 | $user->use_ssl = 1; |
118 | 118 | |
119 | 119 | $errors = new WP_Error(); |
120 | 120 | |
121 | 121 | /* checking that username has been typed */ |
122 | - if ( $user->user_login == '' ) |
|
123 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ) ); |
|
122 | + if ($user->user_login == '') |
|
123 | + $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.')); |
|
124 | 124 | |
125 | 125 | /* checking that nickname has been typed */ |
126 | - if ( $update && empty( $user->nickname ) ) { |
|
127 | - $errors->add( 'nickname', __( '<strong>ERROR</strong>: Please enter a nickname.' ) ); |
|
126 | + if ($update && empty($user->nickname)) { |
|
127 | + $errors->add('nickname', __('<strong>ERROR</strong>: Please enter a nickname.')); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -136,46 +136,46 @@ discard block |
||
136 | 136 | * @param string &$pass1 The password, passed by reference. |
137 | 137 | * @param string &$pass2 The confirmed password, passed by reference. |
138 | 138 | */ |
139 | - do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) ); |
|
139 | + do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2)); |
|
140 | 140 | |
141 | 141 | // Check for blank password when adding a user. |
142 | - if ( ! $update && empty( $pass1 ) ) { |
|
143 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) ); |
|
142 | + if ( ! $update && empty($pass1)) { |
|
143 | + $errors->add('pass', __('<strong>ERROR</strong>: Please enter a password.'), array('form-field' => 'pass1')); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Check for "\" in password. |
147 | - if ( false !== strpos( wp_unslash( $pass1 ), "\\" ) ) { |
|
148 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); |
|
147 | + if (false !== strpos(wp_unslash($pass1), "\\")) { |
|
148 | + $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'), array('form-field' => 'pass1')); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Checking the password has been typed twice the same. |
152 | - if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) { |
|
153 | - $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) ); |
|
152 | + if (($update || ! empty($pass1)) && $pass1 != $pass2) { |
|
153 | + $errors->add('pass', __('<strong>ERROR</strong>: Please enter the same password in both password fields.'), array('form-field' => 'pass1')); |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( !empty( $pass1 ) ) |
|
156 | + if ( ! empty($pass1)) |
|
157 | 157 | $user->user_pass = $pass1; |
158 | 158 | |
159 | - if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) ) |
|
160 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); |
|
159 | + if ( ! $update && isset($_POST['user_login']) && ! validate_username($_POST['user_login'])) |
|
160 | + $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.')); |
|
161 | 161 | |
162 | - if ( !$update && username_exists( $user->user_login ) ) |
|
163 | - $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' )); |
|
162 | + if ( ! $update && username_exists($user->user_login)) |
|
163 | + $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered. Please choose another one.')); |
|
164 | 164 | |
165 | 165 | /** This filter is documented in wp-includes/user.php */ |
166 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
166 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
167 | 167 | |
168 | - if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) { |
|
169 | - $errors->add( 'invalid_username', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) ); |
|
168 | + if (in_array(strtolower($user->user_login), array_map('strtolower', $illegal_logins))) { |
|
169 | + $errors->add('invalid_username', __('<strong>ERROR</strong>: Sorry, that username is not allowed.')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /* checking email address */ |
173 | - if ( empty( $user->user_email ) ) { |
|
174 | - $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an email address.' ), array( 'form-field' => 'email' ) ); |
|
175 | - } elseif ( !is_email( $user->user_email ) ) { |
|
176 | - $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn’t correct.' ), array( 'form-field' => 'email' ) ); |
|
177 | - } elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) { |
|
178 | - $errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) ); |
|
173 | + if (empty($user->user_email)) { |
|
174 | + $errors->add('empty_email', __('<strong>ERROR</strong>: Please enter an email address.'), array('form-field' => 'email')); |
|
175 | + } elseif ( ! is_email($user->user_email)) { |
|
176 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'), array('form-field' => 'email')); |
|
177 | + } elseif (($owner_id = email_exists($user->user_email)) && ( ! $update || ($owner_id != $user->ID))) { |
|
178 | + $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array('form-field' => 'email')); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | * @param bool $update Whether this is a user update. |
188 | 188 | * @param stdClass &$user User object, passed by reference. |
189 | 189 | */ |
190 | - do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); |
|
190 | + do_action_ref_array('user_profile_update_errors', array(&$errors, $update, &$user)); |
|
191 | 191 | |
192 | - if ( $errors->get_error_codes() ) |
|
192 | + if ($errors->get_error_codes()) |
|
193 | 193 | return $errors; |
194 | 194 | |
195 | - if ( $update ) { |
|
196 | - $user_id = wp_update_user( $user ); |
|
195 | + if ($update) { |
|
196 | + $user_id = wp_update_user($user); |
|
197 | 197 | } else { |
198 | - $user_id = wp_insert_user( $user ); |
|
199 | - $notify = isset( $_POST['send_user_notification'] ) ? 'both' : 'admin'; |
|
198 | + $user_id = wp_insert_user($user); |
|
199 | + $notify = isset($_POST['send_user_notification']) ? 'both' : 'admin'; |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Fires after a new user has been created. |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string $notify Type of notification that should happen. See wp_send_new_user_notifications() |
208 | 208 | * for more information on possible values. |
209 | 209 | */ |
210 | - do_action( 'edit_user_created_user', $user_id, $notify ); |
|
210 | + do_action('edit_user_created_user', $user_id, $notify); |
|
211 | 211 | } |
212 | 212 | return $user_id; |
213 | 213 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param array $all_roles List of roles. |
240 | 240 | */ |
241 | - $editable_roles = apply_filters( 'editable_roles', $all_roles ); |
|
241 | + $editable_roles = apply_filters('editable_roles', $all_roles); |
|
242 | 242 | |
243 | 243 | return $editable_roles; |
244 | 244 | } |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | * @param int $user_id User ID. |
252 | 252 | * @return WP_User|bool WP_User object on success, false on failure. |
253 | 253 | */ |
254 | -function get_user_to_edit( $user_id ) { |
|
255 | - $user = get_userdata( $user_id ); |
|
254 | +function get_user_to_edit($user_id) { |
|
255 | + $user = get_userdata($user_id); |
|
256 | 256 | |
257 | - if ( $user ) |
|
257 | + if ($user) |
|
258 | 258 | $user->filter = 'edit'; |
259 | 259 | |
260 | 260 | return $user; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param int $user_id User ID. |
271 | 271 | * @return array |
272 | 272 | */ |
273 | -function get_users_drafts( $user_id ) { |
|
273 | +function get_users_drafts($user_id) { |
|
274 | 274 | global $wpdb; |
275 | 275 | $query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id); |
276 | 276 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @param string $query The user's drafts query string. |
283 | 283 | */ |
284 | - $query = apply_filters( 'get_users_drafts', $query ); |
|
285 | - return $wpdb->get_results( $query ); |
|
284 | + $query = apply_filters('get_users_drafts', $query); |
|
285 | + return $wpdb->get_results($query); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | * @param int $reassign Optional. Reassign posts and links to new User ID. |
302 | 302 | * @return bool True when finished. |
303 | 303 | */ |
304 | -function wp_delete_user( $id, $reassign = null ) { |
|
304 | +function wp_delete_user($id, $reassign = null) { |
|
305 | 305 | global $wpdb; |
306 | 306 | |
307 | - if ( ! is_numeric( $id ) ) { |
|
307 | + if ( ! is_numeric($id)) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | |
311 | 311 | $id = (int) $id; |
312 | - $user = new WP_User( $id ); |
|
312 | + $user = new WP_User($id); |
|
313 | 313 | |
314 | - if ( !$user->exists() ) |
|
314 | + if ( ! $user->exists()) |
|
315 | 315 | return false; |
316 | 316 | |
317 | 317 | // Normalize $reassign to null or a user ID. 'novalue' was an older default. |
318 | - if ( 'novalue' === $reassign ) { |
|
318 | + if ('novalue' === $reassign) { |
|
319 | 319 | $reassign = null; |
320 | - } elseif ( null !== $reassign ) { |
|
320 | + } elseif (null !== $reassign) { |
|
321 | 321 | $reassign = (int) $reassign; |
322 | 322 | } |
323 | 323 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param int|null $reassign ID of the user to reassign posts and links to. |
331 | 331 | * Default null, for no reassignment. |
332 | 332 | */ |
333 | - do_action( 'delete_user', $id, $reassign ); |
|
333 | + do_action('delete_user', $id, $reassign); |
|
334 | 334 | |
335 | - if ( null === $reassign ) { |
|
335 | + if (null === $reassign) { |
|
336 | 336 | $post_types_to_delete = array(); |
337 | - foreach ( get_post_types( array(), 'objects' ) as $post_type ) { |
|
338 | - if ( $post_type->delete_with_user ) { |
|
337 | + foreach (get_post_types(array(), 'objects') as $post_type) { |
|
338 | + if ($post_type->delete_with_user) { |
|
339 | 339 | $post_types_to_delete[] = $post_type->name; |
340 | - } elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) { |
|
340 | + } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) { |
|
341 | 341 | $post_types_to_delete[] = $post_type->name; |
342 | 342 | } |
343 | 343 | } |
@@ -350,48 +350,48 @@ discard block |
||
350 | 350 | * @param array $post_types_to_delete Post types to delete. |
351 | 351 | * @param int $id User ID. |
352 | 352 | */ |
353 | - $post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id ); |
|
354 | - $post_types_to_delete = implode( "', '", $post_types_to_delete ); |
|
355 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) ); |
|
356 | - if ( $post_ids ) { |
|
357 | - foreach ( $post_ids as $post_id ) |
|
358 | - wp_delete_post( $post_id ); |
|
353 | + $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id); |
|
354 | + $post_types_to_delete = implode("', '", $post_types_to_delete); |
|
355 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id)); |
|
356 | + if ($post_ids) { |
|
357 | + foreach ($post_ids as $post_id) |
|
358 | + wp_delete_post($post_id); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | // Clean links |
362 | - $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
|
362 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id)); |
|
363 | 363 | |
364 | - if ( $link_ids ) { |
|
365 | - foreach ( $link_ids as $link_id ) |
|
364 | + if ($link_ids) { |
|
365 | + foreach ($link_ids as $link_id) |
|
366 | 366 | wp_delete_link($link_id); |
367 | 367 | } |
368 | 368 | } else { |
369 | - $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
|
370 | - $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); |
|
371 | - if ( ! empty( $post_ids ) ) { |
|
372 | - foreach ( $post_ids as $post_id ) |
|
373 | - clean_post_cache( $post_id ); |
|
369 | + $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id)); |
|
370 | + $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id)); |
|
371 | + if ( ! empty($post_ids)) { |
|
372 | + foreach ($post_ids as $post_id) |
|
373 | + clean_post_cache($post_id); |
|
374 | 374 | } |
375 | - $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); |
|
376 | - $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); |
|
377 | - if ( ! empty( $link_ids ) ) { |
|
378 | - foreach ( $link_ids as $link_id ) |
|
379 | - clean_bookmark_cache( $link_id ); |
|
375 | + $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id)); |
|
376 | + $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id)); |
|
377 | + if ( ! empty($link_ids)) { |
|
378 | + foreach ($link_ids as $link_id) |
|
379 | + clean_bookmark_cache($link_id); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | 383 | // FINALLY, delete user |
384 | - if ( is_multisite() ) { |
|
385 | - remove_user_from_blog( $id, get_current_blog_id() ); |
|
384 | + if (is_multisite()) { |
|
385 | + remove_user_from_blog($id, get_current_blog_id()); |
|
386 | 386 | } else { |
387 | - $meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
|
388 | - foreach ( $meta as $mid ) |
|
389 | - delete_metadata_by_mid( 'user', $mid ); |
|
387 | + $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id)); |
|
388 | + foreach ($meta as $mid) |
|
389 | + delete_metadata_by_mid('user', $mid); |
|
390 | 390 | |
391 | - $wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
|
391 | + $wpdb->delete($wpdb->users, array('ID' => $id)); |
|
392 | 392 | } |
393 | 393 | |
394 | - clean_user_cache( $user ); |
|
394 | + clean_user_cache($user); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Fires immediately after a user is deleted from the database. |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @param int|null $reassign ID of the user to reassign posts and links to. |
403 | 403 | * Default null, for no reassignment. |
404 | 404 | */ |
405 | - do_action( 'deleted_user', $id, $reassign ); |
|
405 | + do_action('deleted_user', $id, $reassign); |
|
406 | 406 | |
407 | 407 | return true; |
408 | 408 | } |
@@ -431,11 +431,11 @@ discard block |
||
431 | 431 | function default_password_nag_handler($errors = false) { |
432 | 432 | global $user_ID; |
433 | 433 | // Short-circuit it. |
434 | - if ( ! get_user_option('default_password_nag') ) |
|
434 | + if ( ! get_user_option('default_password_nag')) |
|
435 | 435 | return; |
436 | 436 | |
437 | 437 | // get_user_setting = JS saved UI setting. else no-js-fallback code. |
438 | - if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) { |
|
438 | + if ('hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag']) { |
|
439 | 439 | delete_user_setting('default_password_nag'); |
440 | 440 | update_user_option($user_ID, 'default_password_nag', false, true); |
441 | 441 | } |
@@ -449,13 +449,13 @@ discard block |
||
449 | 449 | */ |
450 | 450 | function default_password_nag_edit_user($user_ID, $old_data) { |
451 | 451 | // Short-circuit it. |
452 | - if ( ! get_user_option('default_password_nag', $user_ID) ) |
|
452 | + if ( ! get_user_option('default_password_nag', $user_ID)) |
|
453 | 453 | return; |
454 | 454 | |
455 | 455 | $new_data = get_userdata($user_ID); |
456 | 456 | |
457 | 457 | // Remove the nag if the password has been changed. |
458 | - if ( $new_data->user_pass != $old_data->user_pass ) { |
|
458 | + if ($new_data->user_pass != $old_data->user_pass) { |
|
459 | 459 | delete_user_setting('default_password_nag'); |
460 | 460 | update_user_option($user_ID, 'default_password_nag', false, true); |
461 | 461 | } |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | function default_password_nag() { |
470 | 470 | global $pagenow; |
471 | 471 | // Short-circuit it. |
472 | - if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) |
|
472 | + if ('profile.php' == $pagenow || ! get_user_option('default_password_nag')) |
|
473 | 473 | return; |
474 | 474 | |
475 | 475 | echo '<div class="error default-password-nag">'; |
476 | 476 | echo '<p>'; |
477 | - echo '<strong>' . __('Notice:') . '</strong> '; |
|
477 | + echo '<strong>'.__('Notice:').'</strong> '; |
|
478 | 478 | _e('You’re using the auto-generated password for your account. Would you like to change it?'); |
479 | 479 | echo '</p><p>'; |
480 | - printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', get_edit_profile_url() . '#password' ); |
|
481 | - printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); |
|
480 | + printf('<a href="%s">'.__('Yes, take me to my profile page').'</a> | ', get_edit_profile_url().'#password'); |
|
481 | + printf('<a href="%s" id="default-password-nag-no">'.__('No thanks, do not remind me again').'</a>', '?default_password_nag=0'); |
|
482 | 482 | echo '</p></div>'; |
483 | 483 | } |
484 | 484 | |
@@ -524,16 +524,16 @@ discard block |
||
524 | 524 | * @param string $text |
525 | 525 | * @return string |
526 | 526 | */ |
527 | -function admin_created_user_email( $text ) { |
|
527 | +function admin_created_user_email($text) { |
|
528 | 528 | $roles = get_editable_roles(); |
529 | - $role = $roles[ $_REQUEST['role'] ]; |
|
529 | + $role = $roles[$_REQUEST['role']]; |
|
530 | 530 | /* translators: 1: Site name, 2: site URL, 3: role */ |
531 | - return sprintf( __( 'Hi, |
|
531 | + return sprintf(__('Hi, |
|
532 | 532 | You\'ve been invited to join \'%1$s\' at |
533 | 533 | %2$s with the role of %3$s. |
534 | 534 | If you do not want to join this site please ignore |
535 | 535 | this email. This invitation will expire in a few days. |
536 | 536 | |
537 | 537 | Please click the following link to activate your user account: |
538 | -%%s' ), get_bloginfo( 'name' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); |
|
538 | +%%s' ), get_bloginfo('name'), home_url(), wp_specialchars_decode(translate_user_role($role['name']))); |
|
539 | 539 | } |
@@ -203,15 +203,15 @@ |
||
203 | 203 | |
204 | 204 | /* translators: 1: WordPress version number, 2: plural number of bugs. */ |
205 | 205 | _n_noop( '<strong>Version %1$s</strong> addressed %2$s bug.', |
206 | - '<strong>Version %1$s</strong> addressed %2$s bugs.' ); |
|
206 | + '<strong>Version %1$s</strong> addressed %2$s bugs.' ); |
|
207 | 207 | |
208 | 208 | /* translators: 1: WordPress version number, 2: plural number of bugs. Singular security issue. */ |
209 | 209 | _n_noop( '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.', |
210 | - '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.' ); |
|
210 | + '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.' ); |
|
211 | 211 | |
212 | 212 | /* translators: 1: WordPress version number, 2: plural number of bugs. More than one security issue. */ |
213 | 213 | _n_noop( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.', |
214 | - '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.' ); |
|
214 | + '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.' ); |
|
215 | 215 | |
216 | 216 | /* translators: %s: Codex URL */ |
217 | 217 | __( 'For more information, see <a href="%s">the release notes</a>.' ); |
@@ -7,75 +7,75 @@ 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 ( ! wp_is_mobile() ) { |
|
13 | - wp_enqueue_style( 'wp-mediaelement' ); |
|
14 | - wp_enqueue_script( 'wp-mediaelement' ); |
|
15 | - wp_localize_script( 'mediaelement', '_wpmejsSettings', array( |
|
16 | - 'pluginPath' => includes_url( 'js/mediaelement/', 'relative' ), |
|
12 | +if ( ! wp_is_mobile()) { |
|
13 | + wp_enqueue_style('wp-mediaelement'); |
|
14 | + wp_enqueue_script('wp-mediaelement'); |
|
15 | + wp_localize_script('mediaelement', '_wpmejsSettings', array( |
|
16 | + 'pluginPath' => includes_url('js/mediaelement/', 'relative'), |
|
17 | 17 | 'pauseOtherPlayers' => '', |
18 | - ) ); |
|
18 | + )); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $video_url = 'https://videopress.com/embed/AHz0Ca46?hd=true'; |
22 | -$lang_code = str_replace( '_', '-', get_user_locale() ); |
|
23 | -list( $lang_code ) = explode( '-', $lang_code ); |
|
24 | -if ( 'en' !== $lang_code ) { |
|
25 | - $video_url = add_query_arg( 'defaultLangCode', $lang_code, $video_url ); |
|
22 | +$lang_code = str_replace('_', '-', get_user_locale()); |
|
23 | +list($lang_code) = explode('-', $lang_code); |
|
24 | +if ('en' !== $lang_code) { |
|
25 | + $video_url = add_query_arg('defaultLangCode', $lang_code, $video_url); |
|
26 | 26 | } |
27 | 27 | |
28 | -$title = __( 'About' ); |
|
28 | +$title = __('About'); |
|
29 | 29 | |
30 | -list( $display_version ) = explode( '-', get_bloginfo( 'version' ) ); |
|
30 | +list($display_version) = explode('-', get_bloginfo('version')); |
|
31 | 31 | |
32 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
32 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
33 | 33 | ?> |
34 | 34 | <div class="wrap about-wrap"> |
35 | - <h1><?php printf( __( 'Welcome to WordPress %s' ), $display_version ); ?></h1> |
|
35 | + <h1><?php printf(__('Welcome to WordPress %s'), $display_version); ?></h1> |
|
36 | 36 | |
37 | - <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> |
|
38 | - <div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div> |
|
37 | + <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> |
|
38 | + <div class="wp-badge"><?php printf(__('Version %s'), $display_version); ?></div> |
|
39 | 39 | |
40 | 40 | <h2 class="nav-tab-wrapper wp-clearfix"> |
41 | - <a href="about.php" class="nav-tab nav-tab-active"><?php _e( 'What’s New' ); ?></a> |
|
42 | - <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a> |
|
43 | - <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a> |
|
41 | + <a href="about.php" class="nav-tab nav-tab-active"><?php _e('What’s New'); ?></a> |
|
42 | + <a href="credits.php" class="nav-tab"><?php _e('Credits'); ?></a> |
|
43 | + <a href="freedoms.php" class="nav-tab"><?php _e('Freedoms'); ?></a> |
|
44 | 44 | </h2> |
45 | 45 | |
46 | 46 | <div class="headline-feature feature-video"> |
47 | - <iframe width="1050" height="591" src="<?php echo esc_url( $video_url ); ?>" frameborder="0" allowfullscreen></iframe> |
|
47 | + <iframe width="1050" height="591" src="<?php echo esc_url($video_url); ?>" frameborder="0" allowfullscreen></iframe> |
|
48 | 48 | <script src="https://videopress.com/videopress-iframe.js"></script> |
49 | 49 | </div> |
50 | 50 | |
51 | 51 | <hr /> |
52 | 52 | |
53 | 53 | <div class="feature-section one-col"> |
54 | - <h2><?php _e( 'Presenting Twenty Seventeen' ); ?></h2> |
|
55 | - <p class="lead-description"><?php _e( 'A brand new default theme brings your site to life with immersive featured images and video headers.' ); ?></p> |
|
54 | + <h2><?php _e('Presenting Twenty Seventeen'); ?></h2> |
|
55 | + <p class="lead-description"><?php _e('A brand new default theme brings your site to life with immersive featured images and video headers.'); ?></p> |
|
56 | 56 | <picture> |
57 | 57 | <source media="(min-width: 450px)" srcset="https://s.w.org/images/core/4.7/twenty-seventeen-1600.jpg?v2 1600w, https://s.w.org/images/core/4.7/twenty-seventeen-493.jpg?v2 493w, https://s.w.org/images/core/4.7/twenty-seventeen-663.jpg?v2 663w, https://s.w.org/images/core/4.7/twenty-seventeen-804.jpg?v2 804w, https://s.w.org/images/core/4.7/twenty-seventeen-928.jpg?v2 928w, https://s.w.org/images/core/4.7/twenty-seventeen-1058.jpg?v2 1058w, https://s.w.org/images/core/4.7/twenty-seventeen-1173.jpg?v2 1173w, https://s.w.org/images/core/4.7/twenty-seventeen-1299.jpg?v2 1299w, https://s.w.org/images/core/4.7/twenty-seventeen-1410.jpg?v2 1410w, https://s.w.org/images/core/4.7/twenty-seventeen-1513.jpg?v2 1513w, https://s.w.org/images/core/4.7/twenty-seventeen-1595.jpg?v2 1595w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 782px) calc(100vw - 70px), (max-width: 959px) calc(100vw - 116px), (max-width: 1290px) calc(100vw - 240px), 1050px"> |
58 | 58 | <source srcset="https://s.w.org/images/core/4.7/twenty-seventeen-mobile-564.jpg?v2 564w, https://s.w.org/images/core/4.7/twenty-seventeen-mobile-280.jpg?v2 280w, https://s.w.org/images/core/4.7/twenty-seventeen-mobile-372.jpg?v2 372w, https://s.w.org/images/core/4.7/twenty-seventeen-mobile-454.jpg?v2 454w, https://s.w.org/images/core/4.7/twenty-seventeen-mobile-541.jpg?v2 541w" sizes="calc(100vw - 40px)"> |
59 | 59 | <img src="https://s.w.org/images/core/4.7/twenty-seventeen-1600.jpg?v2" srcset="https://s.w.org/images/core/4.7/twenty-seventeen-1600.jpg?v2 1600w, https://s.w.org/images/core/4.7/twenty-seventeen-280.jpg?v2 280w, https://s.w.org/images/core/4.7/twenty-seventeen-493.jpg?v2 493w, https://s.w.org/images/core/4.7/twenty-seventeen-663.jpg?v2 663w, https://s.w.org/images/core/4.7/twenty-seventeen-804.jpg?v2 804w, https://s.w.org/images/core/4.7/twenty-seventeen-928.jpg?v2 928w, https://s.w.org/images/core/4.7/twenty-seventeen-1058.jpg?v2 1058w, https://s.w.org/images/core/4.7/twenty-seventeen-1173.jpg?v2 1173w, https://s.w.org/images/core/4.7/twenty-seventeen-1299.jpg?v2 1299w, https://s.w.org/images/core/4.7/twenty-seventeen-1410.jpg?v2 1410w, https://s.w.org/images/core/4.7/twenty-seventeen-1513.jpg?v2 1513w, https://s.w.org/images/core/4.7/twenty-seventeen-1595.jpg?v2 1595w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 782px) calc(100vw - 70px), (max-width: 959px) calc(100vw - 116px), (max-width: 1290px) calc(100vw - 240px), 1050px" alt="" /> |
60 | 60 | </picture> |
61 | - <p><?php _e( 'Twenty Seventeen focuses on business sites and features a customizable front page with multiple sections. Personalize it with widgets, navigation, social menus, a logo, custom colors, and more. Our default theme for 2017 works great in many languages, on any device, and for a wide range of users.' ); ?></p> |
|
61 | + <p><?php _e('Twenty Seventeen focuses on business sites and features a customizable front page with multiple sections. Personalize it with widgets, navigation, social menus, a logo, custom colors, and more. Our default theme for 2017 works great in many languages, on any device, and for a wide range of users.'); ?></p> |
|
62 | 62 | </div> |
63 | 63 | |
64 | 64 | <hr /> |
65 | 65 | |
66 | 66 | <div class="feature-section one-col"> |
67 | - <h2><?php _e( 'Your Site, Your Way' ); ?></h2> |
|
68 | - <p class="lead-description"><?php _e( 'WordPress 4.7 adds new features to the customizer to help take you through the initial setup of a theme, with non-destructive live previews of all your changes in one uninterrupted workflow.' ); ?></p> |
|
67 | + <h2><?php _e('Your Site, Your Way'); ?></h2> |
|
68 | + <p class="lead-description"><?php _e('WordPress 4.7 adds new features to the customizer to help take you through the initial setup of a theme, with non-destructive live previews of all your changes in one uninterrupted workflow.'); ?></p> |
|
69 | 69 | </div> |
70 | 70 | |
71 | 71 | <div class="feature-section two-col"> |
72 | 72 | <div class="col"> |
73 | - <h3><?php _e( 'Theme Starter Content' ); ?></h3> |
|
74 | - <p><?php _e( 'To help give you a solid base to build from, individual themes can provide starter content that appears when you go to customize your brand new site. This can range from placing a business information widget in the best location to providing a sample menu with social icon links to a static front page complete with beautiful images. Don’t worry - nothing new will appear on the live site until you’re ready to save and publish your initial theme setup.' ); ?></p> |
|
73 | + <h3><?php _e('Theme Starter Content'); ?></h3> |
|
74 | + <p><?php _e('To help give you a solid base to build from, individual themes can provide starter content that appears when you go to customize your brand new site. This can range from placing a business information widget in the best location to providing a sample menu with social icon links to a static front page complete with beautiful images. Don’t worry - nothing new will appear on the live site until you’re ready to save and publish your initial theme setup.'); ?></p> |
|
75 | 75 | </div> |
76 | 76 | <div class="col"> |
77 | 77 | <?php |
78 | - echo wp_video_shortcode( array( |
|
78 | + echo wp_video_shortcode(array( |
|
79 | 79 | 'mp4' => 'https://s.w.org/images/core/4.7/starter-content-v1.mp4', |
80 | 80 | 'poster' => 'https://s.w.org/images/core/4.7/starter-content.jpg?v2', |
81 | 81 | 'loop' => true, |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | 'width' => 1140, |
84 | 84 | 'height' => 624, |
85 | 85 | // 'class' => 'wp-video-shortcode feature-video', |
86 | - ) ); |
|
86 | + )); |
|
87 | 87 | ?> |
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | |
91 | 91 | <div class="feature-section two-col"> |
92 | 92 | <div class="col"> |
93 | - <h3><?php _e( 'Edit Shortcuts' ); ?></h3> |
|
93 | + <h3><?php _e('Edit Shortcuts'); ?></h3> |
|
94 | 94 | <?php |
95 | - echo wp_video_shortcode( array( |
|
95 | + echo wp_video_shortcode(array( |
|
96 | 96 | 'mp4' => 'https://s.w.org/images/core/4.7/edit-shortcuts-v1.mp4', |
97 | 97 | 'poster' => 'https://s.w.org/images/core/4.7/edit-shortcuts.jpg?v2', |
98 | 98 | 'loop' => true, |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | 'width' => 2520, |
101 | 101 | 'height' => 1454, |
102 | 102 | // 'class' => 'wp-video-shortcode feature-video', |
103 | - ) ); |
|
103 | + )); |
|
104 | 104 | ?> |
105 | - <p><?php _e( 'Visible icons appear to show you which parts of your site can be customized while live previewing. Click on a shortcut and get straight to editing. Paired with starter content, getting started with customizing your site is faster than ever.' );?></p> |
|
105 | + <p><?php _e('Visible icons appear to show you which parts of your site can be customized while live previewing. Click on a shortcut and get straight to editing. Paired with starter content, getting started with customizing your site is faster than ever.'); ?></p> |
|
106 | 106 | </div> |
107 | 107 | <div class="col"> |
108 | - <h3><?php _e( 'Video Headers' ); ?></h3> |
|
108 | + <h3><?php _e('Video Headers'); ?></h3> |
|
109 | 109 | <?php |
110 | - echo wp_video_shortcode( array( |
|
110 | + echo wp_video_shortcode(array( |
|
111 | 111 | 'mp4' => 'https://s.w.org/images/core/4.7/header-video-v1.mp4', |
112 | 112 | 'poster' => 'https://s.w.org/images/core/4.7/header-video.jpg?v2', |
113 | 113 | 'loop' => true, |
@@ -115,22 +115,22 @@ discard block |
||
115 | 115 | 'width' => 2520, |
116 | 116 | 'height' => 1454, |
117 | 117 | // 'class' => 'wp-video-shortcode feature-video', |
118 | - ) ); |
|
118 | + )); |
|
119 | 119 | ?> |
120 | - <p><?php _e( 'Sometimes a big atmospheric video as a moving header image is just what you need to showcase your wares; go ahead and try it out with Twenty Seventeen. Need some video inspiration? Try searching for sites with video headers available for download and use.' ); ?></p> |
|
120 | + <p><?php _e('Sometimes a big atmospheric video as a moving header image is just what you need to showcase your wares; go ahead and try it out with Twenty Seventeen. Need some video inspiration? Try searching for sites with video headers available for download and use.'); ?></p> |
|
121 | 121 | </div> |
122 | 122 | </div> |
123 | 123 | |
124 | 124 | <div class="feature-section two-col"> |
125 | 125 | <div class="col"> |
126 | - <h3><?php _e( 'Smoother Menu Building' ); ?></h3> |
|
126 | + <h3><?php _e('Smoother Menu Building'); ?></h3> |
|
127 | 127 | <img src="https://s.w.org/images/core/4.7/nav-menus-760.jpg?v2" srcset="https://s.w.org/images/core/4.7/nav-menus-760.jpg?v2 760w, https://s.w.org/images/core/4.7/nav-menus-280.jpg?v2 280w, https://s.w.org/images/core/4.7/nav-menus-536.jpg?v2 536w, https://s.w.org/images/core/4.7/nav-menus-745.jpg?v2 745w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 781px) calc((100vw - 70px) * .466), (max-width: 959px) calc((100vw - 116px) * .469), (max-width: 1290px) calc((100vw - 240px) * .472), 496px" alt="" /> |
128 | - <p><?php _e( 'Many menus for sites contain links to the pages of your site, but what happens when you don’t have any pages yet? Now you can add new pages while building menus instead of leaving the customizer and abandoning your changes. Once you’ve published your customizations, you’ll have new pages ready for you to fill with content.' );?></p> |
|
128 | + <p><?php _e('Many menus for sites contain links to the pages of your site, but what happens when you don’t have any pages yet? Now you can add new pages while building menus instead of leaving the customizer and abandoning your changes. Once you’ve published your customizations, you’ll have new pages ready for you to fill with content.'); ?></p> |
|
129 | 129 | </div> |
130 | 130 | <div class="col"> |
131 | - <h3><?php _e( 'Custom CSS' ); ?></h3> |
|
131 | + <h3><?php _e('Custom CSS'); ?></h3> |
|
132 | 132 | <img src="https://s.w.org/images/core/4.7/css-760.jpg?v2" srcset="https://s.w.org/images/core/4.7/css-760.jpg?v2 760w, https://s.w.org/images/core/4.7/css-280.jpg?v2 280w, https://s.w.org/images/core/4.7/css-547.jpg?v2 547w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 781px) calc((100vw - 70px) * .466), (max-width: 959px) calc((100vw - 116px) * .469), (max-width: 1290px) calc((100vw - 240px) * .472), 496px" alt="" /> |
133 | - <p><?php _e( 'Sometimes you just need a few visual tweaks to make your site perfect. WordPress 4.7 allows you to add custom CSS and instantly see how your changes affect your site. The live preview allows you to work quickly without page refreshes slowing you down.' ); ?></p> |
|
133 | + <p><?php _e('Sometimes you just need a few visual tweaks to make your site perfect. WordPress 4.7 allows you to add custom CSS and instantly see how your changes affect your site. The live preview allows you to work quickly without page refreshes slowing you down.'); ?></p> |
|
134 | 134 | </div> |
135 | 135 | </div> |
136 | 136 | |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | |
139 | 139 | <div class="feature-section no-heading two-col"> |
140 | 140 | <div class="col"> |
141 | - <h3><?php _e( 'PDF Thumbnail Previews' ); ?></h3> |
|
141 | + <h3><?php _e('PDF Thumbnail Previews'); ?></h3> |
|
142 | 142 | <img src="https://s.w.org/images/core/4.7/pdf-760.jpg?v2" srcset="https://s.w.org/images/core/4.7/pdf-760.jpg?v2 760w, https://s.w.org/images/core/4.7/pdf-280.jpg?v2 280w, https://s.w.org/images/core/4.7/pdf-412.jpg?v2 412w, https://s.w.org/images/core/4.7/pdf-516.jpg?v2 516w, https://s.w.org/images/core/4.7/pdf-615.jpg?v2 615w, https://s.w.org/images/core/4.7/pdf-716.jpg?v2 716w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 781px) calc((100vw - 70px) * .466), (max-width: 959px) calc((100vw - 116px) * .469), (max-width: 1290px) calc((100vw - 240px) * .472), 496px" alt="" /> |
143 | - <p><?php _e( 'Managing your document collection is easier with WordPress 4.7. Uploading PDFs will generate thumbnail images so you can more easily distinguish between all your documents.' ); ?></p> |
|
143 | + <p><?php _e('Managing your document collection is easier with WordPress 4.7. Uploading PDFs will generate thumbnail images so you can more easily distinguish between all your documents.'); ?></p> |
|
144 | 144 | </div> |
145 | 145 | <div class="col"> |
146 | - <h3><?php _e( 'Dashboard in your language' ); ?></h3> |
|
146 | + <h3><?php _e('Dashboard in your language'); ?></h3> |
|
147 | 147 | <img src="https://s.w.org/images/core/4.7/language-760.jpg?v2" srcset="https://s.w.org/images/core/4.7/language-760.jpg?v2 760w, https://s.w.org/images/core/4.7/language-280.jpg?v2 280w, https://s.w.org/images/core/4.7/language-568.jpg?v2 568w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 781px) calc((100vw - 70px) * .466), (max-width: 959px) calc((100vw - 116px) * .469), (max-width: 1290px) calc((100vw - 240px) * .472), 496px" alt="" /> |
148 | - <p><?php _e( 'Just because your site is in one language doesn’t mean that everybody helping manage it prefers that language for their admin. Add more languages to your site and a user language option will show up in your user’s profiles.' );?></p> |
|
148 | + <p><?php _e('Just because your site is in one language doesn’t mean that everybody helping manage it prefers that language for their admin. Add more languages to your site and a user language option will show up in your user’s profiles.'); ?></p> |
|
149 | 149 | </div> |
150 | 150 | </div> |
151 | 151 | |
152 | 152 | <hr /> |
153 | 153 | |
154 | 154 | <div class="rest-api feature-section one-col"> |
155 | - <h2><?php _e( 'Introducing REST API Content Endpoints' ); ?></h2> |
|
156 | - <p class="lead-description"><?php _e( 'WordPress 4.7 comes with REST API endpoints for posts, comments, terms, users, meta, and settings.' ); ?></p> |
|
155 | + <h2><?php _e('Introducing REST API Content Endpoints'); ?></h2> |
|
156 | + <p class="lead-description"><?php _e('WordPress 4.7 comes with REST API endpoints for posts, comments, terms, users, meta, and settings.'); ?></p> |
|
157 | 157 | <img src="https://s.w.org/images/core/4.7/api-1559.jpg?v2" srcset="https://s.w.org/images/core/4.7/api-2100.jpg?v2 2100w, https://s.w.org/images/core/4.7/api-280.jpg?v2 280w, https://s.w.org/images/core/4.7/api-1034.jpg?v2 1034w, https://s.w.org/images/core/4.7/api-1559.jpg?v2 1559w, https://s.w.org/images/core/4.7/api-2032.jpg?v2 2032w" sizes="(max-width: 500px) calc(100vw - 40px), (max-width: 782px) calc(100vw - 70px), (max-width: 959px) calc(100vw - 116px), (max-width: 1290px) calc(100vw - 240px), 1050px" alt="" /> |
158 | 158 | <p><?php |
159 | 159 | printf( |
160 | 160 | /* translators: %s: https://developer.wordpress.org/rest-api/ */ |
161 | - __( 'Content endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, paving the way for new and innovative methods of interacting with sites through plugins, themes, apps, and beyond. Ready to get started with development? <a href="%s">Check out the REST API reference.</a>' ), |
|
161 | + __('Content endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, paving the way for new and innovative methods of interacting with sites through plugins, themes, apps, and beyond. Ready to get started with development? <a href="%s">Check out the REST API reference.</a>'), |
|
162 | 162 | 'https://developer.wordpress.org/rest-api/reference/' |
163 | 163 | ); |
164 | 164 | ?></p> |
@@ -170,29 +170,29 @@ discard block |
||
170 | 170 | <h2><?php |
171 | 171 | printf( |
172 | 172 | /* translators: %s: smiling face with smiling eyes emoji */ |
173 | - __( 'Even More Developer Happiness %s' ), |
|
173 | + __('Even More Developer Happiness %s'), |
|
174 | 174 | '😊' |
175 | 175 | ); |
176 | 176 | ?></h2> |
177 | 177 | |
178 | 178 | <div class="under-the-hood three-col"> |
179 | 179 | <div class="col"> |
180 | - <h3><a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/"><?php _e( 'Post Type Templates' ); ?></a></h3> |
|
181 | - <p><?php _e( 'By opening up the page template functionality to all post types, theme developers have even more flexibility with the WordPress template hierarchy.' ); ?></p> |
|
180 | + <h3><a href="https://make.wordpress.org/core/2016/11/03/post-type-templates-in-4-7/"><?php _e('Post Type Templates'); ?></a></h3> |
|
181 | + <p><?php _e('By opening up the page template functionality to all post types, theme developers have even more flexibility with the WordPress template hierarchy.'); ?></p> |
|
182 | 182 | </div> |
183 | 183 | <div class="col"> |
184 | - <h3><?php _e( 'More Theme API Goodies' ); ?></h3> |
|
184 | + <h3><?php _e('More Theme API Goodies'); ?></h3> |
|
185 | 185 | <p><?php |
186 | 186 | printf( |
187 | 187 | /* translators: %s: https://make.wordpress.org/core/2016/09/09/new-functions-hooks-and-behaviour-for-theme-developers-in-wordpress-4-7/ */ |
188 | - __( 'WordPress 4.7 includes <a href="%s">new functions, hooks, and behavior</a> for theme developers.' ), |
|
188 | + __('WordPress 4.7 includes <a href="%s">new functions, hooks, and behavior</a> for theme developers.'), |
|
189 | 189 | 'https://make.wordpress.org/core/2016/09/09/new-functions-hooks-and-behaviour-for-theme-developers-in-wordpress-4-7/' |
190 | 190 | ); |
191 | 191 | ?></p> |
192 | 192 | </div> |
193 | 193 | <div class="col"> |
194 | - <h3><a href="https://make.wordpress.org/core/2016/10/04/custom-bulk-actions/"><?php _e( 'Custom Bulk Actions' ); ?></a></h3> |
|
195 | - <p><?php _e( 'List tables, now with more than bulk edit and delete.' ); ?></p> |
|
194 | + <h3><a href="https://make.wordpress.org/core/2016/10/04/custom-bulk-actions/"><?php _e('Custom Bulk Actions'); ?></a></h3> |
|
195 | + <p><?php _e('List tables, now with more than bulk edit and delete.'); ?></p> |
|
196 | 196 | </div> |
197 | 197 | </div> |
198 | 198 | |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | <p><?php |
203 | 203 | printf( |
204 | 204 | /* translators: %s: https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/ */ |
205 | - __( 'The code that lies beneath actions and filters has been overhauled and modernized, fixing bugs along the way.' ), |
|
205 | + __('The code that lies beneath actions and filters has been overhauled and modernized, fixing bugs along the way.'), |
|
206 | 206 | 'https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/' |
207 | 207 | ); |
208 | 208 | ?></p> |
209 | 209 | </div> |
210 | 210 | <div class="col"> |
211 | - <h3><?php _e( 'Settings Registration API' ); ?></h3> |
|
211 | + <h3><?php _e('Settings Registration API'); ?></h3> |
|
212 | 212 | <p><?php |
213 | 213 | printf( |
214 | 214 | /* translators: 1: register_setting(), 2: https://make.wordpress.org/core/2016/10/26/registering-your-settings-in-wordpress-4-7/ */ |
215 | - __( '%1$s <a href="%2$s">has been enhanced</a> to include type, description, and REST API visibility.' ), |
|
215 | + __('%1$s <a href="%2$s">has been enhanced</a> to include type, description, and REST API visibility.'), |
|
216 | 216 | '<code>register_setting()</code>', |
217 | 217 | 'https://make.wordpress.org/core/2016/10/26/registering-your-settings-in-wordpress-4-7/' |
218 | 218 | ); |
219 | 219 | ?></p> |
220 | 220 | </div> |
221 | 221 | <div class="col"> |
222 | - <h3><a href="https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/"><?php _e( 'Customize Changesets' ); ?></a></h3> |
|
223 | - <p><?php _e( 'Customize changesets make changes in the customizer persistent, like autosave drafts. They also make exciting new features like starter content possible.' ); ?></p> |
|
222 | + <h3><a href="https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/"><?php _e('Customize Changesets'); ?></a></h3> |
|
223 | + <p><?php _e('Customize changesets make changes in the customizer persistent, like autosave drafts. They also make exciting new features like starter content possible.'); ?></p> |
|
224 | 224 | </div> |
225 | 225 | </div> |
226 | 226 | |
@@ -229,47 +229,47 @@ discard block |
||
229 | 229 | <hr /> |
230 | 230 | |
231 | 231 | <div class="return-to-dashboard"> |
232 | - <?php if ( current_user_can( 'update_core' ) && isset( $_GET['updated'] ) ) : ?> |
|
233 | - <a href="<?php echo esc_url( self_admin_url( 'update-core.php' ) ); ?>"> |
|
234 | - <?php is_multisite() ? _e( 'Return to Updates' ) : _e( 'Return to Dashboard → Updates' ); ?> |
|
232 | + <?php if (current_user_can('update_core') && isset($_GET['updated'])) : ?> |
|
233 | + <a href="<?php echo esc_url(self_admin_url('update-core.php')); ?>"> |
|
234 | + <?php is_multisite() ? _e('Return to Updates') : _e('Return to Dashboard → Updates'); ?> |
|
235 | 235 | </a> | |
236 | 236 | <?php endif; ?> |
237 | - <a href="<?php echo esc_url( self_admin_url() ); ?>"><?php is_blog_admin() ? _e( 'Go to Dashboard → Home' ) : _e( 'Go to Dashboard' ); ?></a> |
|
237 | + <a href="<?php echo esc_url(self_admin_url()); ?>"><?php is_blog_admin() ? _e('Go to Dashboard → Home') : _e('Go to Dashboard'); ?></a> |
|
238 | 238 | </div> |
239 | 239 | |
240 | 240 | </div> |
241 | 241 | <?php |
242 | 242 | |
243 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
243 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
|
244 | 244 | |
245 | 245 | // These are strings we may use to describe maintenance/security releases, where we aim for no new strings. |
246 | 246 | return; |
247 | 247 | |
248 | -__( 'Maintenance Release' ); |
|
249 | -__( 'Maintenance Releases' ); |
|
248 | +__('Maintenance Release'); |
|
249 | +__('Maintenance Releases'); |
|
250 | 250 | |
251 | -__( 'Security Release' ); |
|
252 | -__( 'Security Releases' ); |
|
251 | +__('Security Release'); |
|
252 | +__('Security Releases'); |
|
253 | 253 | |
254 | -__( 'Maintenance and Security Release' ); |
|
255 | -__( 'Maintenance and Security Releases' ); |
|
254 | +__('Maintenance and Security Release'); |
|
255 | +__('Maintenance and Security Releases'); |
|
256 | 256 | |
257 | 257 | /* translators: %s: WordPress version number */ |
258 | -__( '<strong>Version %s</strong> addressed one security issue.' ); |
|
258 | +__('<strong>Version %s</strong> addressed one security issue.'); |
|
259 | 259 | /* translators: %s: WordPress version number */ |
260 | -__( '<strong>Version %s</strong> addressed some security issues.' ); |
|
260 | +__('<strong>Version %s</strong> addressed some security issues.'); |
|
261 | 261 | |
262 | 262 | /* translators: 1: WordPress version number, 2: plural number of bugs. */ |
263 | -_n_noop( '<strong>Version %1$s</strong> addressed %2$s bug.', |
|
264 | - '<strong>Version %1$s</strong> addressed %2$s bugs.' ); |
|
263 | +_n_noop('<strong>Version %1$s</strong> addressed %2$s bug.', |
|
264 | + '<strong>Version %1$s</strong> addressed %2$s bugs.'); |
|
265 | 265 | |
266 | 266 | /* translators: 1: WordPress version number, 2: plural number of bugs. Singular security issue. */ |
267 | -_n_noop( '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.', |
|
268 | - '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.' ); |
|
267 | +_n_noop('<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.', |
|
268 | + '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.'); |
|
269 | 269 | |
270 | 270 | /* translators: 1: WordPress version number, 2: plural number of bugs. More than one security issue. */ |
271 | -_n_noop( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.', |
|
272 | - '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.' ); |
|
271 | +_n_noop('<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.', |
|
272 | + '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.'); |
|
273 | 273 | |
274 | 274 | /* translators: %s: Codex URL */ |
275 | -__( 'For more information, see <a href="%s">the release notes</a>.' ); |
|
275 | +__('For more information, see <a href="%s">the release notes</a>.'); |
@@ -348,7 +348,7 @@ |
||
348 | 348 | if ( current_user_can($tax->cap->edit_terms) ) { |
349 | 349 | if ( 'category' == $taxonomy ) { |
350 | 350 | /** |
351 | - * Fires before the Add Category form. |
|
351 | + * Fires before the Add Category form. |
|
352 | 352 | * |
353 | 353 | * @since 2.1.0 |
354 | 354 | * @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead. |
@@ -68,115 +68,115 @@ |
||
68 | 68 | |
69 | 69 | switch ( $wp_list_table->current_action() ) { |
70 | 70 | |
71 | -case 'add-tag': |
|
72 | - check_admin_referer( 'add-tag', '_wpnonce_add-tag' ); |
|
73 | - |
|
74 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
75 | - wp_die( |
|
76 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
77 | - '<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>', |
|
78 | - 403 |
|
79 | - ); |
|
80 | - } |
|
81 | - |
|
82 | - $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); |
|
83 | - if ( $ret && !is_wp_error( $ret ) ) |
|
84 | - $location = add_query_arg( 'message', 1, $referer ); |
|
85 | - else |
|
86 | - $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); |
|
87 | - |
|
88 | - break; |
|
71 | + case 'add-tag': |
|
72 | + check_admin_referer( 'add-tag', '_wpnonce_add-tag' ); |
|
73 | + |
|
74 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
75 | + wp_die( |
|
76 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
77 | + '<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>', |
|
78 | + 403 |
|
79 | + ); |
|
80 | + } |
|
81 | + |
|
82 | + $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); |
|
83 | + if ( $ret && !is_wp_error( $ret ) ) |
|
84 | + $location = add_query_arg( 'message', 1, $referer ); |
|
85 | + else |
|
86 | + $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); |
|
89 | 87 | |
90 | -case 'delete': |
|
91 | - if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
92 | 88 | break; |
93 | - } |
|
94 | 89 | |
95 | - $tag_ID = (int) $_REQUEST['tag_ID']; |
|
96 | - check_admin_referer( 'delete-tag_' . $tag_ID ); |
|
90 | + case 'delete': |
|
91 | + if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
92 | + break; |
|
93 | + } |
|
97 | 94 | |
98 | - if ( ! current_user_can( 'delete_term', $tag_ID ) ) { |
|
99 | - wp_die( |
|
100 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
101 | - '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>', |
|
102 | - 403 |
|
103 | - ); |
|
104 | - } |
|
95 | + $tag_ID = (int) $_REQUEST['tag_ID']; |
|
96 | + check_admin_referer( 'delete-tag_' . $tag_ID ); |
|
105 | 97 | |
106 | - wp_delete_term( $tag_ID, $taxonomy ); |
|
98 | + if ( ! current_user_can( 'delete_term', $tag_ID ) ) { |
|
99 | + wp_die( |
|
100 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
101 | + '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>', |
|
102 | + 403 |
|
103 | + ); |
|
104 | + } |
|
107 | 105 | |
108 | - $location = add_query_arg( 'message', 2, $referer ); |
|
106 | + wp_delete_term( $tag_ID, $taxonomy ); |
|
109 | 107 | |
110 | - break; |
|
108 | + $location = add_query_arg( 'message', 2, $referer ); |
|
111 | 109 | |
112 | -case 'bulk-delete': |
|
113 | - check_admin_referer( 'bulk-tags' ); |
|
110 | + break; |
|
114 | 111 | |
115 | - if ( ! current_user_can( $tax->cap->delete_terms ) ) { |
|
116 | - wp_die( |
|
117 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
118 | - '<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>', |
|
119 | - 403 |
|
120 | - ); |
|
121 | - } |
|
112 | + case 'bulk-delete': |
|
113 | + check_admin_referer( 'bulk-tags' ); |
|
122 | 114 | |
123 | - $tags = (array) $_REQUEST['delete_tags']; |
|
124 | - foreach ( $tags as $tag_ID ) { |
|
125 | - wp_delete_term( $tag_ID, $taxonomy ); |
|
126 | - } |
|
115 | + if ( ! current_user_can( $tax->cap->delete_terms ) ) { |
|
116 | + wp_die( |
|
117 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
118 | + '<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>', |
|
119 | + 403 |
|
120 | + ); |
|
121 | + } |
|
127 | 122 | |
128 | - $location = add_query_arg( 'message', 6, $referer ); |
|
123 | + $tags = (array) $_REQUEST['delete_tags']; |
|
124 | + foreach ( $tags as $tag_ID ) { |
|
125 | + wp_delete_term( $tag_ID, $taxonomy ); |
|
126 | + } |
|
129 | 127 | |
130 | - break; |
|
128 | + $location = add_query_arg( 'message', 6, $referer ); |
|
131 | 129 | |
132 | -case 'edit': |
|
133 | - if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
134 | 130 | break; |
135 | - } |
|
136 | 131 | |
137 | - $term_id = (int) $_REQUEST['tag_ID']; |
|
138 | - $term = get_term( $term_id ); |
|
132 | + case 'edit': |
|
133 | + if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
134 | + break; |
|
135 | + } |
|
139 | 136 | |
140 | - if ( ! $term instanceof WP_Term ) { |
|
141 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
142 | - } |
|
137 | + $term_id = (int) $_REQUEST['tag_ID']; |
|
138 | + $term = get_term( $term_id ); |
|
143 | 139 | |
144 | - wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); |
|
145 | - exit; |
|
140 | + if ( ! $term instanceof WP_Term ) { |
|
141 | + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
142 | + } |
|
146 | 143 | |
147 | -case 'editedtag': |
|
148 | - $tag_ID = (int) $_POST['tag_ID']; |
|
149 | - check_admin_referer( 'update-tag_' . $tag_ID ); |
|
144 | + wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); |
|
145 | + exit; |
|
150 | 146 | |
151 | - if ( ! current_user_can( 'edit_term', $tag_ID ) ) { |
|
152 | - wp_die( |
|
153 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
154 | - '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
|
155 | - 403 |
|
156 | - ); |
|
157 | - } |
|
147 | + case 'editedtag': |
|
148 | + $tag_ID = (int) $_POST['tag_ID']; |
|
149 | + check_admin_referer( 'update-tag_' . $tag_ID ); |
|
158 | 150 | |
159 | - $tag = get_term( $tag_ID, $taxonomy ); |
|
160 | - if ( ! $tag ) |
|
161 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
151 | + if ( ! current_user_can( 'edit_term', $tag_ID ) ) { |
|
152 | + wp_die( |
|
153 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
154 | + '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
|
155 | + 403 |
|
156 | + ); |
|
157 | + } |
|
162 | 158 | |
163 | - $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); |
|
159 | + $tag = get_term( $tag_ID, $taxonomy ); |
|
160 | + if ( ! $tag ) |
|
161 | + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
164 | 162 | |
165 | - if ( $ret && ! is_wp_error( $ret ) ) { |
|
166 | - $location = add_query_arg( 'message', 3, $referer ); |
|
167 | - } else { |
|
168 | - $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer ); |
|
169 | - } |
|
170 | - break; |
|
171 | -default: |
|
172 | - if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) { |
|
163 | + $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); |
|
164 | + |
|
165 | + if ( $ret && ! is_wp_error( $ret ) ) { |
|
166 | + $location = add_query_arg( 'message', 3, $referer ); |
|
167 | + } else { |
|
168 | + $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer ); |
|
169 | + } |
|
170 | + break; |
|
171 | + default: |
|
172 | + if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) { |
|
173 | + break; |
|
174 | + } |
|
175 | + check_admin_referer( 'bulk-tags' ); |
|
176 | + $tags = (array) $_REQUEST['delete_tags']; |
|
177 | + /** This action is documented in wp-admin/edit-comments.php */ |
|
178 | + $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); |
|
173 | 179 | break; |
174 | - } |
|
175 | - check_admin_referer( 'bulk-tags' ); |
|
176 | - $tags = (array) $_REQUEST['delete_tags']; |
|
177 | - /** This action is documented in wp-admin/edit-comments.php */ |
|
178 | - $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); |
|
179 | - break; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
@@ -7,24 +7,24 @@ 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 ( ! $taxnow ) |
|
13 | - wp_die( __( 'Invalid taxonomy.' ) ); |
|
12 | +if ( ! $taxnow) |
|
13 | + wp_die(__('Invalid taxonomy.')); |
|
14 | 14 | |
15 | -$tax = get_taxonomy( $taxnow ); |
|
15 | +$tax = get_taxonomy($taxnow); |
|
16 | 16 | |
17 | -if ( ! $tax ) |
|
18 | - wp_die( __( 'Invalid taxonomy.' ) ); |
|
17 | +if ( ! $tax) |
|
18 | + wp_die(__('Invalid taxonomy.')); |
|
19 | 19 | |
20 | -if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) { |
|
21 | - wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); |
|
20 | +if ( ! in_array($tax->name, get_taxonomies(array('show_ui' => true)))) { |
|
21 | + wp_die(__('Sorry, you are not allowed to edit terms in this taxonomy.')); |
|
22 | 22 | } |
23 | 23 | |
24 | -if ( ! current_user_can( $tax->cap->manage_terms ) ) { |
|
24 | +if ( ! current_user_can($tax->cap->manage_terms)) { |
|
25 | 25 | wp_die( |
26 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
27 | - '<p>' . __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ) . '</p>', |
|
26 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
27 | + '<p>'.__('Sorry, you are not allowed to manage terms in this taxonomy.').'</p>', |
|
28 | 28 | 403 |
29 | 29 | ); |
30 | 30 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | |
42 | 42 | $title = $tax->labels->name; |
43 | 43 | |
44 | -if ( 'post' != $post_type ) { |
|
45 | - $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type"; |
|
44 | +if ('post' != $post_type) { |
|
45 | + $parent_file = ('attachment' == $post_type) ? 'upload.php' : "edit.php?post_type=$post_type"; |
|
46 | 46 | $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; |
47 | -} elseif ( 'link_category' == $tax->name ) { |
|
47 | +} elseif ('link_category' == $tax->name) { |
|
48 | 48 | $parent_file = 'link-manager.php'; |
49 | 49 | $submenu_file = 'edit-tags.php?taxonomy=link_category'; |
50 | 50 | } else { |
@@ -52,140 +52,140 @@ discard block |
||
52 | 52 | $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; |
53 | 53 | } |
54 | 54 | |
55 | -add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) ); |
|
55 | +add_screen_option('per_page', array('default' => 20, 'option' => 'edit_'.$tax->name.'_per_page')); |
|
56 | 56 | |
57 | -get_current_screen()->set_screen_reader_content( array( |
|
57 | +get_current_screen()->set_screen_reader_content(array( |
|
58 | 58 | 'heading_pagination' => $tax->labels->items_list_navigation, |
59 | 59 | 'heading_list' => $tax->labels->items_list, |
60 | -) ); |
|
60 | +)); |
|
61 | 61 | |
62 | 62 | $location = false; |
63 | 63 | $referer = wp_get_referer(); |
64 | -if ( ! $referer ) { // For POST requests. |
|
65 | - $referer = wp_unslash( $_SERVER['REQUEST_URI'] ); |
|
64 | +if ( ! $referer) { // For POST requests. |
|
65 | + $referer = wp_unslash($_SERVER['REQUEST_URI']); |
|
66 | 66 | } |
67 | -$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer ); |
|
67 | +$referer = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'error', 'message', 'paged'), $referer); |
|
68 | 68 | |
69 | -switch ( $wp_list_table->current_action() ) { |
|
69 | +switch ($wp_list_table->current_action()) { |
|
70 | 70 | |
71 | 71 | case 'add-tag': |
72 | - check_admin_referer( 'add-tag', '_wpnonce_add-tag' ); |
|
72 | + check_admin_referer('add-tag', '_wpnonce_add-tag'); |
|
73 | 73 | |
74 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
74 | + if ( ! current_user_can($tax->cap->edit_terms)) { |
|
75 | 75 | wp_die( |
76 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
77 | - '<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>', |
|
76 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
77 | + '<p>'.__('Sorry, you are not allowed to create terms in this taxonomy.').'</p>', |
|
78 | 78 | 403 |
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
82 | - $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); |
|
83 | - if ( $ret && !is_wp_error( $ret ) ) |
|
84 | - $location = add_query_arg( 'message', 1, $referer ); |
|
82 | + $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); |
|
83 | + if ($ret && ! is_wp_error($ret)) |
|
84 | + $location = add_query_arg('message', 1, $referer); |
|
85 | 85 | else |
86 | - $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); |
|
86 | + $location = add_query_arg(array('error' => true, 'message' => 4), $referer); |
|
87 | 87 | |
88 | 88 | break; |
89 | 89 | |
90 | 90 | case 'delete': |
91 | - if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
91 | + if ( ! isset($_REQUEST['tag_ID'])) { |
|
92 | 92 | break; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $tag_ID = (int) $_REQUEST['tag_ID']; |
96 | - check_admin_referer( 'delete-tag_' . $tag_ID ); |
|
96 | + check_admin_referer('delete-tag_'.$tag_ID); |
|
97 | 97 | |
98 | - if ( ! current_user_can( 'delete_term', $tag_ID ) ) { |
|
98 | + if ( ! current_user_can('delete_term', $tag_ID)) { |
|
99 | 99 | wp_die( |
100 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
101 | - '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>', |
|
100 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
101 | + '<p>'.__('Sorry, you are not allowed to delete this item.').'</p>', |
|
102 | 102 | 403 |
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
106 | - wp_delete_term( $tag_ID, $taxonomy ); |
|
106 | + wp_delete_term($tag_ID, $taxonomy); |
|
107 | 107 | |
108 | - $location = add_query_arg( 'message', 2, $referer ); |
|
108 | + $location = add_query_arg('message', 2, $referer); |
|
109 | 109 | |
110 | 110 | break; |
111 | 111 | |
112 | 112 | case 'bulk-delete': |
113 | - check_admin_referer( 'bulk-tags' ); |
|
113 | + check_admin_referer('bulk-tags'); |
|
114 | 114 | |
115 | - if ( ! current_user_can( $tax->cap->delete_terms ) ) { |
|
115 | + if ( ! current_user_can($tax->cap->delete_terms)) { |
|
116 | 116 | wp_die( |
117 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
118 | - '<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>', |
|
117 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
118 | + '<p>'.__('Sorry, you are not allowed to delete these items.').'</p>', |
|
119 | 119 | 403 |
120 | 120 | ); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $tags = (array) $_REQUEST['delete_tags']; |
124 | - foreach ( $tags as $tag_ID ) { |
|
125 | - wp_delete_term( $tag_ID, $taxonomy ); |
|
124 | + foreach ($tags as $tag_ID) { |
|
125 | + wp_delete_term($tag_ID, $taxonomy); |
|
126 | 126 | } |
127 | 127 | |
128 | - $location = add_query_arg( 'message', 6, $referer ); |
|
128 | + $location = add_query_arg('message', 6, $referer); |
|
129 | 129 | |
130 | 130 | break; |
131 | 131 | |
132 | 132 | case 'edit': |
133 | - if ( ! isset( $_REQUEST['tag_ID'] ) ) { |
|
133 | + if ( ! isset($_REQUEST['tag_ID'])) { |
|
134 | 134 | break; |
135 | 135 | } |
136 | 136 | |
137 | 137 | $term_id = (int) $_REQUEST['tag_ID']; |
138 | - $term = get_term( $term_id ); |
|
138 | + $term = get_term($term_id); |
|
139 | 139 | |
140 | - if ( ! $term instanceof WP_Term ) { |
|
141 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
140 | + if ( ! $term instanceof WP_Term) { |
|
141 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
142 | 142 | } |
143 | 143 | |
144 | - wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); |
|
144 | + wp_redirect(esc_url_raw(get_edit_term_link($term_id, $taxonomy, $post_type))); |
|
145 | 145 | exit; |
146 | 146 | |
147 | 147 | case 'editedtag': |
148 | 148 | $tag_ID = (int) $_POST['tag_ID']; |
149 | - check_admin_referer( 'update-tag_' . $tag_ID ); |
|
149 | + check_admin_referer('update-tag_'.$tag_ID); |
|
150 | 150 | |
151 | - if ( ! current_user_can( 'edit_term', $tag_ID ) ) { |
|
151 | + if ( ! current_user_can('edit_term', $tag_ID)) { |
|
152 | 152 | wp_die( |
153 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
154 | - '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>', |
|
153 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
154 | + '<p>'.__('Sorry, you are not allowed to edit this item.').'</p>', |
|
155 | 155 | 403 |
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | - $tag = get_term( $tag_ID, $taxonomy ); |
|
160 | - if ( ! $tag ) |
|
161 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
159 | + $tag = get_term($tag_ID, $taxonomy); |
|
160 | + if ( ! $tag) |
|
161 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
162 | 162 | |
163 | - $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); |
|
163 | + $ret = wp_update_term($tag_ID, $taxonomy, $_POST); |
|
164 | 164 | |
165 | - if ( $ret && ! is_wp_error( $ret ) ) { |
|
166 | - $location = add_query_arg( 'message', 3, $referer ); |
|
165 | + if ($ret && ! is_wp_error($ret)) { |
|
166 | + $location = add_query_arg('message', 3, $referer); |
|
167 | 167 | } else { |
168 | - $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer ); |
|
168 | + $location = add_query_arg(array('error' => true, 'message' => 5), $referer); |
|
169 | 169 | } |
170 | 170 | break; |
171 | 171 | default: |
172 | - if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) { |
|
172 | + if ( ! $wp_list_table->current_action() || ! isset($_REQUEST['delete_tags'])) { |
|
173 | 173 | break; |
174 | 174 | } |
175 | - check_admin_referer( 'bulk-tags' ); |
|
175 | + check_admin_referer('bulk-tags'); |
|
176 | 176 | $tags = (array) $_REQUEST['delete_tags']; |
177 | 177 | /** This action is documented in wp-admin/edit-comments.php */ |
178 | - $location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags ); |
|
178 | + $location = apply_filters('handle_bulk_actions-'.get_current_screen()->id, $location, $wp_list_table->current_action(), $tags); |
|
179 | 179 | break; |
180 | 180 | } |
181 | 181 | |
182 | -if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
|
183 | - $location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
182 | +if ( ! $location && ! empty($_REQUEST['_wp_http_referer'])) { |
|
183 | + $location = remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])); |
|
184 | 184 | } |
185 | 185 | |
186 | -if ( $location ) { |
|
187 | - if ( $pagenum > 1 ) { |
|
188 | - $location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages. |
|
186 | +if ($location) { |
|
187 | + if ($pagenum > 1) { |
|
188 | + $location = add_query_arg('paged', $pagenum, $location); // $pagenum takes care of $total_pages. |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -196,114 +196,114 @@ discard block |
||
196 | 196 | * @param string $location The destination URL. |
197 | 197 | * @param object $tax The taxonomy object. |
198 | 198 | */ |
199 | - wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) ); |
|
199 | + wp_redirect(apply_filters('redirect_term_location', $location, $tax)); |
|
200 | 200 | exit; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $wp_list_table->prepare_items(); |
204 | -$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
204 | +$total_pages = $wp_list_table->get_pagination_arg('total_pages'); |
|
205 | 205 | |
206 | -if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
207 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
206 | +if ($pagenum > $total_pages && $total_pages > 0) { |
|
207 | + wp_redirect(add_query_arg('paged', $total_pages)); |
|
208 | 208 | exit; |
209 | 209 | } |
210 | 210 | |
211 | 211 | wp_enqueue_script('admin-tags'); |
212 | -if ( current_user_can($tax->cap->edit_terms) ) |
|
212 | +if (current_user_can($tax->cap->edit_terms)) |
|
213 | 213 | wp_enqueue_script('inline-edit-tax'); |
214 | 214 | |
215 | -if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) { |
|
216 | - $help =''; |
|
217 | - if ( 'category' == $taxonomy ) |
|
218 | - $help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>'; |
|
219 | - elseif ( 'link_category' == $taxonomy ) |
|
220 | - $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>'; |
|
215 | +if ('category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy) { |
|
216 | + $help = ''; |
|
217 | + if ('category' == $taxonomy) |
|
218 | + $help = '<p>'.sprintf(__('You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.'), 'options-writing.php').'</p>'; |
|
219 | + elseif ('link_category' == $taxonomy) |
|
220 | + $help = '<p>'.__('You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.').'</p>'; |
|
221 | 221 | else |
222 | - $help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '</p>'; |
|
222 | + $help = '<p>'.__('You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.').'</p>'; |
|
223 | 223 | |
224 | - if ( 'link_category' == $taxonomy ) |
|
225 | - $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>'; |
|
224 | + if ('link_category' == $taxonomy) |
|
225 | + $help .= '<p>'.__('You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.').'</p>'; |
|
226 | 226 | else |
227 | - $help .='<p>' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>'; |
|
227 | + $help .= '<p>'.__('What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.').'</p>'; |
|
228 | 228 | |
229 | - get_current_screen()->add_help_tab( array( |
|
229 | + get_current_screen()->add_help_tab(array( |
|
230 | 230 | 'id' => 'overview', |
231 | 231 | 'title' => __('Overview'), |
232 | 232 | 'content' => $help, |
233 | - ) ); |
|
233 | + )); |
|
234 | 234 | |
235 | - if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { |
|
236 | - if ( 'category' == $taxonomy ) |
|
237 | - $help = '<p>' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
235 | + if ('category' == $taxonomy || 'post_tag' == $taxonomy) { |
|
236 | + if ('category' == $taxonomy) |
|
237 | + $help = '<p>'.__('When adding a new category on this screen, you’ll fill in the following fields:').'</p>'; |
|
238 | 238 | else |
239 | - $help = '<p>' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
239 | + $help = '<p>'.__('When adding a new tag on this screen, you’ll fill in the following fields:').'</p>'; |
|
240 | 240 | |
241 | - $help .= '<ul>' . |
|
242 | - '<li>' . __( '<strong>Name</strong> — The name is how it appears on your site.' ) . '</li>'; |
|
241 | + $help .= '<ul>'. |
|
242 | + '<li>'.__('<strong>Name</strong> — The name is how it appears on your site.').'</li>'; |
|
243 | 243 | |
244 | - if ( ! global_terms_enabled() ) |
|
245 | - $help .= '<li>' . __( '<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; |
|
244 | + if ( ! global_terms_enabled()) |
|
245 | + $help .= '<li>'.__('<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.').'</li>'; |
|
246 | 246 | |
247 | - if ( 'category' == $taxonomy ) |
|
248 | - $help .= '<li>' . __( '<strong>Parent</strong> — Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>'; |
|
247 | + if ('category' == $taxonomy) |
|
248 | + $help .= '<li>'.__('<strong>Parent</strong> — Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.').'</li>'; |
|
249 | 249 | |
250 | - $help .= '<li>' . __( '<strong>Description</strong> — The description is not prominent by default; however, some themes may display it.' ) . '</li>' . |
|
251 | - '</ul>' . |
|
252 | - '<p>' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '</p>'; |
|
250 | + $help .= '<li>'.__('<strong>Description</strong> — The description is not prominent by default; however, some themes may display it.').'</li>'. |
|
251 | + '</ul>'. |
|
252 | + '<p>'.__('You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.').'</p>'; |
|
253 | 253 | |
254 | - get_current_screen()->add_help_tab( array( |
|
254 | + get_current_screen()->add_help_tab(array( |
|
255 | 255 | 'id' => 'adding-terms', |
256 | - 'title' => 'category' == $taxonomy ? __( 'Adding Categories' ) : __( 'Adding Tags' ), |
|
256 | + 'title' => 'category' == $taxonomy ? __('Adding Categories') : __('Adding Tags'), |
|
257 | 257 | 'content' => $help, |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | } |
260 | 260 | |
261 | - $help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>'; |
|
261 | + $help = '<p><strong>'.__('For more information:').'</strong></p>'; |
|
262 | 262 | |
263 | - if ( 'category' == $taxonomy ) |
|
264 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Categories_Screen">Documentation on Categories</a>' ) . '</p>'; |
|
265 | - elseif ( 'link_category' == $taxonomy ) |
|
266 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>' ) . '</p>'; |
|
263 | + if ('category' == $taxonomy) |
|
264 | + $help .= '<p>'.__('<a href="https://codex.wordpress.org/Posts_Categories_Screen">Documentation on Categories</a>').'</p>'; |
|
265 | + elseif ('link_category' == $taxonomy) |
|
266 | + $help .= '<p>'.__('<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>').'</p>'; |
|
267 | 267 | else |
268 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Tags_Screen">Documentation on Tags</a>' ) . '</p>'; |
|
268 | + $help .= '<p>'.__('<a href="https://codex.wordpress.org/Posts_Tags_Screen">Documentation on Tags</a>').'</p>'; |
|
269 | 269 | |
270 | - $help .= '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'; |
|
270 | + $help .= '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>'; |
|
271 | 271 | |
272 | - get_current_screen()->set_help_sidebar( $help ); |
|
272 | + get_current_screen()->set_help_sidebar($help); |
|
273 | 273 | |
274 | - unset( $help ); |
|
274 | + unset($help); |
|
275 | 275 | } |
276 | 276 | |
277 | -require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
277 | +require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
278 | 278 | |
279 | 279 | /** Also used by the Edit Tag form */ |
280 | -require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); |
|
280 | +require_once(ABSPATH.'wp-admin/includes/edit-tag-messages.php'); |
|
281 | 281 | |
282 | -$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated'; |
|
282 | +$class = (isset($_REQUEST['error'])) ? 'error' : 'updated'; |
|
283 | 283 | |
284 | -if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) { |
|
285 | - $import_link = admin_url( 'admin.php?import=wpcat2tag' ); |
|
284 | +if (is_plugin_active('wpcat2tag-importer/wpcat2tag-importer.php')) { |
|
285 | + $import_link = admin_url('admin.php?import=wpcat2tag'); |
|
286 | 286 | } else { |
287 | - $import_link = admin_url( 'import.php' ); |
|
287 | + $import_link = admin_url('import.php'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | ?> |
291 | 291 | |
292 | 292 | <div class="wrap nosubsub"> |
293 | -<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
|
293 | +<h1 class="wp-heading-inline"><?php echo esc_html($title); ?></h1> |
|
294 | 294 | |
295 | 295 | <?php |
296 | -if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
|
296 | +if (isset($_REQUEST['s']) && strlen($_REQUEST['s'])) { |
|
297 | 297 | /* translators: %s: search keywords */ |
298 | - printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
|
298 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html(wp_unslash($_REQUEST['s']))); |
|
299 | 299 | } |
300 | 300 | ?> |
301 | 301 | |
302 | 302 | <hr class="wp-header-end"> |
303 | 303 | |
304 | -<?php if ( $message ) : ?> |
|
304 | +<?php if ($message) : ?> |
|
305 | 305 | <div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div> |
306 | -<?php $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] ); |
|
306 | +<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message', 'error'), $_SERVER['REQUEST_URI']); |
|
307 | 307 | endif; ?> |
308 | 308 | <div id="ajax-response"></div> |
309 | 309 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> |
312 | 312 | <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> |
313 | 313 | |
314 | -<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?> |
|
314 | +<?php $wp_list_table->search_box($tax->labels->search_items, 'tag'); ?> |
|
315 | 315 | |
316 | 316 | </form> |
317 | 317 | |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | |
323 | 323 | <?php |
324 | 324 | |
325 | -if ( current_user_can($tax->cap->edit_terms) ) { |
|
326 | - if ( 'category' == $taxonomy ) { |
|
325 | +if (current_user_can($tax->cap->edit_terms)) { |
|
326 | + if ('category' == $taxonomy) { |
|
327 | 327 | /** |
328 | 328 | * Fires before the Add Category form. |
329 | 329 | * |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param object $arg Optional arguments cast to an object. |
334 | 334 | */ |
335 | - do_action( 'add_category_form_pre', (object) array( 'parent' => 0 ) ); |
|
336 | - } elseif ( 'link_category' == $taxonomy ) { |
|
335 | + do_action('add_category_form_pre', (object) array('parent' => 0)); |
|
336 | + } elseif ('link_category' == $taxonomy) { |
|
337 | 337 | /** |
338 | 338 | * Fires before the link category form. |
339 | 339 | * |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param object $arg Optional arguments cast to an object. |
344 | 344 | */ |
345 | - do_action( 'add_link_category_form_pre', (object) array( 'parent' => 0 ) ); |
|
345 | + do_action('add_link_category_form_pre', (object) array('parent' => 0)); |
|
346 | 346 | } else { |
347 | 347 | /** |
348 | 348 | * Fires before the Add Tag form. |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @param string $taxonomy The taxonomy slug. |
354 | 354 | */ |
355 | - do_action( 'add_tag_form_pre', $taxonomy ); |
|
355 | + do_action('add_tag_form_pre', $taxonomy); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @param string $taxonomy The taxonomy slug. |
366 | 366 | */ |
367 | - do_action( "{$taxonomy}_pre_add_form", $taxonomy ); |
|
367 | + do_action("{$taxonomy}_pre_add_form", $taxonomy); |
|
368 | 368 | ?> |
369 | 369 | |
370 | 370 | <div class="form-wrap"> |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @since 3.7.0 |
379 | 379 | */ |
380 | -do_action( "{$taxonomy}_term_new_form_tag" ); |
|
380 | +do_action("{$taxonomy}_term_new_form_tag"); |
|
381 | 381 | ?>> |
382 | 382 | <input type="hidden" name="action" value="add-tag" /> |
383 | 383 | <input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" /> |
@@ -386,20 +386,20 @@ discard block |
||
386 | 386 | <?php wp_nonce_field('add-tag', '_wpnonce_add-tag'); ?> |
387 | 387 | |
388 | 388 | <div class="form-field form-required term-name-wrap"> |
389 | - <label for="tag-name"><?php _ex( 'Name', 'term name' ); ?></label> |
|
389 | + <label for="tag-name"><?php _ex('Name', 'term name'); ?></label> |
|
390 | 390 | <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" /> |
391 | 391 | <p><?php _e('The name is how it appears on your site.'); ?></p> |
392 | 392 | </div> |
393 | -<?php if ( ! global_terms_enabled() ) : ?> |
|
393 | +<?php if ( ! global_terms_enabled()) : ?> |
|
394 | 394 | <div class="form-field term-slug-wrap"> |
395 | - <label for="tag-slug"><?php _e( 'Slug' ); ?></label> |
|
395 | + <label for="tag-slug"><?php _e('Slug'); ?></label> |
|
396 | 396 | <input name="slug" id="tag-slug" type="text" value="" size="40" /> |
397 | 397 | <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p> |
398 | 398 | </div> |
399 | 399 | <?php endif; // global_terms_enabled() ?> |
400 | -<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> |
|
400 | +<?php if (is_taxonomy_hierarchical($taxonomy)) : ?> |
|
401 | 401 | <div class="form-field term-parent-wrap"> |
402 | - <label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label> |
|
402 | + <label for="parent"><?php _ex('Parent', 'term parent'); ?></label> |
|
403 | 403 | <?php |
404 | 404 | $dropdown_args = array( |
405 | 405 | 'hide_empty' => 0, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'name' => 'parent', |
409 | 409 | 'orderby' => 'name', |
410 | 410 | 'hierarchical' => true, |
411 | - 'show_option_none' => __( 'None' ), |
|
411 | + 'show_option_none' => __('None'), |
|
412 | 412 | ); |
413 | 413 | |
414 | 414 | /** |
@@ -432,23 +432,23 @@ discard block |
||
432 | 432 | * @param string $taxonomy The taxonomy slug. |
433 | 433 | * @param string $context Filter context. Accepts 'new' or 'edit'. |
434 | 434 | */ |
435 | - $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' ); |
|
435 | + $dropdown_args = apply_filters('taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new'); |
|
436 | 436 | |
437 | - wp_dropdown_categories( $dropdown_args ); |
|
437 | + wp_dropdown_categories($dropdown_args); |
|
438 | 438 | ?> |
439 | - <?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?> |
|
439 | + <?php if ('category' == $taxonomy) : // @todo: Generic text for hierarchical taxonomies ?> |
|
440 | 440 | <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> |
441 | 441 | <?php endif; ?> |
442 | 442 | </div> |
443 | 443 | <?php endif; // is_taxonomy_hierarchical() ?> |
444 | 444 | <div class="form-field term-description-wrap"> |
445 | - <label for="tag-description"><?php _e( 'Description' ); ?></label> |
|
445 | + <label for="tag-description"><?php _e('Description'); ?></label> |
|
446 | 446 | <textarea name="description" id="tag-description" rows="5" cols="40"></textarea> |
447 | 447 | <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> |
448 | 448 | </div> |
449 | 449 | |
450 | 450 | <?php |
451 | -if ( ! is_taxonomy_hierarchical( $taxonomy ) ) { |
|
451 | +if ( ! is_taxonomy_hierarchical($taxonomy)) { |
|
452 | 452 | /** |
453 | 453 | * Fires after the Add Tag form fields for non-hierarchical taxonomies. |
454 | 454 | * |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @param string $taxonomy The taxonomy slug. |
458 | 458 | */ |
459 | - do_action( 'add_tag_form_fields', $taxonomy ); |
|
459 | + do_action('add_tag_form_fields', $taxonomy); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param string $taxonomy The taxonomy slug. |
470 | 470 | */ |
471 | -do_action( "{$taxonomy}_add_form_fields", $taxonomy ); |
|
471 | +do_action("{$taxonomy}_add_form_fields", $taxonomy); |
|
472 | 472 | |
473 | -submit_button( $tax->labels->add_new_item ); |
|
473 | +submit_button($tax->labels->add_new_item); |
|
474 | 474 | |
475 | -if ( 'category' == $taxonomy ) { |
|
475 | +if ('category' == $taxonomy) { |
|
476 | 476 | /** |
477 | 477 | * Fires at the end of the Edit Category form. |
478 | 478 | * |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @param object $arg Optional arguments cast to an object. |
483 | 483 | */ |
484 | - do_action( 'edit_category_form', (object) array( 'parent' => 0 ) ); |
|
485 | -} elseif ( 'link_category' == $taxonomy ) { |
|
484 | + do_action('edit_category_form', (object) array('parent' => 0)); |
|
485 | +} elseif ('link_category' == $taxonomy) { |
|
486 | 486 | /** |
487 | 487 | * Fires at the end of the Edit Link form. |
488 | 488 | * |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @param object $arg Optional arguments cast to an object. |
493 | 493 | */ |
494 | - do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) ); |
|
494 | + do_action('edit_link_category_form', (object) array('parent' => 0)); |
|
495 | 495 | } else { |
496 | 496 | /** |
497 | 497 | * Fires at the end of the Add Tag form. |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * |
502 | 502 | * @param string $taxonomy The taxonomy slug. |
503 | 503 | */ |
504 | - do_action( 'add_tag_form', $taxonomy ); |
|
504 | + do_action('add_tag_form', $taxonomy); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @param string $taxonomy The taxonomy slug. |
515 | 515 | */ |
516 | -do_action( "{$taxonomy}_add_form", $taxonomy ); |
|
516 | +do_action("{$taxonomy}_add_form", $taxonomy); |
|
517 | 517 | ?> |
518 | 518 | </form></div> |
519 | 519 | <?php } ?> |
@@ -524,33 +524,33 @@ discard block |
||
524 | 524 | <div id="col-right"> |
525 | 525 | <div class="col-wrap"> |
526 | 526 | <form id="posts-filter" method="post"> |
527 | -<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /> |
|
528 | -<input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" /> |
|
527 | +<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> |
|
528 | +<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> |
|
529 | 529 | |
530 | 530 | <?php $wp_list_table->display(); ?> |
531 | 531 | |
532 | 532 | </form> |
533 | 533 | |
534 | -<?php if ( 'category' == $taxonomy ) : ?> |
|
534 | +<?php if ('category' == $taxonomy) : ?> |
|
535 | 535 | <div class="form-wrap edit-term-notes"> |
536 | 536 | <p> |
537 | 537 | <?php |
538 | - echo '<strong>' . __( 'Note:' ) . '</strong><br />'; |
|
538 | + echo '<strong>'.__('Note:').'</strong><br />'; |
|
539 | 539 | printf( |
540 | 540 | /* translators: %s: default category */ |
541 | - __( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ), |
|
541 | + __('Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.'), |
|
542 | 542 | /** This filter is documented in wp-includes/category-template.php */ |
543 | - '<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ) ) . '</strong>' |
|
543 | + '<strong>'.apply_filters('the_category', get_cat_name(get_option('default_category'))).'</strong>' |
|
544 | 544 | ); |
545 | 545 | ?> |
546 | 546 | </p> |
547 | -<?php if ( current_user_can( 'import' ) ) : ?> |
|
548 | -<p><?php printf( __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ), esc_url( $import_link ) ) ?></p> |
|
547 | +<?php if (current_user_can('import')) : ?> |
|
548 | +<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), esc_url($import_link)) ?></p> |
|
549 | 549 | <?php endif; ?> |
550 | 550 | </div> |
551 | -<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?> |
|
551 | +<?php elseif ('post_tag' == $taxonomy && current_user_can('import')) : ?> |
|
552 | 552 | <div class="form-wrap edit-term-notes"> |
553 | -<p><?php printf( __( 'Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.' ), esc_url( $import_link ) ) ;?></p> |
|
553 | +<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.'), esc_url($import_link)); ?></p> |
|
554 | 554 | </div> |
555 | 555 | <?php endif; |
556 | 556 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @param string $taxonomy The taxonomy name. |
565 | 565 | */ |
566 | -do_action( "after-{$taxonomy}-table", $taxonomy ); |
|
566 | +do_action("after-{$taxonomy}-table", $taxonomy); |
|
567 | 567 | ?> |
568 | 568 | |
569 | 569 | </div> |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | </div><!-- /col-container --> |
573 | 573 | </div><!-- /wrap --> |
574 | 574 | |
575 | -<?php if ( ! wp_is_mobile() ) : ?> |
|
575 | +<?php if ( ! wp_is_mobile()) : ?> |
|
576 | 576 | <script type="text/javascript"> |
577 | 577 | try{document.forms.addtag['tag-name'].focus();}catch(e){} |
578 | 578 | </script> |
@@ -581,4 +581,4 @@ discard block |
||
581 | 581 | |
582 | 582 | $wp_list_table->inline_edit(); |
583 | 583 | |
584 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
584 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -9,13 +9,15 @@ discard block |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( ! $taxnow ) |
|
12 | +if ( ! $taxnow ) { |
|
13 | 13 | wp_die( __( 'Invalid taxonomy.' ) ); |
14 | +} |
|
14 | 15 | |
15 | 16 | $tax = get_taxonomy( $taxnow ); |
16 | 17 | |
17 | -if ( ! $tax ) |
|
18 | +if ( ! $tax ) { |
|
18 | 19 | wp_die( __( 'Invalid taxonomy.' ) ); |
20 | +} |
|
19 | 21 | |
20 | 22 | if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) { |
21 | 23 | wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); |
@@ -80,10 +82,11 @@ discard block |
||
80 | 82 | } |
81 | 83 | |
82 | 84 | $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); |
83 | - if ( $ret && !is_wp_error( $ret ) ) |
|
84 | - $location = add_query_arg( 'message', 1, $referer ); |
|
85 | - else |
|
86 | - $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); |
|
85 | + if ( $ret && !is_wp_error( $ret ) ) { |
|
86 | + $location = add_query_arg( 'message', 1, $referer ); |
|
87 | + } else { |
|
88 | + $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer ); |
|
89 | + } |
|
87 | 90 | |
88 | 91 | break; |
89 | 92 | |
@@ -157,8 +160,9 @@ discard block |
||
157 | 160 | } |
158 | 161 | |
159 | 162 | $tag = get_term( $tag_ID, $taxonomy ); |
160 | - if ( ! $tag ) |
|
161 | - wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
163 | + if ( ! $tag ) { |
|
164 | + wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); |
|
165 | + } |
|
162 | 166 | |
163 | 167 | $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); |
164 | 168 | |
@@ -209,22 +213,25 @@ discard block |
||
209 | 213 | } |
210 | 214 | |
211 | 215 | wp_enqueue_script('admin-tags'); |
212 | -if ( current_user_can($tax->cap->edit_terms) ) |
|
216 | +if ( current_user_can($tax->cap->edit_terms) ) { |
|
213 | 217 | wp_enqueue_script('inline-edit-tax'); |
218 | +} |
|
214 | 219 | |
215 | 220 | if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) { |
216 | 221 | $help =''; |
217 | - if ( 'category' == $taxonomy ) |
|
218 | - $help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>'; |
|
219 | - elseif ( 'link_category' == $taxonomy ) |
|
220 | - $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>'; |
|
221 | - else |
|
222 | - $help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '</p>'; |
|
223 | - |
|
224 | - if ( 'link_category' == $taxonomy ) |
|
225 | - $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>'; |
|
226 | - else |
|
227 | - $help .='<p>' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>'; |
|
222 | + if ( 'category' == $taxonomy ) { |
|
223 | + $help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>'; |
|
224 | + } elseif ( 'link_category' == $taxonomy ) { |
|
225 | + $help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>'; |
|
226 | + } else { |
|
227 | + $help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there’s no relationship from one tag to another.' ) . '</p>'; |
|
228 | + } |
|
229 | + |
|
230 | + if ( 'link_category' == $taxonomy ) { |
|
231 | + $help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>'; |
|
232 | + } else { |
|
233 | + $help .='<p>' . __( 'What’s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>'; |
|
234 | + } |
|
228 | 235 | |
229 | 236 | get_current_screen()->add_help_tab( array( |
230 | 237 | 'id' => 'overview', |
@@ -233,19 +240,22 @@ discard block |
||
233 | 240 | ) ); |
234 | 241 | |
235 | 242 | if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) { |
236 | - if ( 'category' == $taxonomy ) |
|
237 | - $help = '<p>' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
238 | - else |
|
239 | - $help = '<p>' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
243 | + if ( 'category' == $taxonomy ) { |
|
244 | + $help = '<p>' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
245 | + } else { |
|
246 | + $help = '<p>' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '</p>'; |
|
247 | + } |
|
240 | 248 | |
241 | 249 | $help .= '<ul>' . |
242 | 250 | '<li>' . __( '<strong>Name</strong> — The name is how it appears on your site.' ) . '</li>'; |
243 | 251 | |
244 | - if ( ! global_terms_enabled() ) |
|
245 | - $help .= '<li>' . __( '<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; |
|
252 | + if ( ! global_terms_enabled() ) { |
|
253 | + $help .= '<li>' . __( '<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; |
|
254 | + } |
|
246 | 255 | |
247 | - if ( 'category' == $taxonomy ) |
|
248 | - $help .= '<li>' . __( '<strong>Parent</strong> — Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>'; |
|
256 | + if ( 'category' == $taxonomy ) { |
|
257 | + $help .= '<li>' . __( '<strong>Parent</strong> — Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>'; |
|
258 | + } |
|
249 | 259 | |
250 | 260 | $help .= '<li>' . __( '<strong>Description</strong> — The description is not prominent by default; however, some themes may display it.' ) . '</li>' . |
251 | 261 | '</ul>' . |
@@ -260,12 +270,13 @@ discard block |
||
260 | 270 | |
261 | 271 | $help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>'; |
262 | 272 | |
263 | - if ( 'category' == $taxonomy ) |
|
264 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Categories_Screen">Documentation on Categories</a>' ) . '</p>'; |
|
265 | - elseif ( 'link_category' == $taxonomy ) |
|
266 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>' ) . '</p>'; |
|
267 | - else |
|
268 | - $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Tags_Screen">Documentation on Tags</a>' ) . '</p>'; |
|
273 | + if ( 'category' == $taxonomy ) { |
|
274 | + $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Categories_Screen">Documentation on Categories</a>' ) . '</p>'; |
|
275 | + } elseif ( 'link_category' == $taxonomy ) { |
|
276 | + $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>' ) . '</p>'; |
|
277 | + } else { |
|
278 | + $help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Tags_Screen">Documentation on Tags</a>' ) . '</p>'; |
|
279 | + } |
|
269 | 280 | |
270 | 281 | $help .= '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'; |
271 | 282 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Used to trigger a success message when settings updated and set to true. |
45 | - * |
|
45 | + * |
|
46 | 46 | * @since 3.0.0 |
47 | 47 | * @access private |
48 | 48 | * @var bool |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $this->admin_header_callback = $admin_header_callback; |
61 | 61 | $this->admin_image_div_callback = $admin_image_div_callback; |
62 | 62 | |
63 | - add_action( 'admin_menu', array( $this, 'init' ) ); |
|
63 | + add_action('admin_menu', array($this, 'init')); |
|
64 | 64 | |
65 | - add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) ); |
|
66 | - add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) ); |
|
67 | - add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) ); |
|
68 | - add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) ); |
|
65 | + add_action('customize_save_after', array($this, 'customize_set_last_used')); |
|
66 | + add_action('wp_ajax_custom-header-crop', array($this, 'ajax_header_crop')); |
|
67 | + add_action('wp_ajax_custom-header-add', array($this, 'ajax_header_add')); |
|
68 | + add_action('wp_ajax_custom-header-remove', array($this, 'ajax_header_remove')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @since 2.1.0 |
75 | 75 | */ |
76 | 76 | public function init() { |
77 | - $page = add_theme_page( __( 'Header' ), __( 'Header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) ); |
|
78 | - if ( ! $page ) { |
|
77 | + $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array($this, 'admin_page')); |
|
78 | + if ( ! $page) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - add_action( "admin_print_scripts-$page", array( $this, 'js_includes' ) ); |
|
83 | - add_action( "admin_print_styles-$page", array( $this, 'css_includes' ) ); |
|
84 | - add_action( "admin_head-$page", array( $this, 'help' ) ); |
|
85 | - add_action( "admin_head-$page", array( $this, 'take_action' ), 50 ); |
|
86 | - add_action( "admin_head-$page", array( $this, 'js' ), 50 ); |
|
87 | - if ( $this->admin_header_callback ) { |
|
88 | - add_action( "admin_head-$page", $this->admin_header_callback, 51 ); |
|
82 | + add_action("admin_print_scripts-$page", array($this, 'js_includes')); |
|
83 | + add_action("admin_print_styles-$page", array($this, 'css_includes')); |
|
84 | + add_action("admin_head-$page", array($this, 'help')); |
|
85 | + add_action("admin_head-$page", array($this, 'take_action'), 50); |
|
86 | + add_action("admin_head-$page", array($this, 'js'), 50); |
|
87 | + if ($this->admin_header_callback) { |
|
88 | + add_action("admin_head-$page", $this->admin_header_callback, 51); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -95,37 +95,37 @@ discard block |
||
95 | 95 | * @since 3.0.0 |
96 | 96 | */ |
97 | 97 | public function help() { |
98 | - get_current_screen()->add_help_tab( array( |
|
98 | + get_current_screen()->add_help_tab(array( |
|
99 | 99 | 'id' => 'overview', |
100 | 100 | 'title' => __('Overview'), |
101 | 101 | 'content' => |
102 | - '<p>' . __( 'This screen is used to customize the header section of your theme.') . '</p>' . |
|
103 | - '<p>' . __( 'You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.') . '<p>' |
|
104 | - ) ); |
|
102 | + '<p>'.__('This screen is used to customize the header section of your theme.').'</p>'. |
|
103 | + '<p>'.__('You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.').'<p>' |
|
104 | + )); |
|
105 | 105 | |
106 | - get_current_screen()->add_help_tab( array( |
|
106 | + get_current_screen()->add_help_tab(array( |
|
107 | 107 | 'id' => 'set-header-image', |
108 | 108 | 'title' => __('Header Image'), |
109 | 109 | 'content' => |
110 | - '<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.' ) . '</p>' . |
|
111 | - '<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” button.' ) . '</p>' . |
|
112 | - '<p>' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.') . '</p>' . |
|
113 | - '<p>' . __( 'If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.') . '</p>' |
|
114 | - ) ); |
|
110 | + '<p>'.__('You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.').'</p>'. |
|
111 | + '<p>'.__('Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” button.').'</p>'. |
|
112 | + '<p>'.__('If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.').'</p>'. |
|
113 | + '<p>'.__('If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.').'</p>' |
|
114 | + )); |
|
115 | 115 | |
116 | - get_current_screen()->add_help_tab( array( |
|
116 | + get_current_screen()->add_help_tab(array( |
|
117 | 117 | 'id' => 'set-header-text', |
118 | 118 | 'title' => __('Header Text'), |
119 | 119 | 'content' => |
120 | - '<p>' . sprintf( __( 'For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%1$s">General Settings</a> section.' ), admin_url( 'options-general.php' ) ) . '<p>' . |
|
121 | - '<p>' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' . |
|
122 | - '<p>' . __( 'Don’t forget to click “Save Changes” when you’re done!') . '</p>' |
|
123 | - ) ); |
|
120 | + '<p>'.sprintf(__('For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%1$s">General Settings</a> section.'), admin_url('options-general.php')).'<p>'. |
|
121 | + '<p>'.__('In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.').'</p>'. |
|
122 | + '<p>'.__('Don’t forget to click “Save Changes” when you’re done!').'</p>' |
|
123 | + )); |
|
124 | 124 | |
125 | 125 | get_current_screen()->set_help_sidebar( |
126 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
127 | - '<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Header_Screen">Documentation on Custom Header</a>' ) . '</p>' . |
|
128 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
|
126 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
127 | + '<p>'.__('<a href="https://codex.wordpress.org/Appearance_Header_Screen">Documentation on Custom Header</a>').'</p>'. |
|
128 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
129 | 129 | ); |
130 | 130 | } |
131 | 131 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | * @return int Current step |
138 | 138 | */ |
139 | 139 | public function step() { |
140 | - if ( ! isset( $_GET['step'] ) ) |
|
140 | + if ( ! isset($_GET['step'])) |
|
141 | 141 | return 1; |
142 | 142 | |
143 | 143 | $step = (int) $_GET['step']; |
144 | - if ( $step < 1 || 3 < $step || |
|
145 | - ( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || |
|
146 | - ( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) |
|
144 | + if ($step < 1 || 3 < $step || |
|
145 | + (2 == $step && ! wp_verify_nonce($_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload')) || |
|
146 | + (3 == $step && ! wp_verify_nonce($_REQUEST['_wpnonce'], 'custom-header-crop-image')) |
|
147 | 147 | ) |
148 | 148 | return 1; |
149 | 149 | |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | public function js_includes() { |
159 | 159 | $step = $this->step(); |
160 | 160 | |
161 | - if ( ( 1 == $step || 3 == $step ) ) { |
|
161 | + if ((1 == $step || 3 == $step)) { |
|
162 | 162 | wp_enqueue_media(); |
163 | - wp_enqueue_script( 'custom-header' ); |
|
164 | - if ( current_theme_supports( 'custom-header', 'header-text' ) ) |
|
165 | - wp_enqueue_script( 'wp-color-picker' ); |
|
166 | - } elseif ( 2 == $step ) { |
|
163 | + wp_enqueue_script('custom-header'); |
|
164 | + if (current_theme_supports('custom-header', 'header-text')) |
|
165 | + wp_enqueue_script('wp-color-picker'); |
|
166 | + } elseif (2 == $step) { |
|
167 | 167 | wp_enqueue_script('imgareaselect'); |
168 | 168 | } |
169 | 169 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | public function css_includes() { |
177 | 177 | $step = $this->step(); |
178 | 178 | |
179 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
180 | - wp_enqueue_style( 'wp-color-picker' ); |
|
181 | - elseif ( 2 == $step ) |
|
179 | + if ((1 == $step || 3 == $step) && current_theme_supports('custom-header', 'header-text')) |
|
180 | + wp_enqueue_style('wp-color-picker'); |
|
181 | + elseif (2 == $step) |
|
182 | 182 | wp_enqueue_style('imgareaselect'); |
183 | 183 | } |
184 | 184 | |
@@ -188,42 +188,42 @@ discard block |
||
188 | 188 | * @since 2.6.0 |
189 | 189 | */ |
190 | 190 | public function take_action() { |
191 | - if ( ! current_user_can('edit_theme_options') ) |
|
191 | + if ( ! current_user_can('edit_theme_options')) |
|
192 | 192 | return; |
193 | 193 | |
194 | - if ( empty( $_POST ) ) |
|
194 | + if (empty($_POST)) |
|
195 | 195 | return; |
196 | 196 | |
197 | 197 | $this->updated = true; |
198 | 198 | |
199 | - if ( isset( $_POST['resetheader'] ) ) { |
|
200 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
199 | + if (isset($_POST['resetheader'])) { |
|
200 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
201 | 201 | $this->reset_header_image(); |
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | - if ( isset( $_POST['removeheader'] ) ) { |
|
206 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
205 | + if (isset($_POST['removeheader'])) { |
|
206 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
207 | 207 | $this->remove_header_image(); |
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) { |
|
212 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
213 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
214 | - } elseif ( isset( $_POST['text-color'] ) ) { |
|
215 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
216 | - $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
|
211 | + if (isset($_POST['text-color']) && ! isset($_POST['display-header-text'])) { |
|
212 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
213 | + set_theme_mod('header_textcolor', 'blank'); |
|
214 | + } elseif (isset($_POST['text-color'])) { |
|
215 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
216 | + $_POST['text-color'] = str_replace('#', '', $_POST['text-color']); |
|
217 | 217 | $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); |
218 | - if ( strlen($color) == 6 || strlen($color) == 3 ) |
|
218 | + if (strlen($color) == 6 || strlen($color) == 3) |
|
219 | 219 | set_theme_mod('header_textcolor', $color); |
220 | - elseif ( ! $color ) |
|
221 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
220 | + elseif ( ! $color) |
|
221 | + set_theme_mod('header_textcolor', 'blank'); |
|
222 | 222 | } |
223 | 223 | |
224 | - if ( isset( $_POST['default-header'] ) ) { |
|
225 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
226 | - $this->set_header_image( $_POST['default-header'] ); |
|
224 | + if (isset($_POST['default-header'])) { |
|
225 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
226 | + $this->set_header_image($_POST['default-header']); |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | } |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | public function process_default_headers() { |
239 | 239 | global $_wp_default_headers; |
240 | 240 | |
241 | - if ( !isset($_wp_default_headers) ) |
|
241 | + if ( ! isset($_wp_default_headers)) |
|
242 | 242 | return; |
243 | 243 | |
244 | - if ( ! empty( $this->default_headers ) ) { |
|
244 | + if ( ! empty($this->default_headers)) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $this->default_headers = $_wp_default_headers; |
249 | 249 | $template_directory_uri = get_template_directory_uri(); |
250 | 250 | $stylesheet_directory_uri = get_stylesheet_directory_uri(); |
251 | - foreach ( array_keys($this->default_headers) as $header ) { |
|
252 | - $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri ); |
|
253 | - $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri ); |
|
251 | + foreach (array_keys($this->default_headers) as $header) { |
|
252 | + $this->default_headers[$header]['url'] = sprintf($this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri); |
|
253 | + $this->default_headers[$header]['thumbnail_url'] = sprintf($this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | * @param string $type The header type. One of 'default' (for the Uploaded Images control) |
266 | 266 | * or 'uploaded' (for the Uploaded Images control). |
267 | 267 | */ |
268 | - public function show_header_selector( $type = 'default' ) { |
|
269 | - if ( 'default' == $type ) { |
|
268 | + public function show_header_selector($type = 'default') { |
|
269 | + if ('default' == $type) { |
|
270 | 270 | $headers = $this->default_headers; |
271 | 271 | } else { |
272 | 272 | $headers = get_uploaded_header_images(); |
273 | 273 | $type = 'uploaded'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( 1 < count( $headers ) ) { |
|
276 | + if (1 < count($headers)) { |
|
277 | 277 | echo '<div class="random-header">'; |
278 | - echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />'; |
|
279 | - _e( '<strong>Random:</strong> Show a different image on each page.' ); |
|
278 | + echo '<label><input name="default-header" type="radio" value="random-'.$type.'-image"'.checked(is_random_header_image($type), true, false).' />'; |
|
279 | + _e('<strong>Random:</strong> Show a different image on each page.'); |
|
280 | 280 | echo '</label>'; |
281 | 281 | echo '</div>'; |
282 | 282 | } |
283 | 283 | |
284 | 284 | echo '<div class="available-headers">'; |
285 | - foreach ( $headers as $header_key => $header ) { |
|
285 | + foreach ($headers as $header_key => $header) { |
|
286 | 286 | $header_thumbnail = $header['thumbnail_url']; |
287 | 287 | $header_url = $header['url']; |
288 | - $header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text']; |
|
288 | + $header_alt_text = empty($header['alt_text']) ? '' : $header['alt_text']; |
|
289 | 289 | echo '<div class="default-header">'; |
290 | - echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />'; |
|
290 | + echo '<label><input name="default-header" type="radio" value="'.esc_attr($header_key).'" '.checked($header_url, get_theme_mod('header_image'), false).' />'; |
|
291 | 291 | $width = ''; |
292 | - if ( !empty( $header['attachment_id'] ) ) |
|
292 | + if ( ! empty($header['attachment_id'])) |
|
293 | 293 | $width = ' width="230"'; |
294 | - echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'"' . $width . ' /></label>'; |
|
294 | + echo '<img src="'.set_url_scheme($header_thumbnail).'" alt="'.esc_attr($header_alt_text).'"'.$width.' /></label>'; |
|
295 | 295 | echo '</div>'; |
296 | 296 | } |
297 | 297 | echo '<div class="clear"></div></div>'; |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function js() { |
306 | 306 | $step = $this->step(); |
307 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
307 | + if ((1 == $step || 3 == $step) && current_theme_supports('custom-header', 'header-text')) |
|
308 | 308 | $this->js_1(); |
309 | - elseif ( 2 == $step ) |
|
309 | + elseif (2 == $step) |
|
310 | 310 | $this->js_2(); |
311 | 311 | } |
312 | 312 | |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function js_1() { |
319 | 319 | $default_color = ''; |
320 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
321 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
322 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
323 | - $default_color = '#' . $default_color; |
|
320 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
321 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
322 | + if ($default_color && false === strpos($default_color, '#')) { |
|
323 | + $default_color = '#'.$default_color; |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | ?> |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | } |
363 | 363 | }); |
364 | 364 | $('#display-header-text').click( toggle_text ); |
365 | - <?php if ( ! display_header_text() ) : ?> |
|
365 | + <?php if ( ! display_header_text()) : ?> |
|
366 | 366 | toggle_text(); |
367 | 367 | <?php endif; ?> |
368 | 368 | }); |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | jQuery(document).ready(function() { |
389 | - var xinit = <?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?>; |
|
390 | - var yinit = <?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?>; |
|
389 | + var xinit = <?php echo absint(get_theme_support('custom-header', 'width')); ?>; |
|
390 | + var yinit = <?php echo absint(get_theme_support('custom-header', 'height')); ?>; |
|
391 | 391 | var ratio = xinit / yinit; |
392 | 392 | var ximg = jQuery('img#upload').width(); |
393 | 393 | var yimg = jQuery('img#upload').height(); |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | x2: xinit, |
412 | 412 | y2: yinit, |
413 | 413 | <?php |
414 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
414 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width')) { |
|
415 | 415 | ?> |
416 | 416 | aspectRatio: xinit + ':' + yinit, |
417 | 417 | <?php |
418 | 418 | } |
419 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
419 | + if ( ! current_theme_supports('custom-header', 'flex-height')) { |
|
420 | 420 | ?> |
421 | - maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>, |
|
421 | + maxHeight: <?php echo get_theme_support('custom-header', 'height'); ?>, |
|
422 | 422 | <?php |
423 | 423 | } |
424 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
424 | + if ( ! current_theme_supports('custom-header', 'flex-width')) { |
|
425 | 425 | ?> |
426 | - maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>, |
|
426 | + maxWidth: <?php echo get_theme_support('custom-header', 'width'); ?>, |
|
427 | 427 | <?php |
428 | 428 | } |
429 | 429 | ?> |
@@ -453,144 +453,144 @@ discard block |
||
453 | 453 | ?> |
454 | 454 | |
455 | 455 | <div class="wrap"> |
456 | -<h1><?php _e( 'Custom Header' ); ?></h1> |
|
456 | +<h1><?php _e('Custom Header'); ?></h1> |
|
457 | 457 | |
458 | -<?php if ( current_user_can( 'customize' ) ) { ?> |
|
458 | +<?php if (current_user_can('customize')) { ?> |
|
459 | 459 | <div class="notice notice-info hide-if-no-customize"> |
460 | 460 | <p> |
461 | 461 | <?php |
462 | 462 | printf( |
463 | - __( 'You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.' ), |
|
464 | - admin_url( 'customize.php?autofocus[control]=header_image' ) |
|
463 | + __('You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.'), |
|
464 | + admin_url('customize.php?autofocus[control]=header_image') |
|
465 | 465 | ); |
466 | 466 | ?> |
467 | 467 | </p> |
468 | 468 | </div> |
469 | 469 | <?php } ?> |
470 | 470 | |
471 | -<?php if ( ! empty( $this->updated ) ) { ?> |
|
471 | +<?php if ( ! empty($this->updated)) { ?> |
|
472 | 472 | <div id="message" class="updated"> |
473 | -<p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p> |
|
473 | +<p><?php printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); ?></p> |
|
474 | 474 | </div> |
475 | 475 | <?php } ?> |
476 | 476 | |
477 | -<h3><?php _e( 'Header Image' ); ?></h3> |
|
477 | +<h3><?php _e('Header Image'); ?></h3> |
|
478 | 478 | |
479 | 479 | <table class="form-table"> |
480 | 480 | <tbody> |
481 | 481 | |
482 | -<?php if ( get_custom_header() || display_header_text() ) : ?> |
|
482 | +<?php if (get_custom_header() || display_header_text()) : ?> |
|
483 | 483 | <tr> |
484 | -<th scope="row"><?php _e( 'Preview' ); ?></th> |
|
484 | +<th scope="row"><?php _e('Preview'); ?></th> |
|
485 | 485 | <td> |
486 | 486 | <?php |
487 | - if ( $this->admin_image_div_callback ) { |
|
488 | - call_user_func( $this->admin_image_div_callback ); |
|
487 | + if ($this->admin_image_div_callback) { |
|
488 | + call_user_func($this->admin_image_div_callback); |
|
489 | 489 | } else { |
490 | 490 | $custom_header = get_custom_header(); |
491 | 491 | $header_image = get_header_image(); |
492 | 492 | |
493 | - if ( $header_image ) { |
|
494 | - $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; |
|
495 | - } else { |
|
493 | + if ($header_image) { |
|
494 | + $header_image_style = 'background-image:url('.esc_url($header_image).');'; |
|
495 | + } else { |
|
496 | 496 | $header_image_style = ''; |
497 | 497 | } |
498 | 498 | |
499 | - if ( $custom_header->width ) |
|
500 | - $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
501 | - if ( $custom_header->height ) |
|
502 | - $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
499 | + if ($custom_header->width) |
|
500 | + $header_image_style .= 'max-width:'.$custom_header->width.'px;'; |
|
501 | + if ($custom_header->height) |
|
502 | + $header_image_style .= 'height:'.$custom_header->height.'px;'; |
|
503 | 503 | ?> |
504 | 504 | <div id="headimg" style="<?php echo $header_image_style; ?>"> |
505 | 505 | <?php |
506 | - if ( display_header_text() ) |
|
507 | - $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
506 | + if (display_header_text()) |
|
507 | + $style = ' style="color:#'.get_header_textcolor().';"'; |
|
508 | 508 | else |
509 | 509 | $style = ' style="display:none;"'; |
510 | 510 | ?> |
511 | - <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
512 | - <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
|
511 | + <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
512 | + <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo('description'); ?></div> |
|
513 | 513 | </div> |
514 | 514 | <?php } ?> |
515 | 515 | </td> |
516 | 516 | </tr> |
517 | 517 | <?php endif; ?> |
518 | 518 | |
519 | -<?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
519 | +<?php if (current_user_can('upload_files') && current_theme_supports('custom-header', 'uploads')) : ?> |
|
520 | 520 | <tr> |
521 | -<th scope="row"><?php _e( 'Select Image' ); ?></th> |
|
521 | +<th scope="row"><?php _e('Select Image'); ?></th> |
|
522 | 522 | <td> |
523 | - <p><?php _e( 'You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.' ); ?><br /> |
|
523 | + <p><?php _e('You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.'); ?><br /> |
|
524 | 524 | <?php |
525 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
526 | - printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); |
|
527 | - } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
528 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
525 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width')) { |
|
526 | + printf(__('Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.').'<br />', get_theme_support('custom-header', 'width'), get_theme_support('custom-header', 'height')); |
|
527 | + } elseif (current_theme_supports('custom-header', 'flex-height')) { |
|
528 | + if ( ! current_theme_supports('custom-header', 'flex-width')) |
|
529 | 529 | printf( |
530 | 530 | /* translators: %s: size in pixels */ |
531 | - __( 'Images should be at least %s wide.' ) . ' ', |
|
531 | + __('Images should be at least %s wide.').' ', |
|
532 | 532 | sprintf( |
533 | 533 | /* translators: %d: custom header width */ |
534 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
535 | - get_theme_support( 'custom-header', 'width' ) |
|
534 | + '<strong>'.__('%d pixels').'</strong>', |
|
535 | + get_theme_support('custom-header', 'width') |
|
536 | 536 | ) |
537 | 537 | ); |
538 | - } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
539 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) |
|
538 | + } elseif (current_theme_supports('custom-header', 'flex-width')) { |
|
539 | + if ( ! current_theme_supports('custom-header', 'flex-height')) |
|
540 | 540 | printf( |
541 | 541 | /* translators: %s: size in pixels */ |
542 | - __( 'Images should be at least %s tall.' ) . ' ', |
|
542 | + __('Images should be at least %s tall.').' ', |
|
543 | 543 | sprintf( |
544 | 544 | /* translators: %d: custom header height */ |
545 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
546 | - get_theme_support( 'custom-header', 'height' ) |
|
545 | + '<strong>'.__('%d pixels').'</strong>', |
|
546 | + get_theme_support('custom-header', 'height') |
|
547 | 547 | ) |
548 | 548 | ); |
549 | 549 | } |
550 | - if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
551 | - if ( current_theme_supports( 'custom-header', 'width' ) ) |
|
550 | + if (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width')) { |
|
551 | + if (current_theme_supports('custom-header', 'width')) |
|
552 | 552 | printf( |
553 | 553 | /* translators: %s: size in pixels */ |
554 | - __( 'Suggested width is %s.' ) . ' ', |
|
554 | + __('Suggested width is %s.').' ', |
|
555 | 555 | sprintf( |
556 | 556 | /* translators: %d: custom header width */ |
557 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
558 | - get_theme_support( 'custom-header', 'width' ) |
|
557 | + '<strong>'.__('%d pixels').'</strong>', |
|
558 | + get_theme_support('custom-header', 'width') |
|
559 | 559 | ) |
560 | 560 | ); |
561 | - if ( current_theme_supports( 'custom-header', 'height' ) ) |
|
561 | + if (current_theme_supports('custom-header', 'height')) |
|
562 | 562 | printf( |
563 | 563 | /* translators: %s: size in pixels */ |
564 | - __( 'Suggested height is %s.' ) . ' ', |
|
564 | + __('Suggested height is %s.').' ', |
|
565 | 565 | sprintf( |
566 | 566 | /* translators: %d: custom header height */ |
567 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
568 | - get_theme_support( 'custom-header', 'height' ) |
|
567 | + '<strong>'.__('%d pixels').'</strong>', |
|
568 | + get_theme_support('custom-header', 'height') |
|
569 | 569 | ) |
570 | 570 | ); |
571 | 571 | } |
572 | 572 | ?></p> |
573 | - <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ) ?>"> |
|
573 | + <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url(add_query_arg('step', 2)) ?>"> |
|
574 | 574 | <p> |
575 | - <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
|
575 | + <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /> |
|
576 | 576 | <input type="file" id="upload" name="import" /> |
577 | 577 | <input type="hidden" name="action" value="save" /> |
578 | - <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?> |
|
579 | - <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?> |
|
578 | + <?php wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload'); ?> |
|
579 | + <?php submit_button(__('Upload'), '', 'submit', false); ?> |
|
580 | 580 | </p> |
581 | 581 | <?php |
582 | - $modal_update_href = esc_url( add_query_arg( array( |
|
582 | + $modal_update_href = esc_url(add_query_arg(array( |
|
583 | 583 | 'page' => 'custom-header', |
584 | 584 | 'step' => 2, |
585 | 585 | '_wpnonce-custom-header-upload' => wp_create_nonce('custom-header-upload'), |
586 | - ), admin_url('themes.php') ) ); |
|
586 | + ), admin_url('themes.php'))); |
|
587 | 587 | ?> |
588 | 588 | <p> |
589 | - <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> |
|
589 | + <label for="choose-from-library-link"><?php _e('Or choose an image from your media library:'); ?></label><br /> |
|
590 | 590 | <button id="choose-from-library-link" class="button" |
591 | - data-update-link="<?php echo esc_attr( $modal_update_href ); ?>" |
|
592 | - data-choose="<?php esc_attr_e( 'Choose a Custom Header' ); ?>" |
|
593 | - data-update="<?php esc_attr_e( 'Set as header' ); ?>"><?php _e( 'Choose Image' ); ?></button> |
|
591 | + data-update-link="<?php echo esc_attr($modal_update_href); ?>" |
|
592 | + data-choose="<?php esc_attr_e('Choose a Custom Header'); ?>" |
|
593 | + data-update="<?php esc_attr_e('Set as header'); ?>"><?php _e('Choose Image'); ?></button> |
|
594 | 594 | </p> |
595 | 595 | </form> |
596 | 596 | </td> |
@@ -599,97 +599,97 @@ discard block |
||
599 | 599 | </tbody> |
600 | 600 | </table> |
601 | 601 | |
602 | -<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ) ?>"> |
|
603 | -<?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?> |
|
602 | +<form method="post" action="<?php echo esc_url(add_query_arg('step', 1)) ?>"> |
|
603 | +<?php submit_button(null, 'screen-reader-text', 'save-header-options', false); ?> |
|
604 | 604 | <table class="form-table"> |
605 | 605 | <tbody> |
606 | - <?php if ( get_uploaded_header_images() ) : ?> |
|
606 | + <?php if (get_uploaded_header_images()) : ?> |
|
607 | 607 | <tr> |
608 | -<th scope="row"><?php _e( 'Uploaded Images' ); ?></th> |
|
608 | +<th scope="row"><?php _e('Uploaded Images'); ?></th> |
|
609 | 609 | <td> |
610 | - <p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ) ?></p> |
|
610 | + <p><?php _e('You can choose one of your previously uploaded headers, or show a random one.') ?></p> |
|
611 | 611 | <?php |
612 | - $this->show_header_selector( 'uploaded' ); |
|
612 | + $this->show_header_selector('uploaded'); |
|
613 | 613 | ?> |
614 | 614 | </td> |
615 | 615 | </tr> |
616 | 616 | <?php endif; |
617 | - if ( ! empty( $this->default_headers ) ) : ?> |
|
617 | + if ( ! empty($this->default_headers)) : ?> |
|
618 | 618 | <tr> |
619 | -<th scope="row"><?php _e( 'Default Images' ); ?></th> |
|
619 | +<th scope="row"><?php _e('Default Images'); ?></th> |
|
620 | 620 | <td> |
621 | -<?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
622 | - <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?></p> |
|
621 | +<?php if (current_theme_supports('custom-header', 'uploads')) : ?> |
|
622 | + <p><?php _e('If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.') ?></p> |
|
623 | 623 | <?php else: ?> |
624 | - <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?></p> |
|
624 | + <p><?php _e('You can use one of these cool headers or show a random one on each page.') ?></p> |
|
625 | 625 | <?php endif; ?> |
626 | 626 | <?php |
627 | - $this->show_header_selector( 'default' ); |
|
627 | + $this->show_header_selector('default'); |
|
628 | 628 | ?> |
629 | 629 | </td> |
630 | 630 | </tr> |
631 | 631 | <?php endif; |
632 | - if ( get_header_image() ) : ?> |
|
632 | + if (get_header_image()) : ?> |
|
633 | 633 | <tr> |
634 | -<th scope="row"><?php _e( 'Remove Image' ); ?></th> |
|
634 | +<th scope="row"><?php _e('Remove Image'); ?></th> |
|
635 | 635 | <td> |
636 | - <p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p> |
|
637 | - <?php submit_button( __( 'Remove Header Image' ), '', 'removeheader', false ); ?> |
|
636 | + <p><?php _e('This will remove the header image. You will not be able to restore any customizations.') ?></p> |
|
637 | + <?php submit_button(__('Remove Header Image'), '', 'removeheader', false); ?> |
|
638 | 638 | </td> |
639 | 639 | </tr> |
640 | 640 | <?php endif; |
641 | 641 | |
642 | - $default_image = sprintf( get_theme_support( 'custom-header', 'default-image' ), get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
643 | - if ( $default_image && get_header_image() != $default_image ) : ?> |
|
642 | + $default_image = sprintf(get_theme_support('custom-header', 'default-image'), get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
643 | + if ($default_image && get_header_image() != $default_image) : ?> |
|
644 | 644 | <tr> |
645 | -<th scope="row"><?php _e( 'Reset Image' ); ?></th> |
|
645 | +<th scope="row"><?php _e('Reset Image'); ?></th> |
|
646 | 646 | <td> |
647 | - <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p> |
|
648 | - <?php submit_button( __( 'Restore Original Header Image' ), '', 'resetheader', false ); ?> |
|
647 | + <p><?php _e('This will restore the original header image. You will not be able to restore any customizations.') ?></p> |
|
648 | + <?php submit_button(__('Restore Original Header Image'), '', 'resetheader', false); ?> |
|
649 | 649 | </td> |
650 | 650 | </tr> |
651 | 651 | <?php endif; ?> |
652 | 652 | </tbody> |
653 | 653 | </table> |
654 | 654 | |
655 | -<?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> |
|
655 | +<?php if (current_theme_supports('custom-header', 'header-text')) : ?> |
|
656 | 656 | |
657 | -<h3><?php _e( 'Header Text' ); ?></h3> |
|
657 | +<h3><?php _e('Header Text'); ?></h3> |
|
658 | 658 | |
659 | 659 | <table class="form-table"> |
660 | 660 | <tbody> |
661 | 661 | <tr> |
662 | -<th scope="row"><?php _e( 'Header Text' ); ?></th> |
|
662 | +<th scope="row"><?php _e('Header Text'); ?></th> |
|
663 | 663 | <td> |
664 | 664 | <p> |
665 | - <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked( display_header_text() ); ?> /> <?php _e( 'Show header text with your image.' ); ?></label> |
|
665 | + <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked(display_header_text()); ?> /> <?php _e('Show header text with your image.'); ?></label> |
|
666 | 666 | </p> |
667 | 667 | </td> |
668 | 668 | </tr> |
669 | 669 | |
670 | 670 | <tr class="displaying-header-text"> |
671 | -<th scope="row"><?php _e( 'Text Color' ); ?></th> |
|
671 | +<th scope="row"><?php _e('Text Color'); ?></th> |
|
672 | 672 | <td> |
673 | 673 | <p> |
674 | 674 | <?php |
675 | 675 | $default_color = ''; |
676 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
677 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
678 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
679 | - $default_color = '#' . $default_color; |
|
676 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
677 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
678 | + if ($default_color && false === strpos($default_color, '#')) { |
|
679 | + $default_color = '#'.$default_color; |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | |
683 | - $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : ''; |
|
683 | + $default_color_attr = $default_color ? ' data-default-color="'.esc_attr($default_color).'"' : ''; |
|
684 | 684 | |
685 | - $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' ); |
|
686 | - if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) { |
|
687 | - $header_textcolor = '#' . $header_textcolor; |
|
685 | + $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support('custom-header', 'default-text-color'); |
|
686 | + if ($header_textcolor && false === strpos($header_textcolor, '#')) { |
|
687 | + $header_textcolor = '#'.$header_textcolor; |
|
688 | 688 | } |
689 | 689 | |
690 | - echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />'; |
|
691 | - if ( $default_color ) { |
|
692 | - echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>'; |
|
690 | + echo '<input type="text" name="text-color" id="text-color" value="'.esc_attr($header_textcolor).'"'.$default_color_attr.' />'; |
|
691 | + if ($default_color) { |
|
692 | + echo ' <span class="description hide-if-js">'.sprintf(_x('Default: %s', 'color'), esc_html($default_color)).'</span>'; |
|
693 | 693 | } |
694 | 694 | ?> |
695 | 695 | </p> |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @since 3.1.0 |
706 | 706 | */ |
707 | -do_action( 'custom_header_options' ); |
|
707 | +do_action('custom_header_options'); |
|
708 | 708 | |
709 | -wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> |
|
709 | +wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options'); ?> |
|
710 | 710 | |
711 | -<?php submit_button( null, 'primary', 'save-header-options' ); ?> |
|
711 | +<?php submit_button(null, 'primary', 'save-header-options'); ?> |
|
712 | 712 | </form> |
713 | 713 | </div> |
714 | 714 | |
@@ -721,53 +721,53 @@ discard block |
||
721 | 721 | */ |
722 | 722 | public function step_2() { |
723 | 723 | check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload'); |
724 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
724 | + if ( ! current_theme_supports('custom-header', 'uploads')) { |
|
725 | 725 | wp_die( |
726 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
727 | - '<p>' . __( 'The current theme does not support uploading a custom header image.' ) . '</p>', |
|
726 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
727 | + '<p>'.__('The current theme does not support uploading a custom header image.').'</p>', |
|
728 | 728 | 403 |
729 | 729 | ); |
730 | 730 | } |
731 | 731 | |
732 | - if ( empty( $_POST ) && isset( $_GET['file'] ) ) { |
|
733 | - $attachment_id = absint( $_GET['file'] ); |
|
734 | - $file = get_attached_file( $attachment_id, true ); |
|
735 | - $url = wp_get_attachment_image_src( $attachment_id, 'full' ); |
|
732 | + if (empty($_POST) && isset($_GET['file'])) { |
|
733 | + $attachment_id = absint($_GET['file']); |
|
734 | + $file = get_attached_file($attachment_id, true); |
|
735 | + $url = wp_get_attachment_image_src($attachment_id, 'full'); |
|
736 | 736 | $url = $url[0]; |
737 | - } elseif ( isset( $_POST ) ) { |
|
737 | + } elseif (isset($_POST)) { |
|
738 | 738 | $data = $this->step_2_manage_upload(); |
739 | 739 | $attachment_id = $data['attachment_id']; |
740 | 740 | $file = $data['file']; |
741 | 741 | $url = $data['url']; |
742 | 742 | } |
743 | 743 | |
744 | - if ( file_exists( $file ) ) { |
|
745 | - list( $width, $height, $type, $attr ) = getimagesize( $file ); |
|
744 | + if (file_exists($file)) { |
|
745 | + list($width, $height, $type, $attr) = getimagesize($file); |
|
746 | 746 | } else { |
747 | - $data = wp_get_attachment_metadata( $attachment_id ); |
|
748 | - $height = isset( $data[ 'height' ] ) ? $data[ 'height' ] : 0; |
|
749 | - $width = isset( $data[ 'width' ] ) ? $data[ 'width' ] : 0; |
|
750 | - unset( $data ); |
|
747 | + $data = wp_get_attachment_metadata($attachment_id); |
|
748 | + $height = isset($data['height']) ? $data['height'] : 0; |
|
749 | + $width = isset($data['width']) ? $data['width'] : 0; |
|
750 | + unset($data); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | $max_width = 0; |
754 | 754 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
755 | - if ( current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
755 | + if (current_theme_supports('custom-header', 'flex-width')) |
|
756 | 756 | $max_width = 1500; |
757 | 757 | |
758 | - if ( current_theme_supports( 'custom-header', 'max-width' ) ) |
|
759 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
760 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); |
|
758 | + if (current_theme_supports('custom-header', 'max-width')) |
|
759 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
760 | + $max_width = max($max_width, get_theme_support('custom-header', 'width')); |
|
761 | 761 | |
762 | 762 | // If flexible height isn't supported and the image is the exact right size |
763 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
764 | - && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) |
|
763 | + if ( ! current_theme_supports('custom-header', 'flex-height') && ! current_theme_supports('custom-header', 'flex-width') |
|
764 | + && $width == get_theme_support('custom-header', 'width') && $height == get_theme_support('custom-header', 'height')) |
|
765 | 765 | { |
766 | 766 | // Add the meta-data |
767 | - if ( file_exists( $file ) ) |
|
768 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
767 | + if (file_exists($file)) |
|
768 | + wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file)); |
|
769 | 769 | |
770 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
770 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
771 | 771 | |
772 | 772 | /** |
773 | 773 | * Fires after the header image is set or an error is returned. |
@@ -777,17 +777,17 @@ discard block |
||
777 | 777 | * @param string $file Path to the file. |
778 | 778 | * @param int $attachment_id Attachment ID. |
779 | 779 | */ |
780 | - do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication |
|
780 | + do_action('wp_create_file_in_uploads', $file, $attachment_id); // For replication |
|
781 | 781 | |
782 | 782 | return $this->finished(); |
783 | - } elseif ( $width > $max_width ) { |
|
783 | + } elseif ($width > $max_width) { |
|
784 | 784 | $oitar = $width / $max_width; |
785 | 785 | $image = wp_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
786 | - if ( ! $image || is_wp_error( $image ) ) |
|
787 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
786 | + if ( ! $image || is_wp_error($image)) |
|
787 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
788 | 788 | |
789 | 789 | /** This filter is documented in wp-admin/custom-header.php */ |
790 | - $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication |
|
790 | + $image = apply_filters('wp_create_file_in_uploads', $image, $attachment_id); // For replication |
|
791 | 791 | |
792 | 792 | $url = str_replace(basename($url), basename($image), $url); |
793 | 793 | $width = $width / $oitar; |
@@ -798,32 +798,32 @@ discard block |
||
798 | 798 | ?> |
799 | 799 | |
800 | 800 | <div class="wrap"> |
801 | -<h1><?php _e( 'Crop Header Image' ); ?></h1> |
|
801 | +<h1><?php _e('Crop Header Image'); ?></h1> |
|
802 | 802 | |
803 | 803 | <form method="post" action="<?php echo esc_url(add_query_arg('step', 3)); ?>"> |
804 | 804 | <p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p> |
805 | - <p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.'); ?></strong></p> |
|
805 | + <p class="hide-if-js"><strong><?php _e('You need JavaScript to choose a part of the image.'); ?></strong></p> |
|
806 | 806 | |
807 | 807 | <div id="crop_image" style="position: relative"> |
808 | - <img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="" /> |
|
808 | + <img src="<?php echo esc_url($url); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="" /> |
|
809 | 809 | </div> |
810 | 810 | |
811 | 811 | <input type="hidden" name="x1" id="x1" value="0"/> |
812 | 812 | <input type="hidden" name="y1" id="y1" value="0"/> |
813 | - <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> |
|
814 | - <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> |
|
815 | - <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $attachment_id ); ?>" /> |
|
816 | - <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
|
817 | - <?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?> |
|
813 | + <input type="hidden" name="width" id="width" value="<?php echo esc_attr($width); ?>"/> |
|
814 | + <input type="hidden" name="height" id="height" value="<?php echo esc_attr($height); ?>"/> |
|
815 | + <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($attachment_id); ?>" /> |
|
816 | + <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr($oitar); ?>" /> |
|
817 | + <?php if (empty($_POST) && isset($_GET['file'])) { ?> |
|
818 | 818 | <input type="hidden" name="create-new-attachment" value="true" /> |
819 | 819 | <?php } ?> |
820 | - <?php wp_nonce_field( 'custom-header-crop-image' ) ?> |
|
820 | + <?php wp_nonce_field('custom-header-crop-image') ?> |
|
821 | 821 | |
822 | 822 | <p class="submit"> |
823 | - <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> |
|
823 | + <?php submit_button(__('Crop and Publish'), 'primary', 'submit', false); ?> |
|
824 | 824 | <?php |
825 | - if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
826 | - submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false ); |
|
825 | + if (isset($oitar) && 1 == $oitar && (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width'))) |
|
826 | + submit_button(__('Skip Cropping, Publish Image as Is'), '', 'skip-cropping', false); |
|
827 | 827 | ?> |
828 | 828 | </p> |
829 | 829 | </form> |
@@ -841,14 +841,14 @@ discard block |
||
841 | 841 | $overrides = array('test_form' => false); |
842 | 842 | |
843 | 843 | $uploaded_file = $_FILES['import']; |
844 | - $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
|
845 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) |
|
846 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
844 | + $wp_filetype = wp_check_filetype_and_ext($uploaded_file['tmp_name'], $uploaded_file['name']); |
|
845 | + if ( ! wp_match_mime_types('image', $wp_filetype['type'])) |
|
846 | + wp_die(__('The uploaded file is not a valid image. Please try again.')); |
|
847 | 847 | |
848 | 848 | $file = wp_handle_upload($uploaded_file, $overrides); |
849 | 849 | |
850 | - if ( isset($file['error']) ) |
|
851 | - wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
850 | + if (isset($file['error'])) |
|
851 | + wp_die($file['error'], __('Image Upload Error')); |
|
852 | 852 | |
853 | 853 | $url = $file['url']; |
854 | 854 | $type = $file['type']; |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | ); |
866 | 866 | |
867 | 867 | // Save the data |
868 | - $attachment_id = wp_insert_attachment( $object, $file ); |
|
869 | - return compact( 'attachment_id', 'file', 'filename', 'url', 'type' ); |
|
868 | + $attachment_id = wp_insert_attachment($object, $file); |
|
869 | + return compact('attachment_id', 'file', 'filename', 'url', 'type'); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -877,73 +877,73 @@ discard block |
||
877 | 877 | * for retrieving the header image URL. |
878 | 878 | */ |
879 | 879 | public function step_3() { |
880 | - check_admin_referer( 'custom-header-crop-image' ); |
|
880 | + check_admin_referer('custom-header-crop-image'); |
|
881 | 881 | |
882 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
882 | + if ( ! current_theme_supports('custom-header', 'uploads')) { |
|
883 | 883 | wp_die( |
884 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
885 | - '<p>' . __( 'The current theme does not support uploading a custom header image.' ) . '</p>', |
|
884 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
885 | + '<p>'.__('The current theme does not support uploading a custom header image.').'</p>', |
|
886 | 886 | 403 |
887 | 887 | ); |
888 | 888 | } |
889 | 889 | |
890 | - if ( ! empty( $_POST['skip-cropping'] ) && ! ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { |
|
890 | + if ( ! empty($_POST['skip-cropping']) && ! (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width'))) { |
|
891 | 891 | wp_die( |
892 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
893 | - '<p>' . __( 'The current theme does not support a flexible sized header image.' ) . '</p>', |
|
892 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
893 | + '<p>'.__('The current theme does not support a flexible sized header image.').'</p>', |
|
894 | 894 | 403 |
895 | 895 | ); |
896 | 896 | } |
897 | 897 | |
898 | - if ( $_POST['oitar'] > 1 ) { |
|
898 | + if ($_POST['oitar'] > 1) { |
|
899 | 899 | $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; |
900 | 900 | $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; |
901 | 901 | $_POST['width'] = $_POST['width'] * $_POST['oitar']; |
902 | 902 | $_POST['height'] = $_POST['height'] * $_POST['oitar']; |
903 | 903 | } |
904 | 904 | |
905 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
905 | + $attachment_id = absint($_POST['attachment_id']); |
|
906 | 906 | $original = get_attached_file($attachment_id); |
907 | 907 | |
908 | - $dimensions = $this->get_header_dimensions( array( |
|
908 | + $dimensions = $this->get_header_dimensions(array( |
|
909 | 909 | 'height' => $_POST['height'], |
910 | 910 | 'width' => $_POST['width'], |
911 | - ) ); |
|
911 | + )); |
|
912 | 912 | $height = $dimensions['dst_height']; |
913 | 913 | $width = $dimensions['dst_width']; |
914 | 914 | |
915 | - if ( empty( $_POST['skip-cropping'] ) ) |
|
916 | - $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
917 | - elseif ( ! empty( $_POST['create-new-attachment'] ) ) |
|
918 | - $cropped = _copy_image_file( $attachment_id ); |
|
915 | + if (empty($_POST['skip-cropping'])) |
|
916 | + $cropped = wp_crop_image($attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height); |
|
917 | + elseif ( ! empty($_POST['create-new-attachment'])) |
|
918 | + $cropped = _copy_image_file($attachment_id); |
|
919 | 919 | else |
920 | - $cropped = get_attached_file( $attachment_id ); |
|
920 | + $cropped = get_attached_file($attachment_id); |
|
921 | 921 | |
922 | - if ( ! $cropped || is_wp_error( $cropped ) ) |
|
923 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
922 | + if ( ! $cropped || is_wp_error($cropped)) |
|
923 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
924 | 924 | |
925 | 925 | /** This filter is documented in wp-admin/custom-header.php */ |
926 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
|
926 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication |
|
927 | 927 | |
928 | - $object = $this->create_attachment_object( $cropped, $attachment_id ); |
|
928 | + $object = $this->create_attachment_object($cropped, $attachment_id); |
|
929 | 929 | |
930 | - if ( ! empty( $_POST['create-new-attachment'] ) ) |
|
931 | - unset( $object['ID'] ); |
|
930 | + if ( ! empty($_POST['create-new-attachment'])) |
|
931 | + unset($object['ID']); |
|
932 | 932 | |
933 | 933 | // Update the attachment |
934 | - $attachment_id = $this->insert_attachment( $object, $cropped ); |
|
934 | + $attachment_id = $this->insert_attachment($object, $cropped); |
|
935 | 935 | |
936 | - $url = wp_get_attachment_url( $attachment_id ); |
|
937 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
936 | + $url = wp_get_attachment_url($attachment_id); |
|
937 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
938 | 938 | |
939 | 939 | // Cleanup. |
940 | - $medium = str_replace( basename( $original ), 'midsize-' . basename( $original ), $original ); |
|
941 | - if ( file_exists( $medium ) ) { |
|
942 | - wp_delete_file( $medium ); |
|
940 | + $medium = str_replace(basename($original), 'midsize-'.basename($original), $original); |
|
941 | + if (file_exists($medium)) { |
|
942 | + wp_delete_file($medium); |
|
943 | 943 | } |
944 | 944 | |
945 | - if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) { |
|
946 | - wp_delete_file( $original ); |
|
945 | + if (empty($_POST['create-new-attachment']) && empty($_POST['skip-cropping'])) { |
|
946 | + wp_delete_file($original); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | return $this->finished(); |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | * @since 2.1.0 |
966 | 966 | */ |
967 | 967 | public function admin_page() { |
968 | - if ( ! current_user_can('edit_theme_options') ) |
|
968 | + if ( ! current_user_can('edit_theme_options')) |
|
969 | 969 | wp_die(__('Sorry, you are not allowed to customize headers.')); |
970 | 970 | $step = $this->step(); |
971 | - if ( 2 == $step ) |
|
971 | + if (2 == $step) |
|
972 | 972 | $this->step_2(); |
973 | - elseif ( 3 == $step ) |
|
973 | + elseif (3 == $step) |
|
974 | 974 | $this->step_3(); |
975 | 975 | else |
976 | 976 | $this->step_1(); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @param array $form_fields |
985 | 985 | * @return array $form_fields |
986 | 986 | */ |
987 | - public function attachment_fields_to_edit( $form_fields ) { |
|
987 | + public function attachment_fields_to_edit($form_fields) { |
|
988 | 988 | return $form_fields; |
989 | 989 | } |
990 | 990 | |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | * @param array $tabs |
997 | 997 | * @return array $tabs |
998 | 998 | */ |
999 | - public function filter_upload_tabs( $tabs ) { |
|
999 | + public function filter_upload_tabs($tabs) { |
|
1000 | 1000 | return $tabs; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1012,13 +1012,13 @@ discard block |
||
1012 | 1012 | * the key of an image uploaded for that theme (the attachment ID of the image). |
1013 | 1013 | * Or an array of arguments: attachment_id, url, width, height. All are required. |
1014 | 1014 | */ |
1015 | - final public function set_header_image( $choice ) { |
|
1016 | - if ( is_array( $choice ) || is_object( $choice ) ) { |
|
1015 | + final public function set_header_image($choice) { |
|
1016 | + if (is_array($choice) || is_object($choice)) { |
|
1017 | 1017 | $choice = (array) $choice; |
1018 | - if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) |
|
1018 | + if ( ! isset($choice['attachment_id']) || ! isset($choice['url'])) |
|
1019 | 1019 | return; |
1020 | 1020 | |
1021 | - $choice['url'] = esc_url_raw( $choice['url'] ); |
|
1021 | + $choice['url'] = esc_url_raw($choice['url']); |
|
1022 | 1022 | |
1023 | 1023 | $header_image_data = (object) array( |
1024 | 1024 | 'attachment_id' => $choice['attachment_id'], |
@@ -1028,32 +1028,32 @@ discard block |
||
1028 | 1028 | 'width' => $choice['width'], |
1029 | 1029 | ); |
1030 | 1030 | |
1031 | - update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1032 | - set_theme_mod( 'header_image', $choice['url'] ); |
|
1033 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
1031 | + update_post_meta($choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1032 | + set_theme_mod('header_image', $choice['url']); |
|
1033 | + set_theme_mod('header_image_data', $header_image_data); |
|
1034 | 1034 | return; |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ) ) ) { |
|
1038 | - set_theme_mod( 'header_image', $choice ); |
|
1039 | - remove_theme_mod( 'header_image_data' ); |
|
1037 | + if (in_array($choice, array('remove-header', 'random-default-image', 'random-uploaded-image'))) { |
|
1038 | + set_theme_mod('header_image', $choice); |
|
1039 | + remove_theme_mod('header_image_data'); |
|
1040 | 1040 | return; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | $uploaded = get_uploaded_header_images(); |
1044 | - if ( $uploaded && isset( $uploaded[ $choice ] ) ) { |
|
1045 | - $header_image_data = $uploaded[ $choice ]; |
|
1044 | + if ($uploaded && isset($uploaded[$choice])) { |
|
1045 | + $header_image_data = $uploaded[$choice]; |
|
1046 | 1046 | |
1047 | 1047 | } else { |
1048 | 1048 | $this->process_default_headers(); |
1049 | - if ( isset( $this->default_headers[ $choice ] ) ) |
|
1050 | - $header_image_data = $this->default_headers[ $choice ]; |
|
1049 | + if (isset($this->default_headers[$choice])) |
|
1050 | + $header_image_data = $this->default_headers[$choice]; |
|
1051 | 1051 | else |
1052 | 1052 | return; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); |
|
1056 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
1055 | + set_theme_mod('header_image', esc_url_raw($header_image_data['url'])); |
|
1056 | + set_theme_mod('header_image_data', $header_image_data); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * @since 3.4.0 |
1063 | 1063 | */ |
1064 | 1064 | final public function remove_header_image() { |
1065 | - $this->set_header_image( 'remove-header' ); |
|
1065 | + $this->set_header_image('remove-header'); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | /** |
@@ -1074,24 +1074,24 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | final public function reset_header_image() { |
1076 | 1076 | $this->process_default_headers(); |
1077 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1077 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1078 | 1078 | |
1079 | - if ( ! $default ) { |
|
1079 | + if ( ! $default) { |
|
1080 | 1080 | $this->remove_header_image(); |
1081 | 1081 | return; |
1082 | 1082 | } |
1083 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1083 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1084 | 1084 | |
1085 | 1085 | $default_data = array(); |
1086 | - foreach ( $this->default_headers as $header => $details ) { |
|
1087 | - if ( $details['url'] == $default ) { |
|
1086 | + foreach ($this->default_headers as $header => $details) { |
|
1087 | + if ($details['url'] == $default) { |
|
1088 | 1088 | $default_data = $details; |
1089 | 1089 | break; |
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
1093 | - set_theme_mod( 'header_image', $default ); |
|
1094 | - set_theme_mod( 'header_image_data', (object) $default_data ); |
|
1093 | + set_theme_mod('header_image', $default); |
|
1094 | + set_theme_mod('header_image_data', (object) $default_data); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1100,41 +1100,41 @@ discard block |
||
1100 | 1100 | * @param array $dimensions |
1101 | 1101 | * @return array dst_height and dst_width of header image. |
1102 | 1102 | */ |
1103 | - final public function get_header_dimensions( $dimensions ) { |
|
1103 | + final public function get_header_dimensions($dimensions) { |
|
1104 | 1104 | $max_width = 0; |
1105 | - $width = absint( $dimensions['width'] ); |
|
1106 | - $height = absint( $dimensions['height'] ); |
|
1107 | - $theme_height = get_theme_support( 'custom-header', 'height' ); |
|
1108 | - $theme_width = get_theme_support( 'custom-header', 'width' ); |
|
1109 | - $has_flex_width = current_theme_supports( 'custom-header', 'flex-width' ); |
|
1110 | - $has_flex_height = current_theme_supports( 'custom-header', 'flex-height' ); |
|
1111 | - $has_max_width = current_theme_supports( 'custom-header', 'max-width' ) ; |
|
1112 | - $dst = array( 'dst_height' => null, 'dst_width' => null ); |
|
1105 | + $width = absint($dimensions['width']); |
|
1106 | + $height = absint($dimensions['height']); |
|
1107 | + $theme_height = get_theme_support('custom-header', 'height'); |
|
1108 | + $theme_width = get_theme_support('custom-header', 'width'); |
|
1109 | + $has_flex_width = current_theme_supports('custom-header', 'flex-width'); |
|
1110 | + $has_flex_height = current_theme_supports('custom-header', 'flex-height'); |
|
1111 | + $has_max_width = current_theme_supports('custom-header', 'max-width'); |
|
1112 | + $dst = array('dst_height' => null, 'dst_width' => null); |
|
1113 | 1113 | |
1114 | 1114 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
1115 | - if ( $has_flex_width ) { |
|
1115 | + if ($has_flex_width) { |
|
1116 | 1116 | $max_width = 1500; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - if ( $has_max_width ) { |
|
1120 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
1119 | + if ($has_max_width) { |
|
1120 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
1121 | 1121 | } |
1122 | - $max_width = max( $max_width, $theme_width ); |
|
1122 | + $max_width = max($max_width, $theme_width); |
|
1123 | 1123 | |
1124 | - if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { |
|
1125 | - $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); |
|
1124 | + if ($has_flex_height && ( ! $has_flex_width || $width > $max_width)) { |
|
1125 | + $dst['dst_height'] = absint($height * ($max_width / $width)); |
|
1126 | 1126 | } |
1127 | - elseif ( $has_flex_height && $has_flex_width ) { |
|
1127 | + elseif ($has_flex_height && $has_flex_width) { |
|
1128 | 1128 | $dst['dst_height'] = $height; |
1129 | 1129 | } |
1130 | 1130 | else { |
1131 | 1131 | $dst['dst_height'] = $theme_height; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | - if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { |
|
1135 | - $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); |
|
1134 | + if ($has_flex_width && ( ! $has_flex_height || $width > $max_width)) { |
|
1135 | + $dst['dst_width'] = absint($width * ($max_width / $width)); |
|
1136 | 1136 | } |
1137 | - elseif ( $has_flex_width && $has_flex_height ) { |
|
1137 | + elseif ($has_flex_width && $has_flex_height) { |
|
1138 | 1138 | $dst['dst_width'] = $width; |
1139 | 1139 | } |
1140 | 1140 | else { |
@@ -1152,13 +1152,13 @@ discard block |
||
1152 | 1152 | * |
1153 | 1153 | * @return array Attachment object. |
1154 | 1154 | */ |
1155 | - final public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
1156 | - $parent = get_post( $parent_attachment_id ); |
|
1157 | - $parent_url = wp_get_attachment_url( $parent->ID ); |
|
1158 | - $url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url ); |
|
1155 | + final public function create_attachment_object($cropped, $parent_attachment_id) { |
|
1156 | + $parent = get_post($parent_attachment_id); |
|
1157 | + $parent_url = wp_get_attachment_url($parent->ID); |
|
1158 | + $url = str_replace(basename($parent_url), basename($cropped), $parent_url); |
|
1159 | 1159 | |
1160 | - $size = @getimagesize( $cropped ); |
|
1161 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
1160 | + $size = @getimagesize($cropped); |
|
1161 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
1162 | 1162 | |
1163 | 1163 | $object = array( |
1164 | 1164 | 'ID' => $parent_attachment_id, |
@@ -1179,9 +1179,9 @@ discard block |
||
1179 | 1179 | * |
1180 | 1180 | * @return int Attachment ID. |
1181 | 1181 | */ |
1182 | - final public function insert_attachment( $object, $cropped ) { |
|
1183 | - $attachment_id = wp_insert_attachment( $object, $cropped ); |
|
1184 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
1182 | + final public function insert_attachment($object, $cropped) { |
|
1183 | + $attachment_id = wp_insert_attachment($object, $cropped); |
|
1184 | + $metadata = wp_generate_attachment_metadata($attachment_id, $cropped); |
|
1185 | 1185 | /** |
1186 | 1186 | * Filters the header image attachment metadata. |
1187 | 1187 | * |
@@ -1191,8 +1191,8 @@ discard block |
||
1191 | 1191 | * |
1192 | 1192 | * @param array $metadata Attachment metadata. |
1193 | 1193 | */ |
1194 | - $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
|
1195 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
1194 | + $metadata = apply_filters('wp_header_image_attachment_metadata', $metadata); |
|
1195 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
1196 | 1196 | return $attachment_id; |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1201,24 +1201,24 @@ discard block |
||
1201 | 1201 | * new object. Returns JSON-encoded object details. |
1202 | 1202 | */ |
1203 | 1203 | public function ajax_header_crop() { |
1204 | - check_ajax_referer( 'image_editor-' . $_POST['id'], 'nonce' ); |
|
1204 | + check_ajax_referer('image_editor-'.$_POST['id'], 'nonce'); |
|
1205 | 1205 | |
1206 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1206 | + if ( ! current_user_can('edit_theme_options')) { |
|
1207 | 1207 | wp_send_json_error(); |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
1210 | + if ( ! current_theme_supports('custom-header', 'uploads')) { |
|
1211 | 1211 | wp_send_json_error(); |
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | $crop_details = $_POST['cropDetails']; |
1215 | 1215 | |
1216 | - $dimensions = $this->get_header_dimensions( array( |
|
1216 | + $dimensions = $this->get_header_dimensions(array( |
|
1217 | 1217 | 'height' => $crop_details['height'], |
1218 | 1218 | 'width' => $crop_details['width'], |
1219 | - ) ); |
|
1219 | + )); |
|
1220 | 1220 | |
1221 | - $attachment_id = absint( $_POST['id'] ); |
|
1221 | + $attachment_id = absint($_POST['id']); |
|
1222 | 1222 | |
1223 | 1223 | $cropped = wp_crop_image( |
1224 | 1224 | $attachment_id, |
@@ -1230,25 +1230,25 @@ discard block |
||
1230 | 1230 | (int) $dimensions['dst_height'] |
1231 | 1231 | ); |
1232 | 1232 | |
1233 | - if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
1234 | - wp_send_json_error( array( 'message' => __( 'Image could not be processed. Please go back and try again.' ) ) ); |
|
1233 | + if ( ! $cropped || is_wp_error($cropped)) { |
|
1234 | + wp_send_json_error(array('message' => __('Image could not be processed. Please go back and try again.'))); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | /** This filter is documented in wp-admin/custom-header.php */ |
1238 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
|
1238 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication |
|
1239 | 1239 | |
1240 | - $object = $this->create_attachment_object( $cropped, $attachment_id ); |
|
1240 | + $object = $this->create_attachment_object($cropped, $attachment_id); |
|
1241 | 1241 | |
1242 | - unset( $object['ID'] ); |
|
1242 | + unset($object['ID']); |
|
1243 | 1243 | |
1244 | - $new_attachment_id = $this->insert_attachment( $object, $cropped ); |
|
1244 | + $new_attachment_id = $this->insert_attachment($object, $cropped); |
|
1245 | 1245 | |
1246 | 1246 | $object['attachment_id'] = $new_attachment_id; |
1247 | - $object['url'] = wp_get_attachment_url( $new_attachment_id );; |
|
1247 | + $object['url'] = wp_get_attachment_url($new_attachment_id); ; |
|
1248 | 1248 | $object['width'] = $dimensions['dst_width']; |
1249 | 1249 | $object['height'] = $dimensions['dst_height']; |
1250 | 1250 | |
1251 | - wp_send_json_success( $object ); |
|
1251 | + wp_send_json_success($object); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** |
@@ -1259,20 +1259,20 @@ discard block |
||
1259 | 1259 | * Media Manager, even if s/he doesn't save that change. |
1260 | 1260 | */ |
1261 | 1261 | public function ajax_header_add() { |
1262 | - check_ajax_referer( 'header-add', 'nonce' ); |
|
1262 | + check_ajax_referer('header-add', 'nonce'); |
|
1263 | 1263 | |
1264 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1264 | + if ( ! current_user_can('edit_theme_options')) { |
|
1265 | 1265 | wp_send_json_error(); |
1266 | 1266 | } |
1267 | 1267 | |
1268 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1269 | - if ( $attachment_id < 1 ) { |
|
1268 | + $attachment_id = absint($_POST['attachment_id']); |
|
1269 | + if ($attachment_id < 1) { |
|
1270 | 1270 | wp_send_json_error(); |
1271 | 1271 | } |
1272 | 1272 | |
1273 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1274 | - update_post_meta( $attachment_id, $key, time() ); |
|
1275 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1273 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1274 | + update_post_meta($attachment_id, $key, time()); |
|
1275 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1276 | 1276 | |
1277 | 1277 | wp_send_json_success(); |
1278 | 1278 | } |
@@ -1285,20 +1285,20 @@ discard block |
||
1285 | 1285 | * choice in the Customizer's Header tool. |
1286 | 1286 | */ |
1287 | 1287 | public function ajax_header_remove() { |
1288 | - check_ajax_referer( 'header-remove', 'nonce' ); |
|
1288 | + check_ajax_referer('header-remove', 'nonce'); |
|
1289 | 1289 | |
1290 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1290 | + if ( ! current_user_can('edit_theme_options')) { |
|
1291 | 1291 | wp_send_json_error(); |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1295 | - if ( $attachment_id < 1 ) { |
|
1294 | + $attachment_id = absint($_POST['attachment_id']); |
|
1295 | + if ($attachment_id < 1) { |
|
1296 | 1296 | wp_send_json_error(); |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1300 | - delete_post_meta( $attachment_id, $key ); |
|
1301 | - delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1299 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1300 | + delete_post_meta($attachment_id, $key); |
|
1301 | + delete_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1302 | 1302 | |
1303 | 1303 | wp_send_json_success(); |
1304 | 1304 | } |
@@ -1307,16 +1307,16 @@ discard block |
||
1307 | 1307 | * |
1308 | 1308 | * @param WP_Customize_Manager $wp_customize |
1309 | 1309 | */ |
1310 | - public function customize_set_last_used( $wp_customize ) { |
|
1311 | - $data = $wp_customize->get_setting( 'header_image_data' )->post_value(); |
|
1310 | + public function customize_set_last_used($wp_customize) { |
|
1311 | + $data = $wp_customize->get_setting('header_image_data')->post_value(); |
|
1312 | 1312 | |
1313 | - if ( ! isset( $data['attachment_id'] ) ) { |
|
1313 | + if ( ! isset($data['attachment_id'])) { |
|
1314 | 1314 | return; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | $attachment_id = $data['attachment_id']; |
1318 | - $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1319 | - update_post_meta( $attachment_id, $key, time() ); |
|
1318 | + $key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1319 | + update_post_meta($attachment_id, $key, time()); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | /** |
@@ -1327,23 +1327,23 @@ discard block |
||
1327 | 1327 | $this->process_default_headers(); |
1328 | 1328 | |
1329 | 1329 | // Get the default image if there is one. |
1330 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1330 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1331 | 1331 | |
1332 | - if ( ! $default ) { // If not, |
|
1332 | + if ( ! $default) { // If not, |
|
1333 | 1333 | return $this->default_headers; // easy peasy. |
1334 | 1334 | } |
1335 | 1335 | |
1336 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1336 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1337 | 1337 | $already_has_default = false; |
1338 | 1338 | |
1339 | - foreach ( $this->default_headers as $k => $h ) { |
|
1340 | - if ( $h['url'] === $default ) { |
|
1339 | + foreach ($this->default_headers as $k => $h) { |
|
1340 | + if ($h['url'] === $default) { |
|
1341 | 1341 | $already_has_default = true; |
1342 | 1342 | break; |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - if ( $already_has_default ) { |
|
1346 | + if ($already_has_default) { |
|
1347 | 1347 | return $this->default_headers; |
1348 | 1348 | } |
1349 | 1349 | |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | ); |
1357 | 1357 | |
1358 | 1358 | // The rest of the set comes after. |
1359 | - return array_merge( $header_images, $this->default_headers ); |
|
1359 | + return array_merge($header_images, $this->default_headers); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | */ |
1366 | 1366 | public function get_uploaded_header_images() { |
1367 | 1367 | $header_images = get_uploaded_header_images(); |
1368 | - $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1368 | + $timestamp_key = '_wp_attachment_custom_header_last_used_'.get_stylesheet(); |
|
1369 | 1369 | $alt_text_key = '_wp_attachment_image_alt'; |
1370 | 1370 | |
1371 | - foreach ( $header_images as &$header_image ) { |
|
1372 | - $header_meta = get_post_meta( $header_image['attachment_id'] ); |
|
1373 | - $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; |
|
1374 | - $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; |
|
1371 | + foreach ($header_images as &$header_image) { |
|
1372 | + $header_meta = get_post_meta($header_image['attachment_id']); |
|
1373 | + $header_image['timestamp'] = isset($header_meta[$timestamp_key]) ? $header_meta[$timestamp_key] : ''; |
|
1374 | + $header_image['alt_text'] = isset($header_meta[$alt_text_key]) ? $header_meta[$alt_text_key] : ''; |
|
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | return $header_images; |
@@ -137,15 +137,17 @@ discard block |
||
137 | 137 | * @return int Current step |
138 | 138 | */ |
139 | 139 | public function step() { |
140 | - if ( ! isset( $_GET['step'] ) ) |
|
141 | - return 1; |
|
140 | + if ( ! isset( $_GET['step'] ) ) { |
|
141 | + return 1; |
|
142 | + } |
|
142 | 143 | |
143 | 144 | $step = (int) $_GET['step']; |
144 | 145 | if ( $step < 1 || 3 < $step || |
145 | 146 | ( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || |
146 | 147 | ( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) |
147 | - ) |
|
148 | - return 1; |
|
148 | + ) { |
|
149 | + return 1; |
|
150 | + } |
|
149 | 151 | |
150 | 152 | return $step; |
151 | 153 | } |
@@ -161,8 +163,9 @@ discard block |
||
161 | 163 | if ( ( 1 == $step || 3 == $step ) ) { |
162 | 164 | wp_enqueue_media(); |
163 | 165 | wp_enqueue_script( 'custom-header' ); |
164 | - if ( current_theme_supports( 'custom-header', 'header-text' ) ) |
|
165 | - wp_enqueue_script( 'wp-color-picker' ); |
|
166 | + if ( current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
167 | + wp_enqueue_script( 'wp-color-picker' ); |
|
168 | + } |
|
166 | 169 | } elseif ( 2 == $step ) { |
167 | 170 | wp_enqueue_script('imgareaselect'); |
168 | 171 | } |
@@ -176,10 +179,11 @@ discard block |
||
176 | 179 | public function css_includes() { |
177 | 180 | $step = $this->step(); |
178 | 181 | |
179 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
180 | - wp_enqueue_style( 'wp-color-picker' ); |
|
181 | - elseif ( 2 == $step ) |
|
182 | - wp_enqueue_style('imgareaselect'); |
|
182 | + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
183 | + wp_enqueue_style( 'wp-color-picker' ); |
|
184 | + } elseif ( 2 == $step ) { |
|
185 | + wp_enqueue_style('imgareaselect'); |
|
186 | + } |
|
183 | 187 | } |
184 | 188 | |
185 | 189 | /** |
@@ -188,11 +192,13 @@ discard block |
||
188 | 192 | * @since 2.6.0 |
189 | 193 | */ |
190 | 194 | public function take_action() { |
191 | - if ( ! current_user_can('edit_theme_options') ) |
|
192 | - return; |
|
195 | + if ( ! current_user_can('edit_theme_options') ) { |
|
196 | + return; |
|
197 | + } |
|
193 | 198 | |
194 | - if ( empty( $_POST ) ) |
|
195 | - return; |
|
199 | + if ( empty( $_POST ) ) { |
|
200 | + return; |
|
201 | + } |
|
196 | 202 | |
197 | 203 | $this->updated = true; |
198 | 204 | |
@@ -215,10 +221,11 @@ discard block |
||
215 | 221 | check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
216 | 222 | $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
217 | 223 | $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); |
218 | - if ( strlen($color) == 6 || strlen($color) == 3 ) |
|
219 | - set_theme_mod('header_textcolor', $color); |
|
220 | - elseif ( ! $color ) |
|
221 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
224 | + if ( strlen($color) == 6 || strlen($color) == 3 ) { |
|
225 | + set_theme_mod('header_textcolor', $color); |
|
226 | + } elseif ( ! $color ) { |
|
227 | + set_theme_mod( 'header_textcolor', 'blank' ); |
|
228 | + } |
|
222 | 229 | } |
223 | 230 | |
224 | 231 | if ( isset( $_POST['default-header'] ) ) { |
@@ -238,8 +245,9 @@ discard block |
||
238 | 245 | public function process_default_headers() { |
239 | 246 | global $_wp_default_headers; |
240 | 247 | |
241 | - if ( !isset($_wp_default_headers) ) |
|
242 | - return; |
|
248 | + if ( !isset($_wp_default_headers) ) { |
|
249 | + return; |
|
250 | + } |
|
243 | 251 | |
244 | 252 | if ( ! empty( $this->default_headers ) ) { |
245 | 253 | return; |
@@ -289,8 +297,9 @@ discard block |
||
289 | 297 | echo '<div class="default-header">'; |
290 | 298 | echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />'; |
291 | 299 | $width = ''; |
292 | - if ( !empty( $header['attachment_id'] ) ) |
|
293 | - $width = ' width="230"'; |
|
300 | + if ( !empty( $header['attachment_id'] ) ) { |
|
301 | + $width = ' width="230"'; |
|
302 | + } |
|
294 | 303 | echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'"' . $width . ' /></label>'; |
295 | 304 | echo '</div>'; |
296 | 305 | } |
@@ -304,10 +313,11 @@ discard block |
||
304 | 313 | */ |
305 | 314 | public function js() { |
306 | 315 | $step = $this->step(); |
307 | - if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) |
|
308 | - $this->js_1(); |
|
309 | - elseif ( 2 == $step ) |
|
310 | - $this->js_2(); |
|
316 | + if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
317 | + $this->js_1(); |
|
318 | + } elseif ( 2 == $step ) { |
|
319 | + $this->js_2(); |
|
320 | + } |
|
311 | 321 | } |
312 | 322 | |
313 | 323 | /** |
@@ -492,21 +502,24 @@ discard block |
||
492 | 502 | |
493 | 503 | if ( $header_image ) { |
494 | 504 | $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; |
495 | - } else { |
|
505 | + } else { |
|
496 | 506 | $header_image_style = ''; |
497 | 507 | } |
498 | 508 | |
499 | - if ( $custom_header->width ) |
|
500 | - $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
501 | - if ( $custom_header->height ) |
|
502 | - $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
509 | + if ( $custom_header->width ) { |
|
510 | + $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
|
511 | + } |
|
512 | + if ( $custom_header->height ) { |
|
513 | + $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
|
514 | + } |
|
503 | 515 | ?> |
504 | 516 | <div id="headimg" style="<?php echo $header_image_style; ?>"> |
505 | 517 | <?php |
506 | - if ( display_header_text() ) |
|
507 | - $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
508 | - else |
|
509 | - $style = ' style="display:none;"'; |
|
518 | + if ( display_header_text() ) { |
|
519 | + $style = ' style="color:#' . get_header_textcolor() . ';"'; |
|
520 | + } else { |
|
521 | + $style = ' style="display:none;"'; |
|
522 | + } |
|
510 | 523 | ?> |
511 | 524 | <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
512 | 525 | <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
@@ -525,8 +538,8 @@ discard block |
||
525 | 538 | if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
526 | 539 | printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) ); |
527 | 540 | } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { |
528 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
529 | - printf( |
|
541 | + if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
542 | + printf( |
|
530 | 543 | /* translators: %s: size in pixels */ |
531 | 544 | __( 'Images should be at least %s wide.' ) . ' ', |
532 | 545 | sprintf( |
@@ -535,9 +548,10 @@ discard block |
||
535 | 548 | get_theme_support( 'custom-header', 'width' ) |
536 | 549 | ) |
537 | 550 | ); |
551 | + } |
|
538 | 552 | } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
539 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) |
|
540 | - printf( |
|
553 | + if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
554 | + printf( |
|
541 | 555 | /* translators: %s: size in pixels */ |
542 | 556 | __( 'Images should be at least %s tall.' ) . ' ', |
543 | 557 | sprintf( |
@@ -546,10 +560,11 @@ discard block |
||
546 | 560 | get_theme_support( 'custom-header', 'height' ) |
547 | 561 | ) |
548 | 562 | ); |
563 | + } |
|
549 | 564 | } |
550 | 565 | if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) { |
551 | - if ( current_theme_supports( 'custom-header', 'width' ) ) |
|
552 | - printf( |
|
566 | + if ( current_theme_supports( 'custom-header', 'width' ) ) { |
|
567 | + printf( |
|
553 | 568 | /* translators: %s: size in pixels */ |
554 | 569 | __( 'Suggested width is %s.' ) . ' ', |
555 | 570 | sprintf( |
@@ -558,8 +573,9 @@ discard block |
||
558 | 573 | get_theme_support( 'custom-header', 'width' ) |
559 | 574 | ) |
560 | 575 | ); |
561 | - if ( current_theme_supports( 'custom-header', 'height' ) ) |
|
562 | - printf( |
|
576 | + } |
|
577 | + if ( current_theme_supports( 'custom-header', 'height' ) ) { |
|
578 | + printf( |
|
563 | 579 | /* translators: %s: size in pixels */ |
564 | 580 | __( 'Suggested height is %s.' ) . ' ', |
565 | 581 | sprintf( |
@@ -568,6 +584,7 @@ discard block |
||
568 | 584 | get_theme_support( 'custom-header', 'height' ) |
569 | 585 | ) |
570 | 586 | ); |
587 | + } |
|
571 | 588 | } |
572 | 589 | ?></p> |
573 | 590 | <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ) ?>"> |
@@ -620,9 +637,12 @@ discard block |
||
620 | 637 | <td> |
621 | 638 | <?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
622 | 639 | <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?></p> |
623 | -<?php else: ?> |
|
640 | +<?php else { |
|
641 | + : ?> |
|
624 | 642 | <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?></p> |
625 | -<?php endif; ?> |
|
643 | +<?php endif; |
|
644 | +} |
|
645 | +?> |
|
626 | 646 | <?php |
627 | 647 | $this->show_header_selector( 'default' ); |
628 | 648 | ?> |
@@ -752,11 +772,13 @@ discard block |
||
752 | 772 | |
753 | 773 | $max_width = 0; |
754 | 774 | // For flex, limit size of image displayed to 1500px unless theme says otherwise |
755 | - if ( current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
756 | - $max_width = 1500; |
|
775 | + if ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
776 | + $max_width = 1500; |
|
777 | + } |
|
757 | 778 | |
758 | - if ( current_theme_supports( 'custom-header', 'max-width' ) ) |
|
759 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
779 | + if ( current_theme_supports( 'custom-header', 'max-width' ) ) { |
|
780 | + $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
781 | + } |
|
760 | 782 | $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); |
761 | 783 | |
762 | 784 | // If flexible height isn't supported and the image is the exact right size |
@@ -764,8 +786,9 @@ discard block |
||
764 | 786 | && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) |
765 | 787 | { |
766 | 788 | // Add the meta-data |
767 | - if ( file_exists( $file ) ) |
|
768 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
789 | + if ( file_exists( $file ) ) { |
|
790 | + wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
791 | + } |
|
769 | 792 | |
770 | 793 | $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
771 | 794 | |
@@ -783,8 +806,9 @@ discard block |
||
783 | 806 | } elseif ( $width > $max_width ) { |
784 | 807 | $oitar = $width / $max_width; |
785 | 808 | $image = wp_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file)); |
786 | - if ( ! $image || is_wp_error( $image ) ) |
|
787 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
809 | + if ( ! $image || is_wp_error( $image ) ) { |
|
810 | + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
811 | + } |
|
788 | 812 | |
789 | 813 | /** This filter is documented in wp-admin/custom-header.php */ |
790 | 814 | $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication |
@@ -822,8 +846,9 @@ discard block |
||
822 | 846 | <p class="submit"> |
823 | 847 | <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> |
824 | 848 | <?php |
825 | - if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) |
|
826 | - submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false ); |
|
849 | + if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) { |
|
850 | + submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false ); |
|
851 | + } |
|
827 | 852 | ?> |
828 | 853 | </p> |
829 | 854 | </form> |
@@ -842,13 +867,15 @@ discard block |
||
842 | 867 | |
843 | 868 | $uploaded_file = $_FILES['import']; |
844 | 869 | $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
845 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) |
|
846 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
870 | + if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { |
|
871 | + wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
872 | + } |
|
847 | 873 | |
848 | 874 | $file = wp_handle_upload($uploaded_file, $overrides); |
849 | 875 | |
850 | - if ( isset($file['error']) ) |
|
851 | - wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
876 | + if ( isset($file['error']) ) { |
|
877 | + wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
878 | + } |
|
852 | 879 | |
853 | 880 | $url = $file['url']; |
854 | 881 | $type = $file['type']; |
@@ -912,23 +939,26 @@ discard block |
||
912 | 939 | $height = $dimensions['dst_height']; |
913 | 940 | $width = $dimensions['dst_width']; |
914 | 941 | |
915 | - if ( empty( $_POST['skip-cropping'] ) ) |
|
916 | - $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
917 | - elseif ( ! empty( $_POST['create-new-attachment'] ) ) |
|
918 | - $cropped = _copy_image_file( $attachment_id ); |
|
919 | - else |
|
920 | - $cropped = get_attached_file( $attachment_id ); |
|
942 | + if ( empty( $_POST['skip-cropping'] ) ) { |
|
943 | + $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height ); |
|
944 | + } elseif ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
945 | + $cropped = _copy_image_file( $attachment_id ); |
|
946 | + } else { |
|
947 | + $cropped = get_attached_file( $attachment_id ); |
|
948 | + } |
|
921 | 949 | |
922 | - if ( ! $cropped || is_wp_error( $cropped ) ) |
|
923 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
950 | + if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
951 | + wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
952 | + } |
|
924 | 953 | |
925 | 954 | /** This filter is documented in wp-admin/custom-header.php */ |
926 | 955 | $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication |
927 | 956 | |
928 | 957 | $object = $this->create_attachment_object( $cropped, $attachment_id ); |
929 | 958 | |
930 | - if ( ! empty( $_POST['create-new-attachment'] ) ) |
|
931 | - unset( $object['ID'] ); |
|
959 | + if ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
960 | + unset( $object['ID'] ); |
|
961 | + } |
|
932 | 962 | |
933 | 963 | // Update the attachment |
934 | 964 | $attachment_id = $this->insert_attachment( $object, $cropped ); |
@@ -965,15 +995,17 @@ discard block |
||
965 | 995 | * @since 2.1.0 |
966 | 996 | */ |
967 | 997 | public function admin_page() { |
968 | - if ( ! current_user_can('edit_theme_options') ) |
|
969 | - wp_die(__('Sorry, you are not allowed to customize headers.')); |
|
998 | + if ( ! current_user_can('edit_theme_options') ) { |
|
999 | + wp_die(__('Sorry, you are not allowed to customize headers.')); |
|
1000 | + } |
|
970 | 1001 | $step = $this->step(); |
971 | - if ( 2 == $step ) |
|
972 | - $this->step_2(); |
|
973 | - elseif ( 3 == $step ) |
|
974 | - $this->step_3(); |
|
975 | - else |
|
976 | - $this->step_1(); |
|
1002 | + if ( 2 == $step ) { |
|
1003 | + $this->step_2(); |
|
1004 | + } elseif ( 3 == $step ) { |
|
1005 | + $this->step_3(); |
|
1006 | + } else { |
|
1007 | + $this->step_1(); |
|
1008 | + } |
|
977 | 1009 | } |
978 | 1010 | |
979 | 1011 | /** |
@@ -1015,8 +1047,9 @@ discard block |
||
1015 | 1047 | final public function set_header_image( $choice ) { |
1016 | 1048 | if ( is_array( $choice ) || is_object( $choice ) ) { |
1017 | 1049 | $choice = (array) $choice; |
1018 | - if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) |
|
1019 | - return; |
|
1050 | + if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) { |
|
1051 | + return; |
|
1052 | + } |
|
1020 | 1053 | |
1021 | 1054 | $choice['url'] = esc_url_raw( $choice['url'] ); |
1022 | 1055 | |
@@ -1046,10 +1079,11 @@ discard block |
||
1046 | 1079 | |
1047 | 1080 | } else { |
1048 | 1081 | $this->process_default_headers(); |
1049 | - if ( isset( $this->default_headers[ $choice ] ) ) |
|
1050 | - $header_image_data = $this->default_headers[ $choice ]; |
|
1051 | - else |
|
1052 | - return; |
|
1082 | + if ( isset( $this->default_headers[ $choice ] ) ) { |
|
1083 | + $header_image_data = $this->default_headers[ $choice ]; |
|
1084 | + } else { |
|
1085 | + return; |
|
1086 | + } |
|
1053 | 1087 | } |
1054 | 1088 | |
1055 | 1089 | set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); |
@@ -1123,21 +1157,17 @@ discard block |
||
1123 | 1157 | |
1124 | 1158 | if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { |
1125 | 1159 | $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); |
1126 | - } |
|
1127 | - elseif ( $has_flex_height && $has_flex_width ) { |
|
1160 | + } elseif ( $has_flex_height && $has_flex_width ) { |
|
1128 | 1161 | $dst['dst_height'] = $height; |
1129 | - } |
|
1130 | - else { |
|
1162 | + } else { |
|
1131 | 1163 | $dst['dst_height'] = $theme_height; |
1132 | 1164 | } |
1133 | 1165 | |
1134 | 1166 | if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { |
1135 | 1167 | $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); |
1136 | - } |
|
1137 | - elseif ( $has_flex_width && $has_flex_height ) { |
|
1168 | + } elseif ( $has_flex_width && $has_flex_height ) { |
|
1138 | 1169 | $dst['dst_width'] = $width; |
1139 | - } |
|
1140 | - else { |
|
1170 | + } else { |
|
1141 | 1171 | $dst['dst_width'] = $theme_width; |
1142 | 1172 | } |
1143 | 1173 |