@@ -126,6 +126,9 @@ discard block |
||
126 | 126 | return true; |
127 | 127 | } |
128 | 128 | |
129 | + /** |
|
130 | + * @param integer $version |
|
131 | + */ |
|
129 | 132 | public function getLyrics3Data($endoffset, $version, $length) { |
130 | 133 | // http://www.volweb.cz/str/tags.htm |
131 | 134 | |
@@ -287,6 +290,9 @@ discard block |
||
287 | 290 | return true; |
288 | 291 | } |
289 | 292 | |
293 | + /** |
|
294 | + * @param string $char |
|
295 | + */ |
|
290 | 296 | public function IntString2Bool($char) { |
291 | 297 | if ($char == '1') { |
292 | 298 | return true; |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | |
24 | 24 | // http://www.volweb.cz/str/tags.htm |
25 | 25 | |
26 | - if (!getid3_lib::intValueSupported($info['filesize'])) { |
|
26 | + if ( ! getid3_lib::intValueSupported($info['filesize'])) { |
|
27 | 27 | $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
31 | - $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
|
31 | + $this->fseek((0 - 128 - 9 - 6), SEEK_END); // end - ID3v1 - "LYRICSEND" - [Lyrics3size] |
|
32 | 32 | $lyrics3_id3v1 = $this->fread(128 + 9 + 6); |
33 | - $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
|
34 | - $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
|
33 | + $lyrics3lsz = substr($lyrics3_id3v1, 0, 6); // Lyrics3size |
|
34 | + $lyrics3end = substr($lyrics3_id3v1, 6, 9); // LYRICSEND or LYRICS200 |
|
35 | 35 | $id3v1tag = substr($lyrics3_id3v1, 15, 128); // ID3v1 |
36 | 36 | |
37 | 37 | if ($lyrics3end == 'LYRICSEND') { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $info['avdataend'] = $lyrics3offset; |
101 | 101 | $this->getLyrics3Data($lyrics3offset, $lyrics3version, $lyrics3size); |
102 | 102 | |
103 | - if (!isset($info['ape'])) { |
|
103 | + if ( ! isset($info['ape'])) { |
|
104 | 104 | if (isset($info['lyrics3']['tag_offset_start'])) { |
105 | 105 | $GETID3_ERRORARRAY = &$info['warning']; |
106 | 106 | getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | $getid3_apetag = new getid3_apetag($getid3_temp); |
110 | 110 | $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start']; |
111 | 111 | $getid3_apetag->Analyze(); |
112 | - if (!empty($getid3_temp->info['ape'])) { |
|
112 | + if ( ! empty($getid3_temp->info['ape'])) { |
|
113 | 113 | $info['ape'] = $getid3_temp->info['ape']; |
114 | 114 | } |
115 | - if (!empty($getid3_temp->info['replay_gain'])) { |
|
115 | + if ( ! empty($getid3_temp->info['replay_gain'])) { |
|
116 | 116 | $info['replay_gain'] = $getid3_temp->info['replay_gain']; |
117 | 117 | } |
118 | 118 | unset($getid3_temp, $getid3_apetag); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | $info = &$this->getid3->info; |
133 | 133 | |
134 | - if (!getid3_lib::intValueSupported($endoffset)) { |
|
134 | + if ( ! getid3_lib::intValueSupported($endoffset)) { |
|
135 | 135 | $info['warning'][] = 'Unable to check for Lyrics3 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB'; |
136 | 136 | return false; |
137 | 137 | } |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | foreach ($imagestrings as $key => $imagestring) { |
212 | 212 | if (strpos($imagestring, '||') !== false) { |
213 | 213 | $imagearray = explode('||', $imagestring); |
214 | - $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : ''); |
|
215 | - $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : ''); |
|
214 | + $ParsedLyrics3['images'][$key]['filename'] = (isset($imagearray[0]) ? $imagearray[0] : ''); |
|
215 | + $ParsedLyrics3['images'][$key]['description'] = (isset($imagearray[1]) ? $imagearray[1] : ''); |
|
216 | 216 | $ParsedLyrics3['images'][$key]['timestamp'] = $this->Lyrics3Timestamp2Seconds(isset($imagearray[2]) ? $imagearray[2] : ''); |
217 | 217 | } |
218 | 218 | } |
@@ -218,7 +218,7 @@ |
||
218 | 218 | * @global float $timestart Seconds from when timer_start() is called. |
219 | 219 | * @global float $timeend Seconds from when function is called. |
220 | 220 | * |
221 | - * @param int|bool $display Whether to echo or return the results. Accepts 0|false for return, |
|
221 | + * @param integer $display Whether to echo or return the results. Accepts 0|false for return, |
|
222 | 222 | * 1|true for echo. Default 0|false. |
223 | 223 | * @param int $precision The number of digits from the right of the decimal to display. |
224 | 224 | * Default 3. |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * These functions are needed to load WordPress. |
|
4 | - * |
|
5 | - * @internal This file must be parsable by PHP4. |
|
6 | - * |
|
7 | - * @package WordPress |
|
8 | - */ |
|
3 | + * These functions are needed to load WordPress. |
|
4 | + * |
|
5 | + * @internal This file must be parsable by PHP4. |
|
6 | + * |
|
7 | + * @package WordPress |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Turn register globals off. |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function wp_get_server_protocol() { |
18 | 18 | $protocol = $_SERVER['SERVER_PROTOCOL']; |
19 | - if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { |
|
19 | + if ( ! in_array($protocol, array('HTTP/1.1', 'HTTP/2', 'HTTP/2.0'))) { |
|
20 | 20 | $protocol = 'HTTP/1.0'; |
21 | 21 | } |
22 | 22 | return $protocol; |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | * @access private |
30 | 30 | */ |
31 | 31 | function wp_unregister_GLOBALS() { |
32 | - if ( !ini_get( 'register_globals' ) ) |
|
32 | + if ( ! ini_get('register_globals')) |
|
33 | 33 | return; |
34 | 34 | |
35 | - if ( isset( $_REQUEST['GLOBALS'] ) ) |
|
36 | - die( 'GLOBALS overwrite attempt detected' ); |
|
35 | + if (isset($_REQUEST['GLOBALS'])) |
|
36 | + die('GLOBALS overwrite attempt detected'); |
|
37 | 37 | |
38 | 38 | // Variables that shouldn't be unset |
39 | - $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
|
39 | + $no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); |
|
40 | 40 | |
41 | - $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
|
42 | - foreach ( $input as $k => $v ) |
|
43 | - if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
44 | - unset( $GLOBALS[$k] ); |
|
41 | + $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); |
|
42 | + foreach ($input as $k => $v) |
|
43 | + if ( ! in_array($k, $no_unset) && isset($GLOBALS[$k])) { |
|
44 | + unset($GLOBALS[$k]); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | 'REQUEST_URI' => '', |
63 | 63 | ); |
64 | 64 | |
65 | - $_SERVER = array_merge( $default_server_values, $_SERVER ); |
|
65 | + $_SERVER = array_merge($default_server_values, $_SERVER); |
|
66 | 66 | |
67 | 67 | // Fix for IIS when running with PHP ISAPI |
68 | - if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { |
|
68 | + if (empty($_SERVER['REQUEST_URI']) || (PHP_SAPI != 'cgi-fcgi' && preg_match('/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE']))) { |
|
69 | 69 | |
70 | 70 | // IIS Mod-Rewrite |
71 | - if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { |
|
71 | + if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { |
|
72 | 72 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; |
73 | 73 | } |
74 | 74 | // IIS Isapi_Rewrite |
75 | - elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { |
|
75 | + elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { |
|
76 | 76 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
77 | 77 | } else { |
78 | 78 | // Use ORIG_PATH_INFO if there is no PATH_INFO |
79 | - if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
|
79 | + if ( ! isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) |
|
80 | 80 | $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
81 | 81 | |
82 | 82 | // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
83 | - if ( isset( $_SERVER['PATH_INFO'] ) ) { |
|
84 | - if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
|
83 | + if (isset($_SERVER['PATH_INFO'])) { |
|
84 | + if ($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME']) |
|
85 | 85 | $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
86 | 86 | else |
87 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
87 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO']; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // Append the query string if it exists and isn't null |
91 | - if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
|
92 | - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
91 | + if ( ! empty($_SERVER['QUERY_STRING'])) { |
|
92 | + $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | 97 | // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
98 | - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
|
98 | + if (isset($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7)) |
|
99 | 99 | $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
100 | 100 | |
101 | 101 | // Fix for Dreamhost and other PHP as CGI hosts |
102 | - if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
|
103 | - unset( $_SERVER['PATH_INFO'] ); |
|
102 | + if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) |
|
103 | + unset($_SERVER['PATH_INFO']); |
|
104 | 104 | |
105 | 105 | // Fix empty PHP_SELF |
106 | 106 | $PHP_SELF = $_SERVER['PHP_SELF']; |
107 | - if ( empty( $PHP_SELF ) ) |
|
108 | - $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
107 | + if (empty($PHP_SELF)) |
|
108 | + $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace('/(\?.*)?$/', '', $_SERVER["REQUEST_URI"]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -124,22 +124,22 @@ discard block |
||
124 | 124 | global $required_php_version, $wp_version; |
125 | 125 | $php_version = phpversion(); |
126 | 126 | |
127 | - if ( version_compare( $required_php_version, $php_version, '>' ) ) { |
|
127 | + if (version_compare($required_php_version, $php_version, '>')) { |
|
128 | 128 | wp_load_translations_early(); |
129 | 129 | |
130 | 130 | $protocol = wp_get_server_protocol(); |
131 | - header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
|
132 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
133 | - die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) ); |
|
131 | + header(sprintf('%s 500 Internal Server Error', $protocol), true, 500); |
|
132 | + header('Content-Type: text/html; charset=utf-8'); |
|
133 | + die(sprintf(__('Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'), $php_version, $wp_version, $required_php_version)); |
|
134 | 134 | } |
135 | 135 | |
136 | - if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
|
136 | + if ( ! extension_loaded('mysql') && ! extension_loaded('mysqli') && ! extension_loaded('mysqlnd') && ! file_exists(WP_CONTENT_DIR.'/db.php')) { |
|
137 | 137 | wp_load_translations_early(); |
138 | 138 | |
139 | 139 | $protocol = wp_get_server_protocol(); |
140 | - header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); |
|
141 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
142 | - die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) ); |
|
140 | + header(sprintf('%s 500 Internal Server Error', $protocol), true, 500); |
|
141 | + header('Content-Type: text/html; charset=utf-8'); |
|
142 | + die(__('Your PHP installation appears to be missing the MySQL extension which is required by WordPress.')); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @since 3.0.0 |
152 | 152 | */ |
153 | 153 | function wp_favicon_request() { |
154 | - if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { |
|
154 | + if ('/favicon.ico' == $_SERVER['REQUEST_URI']) { |
|
155 | 155 | header('Content-Type: image/vnd.microsoft.icon'); |
156 | 156 | exit; |
157 | 157 | } |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | * @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
175 | 175 | */ |
176 | 176 | function wp_maintenance() { |
177 | - if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) |
|
177 | + if ( ! file_exists(ABSPATH.'.maintenance') || wp_installing()) |
|
178 | 178 | return; |
179 | 179 | |
180 | 180 | global $upgrading; |
181 | 181 | |
182 | - include( ABSPATH . '.maintenance' ); |
|
182 | + include(ABSPATH.'.maintenance'); |
|
183 | 183 | // If the $upgrading timestamp is older than 10 minutes, don't die. |
184 | - if ( ( time() - $upgrading ) >= 600 ) |
|
184 | + if ((time() - $upgrading) >= 600) |
|
185 | 185 | return; |
186 | 186 | |
187 | - if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
|
188 | - require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
|
187 | + if (file_exists(WP_CONTENT_DIR.'/maintenance.php')) { |
|
188 | + require_once(WP_CONTENT_DIR.'/maintenance.php'); |
|
189 | 189 | die(); |
190 | 190 | } |
191 | 191 | |
192 | 192 | wp_load_translations_early(); |
193 | 193 | |
194 | 194 | $protocol = wp_get_server_protocol(); |
195 | - header( "$protocol 503 Service Unavailable", true, 503 ); |
|
196 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
197 | - header( 'Retry-After: 600' ); |
|
195 | + header("$protocol 503 Service Unavailable", true, 503); |
|
196 | + header('Content-Type: text/html; charset=utf-8'); |
|
197 | + header('Retry-After: 600'); |
|
198 | 198 | ?> |
199 | 199 | <!DOCTYPE html> |
200 | - <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
200 | + <html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>> |
|
201 | 201 | <head> |
202 | 202 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
203 | - <title><?php _e( 'Maintenance' ); ?></title> |
|
203 | + <title><?php _e('Maintenance'); ?></title> |
|
204 | 204 | |
205 | 205 | </head> |
206 | 206 | <body> |
207 | - <h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1> |
|
207 | + <h1><?php _e('Briefly unavailable for scheduled maintenance. Check back in a minute.'); ?></h1> |
|
208 | 208 | </body> |
209 | 209 | </html> |
210 | 210 | <?php |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | function timer_start() { |
226 | 226 | global $timestart; |
227 | - $timestart = microtime( true ); |
|
227 | + $timestart = microtime(true); |
|
228 | 228 | return true; |
229 | 229 | } |
230 | 230 | |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | * @return string The "second.microsecond" finished time calculation. The number is formatted |
244 | 244 | * for human consumption, both localized and rounded. |
245 | 245 | */ |
246 | -function timer_stop( $display = 0, $precision = 3 ) { |
|
246 | +function timer_stop($display = 0, $precision = 3) { |
|
247 | 247 | global $timestart, $timeend; |
248 | - $timeend = microtime( true ); |
|
248 | + $timeend = microtime(true); |
|
249 | 249 | $timetotal = $timeend - $timestart; |
250 | - $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
|
251 | - if ( $display ) |
|
250 | + $r = (function_exists('number_format_i18n')) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); |
|
251 | + if ($display) |
|
252 | 252 | echo $r; |
253 | 253 | return $r; |
254 | 254 | } |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @access private |
286 | 286 | */ |
287 | 287 | function wp_debug_mode() { |
288 | - if ( WP_DEBUG ) { |
|
289 | - error_reporting( E_ALL ); |
|
288 | + if (WP_DEBUG) { |
|
289 | + error_reporting(E_ALL); |
|
290 | 290 | |
291 | - if ( WP_DEBUG_DISPLAY ) |
|
292 | - ini_set( 'display_errors', 1 ); |
|
293 | - elseif ( null !== WP_DEBUG_DISPLAY ) |
|
294 | - ini_set( 'display_errors', 0 ); |
|
291 | + if (WP_DEBUG_DISPLAY) |
|
292 | + ini_set('display_errors', 1); |
|
293 | + elseif (null !== WP_DEBUG_DISPLAY) |
|
294 | + ini_set('display_errors', 0); |
|
295 | 295 | |
296 | - if ( WP_DEBUG_LOG ) { |
|
297 | - ini_set( 'log_errors', 1 ); |
|
298 | - ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); |
|
296 | + if (WP_DEBUG_LOG) { |
|
297 | + ini_set('log_errors', 1); |
|
298 | + ini_set('error_log', WP_CONTENT_DIR.'/debug.log'); |
|
299 | 299 | } |
300 | 300 | } else { |
301 | - error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
|
301 | + error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
305 | - ini_set( 'display_errors', 0 ); |
|
304 | + if (defined('XMLRPC_REQUEST') || defined('REST_REQUEST') || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
305 | + ini_set('display_errors', 0); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * @access private |
321 | 321 | */ |
322 | 322 | function wp_set_lang_dir() { |
323 | - if ( !defined( 'WP_LANG_DIR' ) ) { |
|
324 | - if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) { |
|
323 | + if ( ! defined('WP_LANG_DIR')) { |
|
324 | + if (file_exists(WP_CONTENT_DIR.'/languages') && @is_dir(WP_CONTENT_DIR.'/languages') || ! @is_dir(ABSPATH.WPINC.'/languages')) { |
|
325 | 325 | /** |
326 | 326 | * Server path of the language directory. |
327 | 327 | * |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @since 2.1.0 |
331 | 331 | */ |
332 | - define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
333 | - if ( !defined( 'LANGDIR' ) ) { |
|
332 | + define('WP_LANG_DIR', WP_CONTENT_DIR.'/languages'); |
|
333 | + if ( ! defined('LANGDIR')) { |
|
334 | 334 | // Old static relative path maintained for limited backwards compatibility - won't work in some cases |
335 | - define( 'LANGDIR', 'wp-content/languages' ); |
|
335 | + define('LANGDIR', 'wp-content/languages'); |
|
336 | 336 | } |
337 | 337 | } else { |
338 | 338 | /** |
@@ -342,10 +342,10 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @since 2.1.0 |
344 | 344 | */ |
345 | - define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
346 | - if ( !defined( 'LANGDIR' ) ) { |
|
345 | + define('WP_LANG_DIR', ABSPATH.WPINC.'/languages'); |
|
346 | + if ( ! defined('LANGDIR')) { |
|
347 | 347 | // Old relative path maintained for backwards compatibility |
348 | - define( 'LANGDIR', WPINC . '/languages' ); |
|
348 | + define('LANGDIR', WPINC.'/languages'); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | function require_wp_db() { |
362 | 362 | global $wpdb; |
363 | 363 | |
364 | - require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
365 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
366 | - require_once( WP_CONTENT_DIR . '/db.php' ); |
|
364 | + require_once(ABSPATH.WPINC.'/wp-db.php'); |
|
365 | + if (file_exists(WP_CONTENT_DIR.'/db.php')) |
|
366 | + require_once(WP_CONTENT_DIR.'/db.php'); |
|
367 | 367 | |
368 | - if ( isset( $wpdb ) ) |
|
368 | + if (isset($wpdb)) |
|
369 | 369 | return; |
370 | 370 | |
371 | - $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
|
371 | + $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function wp_set_wpdb_vars() { |
387 | 387 | global $wpdb, $table_prefix; |
388 | - if ( !empty( $wpdb->error ) ) |
|
388 | + if ( ! empty($wpdb->error)) |
|
389 | 389 | dead_db(); |
390 | 390 | |
391 | - $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
392 | - 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
391 | + $wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
392 | + 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
393 | 393 | 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', |
394 | 394 | 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', |
395 | 395 | // multisite: |
396 | 396 | 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', |
397 | 397 | ); |
398 | 398 | |
399 | - $prefix = $wpdb->set_prefix( $table_prefix ); |
|
399 | + $prefix = $wpdb->set_prefix($table_prefix); |
|
400 | 400 | |
401 | - if ( is_wp_error( $prefix ) ) { |
|
401 | + if (is_wp_error($prefix)) { |
|
402 | 402 | wp_load_translations_early(); |
403 | 403 | wp_die( |
404 | 404 | /* translators: 1: $table_prefix 2: wp-config.php */ |
405 | - sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
|
405 | + sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'), |
|
406 | 406 | '<code>$table_prefix</code>', |
407 | 407 | '<code>wp-config.php</code>' |
408 | 408 | ) |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | * @param bool $using Whether external object cache is being used. |
422 | 422 | * @return bool The current 'using' setting. |
423 | 423 | */ |
424 | -function wp_using_ext_object_cache( $using = null ) { |
|
424 | +function wp_using_ext_object_cache($using = null) { |
|
425 | 425 | global $_wp_using_ext_object_cache; |
426 | 426 | $current_using = $_wp_using_ext_object_cache; |
427 | - if ( null !== $using ) |
|
427 | + if (null !== $using) |
|
428 | 428 | $_wp_using_ext_object_cache = $using; |
429 | 429 | return $current_using; |
430 | 430 | } |
@@ -444,40 +444,40 @@ discard block |
||
444 | 444 | global $blog_id; |
445 | 445 | |
446 | 446 | $first_init = false; |
447 | - if ( ! function_exists( 'wp_cache_init' ) ) { |
|
448 | - if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
449 | - require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
|
450 | - if ( function_exists( 'wp_cache_init' ) ) |
|
451 | - wp_using_ext_object_cache( true ); |
|
447 | + if ( ! function_exists('wp_cache_init')) { |
|
448 | + if (file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
449 | + require_once (WP_CONTENT_DIR.'/object-cache.php'); |
|
450 | + if (function_exists('wp_cache_init')) |
|
451 | + wp_using_ext_object_cache(true); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | $first_init = true; |
455 | - } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
455 | + } elseif ( ! wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
456 | 456 | /* |
457 | 457 | * Sometimes advanced-cache.php can load object-cache.php before |
458 | 458 | * it is loaded here. This breaks the function_exists check above |
459 | 459 | * and can result in `$_wp_using_ext_object_cache` being set |
460 | 460 | * incorrectly. Double check if an external cache exists. |
461 | 461 | */ |
462 | - wp_using_ext_object_cache( true ); |
|
462 | + wp_using_ext_object_cache(true); |
|
463 | 463 | } |
464 | 464 | |
465 | - if ( ! wp_using_ext_object_cache() ) |
|
466 | - require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
465 | + if ( ! wp_using_ext_object_cache()) |
|
466 | + require_once (ABSPATH.WPINC.'/cache.php'); |
|
467 | 467 | |
468 | 468 | /* |
469 | 469 | * If cache supports reset, reset instead of init if already |
470 | 470 | * initialized. Reset signals to the cache that global IDs |
471 | 471 | * have changed and it may need to update keys and cleanup caches. |
472 | 472 | */ |
473 | - if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
|
474 | - wp_cache_switch_to_blog( $blog_id ); |
|
475 | - elseif ( function_exists( 'wp_cache_init' ) ) |
|
473 | + if ( ! $first_init && function_exists('wp_cache_switch_to_blog')) |
|
474 | + wp_cache_switch_to_blog($blog_id); |
|
475 | + elseif (function_exists('wp_cache_init')) |
|
476 | 476 | wp_cache_init(); |
477 | 477 | |
478 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
479 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
480 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
478 | + if (function_exists('wp_cache_add_global_groups')) { |
|
479 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
480 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
@@ -490,22 +490,22 @@ discard block |
||
490 | 490 | * @access private |
491 | 491 | */ |
492 | 492 | function wp_not_installed() { |
493 | - if ( is_multisite() ) { |
|
494 | - if ( ! is_blog_installed() && ! wp_installing() ) { |
|
493 | + if (is_multisite()) { |
|
494 | + if ( ! is_blog_installed() && ! wp_installing()) { |
|
495 | 495 | nocache_headers(); |
496 | 496 | |
497 | - wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
|
497 | + wp_die(__('The site you have requested is not installed properly. Please contact the system administrator.')); |
|
498 | 498 | } |
499 | - } elseif ( ! is_blog_installed() && ! wp_installing() ) { |
|
499 | + } elseif ( ! is_blog_installed() && ! wp_installing()) { |
|
500 | 500 | nocache_headers(); |
501 | 501 | |
502 | - require( ABSPATH . WPINC . '/kses.php' ); |
|
503 | - require( ABSPATH . WPINC . '/pluggable.php' ); |
|
504 | - require( ABSPATH . WPINC . '/formatting.php' ); |
|
502 | + require(ABSPATH.WPINC.'/kses.php'); |
|
503 | + require(ABSPATH.WPINC.'/pluggable.php'); |
|
504 | + require(ABSPATH.WPINC.'/formatting.php'); |
|
505 | 505 | |
506 | - $link = wp_guess_url() . '/wp-admin/install.php'; |
|
506 | + $link = wp_guess_url().'/wp-admin/install.php'; |
|
507 | 507 | |
508 | - wp_redirect( $link ); |
|
508 | + wp_redirect($link); |
|
509 | 509 | die(); |
510 | 510 | } |
511 | 511 | } |
@@ -524,16 +524,16 @@ discard block |
||
524 | 524 | */ |
525 | 525 | function wp_get_mu_plugins() { |
526 | 526 | $mu_plugins = array(); |
527 | - if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
527 | + if ( ! is_dir(WPMU_PLUGIN_DIR)) |
|
528 | 528 | return $mu_plugins; |
529 | - if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
529 | + if ( ! $dh = opendir(WPMU_PLUGIN_DIR)) |
|
530 | 530 | return $mu_plugins; |
531 | - while ( ( $plugin = readdir( $dh ) ) !== false ) { |
|
532 | - if ( substr( $plugin, -4 ) == '.php' ) |
|
533 | - $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
531 | + while (($plugin = readdir($dh)) !== false) { |
|
532 | + if (substr($plugin, -4) == '.php') |
|
533 | + $mu_plugins[] = WPMU_PLUGIN_DIR.'/'.$plugin; |
|
534 | 534 | } |
535 | - closedir( $dh ); |
|
536 | - sort( $mu_plugins ); |
|
535 | + closedir($dh); |
|
536 | + sort($mu_plugins); |
|
537 | 537 | |
538 | 538 | return $mu_plugins; |
539 | 539 | } |
@@ -554,27 +554,27 @@ discard block |
||
554 | 554 | */ |
555 | 555 | function wp_get_active_and_valid_plugins() { |
556 | 556 | $plugins = array(); |
557 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
557 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
558 | 558 | |
559 | 559 | // Check for hacks file if the option is enabled |
560 | - if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
|
561 | - _deprecated_file( 'my-hacks.php', '1.5' ); |
|
562 | - array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
|
560 | + if (get_option('hack_file') && file_exists(ABSPATH.'my-hacks.php')) { |
|
561 | + _deprecated_file('my-hacks.php', '1.5'); |
|
562 | + array_unshift($plugins, ABSPATH.'my-hacks.php'); |
|
563 | 563 | } |
564 | 564 | |
565 | - if ( empty( $active_plugins ) || wp_installing() ) |
|
565 | + if (empty($active_plugins) || wp_installing()) |
|
566 | 566 | return $plugins; |
567 | 567 | |
568 | 568 | $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
569 | 569 | |
570 | - foreach ( $active_plugins as $plugin ) { |
|
571 | - if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
572 | - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
573 | - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
570 | + foreach ($active_plugins as $plugin) { |
|
571 | + if ( ! validate_file($plugin) // $plugin must validate as file |
|
572 | + && '.php' == substr($plugin, -4) // $plugin must end with '.php' |
|
573 | + && file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist |
|
574 | 574 | // not already included as a network plugin |
575 | - && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
|
575 | + && ( ! $network_plugins || ! in_array(WP_PLUGIN_DIR.'/'.$plugin, $network_plugins)) |
|
576 | 576 | ) |
577 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
577 | + $plugins[] = WP_PLUGIN_DIR.'/'.$plugin; |
|
578 | 578 | } |
579 | 579 | return $plugins; |
580 | 580 | } |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | * @access private |
590 | 590 | */ |
591 | 591 | function wp_set_internal_encoding() { |
592 | - if ( function_exists( 'mb_internal_encoding' ) ) { |
|
593 | - $charset = get_option( 'blog_charset' ); |
|
594 | - if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
595 | - mb_internal_encoding( 'UTF-8' ); |
|
592 | + if (function_exists('mb_internal_encoding')) { |
|
593 | + $charset = get_option('blog_charset'); |
|
594 | + if ( ! $charset || ! @mb_internal_encoding($charset)) |
|
595 | + mb_internal_encoding('UTF-8'); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -607,20 +607,20 @@ discard block |
||
607 | 607 | */ |
608 | 608 | function wp_magic_quotes() { |
609 | 609 | // If already slashed, strip. |
610 | - if ( get_magic_quotes_gpc() ) { |
|
611 | - $_GET = stripslashes_deep( $_GET ); |
|
612 | - $_POST = stripslashes_deep( $_POST ); |
|
613 | - $_COOKIE = stripslashes_deep( $_COOKIE ); |
|
610 | + if (get_magic_quotes_gpc()) { |
|
611 | + $_GET = stripslashes_deep($_GET); |
|
612 | + $_POST = stripslashes_deep($_POST); |
|
613 | + $_COOKIE = stripslashes_deep($_COOKIE); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | // Escape with wpdb. |
617 | - $_GET = add_magic_quotes( $_GET ); |
|
618 | - $_POST = add_magic_quotes( $_POST ); |
|
619 | - $_COOKIE = add_magic_quotes( $_COOKIE ); |
|
620 | - $_SERVER = add_magic_quotes( $_SERVER ); |
|
617 | + $_GET = add_magic_quotes($_GET); |
|
618 | + $_POST = add_magic_quotes($_POST); |
|
619 | + $_COOKIE = add_magic_quotes($_COOKIE); |
|
620 | + $_SERVER = add_magic_quotes($_SERVER); |
|
621 | 621 | |
622 | 622 | // Force REQUEST to be GET + POST. |
623 | - $_REQUEST = array_merge( $_GET, $_POST ); |
|
623 | + $_REQUEST = array_merge($_GET, $_POST); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @since 1.2.0 |
637 | 637 | */ |
638 | - do_action( 'shutdown' ); |
|
638 | + do_action('shutdown'); |
|
639 | 639 | |
640 | 640 | wp_cache_close(); |
641 | 641 | } |
@@ -649,9 +649,9 @@ discard block |
||
649 | 649 | * @param object $object The object to clone. |
650 | 650 | * @return object The cloned object. |
651 | 651 | */ |
652 | -function wp_clone( $object ) { |
|
652 | +function wp_clone($object) { |
|
653 | 653 | // Use parens for clone to accommodate PHP 4. See #17880 |
654 | - return clone( $object ); |
|
654 | + return clone($object); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | * @return bool True if inside WordPress administration interface, false otherwise. |
668 | 668 | */ |
669 | 669 | function is_admin() { |
670 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
670 | + if (isset($GLOBALS['current_screen'])) |
|
671 | 671 | return $GLOBALS['current_screen']->in_admin(); |
672 | - elseif ( defined( 'WP_ADMIN' ) ) |
|
672 | + elseif (defined('WP_ADMIN')) |
|
673 | 673 | return WP_ADMIN; |
674 | 674 | |
675 | 675 | return false; |
@@ -690,9 +690,9 @@ discard block |
||
690 | 690 | * @return bool True if inside WordPress blog administration pages. |
691 | 691 | */ |
692 | 692 | function is_blog_admin() { |
693 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
694 | - return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
695 | - elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
693 | + if (isset($GLOBALS['current_screen'])) |
|
694 | + return $GLOBALS['current_screen']->in_admin('site'); |
|
695 | + elseif (defined('WP_BLOG_ADMIN')) |
|
696 | 696 | return WP_BLOG_ADMIN; |
697 | 697 | |
698 | 698 | return false; |
@@ -713,9 +713,9 @@ discard block |
||
713 | 713 | * @return bool True if inside WordPress network administration pages. |
714 | 714 | */ |
715 | 715 | function is_network_admin() { |
716 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
717 | - return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
718 | - elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
716 | + if (isset($GLOBALS['current_screen'])) |
|
717 | + return $GLOBALS['current_screen']->in_admin('network'); |
|
718 | + elseif (defined('WP_NETWORK_ADMIN')) |
|
719 | 719 | return WP_NETWORK_ADMIN; |
720 | 720 | |
721 | 721 | return false; |
@@ -737,9 +737,9 @@ discard block |
||
737 | 737 | * @return bool True if inside WordPress user administration pages. |
738 | 738 | */ |
739 | 739 | function is_user_admin() { |
740 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
741 | - return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
742 | - elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
740 | + if (isset($GLOBALS['current_screen'])) |
|
741 | + return $GLOBALS['current_screen']->in_admin('user'); |
|
742 | + elseif (defined('WP_USER_ADMIN')) |
|
743 | 743 | return WP_USER_ADMIN; |
744 | 744 | |
745 | 745 | return false; |
@@ -753,10 +753,10 @@ discard block |
||
753 | 753 | * @return bool True if Multisite is enabled, false otherwise. |
754 | 754 | */ |
755 | 755 | function is_multisite() { |
756 | - if ( defined( 'MULTISITE' ) ) |
|
756 | + if (defined('MULTISITE')) |
|
757 | 757 | return MULTISITE; |
758 | 758 | |
759 | - if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
759 | + if (defined('SUBDOMAIN_INSTALL') || defined('VHOST') || defined('SUNRISE')) |
|
760 | 760 | return true; |
761 | 761 | |
762 | 762 | return false; |
@@ -798,62 +798,62 @@ discard block |
||
798 | 798 | global $text_direction, $wp_locale; |
799 | 799 | |
800 | 800 | static $loaded = false; |
801 | - if ( $loaded ) |
|
801 | + if ($loaded) |
|
802 | 802 | return; |
803 | 803 | $loaded = true; |
804 | 804 | |
805 | - if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
805 | + if (function_exists('did_action') && did_action('init')) |
|
806 | 806 | return; |
807 | 807 | |
808 | 808 | // We need $wp_local_package |
809 | - require ABSPATH . WPINC . '/version.php'; |
|
809 | + require ABSPATH.WPINC.'/version.php'; |
|
810 | 810 | |
811 | 811 | // Translation and localization |
812 | - require_once ABSPATH . WPINC . '/pomo/mo.php'; |
|
813 | - require_once ABSPATH . WPINC . '/l10n.php'; |
|
814 | - require_once ABSPATH . WPINC . '/locale.php'; |
|
812 | + require_once ABSPATH.WPINC.'/pomo/mo.php'; |
|
813 | + require_once ABSPATH.WPINC.'/l10n.php'; |
|
814 | + require_once ABSPATH.WPINC.'/locale.php'; |
|
815 | 815 | |
816 | 816 | // General libraries |
817 | - require_once ABSPATH . WPINC . '/plugin.php'; |
|
817 | + require_once ABSPATH.WPINC.'/plugin.php'; |
|
818 | 818 | |
819 | 819 | $locales = $locations = array(); |
820 | 820 | |
821 | - while ( true ) { |
|
822 | - if ( defined( 'WPLANG' ) ) { |
|
823 | - if ( '' == WPLANG ) |
|
821 | + while (true) { |
|
822 | + if (defined('WPLANG')) { |
|
823 | + if ('' == WPLANG) |
|
824 | 824 | break; |
825 | 825 | $locales[] = WPLANG; |
826 | 826 | } |
827 | 827 | |
828 | - if ( isset( $wp_local_package ) ) |
|
828 | + if (isset($wp_local_package)) |
|
829 | 829 | $locales[] = $wp_local_package; |
830 | 830 | |
831 | - if ( ! $locales ) |
|
831 | + if ( ! $locales) |
|
832 | 832 | break; |
833 | 833 | |
834 | - if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
834 | + if (defined('WP_LANG_DIR') && @is_dir(WP_LANG_DIR)) |
|
835 | 835 | $locations[] = WP_LANG_DIR; |
836 | 836 | |
837 | - if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
838 | - $locations[] = WP_CONTENT_DIR . '/languages'; |
|
837 | + if (defined('WP_CONTENT_DIR') && @is_dir(WP_CONTENT_DIR.'/languages')) |
|
838 | + $locations[] = WP_CONTENT_DIR.'/languages'; |
|
839 | 839 | |
840 | - if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
841 | - $locations[] = ABSPATH . 'wp-content/languages'; |
|
840 | + if (@is_dir(ABSPATH.'wp-content/languages')) |
|
841 | + $locations[] = ABSPATH.'wp-content/languages'; |
|
842 | 842 | |
843 | - if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
844 | - $locations[] = ABSPATH . WPINC . '/languages'; |
|
843 | + if (@is_dir(ABSPATH.WPINC.'/languages')) |
|
844 | + $locations[] = ABSPATH.WPINC.'/languages'; |
|
845 | 845 | |
846 | - if ( ! $locations ) |
|
846 | + if ( ! $locations) |
|
847 | 847 | break; |
848 | 848 | |
849 | - $locations = array_unique( $locations ); |
|
849 | + $locations = array_unique($locations); |
|
850 | 850 | |
851 | - foreach ( $locales as $locale ) { |
|
852 | - foreach ( $locations as $location ) { |
|
853 | - if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
854 | - load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
|
855 | - if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
856 | - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
851 | + foreach ($locales as $locale) { |
|
852 | + foreach ($locations as $location) { |
|
853 | + if (file_exists($location.'/'.$locale.'.mo')) { |
|
854 | + load_textdomain('default', $location.'/'.$locale.'.mo'); |
|
855 | + if (defined('WP_SETUP_CONFIG') && file_exists($location.'/admin-'.$locale.'.mo')) |
|
856 | + load_textdomain('default', $location.'/admin-'.$locale.'.mo'); |
|
857 | 857 | break 2; |
858 | 858 | } |
859 | 859 | } |
@@ -879,15 +879,15 @@ discard block |
||
879 | 879 | * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will |
880 | 880 | * report whether WP was in installing mode prior to the change to `$is_installing`. |
881 | 881 | */ |
882 | -function wp_installing( $is_installing = null ) { |
|
882 | +function wp_installing($is_installing = null) { |
|
883 | 883 | static $installing = null; |
884 | 884 | |
885 | 885 | // Support for the `WP_INSTALLING` constant, defined before WP is loaded. |
886 | - if ( is_null( $installing ) ) { |
|
887 | - $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
|
886 | + if (is_null($installing)) { |
|
887 | + $installing = defined('WP_INSTALLING') && WP_INSTALLING; |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( ! is_null( $is_installing ) ) { |
|
890 | + if ( ! is_null($is_installing)) { |
|
891 | 891 | $old_installing = $installing; |
892 | 892 | $installing = $is_installing; |
893 | 893 | return (bool) $old_installing; |
@@ -29,19 +29,22 @@ discard block |
||
29 | 29 | * @access private |
30 | 30 | */ |
31 | 31 | function wp_unregister_GLOBALS() { |
32 | - if ( !ini_get( 'register_globals' ) ) |
|
33 | - return; |
|
32 | + if ( !ini_get( 'register_globals' ) ) { |
|
33 | + return; |
|
34 | + } |
|
34 | 35 | |
35 | - if ( isset( $_REQUEST['GLOBALS'] ) ) |
|
36 | - die( 'GLOBALS overwrite attempt detected' ); |
|
36 | + if ( isset( $_REQUEST['GLOBALS'] ) ) { |
|
37 | + die( 'GLOBALS overwrite attempt detected' ); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // Variables that shouldn't be unset |
39 | 41 | $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); |
40 | 42 | |
41 | 43 | $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); |
42 | - foreach ( $input as $k => $v ) |
|
43 | - if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
44 | + foreach ( $input as $k => $v ) { |
|
45 | + if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { |
|
44 | 46 | unset( $GLOBALS[$k] ); |
47 | + } |
|
45 | 48 | } |
46 | 49 | } |
47 | 50 | |
@@ -76,15 +79,17 @@ discard block |
||
76 | 79 | $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; |
77 | 80 | } else { |
78 | 81 | // Use ORIG_PATH_INFO if there is no PATH_INFO |
79 | - if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) |
|
80 | - $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
82 | + if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { |
|
83 | + $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; |
|
84 | + } |
|
81 | 85 | |
82 | 86 | // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) |
83 | 87 | if ( isset( $_SERVER['PATH_INFO'] ) ) { |
84 | - if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) |
|
85 | - $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
|
86 | - else |
|
87 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
88 | + if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { |
|
89 | + $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; |
|
90 | + } else { |
|
91 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; |
|
92 | + } |
|
88 | 93 | } |
89 | 94 | |
90 | 95 | // Append the query string if it exists and isn't null |
@@ -95,18 +100,21 @@ discard block |
||
95 | 100 | } |
96 | 101 | |
97 | 102 | // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests |
98 | - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) |
|
99 | - $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
103 | + if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { |
|
104 | + $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; |
|
105 | + } |
|
100 | 106 | |
101 | 107 | // Fix for Dreamhost and other PHP as CGI hosts |
102 | - if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) |
|
103 | - unset( $_SERVER['PATH_INFO'] ); |
|
108 | + if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { |
|
109 | + unset( $_SERVER['PATH_INFO'] ); |
|
110 | + } |
|
104 | 111 | |
105 | 112 | // Fix empty PHP_SELF |
106 | 113 | $PHP_SELF = $_SERVER['PHP_SELF']; |
107 | - if ( empty( $PHP_SELF ) ) |
|
108 | - $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
109 | -} |
|
114 | + if ( empty( $PHP_SELF ) ) { |
|
115 | + $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); |
|
116 | + } |
|
117 | + } |
|
110 | 118 | |
111 | 119 | /** |
112 | 120 | * Check for the required PHP version, and the MySQL extension or |
@@ -174,15 +182,17 @@ discard block |
||
174 | 182 | * @global int $upgrading the unix timestamp marking when upgrading WordPress began. |
175 | 183 | */ |
176 | 184 | function wp_maintenance() { |
177 | - if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) |
|
178 | - return; |
|
185 | + if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { |
|
186 | + return; |
|
187 | + } |
|
179 | 188 | |
180 | 189 | global $upgrading; |
181 | 190 | |
182 | 191 | include( ABSPATH . '.maintenance' ); |
183 | 192 | // If the $upgrading timestamp is older than 10 minutes, don't die. |
184 | - if ( ( time() - $upgrading ) >= 600 ) |
|
185 | - return; |
|
193 | + if ( ( time() - $upgrading ) >= 600 ) { |
|
194 | + return; |
|
195 | + } |
|
186 | 196 | |
187 | 197 | if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
188 | 198 | require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
@@ -197,7 +207,10 @@ discard block |
||
197 | 207 | header( 'Retry-After: 600' ); |
198 | 208 | ?> |
199 | 209 | <!DOCTYPE html> |
200 | - <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
210 | + <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) { |
|
211 | + echo ' dir="rtl"'; |
|
212 | +} |
|
213 | +?>> |
|
201 | 214 | <head> |
202 | 215 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
203 | 216 | <title><?php _e( 'Maintenance' ); ?></title> |
@@ -248,8 +261,9 @@ discard block |
||
248 | 261 | $timeend = microtime( true ); |
249 | 262 | $timetotal = $timeend - $timestart; |
250 | 263 | $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
251 | - if ( $display ) |
|
252 | - echo $r; |
|
264 | + if ( $display ) { |
|
265 | + echo $r; |
|
266 | + } |
|
253 | 267 | return $r; |
254 | 268 | } |
255 | 269 | |
@@ -288,10 +302,11 @@ discard block |
||
288 | 302 | if ( WP_DEBUG ) { |
289 | 303 | error_reporting( E_ALL ); |
290 | 304 | |
291 | - if ( WP_DEBUG_DISPLAY ) |
|
292 | - ini_set( 'display_errors', 1 ); |
|
293 | - elseif ( null !== WP_DEBUG_DISPLAY ) |
|
294 | - ini_set( 'display_errors', 0 ); |
|
305 | + if ( WP_DEBUG_DISPLAY ) { |
|
306 | + ini_set( 'display_errors', 1 ); |
|
307 | + } elseif ( null !== WP_DEBUG_DISPLAY ) { |
|
308 | + ini_set( 'display_errors', 0 ); |
|
309 | + } |
|
295 | 310 | |
296 | 311 | if ( WP_DEBUG_LOG ) { |
297 | 312 | ini_set( 'log_errors', 1 ); |
@@ -362,11 +377,13 @@ discard block |
||
362 | 377 | global $wpdb; |
363 | 378 | |
364 | 379 | require_once( ABSPATH . WPINC . '/wp-db.php' ); |
365 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
366 | - require_once( WP_CONTENT_DIR . '/db.php' ); |
|
380 | + if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { |
|
381 | + require_once( WP_CONTENT_DIR . '/db.php' ); |
|
382 | + } |
|
367 | 383 | |
368 | - if ( isset( $wpdb ) ) |
|
369 | - return; |
|
384 | + if ( isset( $wpdb ) ) { |
|
385 | + return; |
|
386 | + } |
|
370 | 387 | |
371 | 388 | $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
372 | 389 | } |
@@ -385,8 +402,9 @@ discard block |
||
385 | 402 | */ |
386 | 403 | function wp_set_wpdb_vars() { |
387 | 404 | global $wpdb, $table_prefix; |
388 | - if ( !empty( $wpdb->error ) ) |
|
389 | - dead_db(); |
|
405 | + if ( !empty( $wpdb->error ) ) { |
|
406 | + dead_db(); |
|
407 | + } |
|
390 | 408 | |
391 | 409 | $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
392 | 410 | 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
@@ -424,8 +442,9 @@ discard block |
||
424 | 442 | function wp_using_ext_object_cache( $using = null ) { |
425 | 443 | global $_wp_using_ext_object_cache; |
426 | 444 | $current_using = $_wp_using_ext_object_cache; |
427 | - if ( null !== $using ) |
|
428 | - $_wp_using_ext_object_cache = $using; |
|
445 | + if ( null !== $using ) { |
|
446 | + $_wp_using_ext_object_cache = $using; |
|
447 | + } |
|
429 | 448 | return $current_using; |
430 | 449 | } |
431 | 450 | |
@@ -447,8 +466,9 @@ discard block |
||
447 | 466 | if ( ! function_exists( 'wp_cache_init' ) ) { |
448 | 467 | if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
449 | 468 | require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
450 | - if ( function_exists( 'wp_cache_init' ) ) |
|
451 | - wp_using_ext_object_cache( true ); |
|
469 | + if ( function_exists( 'wp_cache_init' ) ) { |
|
470 | + wp_using_ext_object_cache( true ); |
|
471 | + } |
|
452 | 472 | } |
453 | 473 | |
454 | 474 | $first_init = true; |
@@ -462,18 +482,20 @@ discard block |
||
462 | 482 | wp_using_ext_object_cache( true ); |
463 | 483 | } |
464 | 484 | |
465 | - if ( ! wp_using_ext_object_cache() ) |
|
466 | - require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
485 | + if ( ! wp_using_ext_object_cache() ) { |
|
486 | + require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
487 | + } |
|
467 | 488 | |
468 | 489 | /* |
469 | 490 | * If cache supports reset, reset instead of init if already |
470 | 491 | * initialized. Reset signals to the cache that global IDs |
471 | 492 | * have changed and it may need to update keys and cleanup caches. |
472 | 493 | */ |
473 | - if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
|
474 | - wp_cache_switch_to_blog( $blog_id ); |
|
475 | - elseif ( function_exists( 'wp_cache_init' ) ) |
|
476 | - wp_cache_init(); |
|
494 | + if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
495 | + wp_cache_switch_to_blog( $blog_id ); |
|
496 | + } elseif ( function_exists( 'wp_cache_init' ) ) { |
|
497 | + wp_cache_init(); |
|
498 | + } |
|
477 | 499 | |
478 | 500 | if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
479 | 501 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
@@ -524,13 +546,16 @@ discard block |
||
524 | 546 | */ |
525 | 547 | function wp_get_mu_plugins() { |
526 | 548 | $mu_plugins = array(); |
527 | - if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
528 | - return $mu_plugins; |
|
529 | - if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
530 | - return $mu_plugins; |
|
549 | + if ( !is_dir( WPMU_PLUGIN_DIR ) ) { |
|
550 | + return $mu_plugins; |
|
551 | + } |
|
552 | + if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) { |
|
553 | + return $mu_plugins; |
|
554 | + } |
|
531 | 555 | while ( ( $plugin = readdir( $dh ) ) !== false ) { |
532 | - if ( substr( $plugin, -4 ) == '.php' ) |
|
533 | - $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
556 | + if ( substr( $plugin, -4 ) == '.php' ) { |
|
557 | + $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
558 | + } |
|
534 | 559 | } |
535 | 560 | closedir( $dh ); |
536 | 561 | sort( $mu_plugins ); |
@@ -562,8 +587,9 @@ discard block |
||
562 | 587 | array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
563 | 588 | } |
564 | 589 | |
565 | - if ( empty( $active_plugins ) || wp_installing() ) |
|
566 | - return $plugins; |
|
590 | + if ( empty( $active_plugins ) || wp_installing() ) { |
|
591 | + return $plugins; |
|
592 | + } |
|
567 | 593 | |
568 | 594 | $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
569 | 595 | |
@@ -573,8 +599,9 @@ discard block |
||
573 | 599 | && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
574 | 600 | // not already included as a network plugin |
575 | 601 | && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
576 | - ) |
|
577 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
602 | + ) { |
|
603 | + $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
604 | + } |
|
578 | 605 | } |
579 | 606 | return $plugins; |
580 | 607 | } |
@@ -591,8 +618,9 @@ discard block |
||
591 | 618 | function wp_set_internal_encoding() { |
592 | 619 | if ( function_exists( 'mb_internal_encoding' ) ) { |
593 | 620 | $charset = get_option( 'blog_charset' ); |
594 | - if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
595 | - mb_internal_encoding( 'UTF-8' ); |
|
621 | + if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { |
|
622 | + mb_internal_encoding( 'UTF-8' ); |
|
623 | + } |
|
596 | 624 | } |
597 | 625 | } |
598 | 626 | |
@@ -667,10 +695,11 @@ discard block |
||
667 | 695 | * @return bool True if inside WordPress administration interface, false otherwise. |
668 | 696 | */ |
669 | 697 | function is_admin() { |
670 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
671 | - return $GLOBALS['current_screen']->in_admin(); |
|
672 | - elseif ( defined( 'WP_ADMIN' ) ) |
|
673 | - return WP_ADMIN; |
|
698 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
699 | + return $GLOBALS['current_screen']->in_admin(); |
|
700 | + } elseif ( defined( 'WP_ADMIN' ) ) { |
|
701 | + return WP_ADMIN; |
|
702 | + } |
|
674 | 703 | |
675 | 704 | return false; |
676 | 705 | } |
@@ -690,10 +719,11 @@ discard block |
||
690 | 719 | * @return bool True if inside WordPress blog administration pages. |
691 | 720 | */ |
692 | 721 | function is_blog_admin() { |
693 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
694 | - return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
695 | - elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
696 | - return WP_BLOG_ADMIN; |
|
722 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
723 | + return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
724 | + } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { |
|
725 | + return WP_BLOG_ADMIN; |
|
726 | + } |
|
697 | 727 | |
698 | 728 | return false; |
699 | 729 | } |
@@ -713,10 +743,11 @@ discard block |
||
713 | 743 | * @return bool True if inside WordPress network administration pages. |
714 | 744 | */ |
715 | 745 | function is_network_admin() { |
716 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
717 | - return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
718 | - elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
719 | - return WP_NETWORK_ADMIN; |
|
746 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
747 | + return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
748 | + } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { |
|
749 | + return WP_NETWORK_ADMIN; |
|
750 | + } |
|
720 | 751 | |
721 | 752 | return false; |
722 | 753 | } |
@@ -737,10 +768,11 @@ discard block |
||
737 | 768 | * @return bool True if inside WordPress user administration pages. |
738 | 769 | */ |
739 | 770 | function is_user_admin() { |
740 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
741 | - return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
742 | - elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
743 | - return WP_USER_ADMIN; |
|
771 | + if ( isset( $GLOBALS['current_screen'] ) ) { |
|
772 | + return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
773 | + } elseif ( defined( 'WP_USER_ADMIN' ) ) { |
|
774 | + return WP_USER_ADMIN; |
|
775 | + } |
|
744 | 776 | |
745 | 777 | return false; |
746 | 778 | } |
@@ -753,11 +785,13 @@ discard block |
||
753 | 785 | * @return bool True if Multisite is enabled, false otherwise. |
754 | 786 | */ |
755 | 787 | function is_multisite() { |
756 | - if ( defined( 'MULTISITE' ) ) |
|
757 | - return MULTISITE; |
|
788 | + if ( defined( 'MULTISITE' ) ) { |
|
789 | + return MULTISITE; |
|
790 | + } |
|
758 | 791 | |
759 | - if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
760 | - return true; |
|
792 | + if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { |
|
793 | + return true; |
|
794 | + } |
|
761 | 795 | |
762 | 796 | return false; |
763 | 797 | } |
@@ -798,12 +832,14 @@ discard block |
||
798 | 832 | global $text_direction, $wp_locale; |
799 | 833 | |
800 | 834 | static $loaded = false; |
801 | - if ( $loaded ) |
|
802 | - return; |
|
835 | + if ( $loaded ) { |
|
836 | + return; |
|
837 | + } |
|
803 | 838 | $loaded = true; |
804 | 839 | |
805 | - if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
806 | - return; |
|
840 | + if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { |
|
841 | + return; |
|
842 | + } |
|
807 | 843 | |
808 | 844 | // We need $wp_local_package |
809 | 845 | require ABSPATH . WPINC . '/version.php'; |
@@ -820,31 +856,39 @@ discard block |
||
820 | 856 | |
821 | 857 | while ( true ) { |
822 | 858 | if ( defined( 'WPLANG' ) ) { |
823 | - if ( '' == WPLANG ) |
|
824 | - break; |
|
859 | + if ( '' == WPLANG ) { |
|
860 | + break; |
|
861 | + } |
|
825 | 862 | $locales[] = WPLANG; |
826 | 863 | } |
827 | 864 | |
828 | - if ( isset( $wp_local_package ) ) |
|
829 | - $locales[] = $wp_local_package; |
|
865 | + if ( isset( $wp_local_package ) ) { |
|
866 | + $locales[] = $wp_local_package; |
|
867 | + } |
|
830 | 868 | |
831 | - if ( ! $locales ) |
|
832 | - break; |
|
869 | + if ( ! $locales ) { |
|
870 | + break; |
|
871 | + } |
|
833 | 872 | |
834 | - if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
835 | - $locations[] = WP_LANG_DIR; |
|
873 | + if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { |
|
874 | + $locations[] = WP_LANG_DIR; |
|
875 | + } |
|
836 | 876 | |
837 | - if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
838 | - $locations[] = WP_CONTENT_DIR . '/languages'; |
|
877 | + if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { |
|
878 | + $locations[] = WP_CONTENT_DIR . '/languages'; |
|
879 | + } |
|
839 | 880 | |
840 | - if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
841 | - $locations[] = ABSPATH . 'wp-content/languages'; |
|
881 | + if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { |
|
882 | + $locations[] = ABSPATH . 'wp-content/languages'; |
|
883 | + } |
|
842 | 884 | |
843 | - if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
844 | - $locations[] = ABSPATH . WPINC . '/languages'; |
|
885 | + if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { |
|
886 | + $locations[] = ABSPATH . WPINC . '/languages'; |
|
887 | + } |
|
845 | 888 | |
846 | - if ( ! $locations ) |
|
847 | - break; |
|
889 | + if ( ! $locations ) { |
|
890 | + break; |
|
891 | + } |
|
848 | 892 | |
849 | 893 | $locations = array_unique( $locations ); |
850 | 894 | |
@@ -852,8 +896,9 @@ discard block |
||
852 | 896 | foreach ( $locations as $location ) { |
853 | 897 | if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
854 | 898 | load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
855 | - if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
856 | - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
899 | + if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { |
|
900 | + load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
901 | + } |
|
857 | 902 | break 2; |
858 | 903 | } |
859 | 904 | } |
@@ -595,7 +595,7 @@ |
||
595 | 595 | * |
596 | 596 | * @param int $new_blog The id of the blog you want to switch to. Default: current blog |
597 | 597 | * @param bool $deprecated Deprecated argument |
598 | - * @return true Always returns True. |
|
598 | + * @return boolean Always returns True. |
|
599 | 599 | */ |
600 | 600 | function switch_to_blog( $new_blog, $deprecated = null ) { |
601 | 601 | global $wpdb; |
@@ -845,7 +845,7 @@ |
||
845 | 845 | * |
846 | 846 | * @param int $blog_id Blog ID. |
847 | 847 | * @param string $value The value of blog status. |
848 | - */ |
|
848 | + */ |
|
849 | 849 | do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public(). |
850 | 850 | } |
851 | 851 |
@@ -52,11 +52,13 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function get_blogaddress_by_name( $blogname ) { |
54 | 54 | if ( is_subdomain_install() ) { |
55 | - if ( $blogname == 'main' ) |
|
56 | - $blogname = 'www'; |
|
55 | + if ( $blogname == 'main' ) { |
|
56 | + $blogname = 'www'; |
|
57 | + } |
|
57 | 58 | $url = rtrim( network_home_url(), '/' ); |
58 | - if ( !empty( $blogname ) ) |
|
59 | - $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url ); |
|
59 | + if ( !empty( $blogname ) ) { |
|
60 | + $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url ); |
|
61 | + } |
|
60 | 62 | } else { |
61 | 63 | $url = network_home_url( $blogname ); |
62 | 64 | } |
@@ -80,8 +82,9 @@ discard block |
||
80 | 82 | $slug = trim( $slug, '/' ); |
81 | 83 | |
82 | 84 | $blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ); |
83 | - if ( $blog_id ) |
|
84 | - return $blog_id; |
|
85 | + if ( $blog_id ) { |
|
86 | + return $blog_id; |
|
87 | + } |
|
85 | 88 | |
86 | 89 | if ( is_subdomain_install() ) { |
87 | 90 | $domain = $slug . '.' . $current_site->domain; |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | } elseif ( isset($fields['domain']) && isset($fields['path']) ) { |
119 | 122 | $key = md5( $fields['domain'] . $fields['path'] ); |
120 | 123 | $blog = wp_cache_get($key, 'blog-lookup'); |
121 | - if ( false !== $blog ) |
|
122 | - return $blog; |
|
124 | + if ( false !== $blog ) { |
|
125 | + return $blog; |
|
126 | + } |
|
123 | 127 | if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
124 | 128 | $nowww = substr( $fields['domain'], 4 ); |
125 | 129 | $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); |
@@ -135,8 +139,9 @@ discard block |
||
135 | 139 | } elseif ( isset($fields['domain']) && is_subdomain_install() ) { |
136 | 140 | $key = md5( $fields['domain'] ); |
137 | 141 | $blog = wp_cache_get($key, 'blog-lookup'); |
138 | - if ( false !== $blog ) |
|
139 | - return $blog; |
|
142 | + if ( false !== $blog ) { |
|
143 | + return $blog; |
|
144 | + } |
|
140 | 145 | if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
141 | 146 | $nowww = substr( $fields['domain'], 4 ); |
142 | 147 | $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); |
@@ -153,12 +158,13 @@ discard block |
||
153 | 158 | return false; |
154 | 159 | } |
155 | 160 | } else { |
156 | - if ( ! $fields ) |
|
157 | - $blog_id = get_current_blog_id(); |
|
158 | - elseif ( ! is_numeric( $fields ) ) |
|
159 | - $blog_id = get_id_from_blogname( $fields ); |
|
160 | - else |
|
161 | - $blog_id = $fields; |
|
161 | + if ( ! $fields ) { |
|
162 | + $blog_id = get_current_blog_id(); |
|
163 | + } elseif ( ! is_numeric( $fields ) ) { |
|
164 | + $blog_id = get_id_from_blogname( $fields ); |
|
165 | + } else { |
|
166 | + $blog_id = $fields; |
|
167 | + } |
|
162 | 168 | } |
163 | 169 | |
164 | 170 | $blog_id = (int) $blog_id; |
@@ -289,15 +295,18 @@ discard block |
||
289 | 295 | function update_blog_details( $blog_id, $details = array() ) { |
290 | 296 | global $wpdb; |
291 | 297 | |
292 | - if ( empty($details) ) |
|
293 | - return false; |
|
298 | + if ( empty($details) ) { |
|
299 | + return false; |
|
300 | + } |
|
294 | 301 | |
295 | - if ( is_object($details) ) |
|
296 | - $details = get_object_vars($details); |
|
302 | + if ( is_object($details) ) { |
|
303 | + $details = get_object_vars($details); |
|
304 | + } |
|
297 | 305 | |
298 | 306 | $current_details = get_blog_details($blog_id, false); |
299 | - if ( empty($current_details) ) |
|
300 | - return false; |
|
307 | + if ( empty($current_details) ) { |
|
308 | + return false; |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $current_details = get_object_vars($current_details); |
303 | 312 | |
@@ -316,8 +325,9 @@ discard block |
||
316 | 325 | |
317 | 326 | $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); |
318 | 327 | |
319 | - if ( false === $result ) |
|
320 | - return false; |
|
328 | + if ( false === $result ) { |
|
329 | + return false; |
|
330 | + } |
|
321 | 331 | |
322 | 332 | // If spam status changed, issue actions. |
323 | 333 | if ( $details['spam'] != $current_details['spam'] ) { |
@@ -462,11 +472,13 @@ discard block |
||
462 | 472 | function get_blog_option( $id, $option, $default = false ) { |
463 | 473 | $id = (int) $id; |
464 | 474 | |
465 | - if ( empty( $id ) ) |
|
466 | - $id = get_current_blog_id(); |
|
475 | + if ( empty( $id ) ) { |
|
476 | + $id = get_current_blog_id(); |
|
477 | + } |
|
467 | 478 | |
468 | - if ( get_current_blog_id() == $id ) |
|
469 | - return get_option( $option, $default ); |
|
479 | + if ( get_current_blog_id() == $id ) { |
|
480 | + return get_option( $option, $default ); |
|
481 | + } |
|
470 | 482 | |
471 | 483 | switch_to_blog( $id ); |
472 | 484 | $value = get_option( $option, $default ); |
@@ -507,11 +519,13 @@ discard block |
||
507 | 519 | function add_blog_option( $id, $option, $value ) { |
508 | 520 | $id = (int) $id; |
509 | 521 | |
510 | - if ( empty( $id ) ) |
|
511 | - $id = get_current_blog_id(); |
|
522 | + if ( empty( $id ) ) { |
|
523 | + $id = get_current_blog_id(); |
|
524 | + } |
|
512 | 525 | |
513 | - if ( get_current_blog_id() == $id ) |
|
514 | - return add_option( $option, $value ); |
|
526 | + if ( get_current_blog_id() == $id ) { |
|
527 | + return add_option( $option, $value ); |
|
528 | + } |
|
515 | 529 | |
516 | 530 | switch_to_blog( $id ); |
517 | 531 | $return = add_option( $option, $value ); |
@@ -532,11 +546,13 @@ discard block |
||
532 | 546 | function delete_blog_option( $id, $option ) { |
533 | 547 | $id = (int) $id; |
534 | 548 | |
535 | - if ( empty( $id ) ) |
|
536 | - $id = get_current_blog_id(); |
|
549 | + if ( empty( $id ) ) { |
|
550 | + $id = get_current_blog_id(); |
|
551 | + } |
|
537 | 552 | |
538 | - if ( get_current_blog_id() == $id ) |
|
539 | - return delete_option( $option ); |
|
553 | + if ( get_current_blog_id() == $id ) { |
|
554 | + return delete_option( $option ); |
|
555 | + } |
|
540 | 556 | |
541 | 557 | switch_to_blog( $id ); |
542 | 558 | $return = delete_option( $option ); |
@@ -558,11 +574,13 @@ discard block |
||
558 | 574 | function update_blog_option( $id, $option, $value, $deprecated = null ) { |
559 | 575 | $id = (int) $id; |
560 | 576 | |
561 | - if ( null !== $deprecated ) |
|
562 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
577 | + if ( null !== $deprecated ) { |
|
578 | + _deprecated_argument( __FUNCTION__, '3.1' ); |
|
579 | + } |
|
563 | 580 | |
564 | - if ( get_current_blog_id() == $id ) |
|
565 | - return update_option( $option, $value ); |
|
581 | + if ( get_current_blog_id() == $id ) { |
|
582 | + return update_option( $option, $value ); |
|
583 | + } |
|
566 | 584 | |
567 | 585 | switch_to_blog( $id ); |
568 | 586 | $return = update_option( $option, $value ); |
@@ -600,8 +618,9 @@ discard block |
||
600 | 618 | function switch_to_blog( $new_blog, $deprecated = null ) { |
601 | 619 | global $wpdb; |
602 | 620 | |
603 | - if ( empty( $new_blog ) ) |
|
604 | - $new_blog = $GLOBALS['blog_id']; |
|
621 | + if ( empty( $new_blog ) ) { |
|
622 | + $new_blog = $GLOBALS['blog_id']; |
|
623 | + } |
|
605 | 624 | |
606 | 625 | $GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id']; |
607 | 626 | |
@@ -634,10 +653,11 @@ discard block |
||
634 | 653 | } else { |
635 | 654 | global $wp_object_cache; |
636 | 655 | |
637 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
638 | - $global_groups = $wp_object_cache->global_groups; |
|
639 | - else |
|
640 | - $global_groups = false; |
|
656 | + if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { |
|
657 | + $global_groups = $wp_object_cache->global_groups; |
|
658 | + } else { |
|
659 | + $global_groups = false; |
|
660 | + } |
|
641 | 661 | |
642 | 662 | wp_cache_init(); |
643 | 663 | |
@@ -682,8 +702,9 @@ discard block |
||
682 | 702 | function restore_current_blog() { |
683 | 703 | global $wpdb; |
684 | 704 | |
685 | - if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
|
686 | - return false; |
|
705 | + if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
|
706 | + return false; |
|
707 | + } |
|
687 | 708 | |
688 | 709 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
689 | 710 | |
@@ -705,10 +726,11 @@ discard block |
||
705 | 726 | } else { |
706 | 727 | global $wp_object_cache; |
707 | 728 | |
708 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
709 | - $global_groups = $wp_object_cache->global_groups; |
|
710 | - else |
|
711 | - $global_groups = false; |
|
729 | + if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) { |
|
730 | + $global_groups = $wp_object_cache->global_groups; |
|
731 | + } else { |
|
732 | + $global_groups = false; |
|
733 | + } |
|
712 | 734 | |
713 | 735 | wp_cache_init(); |
714 | 736 | |
@@ -792,16 +814,19 @@ discard block |
||
792 | 814 | function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { |
793 | 815 | global $wpdb; |
794 | 816 | |
795 | - if ( null !== $deprecated ) |
|
796 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
817 | + if ( null !== $deprecated ) { |
|
818 | + _deprecated_argument( __FUNCTION__, '3.1' ); |
|
819 | + } |
|
797 | 820 | |
798 | - if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) |
|
799 | - return $value; |
|
821 | + if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) { |
|
822 | + return $value; |
|
823 | + } |
|
800 | 824 | |
801 | 825 | $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); |
802 | 826 | |
803 | - if ( false === $result ) |
|
804 | - return false; |
|
827 | + if ( false === $result ) { |
|
828 | + return false; |
|
829 | + } |
|
805 | 830 | |
806 | 831 | refresh_blog_details( $blog_id ); |
807 | 832 | |
@@ -867,8 +892,9 @@ discard block |
||
867 | 892 | global $wpdb; |
868 | 893 | |
869 | 894 | $details = get_blog_details( $id, false ); |
870 | - if ( $details ) |
|
871 | - return $details->$pref; |
|
895 | + if ( $details ) { |
|
896 | + return $details->$pref; |
|
897 | + } |
|
872 | 898 | |
873 | 899 | return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) ); |
874 | 900 | } |
@@ -888,8 +914,10 @@ discard block |
||
888 | 914 | function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { |
889 | 915 | global $wpdb; |
890 | 916 | |
891 | - if ( ! empty( $deprecated ) ) |
|
892 | - _deprecated_argument( __FUNCTION__, 'MU' ); // never used |
|
917 | + if ( ! empty( $deprecated ) ) { |
|
918 | + _deprecated_argument( __FUNCTION__, 'MU' ); |
|
919 | + } |
|
920 | + // never used |
|
893 | 921 | |
894 | 922 | return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A ); |
895 | 923 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | function wpmu_update_blogs_date() { |
19 | 19 | global $wpdb; |
20 | 20 | |
21 | - update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) ); |
|
21 | + update_blog_details($wpdb->blogid, array('last_updated' => current_time('mysql', true))); |
|
22 | 22 | /** |
23 | 23 | * Fires after the blog details are updated. |
24 | 24 | * |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param int $blog_id Site ID. |
28 | 28 | */ |
29 | - do_action( 'wpmu_blog_updated', $wpdb->blogid ); |
|
29 | + do_action('wpmu_blog_updated', $wpdb->blogid); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param int $blog_id Blog ID |
38 | 38 | * @return string Full URL of the blog if found. Empty string if not. |
39 | 39 | */ |
40 | -function get_blogaddress_by_id( $blog_id ) { |
|
41 | - $bloginfo = get_blog_details( (int) $blog_id ); |
|
40 | +function get_blogaddress_by_id($blog_id) { |
|
41 | + $bloginfo = get_blog_details((int) $blog_id); |
|
42 | 42 | |
43 | - if ( empty( $bloginfo ) ) { |
|
43 | + if (empty($bloginfo)) { |
|
44 | 44 | return ''; |
45 | 45 | } |
46 | 46 | |
47 | - $scheme = parse_url( $bloginfo->home, PHP_URL_SCHEME ); |
|
48 | - $scheme = empty( $scheme ) ? 'http' : $scheme; |
|
47 | + $scheme = parse_url($bloginfo->home, PHP_URL_SCHEME); |
|
48 | + $scheme = empty($scheme) ? 'http' : $scheme; |
|
49 | 49 | |
50 | - return esc_url( $scheme . '://' . $bloginfo->domain . $bloginfo->path ); |
|
50 | + return esc_url($scheme.'://'.$bloginfo->domain.$bloginfo->path); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -58,17 +58,17 @@ discard block |
||
58 | 58 | * @param string $blogname The (subdomain or directory) name |
59 | 59 | * @return string |
60 | 60 | */ |
61 | -function get_blogaddress_by_name( $blogname ) { |
|
62 | - if ( is_subdomain_install() ) { |
|
63 | - if ( $blogname == 'main' ) |
|
61 | +function get_blogaddress_by_name($blogname) { |
|
62 | + if (is_subdomain_install()) { |
|
63 | + if ($blogname == 'main') |
|
64 | 64 | $blogname = 'www'; |
65 | - $url = rtrim( network_home_url(), '/' ); |
|
66 | - if ( !empty( $blogname ) ) |
|
67 | - $url = preg_replace( '|^([^\.]+://)|', "\${1}" . $blogname . '.', $url ); |
|
65 | + $url = rtrim(network_home_url(), '/'); |
|
66 | + if ( ! empty($blogname)) |
|
67 | + $url = preg_replace('|^([^\.]+://)|', "\${1}".$blogname.'.', $url); |
|
68 | 68 | } else { |
69 | - $url = network_home_url( $blogname ); |
|
69 | + $url = network_home_url($blogname); |
|
70 | 70 | } |
71 | - return esc_url( $url . '/' ); |
|
71 | + return esc_url($url.'/'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -81,26 +81,26 @@ discard block |
||
81 | 81 | * @param string $slug |
82 | 82 | * @return int A blog id |
83 | 83 | */ |
84 | -function get_id_from_blogname( $slug ) { |
|
84 | +function get_id_from_blogname($slug) { |
|
85 | 85 | global $wpdb; |
86 | 86 | |
87 | 87 | $current_site = get_current_site(); |
88 | - $slug = trim( $slug, '/' ); |
|
88 | + $slug = trim($slug, '/'); |
|
89 | 89 | |
90 | - $blog_id = wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ); |
|
91 | - if ( $blog_id ) |
|
90 | + $blog_id = wp_cache_get('get_id_from_blogname_'.$slug, 'blog-details'); |
|
91 | + if ($blog_id) |
|
92 | 92 | return $blog_id; |
93 | 93 | |
94 | - if ( is_subdomain_install() ) { |
|
95 | - $domain = $slug . '.' . $current_site->domain; |
|
94 | + if (is_subdomain_install()) { |
|
95 | + $domain = $slug.'.'.$current_site->domain; |
|
96 | 96 | $path = $current_site->path; |
97 | 97 | } else { |
98 | 98 | $domain = $current_site->domain; |
99 | - $path = $current_site->path . $slug . '/'; |
|
99 | + $path = $current_site->path.$slug.'/'; |
|
100 | 100 | } |
101 | 101 | |
102 | - $blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) ); |
|
103 | - wp_cache_set( 'get_id_from_blogname_' . $slug, $blog_id, 'blog-details' ); |
|
102 | + $blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path)); |
|
103 | + wp_cache_set('get_id_from_blogname_'.$slug, $blog_id, 'blog-details'); |
|
104 | 104 | return $blog_id; |
105 | 105 | } |
106 | 106 | |
@@ -117,42 +117,42 @@ discard block |
||
117 | 117 | * Default is true. |
118 | 118 | * @return WP_Site|false Blog details on success. False on failure. |
119 | 119 | */ |
120 | -function get_blog_details( $fields = null, $get_all = true ) { |
|
120 | +function get_blog_details($fields = null, $get_all = true) { |
|
121 | 121 | global $wpdb; |
122 | 122 | |
123 | - if ( is_array($fields ) ) { |
|
124 | - if ( isset($fields['blog_id']) ) { |
|
123 | + if (is_array($fields)) { |
|
124 | + if (isset($fields['blog_id'])) { |
|
125 | 125 | $blog_id = $fields['blog_id']; |
126 | - } elseif ( isset($fields['domain']) && isset($fields['path']) ) { |
|
127 | - $key = md5( $fields['domain'] . $fields['path'] ); |
|
126 | + } elseif (isset($fields['domain']) && isset($fields['path'])) { |
|
127 | + $key = md5($fields['domain'].$fields['path']); |
|
128 | 128 | $blog = wp_cache_get($key, 'blog-lookup'); |
129 | - if ( false !== $blog ) |
|
129 | + if (false !== $blog) |
|
130 | 130 | return $blog; |
131 | - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
|
132 | - $nowww = substr( $fields['domain'], 4 ); |
|
133 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) ); |
|
131 | + if (substr($fields['domain'], 0, 4) == 'www.') { |
|
132 | + $nowww = substr($fields['domain'], 4); |
|
133 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'])); |
|
134 | 134 | } else { |
135 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) ); |
|
135 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'])); |
|
136 | 136 | } |
137 | - if ( $blog ) { |
|
138 | - wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); |
|
137 | + if ($blog) { |
|
138 | + wp_cache_set($blog->blog_id.'short', $blog, 'blog-details'); |
|
139 | 139 | $blog_id = $blog->blog_id; |
140 | 140 | } else { |
141 | 141 | return false; |
142 | 142 | } |
143 | - } elseif ( isset($fields['domain']) && is_subdomain_install() ) { |
|
144 | - $key = md5( $fields['domain'] ); |
|
143 | + } elseif (isset($fields['domain']) && is_subdomain_install()) { |
|
144 | + $key = md5($fields['domain']); |
|
145 | 145 | $blog = wp_cache_get($key, 'blog-lookup'); |
146 | - if ( false !== $blog ) |
|
146 | + if (false !== $blog) |
|
147 | 147 | return $blog; |
148 | - if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) { |
|
149 | - $nowww = substr( $fields['domain'], 4 ); |
|
150 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) ); |
|
148 | + if (substr($fields['domain'], 0, 4) == 'www.') { |
|
149 | + $nowww = substr($fields['domain'], 4); |
|
150 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'])); |
|
151 | 151 | } else { |
152 | - $blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) ); |
|
152 | + $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'])); |
|
153 | 153 | } |
154 | - if ( $blog ) { |
|
155 | - wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details'); |
|
154 | + if ($blog) { |
|
155 | + wp_cache_set($blog->blog_id.'short', $blog, 'blog-details'); |
|
156 | 156 | $blog_id = $blog->blog_id; |
157 | 157 | } else { |
158 | 158 | return false; |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | } else { |
164 | - if ( ! $fields ) |
|
164 | + if ( ! $fields) |
|
165 | 165 | $blog_id = get_current_blog_id(); |
166 | - elseif ( ! is_numeric( $fields ) ) |
|
167 | - $blog_id = get_id_from_blogname( $fields ); |
|
166 | + elseif ( ! is_numeric($fields)) |
|
167 | + $blog_id = get_id_from_blogname($fields); |
|
168 | 168 | else |
169 | 169 | $blog_id = $fields; |
170 | 170 | } |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | $blog_id = (int) $blog_id; |
173 | 173 | |
174 | 174 | $all = $get_all == true ? '' : 'short'; |
175 | - $details = wp_cache_get( $blog_id . $all, 'blog-details' ); |
|
175 | + $details = wp_cache_get($blog_id.$all, 'blog-details'); |
|
176 | 176 | |
177 | - if ( $details ) { |
|
178 | - if ( ! is_object( $details ) ) { |
|
179 | - if ( $details == -1 ) { |
|
177 | + if ($details) { |
|
178 | + if ( ! is_object($details)) { |
|
179 | + if ($details == -1) { |
|
180 | 180 | return false; |
181 | 181 | } else { |
182 | 182 | // Clear old pre-serialized objects. Cache clients do better with that. |
183 | - wp_cache_delete( $blog_id . $all, 'blog-details' ); |
|
183 | + wp_cache_delete($blog_id.$all, 'blog-details'); |
|
184 | 184 | unset($details); |
185 | 185 | } |
186 | 186 | } else { |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | // Try the other cache. |
192 | - if ( $get_all ) { |
|
193 | - $details = wp_cache_get( $blog_id . 'short', 'blog-details' ); |
|
192 | + if ($get_all) { |
|
193 | + $details = wp_cache_get($blog_id.'short', 'blog-details'); |
|
194 | 194 | } else { |
195 | - $details = wp_cache_get( $blog_id, 'blog-details' ); |
|
195 | + $details = wp_cache_get($blog_id, 'blog-details'); |
|
196 | 196 | // If short was requested and full cache is set, we can return. |
197 | - if ( $details ) { |
|
198 | - if ( ! is_object( $details ) ) { |
|
199 | - if ( $details == -1 ) { |
|
197 | + if ($details) { |
|
198 | + if ( ! is_object($details)) { |
|
199 | + if ($details == -1) { |
|
200 | 200 | return false; |
201 | 201 | } else { |
202 | 202 | // Clear old pre-serialized objects. Cache clients do better with that. |
203 | - wp_cache_delete( $blog_id, 'blog-details' ); |
|
203 | + wp_cache_delete($blog_id, 'blog-details'); |
|
204 | 204 | unset($details); |
205 | 205 | } |
206 | 206 | } else { |
@@ -209,29 +209,29 @@ discard block |
||
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if ( empty($details) ) { |
|
213 | - $details = WP_Site::get_instance( $blog_id ); |
|
214 | - if ( ! $details ) { |
|
212 | + if (empty($details)) { |
|
213 | + $details = WP_Site::get_instance($blog_id); |
|
214 | + if ( ! $details) { |
|
215 | 215 | // Set the full cache. |
216 | - wp_cache_set( $blog_id, -1, 'blog-details' ); |
|
216 | + wp_cache_set($blog_id, -1, 'blog-details'); |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ! $details instanceof WP_Site ) { |
|
222 | - $details = new WP_Site( $details ); |
|
221 | + if ( ! $details instanceof WP_Site) { |
|
222 | + $details = new WP_Site($details); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( ! $get_all ) { |
|
226 | - wp_cache_set( $blog_id . $all, $details, 'blog-details' ); |
|
225 | + if ( ! $get_all) { |
|
226 | + wp_cache_set($blog_id.$all, $details, 'blog-details'); |
|
227 | 227 | return $details; |
228 | 228 | } |
229 | 229 | |
230 | - switch_to_blog( $blog_id ); |
|
231 | - $details->blogname = get_option( 'blogname' ); |
|
232 | - $details->siteurl = get_option( 'siteurl' ); |
|
233 | - $details->post_count = get_option( 'post_count' ); |
|
234 | - $details->home = get_option( 'home' ); |
|
230 | + switch_to_blog($blog_id); |
|
231 | + $details->blogname = get_option('blogname'); |
|
232 | + $details->siteurl = get_option('siteurl'); |
|
233 | + $details->post_count = get_option('post_count'); |
|
234 | + $details->home = get_option('home'); |
|
235 | 235 | restore_current_blog(); |
236 | 236 | |
237 | 237 | /** |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param object $details The blog details. |
243 | 243 | */ |
244 | - $details = apply_filters( 'blog_details', $details ); |
|
244 | + $details = apply_filters('blog_details', $details); |
|
245 | 245 | |
246 | - wp_cache_set( $blog_id . $all, $details, 'blog-details' ); |
|
246 | + wp_cache_set($blog_id.$all, $details, 'blog-details'); |
|
247 | 247 | |
248 | - $key = md5( $details->domain . $details->path ); |
|
249 | - wp_cache_set( $key, $details, 'blog-lookup' ); |
|
248 | + $key = md5($details->domain.$details->path); |
|
249 | + wp_cache_set($key, $details, 'blog-lookup'); |
|
250 | 250 | |
251 | 251 | return $details; |
252 | 252 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @param int $blog_id Optional. Blog ID. Defaults to current blog. |
260 | 260 | */ |
261 | -function refresh_blog_details( $blog_id = 0 ) { |
|
261 | +function refresh_blog_details($blog_id = 0) { |
|
262 | 262 | $blog_id = (int) $blog_id; |
263 | - if ( ! $blog_id ) { |
|
263 | + if ( ! $blog_id) { |
|
264 | 264 | $blog_id = get_current_blog_id(); |
265 | 265 | } |
266 | 266 | |
267 | - $details = get_blog_details( $blog_id, false ); |
|
268 | - if ( ! $details ) { |
|
267 | + $details = get_blog_details($blog_id, false); |
|
268 | + if ( ! $details) { |
|
269 | 269 | // Make sure clean_blog_cache() gets the blog ID |
270 | 270 | // when the blog has been previously cached as |
271 | 271 | // non-existent. |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
279 | - clean_blog_cache( $details ); |
|
279 | + clean_blog_cache($details); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Fires after the blog details cache is cleared. |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param int $blog_id Blog ID. |
287 | 287 | */ |
288 | - do_action( 'refresh_blog_details', $blog_id ); |
|
288 | + do_action('refresh_blog_details', $blog_id); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | * @param array $details Array of details keyed by blogs table field names. |
300 | 300 | * @return bool True if update succeeds, false otherwise. |
301 | 301 | */ |
302 | -function update_blog_details( $blog_id, $details = array() ) { |
|
302 | +function update_blog_details($blog_id, $details = array()) { |
|
303 | 303 | global $wpdb; |
304 | 304 | |
305 | - if ( empty($details) ) |
|
305 | + if (empty($details)) |
|
306 | 306 | return false; |
307 | 307 | |
308 | - if ( is_object($details) ) |
|
308 | + if (is_object($details)) |
|
309 | 309 | $details = get_object_vars($details); |
310 | 310 | |
311 | 311 | $current_details = get_blog_details($blog_id, false); |
312 | - if ( empty($current_details) ) |
|
312 | + if (empty($current_details)) |
|
313 | 313 | return false; |
314 | 314 | |
315 | 315 | $current_details = get_object_vars($current_details); |
@@ -318,23 +318,23 @@ discard block |
||
318 | 318 | $details['last_updated'] = current_time('mysql', true); |
319 | 319 | |
320 | 320 | $update_details = array(); |
321 | - $fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); |
|
322 | - foreach ( array_intersect( array_keys( $details ), $fields ) as $field ) { |
|
323 | - if ( 'path' === $field ) { |
|
324 | - $details[ $field ] = trailingslashit( '/' . trim( $details[ $field ], '/' ) ); |
|
321 | + $fields = array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'); |
|
322 | + foreach (array_intersect(array_keys($details), $fields) as $field) { |
|
323 | + if ('path' === $field) { |
|
324 | + $details[$field] = trailingslashit('/'.trim($details[$field], '/')); |
|
325 | 325 | } |
326 | 326 | |
327 | - $update_details[ $field ] = $details[ $field ]; |
|
327 | + $update_details[$field] = $details[$field]; |
|
328 | 328 | } |
329 | 329 | |
330 | - $result = $wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) ); |
|
330 | + $result = $wpdb->update($wpdb->blogs, $update_details, array('blog_id' => $blog_id)); |
|
331 | 331 | |
332 | - if ( false === $result ) |
|
332 | + if (false === $result) |
|
333 | 333 | return false; |
334 | 334 | |
335 | 335 | // If spam status changed, issue actions. |
336 | - if ( $details['spam'] != $current_details['spam'] ) { |
|
337 | - if ( $details['spam'] == 1 ) { |
|
336 | + if ($details['spam'] != $current_details['spam']) { |
|
337 | + if ($details['spam'] == 1) { |
|
338 | 338 | /** |
339 | 339 | * Fires when the blog status is changed to 'spam'. |
340 | 340 | * |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param int $blog_id Blog ID. |
344 | 344 | */ |
345 | - do_action( 'make_spam_blog', $blog_id ); |
|
345 | + do_action('make_spam_blog', $blog_id); |
|
346 | 346 | } else { |
347 | 347 | /** |
348 | 348 | * Fires when the blog status is changed to 'ham'. |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @param int $blog_id Blog ID. |
353 | 353 | */ |
354 | - do_action( 'make_ham_blog', $blog_id ); |
|
354 | + do_action('make_ham_blog', $blog_id); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | 358 | // If mature status changed, issue actions. |
359 | - if ( $details['mature'] != $current_details['mature'] ) { |
|
360 | - if ( $details['mature'] == 1 ) { |
|
359 | + if ($details['mature'] != $current_details['mature']) { |
|
360 | + if ($details['mature'] == 1) { |
|
361 | 361 | /** |
362 | 362 | * Fires when the blog status is changed to 'mature'. |
363 | 363 | * |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param int $blog_id Blog ID. |
367 | 367 | */ |
368 | - do_action( 'mature_blog', $blog_id ); |
|
368 | + do_action('mature_blog', $blog_id); |
|
369 | 369 | } else { |
370 | 370 | /** |
371 | 371 | * Fires when the blog status is changed to 'unmature'. |
@@ -374,13 +374,13 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @param int $blog_id Blog ID. |
376 | 376 | */ |
377 | - do_action( 'unmature_blog', $blog_id ); |
|
377 | + do_action('unmature_blog', $blog_id); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
381 | 381 | // If archived status changed, issue actions. |
382 | - if ( $details['archived'] != $current_details['archived'] ) { |
|
383 | - if ( $details['archived'] == 1 ) { |
|
382 | + if ($details['archived'] != $current_details['archived']) { |
|
383 | + if ($details['archived'] == 1) { |
|
384 | 384 | /** |
385 | 385 | * Fires when the blog status is changed to 'archived'. |
386 | 386 | * |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param int $blog_id Blog ID. |
390 | 390 | */ |
391 | - do_action( 'archive_blog', $blog_id ); |
|
391 | + do_action('archive_blog', $blog_id); |
|
392 | 392 | } else { |
393 | 393 | /** |
394 | 394 | * Fires when the blog status is changed to 'unarchived'. |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @param int $blog_id Blog ID. |
399 | 399 | */ |
400 | - do_action( 'unarchive_blog', $blog_id ); |
|
400 | + do_action('unarchive_blog', $blog_id); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | // If deleted status changed, issue actions. |
405 | - if ( $details['deleted'] != $current_details['deleted'] ) { |
|
406 | - if ( $details['deleted'] == 1 ) { |
|
405 | + if ($details['deleted'] != $current_details['deleted']) { |
|
406 | + if ($details['deleted'] == 1) { |
|
407 | 407 | /** |
408 | 408 | * Fires when the blog status is changed to 'deleted'. |
409 | 409 | * |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param int $blog_id Blog ID. |
413 | 413 | */ |
414 | - do_action( 'make_delete_blog', $blog_id ); |
|
414 | + do_action('make_delete_blog', $blog_id); |
|
415 | 415 | } else { |
416 | 416 | /** |
417 | 417 | * Fires when the blog status is changed to 'undeleted'. |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @param int $blog_id Blog ID. |
422 | 422 | */ |
423 | - do_action( 'make_undelete_blog', $blog_id ); |
|
423 | + do_action('make_undelete_blog', $blog_id); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | - if ( isset( $details['public'] ) ) { |
|
428 | - switch_to_blog( $blog_id ); |
|
429 | - update_option( 'blog_public', $details['public'] ); |
|
427 | + if (isset($details['public'])) { |
|
428 | + switch_to_blog($blog_id); |
|
429 | + update_option('blog_public', $details['public']); |
|
430 | 430 | restore_current_blog(); |
431 | 431 | } |
432 | 432 | |
@@ -442,18 +442,18 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @param WP_Site $blog The blog details as returned from get_blog_details() |
444 | 444 | */ |
445 | -function clean_blog_cache( $blog ) { |
|
445 | +function clean_blog_cache($blog) { |
|
446 | 446 | $blog_id = $blog->blog_id; |
447 | - $domain_path_key = md5( $blog->domain . $blog->path ); |
|
448 | - |
|
449 | - wp_cache_delete( $blog_id, 'sites' ); |
|
450 | - wp_cache_delete( $blog_id , 'blog-details' ); |
|
451 | - wp_cache_delete( $blog_id . 'short' , 'blog-details' ); |
|
452 | - wp_cache_delete( $domain_path_key, 'blog-lookup' ); |
|
453 | - wp_cache_delete( 'current_blog_' . $blog->domain, 'site-options' ); |
|
454 | - wp_cache_delete( 'current_blog_' . $blog->domain . $blog->path, 'site-options' ); |
|
455 | - wp_cache_delete( 'get_id_from_blogname_' . trim( $blog->path, '/' ), 'blog-details' ); |
|
456 | - wp_cache_delete( $domain_path_key, 'blog-id-cache' ); |
|
447 | + $domain_path_key = md5($blog->domain.$blog->path); |
|
448 | + |
|
449 | + wp_cache_delete($blog_id, 'sites'); |
|
450 | + wp_cache_delete($blog_id, 'blog-details'); |
|
451 | + wp_cache_delete($blog_id.'short', 'blog-details'); |
|
452 | + wp_cache_delete($domain_path_key, 'blog-lookup'); |
|
453 | + wp_cache_delete('current_blog_'.$blog->domain, 'site-options'); |
|
454 | + wp_cache_delete('current_blog_'.$blog->domain.$blog->path, 'site-options'); |
|
455 | + wp_cache_delete('get_id_from_blogname_'.trim($blog->path, '/'), 'blog-details'); |
|
456 | + wp_cache_delete($domain_path_key, 'blog-id-cache'); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -473,17 +473,17 @@ discard block |
||
473 | 473 | * @param mixed $default Optional. Default value to return if the option does not exist. |
474 | 474 | * @return mixed Value set for the option. |
475 | 475 | */ |
476 | -function get_blog_option( $id, $option, $default = false ) { |
|
476 | +function get_blog_option($id, $option, $default = false) { |
|
477 | 477 | $id = (int) $id; |
478 | 478 | |
479 | - if ( empty( $id ) ) |
|
479 | + if (empty($id)) |
|
480 | 480 | $id = get_current_blog_id(); |
481 | 481 | |
482 | - if ( get_current_blog_id() == $id ) |
|
483 | - return get_option( $option, $default ); |
|
482 | + if (get_current_blog_id() == $id) |
|
483 | + return get_option($option, $default); |
|
484 | 484 | |
485 | - switch_to_blog( $id ); |
|
486 | - $value = get_option( $option, $default ); |
|
485 | + switch_to_blog($id); |
|
486 | + $value = get_option($option, $default); |
|
487 | 487 | restore_current_blog(); |
488 | 488 | |
489 | 489 | /** |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @param string $value The option value. |
497 | 497 | * @param int $id Blog ID. |
498 | 498 | */ |
499 | - return apply_filters( "blog_option_{$option}", $value, $id ); |
|
499 | + return apply_filters("blog_option_{$option}", $value, $id); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -518,17 +518,17 @@ discard block |
||
518 | 518 | * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped. |
519 | 519 | * @return bool False if option was not added and true if option was added. |
520 | 520 | */ |
521 | -function add_blog_option( $id, $option, $value ) { |
|
521 | +function add_blog_option($id, $option, $value) { |
|
522 | 522 | $id = (int) $id; |
523 | 523 | |
524 | - if ( empty( $id ) ) |
|
524 | + if (empty($id)) |
|
525 | 525 | $id = get_current_blog_id(); |
526 | 526 | |
527 | - if ( get_current_blog_id() == $id ) |
|
528 | - return add_option( $option, $value ); |
|
527 | + if (get_current_blog_id() == $id) |
|
528 | + return add_option($option, $value); |
|
529 | 529 | |
530 | - switch_to_blog( $id ); |
|
531 | - $return = add_option( $option, $value ); |
|
530 | + switch_to_blog($id); |
|
531 | + $return = add_option($option, $value); |
|
532 | 532 | restore_current_blog(); |
533 | 533 | |
534 | 534 | return $return; |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | * @param string $option Name of option to remove. Expected to not be SQL-escaped. |
544 | 544 | * @return bool True, if option is successfully deleted. False on failure. |
545 | 545 | */ |
546 | -function delete_blog_option( $id, $option ) { |
|
546 | +function delete_blog_option($id, $option) { |
|
547 | 547 | $id = (int) $id; |
548 | 548 | |
549 | - if ( empty( $id ) ) |
|
549 | + if (empty($id)) |
|
550 | 550 | $id = get_current_blog_id(); |
551 | 551 | |
552 | - if ( get_current_blog_id() == $id ) |
|
553 | - return delete_option( $option ); |
|
552 | + if (get_current_blog_id() == $id) |
|
553 | + return delete_option($option); |
|
554 | 554 | |
555 | - switch_to_blog( $id ); |
|
556 | - $return = delete_option( $option ); |
|
555 | + switch_to_blog($id); |
|
556 | + $return = delete_option($option); |
|
557 | 557 | restore_current_blog(); |
558 | 558 | |
559 | 559 | return $return; |
@@ -570,20 +570,20 @@ discard block |
||
570 | 570 | * @param mixed $deprecated Not used. |
571 | 571 | * @return bool True on success, false on failure. |
572 | 572 | */ |
573 | -function update_blog_option( $id, $option, $value, $deprecated = null ) { |
|
573 | +function update_blog_option($id, $option, $value, $deprecated = null) { |
|
574 | 574 | $id = (int) $id; |
575 | 575 | |
576 | - if ( null !== $deprecated ) |
|
577 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
576 | + if (null !== $deprecated) |
|
577 | + _deprecated_argument(__FUNCTION__, '3.1'); |
|
578 | 578 | |
579 | - if ( get_current_blog_id() == $id ) |
|
580 | - return update_option( $option, $value ); |
|
579 | + if (get_current_blog_id() == $id) |
|
580 | + return update_option($option, $value); |
|
581 | 581 | |
582 | - switch_to_blog( $id ); |
|
583 | - $return = update_option( $option, $value ); |
|
582 | + switch_to_blog($id); |
|
583 | + $return = update_option($option, $value); |
|
584 | 584 | restore_current_blog(); |
585 | 585 | |
586 | - refresh_blog_details( $id ); |
|
586 | + refresh_blog_details($id); |
|
587 | 587 | |
588 | 588 | return $return; |
589 | 589 | } |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | * @param bool $deprecated Deprecated argument |
613 | 613 | * @return true Always returns True. |
614 | 614 | */ |
615 | -function switch_to_blog( $new_blog, $deprecated = null ) { |
|
615 | +function switch_to_blog($new_blog, $deprecated = null) { |
|
616 | 616 | global $wpdb; |
617 | 617 | |
618 | - if ( empty( $new_blog ) ) |
|
618 | + if (empty($new_blog)) |
|
619 | 619 | $new_blog = $GLOBALS['blog_id']; |
620 | 620 | |
621 | 621 | $GLOBALS['_wp_switched_stack'][] = $GLOBALS['blog_id']; |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * set the right vars, do the associated actions, but skip |
626 | 626 | * the extra unnecessary work |
627 | 627 | */ |
628 | - if ( $new_blog == $GLOBALS['blog_id'] ) { |
|
628 | + if ($new_blog == $GLOBALS['blog_id']) { |
|
629 | 629 | /** |
630 | 630 | * Fires when the blog is switched. |
631 | 631 | * |
@@ -634,46 +634,46 @@ discard block |
||
634 | 634 | * @param int $new_blog New blog ID. |
635 | 635 | * @param int $new_blog Blog ID. |
636 | 636 | */ |
637 | - do_action( 'switch_blog', $new_blog, $new_blog ); |
|
637 | + do_action('switch_blog', $new_blog, $new_blog); |
|
638 | 638 | $GLOBALS['switched'] = true; |
639 | 639 | return true; |
640 | 640 | } |
641 | 641 | |
642 | - $wpdb->set_blog_id( $new_blog ); |
|
642 | + $wpdb->set_blog_id($new_blog); |
|
643 | 643 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
644 | 644 | $prev_blog_id = $GLOBALS['blog_id']; |
645 | 645 | $GLOBALS['blog_id'] = $new_blog; |
646 | 646 | |
647 | - if ( function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
648 | - wp_cache_switch_to_blog( $new_blog ); |
|
647 | + if (function_exists('wp_cache_switch_to_blog')) { |
|
648 | + wp_cache_switch_to_blog($new_blog); |
|
649 | 649 | } else { |
650 | 650 | global $wp_object_cache; |
651 | 651 | |
652 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
652 | + if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) |
|
653 | 653 | $global_groups = $wp_object_cache->global_groups; |
654 | 654 | else |
655 | 655 | $global_groups = false; |
656 | 656 | |
657 | 657 | wp_cache_init(); |
658 | 658 | |
659 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
660 | - if ( is_array( $global_groups ) ) { |
|
661 | - wp_cache_add_global_groups( $global_groups ); |
|
659 | + if (function_exists('wp_cache_add_global_groups')) { |
|
660 | + if (is_array($global_groups)) { |
|
661 | + wp_cache_add_global_groups($global_groups); |
|
662 | 662 | } else { |
663 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
663 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
664 | 664 | } |
665 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
665 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
669 | - if ( did_action( 'init' ) ) { |
|
669 | + if (did_action('init')) { |
|
670 | 670 | wp_roles()->reinit(); |
671 | 671 | $current_user = wp_get_current_user(); |
672 | - $current_user->for_blog( $new_blog ); |
|
672 | + $current_user->for_blog($new_blog); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** This filter is documented in wp-includes/ms-blogs.php */ |
676 | - do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
|
676 | + do_action('switch_blog', $new_blog, $prev_blog_id); |
|
677 | 677 | $GLOBALS['switched'] = true; |
678 | 678 | |
679 | 679 | return true; |
@@ -697,57 +697,57 @@ discard block |
||
697 | 697 | function restore_current_blog() { |
698 | 698 | global $wpdb; |
699 | 699 | |
700 | - if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
|
700 | + if (empty($GLOBALS['_wp_switched_stack'])) |
|
701 | 701 | return false; |
702 | 702 | |
703 | - $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
|
703 | + $blog = array_pop($GLOBALS['_wp_switched_stack']); |
|
704 | 704 | |
705 | - if ( $GLOBALS['blog_id'] == $blog ) { |
|
705 | + if ($GLOBALS['blog_id'] == $blog) { |
|
706 | 706 | /** This filter is documented in wp-includes/ms-blogs.php */ |
707 | - do_action( 'switch_blog', $blog, $blog ); |
|
707 | + do_action('switch_blog', $blog, $blog); |
|
708 | 708 | // If we still have items in the switched stack, consider ourselves still 'switched' |
709 | - $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
709 | + $GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']); |
|
710 | 710 | return true; |
711 | 711 | } |
712 | 712 | |
713 | - $wpdb->set_blog_id( $blog ); |
|
713 | + $wpdb->set_blog_id($blog); |
|
714 | 714 | $prev_blog_id = $GLOBALS['blog_id']; |
715 | 715 | $GLOBALS['blog_id'] = $blog; |
716 | 716 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
717 | 717 | |
718 | - if ( function_exists( 'wp_cache_switch_to_blog' ) ) { |
|
719 | - wp_cache_switch_to_blog( $blog ); |
|
718 | + if (function_exists('wp_cache_switch_to_blog')) { |
|
719 | + wp_cache_switch_to_blog($blog); |
|
720 | 720 | } else { |
721 | 721 | global $wp_object_cache; |
722 | 722 | |
723 | - if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) |
|
723 | + if (is_object($wp_object_cache) && isset($wp_object_cache->global_groups)) |
|
724 | 724 | $global_groups = $wp_object_cache->global_groups; |
725 | 725 | else |
726 | 726 | $global_groups = false; |
727 | 727 | |
728 | 728 | wp_cache_init(); |
729 | 729 | |
730 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
731 | - if ( is_array( $global_groups ) ) { |
|
732 | - wp_cache_add_global_groups( $global_groups ); |
|
730 | + if (function_exists('wp_cache_add_global_groups')) { |
|
731 | + if (is_array($global_groups)) { |
|
732 | + wp_cache_add_global_groups($global_groups); |
|
733 | 733 | } else { |
734 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
734 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
735 | 735 | } |
736 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
736 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
737 | 737 | } |
738 | 738 | } |
739 | 739 | |
740 | - if ( did_action( 'init' ) ) { |
|
740 | + if (did_action('init')) { |
|
741 | 741 | wp_roles()->reinit(); |
742 | 742 | $current_user = wp_get_current_user(); |
743 | - $current_user->for_blog( $blog ); |
|
743 | + $current_user->for_blog($blog); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** This filter is documented in wp-includes/ms-blogs.php */ |
747 | - do_action( 'switch_blog', $blog, $prev_blog_id ); |
|
747 | + do_action('switch_blog', $blog, $prev_blog_id); |
|
748 | 748 | |
749 | 749 | // If we still have items in the switched stack, consider ourselves still 'switched' |
750 | - $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
750 | + $GLOBALS['switched'] = ! empty($GLOBALS['_wp_switched_stack']); |
|
751 | 751 | |
752 | 752 | return true; |
753 | 753 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * @return bool True if switched, false otherwise. |
763 | 763 | */ |
764 | 764 | function ms_is_switched() { |
765 | - return ! empty( $GLOBALS['_wp_switched_stack'] ); |
|
765 | + return ! empty($GLOBALS['_wp_switched_stack']); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * @param int $id The blog id |
774 | 774 | * @return string Whether the blog is archived or not |
775 | 775 | */ |
776 | -function is_archived( $id ) { |
|
776 | +function is_archived($id) { |
|
777 | 777 | return get_blog_status($id, 'archived'); |
778 | 778 | } |
779 | 779 | |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | * @param string $archived The new status |
787 | 787 | * @return string $archived |
788 | 788 | */ |
789 | -function update_archived( $id, $archived ) { |
|
789 | +function update_archived($id, $archived) { |
|
790 | 790 | update_blog_status($id, 'archived', $archived); |
791 | 791 | return $archived; |
792 | 792 | } |
@@ -804,55 +804,55 @@ discard block |
||
804 | 804 | * @param null $deprecated |
805 | 805 | * @return string|false $value |
806 | 806 | */ |
807 | -function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { |
|
807 | +function update_blog_status($blog_id, $pref, $value, $deprecated = null) { |
|
808 | 808 | global $wpdb; |
809 | 809 | |
810 | - if ( null !== $deprecated ) |
|
811 | - _deprecated_argument( __FUNCTION__, '3.1' ); |
|
810 | + if (null !== $deprecated) |
|
811 | + _deprecated_argument(__FUNCTION__, '3.1'); |
|
812 | 812 | |
813 | - if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) ) |
|
813 | + if ( ! in_array($pref, array('site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'))) |
|
814 | 814 | return $value; |
815 | 815 | |
816 | - $result = $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) ); |
|
816 | + $result = $wpdb->update($wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id)); |
|
817 | 817 | |
818 | - if ( false === $result ) |
|
818 | + if (false === $result) |
|
819 | 819 | return false; |
820 | 820 | |
821 | - refresh_blog_details( $blog_id ); |
|
821 | + refresh_blog_details($blog_id); |
|
822 | 822 | |
823 | - if ( 'spam' == $pref ) { |
|
824 | - if ( $value == 1 ) { |
|
823 | + if ('spam' == $pref) { |
|
824 | + if ($value == 1) { |
|
825 | 825 | /** This filter is documented in wp-includes/ms-blogs.php */ |
826 | - do_action( 'make_spam_blog', $blog_id ); |
|
826 | + do_action('make_spam_blog', $blog_id); |
|
827 | 827 | } else { |
828 | 828 | /** This filter is documented in wp-includes/ms-blogs.php */ |
829 | - do_action( 'make_ham_blog', $blog_id ); |
|
829 | + do_action('make_ham_blog', $blog_id); |
|
830 | 830 | } |
831 | - } elseif ( 'mature' == $pref ) { |
|
832 | - if ( $value == 1 ) { |
|
831 | + } elseif ('mature' == $pref) { |
|
832 | + if ($value == 1) { |
|
833 | 833 | /** This filter is documented in wp-includes/ms-blogs.php */ |
834 | - do_action( 'mature_blog', $blog_id ); |
|
834 | + do_action('mature_blog', $blog_id); |
|
835 | 835 | } else { |
836 | 836 | /** This filter is documented in wp-includes/ms-blogs.php */ |
837 | - do_action( 'unmature_blog', $blog_id ); |
|
837 | + do_action('unmature_blog', $blog_id); |
|
838 | 838 | } |
839 | - } elseif ( 'archived' == $pref ) { |
|
840 | - if ( $value == 1 ) { |
|
839 | + } elseif ('archived' == $pref) { |
|
840 | + if ($value == 1) { |
|
841 | 841 | /** This filter is documented in wp-includes/ms-blogs.php */ |
842 | - do_action( 'archive_blog', $blog_id ); |
|
842 | + do_action('archive_blog', $blog_id); |
|
843 | 843 | } else { |
844 | 844 | /** This filter is documented in wp-includes/ms-blogs.php */ |
845 | - do_action( 'unarchive_blog', $blog_id ); |
|
845 | + do_action('unarchive_blog', $blog_id); |
|
846 | 846 | } |
847 | - } elseif ( 'deleted' == $pref ) { |
|
848 | - if ( $value == 1 ) { |
|
847 | + } elseif ('deleted' == $pref) { |
|
848 | + if ($value == 1) { |
|
849 | 849 | /** This filter is documented in wp-includes/ms-blogs.php */ |
850 | - do_action( 'make_delete_blog', $blog_id ); |
|
850 | + do_action('make_delete_blog', $blog_id); |
|
851 | 851 | } else { |
852 | 852 | /** This filter is documented in wp-includes/ms-blogs.php */ |
853 | - do_action( 'make_undelete_blog', $blog_id ); |
|
853 | + do_action('make_undelete_blog', $blog_id); |
|
854 | 854 | } |
855 | - } elseif ( 'public' == $pref ) { |
|
855 | + } elseif ('public' == $pref) { |
|
856 | 856 | /** |
857 | 857 | * Fires after the current blog's 'public' setting is updated. |
858 | 858 | * |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | * @param int $blog_id Blog ID. |
862 | 862 | * @param string $value The value of blog status. |
863 | 863 | */ |
864 | - do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public(). |
|
864 | + do_action('update_blog_public', $blog_id, $value); // Moved here from update_blog_public(). |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | return $value; |
@@ -878,14 +878,14 @@ discard block |
||
878 | 878 | * @param string $pref A field name |
879 | 879 | * @return bool|string|null $value |
880 | 880 | */ |
881 | -function get_blog_status( $id, $pref ) { |
|
881 | +function get_blog_status($id, $pref) { |
|
882 | 882 | global $wpdb; |
883 | 883 | |
884 | - $details = get_blog_details( $id, false ); |
|
885 | - if ( $details ) |
|
884 | + $details = get_blog_details($id, false); |
|
885 | + if ($details) |
|
886 | 886 | return $details->$pref; |
887 | 887 | |
888 | - return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) ); |
|
888 | + return $wpdb->get_var($wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id)); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -900,13 +900,13 @@ discard block |
||
900 | 900 | * @param int $quantity The maximum number of blogs to retrieve. Default is 40. |
901 | 901 | * @return array The list of blogs |
902 | 902 | */ |
903 | -function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { |
|
903 | +function get_last_updated($deprecated = '', $start = 0, $quantity = 40) { |
|
904 | 904 | global $wpdb; |
905 | 905 | |
906 | - if ( ! empty( $deprecated ) ) |
|
907 | - _deprecated_argument( __FUNCTION__, 'MU' ); // never used |
|
906 | + if ( ! empty($deprecated)) |
|
907 | + _deprecated_argument(__FUNCTION__, 'MU'); // never used |
|
908 | 908 | |
909 | - return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A ); |
|
909 | + return $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity), ARRAY_A); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -918,13 +918,13 @@ discard block |
||
918 | 918 | * @param string $old_status The old post status |
919 | 919 | * @param object $post Post object |
920 | 920 | */ |
921 | -function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { |
|
922 | - $post_type_obj = get_post_type_object( $post->post_type ); |
|
923 | - if ( ! $post_type_obj || ! $post_type_obj->public ) { |
|
921 | +function _update_blog_date_on_post_publish($new_status, $old_status, $post) { |
|
922 | + $post_type_obj = get_post_type_object($post->post_type); |
|
923 | + if ( ! $post_type_obj || ! $post_type_obj->public) { |
|
924 | 924 | return; |
925 | 925 | } |
926 | 926 | |
927 | - if ( 'publish' != $new_status && 'publish' != $old_status ) { |
|
927 | + if ('publish' != $new_status && 'publish' != $old_status) { |
|
928 | 928 | return; |
929 | 929 | } |
930 | 930 | |
@@ -940,15 +940,15 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @param int $post_id Post ID |
942 | 942 | */ |
943 | -function _update_blog_date_on_post_delete( $post_id ) { |
|
944 | - $post = get_post( $post_id ); |
|
943 | +function _update_blog_date_on_post_delete($post_id) { |
|
944 | + $post = get_post($post_id); |
|
945 | 945 | |
946 | - $post_type_obj = get_post_type_object( $post->post_type ); |
|
947 | - if ( ! $post_type_obj || ! $post_type_obj->public ) { |
|
946 | + $post_type_obj = get_post_type_object($post->post_type); |
|
947 | + if ( ! $post_type_obj || ! $post_type_obj->public) { |
|
948 | 948 | return; |
949 | 949 | } |
950 | 950 | |
951 | - if ( 'publish' != $post->post_status ) { |
|
951 | + if ('publish' != $post->post_status) { |
|
952 | 952 | return; |
953 | 953 | } |
954 | 954 | |
@@ -962,10 +962,10 @@ discard block |
||
962 | 962 | * |
963 | 963 | * @param int $post_id Post ID. |
964 | 964 | */ |
965 | -function _update_posts_count_on_delete( $post_id ) { |
|
966 | - $post = get_post( $post_id ); |
|
965 | +function _update_posts_count_on_delete($post_id) { |
|
966 | + $post = get_post($post_id); |
|
967 | 967 | |
968 | - if ( ! $post || 'publish' !== $post->post_status ) { |
|
968 | + if ( ! $post || 'publish' !== $post->post_status) { |
|
969 | 969 | return; |
970 | 970 | } |
971 | 971 | |
@@ -980,12 +980,12 @@ discard block |
||
980 | 980 | * @param string $new_status The status the post is changing to. |
981 | 981 | * @param string $old_status The status the post is changing from. |
982 | 982 | */ |
983 | -function _update_posts_count_on_transition_post_status( $new_status, $old_status ) { |
|
984 | - if ( $new_status === $old_status ) { |
|
983 | +function _update_posts_count_on_transition_post_status($new_status, $old_status) { |
|
984 | + if ($new_status === $old_status) { |
|
985 | 985 | return; |
986 | 986 | } |
987 | 987 | |
988 | - if ( 'publish' !== $new_status && 'publish' !== $old_status ) { |
|
988 | + if ('publish' !== $new_status && 'publish' !== $old_status) { |
|
989 | 989 | return; |
990 | 990 | } |
991 | 991 |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * |
66 | 66 | * @since 3.0.0 |
67 | 67 | * |
68 | - * @return true|string Returns true on success, or drop-in file to include. |
|
68 | + * @return boolean|string Returns true on success, or drop-in file to include. |
|
69 | 69 | */ |
70 | 70 | function ms_site_check() { |
71 | 71 | $blog = get_blog_details(); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * These functions are needed to load Multisite. |
|
4 | - * |
|
5 | - * @since 3.0.0 |
|
6 | - * |
|
7 | - * @package WordPress |
|
8 | - * @subpackage Multisite |
|
9 | - */ |
|
3 | + * These functions are needed to load Multisite. |
|
4 | + * |
|
5 | + * @since 3.0.0 |
|
6 | + * |
|
7 | + * @package WordPress |
|
8 | + * @subpackage Multisite |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Whether a subdomain configuration is enabled. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @since 3.0.0 |
77 | 77 | * |
78 | 78 | * @param bool null Whether to skip the blog status check. Default null. |
79 | - */ |
|
79 | + */ |
|
80 | 80 | $check = apply_filters( 'ms_site_check', null ); |
81 | 81 | if ( null !== $check ) |
82 | 82 | return true; |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * @return bool True if subdomain configuration is enabled, false otherwise. |
17 | 17 | */ |
18 | 18 | function is_subdomain_install() { |
19 | - if ( defined('SUBDOMAIN_INSTALL') ) |
|
19 | + if (defined('SUBDOMAIN_INSTALL')) |
|
20 | 20 | return SUBDOMAIN_INSTALL; |
21 | 21 | |
22 | - return ( defined( 'VHOST' ) && VHOST == 'yes' ); |
|
22 | + return (defined('VHOST') && VHOST == 'yes'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @return array Files to include. |
35 | 35 | */ |
36 | 36 | function wp_get_active_network_plugins() { |
37 | - $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); |
|
38 | - if ( empty( $active_plugins ) ) |
|
37 | + $active_plugins = (array) get_site_option('active_sitewide_plugins', array()); |
|
38 | + if (empty($active_plugins)) |
|
39 | 39 | return array(); |
40 | 40 | |
41 | 41 | $plugins = array(); |
42 | - $active_plugins = array_keys( $active_plugins ); |
|
43 | - sort( $active_plugins ); |
|
42 | + $active_plugins = array_keys($active_plugins); |
|
43 | + sort($active_plugins); |
|
44 | 44 | |
45 | - foreach ( $active_plugins as $plugin ) { |
|
46 | - if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
47 | - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
48 | - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
45 | + foreach ($active_plugins as $plugin) { |
|
46 | + if ( ! validate_file($plugin) // $plugin must validate as file |
|
47 | + && '.php' == substr($plugin, -4) // $plugin must end with '.php' |
|
48 | + && file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist |
|
49 | 49 | ) |
50 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
50 | + $plugins[] = WP_PLUGIN_DIR.'/'.$plugin; |
|
51 | 51 | } |
52 | 52 | return $plugins; |
53 | 53 | } |
@@ -77,40 +77,40 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param bool null Whether to skip the blog status check. Default null. |
79 | 79 | */ |
80 | - $check = apply_filters( 'ms_site_check', null ); |
|
81 | - if ( null !== $check ) |
|
80 | + $check = apply_filters('ms_site_check', null); |
|
81 | + if (null !== $check) |
|
82 | 82 | return true; |
83 | 83 | |
84 | 84 | // Allow super admins to see blocked sites |
85 | - if ( is_super_admin() ) |
|
85 | + if (is_super_admin()) |
|
86 | 86 | return true; |
87 | 87 | |
88 | - if ( '1' == $blog->deleted ) { |
|
89 | - if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) |
|
90 | - return WP_CONTENT_DIR . '/blog-deleted.php'; |
|
88 | + if ('1' == $blog->deleted) { |
|
89 | + if (file_exists(WP_CONTENT_DIR.'/blog-deleted.php')) |
|
90 | + return WP_CONTENT_DIR.'/blog-deleted.php'; |
|
91 | 91 | else |
92 | - wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) ); |
|
92 | + wp_die(__('This site is no longer available.'), '', array('response' => 410)); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( '2' == $blog->deleted ) { |
|
96 | - if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) { |
|
97 | - return WP_CONTENT_DIR . '/blog-inactive.php'; |
|
95 | + if ('2' == $blog->deleted) { |
|
96 | + if (file_exists(WP_CONTENT_DIR.'/blog-inactive.php')) { |
|
97 | + return WP_CONTENT_DIR.'/blog-inactive.php'; |
|
98 | 98 | } else { |
99 | - $admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_current_site()->domain ) ); |
|
99 | + $admin_email = str_replace('@', ' AT ', get_site_option('admin_email', 'support@'.get_current_site()->domain)); |
|
100 | 100 | wp_die( |
101 | 101 | /* translators: %s: admin email link */ |
102 | - sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ), |
|
103 | - sprintf( '<a href="mailto:%s">%s</a>', $admin_email ) |
|
102 | + sprintf(__('This site has not been activated yet. If you are having problems activating your site, please contact %s.'), |
|
103 | + sprintf('<a href="mailto:%s">%s</a>', $admin_email) |
|
104 | 104 | ) |
105 | 105 | ); |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - if ( $blog->archived == '1' || $blog->spam == '1' ) { |
|
110 | - if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) |
|
111 | - return WP_CONTENT_DIR . '/blog-suspended.php'; |
|
109 | + if ($blog->archived == '1' || $blog->spam == '1') { |
|
110 | + if (file_exists(WP_CONTENT_DIR.'/blog-suspended.php')) |
|
111 | + return WP_CONTENT_DIR.'/blog-suspended.php'; |
|
112 | 112 | else |
113 | - wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) ); |
|
113 | + wp_die(__('This site has been archived or suspended.'), '', array('response' => 410)); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return true; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @param int|null $segments Path segments to use. Defaults to null, or the full path. |
128 | 128 | * @return WP_Network|false Network object if successful. False when no network is found. |
129 | 129 | */ |
130 | -function get_network_by_path( $domain, $path, $segments = null ) { |
|
131 | - return WP_Network::get_by_path( $domain, $path, $segments ); |
|
130 | +function get_network_by_path($domain, $path, $segments = null) { |
|
131 | + return WP_Network::get_by_path($domain, $path, $segments); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @param object|int $network The network's database row or ID. |
141 | 141 | * @return WP_Network|false Object containing network information if found, false if not. |
142 | 142 | */ |
143 | -function wp_get_network( $network ) { |
|
144 | - if ( ! is_object( $network ) ) { |
|
145 | - $network = WP_Network::get_instance( $network ); |
|
143 | +function wp_get_network($network) { |
|
144 | + if ( ! is_object($network)) { |
|
145 | + $network = WP_Network::get_instance($network); |
|
146 | 146 | } else { |
147 | - $network = new WP_Network( $network ); |
|
147 | + $network = new WP_Network($network); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | return $network; |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @param int|null $segments Path segments to use. Defaults to null, or the full path. |
163 | 163 | * @return object|false Site object if successful. False when no site is found. |
164 | 164 | */ |
165 | -function get_site_by_path( $domain, $path, $segments = null ) { |
|
165 | +function get_site_by_path($domain, $path, $segments = null) { |
|
166 | 166 | global $wpdb; |
167 | 167 | |
168 | - $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); |
|
168 | + $path_segments = array_filter(explode('/', trim($path, '/'))); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Filter the number of path segments to consider when searching for a site. |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | * @param string $domain The requested domain. |
179 | 179 | * @param string $path The requested path, in full. |
180 | 180 | */ |
181 | - $segments = apply_filters( 'site_by_path_segments_count', $segments, $domain, $path ); |
|
181 | + $segments = apply_filters('site_by_path_segments_count', $segments, $domain, $path); |
|
182 | 182 | |
183 | - if ( null !== $segments && count( $path_segments ) > $segments ) { |
|
184 | - $path_segments = array_slice( $path_segments, 0, $segments ); |
|
183 | + if (null !== $segments && count($path_segments) > $segments) { |
|
184 | + $path_segments = array_slice($path_segments, 0, $segments); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | $paths = array(); |
188 | 188 | |
189 | - while ( count( $path_segments ) ) { |
|
190 | - $paths[] = '/' . implode( '/', $path_segments ) . '/'; |
|
191 | - array_pop( $path_segments ); |
|
189 | + while (count($path_segments)) { |
|
190 | + $paths[] = '/'.implode('/', $path_segments).'/'; |
|
191 | + array_pop($path_segments); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $paths[] = '/'; |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * Default null, meaning the entire path was to be consulted. |
213 | 213 | * @param array $paths The paths to search for, based on $path and $segments. |
214 | 214 | */ |
215 | - $pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths ); |
|
216 | - if ( null !== $pre ) { |
|
215 | + $pre = apply_filters('pre_get_site_by_path', null, $domain, $path, $segments, $paths); |
|
216 | + if (null !== $pre) { |
|
217 | 217 | return $pre; |
218 | 218 | } |
219 | 219 | |
@@ -228,31 +228,31 @@ discard block |
||
228 | 228 | |
229 | 229 | // Either www or non-www is supported, not both. If a www domain is requested, |
230 | 230 | // query for both to provide the proper redirect. |
231 | - $domains = array( $domain ); |
|
232 | - if ( 'www.' === substr( $domain, 0, 4 ) ) { |
|
233 | - $domains[] = substr( $domain, 4 ); |
|
234 | - $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'"; |
|
231 | + $domains = array($domain); |
|
232 | + if ('www.' === substr($domain, 0, 4)) { |
|
233 | + $domains[] = substr($domain, 4); |
|
234 | + $search_domains = "'".implode("', '", $wpdb->_escape($domains))."'"; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( count( $paths ) > 1 ) { |
|
238 | - $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; |
|
237 | + if (count($paths) > 1) { |
|
238 | + $search_paths = "'".implode("', '", $wpdb->_escape($paths))."'"; |
|
239 | 239 | } |
240 | 240 | |
241 | - if ( count( $domains ) > 1 && count( $paths ) > 1 ) { |
|
242 | - $site = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1" ); |
|
243 | - } elseif ( count( $domains ) > 1 ) { |
|
244 | - $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0] ); |
|
241 | + if (count($domains) > 1 && count($paths) > 1) { |
|
242 | + $site = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain IN ($search_domains) AND path IN ($search_paths) ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC LIMIT 1"); |
|
243 | + } elseif (count($domains) > 1) { |
|
244 | + $sql = $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE path = %s", $paths[0]); |
|
245 | 245 | $sql .= " AND domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1"; |
246 | - $site = $wpdb->get_row( $sql ); |
|
247 | - } elseif ( count( $paths ) > 1 ) { |
|
248 | - $sql = $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0] ); |
|
246 | + $site = $wpdb->get_row($sql); |
|
247 | + } elseif (count($paths) > 1) { |
|
248 | + $sql = $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s", $domains[0]); |
|
249 | 249 | $sql .= " AND path IN ($search_paths) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1"; |
250 | - $site = $wpdb->get_row( $sql ); |
|
250 | + $site = $wpdb->get_row($sql); |
|
251 | 251 | } else { |
252 | - $site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0] ) ); |
|
252 | + $site = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $domains[0], $paths[0])); |
|
253 | 253 | } |
254 | 254 | |
255 | - if ( $site ) { |
|
255 | + if ($site) { |
|
256 | 256 | // @todo get_blog_details() |
257 | 257 | return $site; |
258 | 258 | } |
@@ -274,50 +274,50 @@ discard block |
||
274 | 274 | * @param string $domain The requested domain for the error to reference. |
275 | 275 | * @param string $path The requested path for the error to reference. |
276 | 276 | */ |
277 | -function ms_not_installed( $domain, $path ) { |
|
277 | +function ms_not_installed($domain, $path) { |
|
278 | 278 | global $wpdb; |
279 | 279 | |
280 | - if ( ! is_admin() ) { |
|
280 | + if ( ! is_admin()) { |
|
281 | 281 | dead_db(); |
282 | 282 | } |
283 | 283 | |
284 | 284 | wp_load_translations_early(); |
285 | 285 | |
286 | - $title = __( 'Error establishing a database connection' ); |
|
286 | + $title = __('Error establishing a database connection'); |
|
287 | 287 | |
288 | - $msg = '<h1>' . $title . '</h1>'; |
|
289 | - $msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . ''; |
|
290 | - $msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>'; |
|
291 | - $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) ); |
|
292 | - if ( ! $wpdb->get_var( $query ) ) { |
|
293 | - $msg .= '<p>' . sprintf( |
|
288 | + $msg = '<h1>'.$title.'</h1>'; |
|
289 | + $msg .= '<p>'.__('If your site does not display, please contact the owner of this network.').''; |
|
290 | + $msg .= ' '.__('If you are the owner of this network please check that MySQL is running properly and all tables are error free.').'</p>'; |
|
291 | + $query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($wpdb->site)); |
|
292 | + if ( ! $wpdb->get_var($query)) { |
|
293 | + $msg .= '<p>'.sprintf( |
|
294 | 294 | /* translators: %s: table name */ |
295 | - __( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ), |
|
296 | - '<code>' . $wpdb->site . '</code>' |
|
297 | - ) . '</p>'; |
|
295 | + __('<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.'), |
|
296 | + '<code>'.$wpdb->site.'</code>' |
|
297 | + ).'</p>'; |
|
298 | 298 | } else { |
299 | - $msg .= '<p>' . sprintf( |
|
299 | + $msg .= '<p>'.sprintf( |
|
300 | 300 | /* translators: 1: site url, 2: table name, 3: database name */ |
301 | - __( '<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?' ), |
|
302 | - '<code>' . rtrim( $domain . $path, '/' ) . '</code>', |
|
303 | - '<code>' . $wpdb->blogs . '</code>', |
|
304 | - '<code>' . DB_NAME . '</code>' |
|
305 | - ) . '</p>'; |
|
301 | + __('<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?'), |
|
302 | + '<code>'.rtrim($domain.$path, '/').'</code>', |
|
303 | + '<code>'.$wpdb->blogs.'</code>', |
|
304 | + '<code>'.DB_NAME.'</code>' |
|
305 | + ).'</p>'; |
|
306 | 306 | } |
307 | - $msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> '; |
|
307 | + $msg .= '<p><strong>'.__('What do I do now?').'</strong> '; |
|
308 | 308 | /* translators: %s: Codex URL */ |
309 | - $msg .= sprintf( __( 'Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ), |
|
310 | - __( 'https://codex.wordpress.org/Debugging_a_WordPress_Network' ) |
|
309 | + $msg .= sprintf(__('Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.'), |
|
310 | + __('https://codex.wordpress.org/Debugging_a_WordPress_Network') |
|
311 | 311 | ); |
312 | - $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>'; |
|
313 | - foreach ( $wpdb->tables('global') as $t => $table ) { |
|
314 | - if ( 'sitecategories' == $t ) |
|
312 | + $msg .= ' '.__('If you’re still stuck with this message, then check that your database contains the following tables:').'</p><ul>'; |
|
313 | + foreach ($wpdb->tables('global') as $t => $table) { |
|
314 | + if ('sitecategories' == $t) |
|
315 | 315 | continue; |
316 | - $msg .= '<li>' . $table . '</li>'; |
|
316 | + $msg .= '<li>'.$table.'</li>'; |
|
317 | 317 | } |
318 | 318 | $msg .= '</ul>'; |
319 | 319 | |
320 | - wp_die( $msg, $title, array( 'response' => 500 ) ); |
|
320 | + wp_die($msg, $title, array('response' => 500)); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | * @param object $current_site |
334 | 334 | * @return object |
335 | 335 | */ |
336 | -function get_current_site_name( $current_site ) { |
|
337 | - _deprecated_function( __FUNCTION__, '3.9', 'get_current_site()' ); |
|
336 | +function get_current_site_name($current_site) { |
|
337 | + _deprecated_function(__FUNCTION__, '3.9', 'get_current_site()'); |
|
338 | 338 | return $current_site; |
339 | 339 | } |
340 | 340 | |
@@ -354,6 +354,6 @@ discard block |
||
354 | 354 | */ |
355 | 355 | function wpmu_current_site() { |
356 | 356 | global $current_site; |
357 | - _deprecated_function( __FUNCTION__, '3.9' ); |
|
357 | + _deprecated_function(__FUNCTION__, '3.9'); |
|
358 | 358 | return $current_site; |
359 | 359 | } |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @return bool True if subdomain configuration is enabled, false otherwise. |
17 | 17 | */ |
18 | 18 | function is_subdomain_install() { |
19 | - if ( defined('SUBDOMAIN_INSTALL') ) |
|
20 | - return SUBDOMAIN_INSTALL; |
|
19 | + if ( defined('SUBDOMAIN_INSTALL') ) { |
|
20 | + return SUBDOMAIN_INSTALL; |
|
21 | + } |
|
21 | 22 | |
22 | 23 | return ( defined( 'VHOST' ) && VHOST == 'yes' ); |
23 | 24 | } |
@@ -35,8 +36,9 @@ discard block |
||
35 | 36 | */ |
36 | 37 | function wp_get_active_network_plugins() { |
37 | 38 | $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); |
38 | - if ( empty( $active_plugins ) ) |
|
39 | - return array(); |
|
39 | + if ( empty( $active_plugins ) ) { |
|
40 | + return array(); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $plugins = array(); |
42 | 44 | $active_plugins = array_keys( $active_plugins ); |
@@ -46,8 +48,9 @@ discard block |
||
46 | 48 | if ( ! validate_file( $plugin ) // $plugin must validate as file |
47 | 49 | && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
48 | 50 | && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
49 | - ) |
|
50 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
51 | + ) { |
|
52 | + $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
53 | + } |
|
51 | 54 | } |
52 | 55 | return $plugins; |
53 | 56 | } |
@@ -78,18 +81,21 @@ discard block |
||
78 | 81 | * @param bool null Whether to skip the blog status check. Default null. |
79 | 82 | */ |
80 | 83 | $check = apply_filters( 'ms_site_check', null ); |
81 | - if ( null !== $check ) |
|
82 | - return true; |
|
84 | + if ( null !== $check ) { |
|
85 | + return true; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | // Allow super admins to see blocked sites |
85 | - if ( is_super_admin() ) |
|
86 | - return true; |
|
89 | + if ( is_super_admin() ) { |
|
90 | + return true; |
|
91 | + } |
|
87 | 92 | |
88 | 93 | if ( '1' == $blog->deleted ) { |
89 | - if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) |
|
90 | - return WP_CONTENT_DIR . '/blog-deleted.php'; |
|
91 | - else |
|
92 | - wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) ); |
|
94 | + if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) { |
|
95 | + return WP_CONTENT_DIR . '/blog-deleted.php'; |
|
96 | + } else { |
|
97 | + wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) ); |
|
98 | + } |
|
93 | 99 | } |
94 | 100 | |
95 | 101 | if ( '2' == $blog->deleted ) { |
@@ -107,10 +113,11 @@ discard block |
||
107 | 113 | } |
108 | 114 | |
109 | 115 | if ( $blog->archived == '1' || $blog->spam == '1' ) { |
110 | - if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) |
|
111 | - return WP_CONTENT_DIR . '/blog-suspended.php'; |
|
112 | - else |
|
113 | - wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) ); |
|
116 | + if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) { |
|
117 | + return WP_CONTENT_DIR . '/blog-suspended.php'; |
|
118 | + } else { |
|
119 | + wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) ); |
|
120 | + } |
|
114 | 121 | } |
115 | 122 | |
116 | 123 | return true; |
@@ -311,8 +318,9 @@ discard block |
||
311 | 318 | ); |
312 | 319 | $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>'; |
313 | 320 | foreach ( $wpdb->tables('global') as $t => $table ) { |
314 | - if ( 'sitecategories' == $t ) |
|
315 | - continue; |
|
321 | + if ( 'sitecategories' == $t ) { |
|
322 | + continue; |
|
323 | + } |
|
316 | 324 | $msg .= '<li>' . $table . '</li>'; |
317 | 325 | } |
318 | 326 | $msg .= '</ul>'; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @param resource $fh |
71 | - * @return true |
|
71 | + * @return boolean |
|
72 | 72 | */ |
73 | 73 | function export_to_file_handle($fh) { |
74 | 74 | $entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) ); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class for working with MO files |
|
4 | - * |
|
5 | - * @version $Id: mo.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
6 | - * @package pomo |
|
7 | - * @subpackage mo |
|
8 | - */ |
|
3 | + * Class for working with MO files |
|
4 | + * |
|
5 | + * @version $Id: mo.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
6 | + * @package pomo |
|
7 | + * @subpackage mo |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | require_once dirname(__FILE__) . '/translations.php'; |
11 | 11 | require_once dirname(__FILE__) . '/streams.php'; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * @subpackage mo |
8 | 8 | */ |
9 | 9 | |
10 | -require_once dirname(__FILE__) . '/translations.php'; |
|
11 | -require_once dirname(__FILE__) . '/streams.php'; |
|
10 | +require_once dirname(__FILE__).'/translations.php'; |
|
11 | +require_once dirname(__FILE__).'/streams.php'; |
|
12 | 12 | |
13 | -if ( ! class_exists( 'MO', false ) ): |
|
13 | +if ( ! class_exists('MO', false)): |
|
14 | 14 | class MO extends Gettext_Translations { |
15 | 15 | |
16 | 16 | var $_nplurals = 2; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function import_from_file($filename) { |
24 | 24 | $reader = new POMO_FileReader($filename); |
25 | - if (!$reader->is_resource()) |
|
25 | + if ( ! $reader->is_resource()) |
|
26 | 26 | return false; |
27 | 27 | return $this->import_from_reader($reader); |
28 | 28 | } |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function export_to_file($filename) { |
35 | 35 | $fh = fopen($filename, 'wb'); |
36 | - if ( !$fh ) return false; |
|
37 | - $res = $this->export_to_file_handle( $fh ); |
|
36 | + if ( ! $fh) return false; |
|
37 | + $res = $this->export_to_file_handle($fh); |
|
38 | 38 | fclose($fh); |
39 | 39 | return $res; |
40 | 40 | } |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function export() { |
46 | 46 | $tmp_fh = fopen("php://temp", 'r+'); |
47 | - if ( !$tmp_fh ) return false; |
|
48 | - $this->export_to_file_handle( $tmp_fh ); |
|
49 | - rewind( $tmp_fh ); |
|
50 | - return stream_get_contents( $tmp_fh ); |
|
47 | + if ( ! $tmp_fh) return false; |
|
48 | + $this->export_to_file_handle($tmp_fh); |
|
49 | + rewind($tmp_fh); |
|
50 | + return stream_get_contents($tmp_fh); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param Translation_Entry $entry |
55 | 55 | * @return bool |
56 | 56 | */ |
57 | - function is_entry_good_for_export( $entry ) { |
|
58 | - if ( empty( $entry->translations ) ) { |
|
57 | + function is_entry_good_for_export($entry) { |
|
58 | + if (empty($entry->translations)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - if ( !array_filter( $entry->translations ) ) { |
|
62 | + if ( ! array_filter($entry->translations)) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return true |
72 | 72 | */ |
73 | 73 | function export_to_file_handle($fh) { |
74 | - $entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) ); |
|
74 | + $entries = array_filter($this->entries, array($this, 'is_entry_good_for_export')); |
|
75 | 75 | ksort($entries); |
76 | 76 | $magic = 0x950412de; |
77 | 77 | $revision = 0; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | $reader = new POMO_Reader(); |
94 | 94 | |
95 | - foreach($entries as $entry) { |
|
96 | - $originals_table .= $this->export_original($entry) . chr(0); |
|
95 | + foreach ($entries as $entry) { |
|
96 | + $originals_table .= $this->export_original($entry).chr(0); |
|
97 | 97 | $length = $reader->strlen($this->export_original($entry)); |
98 | 98 | fwrite($fh, pack('VV', $length, $current_addr)); |
99 | 99 | $current_addr += $length + 1; // account for the NULL byte after |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | $exported_headers = $this->export_headers(); |
103 | 103 | fwrite($fh, pack('VV', $reader->strlen($exported_headers), $current_addr)); |
104 | 104 | $current_addr += strlen($exported_headers) + 1; |
105 | - $translations_table = $exported_headers . chr(0); |
|
105 | + $translations_table = $exported_headers.chr(0); |
|
106 | 106 | |
107 | - foreach($entries as $entry) { |
|
108 | - $translations_table .= $this->export_translations($entry) . chr(0); |
|
107 | + foreach ($entries as $entry) { |
|
108 | + $translations_table .= $this->export_translations($entry).chr(0); |
|
109 | 109 | $length = $reader->strlen($this->export_translations($entry)); |
110 | 110 | fwrite($fh, pack('VV', $length, $current_addr)); |
111 | 111 | $current_addr += $length + 1; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | //TODO: warnings for control characters |
125 | 125 | $exported = $entry->singular; |
126 | 126 | if ($entry->is_plural) $exported .= chr(0).$entry->plural; |
127 | - if ($entry->context) $exported = $entry->context . chr(4) . $exported; |
|
127 | + if ($entry->context) $exported = $entry->context.chr(4).$exported; |
|
128 | 128 | return $exported; |
129 | 129 | } |
130 | 130 | |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function export_headers() { |
144 | 144 | $exported = ''; |
145 | - foreach($this->headers as $header => $value) { |
|
146 | - $exported.= "$header: $value\n"; |
|
145 | + foreach ($this->headers as $header => $value) { |
|
146 | + $exported .= "$header: $value\n"; |
|
147 | 147 | } |
148 | 148 | return $exported; |
149 | 149 | } |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | // The magic is 0x950412de |
157 | 157 | |
158 | 158 | // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 |
159 | - $magic_little = (int) - 1794895138; |
|
159 | + $magic_little = (int) -1794895138; |
|
160 | 160 | $magic_little_64 = (int) 2500072158; |
161 | 161 | // 0xde120495 |
162 | - $magic_big = ((int) - 569244523) & 0xFFFFFFFF; |
|
162 | + $magic_big = ((int) -569244523) & 0xFFFFFFFF; |
|
163 | 163 | if ($magic_little == $magic || $magic_little_64 == $magic) { |
164 | 164 | return 'little'; |
165 | 165 | } else if ($magic_big == $magic) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | $reader->setEndian($endian_string); |
181 | 181 | |
182 | - $endian = ('big' == $endian_string)? 'N' : 'V'; |
|
182 | + $endian = ('big' == $endian_string) ? 'N' : 'V'; |
|
183 | 183 | |
184 | 184 | $header = $reader->read(24); |
185 | 185 | if ($reader->strlen($header) != 24) |
@@ -187,42 +187,42 @@ discard block |
||
187 | 187 | |
188 | 188 | // parse header |
189 | 189 | $header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header); |
190 | - if (!is_array($header)) |
|
190 | + if ( ! is_array($header)) |
|
191 | 191 | return false; |
192 | 192 | |
193 | 193 | // support revision 0 of MO format specs, only |
194 | - if ( $header['revision'] != 0 ) { |
|
194 | + if ($header['revision'] != 0) { |
|
195 | 195 | return false; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // seek to data blocks |
199 | - $reader->seekto( $header['originals_lenghts_addr'] ); |
|
199 | + $reader->seekto($header['originals_lenghts_addr']); |
|
200 | 200 | |
201 | 201 | // read originals' indices |
202 | 202 | $originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr']; |
203 | - if ( $originals_lengths_length != $header['total'] * 8 ) { |
|
203 | + if ($originals_lengths_length != $header['total'] * 8) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $originals = $reader->read($originals_lengths_length); |
208 | - if ( $reader->strlen( $originals ) != $originals_lengths_length ) { |
|
208 | + if ($reader->strlen($originals) != $originals_lengths_length) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | |
212 | 212 | // read translations' indices |
213 | 213 | $translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr']; |
214 | - if ( $translations_lenghts_length != $header['total'] * 8 ) { |
|
214 | + if ($translations_lenghts_length != $header['total'] * 8) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | 218 | $translations = $reader->read($translations_lenghts_length); |
219 | - if ( $reader->strlen( $translations ) != $translations_lenghts_length ) { |
|
219 | + if ($reader->strlen($translations) != $translations_lenghts_length) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // transform raw data into set of indices |
224 | - $originals = $reader->str_split( $originals, 8 ); |
|
225 | - $translations = $reader->str_split( $translations, 8 ); |
|
224 | + $originals = $reader->str_split($originals, 8); |
|
225 | + $translations = $reader->str_split($translations, 8); |
|
226 | 226 | |
227 | 227 | // skip hash table |
228 | 228 | $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4; |
@@ -232,17 +232,17 @@ discard block |
||
232 | 232 | $strings = $reader->read_all(); |
233 | 233 | $reader->close(); |
234 | 234 | |
235 | - for ( $i = 0; $i < $header['total']; $i++ ) { |
|
236 | - $o = unpack( "{$endian}length/{$endian}pos", $originals[$i] ); |
|
237 | - $t = unpack( "{$endian}length/{$endian}pos", $translations[$i] ); |
|
238 | - if ( !$o || !$t ) return false; |
|
235 | + for ($i = 0; $i < $header['total']; $i++) { |
|
236 | + $o = unpack("{$endian}length/{$endian}pos", $originals[$i]); |
|
237 | + $t = unpack("{$endian}length/{$endian}pos", $translations[$i]); |
|
238 | + if ( ! $o || ! $t) return false; |
|
239 | 239 | |
240 | 240 | // adjust offset due to reading strings to separate space before |
241 | 241 | $o['pos'] -= $strings_addr; |
242 | 242 | $t['pos'] -= $strings_addr; |
243 | 243 | |
244 | - $original = $reader->substr( $strings, $o['pos'], $o['length'] ); |
|
245 | - $translation = $reader->substr( $strings, $t['pos'], $t['length'] ); |
|
244 | + $original = $reader->substr($strings, $o['pos'], $o['length']); |
|
245 | + $translation = $reader->substr($strings, $t['pos'], $t['length']); |
|
246 | 246 | |
247 | 247 | if ('' === $original) { |
248 | 248 | $this->set_headers($this->make_headers($translation)); |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function import_from_file($filename) { |
24 | 24 | $reader = new POMO_FileReader($filename); |
25 | - if (!$reader->is_resource()) |
|
26 | - return false; |
|
25 | + if (!$reader->is_resource()) { |
|
26 | + return false; |
|
27 | + } |
|
27 | 28 | return $this->import_from_reader($reader); |
28 | 29 | } |
29 | 30 | |
@@ -33,7 +34,9 @@ discard block |
||
33 | 34 | */ |
34 | 35 | function export_to_file($filename) { |
35 | 36 | $fh = fopen($filename, 'wb'); |
36 | - if ( !$fh ) return false; |
|
37 | + if ( !$fh ) { |
|
38 | + return false; |
|
39 | + } |
|
37 | 40 | $res = $this->export_to_file_handle( $fh ); |
38 | 41 | fclose($fh); |
39 | 42 | return $res; |
@@ -44,7 +47,9 @@ discard block |
||
44 | 47 | */ |
45 | 48 | function export() { |
46 | 49 | $tmp_fh = fopen("php://temp", 'r+'); |
47 | - if ( !$tmp_fh ) return false; |
|
50 | + if ( !$tmp_fh ) { |
|
51 | + return false; |
|
52 | + } |
|
48 | 53 | $this->export_to_file_handle( $tmp_fh ); |
49 | 54 | rewind( $tmp_fh ); |
50 | 55 | return stream_get_contents( $tmp_fh ); |
@@ -123,8 +128,12 @@ discard block |
||
123 | 128 | function export_original($entry) { |
124 | 129 | //TODO: warnings for control characters |
125 | 130 | $exported = $entry->singular; |
126 | - if ($entry->is_plural) $exported .= chr(0).$entry->plural; |
|
127 | - if ($entry->context) $exported = $entry->context . chr(4) . $exported; |
|
131 | + if ($entry->is_plural) { |
|
132 | + $exported .= chr(0).$entry->plural; |
|
133 | + } |
|
134 | + if ($entry->context) { |
|
135 | + $exported = $entry->context . chr(4) . $exported; |
|
136 | + } |
|
128 | 137 | return $exported; |
129 | 138 | } |
130 | 139 | |
@@ -182,13 +191,15 @@ discard block |
||
182 | 191 | $endian = ('big' == $endian_string)? 'N' : 'V'; |
183 | 192 | |
184 | 193 | $header = $reader->read(24); |
185 | - if ($reader->strlen($header) != 24) |
|
186 | - return false; |
|
194 | + if ($reader->strlen($header) != 24) { |
|
195 | + return false; |
|
196 | + } |
|
187 | 197 | |
188 | 198 | // parse header |
189 | 199 | $header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header); |
190 | - if (!is_array($header)) |
|
191 | - return false; |
|
200 | + if (!is_array($header)) { |
|
201 | + return false; |
|
202 | + } |
|
192 | 203 | |
193 | 204 | // support revision 0 of MO format specs, only |
194 | 205 | if ( $header['revision'] != 0 ) { |
@@ -235,7 +246,9 @@ discard block |
||
235 | 246 | for ( $i = 0; $i < $header['total']; $i++ ) { |
236 | 247 | $o = unpack( "{$endian}length/{$endian}pos", $originals[$i] ); |
237 | 248 | $t = unpack( "{$endian}length/{$endian}pos", $translations[$i] ); |
238 | - if ( !$o || !$t ) return false; |
|
249 | + if ( !$o || !$t ) { |
|
250 | + return false; |
|
251 | + } |
|
239 | 252 | |
240 | 253 | // adjust offset due to reading strings to separate space before |
241 | 254 | $o['pos'] -= $strings_addr; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Sets the endianness of the file. |
34 | 34 | * |
35 | - * @param $endian string 'big' or 'little' |
|
35 | + * @param string $endian string 'big' or 'little' |
|
36 | 36 | */ |
37 | 37 | function setEndian($endian) { |
38 | 38 | $this->endian = $endian; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Reads a 32bit Integer from the Stream |
43 | 43 | * |
44 | - * @return mixed The integer, corresponding to the next 32 bits from |
|
44 | + * @return integer The integer, corresponding to the next 32 bits from |
|
45 | 45 | * the stream of false if there are not enough bytes or on error |
46 | 46 | */ |
47 | 47 | function readint32() { |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * @return true |
|
122 | + * @return boolean |
|
123 | 123 | */ |
124 | 124 | function is_resource() { |
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | - * @return true |
|
129 | + * @return boolean |
|
130 | 130 | */ |
131 | 131 | function close() { |
132 | 132 | return true; |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function readint32() { |
48 | 48 | $bytes = $this->read(4); |
49 | - if (4 != $this->strlen($bytes)) |
|
50 | - return false; |
|
49 | + if (4 != $this->strlen($bytes)) { |
|
50 | + return false; |
|
51 | + } |
|
51 | 52 | $endian_letter = ('big' == $this->endian)? 'N' : 'V'; |
52 | 53 | $int = unpack($endian_letter, $bytes); |
53 | 54 | return reset( $int ); |
@@ -62,8 +63,9 @@ discard block |
||
62 | 63 | */ |
63 | 64 | function readint32array($count) { |
64 | 65 | $bytes = $this->read(4 * $count); |
65 | - if (4*$count != $this->strlen($bytes)) |
|
66 | - return false; |
|
66 | + if (4*$count != $this->strlen($bytes)) { |
|
67 | + return false; |
|
68 | + } |
|
67 | 69 | $endian_letter = ('big' == $this->endian)? 'N' : 'V'; |
68 | 70 | return unpack($endian_letter.$count, $bytes); |
69 | 71 | } |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | if (!function_exists('str_split')) { |
104 | 106 | $length = $this->strlen($string); |
105 | 107 | $out = array(); |
106 | - for ($i = 0; $i < $length; $i += $chunk_size) |
|
107 | - $out[] = $this->substr($string, $i, $chunk_size); |
|
108 | + for ($i = 0; $i < $length; $i += $chunk_size) { |
|
109 | + $out[] = $this->substr($string, $i, $chunk_size); |
|
110 | + } |
|
108 | 111 | return $out; |
109 | 112 | } else { |
110 | 113 | return str_split( $string, $chunk_size ); |
@@ -197,8 +200,9 @@ discard block |
||
197 | 200 | */ |
198 | 201 | function read_all() { |
199 | 202 | $all = ''; |
200 | - while ( !$this->feof() ) |
|
201 | - $all .= $this->read(4096); |
|
203 | + while ( !$this->feof() ) { |
|
204 | + $all .= $this->read(4096); |
|
205 | + } |
|
202 | 206 | return $all; |
203 | 207 | } |
204 | 208 | } |
@@ -236,7 +240,9 @@ discard block |
||
236 | 240 | function read($bytes) { |
237 | 241 | $data = $this->substr($this->_str, $this->_pos, $bytes); |
238 | 242 | $this->_pos += $bytes; |
239 | - if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str); |
|
243 | + if ($this->strlen($this->_str) < $this->_pos) { |
|
244 | + $this->_pos = $this->strlen($this->_str); |
|
245 | + } |
|
240 | 246 | return $data; |
241 | 247 | } |
242 | 248 | |
@@ -246,7 +252,9 @@ discard block |
||
246 | 252 | */ |
247 | 253 | function seekto($pos) { |
248 | 254 | $this->_pos = $pos; |
249 | - if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str); |
|
255 | + if ($this->strlen($this->_str) < $this->_pos) { |
|
256 | + $this->_pos = $this->strlen($this->_str); |
|
257 | + } |
|
250 | 258 | return $this->_pos; |
251 | 259 | } |
252 | 260 | |
@@ -278,8 +286,9 @@ discard block |
||
278 | 286 | function __construct( $filename ) { |
279 | 287 | parent::POMO_StringReader(); |
280 | 288 | $this->_str = file_get_contents($filename); |
281 | - if (false === $this->_str) |
|
282 | - return false; |
|
289 | + if (false === $this->_str) { |
|
290 | + return false; |
|
291 | + } |
|
283 | 292 | $this->_pos = 0; |
284 | 293 | } |
285 | 294 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Classes, which help reading streams of data from files. |
|
4 | - * Based on the classes from Danilo Segan <[email protected]> |
|
5 | - * |
|
6 | - * @version $Id: streams.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
7 | - * @package pomo |
|
8 | - * @subpackage streams |
|
9 | - */ |
|
3 | + * Classes, which help reading streams of data from files. |
|
4 | + * Based on the classes from Danilo Segan <[email protected]> |
|
5 | + * |
|
6 | + * @version $Id: streams.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
7 | + * @package pomo |
|
8 | + * @subpackage streams |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | if ( ! class_exists( 'POMO_Reader', false ) ): |
12 | 12 | class POMO_Reader { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage streams |
9 | 9 | */ |
10 | 10 | |
11 | -if ( ! class_exists( 'POMO_Reader', false ) ): |
|
11 | +if ( ! class_exists('POMO_Reader', false)): |
|
12 | 12 | class POMO_Reader { |
13 | 13 | |
14 | 14 | var $endian = 'little'; |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $bytes = $this->read(4); |
49 | 49 | if (4 != $this->strlen($bytes)) |
50 | 50 | return false; |
51 | - $endian_letter = ('big' == $this->endian)? 'N' : 'V'; |
|
51 | + $endian_letter = ('big' == $this->endian) ? 'N' : 'V'; |
|
52 | 52 | $int = unpack($endian_letter, $bytes); |
53 | - return reset( $int ); |
|
53 | + return reset($int); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function readint32array($count) { |
64 | 64 | $bytes = $this->read(4 * $count); |
65 | - if (4*$count != $this->strlen($bytes)) |
|
65 | + if (4 * $count != $this->strlen($bytes)) |
|
66 | 66 | return false; |
67 | - $endian_letter = ('big' == $this->endian)? 'N' : 'V'; |
|
67 | + $endian_letter = ('big' == $this->endian) ? 'N' : 'V'; |
|
68 | 68 | return unpack($endian_letter.$count, $bytes); |
69 | 69 | } |
70 | 70 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * @return array |
101 | 101 | */ |
102 | 102 | function str_split($string, $chunk_size) { |
103 | - if (!function_exists('str_split')) { |
|
103 | + if ( ! function_exists('str_split')) { |
|
104 | 104 | $length = $this->strlen($string); |
105 | 105 | $out = array(); |
106 | 106 | for ($i = 0; $i < $length; $i += $chunk_size) |
107 | 107 | $out[] = $this->substr($string, $i, $chunk_size); |
108 | 108 | return $out; |
109 | 109 | } else { |
110 | - return str_split( $string, $chunk_size ); |
|
110 | + return str_split($string, $chunk_size); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | } |
135 | 135 | endif; |
136 | 136 | |
137 | -if ( ! class_exists( 'POMO_FileReader', false ) ): |
|
137 | +if ( ! class_exists('POMO_FileReader', false)): |
|
138 | 138 | class POMO_FileReader extends POMO_Reader { |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * @param string $filename |
142 | 142 | */ |
143 | - function __construct( $filename ) { |
|
143 | + function __construct($filename) { |
|
144 | 144 | parent::POMO_Reader(); |
145 | 145 | $this->_f = fopen($filename, 'rb'); |
146 | 146 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * PHP4 constructor. |
150 | 150 | */ |
151 | - public function POMO_FileReader( $filename ) { |
|
152 | - self::__construct( $filename ); |
|
151 | + public function POMO_FileReader($filename) { |
|
152 | + self::__construct($filename); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | */ |
198 | 198 | function read_all() { |
199 | 199 | $all = ''; |
200 | - while ( !$this->feof() ) |
|
200 | + while ( ! $this->feof()) |
|
201 | 201 | $all .= $this->read(4096); |
202 | 202 | return $all; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | endif; |
206 | 206 | |
207 | -if ( ! class_exists( 'POMO_StringReader', false ) ): |
|
207 | +if ( ! class_exists('POMO_StringReader', false)): |
|
208 | 208 | /** |
209 | 209 | * Provides file-like methods for manipulating a string instead |
210 | 210 | * of a physical file. |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * PHP5 constructor. |
218 | 218 | */ |
219 | - function __construct( $str = '' ) { |
|
219 | + function __construct($str = '') { |
|
220 | 220 | parent::POMO_Reader(); |
221 | 221 | $this->_str = $str; |
222 | 222 | $this->_pos = 0; |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | /** |
226 | 226 | * PHP4 constructor. |
227 | 227 | */ |
228 | - public function POMO_StringReader( $str = '' ) { |
|
229 | - self::__construct( $str ); |
|
228 | + public function POMO_StringReader($str = '') { |
|
229 | + self::__construct($str); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | } |
268 | 268 | endif; |
269 | 269 | |
270 | -if ( ! class_exists( 'POMO_CachedFileReader', false ) ): |
|
270 | +if ( ! class_exists('POMO_CachedFileReader', false)): |
|
271 | 271 | /** |
272 | 272 | * Reads the contents of the file in the beginning. |
273 | 273 | */ |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | /** |
276 | 276 | * PHP5 constructor. |
277 | 277 | */ |
278 | - function __construct( $filename ) { |
|
278 | + function __construct($filename) { |
|
279 | 279 | parent::POMO_StringReader(); |
280 | 280 | $this->_str = file_get_contents($filename); |
281 | 281 | if (false === $this->_str) |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * PHP4 constructor. |
288 | 288 | */ |
289 | - public function POMO_CachedFileReader( $filename ) { |
|
290 | - self::__construct( $filename ); |
|
289 | + public function POMO_CachedFileReader($filename) { |
|
290 | + self::__construct($filename); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | endif; |
294 | 294 | |
295 | -if ( ! class_exists( 'POMO_CachedIntFileReader', false ) ): |
|
295 | +if ( ! class_exists('POMO_CachedIntFileReader', false)): |
|
296 | 296 | /** |
297 | 297 | * Reads the contents of the file in the beginning. |
298 | 298 | */ |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | /** |
301 | 301 | * PHP5 constructor. |
302 | 302 | */ |
303 | - public function __construct( $filename ) { |
|
303 | + public function __construct($filename) { |
|
304 | 304 | parent::POMO_CachedFileReader($filename); |
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | 308 | * PHP4 constructor. |
309 | 309 | */ |
310 | - function POMO_CachedIntFileReader( $filename ) { |
|
311 | - self::__construct( $filename ); |
|
310 | + function POMO_CachedIntFileReader($filename) { |
|
311 | + self::__construct($filename); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | endif; |
@@ -18,6 +18,7 @@ discard block |
||
18 | 18 | * Add entry to the PO structure |
19 | 19 | * |
20 | 20 | * @param array|Translation_Entry &$entry |
21 | + * @param Translation_Entry $entry |
|
21 | 22 | * @return bool true on success, false if the entry doesn't have a key |
22 | 23 | */ |
23 | 24 | function add_entry($entry) { |
@@ -72,6 +73,7 @@ discard block |
||
72 | 73 | |
73 | 74 | /** |
74 | 75 | * @param string $header |
76 | + * @return string |
|
75 | 77 | */ |
76 | 78 | function get_header($header) { |
77 | 79 | return isset($this->headers[$header])? $this->headers[$header] : false; |
@@ -150,7 +152,7 @@ discard block |
||
150 | 152 | } |
151 | 153 | |
152 | 154 | /** |
153 | - * @param object $other |
|
155 | + * @param Translations $other |
|
154 | 156 | */ |
155 | 157 | function merge_originals_with(&$other) { |
156 | 158 | foreach( $other->entries as $entry ) { |
@@ -326,7 +328,7 @@ discard block |
||
326 | 328 | /** |
327 | 329 | * |
328 | 330 | * @param int $count |
329 | - * @return bool |
|
331 | + * @return integer |
|
330 | 332 | */ |
331 | 333 | function select_plural_form($count) { |
332 | 334 | return 1 == $count? 0 : 1; |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | $entry = new Translation_Entry($entry); |
26 | 26 | } |
27 | 27 | $key = $entry->key(); |
28 | - if (false === $key) return false; |
|
28 | + if (false === $key) { |
|
29 | + return false; |
|
30 | + } |
|
29 | 31 | $this->entries[$key] = &$entry; |
30 | 32 | return true; |
31 | 33 | } |
@@ -39,11 +41,14 @@ discard block |
||
39 | 41 | $entry = new Translation_Entry($entry); |
40 | 42 | } |
41 | 43 | $key = $entry->key(); |
42 | - if (false === $key) return false; |
|
43 | - if (isset($this->entries[$key])) |
|
44 | - $this->entries[$key]->merge_with($entry); |
|
45 | - else |
|
46 | - $this->entries[$key] = &$entry; |
|
44 | + if (false === $key) { |
|
45 | + return false; |
|
46 | + } |
|
47 | + if (isset($this->entries[$key])) { |
|
48 | + $this->entries[$key]->merge_with($entry); |
|
49 | + } else { |
|
50 | + $this->entries[$key] = &$entry; |
|
51 | + } |
|
47 | 52 | return true; |
48 | 53 | } |
49 | 54 | |
@@ -131,10 +136,11 @@ discard block |
||
131 | 136 | $total_plural_forms = $this->get_plural_forms_count(); |
132 | 137 | if ($translated && 0 <= $index && $index < $total_plural_forms && |
133 | 138 | is_array($translated->translations) && |
134 | - isset($translated->translations[$index])) |
|
135 | - return $translated->translations[$index]; |
|
136 | - else |
|
137 | - return 1 == $count? $singular : $plural; |
|
139 | + isset($translated->translations[$index])) { |
|
140 | + return $translated->translations[$index]; |
|
141 | + } else { |
|
142 | + return 1 == $count? $singular : $plural; |
|
143 | + } |
|
138 | 144 | } |
139 | 145 | |
140 | 146 | /** |
@@ -154,10 +160,11 @@ discard block |
||
154 | 160 | */ |
155 | 161 | function merge_originals_with(&$other) { |
156 | 162 | foreach( $other->entries as $entry ) { |
157 | - if ( !isset( $this->entries[$entry->key()] ) ) |
|
158 | - $this->entries[$entry->key()] = $entry; |
|
159 | - else |
|
160 | - $this->entries[$entry->key()]->merge_with($entry); |
|
163 | + if ( !isset( $this->entries[$entry->key()] ) ) { |
|
164 | + $this->entries[$entry->key()] = $entry; |
|
165 | + } else { |
|
166 | + $this->entries[$entry->key()]->merge_with($entry); |
|
167 | + } |
|
161 | 168 | } |
162 | 169 | } |
163 | 170 | } |
@@ -251,7 +258,9 @@ discard block |
||
251 | 258 | $lines = explode("\n", $translation); |
252 | 259 | foreach($lines as $line) { |
253 | 260 | $parts = explode(':', $line, 2); |
254 | - if (!isset($parts[1])) continue; |
|
261 | + if (!isset($parts[1])) { |
|
262 | + continue; |
|
263 | + } |
|
255 | 264 | $headers[trim($parts[0])] = trim($parts[1]); |
256 | 265 | } |
257 | 266 | return $headers; |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class for a set of entries for translation and their associated headers |
|
4 | - * |
|
5 | - * @version $Id: translations.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
6 | - * @package pomo |
|
7 | - * @subpackage translations |
|
8 | - */ |
|
3 | + * Class for a set of entries for translation and their associated headers |
|
4 | + * |
|
5 | + * @version $Id: translations.php 1157 2015-11-20 04:30:11Z dd32 $ |
|
6 | + * @package pomo |
|
7 | + * @subpackage translations |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | require_once dirname(__FILE__) . '/entry.php'; |
11 | 11 |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | * @subpackage translations |
8 | 8 | */ |
9 | 9 | |
10 | -require_once dirname(__FILE__) . '/entry.php'; |
|
10 | +require_once dirname(__FILE__).'/entry.php'; |
|
11 | 11 | |
12 | -if ( ! class_exists( 'Translations', false ) ): |
|
12 | +if ( ! class_exists('Translations', false)): |
|
13 | 13 | class Translations { |
14 | 14 | var $entries = array(); |
15 | 15 | var $headers = array(); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $headers |
66 | 66 | */ |
67 | 67 | function set_headers($headers) { |
68 | - foreach($headers as $header => $value) { |
|
68 | + foreach ($headers as $header => $value) { |
|
69 | 69 | $this->set_header($header, $value); |
70 | 70 | } |
71 | 71 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string $header |
75 | 75 | */ |
76 | 76 | function get_header($header) { |
77 | - return isset($this->headers[$header])? $this->headers[$header] : false; |
|
77 | + return isset($this->headers[$header]) ? $this->headers[$header] : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function translate_entry(&$entry) { |
84 | 84 | $key = $entry->key(); |
85 | - return isset($this->entries[$key])? $this->entries[$key] : false; |
|
85 | + return isset($this->entries[$key]) ? $this->entries[$key] : false; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @param string $context |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - function translate($singular, $context=null) { |
|
93 | + function translate($singular, $context = null) { |
|
94 | 94 | $entry = new Translation_Entry(array('singular' => $singular, 'context' => $context)); |
95 | 95 | $translated = $this->translate_entry($entry); |
96 | - return ($translated && !empty($translated->translations))? $translated->translations[0] : $singular; |
|
96 | + return ($translated && ! empty($translated->translations)) ? $translated->translations[0] : $singular; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param integer $count number of items |
109 | 109 | */ |
110 | 110 | function select_plural_form($count) { |
111 | - return 1 == $count? 0 : 1; |
|
111 | + return 1 == $count ? 0 : 1; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | isset($translated->translations[$index])) |
135 | 135 | return $translated->translations[$index]; |
136 | 136 | else |
137 | - return 1 == $count? $singular : $plural; |
|
137 | + return 1 == $count ? $singular : $plural; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return void |
145 | 145 | **/ |
146 | 146 | function merge_with(&$other) { |
147 | - foreach( $other->entries as $entry ) { |
|
147 | + foreach ($other->entries as $entry) { |
|
148 | 148 | $this->entries[$entry->key()] = $entry; |
149 | 149 | } |
150 | 150 | } |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param object $other |
154 | 154 | */ |
155 | 155 | function merge_originals_with(&$other) { |
156 | - foreach( $other->entries as $entry ) { |
|
157 | - if ( !isset( $this->entries[$entry->key()] ) ) |
|
156 | + foreach ($other->entries as $entry) { |
|
157 | + if ( ! isset($this->entries[$entry->key()])) |
|
158 | 158 | $this->entries[$entry->key()] = $entry; |
159 | 159 | else |
160 | 160 | $this->entries[$entry->key()]->merge_with($entry); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param int $count |
173 | 173 | */ |
174 | 174 | function gettext_select_plural_form($count) { |
175 | - if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) { |
|
176 | - list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); |
|
175 | + if ( ! isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) { |
|
176 | + list($nplurals, $expression) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); |
|
177 | 177 | $this->_nplurals = $nplurals; |
178 | 178 | $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression); |
179 | 179 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function nplurals_and_expression_from_header($header) { |
188 | 188 | if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) { |
189 | - $nplurals = (int)$matches[1]; |
|
189 | + $nplurals = (int) $matches[1]; |
|
190 | 190 | $expression = trim($this->parenthesize_plural_exression($matches[2])); |
191 | 191 | return array($nplurals, $expression); |
192 | 192 | } else { |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | $res .= ') : ('; |
231 | 231 | break; |
232 | 232 | case ';': |
233 | - $res .= str_repeat(')', $depth) . ';'; |
|
234 | - $depth= 0; |
|
233 | + $res .= str_repeat(')', $depth).';'; |
|
234 | + $depth = 0; |
|
235 | 235 | break; |
236 | 236 | default: |
237 | 237 | $res .= $char; |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | // sometimes \ns are used instead of real new lines |
250 | 250 | $translation = str_replace('\n', "\n", $translation); |
251 | 251 | $lines = explode("\n", $translation); |
252 | - foreach($lines as $line) { |
|
252 | + foreach ($lines as $line) { |
|
253 | 253 | $parts = explode(':', $line, 2); |
254 | - if (!isset($parts[1])) continue; |
|
254 | + if ( ! isset($parts[1])) continue; |
|
255 | 255 | $headers[trim($parts[0])] = trim($parts[1]); |
256 | 256 | } |
257 | 257 | return $headers; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | function set_header($header, $value) { |
265 | 265 | parent::set_header($header, $value); |
266 | 266 | if ('Plural-Forms' == $header) { |
267 | - list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); |
|
267 | + list($nplurals, $expression) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); |
|
268 | 268 | $this->_nplurals = $nplurals; |
269 | 269 | $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression); |
270 | 270 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | endif; |
274 | 274 | |
275 | -if ( ! class_exists( 'NOOP_Translations', false ) ): |
|
275 | +if ( ! class_exists('NOOP_Translations', false)): |
|
276 | 276 | /** |
277 | 277 | * Provides the same interface as Translations, but doesn't do anything |
278 | 278 | */ |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param string $singular |
320 | 320 | * @param string $context |
321 | 321 | */ |
322 | - function translate($singular, $context=null) { |
|
322 | + function translate($singular, $context = null) { |
|
323 | 323 | return $singular; |
324 | 324 | } |
325 | 325 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return bool |
330 | 330 | */ |
331 | 331 | function select_plural_form($count) { |
332 | - return 1 == $count? 0 : 1; |
|
332 | + return 1 == $count ? 0 : 1; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @param string $context |
347 | 347 | */ |
348 | 348 | function translate_plural($singular, $plural, $count, $context = null) { |
349 | - return 1 == $count? $singular : $plural; |
|
349 | + return 1 == $count ? $singular : $plural; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -135,7 +135,7 @@ |
||
135 | 135 | * @since 3.1.0 |
136 | 136 | * |
137 | 137 | * @param string $format The post format slug. |
138 | - * @return string|WP_Error|false The post format term link. |
|
138 | + * @return string The post format term link. |
|
139 | 139 | */ |
140 | 140 | function get_post_format_link( $format ) { |
141 | 141 | $term = get_term_by('slug', 'post-format-' . $format, 'post_format' ); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Post format functions. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Post |
|
7 | - */ |
|
3 | + * Post format functions. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Post |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Retrieve the format slug for a post |
@@ -15,16 +15,19 @@ discard block |
||
15 | 15 | * @return string|false The format if successful. False otherwise. |
16 | 16 | */ |
17 | 17 | function get_post_format( $post = null ) { |
18 | - if ( ! $post = get_post( $post ) ) |
|
19 | - return false; |
|
18 | + if ( ! $post = get_post( $post ) ) { |
|
19 | + return false; |
|
20 | + } |
|
20 | 21 | |
21 | - if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) |
|
22 | - return false; |
|
22 | + if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
23 | + return false; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | $_format = get_the_terms( $post->ID, 'post_format' ); |
25 | 27 | |
26 | - if ( empty( $_format ) ) |
|
27 | - return false; |
|
28 | + if ( empty( $_format ) ) { |
|
29 | + return false; |
|
30 | + } |
|
28 | 31 | |
29 | 32 | $format = reset( $_format ); |
30 | 33 | |
@@ -64,15 +67,17 @@ discard block |
||
64 | 67 | function set_post_format( $post, $format ) { |
65 | 68 | $post = get_post( $post ); |
66 | 69 | |
67 | - if ( empty( $post ) ) |
|
68 | - return new WP_Error( 'invalid_post', __( 'Invalid post.' ) ); |
|
70 | + if ( empty( $post ) ) { |
|
71 | + return new WP_Error( 'invalid_post', __( 'Invalid post.' ) ); |
|
72 | + } |
|
69 | 73 | |
70 | 74 | if ( ! empty( $format ) ) { |
71 | 75 | $format = sanitize_key( $format ); |
72 | - if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) |
|
73 | - $format = ''; |
|
74 | - else |
|
75 | - $format = 'post-format-' . $format; |
|
76 | + if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) { |
|
77 | + $format = ''; |
|
78 | + } else { |
|
79 | + $format = 'post-format-' . $format; |
|
80 | + } |
|
76 | 81 | } |
77 | 82 | |
78 | 83 | return wp_set_post_terms( $post->ID, $format, 'post_format' ); |
@@ -123,11 +128,12 @@ discard block |
||
123 | 128 | */ |
124 | 129 | function get_post_format_string( $slug ) { |
125 | 130 | $strings = get_post_format_strings(); |
126 | - if ( !$slug ) |
|
127 | - return $strings['standard']; |
|
128 | - else |
|
129 | - return ( isset( $strings[$slug] ) ) ? $strings[$slug] : ''; |
|
130 | -} |
|
131 | + if ( !$slug ) { |
|
132 | + return $strings['standard']; |
|
133 | + } else { |
|
134 | + return ( isset( $strings[$slug] ) ) ? $strings[$slug] : ''; |
|
135 | + } |
|
136 | + } |
|
131 | 137 | |
132 | 138 | /** |
133 | 139 | * Returns a link to a post format index. |
@@ -139,8 +145,9 @@ discard block |
||
139 | 145 | */ |
140 | 146 | function get_post_format_link( $format ) { |
141 | 147 | $term = get_term_by('slug', 'post-format-' . $format, 'post_format' ); |
142 | - if ( ! $term || is_wp_error( $term ) ) |
|
143 | - return false; |
|
148 | + if ( ! $term || is_wp_error( $term ) ) { |
|
149 | + return false; |
|
150 | + } |
|
144 | 151 | return get_term_link( $term ); |
145 | 152 | } |
146 | 153 | |
@@ -154,14 +161,17 @@ discard block |
||
154 | 161 | * @return array |
155 | 162 | */ |
156 | 163 | function _post_format_request( $qvs ) { |
157 | - if ( ! isset( $qvs['post_format'] ) ) |
|
158 | - return $qvs; |
|
164 | + if ( ! isset( $qvs['post_format'] ) ) { |
|
165 | + return $qvs; |
|
166 | + } |
|
159 | 167 | $slugs = get_post_format_slugs(); |
160 | - if ( isset( $slugs[ $qvs['post_format'] ] ) ) |
|
161 | - $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; |
|
168 | + if ( isset( $slugs[ $qvs['post_format'] ] ) ) { |
|
169 | + $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; |
|
170 | + } |
|
162 | 171 | $tax = get_taxonomy( 'post_format' ); |
163 | - if ( ! is_admin() ) |
|
164 | - $qvs['post_type'] = $tax->object_type; |
|
172 | + if ( ! is_admin() ) { |
|
173 | + $qvs['post_type'] = $tax->object_type; |
|
174 | + } |
|
165 | 175 | return $qvs; |
166 | 176 | } |
167 | 177 |
@@ -14,21 +14,21 @@ discard block |
||
14 | 14 | * @param int|object|null $post Post ID or post object. Optional, default is the current post from the loop. |
15 | 15 | * @return string|false The format if successful. False otherwise. |
16 | 16 | */ |
17 | -function get_post_format( $post = null ) { |
|
18 | - if ( ! $post = get_post( $post ) ) |
|
17 | +function get_post_format($post = null) { |
|
18 | + if ( ! $post = get_post($post)) |
|
19 | 19 | return false; |
20 | 20 | |
21 | - if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) |
|
21 | + if ( ! post_type_supports($post->post_type, 'post-formats')) |
|
22 | 22 | return false; |
23 | 23 | |
24 | - $_format = get_the_terms( $post->ID, 'post_format' ); |
|
24 | + $_format = get_the_terms($post->ID, 'post_format'); |
|
25 | 25 | |
26 | - if ( empty( $_format ) ) |
|
26 | + if (empty($_format)) |
|
27 | 27 | return false; |
28 | 28 | |
29 | - $format = reset( $_format ); |
|
29 | + $format = reset($_format); |
|
30 | 30 | |
31 | - return str_replace('post-format-', '', $format->slug ); |
|
31 | + return str_replace('post-format-', '', $format->slug); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * @param object|int|null $post Optional. The post to check. If not supplied, defaults to the current post if used in the loop. |
41 | 41 | * @return bool True if the post has any of the given formats (or any format, if no format specified), false otherwise. |
42 | 42 | */ |
43 | -function has_post_format( $format = array(), $post = null ) { |
|
43 | +function has_post_format($format = array(), $post = null) { |
|
44 | 44 | $prefixed = array(); |
45 | 45 | |
46 | - if ( $format ) { |
|
47 | - foreach ( (array) $format as $single ) { |
|
48 | - $prefixed[] = 'post-format-' . sanitize_key( $single ); |
|
46 | + if ($format) { |
|
47 | + foreach ((array) $format as $single) { |
|
48 | + $prefixed[] = 'post-format-'.sanitize_key($single); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - return has_term( $prefixed, 'post_format', $post ); |
|
52 | + return has_term($prefixed, 'post_format', $post); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -61,21 +61,21 @@ discard block |
||
61 | 61 | * @param string $format A format to assign. Use an empty string or array to remove all formats from the post. |
62 | 62 | * @return array|WP_Error|false WP_Error on error. Array of affected term IDs on success. |
63 | 63 | */ |
64 | -function set_post_format( $post, $format ) { |
|
65 | - $post = get_post( $post ); |
|
64 | +function set_post_format($post, $format) { |
|
65 | + $post = get_post($post); |
|
66 | 66 | |
67 | - if ( empty( $post ) ) |
|
68 | - return new WP_Error( 'invalid_post', __( 'Invalid post.' ) ); |
|
67 | + if (empty($post)) |
|
68 | + return new WP_Error('invalid_post', __('Invalid post.')); |
|
69 | 69 | |
70 | - if ( ! empty( $format ) ) { |
|
71 | - $format = sanitize_key( $format ); |
|
72 | - if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) |
|
70 | + if ( ! empty($format)) { |
|
71 | + $format = sanitize_key($format); |
|
72 | + if ('standard' === $format || ! in_array($format, get_post_format_slugs())) |
|
73 | 73 | $format = ''; |
74 | 74 | else |
75 | - $format = 'post-format-' . $format; |
|
75 | + $format = 'post-format-'.$format; |
|
76 | 76 | } |
77 | 77 | |
78 | - return wp_set_post_terms( $post->ID, $format, 'post_format' ); |
|
78 | + return wp_set_post_terms($post->ID, $format, 'post_format'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function get_post_format_strings() { |
89 | 89 | $strings = array( |
90 | - 'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard |
|
91 | - 'aside' => _x( 'Aside', 'Post format' ), |
|
92 | - 'chat' => _x( 'Chat', 'Post format' ), |
|
93 | - 'gallery' => _x( 'Gallery', 'Post format' ), |
|
94 | - 'link' => _x( 'Link', 'Post format' ), |
|
95 | - 'image' => _x( 'Image', 'Post format' ), |
|
96 | - 'quote' => _x( 'Quote', 'Post format' ), |
|
97 | - 'status' => _x( 'Status', 'Post format' ), |
|
98 | - 'video' => _x( 'Video', 'Post format' ), |
|
99 | - 'audio' => _x( 'Audio', 'Post format' ), |
|
90 | + 'standard' => _x('Standard', 'Post format'), // Special case. any value that evals to false will be considered standard |
|
91 | + 'aside' => _x('Aside', 'Post format'), |
|
92 | + 'chat' => _x('Chat', 'Post format'), |
|
93 | + 'gallery' => _x('Gallery', 'Post format'), |
|
94 | + 'link' => _x('Link', 'Post format'), |
|
95 | + 'image' => _x('Image', 'Post format'), |
|
96 | + 'quote' => _x('Quote', 'Post format'), |
|
97 | + 'status' => _x('Status', 'Post format'), |
|
98 | + 'video' => _x('Video', 'Post format'), |
|
99 | + 'audio' => _x('Audio', 'Post format'), |
|
100 | 100 | ); |
101 | 101 | return $strings; |
102 | 102 | } |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @return array The array of post format slugs. |
110 | 110 | */ |
111 | 111 | function get_post_format_slugs() { |
112 | - $slugs = array_keys( get_post_format_strings() ); |
|
113 | - return array_combine( $slugs, $slugs ); |
|
112 | + $slugs = array_keys(get_post_format_strings()); |
|
113 | + return array_combine($slugs, $slugs); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | * @param string $slug A post format slug. |
122 | 122 | * @return string The translated post format name. |
123 | 123 | */ |
124 | -function get_post_format_string( $slug ) { |
|
124 | +function get_post_format_string($slug) { |
|
125 | 125 | $strings = get_post_format_strings(); |
126 | - if ( !$slug ) |
|
126 | + if ( ! $slug) |
|
127 | 127 | return $strings['standard']; |
128 | 128 | else |
129 | - return ( isset( $strings[$slug] ) ) ? $strings[$slug] : ''; |
|
129 | + return (isset($strings[$slug])) ? $strings[$slug] : ''; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | * @param string $format The post format slug. |
138 | 138 | * @return string|WP_Error|false The post format term link. |
139 | 139 | */ |
140 | -function get_post_format_link( $format ) { |
|
141 | - $term = get_term_by('slug', 'post-format-' . $format, 'post_format' ); |
|
142 | - if ( ! $term || is_wp_error( $term ) ) |
|
140 | +function get_post_format_link($format) { |
|
141 | + $term = get_term_by('slug', 'post-format-'.$format, 'post_format'); |
|
142 | + if ( ! $term || is_wp_error($term)) |
|
143 | 143 | return false; |
144 | - return get_term_link( $term ); |
|
144 | + return get_term_link($term); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | * @param array $qvs |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function _post_format_request( $qvs ) { |
|
157 | - if ( ! isset( $qvs['post_format'] ) ) |
|
156 | +function _post_format_request($qvs) { |
|
157 | + if ( ! isset($qvs['post_format'])) |
|
158 | 158 | return $qvs; |
159 | 159 | $slugs = get_post_format_slugs(); |
160 | - if ( isset( $slugs[ $qvs['post_format'] ] ) ) |
|
161 | - $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; |
|
162 | - $tax = get_taxonomy( 'post_format' ); |
|
163 | - if ( ! is_admin() ) |
|
160 | + if (isset($slugs[$qvs['post_format']])) |
|
161 | + $qvs['post_format'] = 'post-format-'.$slugs[$qvs['post_format']]; |
|
162 | + $tax = get_taxonomy('post_format'); |
|
163 | + if ( ! is_admin()) |
|
164 | 164 | $qvs['post_type'] = $tax->object_type; |
165 | 165 | return $qvs; |
166 | 166 | } |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | * @param string $taxonomy |
179 | 179 | * @return string |
180 | 180 | */ |
181 | -function _post_format_link( $link, $term, $taxonomy ) { |
|
181 | +function _post_format_link($link, $term, $taxonomy) { |
|
182 | 182 | global $wp_rewrite; |
183 | - if ( 'post_format' != $taxonomy ) { |
|
183 | + if ('post_format' != $taxonomy) { |
|
184 | 184 | return $link; |
185 | 185 | } |
186 | - if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { |
|
187 | - return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link ); |
|
186 | + if ($wp_rewrite->get_extra_permastruct($taxonomy)) { |
|
187 | + return str_replace("/{$term->slug}", '/'.str_replace('post-format-', '', $term->slug), $link); |
|
188 | 188 | } else { |
189 | - $link = remove_query_arg( 'post_format', $link ); |
|
190 | - return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link ); |
|
189 | + $link = remove_query_arg('post_format', $link); |
|
190 | + return add_query_arg('post_format', str_replace('post-format-', '', $term->slug), $link); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param object $term |
201 | 201 | * @return object |
202 | 202 | */ |
203 | -function _post_format_get_term( $term ) { |
|
204 | - if ( isset( $term->slug ) ) { |
|
205 | - $term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); |
|
203 | +function _post_format_get_term($term) { |
|
204 | + if (isset($term->slug)) { |
|
205 | + $term->name = get_post_format_string(str_replace('post-format-', '', $term->slug)); |
|
206 | 206 | } |
207 | 207 | return $term; |
208 | 208 | } |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | * @param array $args |
219 | 219 | * @return array |
220 | 220 | */ |
221 | -function _post_format_get_terms( $terms, $taxonomies, $args ) { |
|
222 | - if ( in_array( 'post_format', (array) $taxonomies ) ) { |
|
223 | - if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) { |
|
224 | - foreach ( $terms as $order => $name ) { |
|
225 | - $terms[$order] = get_post_format_string( str_replace( 'post-format-', '', $name ) ); |
|
221 | +function _post_format_get_terms($terms, $taxonomies, $args) { |
|
222 | + if (in_array('post_format', (array) $taxonomies)) { |
|
223 | + if (isset($args['fields']) && 'names' == $args['fields']) { |
|
224 | + foreach ($terms as $order => $name) { |
|
225 | + $terms[$order] = get_post_format_string(str_replace('post-format-', '', $name)); |
|
226 | 226 | } |
227 | 227 | } else { |
228 | - foreach ( (array) $terms as $order => $term ) { |
|
229 | - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { |
|
230 | - $terms[$order]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); |
|
228 | + foreach ((array) $terms as $order => $term) { |
|
229 | + if (isset($term->taxonomy) && 'post_format' == $term->taxonomy) { |
|
230 | + $terms[$order]->name = get_post_format_string(str_replace('post-format-', '', $term->slug)); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | * @param array $terms |
245 | 245 | * @return array |
246 | 246 | */ |
247 | -function _post_format_wp_get_object_terms( $terms ) { |
|
248 | - foreach ( (array) $terms as $order => $term ) { |
|
249 | - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { |
|
250 | - $terms[$order]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); |
|
247 | +function _post_format_wp_get_object_terms($terms) { |
|
248 | + foreach ((array) $terms as $order => $term) { |
|
249 | + if (isset($term->taxonomy) && 'post_format' == $term->taxonomy) { |
|
250 | + $terms[$order]->name = get_post_format_string(str_replace('post-format-', '', $term->slug)); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | return $terms; |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @subpackage MagpieRSS |
410 | 410 | * |
411 | 411 | * @param string $url URL to retrieve feed |
412 | - * @return bool|MagpieRSS false on failure or MagpieRSS object on success. |
|
412 | + * @return integer|null false on failure or MagpieRSS object on success. |
|
413 | 413 | */ |
414 | 414 | function fetch_rss ($url) { |
415 | 415 | // initialize constants |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * |
548 | 548 | * @param string $url URL to retrieve |
549 | 549 | * @param array $headers Optional. Headers to send to the URL. |
550 | - * @return Snoopy style response |
|
550 | + * @return stdClass style response |
|
551 | 551 | */ |
552 | 552 | function _fetch_remote_file($url, $headers = "" ) { |
553 | 553 | $resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) ); |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @package External |
590 | 590 | * @subpackage MagpieRSS |
591 | 591 | * |
592 | - * @param array $resp |
|
592 | + * @param stdClass $resp |
|
593 | 593 | * @return MagpieRSS|bool |
594 | 594 | */ |
595 | 595 | function _response_to_rss ($resp) { |
@@ -746,6 +746,9 @@ discard block |
||
746 | 746 | Input: url from wich the rss file was fetched |
747 | 747 | Output: true on success |
748 | 748 | \*=======================================================================*/ |
749 | + /** |
|
750 | + * @param string $url |
|
751 | + */ |
|
749 | 752 | function set ($url, $rss) { |
750 | 753 | $cache_option = 'rss_' . $this->file_name( $url ); |
751 | 754 | |
@@ -760,6 +763,9 @@ discard block |
||
760 | 763 | Input: url from wich the rss file was fetched |
761 | 764 | Output: cached object on HIT, false on MISS |
762 | 765 | \*=======================================================================*/ |
766 | + /** |
|
767 | + * @param string $url |
|
768 | + */ |
|
763 | 769 | function get ($url) { |
764 | 770 | $this->ERROR = ""; |
765 | 771 | $cache_option = 'rss_' . $this->file_name( $url ); |
@@ -781,6 +787,9 @@ discard block |
||
781 | 787 | Input: url from wich the rss file was fetched |
782 | 788 | Output: cached object on HIT, false on MISS |
783 | 789 | \*=======================================================================*/ |
790 | + /** |
|
791 | + * @param string $url |
|
792 | + */ |
|
784 | 793 | function check_cache ( $url ) { |
785 | 794 | $this->ERROR = ""; |
786 | 795 | $cache_option = 'rss_' . $this->file_name( $url ); |
@@ -936,7 +945,7 @@ discard block |
||
936 | 945 | * |
937 | 946 | * @param string $url URL of feed to display. Will not auto sense feed URL. |
938 | 947 | * @param int $num_items Optional. Number of items to display, default is all. |
939 | - * @return bool False on failure. |
|
948 | + * @return null|false False on failure. |
|
940 | 949 | */ |
941 | 950 | function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS |
942 | 951 | $rss = fetch_rss($url); |
@@ -62,13 +62,15 @@ discard block |
||
62 | 62 | |
63 | 63 | # if PHP xml isn't compiled in, die |
64 | 64 | # |
65 | - if ( !function_exists('xml_parser_create') ) |
|
66 | - trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" ); |
|
65 | + if ( !function_exists('xml_parser_create') ) { |
|
66 | + trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" ); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | $parser = @xml_parser_create(); |
69 | 70 | |
70 | - if ( !is_resource($parser) ) |
|
71 | - trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); |
|
71 | + if ( !is_resource($parser) ) { |
|
72 | + trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | $this->parser = $parser; |
74 | 76 | |
@@ -127,12 +129,10 @@ discard block |
||
127 | 129 | if ( $el == 'rdf' ) { |
128 | 130 | $this->feed_type = RSS; |
129 | 131 | $this->feed_version = '1.0'; |
130 | - } |
|
131 | - elseif ( $el == 'rss' ) { |
|
132 | + } elseif ( $el == 'rss' ) { |
|
132 | 133 | $this->feed_type = RSS; |
133 | 134 | $this->feed_version = $attrs['version']; |
134 | - } |
|
135 | - elseif ( $el == 'feed' ) { |
|
135 | + } elseif ( $el == 'feed' ) { |
|
136 | 136 | $this->feed_type = ATOM; |
137 | 137 | $this->feed_version = $attrs['version']; |
138 | 138 | $this->inchannel = true; |
@@ -143,8 +143,7 @@ discard block |
||
143 | 143 | if ( $el == 'channel' ) |
144 | 144 | { |
145 | 145 | $this->inchannel = true; |
146 | - } |
|
147 | - elseif ($el == 'item' or $el == 'entry' ) |
|
146 | + } elseif ($el == 'item' or $el == 'entry' ) |
|
148 | 147 | { |
149 | 148 | $this->initem = true; |
150 | 149 | if ( isset($attrs['rdf:about']) ) { |
@@ -160,9 +159,7 @@ discard block |
||
160 | 159 | $el == 'textinput' ) |
161 | 160 | { |
162 | 161 | $this->intextinput = true; |
163 | - } |
|
164 | - |
|
165 | - elseif ( |
|
162 | + } elseif ( |
|
166 | 163 | $this->feed_type == RSS and |
167 | 164 | $this->current_namespace == '' and |
168 | 165 | $el == 'image' ) |
@@ -205,8 +202,7 @@ discard block |
||
205 | 202 | if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
206 | 203 | { |
207 | 204 | $link_el = 'link'; |
208 | - } |
|
209 | - else { |
|
205 | + } else { |
|
210 | 206 | $link_el = 'link_' . $attrs['rel']; |
211 | 207 | } |
212 | 208 | |
@@ -223,8 +219,7 @@ discard block |
||
223 | 219 | if ($this->feed_type == ATOM and $this->incontent) |
224 | 220 | { |
225 | 221 | $this->append_content( $text ); |
226 | - } |
|
227 | - else { |
|
222 | + } else { |
|
228 | 223 | $current_el = join('_', array_reverse($this->stack)); |
229 | 224 | $this->append($current_el, $text); |
230 | 225 | } |
@@ -238,37 +233,30 @@ discard block |
||
238 | 233 | $this->items[] = $this->current_item; |
239 | 234 | $this->current_item = array(); |
240 | 235 | $this->initem = false; |
241 | - } |
|
242 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
236 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
243 | 237 | { |
244 | 238 | $this->intextinput = false; |
245 | - } |
|
246 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
239 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
247 | 240 | { |
248 | 241 | $this->inimage = false; |
249 | - } |
|
250 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
242 | + } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
251 | 243 | { |
252 | 244 | $this->incontent = false; |
253 | - } |
|
254 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
245 | + } elseif ($el == 'channel' or $el == 'feed' ) |
|
255 | 246 | { |
256 | 247 | $this->inchannel = false; |
257 | - } |
|
258 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
248 | + } elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
259 | 249 | // balance tags properly |
260 | 250 | // note: This may not actually be necessary |
261 | 251 | if ( $this->stack[0] == $el ) |
262 | 252 | { |
263 | 253 | $this->append_content("</$el>"); |
264 | - } |
|
265 | - else { |
|
254 | + } else { |
|
266 | 255 | $this->append_content("<$el />"); |
267 | 256 | } |
268 | 257 | |
269 | 258 | array_shift( $this->stack ); |
270 | - } |
|
271 | - else { |
|
259 | + } else { |
|
272 | 260 | array_shift( $this->stack ); |
273 | 261 | } |
274 | 262 | |
@@ -285,8 +273,7 @@ discard block |
||
285 | 273 | function append_content($text) { |
286 | 274 | if ( $this->initem ) { |
287 | 275 | $this->concat( $this->current_item[ $this->incontent ], $text ); |
288 | - } |
|
289 | - elseif ( $this->inchannel ) { |
|
276 | + } elseif ( $this->inchannel ) { |
|
290 | 277 | $this->concat( $this->channel[ $this->incontent ], $text ); |
291 | 278 | } |
292 | 279 | } |
@@ -301,34 +288,27 @@ discard block |
||
301 | 288 | if ( $this->initem ) { |
302 | 289 | $this->concat( |
303 | 290 | $this->current_item[ $this->current_namespace ][ $el ], $text); |
304 | - } |
|
305 | - elseif ($this->inchannel) { |
|
291 | + } elseif ($this->inchannel) { |
|
306 | 292 | $this->concat( |
307 | 293 | $this->channel[ $this->current_namespace][ $el ], $text ); |
308 | - } |
|
309 | - elseif ($this->intextinput) { |
|
294 | + } elseif ($this->intextinput) { |
|
310 | 295 | $this->concat( |
311 | 296 | $this->textinput[ $this->current_namespace][ $el ], $text ); |
312 | - } |
|
313 | - elseif ($this->inimage) { |
|
297 | + } elseif ($this->inimage) { |
|
314 | 298 | $this->concat( |
315 | 299 | $this->image[ $this->current_namespace ][ $el ], $text ); |
316 | 300 | } |
317 | - } |
|
318 | - else { |
|
301 | + } else { |
|
319 | 302 | if ( $this->initem ) { |
320 | 303 | $this->concat( |
321 | 304 | $this->current_item[ $el ], $text); |
322 | - } |
|
323 | - elseif ($this->intextinput) { |
|
305 | + } elseif ($this->intextinput) { |
|
324 | 306 | $this->concat( |
325 | 307 | $this->textinput[ $el ], $text ); |
326 | - } |
|
327 | - elseif ($this->inimage) { |
|
308 | + } elseif ($this->inimage) { |
|
328 | 309 | $this->concat( |
329 | 310 | $this->image[ $el ], $text ); |
330 | - } |
|
331 | - elseif ($this->inchannel) { |
|
311 | + } elseif ($this->inchannel) { |
|
332 | 312 | $this->concat( |
333 | 313 | $this->channel[ $el ], $text ); |
334 | 314 | } |
@@ -342,22 +322,25 @@ discard block |
||
342 | 322 | $this->channel['descripton'] = $this->channel['tagline']; |
343 | 323 | for ( $i = 0; $i < count($this->items); $i++) { |
344 | 324 | $item = $this->items[$i]; |
345 | - if ( isset($item['summary']) ) |
|
346 | - $item['description'] = $item['summary']; |
|
347 | - if ( isset($item['atom_content'])) |
|
348 | - $item['content']['encoded'] = $item['atom_content']; |
|
325 | + if ( isset($item['summary']) ) { |
|
326 | + $item['description'] = $item['summary']; |
|
327 | + } |
|
328 | + if ( isset($item['atom_content'])) { |
|
329 | + $item['content']['encoded'] = $item['atom_content']; |
|
330 | + } |
|
349 | 331 | |
350 | 332 | $this->items[$i] = $item; |
351 | 333 | } |
352 | - } |
|
353 | - elseif ( $this->is_rss() ) { |
|
334 | + } elseif ( $this->is_rss() ) { |
|
354 | 335 | $this->channel['tagline'] = $this->channel['description']; |
355 | 336 | for ( $i = 0; $i < count($this->items); $i++) { |
356 | 337 | $item = $this->items[$i]; |
357 | - if ( isset($item['description'])) |
|
358 | - $item['summary'] = $item['description']; |
|
359 | - if ( isset($item['content']['encoded'] ) ) |
|
360 | - $item['atom_content'] = $item['content']['encoded']; |
|
338 | + if ( isset($item['description'])) { |
|
339 | + $item['summary'] = $item['description']; |
|
340 | + } |
|
341 | + if ( isset($item['content']['encoded'] ) ) { |
|
342 | + $item['atom_content'] = $item['content']['encoded']; |
|
343 | + } |
|
361 | 344 | |
362 | 345 | $this->items[$i] = $item; |
363 | 346 | } |
@@ -367,8 +350,7 @@ discard block |
||
367 | 350 | function is_rss () { |
368 | 351 | if ( $this->feed_type == RSS ) { |
369 | 352 | return $this->feed_version; |
370 | - } |
|
371 | - else { |
|
353 | + } else { |
|
372 | 354 | return false; |
373 | 355 | } |
374 | 356 | } |
@@ -376,8 +358,7 @@ discard block |
||
376 | 358 | function is_atom() { |
377 | 359 | if ( $this->feed_type == ATOM ) { |
378 | 360 | return $this->feed_version; |
379 | - } |
|
380 | - else { |
|
361 | + } else { |
|
381 | 362 | return false; |
382 | 363 | } |
383 | 364 | } |
@@ -426,8 +407,7 @@ discard block |
||
426 | 407 | $resp = _fetch_remote_file( $url ); |
427 | 408 | if ( is_success( $resp->status ) ) { |
428 | 409 | return _response_to_rss( $resp ); |
429 | - } |
|
430 | - else { |
|
410 | + } else { |
|
431 | 411 | // error("Failed to fetch $url and cache is off"); |
432 | 412 | return false; |
433 | 413 | } |
@@ -490,8 +470,7 @@ discard block |
||
490 | 470 | // reset cache on 304 (at minutillo insistent prodding) |
491 | 471 | $cache->set($url, $rss); |
492 | 472 | return $rss; |
493 | - } |
|
494 | - elseif ( is_success( $resp->status ) ) { |
|
473 | + } elseif ( is_success( $resp->status ) ) { |
|
495 | 474 | $rss = _response_to_rss( $resp ); |
496 | 475 | if ( $rss ) { |
497 | 476 | if (MAGPIE_DEBUG > 1) { |
@@ -501,21 +480,18 @@ discard block |
||
501 | 480 | $cache->set( $url, $rss ); |
502 | 481 | return $rss; |
503 | 482 | } |
504 | - } |
|
505 | - else { |
|
483 | + } else { |
|
506 | 484 | $errormsg = "Failed to fetch $url. "; |
507 | 485 | if ( $resp->error ) { |
508 | 486 | # compensate for Snoopy's annoying habbit to tacking |
509 | 487 | # on '\n' |
510 | 488 | $http_error = substr($resp->error, 0, -2); |
511 | 489 | $errormsg .= "(HTTP Error: $http_error)"; |
512 | - } |
|
513 | - else { |
|
490 | + } else { |
|
514 | 491 | $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
515 | 492 | } |
516 | 493 | } |
517 | - } |
|
518 | - else { |
|
494 | + } else { |
|
519 | 495 | $errormsg = "Unable to retrieve RSS file for unknown reasons."; |
520 | 496 | } |
521 | 497 | |
@@ -568,8 +544,9 @@ discard block |
||
568 | 544 | if ( !is_array($value) ) { |
569 | 545 | $return_headers[] = "$key: $value"; |
570 | 546 | } else { |
571 | - foreach ( $value as $v ) |
|
572 | - $return_headers[] = "$key: $v"; |
|
547 | + foreach ( $value as $v ) { |
|
548 | + $return_headers[] = "$key: $v"; |
|
549 | + } |
|
573 | 550 | } |
574 | 551 | } |
575 | 552 | |
@@ -603,8 +580,7 @@ discard block |
||
603 | 580 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
604 | 581 | if (strpos($h, ": ")) { |
605 | 582 | list($field, $val) = explode(": ", $h, 2); |
606 | - } |
|
607 | - else { |
|
583 | + } else { |
|
608 | 584 | $field = $h; |
609 | 585 | $val = ""; |
610 | 586 | } |
@@ -642,8 +618,7 @@ discard block |
||
642 | 618 | function init () { |
643 | 619 | if ( defined('MAGPIE_INITALIZED') ) { |
644 | 620 | return; |
645 | - } |
|
646 | - else { |
|
621 | + } else { |
|
647 | 622 | define('MAGPIE_INITALIZED', 1); |
648 | 623 | } |
649 | 624 | |
@@ -672,8 +647,7 @@ discard block |
||
672 | 647 | |
673 | 648 | if ( MAGPIE_CACHE_ON ) { |
674 | 649 | $ua = $ua . ')'; |
675 | - } |
|
676 | - else { |
|
650 | + } else { |
|
677 | 651 | $ua = $ua . '; No cache)'; |
678 | 652 | } |
679 | 653 | |
@@ -830,8 +804,7 @@ discard block |
||
830 | 804 | $this->ERROR = $errormsg; |
831 | 805 | if ( MAGPIE_DEBUG ) { |
832 | 806 | trigger_error( $errormsg, $lvl); |
833 | - } |
|
834 | - else { |
|
807 | + } else { |
|
835 | 808 | error_log( $errormsg, 0); |
836 | 809 | } |
837 | 810 | } |
@@ -858,8 +831,7 @@ discard block |
||
858 | 831 | $offset = 0; |
859 | 832 | if ( $match[11] == 'Z' ) { |
860 | 833 | # zulu time, aka GMT |
861 | - } |
|
862 | - else { |
|
834 | + } else { |
|
863 | 835 | list( $tz_mod, $tz_hour, $tz_min ) = |
864 | 836 | array( $match[8], $match[9], $match[10]); |
865 | 837 | |
@@ -879,8 +851,7 @@ discard block |
||
879 | 851 | } |
880 | 852 | $epoch = $epoch + $offset; |
881 | 853 | return $epoch; |
882 | - } |
|
883 | - else { |
|
854 | + } else { |
|
884 | 855 | return -1; |
885 | 856 | } |
886 | 857 | } |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * MagpieRSS: a simple RSS integration tool |
|
4 | - * |
|
5 | - * A compiled file for RSS syndication |
|
6 | - * |
|
7 | - * @author Kellan Elliott-McCrea <[email protected]> |
|
8 | - * @version 0.51 |
|
9 | - * @license GPL |
|
10 | - * |
|
11 | - * @package External |
|
12 | - * @subpackage MagpieRSS |
|
13 | - * @deprecated 3.0.0 Use SimplePie instead. |
|
14 | - */ |
|
3 | + * MagpieRSS: a simple RSS integration tool |
|
4 | + * |
|
5 | + * A compiled file for RSS syndication |
|
6 | + * |
|
7 | + * @author Kellan Elliott-McCrea <[email protected]> |
|
8 | + * @version 0.51 |
|
9 | + * @license GPL |
|
10 | + * |
|
11 | + * @package External |
|
12 | + * @subpackage MagpieRSS |
|
13 | + * @deprecated 3.0.0 Use SimplePie instead. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Deprecated. Use SimplePie (class-simplepie.php) instead. |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * Deprecated. Use SimplePie (class-simplepie.php) instead. |
18 | 18 | */ |
19 | -_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/class-simplepie.php' ); |
|
19 | +_deprecated_file(basename(__FILE__), '3.0', WPINC.'/class-simplepie.php'); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Fires before MagpieRSS is loaded, to optionally replace it. |
@@ -24,32 +24,32 @@ discard block |
||
24 | 24 | * @since 2.3.0 |
25 | 25 | * @deprecated 3.0.0 |
26 | 26 | */ |
27 | -do_action( 'load_feed_engine' ); |
|
27 | +do_action('load_feed_engine'); |
|
28 | 28 | |
29 | 29 | /** RSS feed constant. */ |
30 | 30 | define('RSS', 'RSS'); |
31 | 31 | define('ATOM', 'Atom'); |
32 | -define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']); |
|
32 | +define('MAGPIE_USER_AGENT', 'WordPress/'.$GLOBALS['wp_version']); |
|
33 | 33 | |
34 | 34 | class MagpieRSS { |
35 | 35 | var $parser; |
36 | - var $current_item = array(); // item currently being parsed |
|
37 | - var $items = array(); // collection of parsed items |
|
38 | - var $channel = array(); // hash of channel fields |
|
39 | - var $textinput = array(); |
|
36 | + var $current_item = array(); // item currently being parsed |
|
37 | + var $items = array(); // collection of parsed items |
|
38 | + var $channel = array(); // hash of channel fields |
|
39 | + var $textinput = array(); |
|
40 | 40 | var $image = array(); |
41 | 41 | var $feed_type; |
42 | 42 | var $feed_version; |
43 | 43 | |
44 | 44 | // parser variables |
45 | - var $stack = array(); // parser stack |
|
45 | + var $stack = array(); // parser stack |
|
46 | 46 | var $inchannel = false; |
47 | - var $initem = false; |
|
47 | + var $initem = false; |
|
48 | 48 | var $incontent = false; // if in Atom <content mode="xml"> field |
49 | - var $intextinput = false; |
|
50 | - var $inimage = false; |
|
51 | - var $current_field = ''; |
|
52 | - var $current_namespace = false; |
|
49 | + var $intextinput = false; |
|
50 | + var $inimage = false; |
|
51 | + var $current_field = ''; |
|
52 | + var $current_namespace = false; |
|
53 | 53 | |
54 | 54 | //var $ERROR = ""; |
55 | 55 | |
@@ -58,44 +58,44 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * PHP5 constructor. |
60 | 60 | */ |
61 | - function __construct( $source ) { |
|
61 | + function __construct($source) { |
|
62 | 62 | |
63 | 63 | # if PHP xml isn't compiled in, die |
64 | 64 | # |
65 | - if ( !function_exists('xml_parser_create') ) |
|
66 | - trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" ); |
|
65 | + if ( ! function_exists('xml_parser_create')) |
|
66 | + trigger_error("Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php"); |
|
67 | 67 | |
68 | 68 | $parser = @xml_parser_create(); |
69 | 69 | |
70 | - if ( !is_resource($parser) ) |
|
71 | - trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); |
|
70 | + if ( ! is_resource($parser)) |
|
71 | + trigger_error("Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php"); |
|
72 | 72 | |
73 | 73 | $this->parser = $parser; |
74 | 74 | |
75 | 75 | # pass in parser, and a reference to this object |
76 | 76 | # set up handlers |
77 | 77 | # |
78 | - xml_set_object( $this->parser, $this ); |
|
78 | + xml_set_object($this->parser, $this); |
|
79 | 79 | xml_set_element_handler($this->parser, |
80 | - 'feed_start_element', 'feed_end_element' ); |
|
80 | + 'feed_start_element', 'feed_end_element'); |
|
81 | 81 | |
82 | - xml_set_character_data_handler( $this->parser, 'feed_cdata' ); |
|
82 | + xml_set_character_data_handler($this->parser, 'feed_cdata'); |
|
83 | 83 | |
84 | - $status = xml_parse( $this->parser, $source ); |
|
84 | + $status = xml_parse($this->parser, $source); |
|
85 | 85 | |
86 | - if (! $status ) { |
|
87 | - $errorcode = xml_get_error_code( $this->parser ); |
|
88 | - if ( $errorcode != XML_ERROR_NONE ) { |
|
89 | - $xml_error = xml_error_string( $errorcode ); |
|
86 | + if ( ! $status) { |
|
87 | + $errorcode = xml_get_error_code($this->parser); |
|
88 | + if ($errorcode != XML_ERROR_NONE) { |
|
89 | + $xml_error = xml_error_string($errorcode); |
|
90 | 90 | $error_line = xml_get_current_line_number($this->parser); |
91 | 91 | $error_col = xml_get_current_column_number($this->parser); |
92 | 92 | $errormsg = "$xml_error at line $error_line, column $error_col"; |
93 | 93 | |
94 | - $this->error( $errormsg ); |
|
94 | + $this->error($errormsg); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - xml_parser_free( $this->parser ); |
|
98 | + xml_parser_free($this->parser); |
|
99 | 99 | |
100 | 100 | $this->normalize(); |
101 | 101 | } |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * PHP4 constructor. |
105 | 105 | */ |
106 | - public function MagpieRSS( $source ) { |
|
107 | - self::__construct( $source ); |
|
106 | + public function MagpieRSS($source) { |
|
107 | + self::__construct($source); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | function feed_start_element($p, $element, &$attrs) { |
@@ -112,27 +112,27 @@ discard block |
||
112 | 112 | $attrs = array_change_key_case($attrs, CASE_LOWER); |
113 | 113 | |
114 | 114 | // check for a namespace, and split if found |
115 | - $ns = false; |
|
116 | - if ( strpos( $element, ':' ) ) { |
|
117 | - list($ns, $el) = split( ':', $element, 2); |
|
115 | + $ns = false; |
|
116 | + if (strpos($element, ':')) { |
|
117 | + list($ns, $el) = split(':', $element, 2); |
|
118 | 118 | } |
119 | - if ( $ns and $ns != 'rdf' ) { |
|
119 | + if ($ns and $ns != 'rdf') { |
|
120 | 120 | $this->current_namespace = $ns; |
121 | 121 | } |
122 | 122 | |
123 | 123 | # if feed type isn't set, then this is first element of feed |
124 | 124 | # identify feed from root element |
125 | 125 | # |
126 | - if (!isset($this->feed_type) ) { |
|
127 | - if ( $el == 'rdf' ) { |
|
126 | + if ( ! isset($this->feed_type)) { |
|
127 | + if ($el == 'rdf') { |
|
128 | 128 | $this->feed_type = RSS; |
129 | 129 | $this->feed_version = '1.0'; |
130 | 130 | } |
131 | - elseif ( $el == 'rss' ) { |
|
131 | + elseif ($el == 'rss') { |
|
132 | 132 | $this->feed_type = RSS; |
133 | 133 | $this->feed_version = $attrs['version']; |
134 | 134 | } |
135 | - elseif ( $el == 'feed' ) { |
|
135 | + elseif ($el == 'feed') { |
|
136 | 136 | $this->feed_type = ATOM; |
137 | 137 | $this->feed_version = $attrs['version']; |
138 | 138 | $this->inchannel = true; |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | - if ( $el == 'channel' ) |
|
143 | + if ($el == 'channel') |
|
144 | 144 | { |
145 | 145 | $this->inchannel = true; |
146 | 146 | } |
147 | - elseif ($el == 'item' or $el == 'entry' ) |
|
147 | + elseif ($el == 'item' or $el == 'entry') |
|
148 | 148 | { |
149 | 149 | $this->initem = true; |
150 | - if ( isset($attrs['rdf:about']) ) { |
|
150 | + if (isset($attrs['rdf:about'])) { |
|
151 | 151 | $this->current_item['about'] = $attrs['rdf:about']; |
152 | 152 | } |
153 | 153 | } |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | # handle atom content constructs |
174 | - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
174 | + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS)) |
|
175 | 175 | { |
176 | 176 | // avoid clashing w/ RSS mod_content |
177 | - if ($el == 'content' ) { |
|
177 | + if ($el == 'content') { |
|
178 | 178 | $el = 'atom_content'; |
179 | 179 | } |
180 | 180 | |
@@ -183,31 +183,31 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
186 | - elseif ($this->feed_type == ATOM and $this->incontent ) |
|
186 | + elseif ($this->feed_type == ATOM and $this->incontent) |
|
187 | 187 | { |
188 | 188 | // if tags are inlined, then flatten |
189 | 189 | $attrs_str = join(' ', |
190 | 190 | array_map(array('MagpieRSS', 'map_attrs'), |
191 | 191 | array_keys($attrs), |
192 | - array_values($attrs) ) ); |
|
192 | + array_values($attrs))); |
|
193 | 193 | |
194 | - $this->append_content( "<$element $attrs_str>" ); |
|
194 | + $this->append_content("<$element $attrs_str>"); |
|
195 | 195 | |
196 | - array_unshift( $this->stack, $el ); |
|
196 | + array_unshift($this->stack, $el); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Atom support many links per containging element. |
200 | 200 | // Magpie treats link elements of type rel='alternate' |
201 | 201 | // as being equivalent to RSS's simple link element. |
202 | 202 | // |
203 | - elseif ($this->feed_type == ATOM and $el == 'link' ) |
|
203 | + elseif ($this->feed_type == ATOM and $el == 'link') |
|
204 | 204 | { |
205 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
|
205 | + if (isset($attrs['rel']) and $attrs['rel'] == 'alternate') |
|
206 | 206 | { |
207 | 207 | $link_el = 'link'; |
208 | 208 | } |
209 | 209 | else { |
210 | - $link_el = 'link_' . $attrs['rel']; |
|
210 | + $link_el = 'link_'.$attrs['rel']; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | $this->append($link_el, $attrs['href']); |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - function feed_cdata ($p, $text) { |
|
221 | + function feed_cdata($p, $text) { |
|
222 | 222 | |
223 | 223 | if ($this->feed_type == ATOM and $this->incontent) |
224 | 224 | { |
225 | - $this->append_content( $text ); |
|
225 | + $this->append_content($text); |
|
226 | 226 | } |
227 | 227 | else { |
228 | 228 | $current_el = join('_', array_reverse($this->stack)); |
@@ -230,35 +230,35 @@ discard block |
||
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | - function feed_end_element ($p, $el) { |
|
233 | + function feed_end_element($p, $el) { |
|
234 | 234 | $el = strtolower($el); |
235 | 235 | |
236 | - if ( $el == 'item' or $el == 'entry' ) |
|
236 | + if ($el == 'item' or $el == 'entry') |
|
237 | 237 | { |
238 | 238 | $this->items[] = $this->current_item; |
239 | 239 | $this->current_item = array(); |
240 | 240 | $this->initem = false; |
241 | 241 | } |
242 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
242 | + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput') |
|
243 | 243 | { |
244 | 244 | $this->intextinput = false; |
245 | 245 | } |
246 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
246 | + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image') |
|
247 | 247 | { |
248 | 248 | $this->inimage = false; |
249 | 249 | } |
250 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
250 | + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS)) |
|
251 | 251 | { |
252 | 252 | $this->incontent = false; |
253 | 253 | } |
254 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
254 | + elseif ($el == 'channel' or $el == 'feed') |
|
255 | 255 | { |
256 | 256 | $this->inchannel = false; |
257 | 257 | } |
258 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
258 | + elseif ($this->feed_type == ATOM and $this->incontent) { |
|
259 | 259 | // balance tags properly |
260 | 260 | // note: This may not actually be necessary |
261 | - if ( $this->stack[0] == $el ) |
|
261 | + if ($this->stack[0] == $el) |
|
262 | 262 | { |
263 | 263 | $this->append_content("</$el>"); |
264 | 264 | } |
@@ -266,97 +266,97 @@ discard block |
||
266 | 266 | $this->append_content("<$el />"); |
267 | 267 | } |
268 | 268 | |
269 | - array_shift( $this->stack ); |
|
269 | + array_shift($this->stack); |
|
270 | 270 | } |
271 | 271 | else { |
272 | - array_shift( $this->stack ); |
|
272 | + array_shift($this->stack); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | $this->current_namespace = false; |
276 | 276 | } |
277 | 277 | |
278 | - function concat (&$str1, $str2="") { |
|
279 | - if (!isset($str1) ) { |
|
280 | - $str1=""; |
|
278 | + function concat(&$str1, $str2 = "") { |
|
279 | + if ( ! isset($str1)) { |
|
280 | + $str1 = ""; |
|
281 | 281 | } |
282 | 282 | $str1 .= $str2; |
283 | 283 | } |
284 | 284 | |
285 | 285 | function append_content($text) { |
286 | - if ( $this->initem ) { |
|
287 | - $this->concat( $this->current_item[ $this->incontent ], $text ); |
|
286 | + if ($this->initem) { |
|
287 | + $this->concat($this->current_item[$this->incontent], $text); |
|
288 | 288 | } |
289 | - elseif ( $this->inchannel ) { |
|
290 | - $this->concat( $this->channel[ $this->incontent ], $text ); |
|
289 | + elseif ($this->inchannel) { |
|
290 | + $this->concat($this->channel[$this->incontent], $text); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | 294 | // smart append - field and namespace aware |
295 | 295 | function append($el, $text) { |
296 | - if (!$el) { |
|
296 | + if ( ! $el) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | - if ( $this->current_namespace ) |
|
299 | + if ($this->current_namespace) |
|
300 | 300 | { |
301 | - if ( $this->initem ) { |
|
301 | + if ($this->initem) { |
|
302 | 302 | $this->concat( |
303 | - $this->current_item[ $this->current_namespace ][ $el ], $text); |
|
303 | + $this->current_item[$this->current_namespace][$el], $text); |
|
304 | 304 | } |
305 | 305 | elseif ($this->inchannel) { |
306 | 306 | $this->concat( |
307 | - $this->channel[ $this->current_namespace][ $el ], $text ); |
|
307 | + $this->channel[$this->current_namespace][$el], $text ); |
|
308 | 308 | } |
309 | 309 | elseif ($this->intextinput) { |
310 | 310 | $this->concat( |
311 | - $this->textinput[ $this->current_namespace][ $el ], $text ); |
|
311 | + $this->textinput[$this->current_namespace][$el], $text ); |
|
312 | 312 | } |
313 | 313 | elseif ($this->inimage) { |
314 | 314 | $this->concat( |
315 | - $this->image[ $this->current_namespace ][ $el ], $text ); |
|
315 | + $this->image[$this->current_namespace][$el], $text ); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | else { |
319 | - if ( $this->initem ) { |
|
319 | + if ($this->initem) { |
|
320 | 320 | $this->concat( |
321 | - $this->current_item[ $el ], $text); |
|
321 | + $this->current_item[$el], $text); |
|
322 | 322 | } |
323 | 323 | elseif ($this->intextinput) { |
324 | 324 | $this->concat( |
325 | - $this->textinput[ $el ], $text ); |
|
325 | + $this->textinput[$el], $text ); |
|
326 | 326 | } |
327 | 327 | elseif ($this->inimage) { |
328 | 328 | $this->concat( |
329 | - $this->image[ $el ], $text ); |
|
329 | + $this->image[$el], $text ); |
|
330 | 330 | } |
331 | 331 | elseif ($this->inchannel) { |
332 | 332 | $this->concat( |
333 | - $this->channel[ $el ], $text ); |
|
333 | + $this->channel[$el], $text ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - function normalize () { |
|
339 | + function normalize() { |
|
340 | 340 | // if atom populate rss fields |
341 | - if ( $this->is_atom() ) { |
|
341 | + if ($this->is_atom()) { |
|
342 | 342 | $this->channel['descripton'] = $this->channel['tagline']; |
343 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
343 | + for ($i = 0; $i < count($this->items); $i++) { |
|
344 | 344 | $item = $this->items[$i]; |
345 | - if ( isset($item['summary']) ) |
|
345 | + if (isset($item['summary'])) |
|
346 | 346 | $item['description'] = $item['summary']; |
347 | - if ( isset($item['atom_content'])) |
|
347 | + if (isset($item['atom_content'])) |
|
348 | 348 | $item['content']['encoded'] = $item['atom_content']; |
349 | 349 | |
350 | 350 | $this->items[$i] = $item; |
351 | 351 | } |
352 | 352 | } |
353 | - elseif ( $this->is_rss() ) { |
|
353 | + elseif ($this->is_rss()) { |
|
354 | 354 | $this->channel['tagline'] = $this->channel['description']; |
355 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
355 | + for ($i = 0; $i < count($this->items); $i++) { |
|
356 | 356 | $item = $this->items[$i]; |
357 | - if ( isset($item['description'])) |
|
357 | + if (isset($item['description'])) |
|
358 | 358 | $item['summary'] = $item['description']; |
359 | - if ( isset($item['content']['encoded'] ) ) |
|
359 | + if (isset($item['content']['encoded'])) |
|
360 | 360 | $item['atom_content'] = $item['content']['encoded']; |
361 | 361 | |
362 | 362 | $this->items[$i] = $item; |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | - function is_rss () { |
|
368 | - if ( $this->feed_type == RSS ) { |
|
367 | + function is_rss() { |
|
368 | + if ($this->feed_type == RSS) { |
|
369 | 369 | return $this->feed_version; |
370 | 370 | } |
371 | 371 | else { |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | function is_atom() { |
377 | - if ( $this->feed_type == ATOM ) { |
|
377 | + if ($this->feed_type == ATOM) { |
|
378 | 378 | return $this->feed_version; |
379 | 379 | } |
380 | 380 | else { |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | return "$k=\"$v\""; |
387 | 387 | } |
388 | 388 | |
389 | - function error( $errormsg, $lvl = E_USER_WARNING ) { |
|
389 | + function error($errormsg, $lvl = E_USER_WARNING) { |
|
390 | 390 | // append PHP's error message if track_errors enabled |
391 | - if ( isset($php_errormsg) ) { |
|
391 | + if (isset($php_errormsg)) { |
|
392 | 392 | $errormsg .= " ($php_errormsg)"; |
393 | 393 | } |
394 | - if ( MAGPIE_DEBUG ) { |
|
395 | - trigger_error( $errormsg, $lvl); |
|
394 | + if (MAGPIE_DEBUG) { |
|
395 | + trigger_error($errormsg, $lvl); |
|
396 | 396 | } else { |
397 | - error_log( $errormsg, 0); |
|
397 | + error_log($errormsg, 0); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | 401 | } |
402 | 402 | |
403 | -if ( !function_exists('fetch_rss') ) : |
|
403 | +if ( ! function_exists('fetch_rss')) : |
|
404 | 404 | /** |
405 | 405 | * Build Magpie object based on RSS from URL. |
406 | 406 | * |
@@ -411,21 +411,21 @@ discard block |
||
411 | 411 | * @param string $url URL to retrieve feed |
412 | 412 | * @return bool|MagpieRSS false on failure or MagpieRSS object on success. |
413 | 413 | */ |
414 | -function fetch_rss ($url) { |
|
414 | +function fetch_rss($url) { |
|
415 | 415 | // initialize constants |
416 | 416 | init(); |
417 | 417 | |
418 | - if ( !isset($url) ) { |
|
418 | + if ( ! isset($url)) { |
|
419 | 419 | // error("fetch_rss called without a url"); |
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | |
423 | 423 | // if cache is disabled |
424 | - if ( !MAGPIE_CACHE_ON ) { |
|
424 | + if ( ! MAGPIE_CACHE_ON) { |
|
425 | 425 | // fetch file, and parse it |
426 | - $resp = _fetch_remote_file( $url ); |
|
427 | - if ( is_success( $resp->status ) ) { |
|
428 | - return _response_to_rss( $resp ); |
|
426 | + $resp = _fetch_remote_file($url); |
|
427 | + if (is_success($resp->status)) { |
|
428 | + return _response_to_rss($resp); |
|
429 | 429 | } |
430 | 430 | else { |
431 | 431 | // error("Failed to fetch $url and cache is off"); |
@@ -440,28 +440,28 @@ discard block |
||
440 | 440 | // 3. if cached obj fails freshness check, fetch remote |
441 | 441 | // 4. if remote fails, return stale object, or error |
442 | 442 | |
443 | - $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); |
|
443 | + $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE); |
|
444 | 444 | |
445 | 445 | if (MAGPIE_DEBUG and $cache->ERROR) { |
446 | 446 | debug($cache->ERROR, E_USER_WARNING); |
447 | 447 | } |
448 | 448 | |
449 | - $cache_status = 0; // response of check_cache |
|
449 | + $cache_status = 0; // response of check_cache |
|
450 | 450 | $request_headers = array(); // HTTP headers to send with fetch |
451 | - $rss = 0; // parsed RSS object |
|
452 | - $errormsg = 0; // errors, if any |
|
451 | + $rss = 0; // parsed RSS object |
|
452 | + $errormsg = 0; // errors, if any |
|
453 | 453 | |
454 | - if (!$cache->ERROR) { |
|
454 | + if ( ! $cache->ERROR) { |
|
455 | 455 | // return cache HIT, MISS, or STALE |
456 | - $cache_status = $cache->check_cache( $url ); |
|
456 | + $cache_status = $cache->check_cache($url); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | // if object cached, and cache is fresh, return cached obj |
460 | - if ( $cache_status == 'HIT' ) { |
|
461 | - $rss = $cache->get( $url ); |
|
462 | - if ( isset($rss) and $rss ) { |
|
460 | + if ($cache_status == 'HIT') { |
|
461 | + $rss = $cache->get($url); |
|
462 | + if (isset($rss) and $rss) { |
|
463 | 463 | $rss->from_cache = 1; |
464 | - if ( MAGPIE_DEBUG > 1) { |
|
464 | + if (MAGPIE_DEBUG > 1) { |
|
465 | 465 | debug("MagpieRSS: Cache HIT", E_USER_NOTICE); |
466 | 466 | } |
467 | 467 | return $rss; |
@@ -471,47 +471,47 @@ discard block |
||
471 | 471 | // else attempt a conditional get |
472 | 472 | |
473 | 473 | // set up headers |
474 | - if ( $cache_status == 'STALE' ) { |
|
475 | - $rss = $cache->get( $url ); |
|
476 | - if ( isset($rss->etag) and $rss->last_modified ) { |
|
474 | + if ($cache_status == 'STALE') { |
|
475 | + $rss = $cache->get($url); |
|
476 | + if (isset($rss->etag) and $rss->last_modified) { |
|
477 | 477 | $request_headers['If-None-Match'] = $rss->etag; |
478 | 478 | $request_headers['If-Last-Modified'] = $rss->last_modified; |
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | - $resp = _fetch_remote_file( $url, $request_headers ); |
|
482 | + $resp = _fetch_remote_file($url, $request_headers); |
|
483 | 483 | |
484 | 484 | if (isset($resp) and $resp) { |
485 | - if ($resp->status == '304' ) { |
|
485 | + if ($resp->status == '304') { |
|
486 | 486 | // we have the most current copy |
487 | - if ( MAGPIE_DEBUG > 1) { |
|
487 | + if (MAGPIE_DEBUG > 1) { |
|
488 | 488 | debug("Got 304 for $url"); |
489 | 489 | } |
490 | 490 | // reset cache on 304 (at minutillo insistent prodding) |
491 | 491 | $cache->set($url, $rss); |
492 | 492 | return $rss; |
493 | 493 | } |
494 | - elseif ( is_success( $resp->status ) ) { |
|
495 | - $rss = _response_to_rss( $resp ); |
|
496 | - if ( $rss ) { |
|
494 | + elseif (is_success($resp->status)) { |
|
495 | + $rss = _response_to_rss($resp); |
|
496 | + if ($rss) { |
|
497 | 497 | if (MAGPIE_DEBUG > 1) { |
498 | 498 | debug("Fetch successful"); |
499 | 499 | } |
500 | 500 | // add object to cache |
501 | - $cache->set( $url, $rss ); |
|
501 | + $cache->set($url, $rss); |
|
502 | 502 | return $rss; |
503 | 503 | } |
504 | 504 | } |
505 | 505 | else { |
506 | 506 | $errormsg = "Failed to fetch $url. "; |
507 | - if ( $resp->error ) { |
|
507 | + if ($resp->error) { |
|
508 | 508 | # compensate for Snoopy's annoying habbit to tacking |
509 | 509 | # on '\n' |
510 | 510 | $http_error = substr($resp->error, 0, -2); |
511 | 511 | $errormsg .= "(HTTP Error: $http_error)"; |
512 | 512 | } |
513 | 513 | else { |
514 | - $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
|
514 | + $errormsg .= "(HTTP Response: ".$resp->response_code.')'; |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | |
524 | 524 | // attempt to return cached object |
525 | 525 | if ($rss) { |
526 | - if ( MAGPIE_DEBUG ) { |
|
526 | + if (MAGPIE_DEBUG) { |
|
527 | 527 | debug("Returning STALE object for $url"); |
528 | 528 | } |
529 | 529 | return $rss; |
@@ -549,35 +549,35 @@ discard block |
||
549 | 549 | * @param array $headers Optional. Headers to send to the URL. |
550 | 550 | * @return Snoopy style response |
551 | 551 | */ |
552 | -function _fetch_remote_file($url, $headers = "" ) { |
|
553 | - $resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) ); |
|
554 | - if ( is_wp_error($resp) ) { |
|
552 | +function _fetch_remote_file($url, $headers = "") { |
|
553 | + $resp = wp_safe_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT)); |
|
554 | + if (is_wp_error($resp)) { |
|
555 | 555 | $error = array_shift($resp->errors); |
556 | 556 | |
557 | 557 | $resp = new stdClass; |
558 | 558 | $resp->status = 500; |
559 | 559 | $resp->response_code = 500; |
560 | - $resp->error = $error[0] . "\n"; //\n = Snoopy compatibility |
|
560 | + $resp->error = $error[0]."\n"; //\n = Snoopy compatibility |
|
561 | 561 | return $resp; |
562 | 562 | } |
563 | 563 | |
564 | 564 | // Snoopy returns headers unprocessed. |
565 | 565 | // Also note, WP_HTTP lowercases all keys, Snoopy did not. |
566 | 566 | $return_headers = array(); |
567 | - foreach ( wp_remote_retrieve_headers( $resp ) as $key => $value ) { |
|
568 | - if ( !is_array($value) ) { |
|
567 | + foreach (wp_remote_retrieve_headers($resp) as $key => $value) { |
|
568 | + if ( ! is_array($value)) { |
|
569 | 569 | $return_headers[] = "$key: $value"; |
570 | 570 | } else { |
571 | - foreach ( $value as $v ) |
|
571 | + foreach ($value as $v) |
|
572 | 572 | $return_headers[] = "$key: $v"; |
573 | 573 | } |
574 | 574 | } |
575 | 575 | |
576 | 576 | $response = new stdClass; |
577 | - $response->status = wp_remote_retrieve_response_code( $resp ); |
|
578 | - $response->response_code = wp_remote_retrieve_response_code( $resp ); |
|
577 | + $response->status = wp_remote_retrieve_response_code($resp); |
|
578 | + $response->response_code = wp_remote_retrieve_response_code($resp); |
|
579 | 579 | $response->headers = $return_headers; |
580 | - $response->results = wp_remote_retrieve_body( $resp ); |
|
580 | + $response->results = wp_remote_retrieve_body($resp); |
|
581 | 581 | |
582 | 582 | return $response; |
583 | 583 | } |
@@ -592,14 +592,14 @@ discard block |
||
592 | 592 | * @param array $resp |
593 | 593 | * @return MagpieRSS|bool |
594 | 594 | */ |
595 | -function _response_to_rss ($resp) { |
|
596 | - $rss = new MagpieRSS( $resp->results ); |
|
595 | +function _response_to_rss($resp) { |
|
596 | + $rss = new MagpieRSS($resp->results); |
|
597 | 597 | |
598 | 598 | // if RSS parsed successfully |
599 | - if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) { |
|
599 | + if ($rss && ( ! isset($rss->ERROR) || ! $rss->ERROR)) { |
|
600 | 600 | |
601 | 601 | // find Etag, and Last-Modified |
602 | - foreach ( (array) $resp->headers as $h) { |
|
602 | + foreach ((array) $resp->headers as $h) { |
|
603 | 603 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
604 | 604 | if (strpos($h, ": ")) { |
605 | 605 | list($field, $val) = explode(": ", $h, 2); |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | $val = ""; |
610 | 610 | } |
611 | 611 | |
612 | - if ( $field == 'etag' ) { |
|
612 | + if ($field == 'etag') { |
|
613 | 613 | $rss->etag = $val; |
614 | 614 | } |
615 | 615 | |
616 | - if ( $field == 'last-modified' ) { |
|
616 | + if ($field == 'last-modified') { |
|
617 | 617 | $rss->last_modified = $val; |
618 | 618 | } |
619 | 619 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | $errormsg = "Failed to parse RSS file."; |
625 | 625 | |
626 | 626 | if ($rss) { |
627 | - $errormsg .= " (" . $rss->ERROR . ")"; |
|
627 | + $errormsg .= " (".$rss->ERROR.")"; |
|
628 | 628 | } |
629 | 629 | // error($errormsg); |
630 | 630 | |
@@ -639,95 +639,95 @@ discard block |
||
639 | 639 | * @package External |
640 | 640 | * @subpackage MagpieRSS |
641 | 641 | */ |
642 | -function init () { |
|
643 | - if ( defined('MAGPIE_INITALIZED') ) { |
|
642 | +function init() { |
|
643 | + if (defined('MAGPIE_INITALIZED')) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | else { |
647 | 647 | define('MAGPIE_INITALIZED', 1); |
648 | 648 | } |
649 | 649 | |
650 | - if ( !defined('MAGPIE_CACHE_ON') ) { |
|
650 | + if ( ! defined('MAGPIE_CACHE_ON')) { |
|
651 | 651 | define('MAGPIE_CACHE_ON', 1); |
652 | 652 | } |
653 | 653 | |
654 | - if ( !defined('MAGPIE_CACHE_DIR') ) { |
|
654 | + if ( ! defined('MAGPIE_CACHE_DIR')) { |
|
655 | 655 | define('MAGPIE_CACHE_DIR', './cache'); |
656 | 656 | } |
657 | 657 | |
658 | - if ( !defined('MAGPIE_CACHE_AGE') ) { |
|
659 | - define('MAGPIE_CACHE_AGE', 60*60); // one hour |
|
658 | + if ( ! defined('MAGPIE_CACHE_AGE')) { |
|
659 | + define('MAGPIE_CACHE_AGE', 60 * 60); // one hour |
|
660 | 660 | } |
661 | 661 | |
662 | - if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) { |
|
662 | + if ( ! defined('MAGPIE_CACHE_FRESH_ONLY')) { |
|
663 | 663 | define('MAGPIE_CACHE_FRESH_ONLY', 0); |
664 | 664 | } |
665 | 665 | |
666 | - if ( !defined('MAGPIE_DEBUG') ) { |
|
666 | + if ( ! defined('MAGPIE_DEBUG')) { |
|
667 | 667 | define('MAGPIE_DEBUG', 0); |
668 | 668 | } |
669 | 669 | |
670 | - if ( !defined('MAGPIE_USER_AGENT') ) { |
|
671 | - $ua = 'WordPress/' . $GLOBALS['wp_version']; |
|
670 | + if ( ! defined('MAGPIE_USER_AGENT')) { |
|
671 | + $ua = 'WordPress/'.$GLOBALS['wp_version']; |
|
672 | 672 | |
673 | - if ( MAGPIE_CACHE_ON ) { |
|
674 | - $ua = $ua . ')'; |
|
673 | + if (MAGPIE_CACHE_ON) { |
|
674 | + $ua = $ua.')'; |
|
675 | 675 | } |
676 | 676 | else { |
677 | - $ua = $ua . '; No cache)'; |
|
677 | + $ua = $ua.'; No cache)'; |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | define('MAGPIE_USER_AGENT', $ua); |
681 | 681 | } |
682 | 682 | |
683 | - if ( !defined('MAGPIE_FETCH_TIME_OUT') ) { |
|
684 | - define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout |
|
683 | + if ( ! defined('MAGPIE_FETCH_TIME_OUT')) { |
|
684 | + define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | // use gzip encoding to fetch rss files if supported? |
688 | - if ( !defined('MAGPIE_USE_GZIP') ) { |
|
688 | + if ( ! defined('MAGPIE_USE_GZIP')) { |
|
689 | 689 | define('MAGPIE_USE_GZIP', true); |
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | -function is_info ($sc) { |
|
693 | +function is_info($sc) { |
|
694 | 694 | return $sc >= 100 && $sc < 200; |
695 | 695 | } |
696 | 696 | |
697 | -function is_success ($sc) { |
|
697 | +function is_success($sc) { |
|
698 | 698 | return $sc >= 200 && $sc < 300; |
699 | 699 | } |
700 | 700 | |
701 | -function is_redirect ($sc) { |
|
701 | +function is_redirect($sc) { |
|
702 | 702 | return $sc >= 300 && $sc < 400; |
703 | 703 | } |
704 | 704 | |
705 | -function is_error ($sc) { |
|
705 | +function is_error($sc) { |
|
706 | 706 | return $sc >= 400 && $sc < 600; |
707 | 707 | } |
708 | 708 | |
709 | -function is_client_error ($sc) { |
|
709 | +function is_client_error($sc) { |
|
710 | 710 | return $sc >= 400 && $sc < 500; |
711 | 711 | } |
712 | 712 | |
713 | -function is_server_error ($sc) { |
|
713 | +function is_server_error($sc) { |
|
714 | 714 | return $sc >= 500 && $sc < 600; |
715 | 715 | } |
716 | 716 | |
717 | 717 | class RSSCache { |
718 | - var $BASE_CACHE; // where the cache files are stored |
|
719 | - var $MAX_AGE = 43200; // when are files stale, default twelve hours |
|
720 | - var $ERROR = ''; // accumulate error messages |
|
718 | + var $BASE_CACHE; // where the cache files are stored |
|
719 | + var $MAX_AGE = 43200; // when are files stale, default twelve hours |
|
720 | + var $ERROR = ''; // accumulate error messages |
|
721 | 721 | |
722 | 722 | /** |
723 | 723 | * PHP5 constructor. |
724 | 724 | */ |
725 | - function __construct( $base = '', $age = '' ) { |
|
726 | - $this->BASE_CACHE = WP_CONTENT_DIR . '/cache'; |
|
727 | - if ( $base ) { |
|
725 | + function __construct($base = '', $age = '') { |
|
726 | + $this->BASE_CACHE = WP_CONTENT_DIR.'/cache'; |
|
727 | + if ($base) { |
|
728 | 728 | $this->BASE_CACHE = $base; |
729 | 729 | } |
730 | - if ( $age ) { |
|
730 | + if ($age) { |
|
731 | 731 | $this->MAX_AGE = $age; |
732 | 732 | } |
733 | 733 | |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | /** |
737 | 737 | * PHP4 constructor. |
738 | 738 | */ |
739 | - public function RSSCache( $base = '', $age = '' ) { |
|
740 | - self::__construct( $base, $age ); |
|
739 | + public function RSSCache($base = '', $age = '') { |
|
740 | + self::__construct($base, $age); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /*=======================================================================*\ |
@@ -746,8 +746,8 @@ discard block |
||
746 | 746 | Input: url from wich the rss file was fetched |
747 | 747 | Output: true on success |
748 | 748 | \*=======================================================================*/ |
749 | - function set ($url, $rss) { |
|
750 | - $cache_option = 'rss_' . $this->file_name( $url ); |
|
749 | + function set($url, $rss) { |
|
750 | + $cache_option = 'rss_'.$this->file_name($url); |
|
751 | 751 | |
752 | 752 | set_transient($cache_option, $rss, $this->MAX_AGE); |
753 | 753 | |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | Input: url from wich the rss file was fetched |
761 | 761 | Output: cached object on HIT, false on MISS |
762 | 762 | \*=======================================================================*/ |
763 | - function get ($url) { |
|
763 | + function get($url) { |
|
764 | 764 | $this->ERROR = ""; |
765 | - $cache_option = 'rss_' . $this->file_name( $url ); |
|
765 | + $cache_option = 'rss_'.$this->file_name($url); |
|
766 | 766 | |
767 | - if ( ! $rss = get_transient( $cache_option ) ) { |
|
767 | + if ( ! $rss = get_transient($cache_option)) { |
|
768 | 768 | $this->debug( |
769 | 769 | "Cache doesn't contain: $url (cache option: $cache_option)" |
770 | 770 | ); |
@@ -781,11 +781,11 @@ discard block |
||
781 | 781 | Input: url from wich the rss file was fetched |
782 | 782 | Output: cached object on HIT, false on MISS |
783 | 783 | \*=======================================================================*/ |
784 | - function check_cache ( $url ) { |
|
784 | + function check_cache($url) { |
|
785 | 785 | $this->ERROR = ""; |
786 | - $cache_option = 'rss_' . $this->file_name( $url ); |
|
786 | + $cache_option = 'rss_'.$this->file_name($url); |
|
787 | 787 | |
788 | - if ( get_transient($cache_option) ) { |
|
788 | + if (get_transient($cache_option)) { |
|
789 | 789 | // object exists and is current |
790 | 790 | return 'HIT'; |
791 | 791 | } else { |
@@ -797,15 +797,15 @@ discard block |
||
797 | 797 | /*=======================================================================*\ |
798 | 798 | Function: serialize |
799 | 799 | \*=======================================================================*/ |
800 | - function serialize ( $rss ) { |
|
801 | - return serialize( $rss ); |
|
800 | + function serialize($rss) { |
|
801 | + return serialize($rss); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | /*=======================================================================*\ |
805 | 805 | Function: unserialize |
806 | 806 | \*=======================================================================*/ |
807 | - function unserialize ( $data ) { |
|
808 | - return unserialize( $data ); |
|
807 | + function unserialize($data) { |
|
808 | + return unserialize($data); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /*=======================================================================*\ |
@@ -814,64 +814,64 @@ discard block |
||
814 | 814 | Input: url from wich the rss file was fetched |
815 | 815 | Output: a file name |
816 | 816 | \*=======================================================================*/ |
817 | - function file_name ($url) { |
|
818 | - return md5( $url ); |
|
817 | + function file_name($url) { |
|
818 | + return md5($url); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | /*=======================================================================*\ |
822 | 822 | Function: error |
823 | 823 | Purpose: register error |
824 | 824 | \*=======================================================================*/ |
825 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
825 | + function error($errormsg, $lvl = E_USER_WARNING) { |
|
826 | 826 | // append PHP's error message if track_errors enabled |
827 | - if ( isset($php_errormsg) ) { |
|
827 | + if (isset($php_errormsg)) { |
|
828 | 828 | $errormsg .= " ($php_errormsg)"; |
829 | 829 | } |
830 | 830 | $this->ERROR = $errormsg; |
831 | - if ( MAGPIE_DEBUG ) { |
|
832 | - trigger_error( $errormsg, $lvl); |
|
831 | + if (MAGPIE_DEBUG) { |
|
832 | + trigger_error($errormsg, $lvl); |
|
833 | 833 | } |
834 | 834 | else { |
835 | - error_log( $errormsg, 0); |
|
835 | + error_log($errormsg, 0); |
|
836 | 836 | } |
837 | 837 | } |
838 | - function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
839 | - if ( MAGPIE_DEBUG ) { |
|
838 | + function debug($debugmsg, $lvl = E_USER_NOTICE) { |
|
839 | + if (MAGPIE_DEBUG) { |
|
840 | 840 | $this->error("MagpieRSS [debug] $debugmsg", $lvl); |
841 | 841 | } |
842 | 842 | } |
843 | 843 | } |
844 | 844 | |
845 | -if ( !function_exists('parse_w3cdtf') ) : |
|
846 | -function parse_w3cdtf ( $date_str ) { |
|
845 | +if ( ! function_exists('parse_w3cdtf')) : |
|
846 | +function parse_w3cdtf($date_str) { |
|
847 | 847 | |
848 | 848 | # regex to match wc3dtf |
849 | 849 | $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
850 | 850 | |
851 | - if ( preg_match( $pat, $date_str, $match ) ) { |
|
852 | - list( $year, $month, $day, $hours, $minutes, $seconds) = |
|
853 | - array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]); |
|
851 | + if (preg_match($pat, $date_str, $match)) { |
|
852 | + list($year, $month, $day, $hours, $minutes, $seconds) = |
|
853 | + array($match[1], $match[2], $match[3], $match[4], $match[5], $match[7]); |
|
854 | 854 | |
855 | 855 | # calc epoch for current date assuming GMT |
856 | - $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); |
|
856 | + $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year); |
|
857 | 857 | |
858 | 858 | $offset = 0; |
859 | - if ( $match[11] == 'Z' ) { |
|
859 | + if ($match[11] == 'Z') { |
|
860 | 860 | # zulu time, aka GMT |
861 | 861 | } |
862 | 862 | else { |
863 | - list( $tz_mod, $tz_hour, $tz_min ) = |
|
864 | - array( $match[8], $match[9], $match[10]); |
|
863 | + list($tz_mod, $tz_hour, $tz_min) = |
|
864 | + array($match[8], $match[9], $match[10]); |
|
865 | 865 | |
866 | 866 | # zero out the variables |
867 | - if ( ! $tz_hour ) { $tz_hour = 0; } |
|
868 | - if ( ! $tz_min ) { $tz_min = 0; } |
|
867 | + if ( ! $tz_hour) { $tz_hour = 0; } |
|
868 | + if ( ! $tz_min) { $tz_min = 0; } |
|
869 | 869 | |
870 | - $offset_secs = (($tz_hour*60)+$tz_min)*60; |
|
870 | + $offset_secs = (($tz_hour * 60) + $tz_min) * 60; |
|
871 | 871 | |
872 | 872 | # is timezone ahead of GMT? then subtract offset |
873 | 873 | # |
874 | - if ( $tz_mod == '+' ) { |
|
874 | + if ($tz_mod == '+') { |
|
875 | 875 | $offset_secs = $offset_secs * -1; |
876 | 876 | } |
877 | 877 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | } |
887 | 887 | endif; |
888 | 888 | |
889 | -if ( !function_exists('wp_rss') ) : |
|
889 | +if ( ! function_exists('wp_rss')) : |
|
890 | 890 | /** |
891 | 891 | * Display all RSS items in a HTML ordered list. |
892 | 892 | * |
@@ -897,31 +897,31 @@ discard block |
||
897 | 897 | * @param string $url URL of feed to display. Will not auto sense feed URL. |
898 | 898 | * @param int $num_items Optional. Number of items to display, default is all. |
899 | 899 | */ |
900 | -function wp_rss( $url, $num_items = -1 ) { |
|
901 | - if ( $rss = fetch_rss( $url ) ) { |
|
900 | +function wp_rss($url, $num_items = -1) { |
|
901 | + if ($rss = fetch_rss($url)) { |
|
902 | 902 | echo '<ul>'; |
903 | 903 | |
904 | - if ( $num_items !== -1 ) { |
|
905 | - $rss->items = array_slice( $rss->items, 0, $num_items ); |
|
904 | + if ($num_items !== -1) { |
|
905 | + $rss->items = array_slice($rss->items, 0, $num_items); |
|
906 | 906 | } |
907 | 907 | |
908 | - foreach ( (array) $rss->items as $item ) { |
|
908 | + foreach ((array) $rss->items as $item) { |
|
909 | 909 | printf( |
910 | 910 | '<li><a href="%1$s" title="%2$s">%3$s</a></li>', |
911 | - esc_url( $item['link'] ), |
|
912 | - esc_attr( strip_tags( $item['description'] ) ), |
|
913 | - esc_html( $item['title'] ) |
|
911 | + esc_url($item['link']), |
|
912 | + esc_attr(strip_tags($item['description'])), |
|
913 | + esc_html($item['title']) |
|
914 | 914 | ); |
915 | 915 | } |
916 | 916 | |
917 | 917 | echo '</ul>'; |
918 | 918 | } else { |
919 | - _e( 'An error has occurred, which probably means the feed is down. Try again later.' ); |
|
919 | + _e('An error has occurred, which probably means the feed is down. Try again later.'); |
|
920 | 920 | } |
921 | 921 | } |
922 | 922 | endif; |
923 | 923 | |
924 | -if ( !function_exists('get_rss') ) : |
|
924 | +if ( ! function_exists('get_rss')) : |
|
925 | 925 | /** |
926 | 926 | * Display RSS items in HTML list items. |
927 | 927 | * |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | * @param int $num_items Optional. Number of items to display, default is all. |
939 | 939 | * @return bool False on failure. |
940 | 940 | */ |
941 | -function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS |
|
941 | +function get_rss($url, $num_items = 5) { // Like get posts, but for RSS |
|
942 | 942 | $rss = fetch_rss($url); |
943 | - if ( $rss ) { |
|
943 | + if ($rss) { |
|
944 | 944 | $rss->items = array_slice($rss->items, 0, $num_items); |
945 | - foreach ( (array) $rss->items as $item ) { |
|
945 | + foreach ((array) $rss->items as $item) { |
|
946 | 946 | echo "<li>\n"; |
947 | 947 | echo "<a href='$item[link]' title='$item[description]'>"; |
948 | 948 | echo esc_html($item['title']); |