@@ -8,5 +8,5 @@ |
||
8 | 8 | * @subpackage Administration |
9 | 9 | */ |
10 | 10 | |
11 | -_deprecated_file( basename(__FILE__), '2.5.0', 'wp-admin/includes/upgrade.php' ); |
|
12 | -require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
11 | +_deprecated_file(basename(__FILE__), '2.5.0', 'wp-admin/includes/upgrade.php'); |
|
12 | +require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function register_importer( $id, $name, $description, $callback ) { |
55 | 55 | global $wp_importers; |
56 | - if ( is_wp_error( $callback ) ) |
|
57 | - return $callback; |
|
56 | + if ( is_wp_error( $callback ) ) { |
|
57 | + return $callback; |
|
58 | + } |
|
58 | 59 | $wp_importers[$id] = array ( $name, $description, $callback ); |
59 | 60 | } |
60 | 61 | |
@@ -147,13 +148,15 @@ discard block |
||
147 | 148 | |
148 | 149 | if ( is_array( $popular_importers ) ) { |
149 | 150 | // If the data was received as translated, return it as-is. |
150 | - if ( $popular_importers['translated'] ) |
|
151 | - return $popular_importers['importers']; |
|
151 | + if ( $popular_importers['translated'] ) { |
|
152 | + return $popular_importers['importers']; |
|
153 | + } |
|
152 | 154 | |
153 | 155 | foreach ( $popular_importers['importers'] as &$importer ) { |
154 | 156 | $importer['description'] = translate( $importer['description'] ); |
155 | - if ( $importer['name'] != 'WordPress' ) |
|
156 | - $importer['name'] = translate( $importer['name'] ); |
|
157 | + if ( $importer['name'] != 'WordPress' ) { |
|
158 | + $importer['name'] = translate( $importer['name'] ); |
|
159 | + } |
|
157 | 160 | } |
158 | 161 | return $popular_importers['importers']; |
159 | 162 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function get_importers() { |
18 | 18 | global $wp_importers; |
19 | - if ( is_array( $wp_importers ) ) { |
|
20 | - uasort( $wp_importers, '_usort_by_first_member' ); |
|
19 | + if (is_array($wp_importers)) { |
|
20 | + uasort($wp_importers, '_usort_by_first_member'); |
|
21 | 21 | } |
22 | 22 | return $wp_importers; |
23 | 23 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param array $b |
35 | 35 | * @return int |
36 | 36 | */ |
37 | -function _usort_by_first_member( $a, $b ) { |
|
38 | - return strnatcasecmp( $a[0], $b[0] ); |
|
37 | +function _usort_by_first_member($a, $b) { |
|
38 | + return strnatcasecmp($a[0], $b[0]); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @param callable $callback Callback to run. |
52 | 52 | * @return WP_Error Returns WP_Error when $callback is WP_Error. |
53 | 53 | */ |
54 | -function register_importer( $id, $name, $description, $callback ) { |
|
54 | +function register_importer($id, $name, $description, $callback) { |
|
55 | 55 | global $wp_importers; |
56 | - if ( is_wp_error( $callback ) ) |
|
56 | + if (is_wp_error($callback)) |
|
57 | 57 | return $callback; |
58 | - $wp_importers[$id] = array ( $name, $description, $callback ); |
|
58 | + $wp_importers[$id] = array($name, $description, $callback); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param string $id Importer ID. |
69 | 69 | */ |
70 | -function wp_import_cleanup( $id ) { |
|
71 | - wp_delete_attachment( $id ); |
|
70 | +function wp_import_cleanup($id) { |
|
71 | + wp_delete_attachment($id); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | * @return array Uploaded file's details on success, error message on failure |
80 | 80 | */ |
81 | 81 | function wp_import_handle_upload() { |
82 | - if ( ! isset( $_FILES['import'] ) ) { |
|
82 | + if ( ! isset($_FILES['import'])) { |
|
83 | 83 | return array( |
84 | - 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) |
|
84 | + 'error' => __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.') |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - $overrides = array( 'test_form' => false, 'test_type' => false ); |
|
88 | + $overrides = array('test_form' => false, 'test_type' => false); |
|
89 | 89 | $_FILES['import']['name'] .= '.txt'; |
90 | - $upload = wp_handle_upload( $_FILES['import'], $overrides ); |
|
90 | + $upload = wp_handle_upload($_FILES['import'], $overrides); |
|
91 | 91 | |
92 | - if ( isset( $upload['error'] ) ) { |
|
92 | + if (isset($upload['error'])) { |
|
93 | 93 | return $upload; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Construct the object array |
97 | 97 | $object = array( |
98 | - 'post_title' => basename( $upload['file'] ), |
|
98 | + 'post_title' => basename($upload['file']), |
|
99 | 99 | 'post_content' => $upload['url'], |
100 | 100 | 'post_mime_type' => $upload['type'], |
101 | 101 | 'guid' => $upload['url'], |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | ); |
105 | 105 | |
106 | 106 | // Save the data |
107 | - $id = wp_insert_attachment( $object, $upload['file'] ); |
|
107 | + $id = wp_insert_attachment($object, $upload['file']); |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | * Schedule a cleanup for one day from now in case of failed |
111 | 111 | * import or missing wp_import_cleanup() call. |
112 | 112 | */ |
113 | - wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); |
|
113 | + wp_schedule_single_event(time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array($id)); |
|
114 | 114 | |
115 | - return array( 'file' => $upload['file'], 'id' => $id ); |
|
115 | + return array('file' => $upload['file'], 'id' => $id); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,37 +123,37 @@ discard block |
||
123 | 123 | * @return array Importers with metadata for each. |
124 | 124 | */ |
125 | 125 | function wp_get_popular_importers() { |
126 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
126 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
127 | 127 | |
128 | 128 | $locale = get_user_locale(); |
129 | - $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); |
|
130 | - $popular_importers = get_site_transient( $cache_key ); |
|
129 | + $cache_key = 'popular_importers_'.md5($locale.$wp_version); |
|
130 | + $popular_importers = get_site_transient($cache_key); |
|
131 | 131 | |
132 | - if ( ! $popular_importers ) { |
|
133 | - $url = add_query_arg( array( |
|
132 | + if ( ! $popular_importers) { |
|
133 | + $url = add_query_arg(array( |
|
134 | 134 | 'locale' => get_user_locale(), |
135 | 135 | 'version' => $wp_version, |
136 | - ), 'http://api.wordpress.org/core/importers/1.1/' ); |
|
137 | - $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() ); |
|
138 | - $response = wp_remote_get( $url, $options ); |
|
139 | - $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
136 | + ), 'http://api.wordpress.org/core/importers/1.1/'); |
|
137 | + $options = array('user-agent' => 'WordPress/'.$wp_version.'; '.home_url()); |
|
138 | + $response = wp_remote_get($url, $options); |
|
139 | + $popular_importers = json_decode(wp_remote_retrieve_body($response), true); |
|
140 | 140 | |
141 | - if ( is_array( $popular_importers ) ) { |
|
142 | - set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS ); |
|
141 | + if (is_array($popular_importers)) { |
|
142 | + set_site_transient($cache_key, $popular_importers, 2 * DAY_IN_SECONDS); |
|
143 | 143 | } else { |
144 | 144 | $popular_importers = false; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - if ( is_array( $popular_importers ) ) { |
|
148 | + if (is_array($popular_importers)) { |
|
149 | 149 | // If the data was received as translated, return it as-is. |
150 | - if ( $popular_importers['translated'] ) |
|
150 | + if ($popular_importers['translated']) |
|
151 | 151 | return $popular_importers['importers']; |
152 | 152 | |
153 | - foreach ( $popular_importers['importers'] as &$importer ) { |
|
154 | - $importer['description'] = translate( $importer['description'] ); |
|
155 | - if ( $importer['name'] != 'WordPress' ) |
|
156 | - $importer['name'] = translate( $importer['name'] ); |
|
153 | + foreach ($popular_importers['importers'] as &$importer) { |
|
154 | + $importer['description'] = translate($importer['description']); |
|
155 | + if ($importer['name'] != 'WordPress') |
|
156 | + $importer['name'] = translate($importer['name']); |
|
157 | 157 | } |
158 | 158 | return $popular_importers['importers']; |
159 | 159 | } |
@@ -161,50 +161,50 @@ discard block |
||
161 | 161 | return array( |
162 | 162 | // slug => name, description, plugin slug, and register_importer() slug |
163 | 163 | 'blogger' => array( |
164 | - 'name' => __( 'Blogger' ), |
|
165 | - 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), |
|
164 | + 'name' => __('Blogger'), |
|
165 | + 'description' => __('Import posts, comments, and users from a Blogger blog.'), |
|
166 | 166 | 'plugin-slug' => 'blogger-importer', |
167 | 167 | 'importer-id' => 'blogger', |
168 | 168 | ), |
169 | 169 | 'wpcat2tag' => array( |
170 | - 'name' => __( 'Categories and Tags Converter' ), |
|
171 | - 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), |
|
170 | + 'name' => __('Categories and Tags Converter'), |
|
171 | + 'description' => __('Convert existing categories to tags or tags to categories, selectively.'), |
|
172 | 172 | 'plugin-slug' => 'wpcat2tag-importer', |
173 | 173 | 'importer-id' => 'wp-cat2tag', |
174 | 174 | ), |
175 | 175 | 'livejournal' => array( |
176 | - 'name' => __( 'LiveJournal' ), |
|
177 | - 'description' => __( 'Import posts from LiveJournal using their API.' ), |
|
176 | + 'name' => __('LiveJournal'), |
|
177 | + 'description' => __('Import posts from LiveJournal using their API.'), |
|
178 | 178 | 'plugin-slug' => 'livejournal-importer', |
179 | 179 | 'importer-id' => 'livejournal', |
180 | 180 | ), |
181 | 181 | 'movabletype' => array( |
182 | - 'name' => __( 'Movable Type and TypePad' ), |
|
183 | - 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), |
|
182 | + 'name' => __('Movable Type and TypePad'), |
|
183 | + 'description' => __('Import posts and comments from a Movable Type or TypePad blog.'), |
|
184 | 184 | 'plugin-slug' => 'movabletype-importer', |
185 | 185 | 'importer-id' => 'mt', |
186 | 186 | ), |
187 | 187 | 'opml' => array( |
188 | - 'name' => __( 'Blogroll' ), |
|
189 | - 'description' => __( 'Import links in OPML format.' ), |
|
188 | + 'name' => __('Blogroll'), |
|
189 | + 'description' => __('Import links in OPML format.'), |
|
190 | 190 | 'plugin-slug' => 'opml-importer', |
191 | 191 | 'importer-id' => 'opml', |
192 | 192 | ), |
193 | 193 | 'rss' => array( |
194 | - 'name' => __( 'RSS' ), |
|
195 | - 'description' => __( 'Import posts from an RSS feed.' ), |
|
194 | + 'name' => __('RSS'), |
|
195 | + 'description' => __('Import posts from an RSS feed.'), |
|
196 | 196 | 'plugin-slug' => 'rss-importer', |
197 | 197 | 'importer-id' => 'rss', |
198 | 198 | ), |
199 | 199 | 'tumblr' => array( |
200 | - 'name' => __( 'Tumblr' ), |
|
201 | - 'description' => __( 'Import posts & media from Tumblr using their API.' ), |
|
200 | + 'name' => __('Tumblr'), |
|
201 | + 'description' => __('Import posts & media from Tumblr using their API.'), |
|
202 | 202 | 'plugin-slug' => 'tumblr-importer', |
203 | 203 | 'importer-id' => 'tumblr', |
204 | 204 | ), |
205 | 205 | 'wordpress' => array( |
206 | 206 | 'name' => 'WordPress', |
207 | - 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), |
|
207 | + 'description' => __('Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), |
|
208 | 208 | 'plugin-slug' => 'wordpress-importer', |
209 | 209 | 'importer-id' => 'wordpress', |
210 | 210 | ), |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param array $args Options for the upgrader, see WP_Upgrader_Skin::__construct(). |
37 | 37 | */ |
38 | - public function __construct( $args = array() ) { |
|
39 | - parent::__construct( $args ); |
|
38 | + public function __construct($args = array()) { |
|
39 | + parent::__construct($args); |
|
40 | 40 | |
41 | 41 | $this->errors = new WP_Error(); |
42 | 42 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | public function get_error_messages() { |
65 | 65 | $messages = array(); |
66 | 66 | |
67 | - foreach ( $this->errors->get_error_codes() as $error_code ) { |
|
68 | - if ( $this->errors->get_error_data( $error_code ) && is_string( $this->errors->get_error_data( $error_code ) ) ) { |
|
69 | - $messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $this->errors->get_error_data( $error_code ) ) ); |
|
67 | + foreach ($this->errors->get_error_codes() as $error_code) { |
|
68 | + if ($this->errors->get_error_data($error_code) && is_string($this->errors->get_error_data($error_code))) { |
|
69 | + $messages[] = $this->errors->get_error_message($error_code).' '.esc_html(strip_tags($this->errors->get_error_data($error_code))); |
|
70 | 70 | } else { |
71 | - $messages[] = $this->errors->get_error_message( $error_code ); |
|
71 | + $messages[] = $this->errors->get_error_message($error_code); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - return implode( ', ', $messages ); |
|
75 | + return implode(', ', $messages); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -83,32 +83,32 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param string|WP_Error $errors Errors. |
85 | 85 | */ |
86 | - public function error( $errors ) { |
|
87 | - if ( is_string( $errors ) ) { |
|
86 | + public function error($errors) { |
|
87 | + if (is_string($errors)) { |
|
88 | 88 | $string = $errors; |
89 | - if ( ! empty( $this->upgrader->strings[ $string ] ) ) { |
|
90 | - $string = $this->upgrader->strings[ $string ]; |
|
89 | + if ( ! empty($this->upgrader->strings[$string])) { |
|
90 | + $string = $this->upgrader->strings[$string]; |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( false !== strpos( $string, '%' ) ) { |
|
93 | + if (false !== strpos($string, '%')) { |
|
94 | 94 | $args = func_get_args(); |
95 | - $args = array_splice( $args, 1 ); |
|
96 | - if ( ! empty( $args ) ) { |
|
97 | - $string = vsprintf( $string, $args ); |
|
95 | + $args = array_splice($args, 1); |
|
96 | + if ( ! empty($args)) { |
|
97 | + $string = vsprintf($string, $args); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Count existing errors to generate an unique error code. |
102 | - $errors_count = count( $errors->get_error_codes() ); |
|
103 | - $this->errors->add( 'unknown_upgrade_error_' . $errors_count + 1 , $string ); |
|
104 | - } elseif ( is_wp_error( $errors ) ) { |
|
105 | - foreach ( $errors->get_error_codes() as $error_code ) { |
|
106 | - $this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) ); |
|
102 | + $errors_count = count($errors->get_error_codes()); |
|
103 | + $this->errors->add('unknown_upgrade_error_'.$errors_count + 1, $string); |
|
104 | + } elseif (is_wp_error($errors)) { |
|
105 | + foreach ($errors->get_error_codes() as $error_code) { |
|
106 | + $this->errors->add($error_code, $errors->get_error_message($error_code), $errors->get_error_data($error_code)); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | $args = func_get_args(); |
111 | - call_user_func_array( array( $this, 'parent::error' ), $args ); |
|
111 | + call_user_func_array(array($this, 'parent::error'), $args); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param string|array|WP_Error $data Log entry data. |
121 | 121 | */ |
122 | - public function feedback( $data ) { |
|
123 | - if ( is_wp_error( $data ) ) { |
|
124 | - foreach ( $data->get_error_codes() as $error_code ) { |
|
125 | - $this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) ); |
|
122 | + public function feedback($data) { |
|
123 | + if (is_wp_error($data)) { |
|
124 | + foreach ($data->get_error_codes() as $error_code) { |
|
125 | + $this->errors->add($error_code, $data->get_error_message($error_code), $data->get_error_data($error_code)); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | $args = func_get_args(); |
130 | - call_user_func_array( array( $this, 'parent::feedback' ), $args ); |
|
130 | + call_user_func_array(array($this, 'parent::feedback'), $args); |
|
131 | 131 | } |
132 | 132 | } |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param string|WP_Screen $screen The screen you want the headers for |
17 | 17 | * @return array Containing the headers in the format id => UI String |
18 | 18 | */ |
19 | -function get_column_headers( $screen ) { |
|
20 | - if ( is_string( $screen ) ) |
|
21 | - $screen = convert_to_screen( $screen ); |
|
19 | +function get_column_headers($screen) { |
|
20 | + if (is_string($screen)) |
|
21 | + $screen = convert_to_screen($screen); |
|
22 | 22 | |
23 | 23 | static $column_headers = array(); |
24 | 24 | |
25 | - if ( ! isset( $column_headers[ $screen->id ] ) ) { |
|
25 | + if ( ! isset($column_headers[$screen->id])) { |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Filters the column headers for a list table on a specific screen. |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $columns An array of column headers. Default empty. |
38 | 38 | */ |
39 | - $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); |
|
39 | + $column_headers[$screen->id] = apply_filters("manage_{$screen->id}_columns", array()); |
|
40 | 40 | } |
41 | 41 | |
42 | - return $column_headers[ $screen->id ]; |
|
42 | + return $column_headers[$screen->id]; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * @param string|WP_Screen $screen The screen you want the hidden columns for |
51 | 51 | * @return array |
52 | 52 | */ |
53 | -function get_hidden_columns( $screen ) { |
|
54 | - if ( is_string( $screen ) ) { |
|
55 | - $screen = convert_to_screen( $screen ); |
|
53 | +function get_hidden_columns($screen) { |
|
54 | + if (is_string($screen)) { |
|
55 | + $screen = convert_to_screen($screen); |
|
56 | 56 | } |
57 | 57 | |
58 | - $hidden = get_user_option( 'manage' . $screen->id . 'columnshidden' ); |
|
58 | + $hidden = get_user_option('manage'.$screen->id.'columnshidden'); |
|
59 | 59 | |
60 | - $use_defaults = ! is_array( $hidden ); |
|
60 | + $use_defaults = ! is_array($hidden); |
|
61 | 61 | |
62 | - if ( $use_defaults ) { |
|
62 | + if ($use_defaults) { |
|
63 | 63 | $hidden = array(); |
64 | 64 | |
65 | 65 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $hidden An array of columns hidden by default. |
71 | 71 | * @param WP_Screen $screen WP_Screen object of the current screen. |
72 | 72 | */ |
73 | - $hidden = apply_filters( 'default_hidden_columns', $hidden, $screen ); |
|
73 | + $hidden = apply_filters('default_hidden_columns', $hidden, $screen); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param WP_Screen $screen WP_Screen object of the current screen. |
84 | 84 | * @param bool $use_defaults Whether to show the default columns. |
85 | 85 | */ |
86 | - return apply_filters( 'hidden_columns', $hidden, $screen, $use_defaults ); |
|
86 | + return apply_filters('hidden_columns', $hidden, $screen, $use_defaults); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,39 +95,39 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param WP_Screen $screen |
97 | 97 | */ |
98 | -function meta_box_prefs( $screen ) { |
|
98 | +function meta_box_prefs($screen) { |
|
99 | 99 | global $wp_meta_boxes; |
100 | 100 | |
101 | - if ( is_string( $screen ) ) |
|
102 | - $screen = convert_to_screen( $screen ); |
|
101 | + if (is_string($screen)) |
|
102 | + $screen = convert_to_screen($screen); |
|
103 | 103 | |
104 | - if ( empty($wp_meta_boxes[$screen->id]) ) |
|
104 | + if (empty($wp_meta_boxes[$screen->id])) |
|
105 | 105 | return; |
106 | 106 | |
107 | 107 | $hidden = get_hidden_meta_boxes($screen); |
108 | 108 | |
109 | - foreach ( array_keys( $wp_meta_boxes[ $screen->id ] ) as $context ) { |
|
110 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
111 | - if ( ! isset( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] ) ) { |
|
109 | + foreach (array_keys($wp_meta_boxes[$screen->id]) as $context) { |
|
110 | + foreach (array('high', 'core', 'default', 'low') as $priority) { |
|
111 | + if ( ! isset($wp_meta_boxes[$screen->id][$context][$priority])) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | - foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { |
|
115 | - if ( false == $box || ! $box['title'] ) |
|
114 | + foreach ($wp_meta_boxes[$screen->id][$context][$priority] as $box) { |
|
115 | + if (false == $box || ! $box['title']) |
|
116 | 116 | continue; |
117 | 117 | // Submit box cannot be hidden |
118 | - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|
118 | + if ('submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id']) |
|
119 | 119 | continue; |
120 | 120 | |
121 | 121 | $widget_title = $box['title']; |
122 | 122 | |
123 | - if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) { |
|
123 | + if (is_array($box['args']) && isset($box['args']['__widget_basename'])) { |
|
124 | 124 | $widget_title = $box['args']['__widget_basename']; |
125 | 125 | } |
126 | 126 | |
127 | 127 | printf( |
128 | 128 | '<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>', |
129 | - esc_attr( $box['id'] ), |
|
130 | - checked( in_array( $box['id'], $hidden ), false, false ), |
|
129 | + esc_attr($box['id']), |
|
130 | + checked(in_array($box['id'], $hidden), false, false), |
|
131 | 131 | $widget_title |
132 | 132 | ); |
133 | 133 | } |
@@ -143,22 +143,22 @@ discard block |
||
143 | 143 | * @param string|WP_Screen $screen Screen identifier |
144 | 144 | * @return array Hidden Meta Boxes |
145 | 145 | */ |
146 | -function get_hidden_meta_boxes( $screen ) { |
|
147 | - if ( is_string( $screen ) ) |
|
148 | - $screen = convert_to_screen( $screen ); |
|
146 | +function get_hidden_meta_boxes($screen) { |
|
147 | + if (is_string($screen)) |
|
148 | + $screen = convert_to_screen($screen); |
|
149 | 149 | |
150 | - $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); |
|
150 | + $hidden = get_user_option("metaboxhidden_{$screen->id}"); |
|
151 | 151 | |
152 | - $use_defaults = ! is_array( $hidden ); |
|
152 | + $use_defaults = ! is_array($hidden); |
|
153 | 153 | |
154 | 154 | // Hide slug boxes by default |
155 | - if ( $use_defaults ) { |
|
155 | + if ($use_defaults) { |
|
156 | 156 | $hidden = array(); |
157 | - if ( 'post' == $screen->base ) { |
|
158 | - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) |
|
157 | + if ('post' == $screen->base) { |
|
158 | + if ('post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type) |
|
159 | 159 | $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
160 | 160 | else |
161 | - $hidden = array( 'slugdiv' ); |
|
161 | + $hidden = array('slugdiv'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $hidden An array of meta boxes hidden by default. |
170 | 170 | * @param WP_Screen $screen WP_Screen object of the current screen. |
171 | 171 | */ |
172 | - $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); |
|
172 | + $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param bool $use_defaults Whether to show the default meta boxes. |
183 | 183 | * Default true. |
184 | 184 | */ |
185 | - return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults ); |
|
185 | + return apply_filters('hidden_meta_boxes', $hidden, $screen, $use_defaults); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * @param string $option An option name. |
194 | 194 | * @param mixed $args Option-dependent arguments. |
195 | 195 | */ |
196 | -function add_screen_option( $option, $args = array() ) { |
|
196 | +function add_screen_option($option, $args = array()) { |
|
197 | 197 | $current_screen = get_current_screen(); |
198 | 198 | |
199 | - if ( ! $current_screen ) |
|
199 | + if ( ! $current_screen) |
|
200 | 200 | return; |
201 | 201 | |
202 | - $current_screen->add_option( $option, $args ); |
|
202 | + $current_screen->add_option($option, $args); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | function get_current_screen() { |
215 | 215 | global $current_screen; |
216 | 216 | |
217 | - if ( ! isset( $current_screen ) ) |
|
217 | + if ( ! isset($current_screen)) |
|
218 | 218 | return null; |
219 | 219 | |
220 | 220 | return $current_screen; |
@@ -228,6 +228,6 @@ discard block |
||
228 | 228 | * @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen, |
229 | 229 | * or an existing screen object. |
230 | 230 | */ |
231 | -function set_current_screen( $hook_name = '' ) { |
|
232 | - WP_Screen::get( $hook_name )->set_current_screen(); |
|
231 | +function set_current_screen($hook_name = '') { |
|
232 | + WP_Screen::get($hook_name)->set_current_screen(); |
|
233 | 233 | } |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @return array Containing the headers in the format id => UI String |
18 | 18 | */ |
19 | 19 | function get_column_headers( $screen ) { |
20 | - if ( is_string( $screen ) ) |
|
21 | - $screen = convert_to_screen( $screen ); |
|
20 | + if ( is_string( $screen ) ) { |
|
21 | + $screen = convert_to_screen( $screen ); |
|
22 | + } |
|
22 | 23 | |
23 | 24 | static $column_headers = array(); |
24 | 25 | |
@@ -98,11 +99,13 @@ discard block |
||
98 | 99 | function meta_box_prefs( $screen ) { |
99 | 100 | global $wp_meta_boxes; |
100 | 101 | |
101 | - if ( is_string( $screen ) ) |
|
102 | - $screen = convert_to_screen( $screen ); |
|
102 | + if ( is_string( $screen ) ) { |
|
103 | + $screen = convert_to_screen( $screen ); |
|
104 | + } |
|
103 | 105 | |
104 | - if ( empty($wp_meta_boxes[$screen->id]) ) |
|
105 | - return; |
|
106 | + if ( empty($wp_meta_boxes[$screen->id]) ) { |
|
107 | + return; |
|
108 | + } |
|
106 | 109 | |
107 | 110 | $hidden = get_hidden_meta_boxes($screen); |
108 | 111 | |
@@ -112,11 +115,13 @@ discard block |
||
112 | 115 | continue; |
113 | 116 | } |
114 | 117 | foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) { |
115 | - if ( false == $box || ! $box['title'] ) |
|
116 | - continue; |
|
118 | + if ( false == $box || ! $box['title'] ) { |
|
119 | + continue; |
|
120 | + } |
|
117 | 121 | // Submit box cannot be hidden |
118 | - if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|
119 | - continue; |
|
122 | + if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { |
|
123 | + continue; |
|
124 | + } |
|
120 | 125 | |
121 | 126 | $widget_title = $box['title']; |
122 | 127 | |
@@ -144,8 +149,9 @@ discard block |
||
144 | 149 | * @return array Hidden Meta Boxes |
145 | 150 | */ |
146 | 151 | function get_hidden_meta_boxes( $screen ) { |
147 | - if ( is_string( $screen ) ) |
|
148 | - $screen = convert_to_screen( $screen ); |
|
152 | + if ( is_string( $screen ) ) { |
|
153 | + $screen = convert_to_screen( $screen ); |
|
154 | + } |
|
149 | 155 | |
150 | 156 | $hidden = get_user_option( "metaboxhidden_{$screen->id}" ); |
151 | 157 | |
@@ -155,10 +161,11 @@ discard block |
||
155 | 161 | if ( $use_defaults ) { |
156 | 162 | $hidden = array(); |
157 | 163 | if ( 'post' == $screen->base ) { |
158 | - if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) |
|
159 | - $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
|
160 | - else |
|
161 | - $hidden = array( 'slugdiv' ); |
|
164 | + if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) { |
|
165 | + $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
|
166 | + } else { |
|
167 | + $hidden = array( 'slugdiv' ); |
|
168 | + } |
|
162 | 169 | } |
163 | 170 | |
164 | 171 | /** |
@@ -196,8 +203,9 @@ discard block |
||
196 | 203 | function add_screen_option( $option, $args = array() ) { |
197 | 204 | $current_screen = get_current_screen(); |
198 | 205 | |
199 | - if ( ! $current_screen ) |
|
200 | - return; |
|
206 | + if ( ! $current_screen ) { |
|
207 | + return; |
|
208 | + } |
|
201 | 209 | |
202 | 210 | $current_screen->add_option( $option, $args ); |
203 | 211 | } |
@@ -214,8 +222,9 @@ discard block |
||
214 | 222 | function get_current_screen() { |
215 | 223 | global $current_screen; |
216 | 224 | |
217 | - if ( ! isset( $current_screen ) ) |
|
218 | - return null; |
|
225 | + if ( ! isset( $current_screen ) ) { |
|
226 | + return null; |
|
227 | + } |
|
219 | 228 | |
220 | 229 | return $current_screen; |
221 | 230 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @deprecated 3.0.0 |
17 | 17 | */ |
18 | 18 | function wpmu_menu() { |
19 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
19 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
20 | 20 | // Deprecated. See #11763. |
21 | 21 | } |
22 | 22 | |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @see is_upload_space_available() |
28 | 28 | */ |
29 | 29 | function wpmu_checkAvailableSpace() { |
30 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()' ); |
|
30 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()'); |
|
31 | 31 | |
32 | - if ( !is_upload_space_available() ) |
|
33 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
32 | + if ( ! is_upload_space_available()) |
|
33 | + wp_die(__('Sorry, you must delete files before you can upload any more.')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @deprecated 3.0.0 |
40 | 40 | */ |
41 | -function mu_options( $options ) { |
|
42 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
41 | +function mu_options($options) { |
|
42 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
43 | 43 | return $options; |
44 | 44 | } |
45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @see activate_plugin() |
51 | 51 | */ |
52 | 52 | function activate_sitewide_plugin() { |
53 | - _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()' ); |
|
53 | + _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()'); |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @deprecated 3.0.0 Use deactivate_sitewide_plugin() |
61 | 61 | * @see deactivate_sitewide_plugin() |
62 | 62 | */ |
63 | -function deactivate_sitewide_plugin( $plugin = false ) { |
|
64 | - _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()' ); |
|
63 | +function deactivate_sitewide_plugin($plugin = false) { |
|
64 | + _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @deprecated 3.0.0 Use is_network_only_plugin() |
71 | 71 | * @see is_network_only_plugin() |
72 | 72 | */ |
73 | -function is_wpmu_sitewide_plugin( $file ) { |
|
74 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()' ); |
|
75 | - return is_network_only_plugin( $file ); |
|
73 | +function is_wpmu_sitewide_plugin($file) { |
|
74 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()'); |
|
75 | + return is_network_only_plugin($file); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @see WP_Theme::get_allowed_on_network() |
83 | 83 | */ |
84 | 84 | function get_site_allowed_themes() { |
85 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()' ); |
|
86 | - return array_map( 'intval', WP_Theme::get_allowed_on_network() ); |
|
85 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()'); |
|
86 | + return array_map('intval', WP_Theme::get_allowed_on_network()); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @deprecated 3.4.0 Use WP_Theme::get_allowed_on_site() |
93 | 93 | * @see WP_Theme::get_allowed_on_site() |
94 | 94 | */ |
95 | -function wpmu_get_blog_allowedthemes( $blog_id = 0 ) { |
|
96 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()' ); |
|
97 | - return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) ); |
|
95 | +function wpmu_get_blog_allowedthemes($blog_id = 0) { |
|
96 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()'); |
|
97 | + return array_map('intval', WP_Theme::get_allowed_on_site($blog_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -29,9 +29,10 @@ |
||
29 | 29 | function wpmu_checkAvailableSpace() { |
30 | 30 | _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()' ); |
31 | 31 | |
32 | - if ( !is_upload_space_available() ) |
|
33 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
34 | -} |
|
32 | + if ( !is_upload_space_available() ) { |
|
33 | + wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
34 | + } |
|
35 | + } |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * WPMU options. |
@@ -8,83 +8,83 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Bookmark hooks. |
11 | -add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' ); |
|
11 | +add_action('admin_page_access_denied', 'wp_link_manager_disabled_message'); |
|
12 | 12 | |
13 | 13 | // Dashboard hooks. |
14 | -add_action( 'activity_box_end', 'wp_dashboard_quota' ); |
|
14 | +add_action('activity_box_end', 'wp_dashboard_quota'); |
|
15 | 15 | |
16 | 16 | // Media hooks. |
17 | -add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' ); |
|
17 | +add_action('attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'); |
|
18 | 18 | |
19 | -add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
|
20 | -add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
|
21 | -add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
|
22 | -add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
|
19 | +add_action('media_upload_image', 'wp_media_upload_handler'); |
|
20 | +add_action('media_upload_audio', 'wp_media_upload_handler'); |
|
21 | +add_action('media_upload_video', 'wp_media_upload_handler'); |
|
22 | +add_action('media_upload_file', 'wp_media_upload_handler'); |
|
23 | 23 | |
24 | -add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); |
|
24 | +add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
|
25 | 25 | |
26 | -add_action( 'post-html-upload-ui', 'media_upload_html_bypass' ); |
|
26 | +add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
|
27 | 27 | |
28 | -add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
|
29 | -add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
|
30 | -add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
|
31 | -add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
|
28 | +add_filter('async_upload_image', 'get_media_item', 10, 2); |
|
29 | +add_filter('async_upload_audio', 'get_media_item', 10, 2); |
|
30 | +add_filter('async_upload_video', 'get_media_item', 10, 2); |
|
31 | +add_filter('async_upload_file', 'get_media_item', 10, 2); |
|
32 | 32 | |
33 | -add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 ); |
|
33 | +add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); |
|
34 | 34 | |
35 | -add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
|
36 | -add_filter( 'media_upload_library', 'media_upload_library' ); |
|
35 | +add_filter('media_upload_gallery', 'media_upload_gallery'); |
|
36 | +add_filter('media_upload_library', 'media_upload_library'); |
|
37 | 37 | |
38 | -add_filter( 'media_upload_tabs', 'update_gallery_tab' ); |
|
38 | +add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
39 | 39 | |
40 | 40 | // Misc hooks. |
41 | -add_action( 'admin_head', 'wp_admin_canonical_url' ); |
|
42 | -add_action( 'admin_head', 'wp_color_scheme_settings' ); |
|
43 | -add_action( 'admin_head', 'wp_site_icon' ); |
|
44 | -add_action( 'admin_head', '_ipad_meta' ); |
|
41 | +add_action('admin_head', 'wp_admin_canonical_url'); |
|
42 | +add_action('admin_head', 'wp_color_scheme_settings'); |
|
43 | +add_action('admin_head', 'wp_site_icon'); |
|
44 | +add_action('admin_head', '_ipad_meta'); |
|
45 | 45 | |
46 | 46 | // Prerendering. |
47 | -if ( ! is_customize_preview() ) { |
|
48 | - add_filter( 'admin_print_styles', 'wp_resource_hints', 1 ); |
|
47 | +if ( ! is_customize_preview()) { |
|
48 | + add_filter('admin_print_styles', 'wp_resource_hints', 1); |
|
49 | 49 | } |
50 | 50 | |
51 | -add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' ); |
|
52 | -add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' ); |
|
51 | +add_action('admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js'); |
|
52 | +add_action('admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js'); |
|
53 | 53 | |
54 | -add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
|
55 | -add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
|
56 | -add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); |
|
54 | +add_action('update_option_home', 'update_home_siteurl', 10, 2); |
|
55 | +add_action('update_option_siteurl', 'update_home_siteurl', 10, 2); |
|
56 | +add_action('update_option_page_on_front', 'update_home_siteurl', 10, 2); |
|
57 | 57 | |
58 | -add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); |
|
59 | -add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); |
|
60 | -add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); |
|
61 | -add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); |
|
58 | +add_filter('heartbeat_received', 'wp_check_locked_posts', 10, 3); |
|
59 | +add_filter('heartbeat_received', 'wp_refresh_post_lock', 10, 3); |
|
60 | +add_filter('wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3); |
|
61 | +add_filter('heartbeat_received', 'heartbeat_autosave', 500, 2); |
|
62 | 62 | |
63 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' ); |
|
63 | +add_filter('heartbeat_settings', 'wp_heartbeat_set_suspension'); |
|
64 | 64 | |
65 | 65 | // Nav Menu hooks. |
66 | -add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' ); |
|
66 | +add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); |
|
67 | 67 | |
68 | 68 | // Plugin hooks. |
69 | -add_filter( 'whitelist_options', 'option_update_filter' ); |
|
69 | +add_filter('whitelist_options', 'option_update_filter'); |
|
70 | 70 | |
71 | 71 | // Plugin Install hooks. |
72 | -add_action( 'install_plugins_featured', 'install_dashboard' ); |
|
73 | -add_action( 'install_plugins_upload', 'install_plugins_upload' ); |
|
74 | -add_action( 'install_plugins_search', 'display_plugins_table' ); |
|
75 | -add_action( 'install_plugins_popular', 'display_plugins_table' ); |
|
76 | -add_action( 'install_plugins_recommended', 'display_plugins_table' ); |
|
77 | -add_action( 'install_plugins_new', 'display_plugins_table' ); |
|
78 | -add_action( 'install_plugins_beta', 'display_plugins_table' ); |
|
79 | -add_action( 'install_plugins_favorites', 'display_plugins_table' ); |
|
80 | -add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' ); |
|
72 | +add_action('install_plugins_featured', 'install_dashboard'); |
|
73 | +add_action('install_plugins_upload', 'install_plugins_upload'); |
|
74 | +add_action('install_plugins_search', 'display_plugins_table'); |
|
75 | +add_action('install_plugins_popular', 'display_plugins_table'); |
|
76 | +add_action('install_plugins_recommended', 'display_plugins_table'); |
|
77 | +add_action('install_plugins_new', 'display_plugins_table'); |
|
78 | +add_action('install_plugins_beta', 'display_plugins_table'); |
|
79 | +add_action('install_plugins_favorites', 'display_plugins_table'); |
|
80 | +add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); |
|
81 | 81 | |
82 | 82 | // Template hooks. |
83 | -add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
84 | -add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
|
83 | +add_action('admin_enqueue_scripts', array('WP_Internal_Pointers', 'enqueue_scripts')); |
|
84 | +add_action('user_register', array('WP_Internal_Pointers', 'dismiss_pointers_for_new_users')); |
|
85 | 85 | |
86 | 86 | // Theme hooks. |
87 | -add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' ); |
|
87 | +add_action('customize_controls_print_footer_scripts', 'customize_themes_print_templates'); |
|
88 | 88 | |
89 | 89 | // Theme Install hooks. |
90 | 90 | // add_action('install_themes_dashboard', 'install_themes_dashboard'); |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | // add_action('install_themes_featured', 'display_themes'); |
94 | 94 | // add_action('install_themes_new', 'display_themes'); |
95 | 95 | // add_action('install_themes_updated', 'display_themes'); |
96 | -add_action( 'install_themes_pre_theme-information', 'install_theme_information' ); |
|
96 | +add_action('install_themes_pre_theme-information', 'install_theme_information'); |
|
97 | 97 | |
98 | 98 | // User hooks. |
99 | -add_action( 'admin_init', 'default_password_nag_handler' ); |
|
99 | +add_action('admin_init', 'default_password_nag_handler'); |
|
100 | 100 | |
101 | -add_action( 'admin_notices', 'default_password_nag' ); |
|
101 | +add_action('admin_notices', 'default_password_nag'); |
|
102 | 102 | |
103 | -add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 ); |
|
103 | +add_action('profile_update', 'default_password_nag_edit_user', 10, 2); |
|
104 | 104 | |
105 | 105 | // Update hooks. |
106 | -add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called. |
|
107 | -add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called. |
|
106 | +add_action('load-plugins.php', 'wp_plugin_update_rows', 20); // After wp_update_plugins() is called. |
|
107 | +add_action('load-themes.php', 'wp_theme_update_rows', 20); // After wp_update_themes() is called. |
|
108 | 108 | |
109 | -add_action( 'admin_notices', 'update_nag', 3 ); |
|
110 | -add_action( 'admin_notices', 'maintenance_nag', 10 ); |
|
109 | +add_action('admin_notices', 'update_nag', 3); |
|
110 | +add_action('admin_notices', 'maintenance_nag', 10); |
|
111 | 111 | |
112 | -add_filter( 'update_footer', 'core_update_footer' ); |
|
112 | +add_filter('update_footer', 'core_update_footer'); |
|
113 | 113 | |
114 | 114 | // Update Core hooks. |
115 | -add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); |
|
115 | +add_action('_core_updated_successfully', '_redirect_to_about_wordpress'); |
|
116 | 116 | |
117 | 117 | // Upgrade hooks. |
118 | -add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
119 | -add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
|
120 | -add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
|
121 | -add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
118 | +add_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
|
119 | +add_action('upgrader_process_complete', 'wp_version_check', 10, 0); |
|
120 | +add_action('upgrader_process_complete', 'wp_update_plugins', 10, 0); |
|
121 | +add_action('upgrader_process_complete', 'wp_update_themes', 10, 0); |
@@ -22,44 +22,44 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param array $opt |
24 | 24 | */ |
25 | - public function __construct( $opt = '' ) { |
|
25 | + public function __construct($opt = '') { |
|
26 | 26 | $this->method = 'ftpext'; |
27 | 27 | $this->errors = new WP_Error(); |
28 | 28 | |
29 | 29 | // Check if possible to use ftp functions. |
30 | - if ( ! extension_loaded('ftp') ) { |
|
30 | + if ( ! extension_loaded('ftp')) { |
|
31 | 31 | $this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available')); |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. |
36 | 36 | |
37 | - if ( ! defined('FS_TIMEOUT') ) |
|
37 | + if ( ! defined('FS_TIMEOUT')) |
|
38 | 38 | define('FS_TIMEOUT', 240); |
39 | 39 | |
40 | - if ( empty($opt['port']) ) |
|
40 | + if (empty($opt['port'])) |
|
41 | 41 | $this->options['port'] = 21; |
42 | 42 | else |
43 | 43 | $this->options['port'] = $opt['port']; |
44 | 44 | |
45 | - if ( empty($opt['hostname']) ) |
|
45 | + if (empty($opt['hostname'])) |
|
46 | 46 | $this->errors->add('empty_hostname', __('FTP hostname is required')); |
47 | 47 | else |
48 | 48 | $this->options['hostname'] = $opt['hostname']; |
49 | 49 | |
50 | 50 | // Check if the options provided are OK. |
51 | - if ( empty($opt['username']) ) |
|
51 | + if (empty($opt['username'])) |
|
52 | 52 | $this->errors->add('empty_username', __('FTP username is required')); |
53 | 53 | else |
54 | 54 | $this->options['username'] = $opt['username']; |
55 | 55 | |
56 | - if ( empty($opt['password']) ) |
|
56 | + if (empty($opt['password'])) |
|
57 | 57 | $this->errors->add('empty_password', __('FTP password is required')); |
58 | 58 | else |
59 | 59 | $this->options['password'] = $opt['password']; |
60 | 60 | |
61 | 61 | $this->options['ssl'] = false; |
62 | - if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) |
|
62 | + if (isset($opt['connection_type']) && 'ftps' == $opt['connection_type']) |
|
63 | 63 | $this->options['ssl'] = true; |
64 | 64 | } |
65 | 65 | |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | * @return bool |
70 | 70 | */ |
71 | 71 | public function connect() { |
72 | - if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) |
|
72 | + if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) |
|
73 | 73 | $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
74 | 74 | else |
75 | 75 | $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
76 | 76 | |
77 | - if ( ! $this->link ) { |
|
78 | - $this->errors->add( 'connect', |
|
77 | + if ( ! $this->link) { |
|
78 | + $this->errors->add('connect', |
|
79 | 79 | /* translators: %s: hostname:port */ |
80 | - sprintf( __( 'Failed to connect to FTP Server %s' ), |
|
81 | - $this->options['hostname'] . ':' . $this->options['port'] |
|
80 | + sprintf(__('Failed to connect to FTP Server %s'), |
|
81 | + $this->options['hostname'].':'.$this->options['port'] |
|
82 | 82 | ) |
83 | 83 | ); |
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
87 | - if ( ! @ftp_login( $this->link,$this->options['username'], $this->options['password'] ) ) { |
|
88 | - $this->errors->add( 'auth', |
|
87 | + if ( ! @ftp_login($this->link, $this->options['username'], $this->options['password'])) { |
|
88 | + $this->errors->add('auth', |
|
89 | 89 | /* translators: %s: username */ |
90 | - sprintf( __( 'Username/Password incorrect for %s' ), |
|
90 | + sprintf(__('Username/Password incorrect for %s'), |
|
91 | 91 | $this->options['username'] |
92 | 92 | ) |
93 | 93 | ); |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Set the Connection to use Passive FTP |
98 | - @ftp_pasv( $this->link, true ); |
|
99 | - if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) |
|
98 | + @ftp_pasv($this->link, true); |
|
99 | + if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT) |
|
100 | 100 | @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
101 | 101 | |
102 | 102 | return true; |
@@ -112,25 +112,25 @@ discard block |
||
112 | 112 | * @return string|false File contents on success, false if no temp file could be opened, |
113 | 113 | * or if the file couldn't be retrieved. |
114 | 114 | */ |
115 | - public function get_contents( $file ) { |
|
115 | + public function get_contents($file) { |
|
116 | 116 | $tempfile = wp_tempnam($file); |
117 | 117 | $temp = fopen($tempfile, 'w+'); |
118 | 118 | |
119 | - if ( ! $temp ) { |
|
120 | - unlink( $tempfile ); |
|
119 | + if ( ! $temp) { |
|
120 | + unlink($tempfile); |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
124 | - if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) { |
|
125 | - fclose( $temp ); |
|
126 | - unlink( $tempfile ); |
|
124 | + if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY)) { |
|
125 | + fclose($temp); |
|
126 | + unlink($tempfile); |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | |
130 | - fseek( $temp, 0 ); // Skip back to the start of the file being written to |
|
130 | + fseek($temp, 0); // Skip back to the start of the file being written to |
|
131 | 131 | $contents = ''; |
132 | 132 | |
133 | - while ( ! feof($temp) ) |
|
133 | + while ( ! feof($temp)) |
|
134 | 134 | $contents .= fread($temp, 8192); |
135 | 135 | |
136 | 136 | fclose($temp); |
@@ -156,31 +156,31 @@ discard block |
||
156 | 156 | * @param bool|int $mode |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | - public function put_contents($file, $contents, $mode = false ) { |
|
159 | + public function put_contents($file, $contents, $mode = false) { |
|
160 | 160 | $tempfile = wp_tempnam($file); |
161 | - $temp = fopen( $tempfile, 'wb+' ); |
|
161 | + $temp = fopen($tempfile, 'wb+'); |
|
162 | 162 | |
163 | - if ( ! $temp ) { |
|
164 | - unlink( $tempfile ); |
|
163 | + if ( ! $temp) { |
|
164 | + unlink($tempfile); |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | mbstring_binary_safe_encoding(); |
169 | 169 | |
170 | - $data_length = strlen( $contents ); |
|
171 | - $bytes_written = fwrite( $temp, $contents ); |
|
170 | + $data_length = strlen($contents); |
|
171 | + $bytes_written = fwrite($temp, $contents); |
|
172 | 172 | |
173 | 173 | reset_mbstring_encoding(); |
174 | 174 | |
175 | - if ( $data_length !== $bytes_written ) { |
|
176 | - fclose( $temp ); |
|
177 | - unlink( $tempfile ); |
|
175 | + if ($data_length !== $bytes_written) { |
|
176 | + fclose($temp); |
|
177 | + unlink($tempfile); |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
181 | - fseek( $temp, 0 ); // Skip back to the start of the file being written to |
|
181 | + fseek($temp, 0); // Skip back to the start of the file being written to |
|
182 | 182 | |
183 | - $ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY ); |
|
183 | + $ret = @ftp_fput($this->link, $file, $temp, FTP_BINARY); |
|
184 | 184 | |
185 | 185 | fclose($temp); |
186 | 186 | unlink($tempfile); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function cwd() { |
199 | 199 | $cwd = @ftp_pwd($this->link); |
200 | - if ( $cwd ) |
|
200 | + if ($cwd) |
|
201 | 201 | $cwd = trailingslashit($cwd); |
202 | 202 | return $cwd; |
203 | 203 | } |
@@ -221,26 +221,26 @@ discard block |
||
221 | 221 | * @return bool |
222 | 222 | */ |
223 | 223 | public function chmod($file, $mode = false, $recursive = false) { |
224 | - if ( ! $mode ) { |
|
225 | - if ( $this->is_file($file) ) |
|
224 | + if ( ! $mode) { |
|
225 | + if ($this->is_file($file)) |
|
226 | 226 | $mode = FS_CHMOD_FILE; |
227 | - elseif ( $this->is_dir($file) ) |
|
227 | + elseif ($this->is_dir($file)) |
|
228 | 228 | $mode = FS_CHMOD_DIR; |
229 | 229 | else |
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // chmod any sub-objects if recursive. |
234 | - if ( $recursive && $this->is_dir($file) ) { |
|
234 | + if ($recursive && $this->is_dir($file)) { |
|
235 | 235 | $filelist = $this->dirlist($file); |
236 | - foreach ( (array)$filelist as $filename => $filemeta ) |
|
237 | - $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
236 | + foreach ((array) $filelist as $filename => $filemeta) |
|
237 | + $this->chmod($file.'/'.$filename, $mode, $recursive); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | // chmod the file or directory |
241 | - if ( ! function_exists('ftp_chmod') ) |
|
242 | - return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
243 | - return (bool)@ftp_chmod($this->link, $mode, $file); |
|
241 | + if ( ! function_exists('ftp_chmod')) |
|
242 | + return (bool) @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
243 | + return (bool) @ftp_chmod($this->link, $mode, $file); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * @return bool |
286 | 286 | */ |
287 | 287 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
288 | - if ( ! $overwrite && $this->exists($destination) ) |
|
288 | + if ( ! $overwrite && $this->exists($destination)) |
|
289 | 289 | return false; |
290 | 290 | $content = $this->get_contents($source); |
291 | - if ( false === $content ) |
|
291 | + if (false === $content) |
|
292 | 292 | return false; |
293 | 293 | return $this->put_contents($destination, $content, $mode); |
294 | 294 | } |
@@ -314,17 +314,17 @@ discard block |
||
314 | 314 | * @return bool |
315 | 315 | */ |
316 | 316 | public function delete($file, $recursive = false, $type = false) { |
317 | - if ( empty($file) ) |
|
317 | + if (empty($file)) |
|
318 | 318 | return false; |
319 | - if ( 'f' == $type || $this->is_file($file) ) |
|
319 | + if ('f' == $type || $this->is_file($file)) |
|
320 | 320 | return @ftp_delete($this->link, $file); |
321 | - if ( !$recursive ) |
|
321 | + if ( ! $recursive) |
|
322 | 322 | return @ftp_rmdir($this->link, $file); |
323 | 323 | |
324 | - $filelist = $this->dirlist( trailingslashit($file) ); |
|
325 | - if ( !empty($filelist) ) |
|
326 | - foreach ( $filelist as $delete_file ) |
|
327 | - $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); |
|
324 | + $filelist = $this->dirlist(trailingslashit($file)); |
|
325 | + if ( ! empty($filelist)) |
|
326 | + foreach ($filelist as $delete_file) |
|
327 | + $this->delete(trailingslashit($file).$delete_file['name'], $recursive, $delete_file['type']); |
|
328 | 328 | return @ftp_rmdir($this->link, $file); |
329 | 329 | } |
330 | 330 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | public function exists($file) { |
338 | 338 | $list = @ftp_nlist($this->link, $file); |
339 | 339 | |
340 | - if ( empty( $list ) && $this->is_dir( $file ) ) { |
|
340 | + if (empty($list) && $this->is_dir($file)) { |
|
341 | 341 | return true; // File is an empty directory. |
342 | 342 | } |
343 | 343 | |
344 | - return !empty($list); //empty list = no file, so invert. |
|
344 | + return ! empty($list); //empty list = no file, so invert. |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @return bool |
352 | 352 | */ |
353 | 353 | public function is_file($file) { |
354 | - return $this->exists($file) && !$this->is_dir($file); |
|
354 | + return $this->exists($file) && ! $this->is_dir($file); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function is_dir($path) { |
364 | 364 | $cwd = $this->cwd(); |
365 | - $result = @ftp_chdir($this->link, trailingslashit($path) ); |
|
366 | - if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) { |
|
365 | + $result = @ftp_chdir($this->link, trailingslashit($path)); |
|
366 | + if ($result && $path == $this->cwd() || $this->cwd() != $cwd) { |
|
367 | 367 | @ftp_chdir($this->link, $cwd); |
368 | 368 | return true; |
369 | 369 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
443 | 443 | $path = untrailingslashit($path); |
444 | - if ( empty($path) ) |
|
444 | + if (empty($path)) |
|
445 | 445 | return false; |
446 | 446 | |
447 | - if ( !@ftp_mkdir($this->link, $path) ) |
|
447 | + if ( ! @ftp_mkdir($this->link, $path)) |
|
448 | 448 | return false; |
449 | 449 | $this->chmod($path, $chmod); |
450 | 450 | return true; |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | */ |
471 | 471 | public function parselisting($line) { |
472 | 472 | static $is_windows = null; |
473 | - if ( is_null($is_windows) ) |
|
474 | - $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
473 | + if (is_null($is_windows)) |
|
474 | + $is_windows = stripos(ftp_systype($this->link), 'win') !== false; |
|
475 | 475 | |
476 | - if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) { |
|
476 | + if ($is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer)) { |
|
477 | 477 | $b = array(); |
478 | - if ( $lucifer[3] < 70 ) |
|
479 | - $lucifer[3] +=2000; |
|
478 | + if ($lucifer[3] < 70) |
|
479 | + $lucifer[3] += 2000; |
|
480 | 480 | else |
481 | 481 | $lucifer[3] += 1900; // 4digit year fix |
482 | - $b['isdir'] = ( $lucifer[7] == '<DIR>'); |
|
483 | - if ( $b['isdir'] ) |
|
482 | + $b['isdir'] = ($lucifer[7] == '<DIR>'); |
|
483 | + if ($b['isdir']) |
|
484 | 484 | $b['type'] = 'd'; |
485 | 485 | else |
486 | 486 | $b['type'] = 'f'; |
@@ -493,27 +493,27 @@ discard block |
||
493 | 493 | $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]); |
494 | 494 | $b['am/pm'] = $lucifer[6]; |
495 | 495 | $b['name'] = $lucifer[8]; |
496 | - } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
|
496 | + } elseif ( ! $is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
|
497 | 497 | //echo $line."\n"; |
498 | 498 | $lcount = count($lucifer); |
499 | - if ( $lcount < 8 ) |
|
499 | + if ($lcount < 8) |
|
500 | 500 | return ''; |
501 | 501 | $b = array(); |
502 | 502 | $b['isdir'] = $lucifer[0]{0} === 'd'; |
503 | 503 | $b['islink'] = $lucifer[0]{0} === 'l'; |
504 | - if ( $b['isdir'] ) |
|
504 | + if ($b['isdir']) |
|
505 | 505 | $b['type'] = 'd'; |
506 | - elseif ( $b['islink'] ) |
|
506 | + elseif ($b['islink']) |
|
507 | 507 | $b['type'] = 'l'; |
508 | 508 | else |
509 | 509 | $b['type'] = 'f'; |
510 | 510 | $b['perms'] = $lucifer[0]; |
511 | - $b['permsn'] = $this->getnumchmodfromh( $b['perms'] ); |
|
511 | + $b['permsn'] = $this->getnumchmodfromh($b['perms']); |
|
512 | 512 | $b['number'] = $lucifer[1]; |
513 | 513 | $b['owner'] = $lucifer[2]; |
514 | 514 | $b['group'] = $lucifer[3]; |
515 | 515 | $b['size'] = $lucifer[4]; |
516 | - if ( $lcount == 8 ) { |
|
516 | + if ($lcount == 8) { |
|
517 | 517 | sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']); |
518 | 518 | sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']); |
519 | 519 | $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } else { |
522 | 522 | $b['month'] = $lucifer[5]; |
523 | 523 | $b['day'] = $lucifer[6]; |
524 | - if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) { |
|
524 | + if (preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2)) { |
|
525 | 525 | $b['year'] = date("Y"); |
526 | 526 | $b['hour'] = $l2[1]; |
527 | 527 | $b['minute'] = $l2[2]; |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | $b['hour'] = 0; |
531 | 531 | $b['minute'] = 0; |
532 | 532 | } |
533 | - $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) ); |
|
533 | + $b['time'] = strtotime(sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'])); |
|
534 | 534 | $b['name'] = $lucifer[8]; |
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | 538 | // Replace symlinks formatted as "source -> target" with just the source name |
539 | - if ( isset( $b['islink'] ) && $b['islink'] ) { |
|
540 | - $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); |
|
539 | + if (isset($b['islink']) && $b['islink']) { |
|
540 | + $b['name'] = preg_replace('/(\s*->\s*.*)$/', '', $b['name']); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | return $b; |
@@ -552,50 +552,50 @@ discard block |
||
552 | 552 | * @return bool|array |
553 | 553 | */ |
554 | 554 | public function dirlist($path = '.', $include_hidden = true, $recursive = false) { |
555 | - if ( $this->is_file($path) ) { |
|
555 | + if ($this->is_file($path)) { |
|
556 | 556 | $limit_file = basename($path); |
557 | - $path = dirname($path) . '/'; |
|
557 | + $path = dirname($path).'/'; |
|
558 | 558 | } else { |
559 | 559 | $limit_file = false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | $pwd = @ftp_pwd($this->link); |
563 | - if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist |
|
563 | + if ( ! @ftp_chdir($this->link, $path)) // Cant change to folder = folder doesn't exist |
|
564 | 564 | return false; |
565 | 565 | $list = @ftp_rawlist($this->link, '-a', false); |
566 | 566 | @ftp_chdir($this->link, $pwd); |
567 | 567 | |
568 | - if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least) |
|
568 | + if (empty($list)) // Empty array = non-existent folder (real folder will show . at least) |
|
569 | 569 | return false; |
570 | 570 | |
571 | 571 | $dirlist = array(); |
572 | - foreach ( $list as $k => $v ) { |
|
572 | + foreach ($list as $k => $v) { |
|
573 | 573 | $entry = $this->parselisting($v); |
574 | - if ( empty($entry) ) |
|
574 | + if (empty($entry)) |
|
575 | 575 | continue; |
576 | 576 | |
577 | - if ( '.' == $entry['name'] || '..' == $entry['name'] ) |
|
577 | + if ('.' == $entry['name'] || '..' == $entry['name']) |
|
578 | 578 | continue; |
579 | 579 | |
580 | - if ( ! $include_hidden && '.' == $entry['name'][0] ) |
|
580 | + if ( ! $include_hidden && '.' == $entry['name'][0]) |
|
581 | 581 | continue; |
582 | 582 | |
583 | - if ( $limit_file && $entry['name'] != $limit_file) |
|
583 | + if ($limit_file && $entry['name'] != $limit_file) |
|
584 | 584 | continue; |
585 | 585 | |
586 | - $dirlist[ $entry['name'] ] = $entry; |
|
586 | + $dirlist[$entry['name']] = $entry; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $ret = array(); |
590 | - foreach ( (array)$dirlist as $struc ) { |
|
591 | - if ( 'd' == $struc['type'] ) { |
|
592 | - if ( $recursive ) |
|
593 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
590 | + foreach ((array) $dirlist as $struc) { |
|
591 | + if ('d' == $struc['type']) { |
|
592 | + if ($recursive) |
|
593 | + $struc['files'] = $this->dirlist($path.'/'.$struc['name'], $include_hidden, $recursive); |
|
594 | 594 | else |
595 | 595 | $struc['files'] = array(); |
596 | 596 | } |
597 | 597 | |
598 | - $ret[ $struc['name'] ] = $struc; |
|
598 | + $ret[$struc['name']] = $struc; |
|
599 | 599 | } |
600 | 600 | return $ret; |
601 | 601 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @access public |
605 | 605 | */ |
606 | 606 | public function __destruct() { |
607 | - if ( $this->link ) |
|
607 | + if ($this->link) |
|
608 | 608 | ftp_close($this->link); |
609 | 609 | } |
610 | 610 | } |
@@ -34,33 +34,39 @@ discard block |
||
34 | 34 | |
35 | 35 | // This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. |
36 | 36 | |
37 | - if ( ! defined('FS_TIMEOUT') ) |
|
38 | - define('FS_TIMEOUT', 240); |
|
37 | + if ( ! defined('FS_TIMEOUT') ) { |
|
38 | + define('FS_TIMEOUT', 240); |
|
39 | + } |
|
39 | 40 | |
40 | - if ( empty($opt['port']) ) |
|
41 | - $this->options['port'] = 21; |
|
42 | - else |
|
43 | - $this->options['port'] = $opt['port']; |
|
41 | + if ( empty($opt['port']) ) { |
|
42 | + $this->options['port'] = 21; |
|
43 | + } else { |
|
44 | + $this->options['port'] = $opt['port']; |
|
45 | + } |
|
44 | 46 | |
45 | - if ( empty($opt['hostname']) ) |
|
46 | - $this->errors->add('empty_hostname', __('FTP hostname is required')); |
|
47 | - else |
|
48 | - $this->options['hostname'] = $opt['hostname']; |
|
47 | + if ( empty($opt['hostname']) ) { |
|
48 | + $this->errors->add('empty_hostname', __('FTP hostname is required')); |
|
49 | + } else { |
|
50 | + $this->options['hostname'] = $opt['hostname']; |
|
51 | + } |
|
49 | 52 | |
50 | 53 | // Check if the options provided are OK. |
51 | - if ( empty($opt['username']) ) |
|
52 | - $this->errors->add('empty_username', __('FTP username is required')); |
|
53 | - else |
|
54 | - $this->options['username'] = $opt['username']; |
|
54 | + if ( empty($opt['username']) ) { |
|
55 | + $this->errors->add('empty_username', __('FTP username is required')); |
|
56 | + } else { |
|
57 | + $this->options['username'] = $opt['username']; |
|
58 | + } |
|
55 | 59 | |
56 | - if ( empty($opt['password']) ) |
|
57 | - $this->errors->add('empty_password', __('FTP password is required')); |
|
58 | - else |
|
59 | - $this->options['password'] = $opt['password']; |
|
60 | + if ( empty($opt['password']) ) { |
|
61 | + $this->errors->add('empty_password', __('FTP password is required')); |
|
62 | + } else { |
|
63 | + $this->options['password'] = $opt['password']; |
|
64 | + } |
|
60 | 65 | |
61 | 66 | $this->options['ssl'] = false; |
62 | - if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) |
|
63 | - $this->options['ssl'] = true; |
|
67 | + if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] ) { |
|
68 | + $this->options['ssl'] = true; |
|
69 | + } |
|
64 | 70 | } |
65 | 71 | |
66 | 72 | /** |
@@ -69,10 +75,11 @@ discard block |
||
69 | 75 | * @return bool |
70 | 76 | */ |
71 | 77 | public function connect() { |
72 | - if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) |
|
73 | - $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
74 | - else |
|
75 | - $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
78 | + if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') ) { |
|
79 | + $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
80 | + } else { |
|
81 | + $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT); |
|
82 | + } |
|
76 | 83 | |
77 | 84 | if ( ! $this->link ) { |
78 | 85 | $this->errors->add( 'connect', |
@@ -96,8 +103,9 @@ discard block |
||
96 | 103 | |
97 | 104 | // Set the Connection to use Passive FTP |
98 | 105 | @ftp_pasv( $this->link, true ); |
99 | - if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) |
|
100 | - @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
|
106 | + if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT ) { |
|
107 | + @ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT); |
|
108 | + } |
|
101 | 109 | |
102 | 110 | return true; |
103 | 111 | } |
@@ -130,8 +138,9 @@ discard block |
||
130 | 138 | fseek( $temp, 0 ); // Skip back to the start of the file being written to |
131 | 139 | $contents = ''; |
132 | 140 | |
133 | - while ( ! feof($temp) ) |
|
134 | - $contents .= fread($temp, 8192); |
|
141 | + while ( ! feof($temp) ) { |
|
142 | + $contents .= fread($temp, 8192); |
|
143 | + } |
|
135 | 144 | |
136 | 145 | fclose($temp); |
137 | 146 | unlink($tempfile); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | */ |
198 | 207 | public function cwd() { |
199 | 208 | $cwd = @ftp_pwd($this->link); |
200 | - if ( $cwd ) |
|
201 | - $cwd = trailingslashit($cwd); |
|
209 | + if ( $cwd ) { |
|
210 | + $cwd = trailingslashit($cwd); |
|
211 | + } |
|
202 | 212 | return $cwd; |
203 | 213 | } |
204 | 214 | |
@@ -222,24 +232,27 @@ discard block |
||
222 | 232 | */ |
223 | 233 | public function chmod($file, $mode = false, $recursive = false) { |
224 | 234 | if ( ! $mode ) { |
225 | - if ( $this->is_file($file) ) |
|
226 | - $mode = FS_CHMOD_FILE; |
|
227 | - elseif ( $this->is_dir($file) ) |
|
228 | - $mode = FS_CHMOD_DIR; |
|
229 | - else |
|
230 | - return false; |
|
235 | + if ( $this->is_file($file) ) { |
|
236 | + $mode = FS_CHMOD_FILE; |
|
237 | + } elseif ( $this->is_dir($file) ) { |
|
238 | + $mode = FS_CHMOD_DIR; |
|
239 | + } else { |
|
240 | + return false; |
|
241 | + } |
|
231 | 242 | } |
232 | 243 | |
233 | 244 | // chmod any sub-objects if recursive. |
234 | 245 | if ( $recursive && $this->is_dir($file) ) { |
235 | 246 | $filelist = $this->dirlist($file); |
236 | - foreach ( (array)$filelist as $filename => $filemeta ) |
|
237 | - $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
247 | + foreach ( (array)$filelist as $filename => $filemeta ) { |
|
248 | + $this->chmod($file . '/' . $filename, $mode, $recursive); |
|
249 | + } |
|
238 | 250 | } |
239 | 251 | |
240 | 252 | // chmod the file or directory |
241 | - if ( ! function_exists('ftp_chmod') ) |
|
242 | - return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
253 | + if ( ! function_exists('ftp_chmod') ) { |
|
254 | + return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file)); |
|
255 | + } |
|
243 | 256 | return (bool)@ftp_chmod($this->link, $mode, $file); |
244 | 257 | } |
245 | 258 | |
@@ -285,11 +298,13 @@ discard block |
||
285 | 298 | * @return bool |
286 | 299 | */ |
287 | 300 | public function copy($source, $destination, $overwrite = false, $mode = false) { |
288 | - if ( ! $overwrite && $this->exists($destination) ) |
|
289 | - return false; |
|
301 | + if ( ! $overwrite && $this->exists($destination) ) { |
|
302 | + return false; |
|
303 | + } |
|
290 | 304 | $content = $this->get_contents($source); |
291 | - if ( false === $content ) |
|
292 | - return false; |
|
305 | + if ( false === $content ) { |
|
306 | + return false; |
|
307 | + } |
|
293 | 308 | return $this->put_contents($destination, $content, $mode); |
294 | 309 | } |
295 | 310 | |
@@ -314,17 +329,21 @@ discard block |
||
314 | 329 | * @return bool |
315 | 330 | */ |
316 | 331 | public function delete($file, $recursive = false, $type = false) { |
317 | - if ( empty($file) ) |
|
318 | - return false; |
|
319 | - if ( 'f' == $type || $this->is_file($file) ) |
|
320 | - return @ftp_delete($this->link, $file); |
|
321 | - if ( !$recursive ) |
|
322 | - return @ftp_rmdir($this->link, $file); |
|
332 | + if ( empty($file) ) { |
|
333 | + return false; |
|
334 | + } |
|
335 | + if ( 'f' == $type || $this->is_file($file) ) { |
|
336 | + return @ftp_delete($this->link, $file); |
|
337 | + } |
|
338 | + if ( !$recursive ) { |
|
339 | + return @ftp_rmdir($this->link, $file); |
|
340 | + } |
|
323 | 341 | |
324 | 342 | $filelist = $this->dirlist( trailingslashit($file) ); |
325 | - if ( !empty($filelist) ) |
|
326 | - foreach ( $filelist as $delete_file ) |
|
343 | + if ( !empty($filelist) ) { |
|
344 | + foreach ( $filelist as $delete_file ) |
|
327 | 345 | $this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] ); |
346 | + } |
|
328 | 347 | return @ftp_rmdir($this->link, $file); |
329 | 348 | } |
330 | 349 | |
@@ -441,11 +460,13 @@ discard block |
||
441 | 460 | */ |
442 | 461 | public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) { |
443 | 462 | $path = untrailingslashit($path); |
444 | - if ( empty($path) ) |
|
445 | - return false; |
|
463 | + if ( empty($path) ) { |
|
464 | + return false; |
|
465 | + } |
|
446 | 466 | |
447 | - if ( !@ftp_mkdir($this->link, $path) ) |
|
448 | - return false; |
|
467 | + if ( !@ftp_mkdir($this->link, $path) ) { |
|
468 | + return false; |
|
469 | + } |
|
449 | 470 | $this->chmod($path, $chmod); |
450 | 471 | return true; |
451 | 472 | } |
@@ -470,20 +491,24 @@ discard block |
||
470 | 491 | */ |
471 | 492 | public function parselisting($line) { |
472 | 493 | static $is_windows = null; |
473 | - if ( is_null($is_windows) ) |
|
474 | - $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
494 | + if ( is_null($is_windows) ) { |
|
495 | + $is_windows = stripos( ftp_systype($this->link), 'win') !== false; |
|
496 | + } |
|
475 | 497 | |
476 | 498 | if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) { |
477 | 499 | $b = array(); |
478 | - if ( $lucifer[3] < 70 ) |
|
479 | - $lucifer[3] +=2000; |
|
480 | - else |
|
481 | - $lucifer[3] += 1900; // 4digit year fix |
|
500 | + if ( $lucifer[3] < 70 ) { |
|
501 | + $lucifer[3] +=2000; |
|
502 | + } else { |
|
503 | + $lucifer[3] += 1900; |
|
504 | + } |
|
505 | + // 4digit year fix |
|
482 | 506 | $b['isdir'] = ( $lucifer[7] == '<DIR>'); |
483 | - if ( $b['isdir'] ) |
|
484 | - $b['type'] = 'd'; |
|
485 | - else |
|
486 | - $b['type'] = 'f'; |
|
507 | + if ( $b['isdir'] ) { |
|
508 | + $b['type'] = 'd'; |
|
509 | + } else { |
|
510 | + $b['type'] = 'f'; |
|
511 | + } |
|
487 | 512 | $b['size'] = $lucifer[7]; |
488 | 513 | $b['month'] = $lucifer[1]; |
489 | 514 | $b['day'] = $lucifer[2]; |
@@ -496,17 +521,19 @@ discard block |
||
496 | 521 | } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) { |
497 | 522 | //echo $line."\n"; |
498 | 523 | $lcount = count($lucifer); |
499 | - if ( $lcount < 8 ) |
|
500 | - return ''; |
|
524 | + if ( $lcount < 8 ) { |
|
525 | + return ''; |
|
526 | + } |
|
501 | 527 | $b = array(); |
502 | 528 | $b['isdir'] = $lucifer[0]{0} === 'd'; |
503 | 529 | $b['islink'] = $lucifer[0]{0} === 'l'; |
504 | - if ( $b['isdir'] ) |
|
505 | - $b['type'] = 'd'; |
|
506 | - elseif ( $b['islink'] ) |
|
507 | - $b['type'] = 'l'; |
|
508 | - else |
|
509 | - $b['type'] = 'f'; |
|
530 | + if ( $b['isdir'] ) { |
|
531 | + $b['type'] = 'd'; |
|
532 | + } elseif ( $b['islink'] ) { |
|
533 | + $b['type'] = 'l'; |
|
534 | + } else { |
|
535 | + $b['type'] = 'f'; |
|
536 | + } |
|
510 | 537 | $b['perms'] = $lucifer[0]; |
511 | 538 | $b['permsn'] = $this->getnumchmodfromh( $b['perms'] ); |
512 | 539 | $b['number'] = $lucifer[1]; |
@@ -560,28 +587,36 @@ discard block |
||
560 | 587 | } |
561 | 588 | |
562 | 589 | $pwd = @ftp_pwd($this->link); |
563 | - if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist |
|
590 | + if ( ! @ftp_chdir($this->link, $path) ) { |
|
591 | + // Cant change to folder = folder doesn't exist |
|
564 | 592 | return false; |
593 | + } |
|
565 | 594 | $list = @ftp_rawlist($this->link, '-a', false); |
566 | 595 | @ftp_chdir($this->link, $pwd); |
567 | 596 | |
568 | - if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least) |
|
597 | + if ( empty($list) ) { |
|
598 | + // Empty array = non-existent folder (real folder will show . at least) |
|
569 | 599 | return false; |
600 | + } |
|
570 | 601 | |
571 | 602 | $dirlist = array(); |
572 | 603 | foreach ( $list as $k => $v ) { |
573 | 604 | $entry = $this->parselisting($v); |
574 | - if ( empty($entry) ) |
|
575 | - continue; |
|
605 | + if ( empty($entry) ) { |
|
606 | + continue; |
|
607 | + } |
|
576 | 608 | |
577 | - if ( '.' == $entry['name'] || '..' == $entry['name'] ) |
|
578 | - continue; |
|
609 | + if ( '.' == $entry['name'] || '..' == $entry['name'] ) { |
|
610 | + continue; |
|
611 | + } |
|
579 | 612 | |
580 | - if ( ! $include_hidden && '.' == $entry['name'][0] ) |
|
581 | - continue; |
|
613 | + if ( ! $include_hidden && '.' == $entry['name'][0] ) { |
|
614 | + continue; |
|
615 | + } |
|
582 | 616 | |
583 | - if ( $limit_file && $entry['name'] != $limit_file) |
|
584 | - continue; |
|
617 | + if ( $limit_file && $entry['name'] != $limit_file) { |
|
618 | + continue; |
|
619 | + } |
|
585 | 620 | |
586 | 621 | $dirlist[ $entry['name'] ] = $entry; |
587 | 622 | } |
@@ -589,10 +624,11 @@ discard block |
||
589 | 624 | $ret = array(); |
590 | 625 | foreach ( (array)$dirlist as $struc ) { |
591 | 626 | if ( 'd' == $struc['type'] ) { |
592 | - if ( $recursive ) |
|
593 | - $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
594 | - else |
|
595 | - $struc['files'] = array(); |
|
627 | + if ( $recursive ) { |
|
628 | + $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive); |
|
629 | + } else { |
|
630 | + $struc['files'] = array(); |
|
631 | + } |
|
596 | 632 | } |
597 | 633 | |
598 | 634 | $ret[ $struc['name'] ] = $struc; |
@@ -604,7 +640,8 @@ discard block |
||
604 | 640 | * @access public |
605 | 641 | */ |
606 | 642 | public function __destruct() { |
607 | - if ( $this->link ) |
|
608 | - ftp_close($this->link); |
|
643 | + if ( $this->link ) { |
|
644 | + ftp_close($this->link); |
|
645 | + } |
|
609 | 646 | } |
610 | 647 | } |
@@ -153,7 +153,7 @@ |
||
153 | 153 | * |
154 | 154 | * @param string $file |
155 | 155 | * @param string $contents |
156 | - * @param bool|int $mode |
|
156 | + * @param string|boolean $mode |
|
157 | 157 | * @return bool |
158 | 158 | */ |
159 | 159 | public function put_contents($file, $contents, $mode = false ) { |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return mixed Comment post ID on success. |
26 | 26 | */ |
27 | -function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) { |
|
27 | +function comment_exists($comment_author, $comment_date, $timezone = 'blog') { |
|
28 | 28 | global $wpdb; |
29 | 29 | |
30 | 30 | $date_field = 'comment_date'; |
31 | - if ( 'gmt' === $timezone ) { |
|
31 | + if ('gmt' === $timezone) { |
|
32 | 32 | $date_field = 'comment_date_gmt'; |
33 | 33 | } |
34 | 34 | |
35 | - return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
35 | + return $wpdb->get_var($wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments |
|
36 | 36 | WHERE comment_author = %s AND $date_field = %s", |
37 | - stripslashes( $comment_author ), |
|
38 | - stripslashes( $comment_date ) |
|
39 | - ) ); |
|
37 | + stripslashes($comment_author), |
|
38 | + stripslashes($comment_date) |
|
39 | + )); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,44 +45,44 @@ discard block |
||
45 | 45 | * @since 2.0.0 |
46 | 46 | */ |
47 | 47 | function edit_comment() { |
48 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
49 | - wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
48 | + if ( ! current_user_can('edit_comment', (int) $_POST['comment_ID'])) |
|
49 | + wp_die(__('Sorry, you are not allowed to edit comments on this post.')); |
|
50 | 50 | |
51 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
51 | + if (isset($_POST['newcomment_author'])) |
|
52 | 52 | $_POST['comment_author'] = $_POST['newcomment_author']; |
53 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
53 | + if (isset($_POST['newcomment_author_email'])) |
|
54 | 54 | $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
55 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
55 | + if (isset($_POST['newcomment_author_url'])) |
|
56 | 56 | $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
57 | - if ( isset( $_POST['comment_status'] ) ) |
|
57 | + if (isset($_POST['comment_status'])) |
|
58 | 58 | $_POST['comment_approved'] = $_POST['comment_status']; |
59 | - if ( isset( $_POST['content'] ) ) |
|
59 | + if (isset($_POST['content'])) |
|
60 | 60 | $_POST['comment_content'] = $_POST['content']; |
61 | - if ( isset( $_POST['comment_ID'] ) ) |
|
61 | + if (isset($_POST['comment_ID'])) |
|
62 | 62 | $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
63 | 63 | |
64 | - foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
|
65 | - if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
|
64 | + foreach (array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit) { |
|
65 | + if ( ! empty($_POST['hidden_'.$timeunit]) && $_POST['hidden_'.$timeunit] != $_POST[$timeunit]) { |
|
66 | 66 | $_POST['edit_date'] = '1'; |
67 | 67 | break; |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - if ( !empty ( $_POST['edit_date'] ) ) { |
|
71 | + if ( ! empty ($_POST['edit_date'])) { |
|
72 | 72 | $aa = $_POST['aa']; |
73 | 73 | $mm = $_POST['mm']; |
74 | 74 | $jj = $_POST['jj']; |
75 | 75 | $hh = $_POST['hh']; |
76 | 76 | $mn = $_POST['mn']; |
77 | 77 | $ss = $_POST['ss']; |
78 | - $jj = ($jj > 31 ) ? 31 : $jj; |
|
79 | - $hh = ($hh > 23 ) ? $hh -24 : $hh; |
|
80 | - $mn = ($mn > 59 ) ? $mn -60 : $mn; |
|
81 | - $ss = ($ss > 59 ) ? $ss -60 : $ss; |
|
78 | + $jj = ($jj > 31) ? 31 : $jj; |
|
79 | + $hh = ($hh > 23) ? $hh - 24 : $hh; |
|
80 | + $mn = ($mn > 59) ? $mn - 60 : $mn; |
|
81 | + $ss = ($ss > 59) ? $ss - 60 : $ss; |
|
82 | 82 | $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; |
83 | 83 | } |
84 | 84 | |
85 | - wp_update_comment( $_POST ); |
|
85 | + wp_update_comment($_POST); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | * @param int $id ID of comment to retrieve. |
94 | 94 | * @return WP_Comment|false Comment if found. False on failure. |
95 | 95 | */ |
96 | -function get_comment_to_edit( $id ) { |
|
97 | - if ( !$comment = get_comment($id) ) |
|
96 | +function get_comment_to_edit($id) { |
|
97 | + if ( ! $comment = get_comment($id)) |
|
98 | 98 | return false; |
99 | 99 | |
100 | 100 | $comment->comment_ID = (int) $comment->comment_ID; |
101 | 101 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
102 | 102 | |
103 | - $comment->comment_content = format_to_edit( $comment->comment_content ); |
|
103 | + $comment->comment_content = format_to_edit($comment->comment_content); |
|
104 | 104 | /** |
105 | 105 | * Filters the comment content before editing. |
106 | 106 | * |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $comment->comment_content Comment content. |
110 | 110 | */ |
111 | - $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); |
|
111 | + $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); |
|
112 | 112 | |
113 | - $comment->comment_author = format_to_edit( $comment->comment_author ); |
|
114 | - $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); |
|
115 | - $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); |
|
113 | + $comment->comment_author = format_to_edit($comment->comment_author); |
|
114 | + $comment->comment_author_email = format_to_edit($comment->comment_author_email); |
|
115 | + $comment->comment_author_url = format_to_edit($comment->comment_author_url); |
|
116 | 116 | $comment->comment_author_url = esc_url($comment->comment_author_url); |
117 | 117 | |
118 | 118 | return $comment; |
@@ -128,23 +128,23 @@ discard block |
||
128 | 128 | * @param int|array $post_id Either a single Post ID or an array of Post IDs |
129 | 129 | * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs |
130 | 130 | */ |
131 | -function get_pending_comments_num( $post_id ) { |
|
131 | +function get_pending_comments_num($post_id) { |
|
132 | 132 | global $wpdb; |
133 | 133 | |
134 | 134 | $single = false; |
135 | - if ( !is_array($post_id) ) { |
|
135 | + if ( ! is_array($post_id)) { |
|
136 | 136 | $post_id_array = (array) $post_id; |
137 | 137 | $single = true; |
138 | 138 | } else { |
139 | 139 | $post_id_array = $post_id; |
140 | 140 | } |
141 | 141 | $post_id_array = array_map('intval', $post_id_array); |
142 | - $post_id_in = "'" . implode("', '", $post_id_array) . "'"; |
|
142 | + $post_id_in = "'".implode("', '", $post_id_array)."'"; |
|
143 | 143 | |
144 | - $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
|
144 | + $pending = $wpdb->get_results("SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A); |
|
145 | 145 | |
146 | - if ( $single ) { |
|
147 | - if ( empty($pending) ) |
|
146 | + if ($single) { |
|
147 | + if (empty($pending)) |
|
148 | 148 | return 0; |
149 | 149 | else |
150 | 150 | return absint($pending[0]['num_comments']); |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | $pending_keyed = array(); |
154 | 154 | |
155 | 155 | // Default to zero pending for all posts in request |
156 | - foreach ( $post_id_array as $id ) |
|
156 | + foreach ($post_id_array as $id) |
|
157 | 157 | $pending_keyed[$id] = 0; |
158 | 158 | |
159 | - if ( !empty($pending) ) |
|
160 | - foreach ( $pending as $pend ) |
|
159 | + if ( ! empty($pending)) |
|
160 | + foreach ($pending as $pend) |
|
161 | 161 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
162 | 162 | |
163 | 163 | return $pending_keyed; |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param string $name User name. |
172 | 172 | * @return string Avatar with Admin name. |
173 | 173 | */ |
174 | -function floated_admin_avatar( $name ) { |
|
175 | - $avatar = get_avatar( get_comment(), 32, 'mystery' ); |
|
174 | +function floated_admin_avatar($name) { |
|
175 | + $avatar = get_avatar(get_comment(), 32, 'mystery'); |
|
176 | 176 | return "$avatar $name"; |
177 | 177 | } |
178 | 178 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * @since 2.7.0 |
181 | 181 | */ |
182 | 182 | function enqueue_comment_hotkeys_js() { |
183 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
184 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
183 | + if ('true' == get_user_option('comment_shortcuts')) |
|
184 | + wp_enqueue_script('jquery-table-hotkeys'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param string $msg Error Message. Assumed to contain HTML and be sanitized. |
191 | 191 | */ |
192 | -function comment_footer_die( $msg ) { |
|
192 | +function comment_footer_die($msg) { |
|
193 | 193 | echo "<div class='wrap'><p>$msg</p></div>"; |
194 | - include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
194 | + include(ABSPATH.'wp-admin/admin-footer.php'); |
|
195 | 195 | die; |
196 | 196 | } |
197 | 197 | \ No newline at end of file |
@@ -45,21 +45,28 @@ discard block |
||
45 | 45 | * @since 2.0.0 |
46 | 46 | */ |
47 | 47 | function edit_comment() { |
48 | - if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) |
|
49 | - wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
50 | - |
|
51 | - if ( isset( $_POST['newcomment_author'] ) ) |
|
52 | - $_POST['comment_author'] = $_POST['newcomment_author']; |
|
53 | - if ( isset( $_POST['newcomment_author_email'] ) ) |
|
54 | - $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
55 | - if ( isset( $_POST['newcomment_author_url'] ) ) |
|
56 | - $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
57 | - if ( isset( $_POST['comment_status'] ) ) |
|
58 | - $_POST['comment_approved'] = $_POST['comment_status']; |
|
59 | - if ( isset( $_POST['content'] ) ) |
|
60 | - $_POST['comment_content'] = $_POST['content']; |
|
61 | - if ( isset( $_POST['comment_ID'] ) ) |
|
62 | - $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
48 | + if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { |
|
49 | + wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); |
|
50 | + } |
|
51 | + |
|
52 | + if ( isset( $_POST['newcomment_author'] ) ) { |
|
53 | + $_POST['comment_author'] = $_POST['newcomment_author']; |
|
54 | + } |
|
55 | + if ( isset( $_POST['newcomment_author_email'] ) ) { |
|
56 | + $_POST['comment_author_email'] = $_POST['newcomment_author_email']; |
|
57 | + } |
|
58 | + if ( isset( $_POST['newcomment_author_url'] ) ) { |
|
59 | + $_POST['comment_author_url'] = $_POST['newcomment_author_url']; |
|
60 | + } |
|
61 | + if ( isset( $_POST['comment_status'] ) ) { |
|
62 | + $_POST['comment_approved'] = $_POST['comment_status']; |
|
63 | + } |
|
64 | + if ( isset( $_POST['content'] ) ) { |
|
65 | + $_POST['comment_content'] = $_POST['content']; |
|
66 | + } |
|
67 | + if ( isset( $_POST['comment_ID'] ) ) { |
|
68 | + $_POST['comment_ID'] = (int) $_POST['comment_ID']; |
|
69 | + } |
|
63 | 70 | |
64 | 71 | foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { |
65 | 72 | if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { |
@@ -94,8 +101,9 @@ discard block |
||
94 | 101 | * @return WP_Comment|false Comment if found. False on failure. |
95 | 102 | */ |
96 | 103 | function get_comment_to_edit( $id ) { |
97 | - if ( !$comment = get_comment($id) ) |
|
98 | - return false; |
|
104 | + if ( !$comment = get_comment($id) ) { |
|
105 | + return false; |
|
106 | + } |
|
99 | 107 | |
100 | 108 | $comment->comment_ID = (int) $comment->comment_ID; |
101 | 109 | $comment->comment_post_ID = (int) $comment->comment_post_ID; |
@@ -144,21 +152,24 @@ discard block |
||
144 | 152 | $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); |
145 | 153 | |
146 | 154 | if ( $single ) { |
147 | - if ( empty($pending) ) |
|
148 | - return 0; |
|
149 | - else |
|
150 | - return absint($pending[0]['num_comments']); |
|
155 | + if ( empty($pending) ) { |
|
156 | + return 0; |
|
157 | + } else { |
|
158 | + return absint($pending[0]['num_comments']); |
|
159 | + } |
|
151 | 160 | } |
152 | 161 | |
153 | 162 | $pending_keyed = array(); |
154 | 163 | |
155 | 164 | // Default to zero pending for all posts in request |
156 | - foreach ( $post_id_array as $id ) |
|
157 | - $pending_keyed[$id] = 0; |
|
165 | + foreach ( $post_id_array as $id ) { |
|
166 | + $pending_keyed[$id] = 0; |
|
167 | + } |
|
158 | 168 | |
159 | - if ( !empty($pending) ) |
|
160 | - foreach ( $pending as $pend ) |
|
169 | + if ( !empty($pending) ) { |
|
170 | + foreach ( $pending as $pend ) |
|
161 | 171 | $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); |
172 | + } |
|
162 | 173 | |
163 | 174 | return $pending_keyed; |
164 | 175 | } |
@@ -180,9 +191,10 @@ discard block |
||
180 | 191 | * @since 2.7.0 |
181 | 192 | */ |
182 | 193 | function enqueue_comment_hotkeys_js() { |
183 | - if ( 'true' == get_user_option( 'comment_shortcuts' ) ) |
|
184 | - wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
185 | -} |
|
194 | + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { |
|
195 | + wp_enqueue_script( 'jquery-table-hotkeys' ); |
|
196 | + } |
|
197 | + } |
|
186 | 198 | |
187 | 199 | /** |
188 | 200 | * Display error message at bottom of comments. |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * @subpackage Administration |
10 | 10 | */ |
11 | 11 | |
12 | -_deprecated_file( basename(__FILE__), '2.5.0', 'wp-admin/includes/admin.php' ); |
|
12 | +_deprecated_file(basename(__FILE__), '2.5.0', 'wp-admin/includes/admin.php'); |
|
13 | 13 | |
14 | 14 | /** WordPress Administration API: Includes all Administration functions. */ |
15 | -require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
15 | +require_once(ABSPATH.'wp-admin/includes/admin.php'); |