@@ -115,40 +115,40 @@ discard block |
||
| 115 | 115 | * @param string $name Optional. User's username |
| 116 | 116 | * @param int $blog_id Optional Site ID, defaults to current site. |
| 117 | 117 | */ |
| 118 | - public function __construct( $id = 0, $name = '', $blog_id = '' ) { |
|
| 119 | - if ( ! isset( self::$back_compat_keys ) ) { |
|
| 118 | + public function __construct($id = 0, $name = '', $blog_id = '') { |
|
| 119 | + if ( ! isset(self::$back_compat_keys)) { |
|
| 120 | 120 | $prefix = $GLOBALS['wpdb']->prefix; |
| 121 | 121 | self::$back_compat_keys = array( |
| 122 | 122 | 'user_firstname' => 'first_name', |
| 123 | 123 | 'user_lastname' => 'last_name', |
| 124 | 124 | 'user_description' => 'description', |
| 125 | - 'user_level' => $prefix . 'user_level', |
|
| 126 | - $prefix . 'usersettings' => $prefix . 'user-settings', |
|
| 127 | - $prefix . 'usersettingstime' => $prefix . 'user-settings-time', |
|
| 125 | + 'user_level' => $prefix.'user_level', |
|
| 126 | + $prefix.'usersettings' => $prefix.'user-settings', |
|
| 127 | + $prefix.'usersettingstime' => $prefix.'user-settings-time', |
|
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $id instanceof WP_User ) { |
|
| 132 | - $this->init( $id->data, $blog_id ); |
|
| 131 | + if ($id instanceof WP_User) { |
|
| 132 | + $this->init($id->data, $blog_id); |
|
| 133 | 133 | return; |
| 134 | - } elseif ( is_object( $id ) ) { |
|
| 135 | - $this->init( $id, $blog_id ); |
|
| 134 | + } elseif (is_object($id)) { |
|
| 135 | + $this->init($id, $blog_id); |
|
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( ! empty( $id ) && ! is_numeric( $id ) ) { |
|
| 139 | + if ( ! empty($id) && ! is_numeric($id)) { |
|
| 140 | 140 | $name = $id; |
| 141 | 141 | $id = 0; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if ( $id ) { |
|
| 145 | - $data = self::get_data_by( 'id', $id ); |
|
| 144 | + if ($id) { |
|
| 145 | + $data = self::get_data_by('id', $id); |
|
| 146 | 146 | } else { |
| 147 | - $data = self::get_data_by( 'login', $name ); |
|
| 147 | + $data = self::get_data_by('login', $name); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ( $data ) { |
|
| 151 | - $this->init( $data, $blog_id ); |
|
| 150 | + if ($data) { |
|
| 151 | + $this->init($data, $blog_id); |
|
| 152 | 152 | } else { |
| 153 | 153 | $this->data = new stdClass; |
| 154 | 154 | } |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | * @param object $data User DB row object. |
| 161 | 161 | * @param int $blog_id Optional. The site ID to initialize for. |
| 162 | 162 | */ |
| 163 | - public function init( $data, $blog_id = '' ) { |
|
| 163 | + public function init($data, $blog_id = '') { |
|
| 164 | 164 | $this->data = $data; |
| 165 | 165 | $this->ID = (int) $data->ID; |
| 166 | 166 | |
| 167 | - $this->for_blog( $blog_id ); |
|
| 167 | + $this->for_blog($blog_id); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -181,30 +181,30 @@ discard block |
||
| 181 | 181 | * @param string|int $value The field value |
| 182 | 182 | * @return object|false Raw user object |
| 183 | 183 | */ |
| 184 | - public static function get_data_by( $field, $value ) { |
|
| 184 | + public static function get_data_by($field, $value) { |
|
| 185 | 185 | global $wpdb; |
| 186 | 186 | |
| 187 | 187 | // 'ID' is an alias of 'id'. |
| 188 | - if ( 'ID' === $field ) { |
|
| 188 | + if ('ID' === $field) { |
|
| 189 | 189 | $field = 'id'; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( 'id' == $field ) { |
|
| 192 | + if ('id' == $field) { |
|
| 193 | 193 | // Make sure the value is numeric to avoid casting objects, for example, |
| 194 | 194 | // to int 1. |
| 195 | - if ( ! is_numeric( $value ) ) |
|
| 195 | + if ( ! is_numeric($value)) |
|
| 196 | 196 | return false; |
| 197 | - $value = intval( $value ); |
|
| 198 | - if ( $value < 1 ) |
|
| 197 | + $value = intval($value); |
|
| 198 | + if ($value < 1) |
|
| 199 | 199 | return false; |
| 200 | 200 | } else { |
| 201 | - $value = trim( $value ); |
|
| 201 | + $value = trim($value); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ( !$value ) |
|
| 204 | + if ( ! $value) |
|
| 205 | 205 | return false; |
| 206 | 206 | |
| 207 | - switch ( $field ) { |
|
| 207 | + switch ($field) { |
|
| 208 | 208 | case 'id': |
| 209 | 209 | $user_id = $value; |
| 210 | 210 | $db_field = 'ID'; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $db_field = 'user_email'; |
| 219 | 219 | break; |
| 220 | 220 | case 'login': |
| 221 | - $value = sanitize_user( $value ); |
|
| 221 | + $value = sanitize_user($value); |
|
| 222 | 222 | $user_id = wp_cache_get($value, 'userlogins'); |
| 223 | 223 | $db_field = 'user_login'; |
| 224 | 224 | break; |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( false !== $user_id ) { |
|
| 230 | - if ( $user = wp_cache_get( $user_id, 'users' ) ) |
|
| 229 | + if (false !== $user_id) { |
|
| 230 | + if ($user = wp_cache_get($user_id, 'users')) |
|
| 231 | 231 | return $user; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( !$user = $wpdb->get_row( $wpdb->prepare( |
|
| 234 | + if ( ! $user = $wpdb->get_row($wpdb->prepare( |
|
| 235 | 235 | "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value |
| 236 | - ) ) ) |
|
| 236 | + ))) |
|
| 237 | 237 | return false; |
| 238 | 238 | |
| 239 | - update_user_caches( $user ); |
|
| 239 | + update_user_caches($user); |
|
| 240 | 240 | |
| 241 | 241 | return $user; |
| 242 | 242 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | * @param array $arguments Arguments to pass when calling. |
| 252 | 252 | * @return mixed|false Return value of the callback, false otherwise. |
| 253 | 253 | */ |
| 254 | - public function __call( $name, $arguments ) { |
|
| 255 | - if ( '_init_caps' === $name ) { |
|
| 256 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 254 | + public function __call($name, $arguments) { |
|
| 255 | + if ('_init_caps' === $name) { |
|
| 256 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 257 | 257 | } |
| 258 | 258 | return false; |
| 259 | 259 | } |
@@ -267,25 +267,25 @@ discard block |
||
| 267 | 267 | * @param string $key User meta key to check if set. |
| 268 | 268 | * @return bool Whether the given user meta key is set. |
| 269 | 269 | */ |
| 270 | - public function __isset( $key ) { |
|
| 271 | - if ( 'id' == $key ) { |
|
| 272 | - _deprecated_argument( 'WP_User->id', '2.1.0', |
|
| 270 | + public function __isset($key) { |
|
| 271 | + if ('id' == $key) { |
|
| 272 | + _deprecated_argument('WP_User->id', '2.1.0', |
|
| 273 | 273 | sprintf( |
| 274 | 274 | /* translators: %s: WP_User->ID */ |
| 275 | - __( 'Use %s instead.' ), |
|
| 275 | + __('Use %s instead.'), |
|
| 276 | 276 | '<code>WP_User->ID</code>' |
| 277 | 277 | ) |
| 278 | 278 | ); |
| 279 | 279 | $key = 'ID'; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if ( isset( $this->data->$key ) ) |
|
| 282 | + if (isset($this->data->$key)) |
|
| 283 | 283 | return true; |
| 284 | 284 | |
| 285 | - if ( isset( self::$back_compat_keys[ $key ] ) ) |
|
| 286 | - $key = self::$back_compat_keys[ $key ]; |
|
| 285 | + if (isset(self::$back_compat_keys[$key])) |
|
| 286 | + $key = self::$back_compat_keys[$key]; |
|
| 287 | 287 | |
| 288 | - return metadata_exists( 'user', $this->ID, $key ); |
|
| 288 | + return metadata_exists('user', $this->ID, $key); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -297,28 +297,28 @@ discard block |
||
| 297 | 297 | * @param string $key User meta key to retrieve. |
| 298 | 298 | * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID. |
| 299 | 299 | */ |
| 300 | - public function __get( $key ) { |
|
| 301 | - if ( 'id' == $key ) { |
|
| 302 | - _deprecated_argument( 'WP_User->id', '2.1.0', |
|
| 300 | + public function __get($key) { |
|
| 301 | + if ('id' == $key) { |
|
| 302 | + _deprecated_argument('WP_User->id', '2.1.0', |
|
| 303 | 303 | sprintf( |
| 304 | 304 | /* translators: %s: WP_User->ID */ |
| 305 | - __( 'Use %s instead.' ), |
|
| 305 | + __('Use %s instead.'), |
|
| 306 | 306 | '<code>WP_User->ID</code>' |
| 307 | 307 | ) |
| 308 | 308 | ); |
| 309 | 309 | return $this->ID; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( isset( $this->data->$key ) ) { |
|
| 312 | + if (isset($this->data->$key)) { |
|
| 313 | 313 | $value = $this->data->$key; |
| 314 | 314 | } else { |
| 315 | - if ( isset( self::$back_compat_keys[ $key ] ) ) |
|
| 316 | - $key = self::$back_compat_keys[ $key ]; |
|
| 317 | - $value = get_user_meta( $this->ID, $key, true ); |
|
| 315 | + if (isset(self::$back_compat_keys[$key])) |
|
| 316 | + $key = self::$back_compat_keys[$key]; |
|
| 317 | + $value = get_user_meta($this->ID, $key, true); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( $this->filter ) { |
|
| 321 | - $value = sanitize_user_field( $key, $value, $this->ID, $this->filter ); |
|
| 320 | + if ($this->filter) { |
|
| 321 | + $value = sanitize_user_field($key, $value, $this->ID, $this->filter); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | return $value; |
@@ -336,12 +336,12 @@ discard block |
||
| 336 | 336 | * @param string $key User meta key. |
| 337 | 337 | * @param mixed $value User meta value. |
| 338 | 338 | */ |
| 339 | - public function __set( $key, $value ) { |
|
| 340 | - if ( 'id' == $key ) { |
|
| 341 | - _deprecated_argument( 'WP_User->id', '2.1.0', |
|
| 339 | + public function __set($key, $value) { |
|
| 340 | + if ('id' == $key) { |
|
| 341 | + _deprecated_argument('WP_User->id', '2.1.0', |
|
| 342 | 342 | sprintf( |
| 343 | 343 | /* translators: %s: WP_User->ID */ |
| 344 | - __( 'Use %s instead.' ), |
|
| 344 | + __('Use %s instead.'), |
|
| 345 | 345 | '<code>WP_User->ID</code>' |
| 346 | 346 | ) |
| 347 | 347 | ); |
@@ -360,23 +360,23 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @param string $key User meta key to unset. |
| 362 | 362 | */ |
| 363 | - public function __unset( $key ) { |
|
| 364 | - if ( 'id' == $key ) { |
|
| 365 | - _deprecated_argument( 'WP_User->id', '2.1.0', |
|
| 363 | + public function __unset($key) { |
|
| 364 | + if ('id' == $key) { |
|
| 365 | + _deprecated_argument('WP_User->id', '2.1.0', |
|
| 366 | 366 | sprintf( |
| 367 | 367 | /* translators: %s: WP_User->ID */ |
| 368 | - __( 'Use %s instead.' ), |
|
| 368 | + __('Use %s instead.'), |
|
| 369 | 369 | '<code>WP_User->ID</code>' |
| 370 | 370 | ) |
| 371 | 371 | ); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( isset( $this->data->$key ) ) { |
|
| 375 | - unset( $this->data->$key ); |
|
| 374 | + if (isset($this->data->$key)) { |
|
| 375 | + unset($this->data->$key); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( isset( self::$back_compat_keys[ $key ] ) ) { |
|
| 379 | - unset( self::$back_compat_keys[ $key ] ); |
|
| 378 | + if (isset(self::$back_compat_keys[$key])) { |
|
| 379 | + unset(self::$back_compat_keys[$key]); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @return bool True if user exists in the database, false if not. |
| 390 | 390 | */ |
| 391 | 391 | public function exists() { |
| 392 | - return ! empty( $this->ID ); |
|
| 392 | + return ! empty($this->ID); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | * @param string $key Property |
| 403 | 403 | * @return mixed |
| 404 | 404 | */ |
| 405 | - public function get( $key ) { |
|
| 406 | - return $this->__get( $key ); |
|
| 405 | + public function get($key) { |
|
| 406 | + return $this->__get($key); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | * @param string $key Property |
| 417 | 417 | * @return bool |
| 418 | 418 | */ |
| 419 | - public function has_prop( $key ) { |
|
| 420 | - return $this->__isset( $key ); |
|
| 419 | + public function has_prop($key) { |
|
| 420 | + return $this->__isset($key); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @return array Array representation. |
| 429 | 429 | */ |
| 430 | 430 | public function to_array() { |
| 431 | - return get_object_vars( $this->data ); |
|
| 431 | + return get_object_vars($this->data); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -446,17 +446,17 @@ discard block |
||
| 446 | 446 | * |
| 447 | 447 | * @param string $cap_key Optional capability key |
| 448 | 448 | */ |
| 449 | - protected function _init_caps( $cap_key = '' ) { |
|
| 449 | + protected function _init_caps($cap_key = '') { |
|
| 450 | 450 | global $wpdb; |
| 451 | 451 | |
| 452 | - if ( empty($cap_key) ) |
|
| 453 | - $this->cap_key = $wpdb->get_blog_prefix() . 'capabilities'; |
|
| 452 | + if (empty($cap_key)) |
|
| 453 | + $this->cap_key = $wpdb->get_blog_prefix().'capabilities'; |
|
| 454 | 454 | else |
| 455 | 455 | $this->cap_key = $cap_key; |
| 456 | 456 | |
| 457 | - $this->caps = get_user_meta( $this->ID, $this->cap_key, true ); |
|
| 457 | + $this->caps = get_user_meta($this->ID, $this->cap_key, true); |
|
| 458 | 458 | |
| 459 | - if ( ! is_array( $this->caps ) ) |
|
| 459 | + if ( ! is_array($this->caps)) |
|
| 460 | 460 | $this->caps = array(); |
| 461 | 461 | |
| 462 | 462 | $this->get_role_caps(); |
@@ -479,16 +479,16 @@ discard block |
||
| 479 | 479 | $wp_roles = wp_roles(); |
| 480 | 480 | |
| 481 | 481 | //Filter out caps that are not role names and assign to $this->roles |
| 482 | - if ( is_array( $this->caps ) ) |
|
| 483 | - $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) ); |
|
| 482 | + if (is_array($this->caps)) |
|
| 483 | + $this->roles = array_filter(array_keys($this->caps), array($wp_roles, 'is_role')); |
|
| 484 | 484 | |
| 485 | 485 | //Build $allcaps from role caps, overlay user's $caps |
| 486 | 486 | $this->allcaps = array(); |
| 487 | - foreach ( (array) $this->roles as $role ) { |
|
| 488 | - $the_role = $wp_roles->get_role( $role ); |
|
| 489 | - $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities ); |
|
| 487 | + foreach ((array) $this->roles as $role) { |
|
| 488 | + $the_role = $wp_roles->get_role($role); |
|
| 489 | + $this->allcaps = array_merge((array) $this->allcaps, (array) $the_role->capabilities); |
|
| 490 | 490 | } |
| 491 | - $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); |
|
| 491 | + $this->allcaps = array_merge((array) $this->allcaps, (array) $this->caps); |
|
| 492 | 492 | |
| 493 | 493 | return $this->allcaps; |
| 494 | 494 | } |
@@ -503,13 +503,13 @@ discard block |
||
| 503 | 503 | * |
| 504 | 504 | * @param string $role Role name. |
| 505 | 505 | */ |
| 506 | - public function add_role( $role ) { |
|
| 507 | - if ( empty( $role ) ) { |
|
| 506 | + public function add_role($role) { |
|
| 507 | + if (empty($role)) { |
|
| 508 | 508 | return; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | $this->caps[$role] = true; |
| 512 | - update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
|
| 512 | + update_user_meta($this->ID, $this->cap_key, $this->caps); |
|
| 513 | 513 | $this->get_role_caps(); |
| 514 | 514 | $this->update_user_level_from_caps(); |
| 515 | 515 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | * @param int $user_id The user ID. |
| 522 | 522 | * @param string $role The new role. |
| 523 | 523 | */ |
| 524 | - do_action( 'add_user_role', $this->ID, $role ); |
|
| 524 | + do_action('add_user_role', $this->ID, $role); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @param string $role Role name. |
| 534 | 534 | */ |
| 535 | - public function remove_role( $role ) { |
|
| 536 | - if ( !in_array($role, $this->roles) ) |
|
| 535 | + public function remove_role($role) { |
|
| 536 | + if ( ! in_array($role, $this->roles)) |
|
| 537 | 537 | return; |
| 538 | - unset( $this->caps[$role] ); |
|
| 539 | - update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
|
| 538 | + unset($this->caps[$role]); |
|
| 539 | + update_user_meta($this->ID, $this->cap_key, $this->caps); |
|
| 540 | 540 | $this->get_role_caps(); |
| 541 | 541 | $this->update_user_level_from_caps(); |
| 542 | 542 | |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @param int $user_id The user ID. |
| 549 | 549 | * @param string $role The removed role. |
| 550 | 550 | */ |
| 551 | - do_action( 'remove_user_role', $this->ID, $role ); |
|
| 551 | + do_action('remove_user_role', $this->ID, $role); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -563,21 +563,21 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @param string $role Role name. |
| 565 | 565 | */ |
| 566 | - public function set_role( $role ) { |
|
| 567 | - if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) |
|
| 566 | + public function set_role($role) { |
|
| 567 | + if (1 == count($this->roles) && $role == current($this->roles)) |
|
| 568 | 568 | return; |
| 569 | 569 | |
| 570 | - foreach ( (array) $this->roles as $oldrole ) |
|
| 571 | - unset( $this->caps[$oldrole] ); |
|
| 570 | + foreach ((array) $this->roles as $oldrole) |
|
| 571 | + unset($this->caps[$oldrole]); |
|
| 572 | 572 | |
| 573 | 573 | $old_roles = $this->roles; |
| 574 | - if ( !empty( $role ) ) { |
|
| 574 | + if ( ! empty($role)) { |
|
| 575 | 575 | $this->caps[$role] = true; |
| 576 | - $this->roles = array( $role => true ); |
|
| 576 | + $this->roles = array($role => true); |
|
| 577 | 577 | } else { |
| 578 | 578 | $this->roles = false; |
| 579 | 579 | } |
| 580 | - update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
|
| 580 | + update_user_meta($this->ID, $this->cap_key, $this->caps); |
|
| 581 | 581 | $this->get_role_caps(); |
| 582 | 582 | $this->update_user_level_from_caps(); |
| 583 | 583 | |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @param string $role The new role. |
| 592 | 592 | * @param array $old_roles An array of the user's previous roles. |
| 593 | 593 | */ |
| 594 | - do_action( 'set_user_role', $this->ID, $role, $old_roles ); |
|
| 594 | + do_action('set_user_role', $this->ID, $role, $old_roles); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -613,10 +613,10 @@ discard block |
||
| 613 | 613 | * @param string $item Level capability name. |
| 614 | 614 | * @return int Max Level. |
| 615 | 615 | */ |
| 616 | - public function level_reduction( $max, $item ) { |
|
| 617 | - if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) { |
|
| 618 | - $level = intval( $matches[1] ); |
|
| 619 | - return max( $max, $level ); |
|
| 616 | + public function level_reduction($max, $item) { |
|
| 617 | + if (preg_match('/^level_(10|[0-9])$/i', $item, $matches)) { |
|
| 618 | + $level = intval($matches[1]); |
|
| 619 | + return max($max, $level); |
|
| 620 | 620 | } else { |
| 621 | 621 | return $max; |
| 622 | 622 | } |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | */ |
| 637 | 637 | public function update_user_level_from_caps() { |
| 638 | 638 | global $wpdb; |
| 639 | - $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 ); |
|
| 640 | - update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level ); |
|
| 639 | + $this->user_level = array_reduce(array_keys($this->allcaps), array($this, 'level_reduction'), 0); |
|
| 640 | + update_user_meta($this->ID, $wpdb->get_blog_prefix().'user_level', $this->user_level); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -649,9 +649,9 @@ discard block |
||
| 649 | 649 | * @param string $cap Capability name. |
| 650 | 650 | * @param bool $grant Whether to grant capability to user. |
| 651 | 651 | */ |
| 652 | - public function add_cap( $cap, $grant = true ) { |
|
| 652 | + public function add_cap($cap, $grant = true) { |
|
| 653 | 653 | $this->caps[$cap] = $grant; |
| 654 | - update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
|
| 654 | + update_user_meta($this->ID, $this->cap_key, $this->caps); |
|
| 655 | 655 | $this->get_role_caps(); |
| 656 | 656 | $this->update_user_level_from_caps(); |
| 657 | 657 | } |
@@ -664,12 +664,12 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @param string $cap Capability name. |
| 666 | 666 | */ |
| 667 | - public function remove_cap( $cap ) { |
|
| 668 | - if ( ! isset( $this->caps[ $cap ] ) ) { |
|
| 667 | + public function remove_cap($cap) { |
|
| 668 | + if ( ! isset($this->caps[$cap])) { |
|
| 669 | 669 | return; |
| 670 | 670 | } |
| 671 | - unset( $this->caps[ $cap ] ); |
|
| 672 | - update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
|
| 671 | + unset($this->caps[$cap]); |
|
| 672 | + update_user_meta($this->ID, $this->cap_key, $this->caps); |
|
| 673 | 673 | $this->get_role_caps(); |
| 674 | 674 | $this->update_user_level_from_caps(); |
| 675 | 675 | } |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | public function remove_all_caps() { |
| 686 | 686 | global $wpdb; |
| 687 | 687 | $this->caps = array(); |
| 688 | - delete_user_meta( $this->ID, $this->cap_key ); |
|
| 689 | - delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' ); |
|
| 688 | + delete_user_meta($this->ID, $this->cap_key); |
|
| 689 | + delete_user_meta($this->ID, $wpdb->get_blog_prefix().'user_level'); |
|
| 690 | 690 | $this->get_role_caps(); |
| 691 | 691 | } |
| 692 | 692 | |
@@ -710,19 +710,19 @@ discard block |
||
| 710 | 710 | * @return bool Whether the current user has the given capability. If `$cap` is a meta cap and `$object_id` is |
| 711 | 711 | * passed, whether the current user has the given meta capability for the given object. |
| 712 | 712 | */ |
| 713 | - public function has_cap( $cap ) { |
|
| 714 | - if ( is_numeric( $cap ) ) { |
|
| 715 | - _deprecated_argument( __FUNCTION__, '2.0.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') ); |
|
| 716 | - $cap = $this->translate_level_to_cap( $cap ); |
|
| 713 | + public function has_cap($cap) { |
|
| 714 | + if (is_numeric($cap)) { |
|
| 715 | + _deprecated_argument(__FUNCTION__, '2.0.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.')); |
|
| 716 | + $cap = $this->translate_level_to_cap($cap); |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | - $args = array_slice( func_get_args(), 1 ); |
|
| 720 | - $args = array_merge( array( $cap, $this->ID ), $args ); |
|
| 721 | - $caps = call_user_func_array( 'map_meta_cap', $args ); |
|
| 719 | + $args = array_slice(func_get_args(), 1); |
|
| 720 | + $args = array_merge(array($cap, $this->ID), $args); |
|
| 721 | + $caps = call_user_func_array('map_meta_cap', $args); |
|
| 722 | 722 | |
| 723 | 723 | // Multisite super admin has all caps by definition, Unless specifically denied. |
| 724 | - if ( is_multisite() && is_super_admin( $this->ID ) ) { |
|
| 725 | - if ( in_array('do_not_allow', $caps) ) |
|
| 724 | + if (is_multisite() && is_super_admin($this->ID)) { |
|
| 725 | + if (in_array('do_not_allow', $caps)) |
|
| 726 | 726 | return false; |
| 727 | 727 | return true; |
| 728 | 728 | } |
@@ -738,14 +738,14 @@ discard block |
||
| 738 | 738 | * @param array $args Optional parameters passed to has_cap(), typically object ID. |
| 739 | 739 | * @param WP_User $user The user object. |
| 740 | 740 | */ |
| 741 | - $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); |
|
| 741 | + $capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args, $this); |
|
| 742 | 742 | |
| 743 | 743 | // Everyone is allowed to exist. |
| 744 | 744 | $capabilities['exist'] = true; |
| 745 | 745 | |
| 746 | 746 | // Must have ALL requested caps. |
| 747 | - foreach ( (array) $caps as $cap ) { |
|
| 748 | - if ( empty( $capabilities[ $cap ] ) ) |
|
| 747 | + foreach ((array) $caps as $cap) { |
|
| 748 | + if (empty($capabilities[$cap])) |
|
| 749 | 749 | return false; |
| 750 | 750 | } |
| 751 | 751 | |
@@ -763,8 +763,8 @@ discard block |
||
| 763 | 763 | * @param int $level Level number, 1 to 10. |
| 764 | 764 | * @return string |
| 765 | 765 | */ |
| 766 | - public function translate_level_to_cap( $level ) { |
|
| 767 | - return 'level_' . $level; |
|
| 766 | + public function translate_level_to_cap($level) { |
|
| 767 | + return 'level_'.$level; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -776,12 +776,12 @@ discard block |
||
| 776 | 776 | * |
| 777 | 777 | * @param int $blog_id Optional. Site ID, defaults to current site. |
| 778 | 778 | */ |
| 779 | - public function for_blog( $blog_id = '' ) { |
|
| 779 | + public function for_blog($blog_id = '') { |
|
| 780 | 780 | global $wpdb; |
| 781 | - if ( ! empty( $blog_id ) ) |
|
| 782 | - $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities'; |
|
| 781 | + if ( ! empty($blog_id)) |
|
| 782 | + $cap_key = $wpdb->get_blog_prefix($blog_id).'capabilities'; |
|
| 783 | 783 | else |
| 784 | 784 | $cap_key = ''; |
| 785 | - $this->_init_caps( $cap_key ); |
|
| 785 | + $this->_init_caps($cap_key); |
|
| 786 | 786 | } |
| 787 | 787 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | * @param mixed $default Optional. Value to return if the query variable is not set. Default empty. |
| 24 | 24 | * @return mixed Contents of the query variable. |
| 25 | 25 | */ |
| 26 | -function get_query_var( $var, $default = '' ) { |
|
| 26 | +function get_query_var($var, $default = '') { |
|
| 27 | 27 | global $wp_query; |
| 28 | - return $wp_query->get( $var, $default ); |
|
| 28 | + return $wp_query->get($var, $default); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | * @param string $var Query variable key. |
| 72 | 72 | * @param mixed $value Query variable value. |
| 73 | 73 | */ |
| 74 | -function set_query_var( $var, $value ) { |
|
| 74 | +function set_query_var($var, $value) { |
|
| 75 | 75 | global $wp_query; |
| 76 | - $wp_query->set( $var, $value ); |
|
| 76 | + $wp_query->set($var, $value); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | function wp_reset_postdata() { |
| 128 | 128 | global $wp_query; |
| 129 | 129 | |
| 130 | - if ( isset( $wp_query ) ) { |
|
| 130 | + if (isset($wp_query)) { |
|
| 131 | 131 | $wp_query->reset_postdata(); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | function is_archive() { |
| 151 | 151 | global $wp_query; |
| 152 | 152 | |
| 153 | - if ( ! isset( $wp_query ) ) { |
|
| 154 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 153 | + if ( ! isset($wp_query)) { |
|
| 154 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,15 +168,15 @@ discard block |
||
| 168 | 168 | * @param string|array $post_types Optional. Post type or array of posts types to check against. |
| 169 | 169 | * @return bool |
| 170 | 170 | */ |
| 171 | -function is_post_type_archive( $post_types = '' ) { |
|
| 171 | +function is_post_type_archive($post_types = '') { |
|
| 172 | 172 | global $wp_query; |
| 173 | 173 | |
| 174 | - if ( ! isset( $wp_query ) ) { |
|
| 175 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 174 | + if ( ! isset($wp_query)) { |
|
| 175 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return $wp_query->is_post_type_archive( $post_types ); |
|
| 179 | + return $wp_query->is_post_type_archive($post_types); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -189,15 +189,15 @@ discard block |
||
| 189 | 189 | * @param int|string|array|object $attachment Attachment ID, title, slug, or array of such. |
| 190 | 190 | * @return bool |
| 191 | 191 | */ |
| 192 | -function is_attachment( $attachment = '' ) { |
|
| 192 | +function is_attachment($attachment = '') { |
|
| 193 | 193 | global $wp_query; |
| 194 | 194 | |
| 195 | - if ( ! isset( $wp_query ) ) { |
|
| 196 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 195 | + if ( ! isset($wp_query)) { |
|
| 196 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - return $wp_query->is_attachment( $attachment ); |
|
| 200 | + return $wp_query->is_attachment($attachment); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames |
| 214 | 214 | * @return bool |
| 215 | 215 | */ |
| 216 | -function is_author( $author = '' ) { |
|
| 216 | +function is_author($author = '') { |
|
| 217 | 217 | global $wp_query; |
| 218 | 218 | |
| 219 | - if ( ! isset( $wp_query ) ) { |
|
| 220 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 219 | + if ( ! isset($wp_query)) { |
|
| 220 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - return $wp_query->is_author( $author ); |
|
| 224 | + return $wp_query->is_author($author); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. |
| 238 | 238 | * @return bool |
| 239 | 239 | */ |
| 240 | -function is_category( $category = '' ) { |
|
| 240 | +function is_category($category = '') { |
|
| 241 | 241 | global $wp_query; |
| 242 | 242 | |
| 243 | - if ( ! isset( $wp_query ) ) { |
|
| 244 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 243 | + if ( ! isset($wp_query)) { |
|
| 244 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - return $wp_query->is_category( $category ); |
|
| 248 | + return $wp_query->is_category($category); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -261,15 +261,15 @@ discard block |
||
| 261 | 261 | * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. |
| 262 | 262 | * @return bool |
| 263 | 263 | */ |
| 264 | -function is_tag( $tag = '' ) { |
|
| 264 | +function is_tag($tag = '') { |
|
| 265 | 265 | global $wp_query; |
| 266 | 266 | |
| 267 | - if ( ! isset( $wp_query ) ) { |
|
| 268 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 267 | + if ( ! isset($wp_query)) { |
|
| 268 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 269 | 269 | return false; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - return $wp_query->is_tag( $tag ); |
|
| 272 | + return $wp_query->is_tag($tag); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -290,15 +290,15 @@ discard block |
||
| 290 | 290 | * @param int|string|array $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. |
| 291 | 291 | * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives). |
| 292 | 292 | */ |
| 293 | -function is_tax( $taxonomy = '', $term = '' ) { |
|
| 293 | +function is_tax($taxonomy = '', $term = '') { |
|
| 294 | 294 | global $wp_query; |
| 295 | 295 | |
| 296 | - if ( ! isset( $wp_query ) ) { |
|
| 297 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 296 | + if ( ! isset($wp_query)) { |
|
| 297 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 298 | 298 | return false; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - return $wp_query->is_tax( $taxonomy, $term ); |
|
| 301 | + return $wp_query->is_tax($taxonomy, $term); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -313,8 +313,8 @@ discard block |
||
| 313 | 313 | function is_date() { |
| 314 | 314 | global $wp_query; |
| 315 | 315 | |
| 316 | - if ( ! isset( $wp_query ) ) { |
|
| 317 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 316 | + if ( ! isset($wp_query)) { |
|
| 317 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 318 | 318 | return false; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | function is_day() { |
| 334 | 334 | global $wp_query; |
| 335 | 335 | |
| 336 | - if ( ! isset( $wp_query ) ) { |
|
| 337 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 336 | + if ( ! isset($wp_query)) { |
|
| 337 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 338 | 338 | return false; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -351,15 +351,15 @@ discard block |
||
| 351 | 351 | * @param string|array $feeds Optional feed types to check. |
| 352 | 352 | * @return bool |
| 353 | 353 | */ |
| 354 | -function is_feed( $feeds = '' ) { |
|
| 354 | +function is_feed($feeds = '') { |
|
| 355 | 355 | global $wp_query; |
| 356 | 356 | |
| 357 | - if ( ! isset( $wp_query ) ) { |
|
| 358 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 357 | + if ( ! isset($wp_query)) { |
|
| 358 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - return $wp_query->is_feed( $feeds ); |
|
| 362 | + return $wp_query->is_feed($feeds); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | function is_comment_feed() { |
| 375 | 375 | global $wp_query; |
| 376 | 376 | |
| 377 | - if ( ! isset( $wp_query ) ) { |
|
| 378 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 377 | + if ( ! isset($wp_query)) { |
|
| 378 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 379 | 379 | return false; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | function is_front_page() { |
| 404 | 404 | global $wp_query; |
| 405 | 405 | |
| 406 | - if ( ! isset( $wp_query ) ) { |
|
| 407 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 406 | + if ( ! isset($wp_query)) { |
|
| 407 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 408 | 408 | return false; |
| 409 | 409 | } |
| 410 | 410 | |
@@ -432,8 +432,8 @@ discard block |
||
| 432 | 432 | function is_home() { |
| 433 | 433 | global $wp_query; |
| 434 | 434 | |
| 435 | - if ( ! isset( $wp_query ) ) { |
|
| 436 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 435 | + if ( ! isset($wp_query)) { |
|
| 436 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 437 | 437 | return false; |
| 438 | 438 | } |
| 439 | 439 | |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | function is_month() { |
| 453 | 453 | global $wp_query; |
| 454 | 454 | |
| 455 | - if ( ! isset( $wp_query ) ) { |
|
| 456 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 455 | + if ( ! isset($wp_query)) { |
|
| 456 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 457 | 457 | return false; |
| 458 | 458 | } |
| 459 | 459 | |
@@ -476,15 +476,15 @@ discard block |
||
| 476 | 476 | * @param int|string|array $page Optional. Page ID, title, slug, or array of such. Default empty. |
| 477 | 477 | * @return bool Whether the query is for an existing single page. |
| 478 | 478 | */ |
| 479 | -function is_page( $page = '' ) { |
|
| 479 | +function is_page($page = '') { |
|
| 480 | 480 | global $wp_query; |
| 481 | 481 | |
| 482 | - if ( ! isset( $wp_query ) ) { |
|
| 483 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 482 | + if ( ! isset($wp_query)) { |
|
| 483 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 484 | 484 | return false; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - return $wp_query->is_page( $page ); |
|
| 487 | + return $wp_query->is_page($page); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -499,8 +499,8 @@ discard block |
||
| 499 | 499 | function is_paged() { |
| 500 | 500 | global $wp_query; |
| 501 | 501 | |
| 502 | - if ( ! isset( $wp_query ) ) { |
|
| 503 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 502 | + if ( ! isset($wp_query)) { |
|
| 503 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 504 | 504 | return false; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -519,8 +519,8 @@ discard block |
||
| 519 | 519 | function is_preview() { |
| 520 | 520 | global $wp_query; |
| 521 | 521 | |
| 522 | - if ( ! isset( $wp_query ) ) { |
|
| 523 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 522 | + if ( ! isset($wp_query)) { |
|
| 523 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 524 | 524 | return false; |
| 525 | 525 | } |
| 526 | 526 | |
@@ -539,8 +539,8 @@ discard block |
||
| 539 | 539 | function is_robots() { |
| 540 | 540 | global $wp_query; |
| 541 | 541 | |
| 542 | - if ( ! isset( $wp_query ) ) { |
|
| 543 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 542 | + if ( ! isset($wp_query)) { |
|
| 543 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 544 | 544 | return false; |
| 545 | 545 | } |
| 546 | 546 | |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | function is_search() { |
| 560 | 560 | global $wp_query; |
| 561 | 561 | |
| 562 | - if ( ! isset( $wp_query ) ) { |
|
| 563 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 562 | + if ( ! isset($wp_query)) { |
|
| 563 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 564 | 564 | return false; |
| 565 | 565 | } |
| 566 | 566 | |
@@ -585,15 +585,15 @@ discard block |
||
| 585 | 585 | * @param int|string|array $post Optional. Post ID, title, slug, or array of such. Default empty. |
| 586 | 586 | * @return bool Whether the query is for an existing single post. |
| 587 | 587 | */ |
| 588 | -function is_single( $post = '' ) { |
|
| 588 | +function is_single($post = '') { |
|
| 589 | 589 | global $wp_query; |
| 590 | 590 | |
| 591 | - if ( ! isset( $wp_query ) ) { |
|
| 592 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 591 | + if ( ! isset($wp_query)) { |
|
| 592 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 593 | 593 | return false; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - return $wp_query->is_single( $post ); |
|
| 596 | + return $wp_query->is_single($post); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -612,15 +612,15 @@ discard block |
||
| 612 | 612 | * @param string|array $post_types Optional. Post type or array of post types. Default empty. |
| 613 | 613 | * @return bool Whether the query is for an existing single post of any of the given post types. |
| 614 | 614 | */ |
| 615 | -function is_singular( $post_types = '' ) { |
|
| 615 | +function is_singular($post_types = '') { |
|
| 616 | 616 | global $wp_query; |
| 617 | 617 | |
| 618 | - if ( ! isset( $wp_query ) ) { |
|
| 619 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 618 | + if ( ! isset($wp_query)) { |
|
| 619 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 620 | 620 | return false; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - return $wp_query->is_singular( $post_types ); |
|
| 623 | + return $wp_query->is_singular($post_types); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
@@ -635,8 +635,8 @@ discard block |
||
| 635 | 635 | function is_time() { |
| 636 | 636 | global $wp_query; |
| 637 | 637 | |
| 638 | - if ( ! isset( $wp_query ) ) { |
|
| 639 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 638 | + if ( ! isset($wp_query)) { |
|
| 639 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 640 | 640 | return false; |
| 641 | 641 | } |
| 642 | 642 | |
@@ -655,8 +655,8 @@ discard block |
||
| 655 | 655 | function is_trackback() { |
| 656 | 656 | global $wp_query; |
| 657 | 657 | |
| 658 | - if ( ! isset( $wp_query ) ) { |
|
| 659 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 658 | + if ( ! isset($wp_query)) { |
|
| 659 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 660 | 660 | return false; |
| 661 | 661 | } |
| 662 | 662 | |
@@ -675,8 +675,8 @@ discard block |
||
| 675 | 675 | function is_year() { |
| 676 | 676 | global $wp_query; |
| 677 | 677 | |
| 678 | - if ( ! isset( $wp_query ) ) { |
|
| 679 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 678 | + if ( ! isset($wp_query)) { |
|
| 679 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 680 | 680 | return false; |
| 681 | 681 | } |
| 682 | 682 | |
@@ -695,8 +695,8 @@ discard block |
||
| 695 | 695 | function is_404() { |
| 696 | 696 | global $wp_query; |
| 697 | 697 | |
| 698 | - if ( ! isset( $wp_query ) ) { |
|
| 699 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 698 | + if ( ! isset($wp_query)) { |
|
| 699 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 700 | 700 | return false; |
| 701 | 701 | } |
| 702 | 702 | |
@@ -715,8 +715,8 @@ discard block |
||
| 715 | 715 | function is_embed() { |
| 716 | 716 | global $wp_query; |
| 717 | 717 | |
| 718 | - if ( ! isset( $wp_query ) ) { |
|
| 719 | - _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); |
|
| 718 | + if ( ! isset($wp_query)) { |
|
| 719 | + _doing_it_wrong(__FUNCTION__, __('Conditional query tags do not work before the query is run. Before then, they always return false.'), '3.1.0'); |
|
| 720 | 720 | return false; |
| 721 | 721 | } |
| 722 | 722 | |
@@ -733,16 +733,16 @@ discard block |
||
| 733 | 733 | * @return bool |
| 734 | 734 | */ |
| 735 | 735 | function is_main_query() { |
| 736 | - if ( 'pre_get_posts' === current_filter() ) { |
|
| 736 | + if ('pre_get_posts' === current_filter()) { |
|
| 737 | 737 | $message = sprintf( |
| 738 | 738 | /* translators: 1: pre_get_posts 2: WP_Query->is_main_query() 3: is_main_query() 4: link to codex is_main_query() page. */ |
| 739 | - __( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ), |
|
| 739 | + __('In %1$s, use the %2$s method, not the %3$s function. See %4$s.'), |
|
| 740 | 740 | '<code>pre_get_posts</code>', |
| 741 | 741 | '<code>WP_Query->is_main_query()</code>', |
| 742 | 742 | '<code>is_main_query()</code>', |
| 743 | - __( 'https://codex.wordpress.org/Function_Reference/is_main_query' ) |
|
| 743 | + __('https://codex.wordpress.org/Function_Reference/is_main_query') |
|
| 744 | 744 | ); |
| 745 | - _doing_it_wrong( __FUNCTION__, $message, '3.7.0' ); |
|
| 745 | + _doing_it_wrong(__FUNCTION__, $message, '3.7.0'); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | global $wp_query; |
@@ -1316,9 +1316,9 @@ discard block |
||
| 1316 | 1316 | */ |
| 1317 | 1317 | private $stopwords; |
| 1318 | 1318 | |
| 1319 | - private $compat_fields = array( 'query_vars_hash', 'query_vars_changed' ); |
|
| 1319 | + private $compat_fields = array('query_vars_hash', 'query_vars_changed'); |
|
| 1320 | 1320 | |
| 1321 | - private $compat_methods = array( 'init_query_flags', 'parse_tax_query' ); |
|
| 1321 | + private $compat_methods = array('init_query_flags', 'parse_tax_query'); |
|
| 1322 | 1322 | |
| 1323 | 1323 | /** |
| 1324 | 1324 | * Resets query flags to false. |
@@ -1372,10 +1372,10 @@ discard block |
||
| 1372 | 1372 | $this->post_count = 0; |
| 1373 | 1373 | $this->current_post = -1; |
| 1374 | 1374 | $this->in_the_loop = false; |
| 1375 | - unset( $this->request ); |
|
| 1376 | - unset( $this->post ); |
|
| 1377 | - unset( $this->comments ); |
|
| 1378 | - unset( $this->comment ); |
|
| 1375 | + unset($this->request); |
|
| 1376 | + unset($this->post); |
|
| 1377 | + unset($this->comments); |
|
| 1378 | + unset($this->comment); |
|
| 1379 | 1379 | $this->comment_count = 0; |
| 1380 | 1380 | $this->current_comment = -1; |
| 1381 | 1381 | $this->found_posts = 0; |
@@ -1446,17 +1446,17 @@ discard block |
||
| 1446 | 1446 | , 'embed' |
| 1447 | 1447 | ); |
| 1448 | 1448 | |
| 1449 | - foreach ( $keys as $key ) { |
|
| 1450 | - if ( !isset($array[$key]) ) |
|
| 1449 | + foreach ($keys as $key) { |
|
| 1450 | + if ( ! isset($array[$key])) |
|
| 1451 | 1451 | $array[$key] = ''; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | - $array_keys = array( 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', |
|
| 1454 | + $array_keys = array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', |
|
| 1455 | 1455 | 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in', |
| 1456 | - 'author__in', 'author__not_in' ); |
|
| 1456 | + 'author__in', 'author__not_in'); |
|
| 1457 | 1457 | |
| 1458 | - foreach ( $array_keys as $key ) { |
|
| 1459 | - if ( !isset($array[$key]) ) |
|
| 1458 | + foreach ($array_keys as $key) { |
|
| 1459 | + if ( ! isset($array[$key])) |
|
| 1460 | 1460 | $array[$key] = array(); |
| 1461 | 1461 | } |
| 1462 | 1462 | return $array; |
@@ -1580,11 +1580,11 @@ discard block |
||
| 1580 | 1580 | * @type int $year The four-digit year. Default empty. Accepts any four-digit year. |
| 1581 | 1581 | * } |
| 1582 | 1582 | */ |
| 1583 | - public function parse_query( $query = '' ) { |
|
| 1584 | - if ( ! empty( $query ) ) { |
|
| 1583 | + public function parse_query($query = '') { |
|
| 1584 | + if ( ! empty($query)) { |
|
| 1585 | 1585 | $this->init(); |
| 1586 | - $this->query = $this->query_vars = wp_parse_args( $query ); |
|
| 1587 | - } elseif ( ! isset( $this->query ) ) { |
|
| 1586 | + $this->query = $this->query_vars = wp_parse_args($query); |
|
| 1587 | + } elseif ( ! isset($this->query)) { |
|
| 1588 | 1588 | $this->query = $this->query_vars; |
| 1589 | 1589 | } |
| 1590 | 1590 | |
@@ -1592,80 +1592,80 @@ discard block |
||
| 1592 | 1592 | $qv = &$this->query_vars; |
| 1593 | 1593 | $this->query_vars_changed = true; |
| 1594 | 1594 | |
| 1595 | - if ( ! empty($qv['robots']) ) |
|
| 1595 | + if ( ! empty($qv['robots'])) |
|
| 1596 | 1596 | $this->is_robots = true; |
| 1597 | 1597 | |
| 1598 | - $qv['p'] = absint($qv['p']); |
|
| 1599 | - $qv['page_id'] = absint($qv['page_id']); |
|
| 1598 | + $qv['p'] = absint($qv['p']); |
|
| 1599 | + $qv['page_id'] = absint($qv['page_id']); |
|
| 1600 | 1600 | $qv['year'] = absint($qv['year']); |
| 1601 | 1601 | $qv['monthnum'] = absint($qv['monthnum']); |
| 1602 | 1602 | $qv['day'] = absint($qv['day']); |
| 1603 | 1603 | $qv['w'] = absint($qv['w']); |
| 1604 | - $qv['m'] = is_scalar( $qv['m'] ) ? preg_replace( '|[^0-9]|', '', $qv['m'] ) : ''; |
|
| 1604 | + $qv['m'] = is_scalar($qv['m']) ? preg_replace('|[^0-9]|', '', $qv['m']) : ''; |
|
| 1605 | 1605 | $qv['paged'] = absint($qv['paged']); |
| 1606 | - $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers |
|
| 1607 | - $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers |
|
| 1608 | - $qv['pagename'] = trim( $qv['pagename'] ); |
|
| 1609 | - $qv['name'] = trim( $qv['name'] ); |
|
| 1610 | - $qv['title'] = trim( $qv['title'] ); |
|
| 1611 | - if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']); |
|
| 1612 | - if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']); |
|
| 1613 | - if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']); |
|
| 1614 | - if ( '' !== $qv['menu_order'] ) $qv['menu_order'] = absint($qv['menu_order']); |
|
| 1606 | + $qv['cat'] = preg_replace('|[^0-9,-]|', '', $qv['cat']); // comma separated list of positive or negative integers |
|
| 1607 | + $qv['author'] = preg_replace('|[^0-9,-]|', '', $qv['author']); // comma separated list of positive or negative integers |
|
| 1608 | + $qv['pagename'] = trim($qv['pagename']); |
|
| 1609 | + $qv['name'] = trim($qv['name']); |
|
| 1610 | + $qv['title'] = trim($qv['title']); |
|
| 1611 | + if ('' !== $qv['hour']) $qv['hour'] = absint($qv['hour']); |
|
| 1612 | + if ('' !== $qv['minute']) $qv['minute'] = absint($qv['minute']); |
|
| 1613 | + if ('' !== $qv['second']) $qv['second'] = absint($qv['second']); |
|
| 1614 | + if ('' !== $qv['menu_order']) $qv['menu_order'] = absint($qv['menu_order']); |
|
| 1615 | 1615 | |
| 1616 | 1616 | // Fairly insane upper bound for search string lengths. |
| 1617 | - if ( ! is_scalar( $qv['s'] ) || ( ! empty( $qv['s'] ) && strlen( $qv['s'] ) > 1600 ) ) { |
|
| 1617 | + if ( ! is_scalar($qv['s']) || ( ! empty($qv['s']) && strlen($qv['s']) > 1600)) { |
|
| 1618 | 1618 | $qv['s'] = ''; |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | // Compat. Map subpost to attachment. |
| 1622 | - if ( '' != $qv['subpost'] ) |
|
| 1622 | + if ('' != $qv['subpost']) |
|
| 1623 | 1623 | $qv['attachment'] = $qv['subpost']; |
| 1624 | - if ( '' != $qv['subpost_id'] ) |
|
| 1624 | + if ('' != $qv['subpost_id']) |
|
| 1625 | 1625 | $qv['attachment_id'] = $qv['subpost_id']; |
| 1626 | 1626 | |
| 1627 | 1627 | $qv['attachment_id'] = absint($qv['attachment_id']); |
| 1628 | 1628 | |
| 1629 | - if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) { |
|
| 1629 | + if (('' != $qv['attachment']) || ! empty($qv['attachment_id'])) { |
|
| 1630 | 1630 | $this->is_single = true; |
| 1631 | 1631 | $this->is_attachment = true; |
| 1632 | - } elseif ( '' != $qv['name'] ) { |
|
| 1632 | + } elseif ('' != $qv['name']) { |
|
| 1633 | 1633 | $this->is_single = true; |
| 1634 | - } elseif ( $qv['p'] ) { |
|
| 1634 | + } elseif ($qv['p']) { |
|
| 1635 | 1635 | $this->is_single = true; |
| 1636 | - } elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) { |
|
| 1636 | + } elseif (('' !== $qv['hour']) && ('' !== $qv['minute']) && ('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { |
|
| 1637 | 1637 | // If year, month, day, hour, minute, and second are set, a single |
| 1638 | 1638 | // post is being queried. |
| 1639 | 1639 | $this->is_single = true; |
| 1640 | - } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) { |
|
| 1640 | + } elseif ('' != $qv['static'] || '' != $qv['pagename'] || ! empty($qv['page_id'])) { |
|
| 1641 | 1641 | $this->is_page = true; |
| 1642 | 1642 | $this->is_single = false; |
| 1643 | 1643 | } else { |
| 1644 | 1644 | // Look for archive queries. Dates, categories, authors, search, post type archives. |
| 1645 | 1645 | |
| 1646 | - if ( isset( $this->query['s'] ) ) { |
|
| 1646 | + if (isset($this->query['s'])) { |
|
| 1647 | 1647 | $this->is_search = true; |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | - if ( '' !== $qv['second'] ) { |
|
| 1650 | + if ('' !== $qv['second']) { |
|
| 1651 | 1651 | $this->is_time = true; |
| 1652 | 1652 | $this->is_date = true; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | - if ( '' !== $qv['minute'] ) { |
|
| 1655 | + if ('' !== $qv['minute']) { |
|
| 1656 | 1656 | $this->is_time = true; |
| 1657 | 1657 | $this->is_date = true; |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - if ( '' !== $qv['hour'] ) { |
|
| 1660 | + if ('' !== $qv['hour']) { |
|
| 1661 | 1661 | $this->is_time = true; |
| 1662 | 1662 | $this->is_date = true; |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | - if ( $qv['day'] ) { |
|
| 1666 | - if ( ! $this->is_date ) { |
|
| 1667 | - $date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] ); |
|
| 1668 | - if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) { |
|
| 1665 | + if ($qv['day']) { |
|
| 1666 | + if ( ! $this->is_date) { |
|
| 1667 | + $date = sprintf('%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day']); |
|
| 1668 | + if ($qv['monthnum'] && $qv['year'] && ! wp_checkdate($qv['monthnum'], $qv['day'], $qv['year'], $date)) { |
|
| 1669 | 1669 | $qv['error'] = '404'; |
| 1670 | 1670 | } else { |
| 1671 | 1671 | $this->is_day = true; |
@@ -1674,9 +1674,9 @@ discard block |
||
| 1674 | 1674 | } |
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | - if ( $qv['monthnum'] ) { |
|
| 1678 | - if ( ! $this->is_date ) { |
|
| 1679 | - if ( 12 < $qv['monthnum'] ) { |
|
| 1677 | + if ($qv['monthnum']) { |
|
| 1678 | + if ( ! $this->is_date) { |
|
| 1679 | + if (12 < $qv['monthnum']) { |
|
| 1680 | 1680 | $qv['error'] = '404'; |
| 1681 | 1681 | } else { |
| 1682 | 1682 | $this->is_month = true; |
@@ -1685,40 +1685,40 @@ discard block |
||
| 1685 | 1685 | } |
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | - if ( $qv['year'] ) { |
|
| 1689 | - if ( ! $this->is_date ) { |
|
| 1688 | + if ($qv['year']) { |
|
| 1689 | + if ( ! $this->is_date) { |
|
| 1690 | 1690 | $this->is_year = true; |
| 1691 | 1691 | $this->is_date = true; |
| 1692 | 1692 | } |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | - if ( $qv['m'] ) { |
|
| 1695 | + if ($qv['m']) { |
|
| 1696 | 1696 | $this->is_date = true; |
| 1697 | - if ( strlen($qv['m']) > 9 ) { |
|
| 1697 | + if (strlen($qv['m']) > 9) { |
|
| 1698 | 1698 | $this->is_time = true; |
| 1699 | - } elseif ( strlen( $qv['m'] ) > 7 ) { |
|
| 1699 | + } elseif (strlen($qv['m']) > 7) { |
|
| 1700 | 1700 | $this->is_day = true; |
| 1701 | - } elseif ( strlen( $qv['m'] ) > 5 ) { |
|
| 1701 | + } elseif (strlen($qv['m']) > 5) { |
|
| 1702 | 1702 | $this->is_month = true; |
| 1703 | 1703 | } else { |
| 1704 | 1704 | $this->is_year = true; |
| 1705 | 1705 | } |
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | - if ( '' != $qv['w'] ) { |
|
| 1708 | + if ('' != $qv['w']) { |
|
| 1709 | 1709 | $this->is_date = true; |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | $this->query_vars_hash = false; |
| 1713 | - $this->parse_tax_query( $qv ); |
|
| 1713 | + $this->parse_tax_query($qv); |
|
| 1714 | 1714 | |
| 1715 | - foreach ( $this->tax_query->queries as $tax_query ) { |
|
| 1716 | - if ( ! is_array( $tax_query ) ) { |
|
| 1715 | + foreach ($this->tax_query->queries as $tax_query) { |
|
| 1716 | + if ( ! is_array($tax_query)) { |
|
| 1717 | 1717 | continue; |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | - if ( isset( $tax_query['operator'] ) && 'NOT IN' != $tax_query['operator'] ) { |
|
| 1721 | - switch ( $tax_query['taxonomy'] ) { |
|
| 1720 | + if (isset($tax_query['operator']) && 'NOT IN' != $tax_query['operator']) { |
|
| 1721 | + switch ($tax_query['taxonomy']) { |
|
| 1722 | 1722 | case 'category': |
| 1723 | 1723 | $this->is_category = true; |
| 1724 | 1724 | break; |
@@ -1730,89 +1730,89 @@ discard block |
||
| 1730 | 1730 | } |
| 1731 | 1731 | } |
| 1732 | 1732 | } |
| 1733 | - unset( $tax_query ); |
|
| 1733 | + unset($tax_query); |
|
| 1734 | 1734 | |
| 1735 | - if ( empty($qv['author']) || ($qv['author'] == '0') ) { |
|
| 1735 | + if (empty($qv['author']) || ($qv['author'] == '0')) { |
|
| 1736 | 1736 | $this->is_author = false; |
| 1737 | 1737 | } else { |
| 1738 | 1738 | $this->is_author = true; |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | - if ( '' != $qv['author_name'] ) |
|
| 1741 | + if ('' != $qv['author_name']) |
|
| 1742 | 1742 | $this->is_author = true; |
| 1743 | 1743 | |
| 1744 | - if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { |
|
| 1745 | - $post_type_obj = get_post_type_object( $qv['post_type'] ); |
|
| 1746 | - if ( ! empty( $post_type_obj->has_archive ) ) |
|
| 1744 | + if ( ! empty($qv['post_type']) && ! is_array($qv['post_type'])) { |
|
| 1745 | + $post_type_obj = get_post_type_object($qv['post_type']); |
|
| 1746 | + if ( ! empty($post_type_obj->has_archive)) |
|
| 1747 | 1747 | $this->is_post_type_archive = true; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | - if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) |
|
| 1750 | + if ($this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) |
|
| 1751 | 1751 | $this->is_archive = true; |
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | - if ( '' != $qv['feed'] ) |
|
| 1754 | + if ('' != $qv['feed']) |
|
| 1755 | 1755 | $this->is_feed = true; |
| 1756 | 1756 | |
| 1757 | - if ( '' != $qv['embed'] ) { |
|
| 1757 | + if ('' != $qv['embed']) { |
|
| 1758 | 1758 | $this->is_embed = true; |
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | - if ( '' != $qv['tb'] ) |
|
| 1761 | + if ('' != $qv['tb']) |
|
| 1762 | 1762 | $this->is_trackback = true; |
| 1763 | 1763 | |
| 1764 | - if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) ) |
|
| 1764 | + if ('' != $qv['paged'] && (intval($qv['paged']) > 1)) |
|
| 1765 | 1765 | $this->is_paged = true; |
| 1766 | 1766 | |
| 1767 | 1767 | // if we're previewing inside the write screen |
| 1768 | - if ( '' != $qv['preview'] ) |
|
| 1768 | + if ('' != $qv['preview']) |
|
| 1769 | 1769 | $this->is_preview = true; |
| 1770 | 1770 | |
| 1771 | - if ( is_admin() ) |
|
| 1771 | + if (is_admin()) |
|
| 1772 | 1772 | $this->is_admin = true; |
| 1773 | 1773 | |
| 1774 | - if ( false !== strpos($qv['feed'], 'comments-') ) { |
|
| 1774 | + if (false !== strpos($qv['feed'], 'comments-')) { |
|
| 1775 | 1775 | $qv['feed'] = str_replace('comments-', '', $qv['feed']); |
| 1776 | 1776 | $qv['withcomments'] = 1; |
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | 1779 | $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; |
| 1780 | 1780 | |
| 1781 | - if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) |
|
| 1781 | + if ($this->is_feed && ( ! empty($qv['withcomments']) || (empty($qv['withoutcomments']) && $this->is_singular))) |
|
| 1782 | 1782 | $this->is_comment_feed = true; |
| 1783 | 1783 | |
| 1784 | - if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) |
|
| 1784 | + if ( ! ($this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || (defined('REST_REQUEST') && REST_REQUEST) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots)) |
|
| 1785 | 1785 | $this->is_home = true; |
| 1786 | 1786 | |
| 1787 | 1787 | // Correct is_* for page_on_front and page_for_posts |
| 1788 | - if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) { |
|
| 1788 | + if ($this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front')) { |
|
| 1789 | 1789 | $_query = wp_parse_args($this->query); |
| 1790 | 1790 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
| 1791 | - if ( isset($_query['pagename']) && '' == $_query['pagename'] ) |
|
| 1791 | + if (isset($_query['pagename']) && '' == $_query['pagename']) |
|
| 1792 | 1792 | unset($_query['pagename']); |
| 1793 | 1793 | |
| 1794 | - unset( $_query['embed'] ); |
|
| 1794 | + unset($_query['embed']); |
|
| 1795 | 1795 | |
| 1796 | - if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) { |
|
| 1796 | + if (empty($_query) || ! array_diff(array_keys($_query), array('preview', 'page', 'paged', 'cpage'))) { |
|
| 1797 | 1797 | $this->is_page = true; |
| 1798 | 1798 | $this->is_home = false; |
| 1799 | 1799 | $qv['page_id'] = get_option('page_on_front'); |
| 1800 | 1800 | // Correct <!--nextpage--> for page_on_front |
| 1801 | - if ( !empty($qv['paged']) ) { |
|
| 1801 | + if ( ! empty($qv['paged'])) { |
|
| 1802 | 1802 | $qv['page'] = $qv['paged']; |
| 1803 | 1803 | unset($qv['paged']); |
| 1804 | 1804 | } |
| 1805 | 1805 | } |
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | - if ( '' != $qv['pagename'] ) { |
|
| 1809 | - $this->queried_object = get_page_by_path( $qv['pagename'] ); |
|
| 1808 | + if ('' != $qv['pagename']) { |
|
| 1809 | + $this->queried_object = get_page_by_path($qv['pagename']); |
|
| 1810 | 1810 | |
| 1811 | - if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) { |
|
| 1812 | - if ( preg_match( "/^[^%]*%(?:postname)%/", get_option( 'permalink_structure' ) ) ) { |
|
| 1811 | + if ($this->queried_object && 'attachment' == $this->queried_object->post_type) { |
|
| 1812 | + if (preg_match("/^[^%]*%(?:postname)%/", get_option('permalink_structure'))) { |
|
| 1813 | 1813 | // See if we also have a post with the same slug |
| 1814 | - $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' ); |
|
| 1815 | - if ( $post ) { |
|
| 1814 | + $post = get_page_by_path($qv['pagename'], OBJECT, 'post'); |
|
| 1815 | + if ($post) { |
|
| 1816 | 1816 | $this->queried_object = $post; |
| 1817 | 1817 | $this->is_page = false; |
| 1818 | 1818 | $this->is_single = true; |
@@ -1820,53 +1820,53 @@ discard block |
||
| 1820 | 1820 | } |
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | - if ( ! empty( $this->queried_object ) ) { |
|
| 1823 | + if ( ! empty($this->queried_object)) { |
|
| 1824 | 1824 | $this->queried_object_id = (int) $this->queried_object->ID; |
| 1825 | 1825 | } else { |
| 1826 | - unset( $this->queried_object ); |
|
| 1826 | + unset($this->queried_object); |
|
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | - if ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) { |
|
| 1829 | + if ('page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts')) { |
|
| 1830 | 1830 | $this->is_page = false; |
| 1831 | 1831 | $this->is_home = true; |
| 1832 | 1832 | $this->is_posts_page = true; |
| 1833 | 1833 | } |
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | - if ( $qv['page_id'] ) { |
|
| 1837 | - if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) { |
|
| 1836 | + if ($qv['page_id']) { |
|
| 1837 | + if ('page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts')) { |
|
| 1838 | 1838 | $this->is_page = false; |
| 1839 | 1839 | $this->is_home = true; |
| 1840 | 1840 | $this->is_posts_page = true; |
| 1841 | 1841 | } |
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | - if ( !empty($qv['post_type']) ) { |
|
| 1845 | - if ( is_array($qv['post_type']) ) |
|
| 1844 | + if ( ! empty($qv['post_type'])) { |
|
| 1845 | + if (is_array($qv['post_type'])) |
|
| 1846 | 1846 | $qv['post_type'] = array_map('sanitize_key', $qv['post_type']); |
| 1847 | 1847 | else |
| 1848 | 1848 | $qv['post_type'] = sanitize_key($qv['post_type']); |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | - if ( ! empty( $qv['post_status'] ) ) { |
|
| 1852 | - if ( is_array( $qv['post_status'] ) ) |
|
| 1851 | + if ( ! empty($qv['post_status'])) { |
|
| 1852 | + if (is_array($qv['post_status'])) |
|
| 1853 | 1853 | $qv['post_status'] = array_map('sanitize_key', $qv['post_status']); |
| 1854 | 1854 | else |
| 1855 | 1855 | $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']); |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | - if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) ) |
|
| 1858 | + if ($this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'])) |
|
| 1859 | 1859 | $this->is_comment_feed = false; |
| 1860 | 1860 | |
| 1861 | 1861 | $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; |
| 1862 | 1862 | // Done correcting is_* for page_on_front and page_for_posts |
| 1863 | 1863 | |
| 1864 | - if ( '404' == $qv['error'] ) |
|
| 1864 | + if ('404' == $qv['error']) |
|
| 1865 | 1865 | $this->set_404(); |
| 1866 | 1866 | |
| 1867 | - $this->is_embed = $this->is_embed && ( $this->is_singular || $this->is_404 ); |
|
| 1867 | + $this->is_embed = $this->is_embed && ($this->is_singular || $this->is_404); |
|
| 1868 | 1868 | |
| 1869 | - $this->query_vars_hash = md5( serialize( $this->query_vars ) ); |
|
| 1869 | + $this->query_vars_hash = md5(serialize($this->query_vars)); |
|
| 1870 | 1870 | $this->query_vars_changed = false; |
| 1871 | 1871 | |
| 1872 | 1872 | /** |
@@ -1876,7 +1876,7 @@ discard block |
||
| 1876 | 1876 | * |
| 1877 | 1877 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 1878 | 1878 | */ |
| 1879 | - do_action_ref_array( 'parse_query', array( &$this ) ); |
|
| 1879 | + do_action_ref_array('parse_query', array(&$this)); |
|
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | /** |
@@ -1889,77 +1889,77 @@ discard block |
||
| 1889 | 1889 | * |
| 1890 | 1890 | * @param array $q The query variables. Passed by reference. |
| 1891 | 1891 | */ |
| 1892 | - public function parse_tax_query( &$q ) { |
|
| 1893 | - if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) { |
|
| 1892 | + public function parse_tax_query(&$q) { |
|
| 1893 | + if ( ! empty($q['tax_query']) && is_array($q['tax_query'])) { |
|
| 1894 | 1894 | $tax_query = $q['tax_query']; |
| 1895 | 1895 | } else { |
| 1896 | 1896 | $tax_query = array(); |
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | - if ( !empty($q['taxonomy']) && !empty($q['term']) ) { |
|
| 1899 | + if ( ! empty($q['taxonomy']) && ! empty($q['term'])) { |
|
| 1900 | 1900 | $tax_query[] = array( |
| 1901 | 1901 | 'taxonomy' => $q['taxonomy'], |
| 1902 | - 'terms' => array( $q['term'] ), |
|
| 1902 | + 'terms' => array($q['term']), |
|
| 1903 | 1903 | 'field' => 'slug', |
| 1904 | 1904 | ); |
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | - foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) { |
|
| 1908 | - if ( 'post_tag' == $taxonomy ) |
|
| 1909 | - continue; // Handled further down in the $q['tag'] block |
|
| 1907 | + foreach (get_taxonomies(array(), 'objects') as $taxonomy => $t) { |
|
| 1908 | + if ('post_tag' == $taxonomy) |
|
| 1909 | + continue; // Handled further down in the $q['tag'] block |
|
| 1910 | 1910 | |
| 1911 | - if ( $t->query_var && !empty( $q[$t->query_var] ) ) { |
|
| 1911 | + if ($t->query_var && ! empty($q[$t->query_var])) { |
|
| 1912 | 1912 | $tax_query_defaults = array( |
| 1913 | 1913 | 'taxonomy' => $taxonomy, |
| 1914 | 1914 | 'field' => 'slug', |
| 1915 | 1915 | ); |
| 1916 | 1916 | |
| 1917 | - if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { |
|
| 1918 | - $q[$t->query_var] = wp_basename( $q[$t->query_var] ); |
|
| 1917 | + if (isset($t->rewrite['hierarchical']) && $t->rewrite['hierarchical']) { |
|
| 1918 | + $q[$t->query_var] = wp_basename($q[$t->query_var]); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | $term = $q[$t->query_var]; |
| 1922 | 1922 | |
| 1923 | - if ( is_array( $term ) ) { |
|
| 1924 | - $term = implode( ',', $term ); |
|
| 1923 | + if (is_array($term)) { |
|
| 1924 | + $term = implode(',', $term); |
|
| 1925 | 1925 | } |
| 1926 | 1926 | |
| 1927 | - if ( strpos($term, '+') !== false ) { |
|
| 1928 | - $terms = preg_split( '/[+]+/', $term ); |
|
| 1929 | - foreach ( $terms as $term ) { |
|
| 1930 | - $tax_query[] = array_merge( $tax_query_defaults, array( |
|
| 1931 | - 'terms' => array( $term ) |
|
| 1932 | - ) ); |
|
| 1927 | + if (strpos($term, '+') !== false) { |
|
| 1928 | + $terms = preg_split('/[+]+/', $term); |
|
| 1929 | + foreach ($terms as $term) { |
|
| 1930 | + $tax_query[] = array_merge($tax_query_defaults, array( |
|
| 1931 | + 'terms' => array($term) |
|
| 1932 | + )); |
|
| 1933 | 1933 | } |
| 1934 | 1934 | } else { |
| 1935 | - $tax_query[] = array_merge( $tax_query_defaults, array( |
|
| 1936 | - 'terms' => preg_split( '/[,]+/', $term ) |
|
| 1937 | - ) ); |
|
| 1935 | + $tax_query[] = array_merge($tax_query_defaults, array( |
|
| 1936 | + 'terms' => preg_split('/[,]+/', $term) |
|
| 1937 | + )); |
|
| 1938 | 1938 | } |
| 1939 | 1939 | } |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | 1942 | // If querystring 'cat' is an array, implode it. |
| 1943 | - if ( is_array( $q['cat'] ) ) { |
|
| 1944 | - $q['cat'] = implode( ',', $q['cat'] ); |
|
| 1943 | + if (is_array($q['cat'])) { |
|
| 1944 | + $q['cat'] = implode(',', $q['cat']); |
|
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | // Category stuff |
| 1948 | - if ( ! empty( $q['cat'] ) && ! $this->is_singular ) { |
|
| 1948 | + if ( ! empty($q['cat']) && ! $this->is_singular) { |
|
| 1949 | 1949 | $cat_in = $cat_not_in = array(); |
| 1950 | 1950 | |
| 1951 | - $cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) ); |
|
| 1952 | - $cat_array = array_map( 'intval', $cat_array ); |
|
| 1953 | - $q['cat'] = implode( ',', $cat_array ); |
|
| 1951 | + $cat_array = preg_split('/[,\s]+/', urldecode($q['cat'])); |
|
| 1952 | + $cat_array = array_map('intval', $cat_array); |
|
| 1953 | + $q['cat'] = implode(',', $cat_array); |
|
| 1954 | 1954 | |
| 1955 | - foreach ( $cat_array as $cat ) { |
|
| 1956 | - if ( $cat > 0 ) |
|
| 1955 | + foreach ($cat_array as $cat) { |
|
| 1956 | + if ($cat > 0) |
|
| 1957 | 1957 | $cat_in[] = $cat; |
| 1958 | - elseif ( $cat < 0 ) |
|
| 1959 | - $cat_not_in[] = abs( $cat ); |
|
| 1958 | + elseif ($cat < 0) |
|
| 1959 | + $cat_not_in[] = abs($cat); |
|
| 1960 | 1960 | } |
| 1961 | 1961 | |
| 1962 | - if ( ! empty( $cat_in ) ) { |
|
| 1962 | + if ( ! empty($cat_in)) { |
|
| 1963 | 1963 | $tax_query[] = array( |
| 1964 | 1964 | 'taxonomy' => 'category', |
| 1965 | 1965 | 'terms' => $cat_in, |
@@ -1968,7 +1968,7 @@ discard block |
||
| 1968 | 1968 | ); |
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | - if ( ! empty( $cat_not_in ) ) { |
|
| 1971 | + if ( ! empty($cat_not_in)) { |
|
| 1972 | 1972 | $tax_query[] = array( |
| 1973 | 1973 | 'taxonomy' => 'category', |
| 1974 | 1974 | 'terms' => $cat_not_in, |
@@ -1977,19 +1977,19 @@ discard block |
||
| 1977 | 1977 | 'include_children' => true |
| 1978 | 1978 | ); |
| 1979 | 1979 | } |
| 1980 | - unset( $cat_array, $cat_in, $cat_not_in ); |
|
| 1980 | + unset($cat_array, $cat_in, $cat_not_in); |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | - if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) { |
|
| 1983 | + if ( ! empty($q['category__and']) && 1 === count((array) $q['category__and'])) { |
|
| 1984 | 1984 | $q['category__and'] = (array) $q['category__and']; |
| 1985 | - if ( ! isset( $q['category__in'] ) ) |
|
| 1985 | + if ( ! isset($q['category__in'])) |
|
| 1986 | 1986 | $q['category__in'] = array(); |
| 1987 | - $q['category__in'][] = absint( reset( $q['category__and'] ) ); |
|
| 1988 | - unset( $q['category__and'] ); |
|
| 1987 | + $q['category__in'][] = absint(reset($q['category__and'])); |
|
| 1988 | + unset($q['category__and']); |
|
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | - if ( ! empty( $q['category__in'] ) ) { |
|
| 1992 | - $q['category__in'] = array_map( 'absint', array_unique( (array) $q['category__in'] ) ); |
|
| 1991 | + if ( ! empty($q['category__in'])) { |
|
| 1992 | + $q['category__in'] = array_map('absint', array_unique((array) $q['category__in'])); |
|
| 1993 | 1993 | $tax_query[] = array( |
| 1994 | 1994 | 'taxonomy' => 'category', |
| 1995 | 1995 | 'terms' => $q['category__in'], |
@@ -1998,8 +1998,8 @@ discard block |
||
| 1998 | 1998 | ); |
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | - if ( ! empty($q['category__not_in']) ) { |
|
| 2002 | - $q['category__not_in'] = array_map( 'absint', array_unique( (array) $q['category__not_in'] ) ); |
|
| 2001 | + if ( ! empty($q['category__not_in'])) { |
|
| 2002 | + $q['category__not_in'] = array_map('absint', array_unique((array) $q['category__not_in'])); |
|
| 2003 | 2003 | $tax_query[] = array( |
| 2004 | 2004 | 'taxonomy' => 'category', |
| 2005 | 2005 | 'terms' => $q['category__not_in'], |
@@ -2008,8 +2008,8 @@ discard block |
||
| 2008 | 2008 | ); |
| 2009 | 2009 | } |
| 2010 | 2010 | |
| 2011 | - if ( ! empty($q['category__and']) ) { |
|
| 2012 | - $q['category__and'] = array_map( 'absint', array_unique( (array) $q['category__and'] ) ); |
|
| 2011 | + if ( ! empty($q['category__and'])) { |
|
| 2012 | + $q['category__and'] = array_map('absint', array_unique((array) $q['category__and'])); |
|
| 2013 | 2013 | $tax_query[] = array( |
| 2014 | 2014 | 'taxonomy' => 'category', |
| 2015 | 2015 | 'terms' => $q['category__and'], |
@@ -2020,21 +2020,21 @@ discard block |
||
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | 2022 | // If querystring 'tag' is array, implode it. |
| 2023 | - if ( is_array( $q['tag'] ) ) { |
|
| 2024 | - $q['tag'] = implode( ',', $q['tag'] ); |
|
| 2023 | + if (is_array($q['tag'])) { |
|
| 2024 | + $q['tag'] = implode(',', $q['tag']); |
|
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | // Tag stuff |
| 2028 | - if ( '' != $q['tag'] && !$this->is_singular && $this->query_vars_changed ) { |
|
| 2029 | - if ( strpos($q['tag'], ',') !== false ) { |
|
| 2028 | + if ('' != $q['tag'] && ! $this->is_singular && $this->query_vars_changed) { |
|
| 2029 | + if (strpos($q['tag'], ',') !== false) { |
|
| 2030 | 2030 | $tags = preg_split('/[,\r\n\t ]+/', $q['tag']); |
| 2031 | - foreach ( (array) $tags as $tag ) { |
|
| 2031 | + foreach ((array) $tags as $tag) { |
|
| 2032 | 2032 | $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); |
| 2033 | 2033 | $q['tag_slug__in'][] = $tag; |
| 2034 | 2034 | } |
| 2035 | - } elseif ( preg_match('/[+\r\n\t ]+/', $q['tag'] ) || ! empty( $q['cat'] ) ) { |
|
| 2035 | + } elseif (preg_match('/[+\r\n\t ]+/', $q['tag']) || ! empty($q['cat'])) { |
|
| 2036 | 2036 | $tags = preg_split('/[+\r\n\t ]+/', $q['tag']); |
| 2037 | - foreach ( (array) $tags as $tag ) { |
|
| 2037 | + foreach ((array) $tags as $tag) { |
|
| 2038 | 2038 | $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db'); |
| 2039 | 2039 | $q['tag_slug__and'][] = $tag; |
| 2040 | 2040 | } |
@@ -2044,24 +2044,24 @@ discard block |
||
| 2044 | 2044 | } |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | - if ( !empty($q['tag_id']) ) { |
|
| 2048 | - $q['tag_id'] = absint( $q['tag_id'] ); |
|
| 2047 | + if ( ! empty($q['tag_id'])) { |
|
| 2048 | + $q['tag_id'] = absint($q['tag_id']); |
|
| 2049 | 2049 | $tax_query[] = array( |
| 2050 | 2050 | 'taxonomy' => 'post_tag', |
| 2051 | 2051 | 'terms' => $q['tag_id'] |
| 2052 | 2052 | ); |
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | - if ( !empty($q['tag__in']) ) { |
|
| 2056 | - $q['tag__in'] = array_map('absint', array_unique( (array) $q['tag__in'] ) ); |
|
| 2055 | + if ( ! empty($q['tag__in'])) { |
|
| 2056 | + $q['tag__in'] = array_map('absint', array_unique((array) $q['tag__in'])); |
|
| 2057 | 2057 | $tax_query[] = array( |
| 2058 | 2058 | 'taxonomy' => 'post_tag', |
| 2059 | 2059 | 'terms' => $q['tag__in'] |
| 2060 | 2060 | ); |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - if ( !empty($q['tag__not_in']) ) { |
|
| 2064 | - $q['tag__not_in'] = array_map('absint', array_unique( (array) $q['tag__not_in'] ) ); |
|
| 2063 | + if ( ! empty($q['tag__not_in'])) { |
|
| 2064 | + $q['tag__not_in'] = array_map('absint', array_unique((array) $q['tag__not_in'])); |
|
| 2065 | 2065 | $tax_query[] = array( |
| 2066 | 2066 | 'taxonomy' => 'post_tag', |
| 2067 | 2067 | 'terms' => $q['tag__not_in'], |
@@ -2069,8 +2069,8 @@ discard block |
||
| 2069 | 2069 | ); |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | - if ( !empty($q['tag__and']) ) { |
|
| 2073 | - $q['tag__and'] = array_map('absint', array_unique( (array) $q['tag__and'] ) ); |
|
| 2072 | + if ( ! empty($q['tag__and'])) { |
|
| 2073 | + $q['tag__and'] = array_map('absint', array_unique((array) $q['tag__and'])); |
|
| 2074 | 2074 | $tax_query[] = array( |
| 2075 | 2075 | 'taxonomy' => 'post_tag', |
| 2076 | 2076 | 'terms' => $q['tag__and'], |
@@ -2078,8 +2078,8 @@ discard block |
||
| 2078 | 2078 | ); |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | - if ( !empty($q['tag_slug__in']) ) { |
|
| 2082 | - $q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__in'] ) ); |
|
| 2081 | + if ( ! empty($q['tag_slug__in'])) { |
|
| 2082 | + $q['tag_slug__in'] = array_map('sanitize_title_for_query', array_unique((array) $q['tag_slug__in'])); |
|
| 2083 | 2083 | $tax_query[] = array( |
| 2084 | 2084 | 'taxonomy' => 'post_tag', |
| 2085 | 2085 | 'terms' => $q['tag_slug__in'], |
@@ -2087,8 +2087,8 @@ discard block |
||
| 2087 | 2087 | ); |
| 2088 | 2088 | } |
| 2089 | 2089 | |
| 2090 | - if ( !empty($q['tag_slug__and']) ) { |
|
| 2091 | - $q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique( (array) $q['tag_slug__and'] ) ); |
|
| 2090 | + if ( ! empty($q['tag_slug__and'])) { |
|
| 2091 | + $q['tag_slug__and'] = array_map('sanitize_title_for_query', array_unique((array) $q['tag_slug__and'])); |
|
| 2092 | 2092 | $tax_query[] = array( |
| 2093 | 2093 | 'taxonomy' => 'post_tag', |
| 2094 | 2094 | 'terms' => $q['tag_slug__and'], |
@@ -2097,7 +2097,7 @@ discard block |
||
| 2097 | 2097 | ); |
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | - $this->tax_query = new WP_Tax_Query( $tax_query ); |
|
| 2100 | + $this->tax_query = new WP_Tax_Query($tax_query); |
|
| 2101 | 2101 | |
| 2102 | 2102 | /** |
| 2103 | 2103 | * Fires after taxonomy-related query vars have been parsed. |
@@ -2106,7 +2106,7 @@ discard block |
||
| 2106 | 2106 | * |
| 2107 | 2107 | * @param WP_Query $this The WP_Query instance. |
| 2108 | 2108 | */ |
| 2109 | - do_action( 'parse_tax_query', $this ); |
|
| 2109 | + do_action('parse_tax_query', $this); |
|
| 2110 | 2110 | } |
| 2111 | 2111 | |
| 2112 | 2112 | /** |
@@ -2119,60 +2119,60 @@ discard block |
||
| 2119 | 2119 | * @param array $q Query variables. |
| 2120 | 2120 | * @return string WHERE clause. |
| 2121 | 2121 | */ |
| 2122 | - protected function parse_search( &$q ) { |
|
| 2122 | + protected function parse_search(&$q) { |
|
| 2123 | 2123 | global $wpdb; |
| 2124 | 2124 | |
| 2125 | 2125 | $search = ''; |
| 2126 | 2126 | |
| 2127 | 2127 | // added slashes screw with quote grouping when done early, so done later |
| 2128 | - $q['s'] = stripslashes( $q['s'] ); |
|
| 2129 | - if ( empty( $_GET['s'] ) && $this->is_main_query() ) |
|
| 2130 | - $q['s'] = urldecode( $q['s'] ); |
|
| 2128 | + $q['s'] = stripslashes($q['s']); |
|
| 2129 | + if (empty($_GET['s']) && $this->is_main_query()) |
|
| 2130 | + $q['s'] = urldecode($q['s']); |
|
| 2131 | 2131 | // there are no line breaks in <input /> fields |
| 2132 | - $q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] ); |
|
| 2132 | + $q['s'] = str_replace(array("\r", "\n"), '', $q['s']); |
|
| 2133 | 2133 | $q['search_terms_count'] = 1; |
| 2134 | - if ( ! empty( $q['sentence'] ) ) { |
|
| 2135 | - $q['search_terms'] = array( $q['s'] ); |
|
| 2134 | + if ( ! empty($q['sentence'])) { |
|
| 2135 | + $q['search_terms'] = array($q['s']); |
|
| 2136 | 2136 | } else { |
| 2137 | - if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches ) ) { |
|
| 2138 | - $q['search_terms_count'] = count( $matches[0] ); |
|
| 2139 | - $q['search_terms'] = $this->parse_search_terms( $matches[0] ); |
|
| 2137 | + if (preg_match_all('/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches)) { |
|
| 2138 | + $q['search_terms_count'] = count($matches[0]); |
|
| 2139 | + $q['search_terms'] = $this->parse_search_terms($matches[0]); |
|
| 2140 | 2140 | // if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence |
| 2141 | - if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 ) |
|
| 2142 | - $q['search_terms'] = array( $q['s'] ); |
|
| 2141 | + if (empty($q['search_terms']) || count($q['search_terms']) > 9) |
|
| 2142 | + $q['search_terms'] = array($q['s']); |
|
| 2143 | 2143 | } else { |
| 2144 | - $q['search_terms'] = array( $q['s'] ); |
|
| 2144 | + $q['search_terms'] = array($q['s']); |
|
| 2145 | 2145 | } |
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | - $n = ! empty( $q['exact'] ) ? '' : '%'; |
|
| 2148 | + $n = ! empty($q['exact']) ? '' : '%'; |
|
| 2149 | 2149 | $searchand = ''; |
| 2150 | 2150 | $q['search_orderby_title'] = array(); |
| 2151 | - foreach ( $q['search_terms'] as $term ) { |
|
| 2151 | + foreach ($q['search_terms'] as $term) { |
|
| 2152 | 2152 | // Terms prefixed with '-' should be excluded. |
| 2153 | - $include = '-' !== substr( $term, 0, 1 ); |
|
| 2154 | - if ( $include ) { |
|
| 2153 | + $include = '-' !== substr($term, 0, 1); |
|
| 2154 | + if ($include) { |
|
| 2155 | 2155 | $like_op = 'LIKE'; |
| 2156 | 2156 | $andor_op = 'OR'; |
| 2157 | 2157 | } else { |
| 2158 | 2158 | $like_op = 'NOT LIKE'; |
| 2159 | 2159 | $andor_op = 'AND'; |
| 2160 | - $term = substr( $term, 1 ); |
|
| 2160 | + $term = substr($term, 1); |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | - if ( $n && $include ) { |
|
| 2164 | - $like = '%' . $wpdb->esc_like( $term ) . '%'; |
|
| 2165 | - $q['search_orderby_title'][] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $like ); |
|
| 2163 | + if ($n && $include) { |
|
| 2164 | + $like = '%'.$wpdb->esc_like($term).'%'; |
|
| 2165 | + $q['search_orderby_title'][] = $wpdb->prepare("$wpdb->posts.post_title LIKE %s", $like); |
|
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | - $like = $n . $wpdb->esc_like( $term ) . $n; |
|
| 2169 | - $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like ); |
|
| 2168 | + $like = $n.$wpdb->esc_like($term).$n; |
|
| 2169 | + $search .= $wpdb->prepare("{$searchand}(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like, $like); |
|
| 2170 | 2170 | $searchand = ' AND '; |
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | - if ( ! empty( $search ) ) { |
|
| 2173 | + if ( ! empty($search)) { |
|
| 2174 | 2174 | $search = " AND ({$search}) "; |
| 2175 | - if ( ! is_user_logged_in() ) |
|
| 2175 | + if ( ! is_user_logged_in()) |
|
| 2176 | 2176 | $search .= " AND ($wpdb->posts.post_password = '') "; |
| 2177 | 2177 | } |
| 2178 | 2178 | |
@@ -2191,24 +2191,24 @@ discard block |
||
| 2191 | 2191 | * @param array $terms Terms to check. |
| 2192 | 2192 | * @return array Terms that are not stopwords. |
| 2193 | 2193 | */ |
| 2194 | - protected function parse_search_terms( $terms ) { |
|
| 2195 | - $strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower'; |
|
| 2194 | + protected function parse_search_terms($terms) { |
|
| 2195 | + $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; |
|
| 2196 | 2196 | $checked = array(); |
| 2197 | 2197 | |
| 2198 | 2198 | $stopwords = $this->get_search_stopwords(); |
| 2199 | 2199 | |
| 2200 | - foreach ( $terms as $term ) { |
|
| 2200 | + foreach ($terms as $term) { |
|
| 2201 | 2201 | // keep before/after spaces when term is for exact match |
| 2202 | - if ( preg_match( '/^".+"$/', $term ) ) |
|
| 2203 | - $term = trim( $term, "\"'" ); |
|
| 2202 | + if (preg_match('/^".+"$/', $term)) |
|
| 2203 | + $term = trim($term, "\"'"); |
|
| 2204 | 2204 | else |
| 2205 | - $term = trim( $term, "\"' " ); |
|
| 2205 | + $term = trim($term, "\"' "); |
|
| 2206 | 2206 | |
| 2207 | 2207 | // Avoid single A-Z and single dashes. |
| 2208 | - if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z\-]$/i', $term ) ) ) |
|
| 2208 | + if ( ! $term || (1 === strlen($term) && preg_match('/^[a-z\-]$/i', $term))) |
|
| 2209 | 2209 | continue; |
| 2210 | 2210 | |
| 2211 | - if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) ) |
|
| 2211 | + if (in_array(call_user_func($strtolower, $term), $stopwords, true)) |
|
| 2212 | 2212 | continue; |
| 2213 | 2213 | |
| 2214 | 2214 | $checked[] = $term; |
@@ -2225,20 +2225,20 @@ discard block |
||
| 2225 | 2225 | * @return array Stopwords. |
| 2226 | 2226 | */ |
| 2227 | 2227 | protected function get_search_stopwords() { |
| 2228 | - if ( isset( $this->stopwords ) ) |
|
| 2228 | + if (isset($this->stopwords)) |
|
| 2229 | 2229 | return $this->stopwords; |
| 2230 | 2230 | |
| 2231 | 2231 | /* translators: This is a comma-separated list of very common words that should be excluded from a search, |
| 2232 | 2232 | * like a, an, and the. These are usually called "stopwords". You should not simply translate these individual |
| 2233 | 2233 | * words into your language. Instead, look for and provide commonly accepted stopwords in your language. |
| 2234 | 2234 | */ |
| 2235 | - $words = explode( ',', _x( 'about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www', |
|
| 2236 | - 'Comma-separated list of search stopwords in your language' ) ); |
|
| 2235 | + $words = explode(',', _x('about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www', |
|
| 2236 | + 'Comma-separated list of search stopwords in your language')); |
|
| 2237 | 2237 | |
| 2238 | 2238 | $stopwords = array(); |
| 2239 | - foreach ( $words as $word ) { |
|
| 2240 | - $word = trim( $word, "\r\n\t " ); |
|
| 2241 | - if ( $word ) |
|
| 2239 | + foreach ($words as $word) { |
|
| 2240 | + $word = trim($word, "\r\n\t "); |
|
| 2241 | + if ($word) |
|
| 2242 | 2242 | $stopwords[] = $word; |
| 2243 | 2243 | } |
| 2244 | 2244 | |
@@ -2249,7 +2249,7 @@ discard block |
||
| 2249 | 2249 | * |
| 2250 | 2250 | * @param array $stopwords Stopwords. |
| 2251 | 2251 | */ |
| 2252 | - $this->stopwords = apply_filters( 'wp_search_stopwords', $stopwords ); |
|
| 2252 | + $this->stopwords = apply_filters('wp_search_stopwords', $stopwords); |
|
| 2253 | 2253 | return $this->stopwords; |
| 2254 | 2254 | } |
| 2255 | 2255 | |
@@ -2261,47 +2261,47 @@ discard block |
||
| 2261 | 2261 | * @param array $q Query variables. |
| 2262 | 2262 | * @return string ORDER BY clause. |
| 2263 | 2263 | */ |
| 2264 | - protected function parse_search_order( &$q ) { |
|
| 2264 | + protected function parse_search_order(&$q) { |
|
| 2265 | 2265 | global $wpdb; |
| 2266 | 2266 | |
| 2267 | - if ( $q['search_terms_count'] > 1 ) { |
|
| 2268 | - $num_terms = count( $q['search_orderby_title'] ); |
|
| 2267 | + if ($q['search_terms_count'] > 1) { |
|
| 2268 | + $num_terms = count($q['search_orderby_title']); |
|
| 2269 | 2269 | |
| 2270 | 2270 | // If the search terms contain negative queries, don't bother ordering by sentence matches. |
| 2271 | 2271 | $like = ''; |
| 2272 | - if ( ! preg_match( '/(?:\s|^)\-/', $q['s'] ) ) { |
|
| 2273 | - $like = '%' . $wpdb->esc_like( $q['s'] ) . '%'; |
|
| 2272 | + if ( ! preg_match('/(?:\s|^)\-/', $q['s'])) { |
|
| 2273 | + $like = '%'.$wpdb->esc_like($q['s']).'%'; |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | $search_orderby = ''; |
| 2277 | 2277 | |
| 2278 | 2278 | // sentence match in 'post_title' |
| 2279 | - if ( $like ) { |
|
| 2280 | - $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_title LIKE %s THEN 1 ", $like ); |
|
| 2279 | + if ($like) { |
|
| 2280 | + $search_orderby .= $wpdb->prepare("WHEN $wpdb->posts.post_title LIKE %s THEN 1 ", $like); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | // sanity limit, sort as sentence when more than 6 terms |
| 2284 | 2284 | // (few searches are longer than 6 terms and most titles are not) |
| 2285 | - if ( $num_terms < 7 ) { |
|
| 2285 | + if ($num_terms < 7) { |
|
| 2286 | 2286 | // all words in title |
| 2287 | - $search_orderby .= 'WHEN ' . implode( ' AND ', $q['search_orderby_title'] ) . ' THEN 2 '; |
|
| 2287 | + $search_orderby .= 'WHEN '.implode(' AND ', $q['search_orderby_title']).' THEN 2 '; |
|
| 2288 | 2288 | // any word in title, not needed when $num_terms == 1 |
| 2289 | - if ( $num_terms > 1 ) |
|
| 2290 | - $search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 '; |
|
| 2289 | + if ($num_terms > 1) |
|
| 2290 | + $search_orderby .= 'WHEN '.implode(' OR ', $q['search_orderby_title']).' THEN 3 '; |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | // Sentence match in 'post_content' and 'post_excerpt'. |
| 2294 | - if ( $like ) { |
|
| 2295 | - $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_excerpt LIKE %s THEN 4 ", $like ); |
|
| 2296 | - $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_content LIKE %s THEN 5 ", $like ); |
|
| 2294 | + if ($like) { |
|
| 2295 | + $search_orderby .= $wpdb->prepare("WHEN $wpdb->posts.post_excerpt LIKE %s THEN 4 ", $like); |
|
| 2296 | + $search_orderby .= $wpdb->prepare("WHEN $wpdb->posts.post_content LIKE %s THEN 5 ", $like); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | - if ( $search_orderby ) { |
|
| 2300 | - $search_orderby = '(CASE ' . $search_orderby . 'ELSE 6 END)'; |
|
| 2299 | + if ($search_orderby) { |
|
| 2300 | + $search_orderby = '(CASE '.$search_orderby.'ELSE 6 END)'; |
|
| 2301 | 2301 | } |
| 2302 | 2302 | } else { |
| 2303 | 2303 | // single word or sentence search |
| 2304 | - $search_orderby = reset( $q['search_orderby_title'] ) . ' DESC'; |
|
| 2304 | + $search_orderby = reset($q['search_orderby_title']).' DESC'; |
|
| 2305 | 2305 | } |
| 2306 | 2306 | |
| 2307 | 2307 | return $search_orderby; |
@@ -2319,7 +2319,7 @@ discard block |
||
| 2319 | 2319 | * @param string $orderby Alias for the field to order by. |
| 2320 | 2320 | * @return string|false Table-prefixed value to used in the ORDER clause. False otherwise. |
| 2321 | 2321 | */ |
| 2322 | - protected function parse_orderby( $orderby ) { |
|
| 2322 | + protected function parse_orderby($orderby) { |
|
| 2323 | 2323 | global $wpdb; |
| 2324 | 2324 | |
| 2325 | 2325 | // Used to filter values. |
@@ -2332,32 +2332,32 @@ discard block |
||
| 2332 | 2332 | $primary_meta_key = ''; |
| 2333 | 2333 | $primary_meta_query = false; |
| 2334 | 2334 | $meta_clauses = $this->meta_query->get_clauses(); |
| 2335 | - if ( ! empty( $meta_clauses ) ) { |
|
| 2336 | - $primary_meta_query = reset( $meta_clauses ); |
|
| 2335 | + if ( ! empty($meta_clauses)) { |
|
| 2336 | + $primary_meta_query = reset($meta_clauses); |
|
| 2337 | 2337 | |
| 2338 | - if ( ! empty( $primary_meta_query['key'] ) ) { |
|
| 2338 | + if ( ! empty($primary_meta_query['key'])) { |
|
| 2339 | 2339 | $primary_meta_key = $primary_meta_query['key']; |
| 2340 | 2340 | $allowed_keys[] = $primary_meta_key; |
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | 2343 | $allowed_keys[] = 'meta_value'; |
| 2344 | 2344 | $allowed_keys[] = 'meta_value_num'; |
| 2345 | - $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_clauses ) ); |
|
| 2345 | + $allowed_keys = array_merge($allowed_keys, array_keys($meta_clauses)); |
|
| 2346 | 2346 | } |
| 2347 | 2347 | |
| 2348 | 2348 | // If RAND() contains a seed value, sanitize and add to allowed keys. |
| 2349 | 2349 | $rand_with_seed = false; |
| 2350 | - if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { |
|
| 2351 | - $orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) ); |
|
| 2350 | + if (preg_match('/RAND\(([0-9]+)\)/i', $orderby, $matches)) { |
|
| 2351 | + $orderby = sprintf('RAND(%s)', intval($matches[1])); |
|
| 2352 | 2352 | $allowed_keys[] = $orderby; |
| 2353 | 2353 | $rand_with_seed = true; |
| 2354 | 2354 | } |
| 2355 | 2355 | |
| 2356 | - if ( ! in_array( $orderby, $allowed_keys, true ) ) { |
|
| 2356 | + if ( ! in_array($orderby, $allowed_keys, true)) { |
|
| 2357 | 2357 | return false; |
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | - switch ( $orderby ) { |
|
| 2360 | + switch ($orderby) { |
|
| 2361 | 2361 | case 'post_name': |
| 2362 | 2362 | case 'post_author': |
| 2363 | 2363 | case 'post_date': |
@@ -2375,7 +2375,7 @@ discard block |
||
| 2375 | 2375 | break; |
| 2376 | 2376 | case $primary_meta_key: |
| 2377 | 2377 | case 'meta_value': |
| 2378 | - if ( ! empty( $primary_meta_query['type'] ) ) { |
|
| 2378 | + if ( ! empty($primary_meta_query['type'])) { |
|
| 2379 | 2379 | $orderby_clause = "CAST({$primary_meta_query['alias']}.meta_value AS {$primary_meta_query['cast']})"; |
| 2380 | 2380 | } else { |
| 2381 | 2381 | $orderby_clause = "{$primary_meta_query['alias']}.meta_value"; |
@@ -2385,15 +2385,15 @@ discard block |
||
| 2385 | 2385 | $orderby_clause = "{$primary_meta_query['alias']}.meta_value+0"; |
| 2386 | 2386 | break; |
| 2387 | 2387 | default: |
| 2388 | - if ( array_key_exists( $orderby, $meta_clauses ) ) { |
|
| 2388 | + if (array_key_exists($orderby, $meta_clauses)) { |
|
| 2389 | 2389 | // $orderby corresponds to a meta_query clause. |
| 2390 | - $meta_clause = $meta_clauses[ $orderby ]; |
|
| 2390 | + $meta_clause = $meta_clauses[$orderby]; |
|
| 2391 | 2391 | $orderby_clause = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; |
| 2392 | - } elseif ( $rand_with_seed ) { |
|
| 2392 | + } elseif ($rand_with_seed) { |
|
| 2393 | 2393 | $orderby_clause = $orderby; |
| 2394 | 2394 | } else { |
| 2395 | 2395 | // Default: order by post field. |
| 2396 | - $orderby_clause = "$wpdb->posts.post_" . sanitize_key( $orderby ); |
|
| 2396 | + $orderby_clause = "$wpdb->posts.post_".sanitize_key($orderby); |
|
| 2397 | 2397 | } |
| 2398 | 2398 | |
| 2399 | 2399 | break; |
@@ -2411,12 +2411,12 @@ discard block |
||
| 2411 | 2411 | * @param string $order The 'order' query variable. |
| 2412 | 2412 | * @return string The sanitized 'order' query variable. |
| 2413 | 2413 | */ |
| 2414 | - protected function parse_order( $order ) { |
|
| 2415 | - if ( ! is_string( $order ) || empty( $order ) ) { |
|
| 2414 | + protected function parse_order($order) { |
|
| 2415 | + if ( ! is_string($order) || empty($order)) { |
|
| 2416 | 2416 | return 'DESC'; |
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | - if ( 'ASC' === strtoupper( $order ) ) { |
|
| 2419 | + if ('ASC' === strtoupper($order)) { |
|
| 2420 | 2420 | return 'ASC'; |
| 2421 | 2421 | } else { |
| 2422 | 2422 | return 'DESC'; |
@@ -2450,9 +2450,9 @@ discard block |
||
| 2450 | 2450 | * @param mixed $default Optional. Value to return if the query variable is not set. Default empty. |
| 2451 | 2451 | * @return mixed Contents of the query variable. |
| 2452 | 2452 | */ |
| 2453 | - public function get( $query_var, $default = '' ) { |
|
| 2454 | - if ( isset( $this->query_vars[ $query_var ] ) ) { |
|
| 2455 | - return $this->query_vars[ $query_var ]; |
|
| 2453 | + public function get($query_var, $default = '') { |
|
| 2454 | + if (isset($this->query_vars[$query_var])) { |
|
| 2455 | + return $this->query_vars[$query_var]; |
|
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | 2458 | return $default; |
@@ -2500,7 +2500,7 @@ discard block |
||
| 2500 | 2500 | * |
| 2501 | 2501 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 2502 | 2502 | */ |
| 2503 | - do_action_ref_array( 'pre_get_posts', array( &$this ) ); |
|
| 2503 | + do_action_ref_array('pre_get_posts', array(&$this)); |
|
| 2504 | 2504 | |
| 2505 | 2505 | // Shorthand. |
| 2506 | 2506 | $q = &$this->query_vars; |
@@ -2510,11 +2510,11 @@ discard block |
||
| 2510 | 2510 | |
| 2511 | 2511 | // Parse meta query |
| 2512 | 2512 | $this->meta_query = new WP_Meta_Query(); |
| 2513 | - $this->meta_query->parse_query_vars( $q ); |
|
| 2513 | + $this->meta_query->parse_query_vars($q); |
|
| 2514 | 2514 | |
| 2515 | 2515 | // Set a flag if a pre_get_posts hook changed the query vars. |
| 2516 | - $hash = md5( serialize( $this->query_vars ) ); |
|
| 2517 | - if ( $hash != $this->query_vars_hash ) { |
|
| 2516 | + $hash = md5(serialize($this->query_vars)); |
|
| 2517 | + if ($hash != $this->query_vars_hash) { |
|
| 2518 | 2518 | $this->query_vars_changed = true; |
| 2519 | 2519 | $this->query_vars_hash = $hash; |
| 2520 | 2520 | } |
@@ -2532,95 +2532,95 @@ discard block |
||
| 2532 | 2532 | $post_status_join = false; |
| 2533 | 2533 | $page = 1; |
| 2534 | 2534 | |
| 2535 | - if ( isset( $q['caller_get_posts'] ) ) { |
|
| 2536 | - _deprecated_argument( 'WP_Query', '3.1.0', __( '"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.' ) ); |
|
| 2537 | - if ( !isset( $q['ignore_sticky_posts'] ) ) |
|
| 2535 | + if (isset($q['caller_get_posts'])) { |
|
| 2536 | + _deprecated_argument('WP_Query', '3.1.0', __('"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.')); |
|
| 2537 | + if ( ! isset($q['ignore_sticky_posts'])) |
|
| 2538 | 2538 | $q['ignore_sticky_posts'] = $q['caller_get_posts']; |
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | - if ( !isset( $q['ignore_sticky_posts'] ) ) |
|
| 2541 | + if ( ! isset($q['ignore_sticky_posts'])) |
|
| 2542 | 2542 | $q['ignore_sticky_posts'] = false; |
| 2543 | 2543 | |
| 2544 | - if ( !isset($q['suppress_filters']) ) |
|
| 2544 | + if ( ! isset($q['suppress_filters'])) |
|
| 2545 | 2545 | $q['suppress_filters'] = false; |
| 2546 | 2546 | |
| 2547 | - if ( !isset($q['cache_results']) ) { |
|
| 2548 | - if ( wp_using_ext_object_cache() ) |
|
| 2547 | + if ( ! isset($q['cache_results'])) { |
|
| 2548 | + if (wp_using_ext_object_cache()) |
|
| 2549 | 2549 | $q['cache_results'] = false; |
| 2550 | 2550 | else |
| 2551 | 2551 | $q['cache_results'] = true; |
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | - if ( !isset($q['update_post_term_cache']) ) |
|
| 2554 | + if ( ! isset($q['update_post_term_cache'])) |
|
| 2555 | 2555 | $q['update_post_term_cache'] = true; |
| 2556 | 2556 | |
| 2557 | - if ( ! isset( $q['lazy_load_term_meta'] ) ) { |
|
| 2557 | + if ( ! isset($q['lazy_load_term_meta'])) { |
|
| 2558 | 2558 | $q['lazy_load_term_meta'] = $q['update_post_term_cache']; |
| 2559 | 2559 | } |
| 2560 | 2560 | |
| 2561 | - if ( !isset($q['update_post_meta_cache']) ) |
|
| 2561 | + if ( ! isset($q['update_post_meta_cache'])) |
|
| 2562 | 2562 | $q['update_post_meta_cache'] = true; |
| 2563 | 2563 | |
| 2564 | - if ( !isset($q['post_type']) ) { |
|
| 2565 | - if ( $this->is_search ) |
|
| 2564 | + if ( ! isset($q['post_type'])) { |
|
| 2565 | + if ($this->is_search) |
|
| 2566 | 2566 | $q['post_type'] = 'any'; |
| 2567 | 2567 | else |
| 2568 | 2568 | $q['post_type'] = ''; |
| 2569 | 2569 | } |
| 2570 | 2570 | $post_type = $q['post_type']; |
| 2571 | - if ( empty( $q['posts_per_page'] ) ) { |
|
| 2572 | - $q['posts_per_page'] = get_option( 'posts_per_page' ); |
|
| 2571 | + if (empty($q['posts_per_page'])) { |
|
| 2572 | + $q['posts_per_page'] = get_option('posts_per_page'); |
|
| 2573 | 2573 | } |
| 2574 | - if ( isset($q['showposts']) && $q['showposts'] ) { |
|
| 2574 | + if (isset($q['showposts']) && $q['showposts']) { |
|
| 2575 | 2575 | $q['showposts'] = (int) $q['showposts']; |
| 2576 | 2576 | $q['posts_per_page'] = $q['showposts']; |
| 2577 | 2577 | } |
| 2578 | - if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) ) |
|
| 2578 | + if ((isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search)) |
|
| 2579 | 2579 | $q['posts_per_page'] = $q['posts_per_archive_page']; |
| 2580 | - if ( !isset($q['nopaging']) ) { |
|
| 2581 | - if ( $q['posts_per_page'] == -1 ) { |
|
| 2580 | + if ( ! isset($q['nopaging'])) { |
|
| 2581 | + if ($q['posts_per_page'] == -1) { |
|
| 2582 | 2582 | $q['nopaging'] = true; |
| 2583 | 2583 | } else { |
| 2584 | 2584 | $q['nopaging'] = false; |
| 2585 | 2585 | } |
| 2586 | 2586 | } |
| 2587 | 2587 | |
| 2588 | - if ( $this->is_feed ) { |
|
| 2588 | + if ($this->is_feed) { |
|
| 2589 | 2589 | // This overrides posts_per_page. |
| 2590 | - if ( ! empty( $q['posts_per_rss'] ) ) { |
|
| 2590 | + if ( ! empty($q['posts_per_rss'])) { |
|
| 2591 | 2591 | $q['posts_per_page'] = $q['posts_per_rss']; |
| 2592 | 2592 | } else { |
| 2593 | - $q['posts_per_page'] = get_option( 'posts_per_rss' ); |
|
| 2593 | + $q['posts_per_page'] = get_option('posts_per_rss'); |
|
| 2594 | 2594 | } |
| 2595 | 2595 | $q['nopaging'] = false; |
| 2596 | 2596 | } |
| 2597 | 2597 | $q['posts_per_page'] = (int) $q['posts_per_page']; |
| 2598 | - if ( $q['posts_per_page'] < -1 ) |
|
| 2598 | + if ($q['posts_per_page'] < -1) |
|
| 2599 | 2599 | $q['posts_per_page'] = abs($q['posts_per_page']); |
| 2600 | - elseif ( $q['posts_per_page'] == 0 ) |
|
| 2600 | + elseif ($q['posts_per_page'] == 0) |
|
| 2601 | 2601 | $q['posts_per_page'] = 1; |
| 2602 | 2602 | |
| 2603 | - if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 ) |
|
| 2603 | + if ( ! isset($q['comments_per_page']) || $q['comments_per_page'] == 0) |
|
| 2604 | 2604 | $q['comments_per_page'] = get_option('comments_per_page'); |
| 2605 | 2605 | |
| 2606 | - if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) { |
|
| 2606 | + if ($this->is_home && (empty($this->query) || $q['preview'] == 'true') && ('page' == get_option('show_on_front')) && get_option('page_on_front')) { |
|
| 2607 | 2607 | $this->is_page = true; |
| 2608 | 2608 | $this->is_home = false; |
| 2609 | 2609 | $q['page_id'] = get_option('page_on_front'); |
| 2610 | 2610 | } |
| 2611 | 2611 | |
| 2612 | - if ( isset($q['page']) ) { |
|
| 2612 | + if (isset($q['page'])) { |
|
| 2613 | 2613 | $q['page'] = trim($q['page'], '/'); |
| 2614 | 2614 | $q['page'] = absint($q['page']); |
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | // If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present. |
| 2618 | - if ( isset($q['no_found_rows']) ) |
|
| 2618 | + if (isset($q['no_found_rows'])) |
|
| 2619 | 2619 | $q['no_found_rows'] = (bool) $q['no_found_rows']; |
| 2620 | 2620 | else |
| 2621 | 2621 | $q['no_found_rows'] = false; |
| 2622 | 2622 | |
| 2623 | - switch ( $q['fields'] ) { |
|
| 2623 | + switch ($q['fields']) { |
|
| 2624 | 2624 | case 'ids': |
| 2625 | 2625 | $fields = "$wpdb->posts.ID"; |
| 2626 | 2626 | break; |
@@ -2631,74 +2631,74 @@ discard block |
||
| 2631 | 2631 | $fields = "$wpdb->posts.*"; |
| 2632 | 2632 | } |
| 2633 | 2633 | |
| 2634 | - if ( '' !== $q['menu_order'] ) |
|
| 2635 | - $where .= " AND $wpdb->posts.menu_order = " . $q['menu_order']; |
|
| 2634 | + if ('' !== $q['menu_order']) |
|
| 2635 | + $where .= " AND $wpdb->posts.menu_order = ".$q['menu_order']; |
|
| 2636 | 2636 | |
| 2637 | 2637 | // The "m" parameter is meant for months but accepts datetimes of varying specificity |
| 2638 | - if ( $q['m'] ) { |
|
| 2639 | - $where .= " AND YEAR($wpdb->posts.post_date)=" . substr($q['m'], 0, 4); |
|
| 2640 | - if ( strlen($q['m']) > 5 ) |
|
| 2641 | - $where .= " AND MONTH($wpdb->posts.post_date)=" . substr($q['m'], 4, 2); |
|
| 2642 | - if ( strlen($q['m']) > 7 ) |
|
| 2643 | - $where .= " AND DAYOFMONTH($wpdb->posts.post_date)=" . substr($q['m'], 6, 2); |
|
| 2644 | - if ( strlen($q['m']) > 9 ) |
|
| 2645 | - $where .= " AND HOUR($wpdb->posts.post_date)=" . substr($q['m'], 8, 2); |
|
| 2646 | - if ( strlen($q['m']) > 11 ) |
|
| 2647 | - $where .= " AND MINUTE($wpdb->posts.post_date)=" . substr($q['m'], 10, 2); |
|
| 2648 | - if ( strlen($q['m']) > 13 ) |
|
| 2649 | - $where .= " AND SECOND($wpdb->posts.post_date)=" . substr($q['m'], 12, 2); |
|
| 2638 | + if ($q['m']) { |
|
| 2639 | + $where .= " AND YEAR($wpdb->posts.post_date)=".substr($q['m'], 0, 4); |
|
| 2640 | + if (strlen($q['m']) > 5) |
|
| 2641 | + $where .= " AND MONTH($wpdb->posts.post_date)=".substr($q['m'], 4, 2); |
|
| 2642 | + if (strlen($q['m']) > 7) |
|
| 2643 | + $where .= " AND DAYOFMONTH($wpdb->posts.post_date)=".substr($q['m'], 6, 2); |
|
| 2644 | + if (strlen($q['m']) > 9) |
|
| 2645 | + $where .= " AND HOUR($wpdb->posts.post_date)=".substr($q['m'], 8, 2); |
|
| 2646 | + if (strlen($q['m']) > 11) |
|
| 2647 | + $where .= " AND MINUTE($wpdb->posts.post_date)=".substr($q['m'], 10, 2); |
|
| 2648 | + if (strlen($q['m']) > 13) |
|
| 2649 | + $where .= " AND SECOND($wpdb->posts.post_date)=".substr($q['m'], 12, 2); |
|
| 2650 | 2650 | } |
| 2651 | 2651 | |
| 2652 | 2652 | // Handle the other individual date parameters |
| 2653 | 2653 | $date_parameters = array(); |
| 2654 | 2654 | |
| 2655 | - if ( '' !== $q['hour'] ) |
|
| 2655 | + if ('' !== $q['hour']) |
|
| 2656 | 2656 | $date_parameters['hour'] = $q['hour']; |
| 2657 | 2657 | |
| 2658 | - if ( '' !== $q['minute'] ) |
|
| 2658 | + if ('' !== $q['minute']) |
|
| 2659 | 2659 | $date_parameters['minute'] = $q['minute']; |
| 2660 | 2660 | |
| 2661 | - if ( '' !== $q['second'] ) |
|
| 2661 | + if ('' !== $q['second']) |
|
| 2662 | 2662 | $date_parameters['second'] = $q['second']; |
| 2663 | 2663 | |
| 2664 | - if ( $q['year'] ) |
|
| 2664 | + if ($q['year']) |
|
| 2665 | 2665 | $date_parameters['year'] = $q['year']; |
| 2666 | 2666 | |
| 2667 | - if ( $q['monthnum'] ) |
|
| 2667 | + if ($q['monthnum']) |
|
| 2668 | 2668 | $date_parameters['monthnum'] = $q['monthnum']; |
| 2669 | 2669 | |
| 2670 | - if ( $q['w'] ) |
|
| 2670 | + if ($q['w']) |
|
| 2671 | 2671 | $date_parameters['week'] = $q['w']; |
| 2672 | 2672 | |
| 2673 | - if ( $q['day'] ) |
|
| 2673 | + if ($q['day']) |
|
| 2674 | 2674 | $date_parameters['day'] = $q['day']; |
| 2675 | 2675 | |
| 2676 | - if ( $date_parameters ) { |
|
| 2677 | - $date_query = new WP_Date_Query( array( $date_parameters ) ); |
|
| 2676 | + if ($date_parameters) { |
|
| 2677 | + $date_query = new WP_Date_Query(array($date_parameters)); |
|
| 2678 | 2678 | $where .= $date_query->get_sql(); |
| 2679 | 2679 | } |
| 2680 | - unset( $date_parameters, $date_query ); |
|
| 2680 | + unset($date_parameters, $date_query); |
|
| 2681 | 2681 | |
| 2682 | 2682 | // Handle complex date queries |
| 2683 | - if ( ! empty( $q['date_query'] ) ) { |
|
| 2684 | - $this->date_query = new WP_Date_Query( $q['date_query'] ); |
|
| 2683 | + if ( ! empty($q['date_query'])) { |
|
| 2684 | + $this->date_query = new WP_Date_Query($q['date_query']); |
|
| 2685 | 2685 | $where .= $this->date_query->get_sql(); |
| 2686 | 2686 | } |
| 2687 | 2687 | |
| 2688 | 2688 | |
| 2689 | 2689 | // If we've got a post_type AND it's not "any" post_type. |
| 2690 | - if ( !empty($q['post_type']) && 'any' != $q['post_type'] ) { |
|
| 2691 | - foreach ( (array)$q['post_type'] as $_post_type ) { |
|
| 2690 | + if ( ! empty($q['post_type']) && 'any' != $q['post_type']) { |
|
| 2691 | + foreach ((array) $q['post_type'] as $_post_type) { |
|
| 2692 | 2692 | $ptype_obj = get_post_type_object($_post_type); |
| 2693 | - if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) ) |
|
| 2693 | + if ( ! $ptype_obj || ! $ptype_obj->query_var || empty($q[$ptype_obj->query_var])) |
|
| 2694 | 2694 | continue; |
| 2695 | 2695 | |
| 2696 | - if ( ! $ptype_obj->hierarchical ) { |
|
| 2696 | + if ( ! $ptype_obj->hierarchical) { |
|
| 2697 | 2697 | // Non-hierarchical post types can directly use 'name'. |
| 2698 | - $q['name'] = $q[ $ptype_obj->query_var ]; |
|
| 2698 | + $q['name'] = $q[$ptype_obj->query_var]; |
|
| 2699 | 2699 | } else { |
| 2700 | 2700 | // Hierarchical post types will operate through 'pagename'. |
| 2701 | - $q['pagename'] = $q[ $ptype_obj->query_var ]; |
|
| 2701 | + $q['pagename'] = $q[$ptype_obj->query_var]; |
|
| 2702 | 2702 | $q['name'] = ''; |
| 2703 | 2703 | } |
| 2704 | 2704 | |
@@ -2708,99 +2708,99 @@ discard block |
||
| 2708 | 2708 | unset($ptype_obj); |
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | - if ( '' !== $q['title'] ) { |
|
| 2712 | - $where .= $wpdb->prepare( " AND $wpdb->posts.post_title = %s", stripslashes( $q['title'] ) ); |
|
| 2711 | + if ('' !== $q['title']) { |
|
| 2712 | + $where .= $wpdb->prepare(" AND $wpdb->posts.post_title = %s", stripslashes($q['title'])); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | // Parameters related to 'post_name'. |
| 2716 | - if ( '' != $q['name'] ) { |
|
| 2717 | - $q['name'] = sanitize_title_for_query( $q['name'] ); |
|
| 2718 | - $where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'"; |
|
| 2719 | - } elseif ( '' != $q['pagename'] ) { |
|
| 2720 | - if ( isset($this->queried_object_id) ) { |
|
| 2716 | + if ('' != $q['name']) { |
|
| 2717 | + $q['name'] = sanitize_title_for_query($q['name']); |
|
| 2718 | + $where .= " AND $wpdb->posts.post_name = '".$q['name']."'"; |
|
| 2719 | + } elseif ('' != $q['pagename']) { |
|
| 2720 | + if (isset($this->queried_object_id)) { |
|
| 2721 | 2721 | $reqpage = $this->queried_object_id; |
| 2722 | 2722 | } else { |
| 2723 | - if ( 'page' != $q['post_type'] ) { |
|
| 2724 | - foreach ( (array)$q['post_type'] as $_post_type ) { |
|
| 2723 | + if ('page' != $q['post_type']) { |
|
| 2724 | + foreach ((array) $q['post_type'] as $_post_type) { |
|
| 2725 | 2725 | $ptype_obj = get_post_type_object($_post_type); |
| 2726 | - if ( !$ptype_obj || !$ptype_obj->hierarchical ) |
|
| 2726 | + if ( ! $ptype_obj || ! $ptype_obj->hierarchical) |
|
| 2727 | 2727 | continue; |
| 2728 | 2728 | |
| 2729 | 2729 | $reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type); |
| 2730 | - if ( $reqpage ) |
|
| 2730 | + if ($reqpage) |
|
| 2731 | 2731 | break; |
| 2732 | 2732 | } |
| 2733 | 2733 | unset($ptype_obj); |
| 2734 | 2734 | } else { |
| 2735 | 2735 | $reqpage = get_page_by_path($q['pagename']); |
| 2736 | 2736 | } |
| 2737 | - if ( !empty($reqpage) ) |
|
| 2737 | + if ( ! empty($reqpage)) |
|
| 2738 | 2738 | $reqpage = $reqpage->ID; |
| 2739 | 2739 | else |
| 2740 | 2740 | $reqpage = 0; |
| 2741 | 2741 | } |
| 2742 | 2742 | |
| 2743 | 2743 | $page_for_posts = get_option('page_for_posts'); |
| 2744 | - if ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) { |
|
| 2745 | - $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); |
|
| 2744 | + if (('page' != get_option('show_on_front')) || empty($page_for_posts) || ($reqpage != $page_for_posts)) { |
|
| 2745 | + $q['pagename'] = sanitize_title_for_query(wp_basename($q['pagename'])); |
|
| 2746 | 2746 | $q['name'] = $q['pagename']; |
| 2747 | 2747 | $where .= " AND ($wpdb->posts.ID = '$reqpage')"; |
| 2748 | - $reqpage_obj = get_post( $reqpage ); |
|
| 2749 | - if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) { |
|
| 2748 | + $reqpage_obj = get_post($reqpage); |
|
| 2749 | + if (is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type) { |
|
| 2750 | 2750 | $this->is_attachment = true; |
| 2751 | 2751 | $post_type = $q['post_type'] = 'attachment'; |
| 2752 | 2752 | $this->is_page = true; |
| 2753 | 2753 | $q['attachment_id'] = $reqpage; |
| 2754 | 2754 | } |
| 2755 | 2755 | } |
| 2756 | - } elseif ( '' != $q['attachment'] ) { |
|
| 2757 | - $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) ); |
|
| 2756 | + } elseif ('' != $q['attachment']) { |
|
| 2757 | + $q['attachment'] = sanitize_title_for_query(wp_basename($q['attachment'])); |
|
| 2758 | 2758 | $q['name'] = $q['attachment']; |
| 2759 | - $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; |
|
| 2760 | - } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) { |
|
| 2761 | - $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] ); |
|
| 2762 | - $post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'"; |
|
| 2759 | + $where .= " AND $wpdb->posts.post_name = '".$q['attachment']."'"; |
|
| 2760 | + } elseif (is_array($q['post_name__in']) && ! empty($q['post_name__in'])) { |
|
| 2761 | + $q['post_name__in'] = array_map('sanitize_title_for_query', $q['post_name__in']); |
|
| 2762 | + $post_name__in = "'".implode("','", $q['post_name__in'])."'"; |
|
| 2763 | 2763 | $where .= " AND $wpdb->posts.post_name IN ($post_name__in)"; |
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | 2766 | // If an attachment is requested by number, let it supersede any post number. |
| 2767 | - if ( $q['attachment_id'] ) |
|
| 2767 | + if ($q['attachment_id']) |
|
| 2768 | 2768 | $q['p'] = absint($q['attachment_id']); |
| 2769 | 2769 | |
| 2770 | 2770 | // If a post number is specified, load that post |
| 2771 | - if ( $q['p'] ) { |
|
| 2772 | - $where .= " AND {$wpdb->posts}.ID = " . $q['p']; |
|
| 2773 | - } elseif ( $q['post__in'] ) { |
|
| 2774 | - $post__in = implode(',', array_map( 'absint', $q['post__in'] )); |
|
| 2771 | + if ($q['p']) { |
|
| 2772 | + $where .= " AND {$wpdb->posts}.ID = ".$q['p']; |
|
| 2773 | + } elseif ($q['post__in']) { |
|
| 2774 | + $post__in = implode(',', array_map('absint', $q['post__in'])); |
|
| 2775 | 2775 | $where .= " AND {$wpdb->posts}.ID IN ($post__in)"; |
| 2776 | - } elseif ( $q['post__not_in'] ) { |
|
| 2777 | - $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] )); |
|
| 2776 | + } elseif ($q['post__not_in']) { |
|
| 2777 | + $post__not_in = implode(',', array_map('absint', $q['post__not_in'])); |
|
| 2778 | 2778 | $where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)"; |
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | - if ( is_numeric( $q['post_parent'] ) ) { |
|
| 2782 | - $where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] ); |
|
| 2783 | - } elseif ( $q['post_parent__in'] ) { |
|
| 2784 | - $post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) ); |
|
| 2781 | + if (is_numeric($q['post_parent'])) { |
|
| 2782 | + $where .= $wpdb->prepare(" AND $wpdb->posts.post_parent = %d ", $q['post_parent']); |
|
| 2783 | + } elseif ($q['post_parent__in']) { |
|
| 2784 | + $post_parent__in = implode(',', array_map('absint', $q['post_parent__in'])); |
|
| 2785 | 2785 | $where .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)"; |
| 2786 | - } elseif ( $q['post_parent__not_in'] ) { |
|
| 2787 | - $post_parent__not_in = implode( ',', array_map( 'absint', $q['post_parent__not_in'] ) ); |
|
| 2786 | + } elseif ($q['post_parent__not_in']) { |
|
| 2787 | + $post_parent__not_in = implode(',', array_map('absint', $q['post_parent__not_in'])); |
|
| 2788 | 2788 | $where .= " AND {$wpdb->posts}.post_parent NOT IN ($post_parent__not_in)"; |
| 2789 | 2789 | } |
| 2790 | 2790 | |
| 2791 | - if ( $q['page_id'] ) { |
|
| 2792 | - if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) { |
|
| 2791 | + if ($q['page_id']) { |
|
| 2792 | + if (('page' != get_option('show_on_front')) || ($q['page_id'] != get_option('page_for_posts'))) { |
|
| 2793 | 2793 | $q['p'] = $q['page_id']; |
| 2794 | - $where = " AND {$wpdb->posts}.ID = " . $q['page_id']; |
|
| 2794 | + $where = " AND {$wpdb->posts}.ID = ".$q['page_id']; |
|
| 2795 | 2795 | } |
| 2796 | 2796 | } |
| 2797 | 2797 | |
| 2798 | 2798 | // If a search pattern is specified, load the posts that match. |
| 2799 | - if ( strlen( $q['s'] ) ) { |
|
| 2800 | - $search = $this->parse_search( $q ); |
|
| 2799 | + if (strlen($q['s'])) { |
|
| 2800 | + $search = $this->parse_search($q); |
|
| 2801 | 2801 | } |
| 2802 | 2802 | |
| 2803 | - if ( ! $q['suppress_filters'] ) { |
|
| 2803 | + if ( ! $q['suppress_filters']) { |
|
| 2804 | 2804 | /** |
| 2805 | 2805 | * Filters the search SQL that is used in the WHERE clause of WP_Query. |
| 2806 | 2806 | * |
@@ -2809,36 +2809,36 @@ discard block |
||
| 2809 | 2809 | * @param string $search Search SQL for WHERE clause. |
| 2810 | 2810 | * @param WP_Query $this The current WP_Query object. |
| 2811 | 2811 | */ |
| 2812 | - $search = apply_filters_ref_array( 'posts_search', array( $search, &$this ) ); |
|
| 2812 | + $search = apply_filters_ref_array('posts_search', array($search, &$this)); |
|
| 2813 | 2813 | } |
| 2814 | 2814 | |
| 2815 | 2815 | // Taxonomies |
| 2816 | - if ( !$this->is_singular ) { |
|
| 2817 | - $this->parse_tax_query( $q ); |
|
| 2816 | + if ( ! $this->is_singular) { |
|
| 2817 | + $this->parse_tax_query($q); |
|
| 2818 | 2818 | |
| 2819 | - $clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' ); |
|
| 2819 | + $clauses = $this->tax_query->get_sql($wpdb->posts, 'ID'); |
|
| 2820 | 2820 | |
| 2821 | 2821 | $join .= $clauses['join']; |
| 2822 | 2822 | $where .= $clauses['where']; |
| 2823 | 2823 | } |
| 2824 | 2824 | |
| 2825 | - if ( $this->is_tax ) { |
|
| 2826 | - if ( empty($post_type) ) { |
|
| 2825 | + if ($this->is_tax) { |
|
| 2826 | + if (empty($post_type)) { |
|
| 2827 | 2827 | // Do a fully inclusive search for currently registered post types of queried taxonomies |
| 2828 | 2828 | $post_type = array(); |
| 2829 | - $taxonomies = array_keys( $this->tax_query->queried_terms ); |
|
| 2830 | - foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) { |
|
| 2831 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt ); |
|
| 2832 | - if ( array_intersect( $taxonomies, $object_taxonomies ) ) |
|
| 2829 | + $taxonomies = array_keys($this->tax_query->queried_terms); |
|
| 2830 | + foreach (get_post_types(array('exclude_from_search' => false)) as $pt) { |
|
| 2831 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
| 2832 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 2833 | 2833 | $post_type[] = $pt; |
| 2834 | 2834 | } |
| 2835 | - if ( ! $post_type ) |
|
| 2835 | + if ( ! $post_type) |
|
| 2836 | 2836 | $post_type = 'any'; |
| 2837 | - elseif ( count( $post_type ) == 1 ) |
|
| 2837 | + elseif (count($post_type) == 1) |
|
| 2838 | 2838 | $post_type = $post_type[0]; |
| 2839 | 2839 | |
| 2840 | 2840 | $post_status_join = true; |
| 2841 | - } elseif ( in_array('attachment', (array) $post_type) ) { |
|
| 2841 | + } elseif (in_array('attachment', (array) $post_type)) { |
|
| 2842 | 2842 | $post_status_join = true; |
| 2843 | 2843 | } |
| 2844 | 2844 | } |
@@ -2847,22 +2847,22 @@ discard block |
||
| 2847 | 2847 | * Ensure that 'taxonomy', 'term', 'term_id', 'cat', and |
| 2848 | 2848 | * 'category_name' vars are set for backward compatibility. |
| 2849 | 2849 | */ |
| 2850 | - if ( ! empty( $this->tax_query->queried_terms ) ) { |
|
| 2850 | + if ( ! empty($this->tax_query->queried_terms)) { |
|
| 2851 | 2851 | |
| 2852 | 2852 | /* |
| 2853 | 2853 | * Set 'taxonomy', 'term', and 'term_id' to the |
| 2854 | 2854 | * first taxonomy other than 'post_tag' or 'category'. |
| 2855 | 2855 | */ |
| 2856 | - if ( ! isset( $q['taxonomy'] ) ) { |
|
| 2857 | - foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) { |
|
| 2858 | - if ( empty( $queried_items['terms'][0] ) ) { |
|
| 2856 | + if ( ! isset($q['taxonomy'])) { |
|
| 2857 | + foreach ($this->tax_query->queried_terms as $queried_taxonomy => $queried_items) { |
|
| 2858 | + if (empty($queried_items['terms'][0])) { |
|
| 2859 | 2859 | continue; |
| 2860 | 2860 | } |
| 2861 | 2861 | |
| 2862 | - if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ) ) ) { |
|
| 2862 | + if ( ! in_array($queried_taxonomy, array('category', 'post_tag'))) { |
|
| 2863 | 2863 | $q['taxonomy'] = $queried_taxonomy; |
| 2864 | 2864 | |
| 2865 | - if ( 'slug' === $queried_items['field'] ) { |
|
| 2865 | + if ('slug' === $queried_items['field']) { |
|
| 2866 | 2866 | $q['term'] = $queried_items['terms'][0]; |
| 2867 | 2867 | } else { |
| 2868 | 2868 | $q['term_id'] = $queried_items['terms'][0]; |
@@ -2875,156 +2875,156 @@ discard block |
||
| 2875 | 2875 | } |
| 2876 | 2876 | |
| 2877 | 2877 | // 'cat', 'category_name', 'tag_id' |
| 2878 | - foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) { |
|
| 2879 | - if ( empty( $queried_items['terms'][0] ) ) { |
|
| 2878 | + foreach ($this->tax_query->queried_terms as $queried_taxonomy => $queried_items) { |
|
| 2879 | + if (empty($queried_items['terms'][0])) { |
|
| 2880 | 2880 | continue; |
| 2881 | 2881 | } |
| 2882 | 2882 | |
| 2883 | - if ( 'category' === $queried_taxonomy ) { |
|
| 2884 | - $the_cat = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'category' ); |
|
| 2885 | - if ( $the_cat ) { |
|
| 2886 | - $this->set( 'cat', $the_cat->term_id ); |
|
| 2887 | - $this->set( 'category_name', $the_cat->slug ); |
|
| 2883 | + if ('category' === $queried_taxonomy) { |
|
| 2884 | + $the_cat = get_term_by($queried_items['field'], $queried_items['terms'][0], 'category'); |
|
| 2885 | + if ($the_cat) { |
|
| 2886 | + $this->set('cat', $the_cat->term_id); |
|
| 2887 | + $this->set('category_name', $the_cat->slug); |
|
| 2888 | 2888 | } |
| 2889 | - unset( $the_cat ); |
|
| 2889 | + unset($the_cat); |
|
| 2890 | 2890 | } |
| 2891 | 2891 | |
| 2892 | - if ( 'post_tag' === $queried_taxonomy ) { |
|
| 2893 | - $the_tag = get_term_by( $queried_items['field'], $queried_items['terms'][0], 'post_tag' ); |
|
| 2894 | - if ( $the_tag ) { |
|
| 2895 | - $this->set( 'tag_id', $the_tag->term_id ); |
|
| 2892 | + if ('post_tag' === $queried_taxonomy) { |
|
| 2893 | + $the_tag = get_term_by($queried_items['field'], $queried_items['terms'][0], 'post_tag'); |
|
| 2894 | + if ($the_tag) { |
|
| 2895 | + $this->set('tag_id', $the_tag->term_id); |
|
| 2896 | 2896 | } |
| 2897 | - unset( $the_tag ); |
|
| 2897 | + unset($the_tag); |
|
| 2898 | 2898 | } |
| 2899 | 2899 | } |
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | - if ( !empty( $this->tax_query->queries ) || !empty( $this->meta_query->queries ) ) { |
|
| 2902 | + if ( ! empty($this->tax_query->queries) || ! empty($this->meta_query->queries)) { |
|
| 2903 | 2903 | $groupby = "{$wpdb->posts}.ID"; |
| 2904 | 2904 | } |
| 2905 | 2905 | |
| 2906 | 2906 | // Author/user stuff |
| 2907 | 2907 | |
| 2908 | - if ( ! empty( $q['author'] ) && $q['author'] != '0' ) { |
|
| 2909 | - $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) ); |
|
| 2910 | - $authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) ); |
|
| 2911 | - foreach ( $authors as $author ) { |
|
| 2908 | + if ( ! empty($q['author']) && $q['author'] != '0') { |
|
| 2909 | + $q['author'] = addslashes_gpc(''.urldecode($q['author'])); |
|
| 2910 | + $authors = array_unique(array_map('intval', preg_split('/[,\s]+/', $q['author']))); |
|
| 2911 | + foreach ($authors as $author) { |
|
| 2912 | 2912 | $key = $author > 0 ? 'author__in' : 'author__not_in'; |
| 2913 | - $q[$key][] = abs( $author ); |
|
| 2913 | + $q[$key][] = abs($author); |
|
| 2914 | 2914 | } |
| 2915 | - $q['author'] = implode( ',', $authors ); |
|
| 2915 | + $q['author'] = implode(',', $authors); |
|
| 2916 | 2916 | } |
| 2917 | 2917 | |
| 2918 | - if ( ! empty( $q['author__not_in'] ) ) { |
|
| 2919 | - $author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) ); |
|
| 2918 | + if ( ! empty($q['author__not_in'])) { |
|
| 2919 | + $author__not_in = implode(',', array_map('absint', array_unique((array) $q['author__not_in']))); |
|
| 2920 | 2920 | $where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) "; |
| 2921 | - } elseif ( ! empty( $q['author__in'] ) ) { |
|
| 2922 | - $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) ); |
|
| 2921 | + } elseif ( ! empty($q['author__in'])) { |
|
| 2922 | + $author__in = implode(',', array_map('absint', array_unique((array) $q['author__in']))); |
|
| 2923 | 2923 | $where .= " AND {$wpdb->posts}.post_author IN ($author__in) "; |
| 2924 | 2924 | } |
| 2925 | 2925 | |
| 2926 | 2926 | // Author stuff for nice URLs |
| 2927 | 2927 | |
| 2928 | - if ( '' != $q['author_name'] ) { |
|
| 2929 | - if ( strpos($q['author_name'], '/') !== false ) { |
|
| 2928 | + if ('' != $q['author_name']) { |
|
| 2929 | + if (strpos($q['author_name'], '/') !== false) { |
|
| 2930 | 2930 | $q['author_name'] = explode('/', $q['author_name']); |
| 2931 | - if ( $q['author_name'][ count($q['author_name'])-1 ] ) { |
|
| 2932 | - $q['author_name'] = $q['author_name'][count($q['author_name'])-1]; // no trailing slash |
|
| 2931 | + if ($q['author_name'][count($q['author_name']) - 1]) { |
|
| 2932 | + $q['author_name'] = $q['author_name'][count($q['author_name']) - 1]; // no trailing slash |
|
| 2933 | 2933 | } else { |
| 2934 | - $q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailing slash |
|
| 2934 | + $q['author_name'] = $q['author_name'][count($q['author_name']) - 2]; // there was a trailing slash |
|
| 2935 | 2935 | } |
| 2936 | 2936 | } |
| 2937 | - $q['author_name'] = sanitize_title_for_query( $q['author_name'] ); |
|
| 2937 | + $q['author_name'] = sanitize_title_for_query($q['author_name']); |
|
| 2938 | 2938 | $q['author'] = get_user_by('slug', $q['author_name']); |
| 2939 | - if ( $q['author'] ) |
|
| 2939 | + if ($q['author']) |
|
| 2940 | 2940 | $q['author'] = $q['author']->ID; |
| 2941 | - $whichauthor .= " AND ($wpdb->posts.post_author = " . absint($q['author']) . ')'; |
|
| 2941 | + $whichauthor .= " AND ($wpdb->posts.post_author = ".absint($q['author']).')'; |
|
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | 2944 | // MIME-Type stuff for attachment browsing |
| 2945 | 2945 | |
| 2946 | - if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) |
|
| 2947 | - $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts ); |
|
| 2946 | + if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) |
|
| 2947 | + $whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $wpdb->posts); |
|
| 2948 | 2948 | |
| 2949 | - $where .= $search . $whichauthor . $whichmimetype; |
|
| 2949 | + $where .= $search.$whichauthor.$whichmimetype; |
|
| 2950 | 2950 | |
| 2951 | - if ( ! empty( $this->meta_query->queries ) ) { |
|
| 2952 | - $clauses = $this->meta_query->get_sql( 'post', $wpdb->posts, 'ID', $this ); |
|
| 2951 | + if ( ! empty($this->meta_query->queries)) { |
|
| 2952 | + $clauses = $this->meta_query->get_sql('post', $wpdb->posts, 'ID', $this); |
|
| 2953 | 2953 | $join .= $clauses['join']; |
| 2954 | 2954 | $where .= $clauses['where']; |
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | - $rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] ); |
|
| 2958 | - if ( ! isset( $q['order'] ) ) { |
|
| 2957 | + $rand = (isset($q['orderby']) && 'rand' === $q['orderby']); |
|
| 2958 | + if ( ! isset($q['order'])) { |
|
| 2959 | 2959 | $q['order'] = $rand ? '' : 'DESC'; |
| 2960 | 2960 | } else { |
| 2961 | - $q['order'] = $rand ? '' : $this->parse_order( $q['order'] ); |
|
| 2961 | + $q['order'] = $rand ? '' : $this->parse_order($q['order']); |
|
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | // Order by. |
| 2965 | - if ( empty( $q['orderby'] ) ) { |
|
| 2965 | + if (empty($q['orderby'])) { |
|
| 2966 | 2966 | /* |
| 2967 | 2967 | * Boolean false or empty array blanks out ORDER BY, |
| 2968 | 2968 | * while leaving the value unset or otherwise empty sets the default. |
| 2969 | 2969 | */ |
| 2970 | - if ( isset( $q['orderby'] ) && ( is_array( $q['orderby'] ) || false === $q['orderby'] ) ) { |
|
| 2970 | + if (isset($q['orderby']) && (is_array($q['orderby']) || false === $q['orderby'])) { |
|
| 2971 | 2971 | $orderby = ''; |
| 2972 | 2972 | } else { |
| 2973 | - $orderby = "$wpdb->posts.post_date " . $q['order']; |
|
| 2973 | + $orderby = "$wpdb->posts.post_date ".$q['order']; |
|
| 2974 | 2974 | } |
| 2975 | - } elseif ( 'none' == $q['orderby'] ) { |
|
| 2975 | + } elseif ('none' == $q['orderby']) { |
|
| 2976 | 2976 | $orderby = ''; |
| 2977 | - } elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) { |
|
| 2977 | + } elseif ($q['orderby'] == 'post__in' && ! empty($post__in)) { |
|
| 2978 | 2978 | $orderby = "FIELD( {$wpdb->posts}.ID, $post__in )"; |
| 2979 | - } elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) { |
|
| 2979 | + } elseif ($q['orderby'] == 'post_parent__in' && ! empty($post_parent__in)) { |
|
| 2980 | 2980 | $orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )"; |
| 2981 | - } elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) { |
|
| 2981 | + } elseif ($q['orderby'] == 'post_name__in' && ! empty($post_name__in)) { |
|
| 2982 | 2982 | $orderby = "FIELD( {$wpdb->posts}.post_name, $post_name__in )"; |
| 2983 | 2983 | } else { |
| 2984 | 2984 | $orderby_array = array(); |
| 2985 | - if ( is_array( $q['orderby'] ) ) { |
|
| 2986 | - foreach ( $q['orderby'] as $_orderby => $order ) { |
|
| 2987 | - $orderby = addslashes_gpc( urldecode( $_orderby ) ); |
|
| 2988 | - $parsed = $this->parse_orderby( $orderby ); |
|
| 2985 | + if (is_array($q['orderby'])) { |
|
| 2986 | + foreach ($q['orderby'] as $_orderby => $order) { |
|
| 2987 | + $orderby = addslashes_gpc(urldecode($_orderby)); |
|
| 2988 | + $parsed = $this->parse_orderby($orderby); |
|
| 2989 | 2989 | |
| 2990 | - if ( ! $parsed ) { |
|
| 2990 | + if ( ! $parsed) { |
|
| 2991 | 2991 | continue; |
| 2992 | 2992 | } |
| 2993 | 2993 | |
| 2994 | - $orderby_array[] = $parsed . ' ' . $this->parse_order( $order ); |
|
| 2994 | + $orderby_array[] = $parsed.' '.$this->parse_order($order); |
|
| 2995 | 2995 | } |
| 2996 | - $orderby = implode( ', ', $orderby_array ); |
|
| 2996 | + $orderby = implode(', ', $orderby_array); |
|
| 2997 | 2997 | |
| 2998 | 2998 | } else { |
| 2999 | - $q['orderby'] = urldecode( $q['orderby'] ); |
|
| 3000 | - $q['orderby'] = addslashes_gpc( $q['orderby'] ); |
|
| 2999 | + $q['orderby'] = urldecode($q['orderby']); |
|
| 3000 | + $q['orderby'] = addslashes_gpc($q['orderby']); |
|
| 3001 | 3001 | |
| 3002 | - foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) { |
|
| 3003 | - $parsed = $this->parse_orderby( $orderby ); |
|
| 3002 | + foreach (explode(' ', $q['orderby']) as $i => $orderby) { |
|
| 3003 | + $parsed = $this->parse_orderby($orderby); |
|
| 3004 | 3004 | // Only allow certain values for safety. |
| 3005 | - if ( ! $parsed ) { |
|
| 3005 | + if ( ! $parsed) { |
|
| 3006 | 3006 | continue; |
| 3007 | 3007 | } |
| 3008 | 3008 | |
| 3009 | 3009 | $orderby_array[] = $parsed; |
| 3010 | 3010 | } |
| 3011 | - $orderby = implode( ' ' . $q['order'] . ', ', $orderby_array ); |
|
| 3011 | + $orderby = implode(' '.$q['order'].', ', $orderby_array); |
|
| 3012 | 3012 | |
| 3013 | - if ( empty( $orderby ) ) { |
|
| 3014 | - $orderby = "$wpdb->posts.post_date " . $q['order']; |
|
| 3015 | - } elseif ( ! empty( $q['order'] ) ) { |
|
| 3013 | + if (empty($orderby)) { |
|
| 3014 | + $orderby = "$wpdb->posts.post_date ".$q['order']; |
|
| 3015 | + } elseif ( ! empty($q['order'])) { |
|
| 3016 | 3016 | $orderby .= " {$q['order']}"; |
| 3017 | 3017 | } |
| 3018 | 3018 | } |
| 3019 | 3019 | } |
| 3020 | 3020 | |
| 3021 | 3021 | // Order search results by relevance only when another "orderby" is not specified in the query. |
| 3022 | - if ( ! empty( $q['s'] ) ) { |
|
| 3022 | + if ( ! empty($q['s'])) { |
|
| 3023 | 3023 | $search_orderby = ''; |
| 3024 | - if ( ! empty( $q['search_orderby_title'] ) && ( empty( $q['orderby'] ) && ! $this->is_feed ) || ( isset( $q['orderby'] ) && 'relevance' === $q['orderby'] ) ) |
|
| 3025 | - $search_orderby = $this->parse_search_order( $q ); |
|
| 3024 | + if ( ! empty($q['search_orderby_title']) && (empty($q['orderby']) && ! $this->is_feed) || (isset($q['orderby']) && 'relevance' === $q['orderby'])) |
|
| 3025 | + $search_orderby = $this->parse_search_order($q); |
|
| 3026 | 3026 | |
| 3027 | - if ( ! $q['suppress_filters'] ) { |
|
| 3027 | + if ( ! $q['suppress_filters']) { |
|
| 3028 | 3028 | /** |
| 3029 | 3029 | * Filters the ORDER BY used when ordering search results. |
| 3030 | 3030 | * |
@@ -3033,94 +3033,94 @@ discard block |
||
| 3033 | 3033 | * @param string $search_orderby The ORDER BY clause. |
| 3034 | 3034 | * @param WP_Query $this The current WP_Query instance. |
| 3035 | 3035 | */ |
| 3036 | - $search_orderby = apply_filters( 'posts_search_orderby', $search_orderby, $this ); |
|
| 3036 | + $search_orderby = apply_filters('posts_search_orderby', $search_orderby, $this); |
|
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | - if ( $search_orderby ) |
|
| 3040 | - $orderby = $orderby ? $search_orderby . ', ' . $orderby : $search_orderby; |
|
| 3039 | + if ($search_orderby) |
|
| 3040 | + $orderby = $orderby ? $search_orderby.', '.$orderby : $search_orderby; |
|
| 3041 | 3041 | } |
| 3042 | 3042 | |
| 3043 | - if ( is_array( $post_type ) && count( $post_type ) > 1 ) { |
|
| 3043 | + if (is_array($post_type) && count($post_type) > 1) { |
|
| 3044 | 3044 | $post_type_cap = 'multiple_post_type'; |
| 3045 | 3045 | } else { |
| 3046 | - if ( is_array( $post_type ) ) |
|
| 3047 | - $post_type = reset( $post_type ); |
|
| 3048 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 3049 | - if ( empty( $post_type_object ) ) |
|
| 3046 | + if (is_array($post_type)) |
|
| 3047 | + $post_type = reset($post_type); |
|
| 3048 | + $post_type_object = get_post_type_object($post_type); |
|
| 3049 | + if (empty($post_type_object)) |
|
| 3050 | 3050 | $post_type_cap = $post_type; |
| 3051 | 3051 | } |
| 3052 | 3052 | |
| 3053 | - if ( isset( $q['post_password'] ) ) { |
|
| 3054 | - $where .= $wpdb->prepare( " AND $wpdb->posts.post_password = %s", $q['post_password'] ); |
|
| 3055 | - if ( empty( $q['perm'] ) ) { |
|
| 3053 | + if (isset($q['post_password'])) { |
|
| 3054 | + $where .= $wpdb->prepare(" AND $wpdb->posts.post_password = %s", $q['post_password']); |
|
| 3055 | + if (empty($q['perm'])) { |
|
| 3056 | 3056 | $q['perm'] = 'readable'; |
| 3057 | 3057 | } |
| 3058 | - } elseif ( isset( $q['has_password'] ) ) { |
|
| 3059 | - $where .= sprintf( " AND $wpdb->posts.post_password %s ''", $q['has_password'] ? '!=' : '=' ); |
|
| 3058 | + } elseif (isset($q['has_password'])) { |
|
| 3059 | + $where .= sprintf(" AND $wpdb->posts.post_password %s ''", $q['has_password'] ? '!=' : '='); |
|
| 3060 | 3060 | } |
| 3061 | 3061 | |
| 3062 | - if ( ! empty( $q['comment_status'] ) ) { |
|
| 3063 | - $where .= $wpdb->prepare( " AND $wpdb->posts.comment_status = %s ", $q['comment_status'] ); |
|
| 3062 | + if ( ! empty($q['comment_status'])) { |
|
| 3063 | + $where .= $wpdb->prepare(" AND $wpdb->posts.comment_status = %s ", $q['comment_status']); |
|
| 3064 | 3064 | } |
| 3065 | 3065 | |
| 3066 | - if ( ! empty( $q['ping_status'] ) ) { |
|
| 3067 | - $where .= $wpdb->prepare( " AND $wpdb->posts.ping_status = %s ", $q['ping_status'] ); |
|
| 3066 | + if ( ! empty($q['ping_status'])) { |
|
| 3067 | + $where .= $wpdb->prepare(" AND $wpdb->posts.ping_status = %s ", $q['ping_status']); |
|
| 3068 | 3068 | } |
| 3069 | 3069 | |
| 3070 | - if ( 'any' == $post_type ) { |
|
| 3071 | - $in_search_post_types = get_post_types( array('exclude_from_search' => false) ); |
|
| 3072 | - if ( empty( $in_search_post_types ) ) |
|
| 3070 | + if ('any' == $post_type) { |
|
| 3071 | + $in_search_post_types = get_post_types(array('exclude_from_search' => false)); |
|
| 3072 | + if (empty($in_search_post_types)) |
|
| 3073 | 3073 | $where .= ' AND 1=0 '; |
| 3074 | 3074 | else |
| 3075 | - $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')"; |
|
| 3076 | - } elseif ( !empty( $post_type ) && is_array( $post_type ) ) { |
|
| 3077 | - $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')"; |
|
| 3078 | - } elseif ( ! empty( $post_type ) ) { |
|
| 3075 | + $where .= " AND $wpdb->posts.post_type IN ('".join("', '", $in_search_post_types)."')"; |
|
| 3076 | + } elseif ( ! empty($post_type) && is_array($post_type)) { |
|
| 3077 | + $where .= " AND $wpdb->posts.post_type IN ('".join("', '", $post_type)."')"; |
|
| 3078 | + } elseif ( ! empty($post_type)) { |
|
| 3079 | 3079 | $where .= " AND $wpdb->posts.post_type = '$post_type'"; |
| 3080 | - $post_type_object = get_post_type_object ( $post_type ); |
|
| 3081 | - } elseif ( $this->is_attachment ) { |
|
| 3080 | + $post_type_object = get_post_type_object($post_type); |
|
| 3081 | + } elseif ($this->is_attachment) { |
|
| 3082 | 3082 | $where .= " AND $wpdb->posts.post_type = 'attachment'"; |
| 3083 | - $post_type_object = get_post_type_object ( 'attachment' ); |
|
| 3084 | - } elseif ( $this->is_page ) { |
|
| 3083 | + $post_type_object = get_post_type_object('attachment'); |
|
| 3084 | + } elseif ($this->is_page) { |
|
| 3085 | 3085 | $where .= " AND $wpdb->posts.post_type = 'page'"; |
| 3086 | - $post_type_object = get_post_type_object ( 'page' ); |
|
| 3086 | + $post_type_object = get_post_type_object('page'); |
|
| 3087 | 3087 | } else { |
| 3088 | 3088 | $where .= " AND $wpdb->posts.post_type = 'post'"; |
| 3089 | - $post_type_object = get_post_type_object ( 'post' ); |
|
| 3089 | + $post_type_object = get_post_type_object('post'); |
|
| 3090 | 3090 | } |
| 3091 | 3091 | |
| 3092 | 3092 | $edit_cap = 'edit_post'; |
| 3093 | 3093 | $read_cap = 'read_post'; |
| 3094 | 3094 | |
| 3095 | - if ( ! empty( $post_type_object ) ) { |
|
| 3095 | + if ( ! empty($post_type_object)) { |
|
| 3096 | 3096 | $edit_others_cap = $post_type_object->cap->edit_others_posts; |
| 3097 | 3097 | $read_private_cap = $post_type_object->cap->read_private_posts; |
| 3098 | 3098 | } else { |
| 3099 | - $edit_others_cap = 'edit_others_' . $post_type_cap . 's'; |
|
| 3100 | - $read_private_cap = 'read_private_' . $post_type_cap . 's'; |
|
| 3099 | + $edit_others_cap = 'edit_others_'.$post_type_cap.'s'; |
|
| 3100 | + $read_private_cap = 'read_private_'.$post_type_cap.'s'; |
|
| 3101 | 3101 | } |
| 3102 | 3102 | |
| 3103 | 3103 | $user_id = get_current_user_id(); |
| 3104 | 3104 | |
| 3105 | 3105 | $q_status = array(); |
| 3106 | - if ( ! empty( $q['post_status'] ) ) { |
|
| 3106 | + if ( ! empty($q['post_status'])) { |
|
| 3107 | 3107 | $statuswheres = array(); |
| 3108 | 3108 | $q_status = $q['post_status']; |
| 3109 | - if ( ! is_array( $q_status ) ) |
|
| 3109 | + if ( ! is_array($q_status)) |
|
| 3110 | 3110 | $q_status = explode(',', $q_status); |
| 3111 | 3111 | $r_status = array(); |
| 3112 | 3112 | $p_status = array(); |
| 3113 | 3113 | $e_status = array(); |
| 3114 | - if ( in_array( 'any', $q_status ) ) { |
|
| 3115 | - foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) { |
|
| 3116 | - if ( ! in_array( $status, $q_status ) ) { |
|
| 3114 | + if (in_array('any', $q_status)) { |
|
| 3115 | + foreach (get_post_stati(array('exclude_from_search' => true)) as $status) { |
|
| 3116 | + if ( ! in_array($status, $q_status)) { |
|
| 3117 | 3117 | $e_status[] = "$wpdb->posts.post_status <> '$status'"; |
| 3118 | 3118 | } |
| 3119 | 3119 | } |
| 3120 | 3120 | } else { |
| 3121 | - foreach ( get_post_stati() as $status ) { |
|
| 3122 | - if ( in_array( $status, $q_status ) ) { |
|
| 3123 | - if ( 'private' == $status ) |
|
| 3121 | + foreach (get_post_stati() as $status) { |
|
| 3122 | + if (in_array($status, $q_status)) { |
|
| 3123 | + if ('private' == $status) |
|
| 3124 | 3124 | $p_status[] = "$wpdb->posts.post_status = '$status'"; |
| 3125 | 3125 | else |
| 3126 | 3126 | $r_status[] = "$wpdb->posts.post_status = '$status'"; |
@@ -3128,58 +3128,58 @@ discard block |
||
| 3128 | 3128 | } |
| 3129 | 3129 | } |
| 3130 | 3130 | |
| 3131 | - if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { |
|
| 3131 | + if (empty($q['perm']) || 'readable' != $q['perm']) { |
|
| 3132 | 3132 | $r_status = array_merge($r_status, $p_status); |
| 3133 | 3133 | unset($p_status); |
| 3134 | 3134 | } |
| 3135 | 3135 | |
| 3136 | - if ( !empty($e_status) ) { |
|
| 3137 | - $statuswheres[] = "(" . join( ' AND ', $e_status ) . ")"; |
|
| 3136 | + if ( ! empty($e_status)) { |
|
| 3137 | + $statuswheres[] = "(".join(' AND ', $e_status).")"; |
|
| 3138 | 3138 | } |
| 3139 | - if ( !empty($r_status) ) { |
|
| 3140 | - if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) ) |
|
| 3141 | - $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))"; |
|
| 3139 | + if ( ! empty($r_status)) { |
|
| 3140 | + if ( ! empty($q['perm']) && 'editable' == $q['perm'] && ! current_user_can($edit_others_cap)) |
|
| 3141 | + $statuswheres[] = "($wpdb->posts.post_author = $user_id "."AND (".join(' OR ', $r_status)."))"; |
|
| 3142 | 3142 | else |
| 3143 | - $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; |
|
| 3143 | + $statuswheres[] = "(".join(' OR ', $r_status).")"; |
|
| 3144 | 3144 | } |
| 3145 | - if ( !empty($p_status) ) { |
|
| 3146 | - if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) |
|
| 3147 | - $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))"; |
|
| 3145 | + if ( ! empty($p_status)) { |
|
| 3146 | + if ( ! empty($q['perm']) && 'readable' == $q['perm'] && ! current_user_can($read_private_cap)) |
|
| 3147 | + $statuswheres[] = "($wpdb->posts.post_author = $user_id "."AND (".join(' OR ', $p_status)."))"; |
|
| 3148 | 3148 | else |
| 3149 | - $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; |
|
| 3149 | + $statuswheres[] = "(".join(' OR ', $p_status).")"; |
|
| 3150 | 3150 | } |
| 3151 | - if ( $post_status_join ) { |
|
| 3151 | + if ($post_status_join) { |
|
| 3152 | 3152 | $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; |
| 3153 | - foreach ( $statuswheres as $index => $statuswhere ) |
|
| 3154 | - $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; |
|
| 3153 | + foreach ($statuswheres as $index => $statuswhere) |
|
| 3154 | + $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND ".str_replace($wpdb->posts, 'p2', $statuswhere)."))"; |
|
| 3155 | 3155 | } |
| 3156 | - $where_status = implode( ' OR ', $statuswheres ); |
|
| 3157 | - if ( ! empty( $where_status ) ) { |
|
| 3156 | + $where_status = implode(' OR ', $statuswheres); |
|
| 3157 | + if ( ! empty($where_status)) { |
|
| 3158 | 3158 | $where .= " AND ($where_status)"; |
| 3159 | 3159 | } |
| 3160 | - } elseif ( !$this->is_singular ) { |
|
| 3160 | + } elseif ( ! $this->is_singular) { |
|
| 3161 | 3161 | $where .= " AND ($wpdb->posts.post_status = 'publish'"; |
| 3162 | 3162 | |
| 3163 | 3163 | // Add public states. |
| 3164 | - $public_states = get_post_stati( array('public' => true) ); |
|
| 3165 | - foreach ( (array) $public_states as $state ) { |
|
| 3166 | - if ( 'publish' == $state ) // Publish is hard-coded above. |
|
| 3164 | + $public_states = get_post_stati(array('public' => true)); |
|
| 3165 | + foreach ((array) $public_states as $state) { |
|
| 3166 | + if ('publish' == $state) // Publish is hard-coded above. |
|
| 3167 | 3167 | continue; |
| 3168 | 3168 | $where .= " OR $wpdb->posts.post_status = '$state'"; |
| 3169 | 3169 | } |
| 3170 | 3170 | |
| 3171 | - if ( $this->is_admin ) { |
|
| 3171 | + if ($this->is_admin) { |
|
| 3172 | 3172 | // Add protected states that should show in the admin all list. |
| 3173 | - $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); |
|
| 3174 | - foreach ( (array) $admin_all_states as $state ) |
|
| 3173 | + $admin_all_states = get_post_stati(array('protected' => true, 'show_in_admin_all_list' => true)); |
|
| 3174 | + foreach ((array) $admin_all_states as $state) |
|
| 3175 | 3175 | $where .= " OR $wpdb->posts.post_status = '$state'"; |
| 3176 | 3176 | } |
| 3177 | 3177 | |
| 3178 | - if ( is_user_logged_in() ) { |
|
| 3178 | + if (is_user_logged_in()) { |
|
| 3179 | 3179 | // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. |
| 3180 | - $private_states = get_post_stati( array('private' => true) ); |
|
| 3181 | - foreach ( (array) $private_states as $state ) |
|
| 3182 | - $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'"; |
|
| 3180 | + $private_states = get_post_stati(array('private' => true)); |
|
| 3181 | + foreach ((array) $private_states as $state) |
|
| 3182 | + $where .= current_user_can($read_private_cap) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'"; |
|
| 3183 | 3183 | } |
| 3184 | 3184 | |
| 3185 | 3185 | $where .= ')'; |
@@ -3189,7 +3189,7 @@ discard block |
||
| 3189 | 3189 | * Apply filters on where and join prior to paging so that any |
| 3190 | 3190 | * manipulations to them are reflected in the paging by day queries. |
| 3191 | 3191 | */ |
| 3192 | - if ( !$q['suppress_filters'] ) { |
|
| 3192 | + if ( ! $q['suppress_filters']) { |
|
| 3193 | 3193 | /** |
| 3194 | 3194 | * Filters the WHERE clause of the query. |
| 3195 | 3195 | * |
@@ -3198,7 +3198,7 @@ discard block |
||
| 3198 | 3198 | * @param string $where The WHERE clause of the query. |
| 3199 | 3199 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3200 | 3200 | */ |
| 3201 | - $where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) ); |
|
| 3201 | + $where = apply_filters_ref_array('posts_where', array($where, &$this)); |
|
| 3202 | 3202 | |
| 3203 | 3203 | /** |
| 3204 | 3204 | * Filters the JOIN clause of the query. |
@@ -3208,28 +3208,28 @@ discard block |
||
| 3208 | 3208 | * @param string $where The JOIN clause of the query. |
| 3209 | 3209 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3210 | 3210 | */ |
| 3211 | - $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) ); |
|
| 3211 | + $join = apply_filters_ref_array('posts_join', array($join, &$this)); |
|
| 3212 | 3212 | } |
| 3213 | 3213 | |
| 3214 | 3214 | // Paging |
| 3215 | - if ( empty($q['nopaging']) && !$this->is_singular ) { |
|
| 3215 | + if (empty($q['nopaging']) && ! $this->is_singular) { |
|
| 3216 | 3216 | $page = absint($q['paged']); |
| 3217 | - if ( !$page ) |
|
| 3217 | + if ( ! $page) |
|
| 3218 | 3218 | $page = 1; |
| 3219 | 3219 | |
| 3220 | 3220 | // If 'offset' is provided, it takes precedence over 'paged'. |
| 3221 | - if ( isset( $q['offset'] ) && is_numeric( $q['offset'] ) ) { |
|
| 3222 | - $q['offset'] = absint( $q['offset'] ); |
|
| 3223 | - $pgstrt = $q['offset'] . ', '; |
|
| 3221 | + if (isset($q['offset']) && is_numeric($q['offset'])) { |
|
| 3222 | + $q['offset'] = absint($q['offset']); |
|
| 3223 | + $pgstrt = $q['offset'].', '; |
|
| 3224 | 3224 | } else { |
| 3225 | - $pgstrt = absint( ( $page - 1 ) * $q['posts_per_page'] ) . ', '; |
|
| 3225 | + $pgstrt = absint(($page - 1) * $q['posts_per_page']).', '; |
|
| 3226 | 3226 | } |
| 3227 | - $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; |
|
| 3227 | + $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; |
|
| 3228 | 3228 | } |
| 3229 | 3229 | |
| 3230 | 3230 | // Comments feeds |
| 3231 | - if ( $this->is_comment_feed && ! $this->is_singular ) { |
|
| 3232 | - if ( $this->is_archive || $this->is_search ) { |
|
| 3231 | + if ($this->is_comment_feed && ! $this->is_singular) { |
|
| 3232 | + if ($this->is_archive || $this->is_search) { |
|
| 3233 | 3233 | $cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; |
| 3234 | 3234 | $cwhere = "WHERE comment_approved = '1' $where"; |
| 3235 | 3235 | $cgroupby = "$wpdb->comments.comment_id"; |
@@ -3239,7 +3239,7 @@ discard block |
||
| 3239 | 3239 | $cgroupby = ''; |
| 3240 | 3240 | } |
| 3241 | 3241 | |
| 3242 | - if ( !$q['suppress_filters'] ) { |
|
| 3242 | + if ( ! $q['suppress_filters']) { |
|
| 3243 | 3243 | /** |
| 3244 | 3244 | * Filters the JOIN clause of the comments feed query before sending. |
| 3245 | 3245 | * |
@@ -3248,7 +3248,7 @@ discard block |
||
| 3248 | 3248 | * @param string $cjoin The JOIN clause of the query. |
| 3249 | 3249 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3250 | 3250 | */ |
| 3251 | - $cjoin = apply_filters_ref_array( 'comment_feed_join', array( $cjoin, &$this ) ); |
|
| 3251 | + $cjoin = apply_filters_ref_array('comment_feed_join', array($cjoin, &$this)); |
|
| 3252 | 3252 | |
| 3253 | 3253 | /** |
| 3254 | 3254 | * Filters the WHERE clause of the comments feed query before sending. |
@@ -3258,7 +3258,7 @@ discard block |
||
| 3258 | 3258 | * @param string $cwhere The WHERE clause of the query. |
| 3259 | 3259 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3260 | 3260 | */ |
| 3261 | - $cwhere = apply_filters_ref_array( 'comment_feed_where', array( $cwhere, &$this ) ); |
|
| 3261 | + $cwhere = apply_filters_ref_array('comment_feed_where', array($cwhere, &$this)); |
|
| 3262 | 3262 | |
| 3263 | 3263 | /** |
| 3264 | 3264 | * Filters the GROUP BY clause of the comments feed query before sending. |
@@ -3268,7 +3268,7 @@ discard block |
||
| 3268 | 3268 | * @param string $cgroupby The GROUP BY clause of the query. |
| 3269 | 3269 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3270 | 3270 | */ |
| 3271 | - $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( $cgroupby, &$this ) ); |
|
| 3271 | + $cgroupby = apply_filters_ref_array('comment_feed_groupby', array($cgroupby, &$this)); |
|
| 3272 | 3272 | |
| 3273 | 3273 | /** |
| 3274 | 3274 | * Filters the ORDER BY clause of the comments feed query before sending. |
@@ -3278,7 +3278,7 @@ discard block |
||
| 3278 | 3278 | * @param string $corderby The ORDER BY clause of the query. |
| 3279 | 3279 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3280 | 3280 | */ |
| 3281 | - $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); |
|
| 3281 | + $corderby = apply_filters_ref_array('comment_feed_orderby', array('comment_date_gmt DESC', &$this)); |
|
| 3282 | 3282 | |
| 3283 | 3283 | /** |
| 3284 | 3284 | * Filters the LIMIT clause of the comments feed query before sending. |
@@ -3288,36 +3288,36 @@ discard block |
||
| 3288 | 3288 | * @param string $climits The JOIN clause of the query. |
| 3289 | 3289 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3290 | 3290 | */ |
| 3291 | - $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); |
|
| 3291 | + $climits = apply_filters_ref_array('comment_feed_limits', array('LIMIT '.get_option('posts_per_rss'), &$this)); |
|
| 3292 | 3292 | } |
| 3293 | - $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; |
|
| 3294 | - $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; |
|
| 3293 | + $cgroupby = ( ! empty($cgroupby)) ? 'GROUP BY '.$cgroupby : ''; |
|
| 3294 | + $corderby = ( ! empty($corderby)) ? 'ORDER BY '.$corderby : ''; |
|
| 3295 | 3295 | |
| 3296 | 3296 | $comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"); |
| 3297 | 3297 | // Convert to WP_Comment |
| 3298 | - $this->comments = array_map( 'get_comment', $comments ); |
|
| 3298 | + $this->comments = array_map('get_comment', $comments); |
|
| 3299 | 3299 | $this->comment_count = count($this->comments); |
| 3300 | 3300 | |
| 3301 | 3301 | $post_ids = array(); |
| 3302 | 3302 | |
| 3303 | - foreach ( $this->comments as $comment ) |
|
| 3303 | + foreach ($this->comments as $comment) |
|
| 3304 | 3304 | $post_ids[] = (int) $comment->comment_post_ID; |
| 3305 | 3305 | |
| 3306 | 3306 | $post_ids = join(',', $post_ids); |
| 3307 | 3307 | $join = ''; |
| 3308 | - if ( $post_ids ) |
|
| 3308 | + if ($post_ids) |
|
| 3309 | 3309 | $where = "AND $wpdb->posts.ID IN ($post_ids) "; |
| 3310 | 3310 | else |
| 3311 | 3311 | $where = "AND 0"; |
| 3312 | 3312 | } |
| 3313 | 3313 | |
| 3314 | - $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); |
|
| 3314 | + $pieces = array('where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits'); |
|
| 3315 | 3315 | |
| 3316 | 3316 | /* |
| 3317 | 3317 | * Apply post-paging filters on where and join. Only plugins that |
| 3318 | 3318 | * manipulate paging queries should use these hooks. |
| 3319 | 3319 | */ |
| 3320 | - if ( !$q['suppress_filters'] ) { |
|
| 3320 | + if ( ! $q['suppress_filters']) { |
|
| 3321 | 3321 | /** |
| 3322 | 3322 | * Filters the WHERE clause of the query. |
| 3323 | 3323 | * |
@@ -3328,7 +3328,7 @@ discard block |
||
| 3328 | 3328 | * @param string $where The WHERE clause of the query. |
| 3329 | 3329 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3330 | 3330 | */ |
| 3331 | - $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); |
|
| 3331 | + $where = apply_filters_ref_array('posts_where_paged', array($where, &$this)); |
|
| 3332 | 3332 | |
| 3333 | 3333 | /** |
| 3334 | 3334 | * Filters the GROUP BY clause of the query. |
@@ -3338,7 +3338,7 @@ discard block |
||
| 3338 | 3338 | * @param string $groupby The GROUP BY clause of the query. |
| 3339 | 3339 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3340 | 3340 | */ |
| 3341 | - $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); |
|
| 3341 | + $groupby = apply_filters_ref_array('posts_groupby', array($groupby, &$this)); |
|
| 3342 | 3342 | |
| 3343 | 3343 | /** |
| 3344 | 3344 | * Filters the JOIN clause of the query. |
@@ -3350,7 +3350,7 @@ discard block |
||
| 3350 | 3350 | * @param string $join The JOIN clause of the query. |
| 3351 | 3351 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3352 | 3352 | */ |
| 3353 | - $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); |
|
| 3353 | + $join = apply_filters_ref_array('posts_join_paged', array($join, &$this)); |
|
| 3354 | 3354 | |
| 3355 | 3355 | /** |
| 3356 | 3356 | * Filters the ORDER BY clause of the query. |
@@ -3360,7 +3360,7 @@ discard block |
||
| 3360 | 3360 | * @param string $orderby The ORDER BY clause of the query. |
| 3361 | 3361 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3362 | 3362 | */ |
| 3363 | - $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
|
| 3363 | + $orderby = apply_filters_ref_array('posts_orderby', array($orderby, &$this)); |
|
| 3364 | 3364 | |
| 3365 | 3365 | /** |
| 3366 | 3366 | * Filters the DISTINCT clause of the query. |
@@ -3370,7 +3370,7 @@ discard block |
||
| 3370 | 3370 | * @param string $distinct The DISTINCT clause of the query. |
| 3371 | 3371 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3372 | 3372 | */ |
| 3373 | - $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); |
|
| 3373 | + $distinct = apply_filters_ref_array('posts_distinct', array($distinct, &$this)); |
|
| 3374 | 3374 | |
| 3375 | 3375 | /** |
| 3376 | 3376 | * Filters the LIMIT clause of the query. |
@@ -3380,7 +3380,7 @@ discard block |
||
| 3380 | 3380 | * @param string $limits The LIMIT clause of the query. |
| 3381 | 3381 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3382 | 3382 | */ |
| 3383 | - $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
|
| 3383 | + $limits = apply_filters_ref_array('post_limits', array($limits, &$this)); |
|
| 3384 | 3384 | |
| 3385 | 3385 | /** |
| 3386 | 3386 | * Filters the SELECT clause of the query. |
@@ -3390,7 +3390,7 @@ discard block |
||
| 3390 | 3390 | * @param string $fields The SELECT clause of the query. |
| 3391 | 3391 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3392 | 3392 | */ |
| 3393 | - $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); |
|
| 3393 | + $fields = apply_filters_ref_array('posts_fields', array($fields, &$this)); |
|
| 3394 | 3394 | |
| 3395 | 3395 | /** |
| 3396 | 3396 | * Filters all query clauses at once, for convenience. |
@@ -3403,15 +3403,15 @@ discard block |
||
| 3403 | 3403 | * @param array $clauses The list of clauses for the query. |
| 3404 | 3404 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3405 | 3405 | */ |
| 3406 | - $clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) ); |
|
| 3407 | - |
|
| 3408 | - $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; |
|
| 3409 | - $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; |
|
| 3410 | - $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; |
|
| 3411 | - $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; |
|
| 3412 | - $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : ''; |
|
| 3413 | - $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; |
|
| 3414 | - $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; |
|
| 3406 | + $clauses = (array) apply_filters_ref_array('posts_clauses', array(compact($pieces), &$this)); |
|
| 3407 | + |
|
| 3408 | + $where = isset($clauses['where']) ? $clauses['where'] : ''; |
|
| 3409 | + $groupby = isset($clauses['groupby']) ? $clauses['groupby'] : ''; |
|
| 3410 | + $join = isset($clauses['join']) ? $clauses['join'] : ''; |
|
| 3411 | + $orderby = isset($clauses['orderby']) ? $clauses['orderby'] : ''; |
|
| 3412 | + $distinct = isset($clauses['distinct']) ? $clauses['distinct'] : ''; |
|
| 3413 | + $fields = isset($clauses['fields']) ? $clauses['fields'] : ''; |
|
| 3414 | + $limits = isset($clauses['limits']) ? $clauses['limits'] : ''; |
|
| 3415 | 3415 | } |
| 3416 | 3416 | |
| 3417 | 3417 | /** |
@@ -3423,13 +3423,13 @@ discard block |
||
| 3423 | 3423 | * |
| 3424 | 3424 | * @param string $selection The assembled selection query. |
| 3425 | 3425 | */ |
| 3426 | - do_action( 'posts_selection', $where . $groupby . $orderby . $limits . $join ); |
|
| 3426 | + do_action('posts_selection', $where.$groupby.$orderby.$limits.$join); |
|
| 3427 | 3427 | |
| 3428 | 3428 | /* |
| 3429 | 3429 | * Filters again for the benefit of caching plugins. |
| 3430 | 3430 | * Regular plugins should use the hooks above. |
| 3431 | 3431 | */ |
| 3432 | - if ( !$q['suppress_filters'] ) { |
|
| 3432 | + if ( ! $q['suppress_filters']) { |
|
| 3433 | 3433 | /** |
| 3434 | 3434 | * Filters the WHERE clause of the query. |
| 3435 | 3435 | * |
@@ -3440,7 +3440,7 @@ discard block |
||
| 3440 | 3440 | * @param string $where The WHERE clause of the query. |
| 3441 | 3441 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3442 | 3442 | */ |
| 3443 | - $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); |
|
| 3443 | + $where = apply_filters_ref_array('posts_where_request', array($where, &$this)); |
|
| 3444 | 3444 | |
| 3445 | 3445 | /** |
| 3446 | 3446 | * Filters the GROUP BY clause of the query. |
@@ -3452,7 +3452,7 @@ discard block |
||
| 3452 | 3452 | * @param string $groupby The GROUP BY clause of the query. |
| 3453 | 3453 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3454 | 3454 | */ |
| 3455 | - $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); |
|
| 3455 | + $groupby = apply_filters_ref_array('posts_groupby_request', array($groupby, &$this)); |
|
| 3456 | 3456 | |
| 3457 | 3457 | /** |
| 3458 | 3458 | * Filters the JOIN clause of the query. |
@@ -3464,7 +3464,7 @@ discard block |
||
| 3464 | 3464 | * @param string $join The JOIN clause of the query. |
| 3465 | 3465 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3466 | 3466 | */ |
| 3467 | - $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); |
|
| 3467 | + $join = apply_filters_ref_array('posts_join_request', array($join, &$this)); |
|
| 3468 | 3468 | |
| 3469 | 3469 | /** |
| 3470 | 3470 | * Filters the ORDER BY clause of the query. |
@@ -3476,7 +3476,7 @@ discard block |
||
| 3476 | 3476 | * @param string $orderby The ORDER BY clause of the query. |
| 3477 | 3477 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3478 | 3478 | */ |
| 3479 | - $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); |
|
| 3479 | + $orderby = apply_filters_ref_array('posts_orderby_request', array($orderby, &$this)); |
|
| 3480 | 3480 | |
| 3481 | 3481 | /** |
| 3482 | 3482 | * Filters the DISTINCT clause of the query. |
@@ -3488,7 +3488,7 @@ discard block |
||
| 3488 | 3488 | * @param string $distinct The DISTINCT clause of the query. |
| 3489 | 3489 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3490 | 3490 | */ |
| 3491 | - $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); |
|
| 3491 | + $distinct = apply_filters_ref_array('posts_distinct_request', array($distinct, &$this)); |
|
| 3492 | 3492 | |
| 3493 | 3493 | /** |
| 3494 | 3494 | * Filters the SELECT clause of the query. |
@@ -3500,7 +3500,7 @@ discard block |
||
| 3500 | 3500 | * @param string $fields The SELECT clause of the query. |
| 3501 | 3501 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3502 | 3502 | */ |
| 3503 | - $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); |
|
| 3503 | + $fields = apply_filters_ref_array('posts_fields_request', array($fields, &$this)); |
|
| 3504 | 3504 | |
| 3505 | 3505 | /** |
| 3506 | 3506 | * Filters the LIMIT clause of the query. |
@@ -3512,7 +3512,7 @@ discard block |
||
| 3512 | 3512 | * @param string $limits The LIMIT clause of the query. |
| 3513 | 3513 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3514 | 3514 | */ |
| 3515 | - $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); |
|
| 3515 | + $limits = apply_filters_ref_array('post_limits_request', array($limits, &$this)); |
|
| 3516 | 3516 | |
| 3517 | 3517 | /** |
| 3518 | 3518 | * Filters all query clauses at once, for convenience. |
@@ -3527,29 +3527,29 @@ discard block |
||
| 3527 | 3527 | * @param array $pieces The pieces of the query. |
| 3528 | 3528 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3529 | 3529 | */ |
| 3530 | - $clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) ); |
|
| 3531 | - |
|
| 3532 | - $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; |
|
| 3533 | - $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; |
|
| 3534 | - $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; |
|
| 3535 | - $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; |
|
| 3536 | - $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : ''; |
|
| 3537 | - $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; |
|
| 3538 | - $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; |
|
| 3530 | + $clauses = (array) apply_filters_ref_array('posts_clauses_request', array(compact($pieces), &$this)); |
|
| 3531 | + |
|
| 3532 | + $where = isset($clauses['where']) ? $clauses['where'] : ''; |
|
| 3533 | + $groupby = isset($clauses['groupby']) ? $clauses['groupby'] : ''; |
|
| 3534 | + $join = isset($clauses['join']) ? $clauses['join'] : ''; |
|
| 3535 | + $orderby = isset($clauses['orderby']) ? $clauses['orderby'] : ''; |
|
| 3536 | + $distinct = isset($clauses['distinct']) ? $clauses['distinct'] : ''; |
|
| 3537 | + $fields = isset($clauses['fields']) ? $clauses['fields'] : ''; |
|
| 3538 | + $limits = isset($clauses['limits']) ? $clauses['limits'] : ''; |
|
| 3539 | 3539 | } |
| 3540 | 3540 | |
| 3541 | - if ( ! empty($groupby) ) |
|
| 3542 | - $groupby = 'GROUP BY ' . $groupby; |
|
| 3543 | - if ( !empty( $orderby ) ) |
|
| 3544 | - $orderby = 'ORDER BY ' . $orderby; |
|
| 3541 | + if ( ! empty($groupby)) |
|
| 3542 | + $groupby = 'GROUP BY '.$groupby; |
|
| 3543 | + if ( ! empty($orderby)) |
|
| 3544 | + $orderby = 'ORDER BY '.$orderby; |
|
| 3545 | 3545 | |
| 3546 | 3546 | $found_rows = ''; |
| 3547 | - if ( !$q['no_found_rows'] && !empty($limits) ) |
|
| 3547 | + if ( ! $q['no_found_rows'] && ! empty($limits)) |
|
| 3548 | 3548 | $found_rows = 'SQL_CALC_FOUND_ROWS'; |
| 3549 | 3549 | |
| 3550 | 3550 | $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
| 3551 | 3551 | |
| 3552 | - if ( !$q['suppress_filters'] ) { |
|
| 3552 | + if ( ! $q['suppress_filters']) { |
|
| 3553 | 3553 | /** |
| 3554 | 3554 | * Filters the completed SQL query before sending. |
| 3555 | 3555 | * |
@@ -3558,7 +3558,7 @@ discard block |
||
| 3558 | 3558 | * @param string $request The complete SQL query. |
| 3559 | 3559 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3560 | 3560 | */ |
| 3561 | - $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) ); |
|
| 3561 | + $this->request = apply_filters_ref_array('posts_request', array($this->request, &$this)); |
|
| 3562 | 3562 | } |
| 3563 | 3563 | |
| 3564 | 3564 | /** |
@@ -3577,41 +3577,41 @@ discard block |
||
| 3577 | 3577 | * or null to allow WP to run its normal queries. |
| 3578 | 3578 | * @param WP_Query $this The WP_Query instance, passed by reference. |
| 3579 | 3579 | */ |
| 3580 | - $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); |
|
| 3580 | + $this->posts = apply_filters_ref_array('posts_pre_query', array(null, &$this)); |
|
| 3581 | 3581 | |
| 3582 | - if ( 'ids' == $q['fields'] ) { |
|
| 3583 | - if ( null === $this->posts ) { |
|
| 3584 | - $this->posts = $wpdb->get_col( $this->request ); |
|
| 3582 | + if ('ids' == $q['fields']) { |
|
| 3583 | + if (null === $this->posts) { |
|
| 3584 | + $this->posts = $wpdb->get_col($this->request); |
|
| 3585 | 3585 | } |
| 3586 | 3586 | |
| 3587 | - $this->posts = array_map( 'intval', $this->posts ); |
|
| 3588 | - $this->post_count = count( $this->posts ); |
|
| 3589 | - $this->set_found_posts( $q, $limits ); |
|
| 3587 | + $this->posts = array_map('intval', $this->posts); |
|
| 3588 | + $this->post_count = count($this->posts); |
|
| 3589 | + $this->set_found_posts($q, $limits); |
|
| 3590 | 3590 | |
| 3591 | 3591 | return $this->posts; |
| 3592 | 3592 | } |
| 3593 | 3593 | |
| 3594 | - if ( 'id=>parent' == $q['fields'] ) { |
|
| 3595 | - if ( null === $this->posts ) { |
|
| 3596 | - $this->posts = $wpdb->get_results( $this->request ); |
|
| 3594 | + if ('id=>parent' == $q['fields']) { |
|
| 3595 | + if (null === $this->posts) { |
|
| 3596 | + $this->posts = $wpdb->get_results($this->request); |
|
| 3597 | 3597 | } |
| 3598 | 3598 | |
| 3599 | - $this->post_count = count( $this->posts ); |
|
| 3600 | - $this->set_found_posts( $q, $limits ); |
|
| 3599 | + $this->post_count = count($this->posts); |
|
| 3600 | + $this->set_found_posts($q, $limits); |
|
| 3601 | 3601 | |
| 3602 | 3602 | $r = array(); |
| 3603 | - foreach ( $this->posts as $key => $post ) { |
|
| 3604 | - $this->posts[ $key ]->ID = (int) $post->ID; |
|
| 3605 | - $this->posts[ $key ]->post_parent = (int) $post->post_parent; |
|
| 3603 | + foreach ($this->posts as $key => $post) { |
|
| 3604 | + $this->posts[$key]->ID = (int) $post->ID; |
|
| 3605 | + $this->posts[$key]->post_parent = (int) $post->post_parent; |
|
| 3606 | 3606 | |
| 3607 | - $r[ (int) $post->ID ] = (int) $post->post_parent; |
|
| 3607 | + $r[(int) $post->ID] = (int) $post->post_parent; |
|
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | 3610 | return $r; |
| 3611 | 3611 | } |
| 3612 | 3612 | |
| 3613 | - if ( null === $this->posts ) { |
|
| 3614 | - $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 ); |
|
| 3613 | + if (null === $this->posts) { |
|
| 3614 | + $split_the_query = ($old_request == $this->request && "$wpdb->posts.*" == $fields && ! empty($limits) && $q['posts_per_page'] < 500); |
|
| 3615 | 3615 | |
| 3616 | 3616 | /** |
| 3617 | 3617 | * Filters whether to split the query. |
@@ -3625,9 +3625,9 @@ discard block |
||
| 3625 | 3625 | * @param bool $split_the_query Whether or not to split the query. |
| 3626 | 3626 | * @param WP_Query $this The WP_Query instance. |
| 3627 | 3627 | */ |
| 3628 | - $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this ); |
|
| 3628 | + $split_the_query = apply_filters('split_the_query', $split_the_query, $this); |
|
| 3629 | 3629 | |
| 3630 | - if ( $split_the_query ) { |
|
| 3630 | + if ($split_the_query) { |
|
| 3631 | 3631 | // First get the IDs and then fill in the objects |
| 3632 | 3632 | |
| 3633 | 3633 | $this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; |
@@ -3640,29 +3640,29 @@ discard block |
||
| 3640 | 3640 | * @param string $request The post ID request. |
| 3641 | 3641 | * @param WP_Query $this The WP_Query instance. |
| 3642 | 3642 | */ |
| 3643 | - $this->request = apply_filters( 'posts_request_ids', $this->request, $this ); |
|
| 3643 | + $this->request = apply_filters('posts_request_ids', $this->request, $this); |
|
| 3644 | 3644 | |
| 3645 | - $ids = $wpdb->get_col( $this->request ); |
|
| 3645 | + $ids = $wpdb->get_col($this->request); |
|
| 3646 | 3646 | |
| 3647 | - if ( $ids ) { |
|
| 3647 | + if ($ids) { |
|
| 3648 | 3648 | $this->posts = $ids; |
| 3649 | - $this->set_found_posts( $q, $limits ); |
|
| 3650 | - _prime_post_caches( $ids, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); |
|
| 3649 | + $this->set_found_posts($q, $limits); |
|
| 3650 | + _prime_post_caches($ids, $q['update_post_term_cache'], $q['update_post_meta_cache']); |
|
| 3651 | 3651 | } else { |
| 3652 | 3652 | $this->posts = array(); |
| 3653 | 3653 | } |
| 3654 | 3654 | } else { |
| 3655 | - $this->posts = $wpdb->get_results( $this->request ); |
|
| 3656 | - $this->set_found_posts( $q, $limits ); |
|
| 3655 | + $this->posts = $wpdb->get_results($this->request); |
|
| 3656 | + $this->set_found_posts($q, $limits); |
|
| 3657 | 3657 | } |
| 3658 | 3658 | } |
| 3659 | 3659 | |
| 3660 | 3660 | // Convert to WP_Post objects. |
| 3661 | - if ( $this->posts ) { |
|
| 3662 | - $this->posts = array_map( 'get_post', $this->posts ); |
|
| 3661 | + if ($this->posts) { |
|
| 3662 | + $this->posts = array_map('get_post', $this->posts); |
|
| 3663 | 3663 | } |
| 3664 | 3664 | |
| 3665 | - if ( ! $q['suppress_filters'] ) { |
|
| 3665 | + if ( ! $q['suppress_filters']) { |
|
| 3666 | 3666 | /** |
| 3667 | 3667 | * Filters the raw post results array, prior to status checks. |
| 3668 | 3668 | * |
@@ -3671,38 +3671,38 @@ discard block |
||
| 3671 | 3671 | * @param array $posts The post results array. |
| 3672 | 3672 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3673 | 3673 | */ |
| 3674 | - $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) ); |
|
| 3674 | + $this->posts = apply_filters_ref_array('posts_results', array($this->posts, &$this)); |
|
| 3675 | 3675 | } |
| 3676 | 3676 | |
| 3677 | - if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { |
|
| 3677 | + if ( ! empty($this->posts) && $this->is_comment_feed && $this->is_singular) { |
|
| 3678 | 3678 | /** This filter is documented in wp-includes/query.php */ |
| 3679 | - $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) ); |
|
| 3679 | + $cjoin = apply_filters_ref_array('comment_feed_join', array('', &$this)); |
|
| 3680 | 3680 | |
| 3681 | 3681 | /** This filter is documented in wp-includes/query.php */ |
| 3682 | - $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) ); |
|
| 3682 | + $cwhere = apply_filters_ref_array('comment_feed_where', array("WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this)); |
|
| 3683 | 3683 | |
| 3684 | 3684 | /** This filter is documented in wp-includes/query.php */ |
| 3685 | - $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) ); |
|
| 3686 | - $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; |
|
| 3685 | + $cgroupby = apply_filters_ref_array('comment_feed_groupby', array('', &$this)); |
|
| 3686 | + $cgroupby = ( ! empty($cgroupby)) ? 'GROUP BY '.$cgroupby : ''; |
|
| 3687 | 3687 | |
| 3688 | 3688 | /** This filter is documented in wp-includes/query.php */ |
| 3689 | - $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); |
|
| 3690 | - $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; |
|
| 3689 | + $corderby = apply_filters_ref_array('comment_feed_orderby', array('comment_date_gmt DESC', &$this)); |
|
| 3690 | + $corderby = ( ! empty($corderby)) ? 'ORDER BY '.$corderby : ''; |
|
| 3691 | 3691 | |
| 3692 | 3692 | /** This filter is documented in wp-includes/query.php */ |
| 3693 | - $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); |
|
| 3693 | + $climits = apply_filters_ref_array('comment_feed_limits', array('LIMIT '.get_option('posts_per_rss'), &$this)); |
|
| 3694 | 3694 | |
| 3695 | 3695 | $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; |
| 3696 | 3696 | $comments = $wpdb->get_results($comments_request); |
| 3697 | 3697 | // Convert to WP_Comment |
| 3698 | - $this->comments = array_map( 'get_comment', $comments ); |
|
| 3698 | + $this->comments = array_map('get_comment', $comments); |
|
| 3699 | 3699 | $this->comment_count = count($this->comments); |
| 3700 | 3700 | } |
| 3701 | 3701 | |
| 3702 | 3702 | // Check post status to determine if post should be displayed. |
| 3703 | - if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { |
|
| 3703 | + if ( ! empty($this->posts) && ($this->is_single || $this->is_page)) { |
|
| 3704 | 3704 | $status = get_post_status($this->posts[0]); |
| 3705 | - if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) { |
|
| 3705 | + if ('attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent) { |
|
| 3706 | 3706 | $this->is_page = false; |
| 3707 | 3707 | $this->is_single = true; |
| 3708 | 3708 | $this->is_attachment = true; |
@@ -3710,23 +3710,23 @@ discard block |
||
| 3710 | 3710 | $post_status_obj = get_post_status_object($status); |
| 3711 | 3711 | |
| 3712 | 3712 | // If the post_status was specifically requested, let it pass through. |
| 3713 | - if ( !$post_status_obj->public && ! in_array( $status, $q_status ) ) { |
|
| 3713 | + if ( ! $post_status_obj->public && ! in_array($status, $q_status)) { |
|
| 3714 | 3714 | |
| 3715 | - if ( ! is_user_logged_in() ) { |
|
| 3715 | + if ( ! is_user_logged_in()) { |
|
| 3716 | 3716 | // User must be logged in to view unpublished posts. |
| 3717 | 3717 | $this->posts = array(); |
| 3718 | 3718 | } else { |
| 3719 | - if ( $post_status_obj->protected ) { |
|
| 3719 | + if ($post_status_obj->protected) { |
|
| 3720 | 3720 | // User must have edit permissions on the draft to preview. |
| 3721 | - if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) { |
|
| 3721 | + if ( ! current_user_can($edit_cap, $this->posts[0]->ID)) { |
|
| 3722 | 3722 | $this->posts = array(); |
| 3723 | 3723 | } else { |
| 3724 | 3724 | $this->is_preview = true; |
| 3725 | - if ( 'future' != $status ) |
|
| 3725 | + if ('future' != $status) |
|
| 3726 | 3726 | $this->posts[0]->post_date = current_time('mysql'); |
| 3727 | 3727 | } |
| 3728 | - } elseif ( $post_status_obj->private ) { |
|
| 3729 | - if ( ! current_user_can($read_cap, $this->posts[0]->ID) ) |
|
| 3728 | + } elseif ($post_status_obj->private) { |
|
| 3729 | + if ( ! current_user_can($read_cap, $this->posts[0]->ID)) |
|
| 3730 | 3730 | $this->posts = array(); |
| 3731 | 3731 | } else { |
| 3732 | 3732 | $this->posts = array(); |
@@ -3734,7 +3734,7 @@ discard block |
||
| 3734 | 3734 | } |
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | - if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) ) { |
|
| 3737 | + if ($this->is_preview && $this->posts && current_user_can($edit_cap, $this->posts[0]->ID)) { |
|
| 3738 | 3738 | /** |
| 3739 | 3739 | * Filters the single post for preview mode. |
| 3740 | 3740 | * |
@@ -3743,18 +3743,18 @@ discard block |
||
| 3743 | 3743 | * @param WP_Post $post_preview The Post object. |
| 3744 | 3744 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3745 | 3745 | */ |
| 3746 | - $this->posts[0] = get_post( apply_filters_ref_array( 'the_preview', array( $this->posts[0], &$this ) ) ); |
|
| 3746 | + $this->posts[0] = get_post(apply_filters_ref_array('the_preview', array($this->posts[0], &$this))); |
|
| 3747 | 3747 | } |
| 3748 | 3748 | } |
| 3749 | 3749 | |
| 3750 | 3750 | // Put sticky posts at the top of the posts array |
| 3751 | 3751 | $sticky_posts = get_option('sticky_posts'); |
| 3752 | - if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) { |
|
| 3752 | + if ($this->is_home && $page <= 1 && is_array($sticky_posts) && ! empty($sticky_posts) && ! $q['ignore_sticky_posts']) { |
|
| 3753 | 3753 | $num_posts = count($this->posts); |
| 3754 | 3754 | $sticky_offset = 0; |
| 3755 | 3755 | // Loop over posts and relocate stickies to the front. |
| 3756 | - for ( $i = 0; $i < $num_posts; $i++ ) { |
|
| 3757 | - if ( in_array($this->posts[$i]->ID, $sticky_posts) ) { |
|
| 3756 | + for ($i = 0; $i < $num_posts; $i++) { |
|
| 3757 | + if (in_array($this->posts[$i]->ID, $sticky_posts)) { |
|
| 3758 | 3758 | $sticky_post = $this->posts[$i]; |
| 3759 | 3759 | // Remove sticky from current position |
| 3760 | 3760 | array_splice($this->posts, $i, 1); |
@@ -3764,36 +3764,36 @@ discard block |
||
| 3764 | 3764 | $sticky_offset++; |
| 3765 | 3765 | // Remove post from sticky posts array |
| 3766 | 3766 | $offset = array_search($sticky_post->ID, $sticky_posts); |
| 3767 | - unset( $sticky_posts[$offset] ); |
|
| 3767 | + unset($sticky_posts[$offset]); |
|
| 3768 | 3768 | } |
| 3769 | 3769 | } |
| 3770 | 3770 | |
| 3771 | 3771 | // If any posts have been excluded specifically, Ignore those that are sticky. |
| 3772 | - if ( !empty($sticky_posts) && !empty($q['post__not_in']) ) |
|
| 3772 | + if ( ! empty($sticky_posts) && ! empty($q['post__not_in'])) |
|
| 3773 | 3773 | $sticky_posts = array_diff($sticky_posts, $q['post__not_in']); |
| 3774 | 3774 | |
| 3775 | 3775 | // Fetch sticky posts that weren't in the query results |
| 3776 | - if ( !empty($sticky_posts) ) { |
|
| 3777 | - $stickies = get_posts( array( |
|
| 3776 | + if ( ! empty($sticky_posts)) { |
|
| 3777 | + $stickies = get_posts(array( |
|
| 3778 | 3778 | 'post__in' => $sticky_posts, |
| 3779 | 3779 | 'post_type' => $post_type, |
| 3780 | 3780 | 'post_status' => 'publish', |
| 3781 | 3781 | 'nopaging' => true |
| 3782 | - ) ); |
|
| 3782 | + )); |
|
| 3783 | 3783 | |
| 3784 | - foreach ( $stickies as $sticky_post ) { |
|
| 3785 | - array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); |
|
| 3784 | + foreach ($stickies as $sticky_post) { |
|
| 3785 | + array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); |
|
| 3786 | 3786 | $sticky_offset++; |
| 3787 | 3787 | } |
| 3788 | 3788 | } |
| 3789 | 3789 | } |
| 3790 | 3790 | |
| 3791 | 3791 | // If comments have been fetched as part of the query, make sure comment meta lazy-loading is set up. |
| 3792 | - if ( ! empty( $this->comments ) ) { |
|
| 3793 | - wp_queue_comments_for_comment_meta_lazyload( $this->comments ); |
|
| 3792 | + if ( ! empty($this->comments)) { |
|
| 3793 | + wp_queue_comments_for_comment_meta_lazyload($this->comments); |
|
| 3794 | 3794 | } |
| 3795 | 3795 | |
| 3796 | - if ( ! $q['suppress_filters'] ) { |
|
| 3796 | + if ( ! $q['suppress_filters']) { |
|
| 3797 | 3797 | /** |
| 3798 | 3798 | * Filters the array of retrieved posts after they've been fetched and |
| 3799 | 3799 | * internally processed. |
@@ -3803,27 +3803,27 @@ discard block |
||
| 3803 | 3803 | * @param array $posts The array of retrieved posts. |
| 3804 | 3804 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3805 | 3805 | */ |
| 3806 | - $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); |
|
| 3806 | + $this->posts = apply_filters_ref_array('the_posts', array($this->posts, &$this)); |
|
| 3807 | 3807 | } |
| 3808 | 3808 | |
| 3809 | 3809 | // Ensure that any posts added/modified via one of the filters above are |
| 3810 | 3810 | // of the type WP_Post and are filtered. |
| 3811 | - if ( $this->posts ) { |
|
| 3812 | - $this->post_count = count( $this->posts ); |
|
| 3811 | + if ($this->posts) { |
|
| 3812 | + $this->post_count = count($this->posts); |
|
| 3813 | 3813 | |
| 3814 | - $this->posts = array_map( 'get_post', $this->posts ); |
|
| 3814 | + $this->posts = array_map('get_post', $this->posts); |
|
| 3815 | 3815 | |
| 3816 | - if ( $q['cache_results'] ) |
|
| 3816 | + if ($q['cache_results']) |
|
| 3817 | 3817 | update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); |
| 3818 | 3818 | |
| 3819 | - $this->post = reset( $this->posts ); |
|
| 3819 | + $this->post = reset($this->posts); |
|
| 3820 | 3820 | } else { |
| 3821 | 3821 | $this->post_count = 0; |
| 3822 | 3822 | $this->posts = array(); |
| 3823 | 3823 | } |
| 3824 | 3824 | |
| 3825 | - if ( $q['lazy_load_term_meta'] ) { |
|
| 3826 | - wp_queue_posts_for_term_meta_lazyload( $this->posts ); |
|
| 3825 | + if ($q['lazy_load_term_meta']) { |
|
| 3826 | + wp_queue_posts_for_term_meta_lazyload($this->posts); |
|
| 3827 | 3827 | } |
| 3828 | 3828 | |
| 3829 | 3829 | return $this->posts; |
@@ -3841,15 +3841,15 @@ discard block |
||
| 3841 | 3841 | * @param array $q Query variables. |
| 3842 | 3842 | * @param string $limits LIMIT clauses of the query. |
| 3843 | 3843 | */ |
| 3844 | - private function set_found_posts( $q, $limits ) { |
|
| 3844 | + private function set_found_posts($q, $limits) { |
|
| 3845 | 3845 | global $wpdb; |
| 3846 | 3846 | |
| 3847 | 3847 | // Bail if posts is an empty array. Continue if posts is an empty string, |
| 3848 | 3848 | // null, or false to accommodate caching plugins that fill posts later. |
| 3849 | - if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) |
|
| 3849 | + if ($q['no_found_rows'] || (is_array($this->posts) && ! $this->posts)) |
|
| 3850 | 3850 | return; |
| 3851 | 3851 | |
| 3852 | - if ( ! empty( $limits ) ) { |
|
| 3852 | + if ( ! empty($limits)) { |
|
| 3853 | 3853 | /** |
| 3854 | 3854 | * Filters the query to run for retrieving the found posts. |
| 3855 | 3855 | * |
@@ -3858,9 +3858,9 @@ discard block |
||
| 3858 | 3858 | * @param string $found_posts The query to run to find the found posts. |
| 3859 | 3859 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3860 | 3860 | */ |
| 3861 | - $this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) ); |
|
| 3861 | + $this->found_posts = $wpdb->get_var(apply_filters_ref_array('found_posts_query', array('SELECT FOUND_ROWS()', &$this))); |
|
| 3862 | 3862 | } else { |
| 3863 | - $this->found_posts = count( $this->posts ); |
|
| 3863 | + $this->found_posts = count($this->posts); |
|
| 3864 | 3864 | } |
| 3865 | 3865 | |
| 3866 | 3866 | /** |
@@ -3871,10 +3871,10 @@ discard block |
||
| 3871 | 3871 | * @param int $found_posts The number of posts found. |
| 3872 | 3872 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3873 | 3873 | */ |
| 3874 | - $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); |
|
| 3874 | + $this->found_posts = apply_filters_ref_array('found_posts', array($this->found_posts, &$this)); |
|
| 3875 | 3875 | |
| 3876 | - if ( ! empty( $limits ) ) |
|
| 3877 | - $this->max_num_pages = ceil( $this->found_posts / $q['posts_per_page'] ); |
|
| 3876 | + if ( ! empty($limits)) |
|
| 3877 | + $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); |
|
| 3878 | 3878 | } |
| 3879 | 3879 | |
| 3880 | 3880 | /** |
@@ -3908,7 +3908,7 @@ discard block |
||
| 3908 | 3908 | global $post; |
| 3909 | 3909 | $this->in_the_loop = true; |
| 3910 | 3910 | |
| 3911 | - if ( $this->current_post == -1 ) // loop has just started |
|
| 3911 | + if ($this->current_post == -1) // loop has just started |
|
| 3912 | 3912 | /** |
| 3913 | 3913 | * Fires once the loop is started. |
| 3914 | 3914 | * |
@@ -3916,10 +3916,10 @@ discard block |
||
| 3916 | 3916 | * |
| 3917 | 3917 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3918 | 3918 | */ |
| 3919 | - do_action_ref_array( 'loop_start', array( &$this ) ); |
|
| 3919 | + do_action_ref_array('loop_start', array(&$this)); |
|
| 3920 | 3920 | |
| 3921 | 3921 | $post = $this->next_post(); |
| 3922 | - $this->setup_postdata( $post ); |
|
| 3922 | + $this->setup_postdata($post); |
|
| 3923 | 3923 | } |
| 3924 | 3924 | |
| 3925 | 3925 | /** |
@@ -3933,9 +3933,9 @@ discard block |
||
| 3933 | 3933 | * @return bool True if posts are available, false if end of loop. |
| 3934 | 3934 | */ |
| 3935 | 3935 | public function have_posts() { |
| 3936 | - if ( $this->current_post + 1 < $this->post_count ) { |
|
| 3936 | + if ($this->current_post + 1 < $this->post_count) { |
|
| 3937 | 3937 | return true; |
| 3938 | - } elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) { |
|
| 3938 | + } elseif ($this->current_post + 1 == $this->post_count && $this->post_count > 0) { |
|
| 3939 | 3939 | /** |
| 3940 | 3940 | * Fires once the loop has ended. |
| 3941 | 3941 | * |
@@ -3943,7 +3943,7 @@ discard block |
||
| 3943 | 3943 | * |
| 3944 | 3944 | * @param WP_Query &$this The WP_Query instance (passed by reference). |
| 3945 | 3945 | */ |
| 3946 | - do_action_ref_array( 'loop_end', array( &$this ) ); |
|
| 3946 | + do_action_ref_array('loop_end', array(&$this)); |
|
| 3947 | 3947 | // Do some cleaning up after the loop |
| 3948 | 3948 | $this->rewind_posts(); |
| 3949 | 3949 | } |
@@ -3960,7 +3960,7 @@ discard block |
||
| 3960 | 3960 | */ |
| 3961 | 3961 | public function rewind_posts() { |
| 3962 | 3962 | $this->current_post = -1; |
| 3963 | - if ( $this->post_count > 0 ) { |
|
| 3963 | + if ($this->post_count > 0) { |
|
| 3964 | 3964 | $this->post = $this->posts[0]; |
| 3965 | 3965 | } |
| 3966 | 3966 | } |
@@ -3992,13 +3992,13 @@ discard block |
||
| 3992 | 3992 | |
| 3993 | 3993 | $comment = $this->next_comment(); |
| 3994 | 3994 | |
| 3995 | - if ( $this->current_comment == 0 ) { |
|
| 3995 | + if ($this->current_comment == 0) { |
|
| 3996 | 3996 | /** |
| 3997 | 3997 | * Fires once the comment loop is started. |
| 3998 | 3998 | * |
| 3999 | 3999 | * @since 2.2.0 |
| 4000 | 4000 | */ |
| 4001 | - do_action( 'comment_loop_start' ); |
|
| 4001 | + do_action('comment_loop_start'); |
|
| 4002 | 4002 | } |
| 4003 | 4003 | } |
| 4004 | 4004 | |
@@ -4013,9 +4013,9 @@ discard block |
||
| 4013 | 4013 | * @return bool True, if more comments. False, if no more posts. |
| 4014 | 4014 | */ |
| 4015 | 4015 | public function have_comments() { |
| 4016 | - if ( $this->current_comment + 1 < $this->comment_count ) { |
|
| 4016 | + if ($this->current_comment + 1 < $this->comment_count) { |
|
| 4017 | 4017 | return true; |
| 4018 | - } elseif ( $this->current_comment + 1 == $this->comment_count ) { |
|
| 4018 | + } elseif ($this->current_comment + 1 == $this->comment_count) { |
|
| 4019 | 4019 | $this->rewind_comments(); |
| 4020 | 4020 | } |
| 4021 | 4021 | |
@@ -4030,7 +4030,7 @@ discard block |
||
| 4030 | 4030 | */ |
| 4031 | 4031 | public function rewind_comments() { |
| 4032 | 4032 | $this->current_comment = -1; |
| 4033 | - if ( $this->comment_count > 0 ) { |
|
| 4033 | + if ($this->comment_count > 0) { |
|
| 4034 | 4034 | $this->comment = $this->comments[0]; |
| 4035 | 4035 | } |
| 4036 | 4036 | } |
@@ -4044,9 +4044,9 @@ discard block |
||
| 4044 | 4044 | * @param string $query URL query string. |
| 4045 | 4045 | * @return array List of posts. |
| 4046 | 4046 | */ |
| 4047 | - public function query( $query ) { |
|
| 4047 | + public function query($query) { |
|
| 4048 | 4048 | $this->init(); |
| 4049 | - $this->query = $this->query_vars = wp_parse_args( $query ); |
|
| 4049 | + $this->query = $this->query_vars = wp_parse_args($query); |
|
| 4050 | 4050 | return $this->get_posts(); |
| 4051 | 4051 | } |
| 4052 | 4052 | |
@@ -4063,66 +4063,66 @@ discard block |
||
| 4063 | 4063 | * @return object |
| 4064 | 4064 | */ |
| 4065 | 4065 | public function get_queried_object() { |
| 4066 | - if ( isset($this->queried_object) ) |
|
| 4066 | + if (isset($this->queried_object)) |
|
| 4067 | 4067 | return $this->queried_object; |
| 4068 | 4068 | |
| 4069 | 4069 | $this->queried_object = null; |
| 4070 | 4070 | $this->queried_object_id = null; |
| 4071 | 4071 | |
| 4072 | - if ( $this->is_category || $this->is_tag || $this->is_tax ) { |
|
| 4073 | - if ( $this->is_category ) { |
|
| 4074 | - if ( $this->get( 'cat' ) ) { |
|
| 4075 | - $term = get_term( $this->get( 'cat' ), 'category' ); |
|
| 4076 | - } elseif ( $this->get( 'category_name' ) ) { |
|
| 4077 | - $term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' ); |
|
| 4072 | + if ($this->is_category || $this->is_tag || $this->is_tax) { |
|
| 4073 | + if ($this->is_category) { |
|
| 4074 | + if ($this->get('cat')) { |
|
| 4075 | + $term = get_term($this->get('cat'), 'category'); |
|
| 4076 | + } elseif ($this->get('category_name')) { |
|
| 4077 | + $term = get_term_by('slug', $this->get('category_name'), 'category'); |
|
| 4078 | 4078 | } |
| 4079 | - } elseif ( $this->is_tag ) { |
|
| 4080 | - if ( $this->get( 'tag_id' ) ) { |
|
| 4081 | - $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); |
|
| 4082 | - } elseif ( $this->get( 'tag' ) ) { |
|
| 4083 | - $term = get_term_by( 'slug', $this->get( 'tag' ), 'post_tag' ); |
|
| 4079 | + } elseif ($this->is_tag) { |
|
| 4080 | + if ($this->get('tag_id')) { |
|
| 4081 | + $term = get_term($this->get('tag_id'), 'post_tag'); |
|
| 4082 | + } elseif ($this->get('tag')) { |
|
| 4083 | + $term = get_term_by('slug', $this->get('tag'), 'post_tag'); |
|
| 4084 | 4084 | } |
| 4085 | 4085 | } else { |
| 4086 | 4086 | // For other tax queries, grab the first term from the first clause. |
| 4087 | - $tax_query_in_and = wp_list_filter( $this->tax_query->queried_terms, array( 'operator' => 'NOT IN' ), 'NOT' ); |
|
| 4087 | + $tax_query_in_and = wp_list_filter($this->tax_query->queried_terms, array('operator' => 'NOT IN'), 'NOT'); |
|
| 4088 | 4088 | |
| 4089 | - if ( ! empty( $tax_query_in_and ) ) { |
|
| 4090 | - $queried_taxonomies = array_keys( $tax_query_in_and ); |
|
| 4091 | - $matched_taxonomy = reset( $queried_taxonomies ); |
|
| 4092 | - $query = $tax_query_in_and[ $matched_taxonomy ]; |
|
| 4089 | + if ( ! empty($tax_query_in_and)) { |
|
| 4090 | + $queried_taxonomies = array_keys($tax_query_in_and); |
|
| 4091 | + $matched_taxonomy = reset($queried_taxonomies); |
|
| 4092 | + $query = $tax_query_in_and[$matched_taxonomy]; |
|
| 4093 | 4093 | |
| 4094 | - if ( $query['terms'] ) { |
|
| 4095 | - if ( 'term_id' == $query['field'] ) { |
|
| 4096 | - $term = get_term( reset( $query['terms'] ), $matched_taxonomy ); |
|
| 4094 | + if ($query['terms']) { |
|
| 4095 | + if ('term_id' == $query['field']) { |
|
| 4096 | + $term = get_term(reset($query['terms']), $matched_taxonomy); |
|
| 4097 | 4097 | } else { |
| 4098 | - $term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy ); |
|
| 4098 | + $term = get_term_by($query['field'], reset($query['terms']), $matched_taxonomy); |
|
| 4099 | 4099 | } |
| 4100 | 4100 | } |
| 4101 | 4101 | } |
| 4102 | 4102 | } |
| 4103 | 4103 | |
| 4104 | - if ( ! empty( $term ) && ! is_wp_error( $term ) ) { |
|
| 4104 | + if ( ! empty($term) && ! is_wp_error($term)) { |
|
| 4105 | 4105 | $this->queried_object = $term; |
| 4106 | 4106 | $this->queried_object_id = (int) $term->term_id; |
| 4107 | 4107 | |
| 4108 | - if ( $this->is_category && 'category' === $this->queried_object->taxonomy ) |
|
| 4109 | - _make_cat_compat( $this->queried_object ); |
|
| 4108 | + if ($this->is_category && 'category' === $this->queried_object->taxonomy) |
|
| 4109 | + _make_cat_compat($this->queried_object); |
|
| 4110 | 4110 | } |
| 4111 | - } elseif ( $this->is_post_type_archive ) { |
|
| 4112 | - $post_type = $this->get( 'post_type' ); |
|
| 4113 | - if ( is_array( $post_type ) ) |
|
| 4114 | - $post_type = reset( $post_type ); |
|
| 4115 | - $this->queried_object = get_post_type_object( $post_type ); |
|
| 4116 | - } elseif ( $this->is_posts_page ) { |
|
| 4111 | + } elseif ($this->is_post_type_archive) { |
|
| 4112 | + $post_type = $this->get('post_type'); |
|
| 4113 | + if (is_array($post_type)) |
|
| 4114 | + $post_type = reset($post_type); |
|
| 4115 | + $this->queried_object = get_post_type_object($post_type); |
|
| 4116 | + } elseif ($this->is_posts_page) { |
|
| 4117 | 4117 | $page_for_posts = get_option('page_for_posts'); |
| 4118 | - $this->queried_object = get_post( $page_for_posts ); |
|
| 4118 | + $this->queried_object = get_post($page_for_posts); |
|
| 4119 | 4119 | $this->queried_object_id = (int) $this->queried_object->ID; |
| 4120 | - } elseif ( $this->is_singular && ! empty( $this->post ) ) { |
|
| 4120 | + } elseif ($this->is_singular && ! empty($this->post)) { |
|
| 4121 | 4121 | $this->queried_object = $this->post; |
| 4122 | 4122 | $this->queried_object_id = (int) $this->post->ID; |
| 4123 | - } elseif ( $this->is_author ) { |
|
| 4123 | + } elseif ($this->is_author) { |
|
| 4124 | 4124 | $this->queried_object_id = (int) $this->get('author'); |
| 4125 | - $this->queried_object = get_userdata( $this->queried_object_id ); |
|
| 4125 | + $this->queried_object = get_userdata($this->queried_object_id); |
|
| 4126 | 4126 | } |
| 4127 | 4127 | |
| 4128 | 4128 | return $this->queried_object; |
@@ -4139,7 +4139,7 @@ discard block |
||
| 4139 | 4139 | public function get_queried_object_id() { |
| 4140 | 4140 | $this->get_queried_object(); |
| 4141 | 4141 | |
| 4142 | - if ( isset($this->queried_object_id) ) { |
|
| 4142 | + if (isset($this->queried_object_id)) { |
|
| 4143 | 4143 | return $this->queried_object_id; |
| 4144 | 4144 | } |
| 4145 | 4145 | |
@@ -4157,7 +4157,7 @@ discard block |
||
| 4157 | 4157 | * @param string|array $query URL query string or array of vars. |
| 4158 | 4158 | */ |
| 4159 | 4159 | public function __construct($query = '') { |
| 4160 | - if ( ! empty($query) ) { |
|
| 4160 | + if ( ! empty($query)) { |
|
| 4161 | 4161 | $this->query($query); |
| 4162 | 4162 | } |
| 4163 | 4163 | } |
@@ -4171,8 +4171,8 @@ discard block |
||
| 4171 | 4171 | * @param string $name Property to get. |
| 4172 | 4172 | * @return mixed Property. |
| 4173 | 4173 | */ |
| 4174 | - public function __get( $name ) { |
|
| 4175 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 4174 | + public function __get($name) { |
|
| 4175 | + if (in_array($name, $this->compat_fields)) { |
|
| 4176 | 4176 | return $this->$name; |
| 4177 | 4177 | } |
| 4178 | 4178 | } |
@@ -4186,9 +4186,9 @@ discard block |
||
| 4186 | 4186 | * @param string $name Property to check if set. |
| 4187 | 4187 | * @return bool Whether the property is set. |
| 4188 | 4188 | */ |
| 4189 | - public function __isset( $name ) { |
|
| 4190 | - if ( in_array( $name, $this->compat_fields ) ) { |
|
| 4191 | - return isset( $this->$name ); |
|
| 4189 | + public function __isset($name) { |
|
| 4190 | + if (in_array($name, $this->compat_fields)) { |
|
| 4191 | + return isset($this->$name); |
|
| 4192 | 4192 | } |
| 4193 | 4193 | } |
| 4194 | 4194 | |
@@ -4202,9 +4202,9 @@ discard block |
||
| 4202 | 4202 | * @param array $arguments Arguments to pass when calling. |
| 4203 | 4203 | * @return mixed|false Return value of the callback, false otherwise. |
| 4204 | 4204 | */ |
| 4205 | - public function __call( $name, $arguments ) { |
|
| 4206 | - if ( in_array( $name, $this->compat_methods ) ) { |
|
| 4207 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 4205 | + public function __call($name, $arguments) { |
|
| 4206 | + if (in_array($name, $this->compat_methods)) { |
|
| 4207 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 4208 | 4208 | } |
| 4209 | 4209 | return false; |
| 4210 | 4210 | } |
@@ -4230,16 +4230,16 @@ discard block |
||
| 4230 | 4230 | * @param mixed $post_types Optional. Post type or array of posts types to check against. |
| 4231 | 4231 | * @return bool |
| 4232 | 4232 | */ |
| 4233 | - public function is_post_type_archive( $post_types = '' ) { |
|
| 4234 | - if ( empty( $post_types ) || ! $this->is_post_type_archive ) |
|
| 4233 | + public function is_post_type_archive($post_types = '') { |
|
| 4234 | + if (empty($post_types) || ! $this->is_post_type_archive) |
|
| 4235 | 4235 | return (bool) $this->is_post_type_archive; |
| 4236 | 4236 | |
| 4237 | - $post_type = $this->get( 'post_type' ); |
|
| 4238 | - if ( is_array( $post_type ) ) |
|
| 4239 | - $post_type = reset( $post_type ); |
|
| 4240 | - $post_type_object = get_post_type_object( $post_type ); |
|
| 4237 | + $post_type = $this->get('post_type'); |
|
| 4238 | + if (is_array($post_type)) |
|
| 4239 | + $post_type = reset($post_type); |
|
| 4240 | + $post_type_object = get_post_type_object($post_type); |
|
| 4241 | 4241 | |
| 4242 | - return in_array( $post_type_object->name, (array) $post_types ); |
|
| 4242 | + return in_array($post_type_object->name, (array) $post_types); |
|
| 4243 | 4243 | } |
| 4244 | 4244 | |
| 4245 | 4245 | /** |
@@ -4250,24 +4250,24 @@ discard block |
||
| 4250 | 4250 | * @param mixed $attachment Attachment ID, title, slug, or array of such. |
| 4251 | 4251 | * @return bool |
| 4252 | 4252 | */ |
| 4253 | - public function is_attachment( $attachment = '' ) { |
|
| 4254 | - if ( ! $this->is_attachment ) { |
|
| 4253 | + public function is_attachment($attachment = '') { |
|
| 4254 | + if ( ! $this->is_attachment) { |
|
| 4255 | 4255 | return false; |
| 4256 | 4256 | } |
| 4257 | 4257 | |
| 4258 | - if ( empty( $attachment ) ) { |
|
| 4258 | + if (empty($attachment)) { |
|
| 4259 | 4259 | return true; |
| 4260 | 4260 | } |
| 4261 | 4261 | |
| 4262 | - $attachment = array_map( 'strval', (array) $attachment ); |
|
| 4262 | + $attachment = array_map('strval', (array) $attachment); |
|
| 4263 | 4263 | |
| 4264 | 4264 | $post_obj = $this->get_queried_object(); |
| 4265 | 4265 | |
| 4266 | - if ( in_array( (string) $post_obj->ID, $attachment ) ) { |
|
| 4266 | + if (in_array((string) $post_obj->ID, $attachment)) { |
|
| 4267 | 4267 | return true; |
| 4268 | - } elseif ( in_array( $post_obj->post_title, $attachment ) ) { |
|
| 4268 | + } elseif (in_array($post_obj->post_title, $attachment)) { |
|
| 4269 | 4269 | return true; |
| 4270 | - } elseif ( in_array( $post_obj->post_name, $attachment ) ) { |
|
| 4270 | + } elseif (in_array($post_obj->post_name, $attachment)) { |
|
| 4271 | 4271 | return true; |
| 4272 | 4272 | } |
| 4273 | 4273 | return false; |
@@ -4284,22 +4284,22 @@ discard block |
||
| 4284 | 4284 | * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames |
| 4285 | 4285 | * @return bool |
| 4286 | 4286 | */ |
| 4287 | - public function is_author( $author = '' ) { |
|
| 4288 | - if ( !$this->is_author ) |
|
| 4287 | + public function is_author($author = '') { |
|
| 4288 | + if ( ! $this->is_author) |
|
| 4289 | 4289 | return false; |
| 4290 | 4290 | |
| 4291 | - if ( empty($author) ) |
|
| 4291 | + if (empty($author)) |
|
| 4292 | 4292 | return true; |
| 4293 | 4293 | |
| 4294 | 4294 | $author_obj = $this->get_queried_object(); |
| 4295 | 4295 | |
| 4296 | - $author = array_map( 'strval', (array) $author ); |
|
| 4296 | + $author = array_map('strval', (array) $author); |
|
| 4297 | 4297 | |
| 4298 | - if ( in_array( (string) $author_obj->ID, $author ) ) |
|
| 4298 | + if (in_array((string) $author_obj->ID, $author)) |
|
| 4299 | 4299 | return true; |
| 4300 | - elseif ( in_array( $author_obj->nickname, $author ) ) |
|
| 4300 | + elseif (in_array($author_obj->nickname, $author)) |
|
| 4301 | 4301 | return true; |
| 4302 | - elseif ( in_array( $author_obj->user_nicename, $author ) ) |
|
| 4302 | + elseif (in_array($author_obj->user_nicename, $author)) |
|
| 4303 | 4303 | return true; |
| 4304 | 4304 | |
| 4305 | 4305 | return false; |
@@ -4316,22 +4316,22 @@ discard block |
||
| 4316 | 4316 | * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs. |
| 4317 | 4317 | * @return bool |
| 4318 | 4318 | */ |
| 4319 | - public function is_category( $category = '' ) { |
|
| 4320 | - if ( !$this->is_category ) |
|
| 4319 | + public function is_category($category = '') { |
|
| 4320 | + if ( ! $this->is_category) |
|
| 4321 | 4321 | return false; |
| 4322 | 4322 | |
| 4323 | - if ( empty($category) ) |
|
| 4323 | + if (empty($category)) |
|
| 4324 | 4324 | return true; |
| 4325 | 4325 | |
| 4326 | 4326 | $cat_obj = $this->get_queried_object(); |
| 4327 | 4327 | |
| 4328 | - $category = array_map( 'strval', (array) $category ); |
|
| 4328 | + $category = array_map('strval', (array) $category); |
|
| 4329 | 4329 | |
| 4330 | - if ( in_array( (string) $cat_obj->term_id, $category ) ) |
|
| 4330 | + if (in_array((string) $cat_obj->term_id, $category)) |
|
| 4331 | 4331 | return true; |
| 4332 | - elseif ( in_array( $cat_obj->name, $category ) ) |
|
| 4332 | + elseif (in_array($cat_obj->name, $category)) |
|
| 4333 | 4333 | return true; |
| 4334 | - elseif ( in_array( $cat_obj->slug, $category ) ) |
|
| 4334 | + elseif (in_array($cat_obj->slug, $category)) |
|
| 4335 | 4335 | return true; |
| 4336 | 4336 | |
| 4337 | 4337 | return false; |
@@ -4348,22 +4348,22 @@ discard block |
||
| 4348 | 4348 | * @param mixed $tag Optional. Tag ID, name, slug, or array of Tag IDs, names, and slugs. |
| 4349 | 4349 | * @return bool |
| 4350 | 4350 | */ |
| 4351 | - public function is_tag( $tag = '' ) { |
|
| 4352 | - if ( ! $this->is_tag ) |
|
| 4351 | + public function is_tag($tag = '') { |
|
| 4352 | + if ( ! $this->is_tag) |
|
| 4353 | 4353 | return false; |
| 4354 | 4354 | |
| 4355 | - if ( empty( $tag ) ) |
|
| 4355 | + if (empty($tag)) |
|
| 4356 | 4356 | return true; |
| 4357 | 4357 | |
| 4358 | 4358 | $tag_obj = $this->get_queried_object(); |
| 4359 | 4359 | |
| 4360 | - $tag = array_map( 'strval', (array) $tag ); |
|
| 4360 | + $tag = array_map('strval', (array) $tag); |
|
| 4361 | 4361 | |
| 4362 | - if ( in_array( (string) $tag_obj->term_id, $tag ) ) |
|
| 4362 | + if (in_array((string) $tag_obj->term_id, $tag)) |
|
| 4363 | 4363 | return true; |
| 4364 | - elseif ( in_array( $tag_obj->name, $tag ) ) |
|
| 4364 | + elseif (in_array($tag_obj->name, $tag)) |
|
| 4365 | 4365 | return true; |
| 4366 | - elseif ( in_array( $tag_obj->slug, $tag ) ) |
|
| 4366 | + elseif (in_array($tag_obj->slug, $tag)) |
|
| 4367 | 4367 | return true; |
| 4368 | 4368 | |
| 4369 | 4369 | return false; |
@@ -4387,32 +4387,32 @@ discard block |
||
| 4387 | 4387 | * @param mixed $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs. |
| 4388 | 4388 | * @return bool True for custom taxonomy archive pages, false for built-in taxonomies (category and tag archives). |
| 4389 | 4389 | */ |
| 4390 | - public function is_tax( $taxonomy = '', $term = '' ) { |
|
| 4390 | + public function is_tax($taxonomy = '', $term = '') { |
|
| 4391 | 4391 | global $wp_taxonomies; |
| 4392 | 4392 | |
| 4393 | - if ( !$this->is_tax ) |
|
| 4393 | + if ( ! $this->is_tax) |
|
| 4394 | 4394 | return false; |
| 4395 | 4395 | |
| 4396 | - if ( empty( $taxonomy ) ) |
|
| 4396 | + if (empty($taxonomy)) |
|
| 4397 | 4397 | return true; |
| 4398 | 4398 | |
| 4399 | 4399 | $queried_object = $this->get_queried_object(); |
| 4400 | - $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy ); |
|
| 4400 | + $tax_array = array_intersect(array_keys($wp_taxonomies), (array) $taxonomy); |
|
| 4401 | 4401 | $term_array = (array) $term; |
| 4402 | 4402 | |
| 4403 | 4403 | // Check that the taxonomy matches. |
| 4404 | - if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) |
|
| 4404 | + if ( ! (isset($queried_object->taxonomy) && count($tax_array) && in_array($queried_object->taxonomy, $tax_array))) |
|
| 4405 | 4405 | return false; |
| 4406 | 4406 | |
| 4407 | 4407 | // Only a Taxonomy provided. |
| 4408 | - if ( empty( $term ) ) |
|
| 4408 | + if (empty($term)) |
|
| 4409 | 4409 | return true; |
| 4410 | 4410 | |
| 4411 | - return isset( $queried_object->term_id ) && |
|
| 4412 | - count( array_intersect( |
|
| 4413 | - array( $queried_object->term_id, $queried_object->name, $queried_object->slug ), |
|
| 4411 | + return isset($queried_object->term_id) && |
|
| 4412 | + count(array_intersect( |
|
| 4413 | + array($queried_object->term_id, $queried_object->name, $queried_object->slug), |
|
| 4414 | 4414 | $term_array |
| 4415 | - ) ); |
|
| 4415 | + )); |
|
| 4416 | 4416 | } |
| 4417 | 4417 | |
| 4418 | 4418 | /** |
@@ -4424,7 +4424,7 @@ discard block |
||
| 4424 | 4424 | * @return bool |
| 4425 | 4425 | */ |
| 4426 | 4426 | public function is_comments_popup() { |
| 4427 | - _deprecated_function( __FUNCTION__, '4.5.0' ); |
|
| 4427 | + _deprecated_function(__FUNCTION__, '4.5.0'); |
|
| 4428 | 4428 | |
| 4429 | 4429 | return false; |
| 4430 | 4430 | } |
@@ -4459,13 +4459,13 @@ discard block |
||
| 4459 | 4459 | * @param string|array $feeds Optional feed types to check. |
| 4460 | 4460 | * @return bool |
| 4461 | 4461 | */ |
| 4462 | - public function is_feed( $feeds = '' ) { |
|
| 4463 | - if ( empty( $feeds ) || ! $this->is_feed ) |
|
| 4462 | + public function is_feed($feeds = '') { |
|
| 4463 | + if (empty($feeds) || ! $this->is_feed) |
|
| 4464 | 4464 | return (bool) $this->is_feed; |
| 4465 | - $qv = $this->get( 'feed' ); |
|
| 4466 | - if ( 'feed' == $qv ) |
|
| 4465 | + $qv = $this->get('feed'); |
|
| 4466 | + if ('feed' == $qv) |
|
| 4467 | 4467 | $qv = get_default_feed(); |
| 4468 | - return in_array( $qv, (array) $feeds ); |
|
| 4468 | + return in_array($qv, (array) $feeds); |
|
| 4469 | 4469 | } |
| 4470 | 4470 | |
| 4471 | 4471 | /** |
@@ -4497,9 +4497,9 @@ discard block |
||
| 4497 | 4497 | */ |
| 4498 | 4498 | public function is_front_page() { |
| 4499 | 4499 | // most likely case |
| 4500 | - if ( 'posts' == get_option( 'show_on_front') && $this->is_home() ) |
|
| 4500 | + if ('posts' == get_option('show_on_front') && $this->is_home()) |
|
| 4501 | 4501 | return true; |
| 4502 | - elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) |
|
| 4502 | + elseif ('page' == get_option('show_on_front') && get_option('page_on_front') && $this->is_page(get_option('page_on_front'))) |
|
| 4503 | 4503 | return true; |
| 4504 | 4504 | else |
| 4505 | 4505 | return false; |
@@ -4550,31 +4550,31 @@ discard block |
||
| 4550 | 4550 | * @param int|string|array $page Optional. Page ID, title, slug, path, or array of such. Default empty. |
| 4551 | 4551 | * @return bool Whether the query is for an existing single page. |
| 4552 | 4552 | */ |
| 4553 | - public function is_page( $page = '' ) { |
|
| 4554 | - if ( !$this->is_page ) |
|
| 4553 | + public function is_page($page = '') { |
|
| 4554 | + if ( ! $this->is_page) |
|
| 4555 | 4555 | return false; |
| 4556 | 4556 | |
| 4557 | - if ( empty( $page ) ) |
|
| 4557 | + if (empty($page)) |
|
| 4558 | 4558 | return true; |
| 4559 | 4559 | |
| 4560 | 4560 | $page_obj = $this->get_queried_object(); |
| 4561 | 4561 | |
| 4562 | - $page = array_map( 'strval', (array) $page ); |
|
| 4562 | + $page = array_map('strval', (array) $page); |
|
| 4563 | 4563 | |
| 4564 | - if ( in_array( (string) $page_obj->ID, $page ) ) { |
|
| 4564 | + if (in_array((string) $page_obj->ID, $page)) { |
|
| 4565 | 4565 | return true; |
| 4566 | - } elseif ( in_array( $page_obj->post_title, $page ) ) { |
|
| 4566 | + } elseif (in_array($page_obj->post_title, $page)) { |
|
| 4567 | 4567 | return true; |
| 4568 | - } elseif ( in_array( $page_obj->post_name, $page ) ) { |
|
| 4568 | + } elseif (in_array($page_obj->post_name, $page)) { |
|
| 4569 | 4569 | return true; |
| 4570 | 4570 | } else { |
| 4571 | - foreach ( $page as $pagepath ) { |
|
| 4572 | - if ( ! strpos( $pagepath, '/' ) ) { |
|
| 4571 | + foreach ($page as $pagepath) { |
|
| 4572 | + if ( ! strpos($pagepath, '/')) { |
|
| 4573 | 4573 | continue; |
| 4574 | 4574 | } |
| 4575 | - $pagepath_obj = get_page_by_path( $pagepath ); |
|
| 4575 | + $pagepath_obj = get_page_by_path($pagepath); |
|
| 4576 | 4576 | |
| 4577 | - if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { |
|
| 4577 | + if ($pagepath_obj && ($pagepath_obj->ID == $page_obj->ID)) { |
|
| 4578 | 4578 | return true; |
| 4579 | 4579 | } |
| 4580 | 4580 | } |
@@ -4643,31 +4643,31 @@ discard block |
||
| 4643 | 4643 | * @param int|string|array $post Optional. Post ID, title, slug, path, or array of such. Default empty. |
| 4644 | 4644 | * @return bool Whether the query is for an existing single post. |
| 4645 | 4645 | */ |
| 4646 | - public function is_single( $post = '' ) { |
|
| 4647 | - if ( !$this->is_single ) |
|
| 4646 | + public function is_single($post = '') { |
|
| 4647 | + if ( ! $this->is_single) |
|
| 4648 | 4648 | return false; |
| 4649 | 4649 | |
| 4650 | - if ( empty($post) ) |
|
| 4650 | + if (empty($post)) |
|
| 4651 | 4651 | return true; |
| 4652 | 4652 | |
| 4653 | 4653 | $post_obj = $this->get_queried_object(); |
| 4654 | 4654 | |
| 4655 | - $post = array_map( 'strval', (array) $post ); |
|
| 4655 | + $post = array_map('strval', (array) $post); |
|
| 4656 | 4656 | |
| 4657 | - if ( in_array( (string) $post_obj->ID, $post ) ) { |
|
| 4657 | + if (in_array((string) $post_obj->ID, $post)) { |
|
| 4658 | 4658 | return true; |
| 4659 | - } elseif ( in_array( $post_obj->post_title, $post ) ) { |
|
| 4659 | + } elseif (in_array($post_obj->post_title, $post)) { |
|
| 4660 | 4660 | return true; |
| 4661 | - } elseif ( in_array( $post_obj->post_name, $post ) ) { |
|
| 4661 | + } elseif (in_array($post_obj->post_name, $post)) { |
|
| 4662 | 4662 | return true; |
| 4663 | 4663 | } else { |
| 4664 | - foreach ( $post as $postpath ) { |
|
| 4665 | - if ( ! strpos( $postpath, '/' ) ) { |
|
| 4664 | + foreach ($post as $postpath) { |
|
| 4665 | + if ( ! strpos($postpath, '/')) { |
|
| 4666 | 4666 | continue; |
| 4667 | 4667 | } |
| 4668 | - $postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); |
|
| 4668 | + $postpath_obj = get_page_by_path($postpath, OBJECT, $post_obj->post_type); |
|
| 4669 | 4669 | |
| 4670 | - if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { |
|
| 4670 | + if ($postpath_obj && ($postpath_obj->ID == $post_obj->ID)) { |
|
| 4671 | 4671 | return true; |
| 4672 | 4672 | } |
| 4673 | 4673 | } |
@@ -4689,13 +4689,13 @@ discard block |
||
| 4689 | 4689 | * @param string|array $post_types Optional. Post type or array of post types. Default empty. |
| 4690 | 4690 | * @return bool Whether the query is for an existing single post of any of the given post types. |
| 4691 | 4691 | */ |
| 4692 | - public function is_singular( $post_types = '' ) { |
|
| 4693 | - if ( empty( $post_types ) || !$this->is_singular ) |
|
| 4692 | + public function is_singular($post_types = '') { |
|
| 4693 | + if (empty($post_types) || ! $this->is_singular) |
|
| 4694 | 4694 | return (bool) $this->is_singular; |
| 4695 | 4695 | |
| 4696 | 4696 | $post_obj = $this->get_queried_object(); |
| 4697 | 4697 | |
| 4698 | - return in_array( $post_obj->post_type, (array) $post_types ); |
|
| 4698 | + return in_array($post_obj->post_type, (array) $post_types); |
|
| 4699 | 4699 | } |
| 4700 | 4700 | |
| 4701 | 4701 | /** |
@@ -4786,14 +4786,14 @@ discard block |
||
| 4786 | 4786 | * @param WP_Post|object|int $post WP_Post instance or Post ID/object. |
| 4787 | 4787 | * @return true True when finished. |
| 4788 | 4788 | */ |
| 4789 | - public function setup_postdata( $post ) { |
|
| 4789 | + public function setup_postdata($post) { |
|
| 4790 | 4790 | global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; |
| 4791 | 4791 | |
| 4792 | - if ( ! ( $post instanceof WP_Post ) ) { |
|
| 4793 | - $post = get_post( $post ); |
|
| 4792 | + if ( ! ($post instanceof WP_Post)) { |
|
| 4793 | + $post = get_post($post); |
|
| 4794 | 4794 | } |
| 4795 | 4795 | |
| 4796 | - if ( ! $post ) { |
|
| 4796 | + if ( ! $post) { |
|
| 4797 | 4797 | return; |
| 4798 | 4798 | } |
| 4799 | 4799 | |
@@ -4805,35 +4805,35 @@ discard block |
||
| 4805 | 4805 | $currentmonth = mysql2date('m', $post->post_date, false); |
| 4806 | 4806 | $numpages = 1; |
| 4807 | 4807 | $multipage = 0; |
| 4808 | - $page = $this->get( 'page' ); |
|
| 4809 | - if ( ! $page ) |
|
| 4808 | + $page = $this->get('page'); |
|
| 4809 | + if ( ! $page) |
|
| 4810 | 4810 | $page = 1; |
| 4811 | 4811 | |
| 4812 | 4812 | /* |
| 4813 | 4813 | * Force full post content when viewing the permalink for the $post, |
| 4814 | 4814 | * or when on an RSS feed. Otherwise respect the 'more' tag. |
| 4815 | 4815 | */ |
| 4816 | - if ( $post->ID === get_queried_object_id() && ( $this->is_page() || $this->is_single() ) ) { |
|
| 4816 | + if ($post->ID === get_queried_object_id() && ($this->is_page() || $this->is_single())) { |
|
| 4817 | 4817 | $more = 1; |
| 4818 | - } elseif ( $this->is_feed() ) { |
|
| 4818 | + } elseif ($this->is_feed()) { |
|
| 4819 | 4819 | $more = 1; |
| 4820 | 4820 | } else { |
| 4821 | 4821 | $more = 0; |
| 4822 | 4822 | } |
| 4823 | 4823 | |
| 4824 | 4824 | $content = $post->post_content; |
| 4825 | - if ( false !== strpos( $content, '<!--nextpage-->' ) ) { |
|
| 4826 | - $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content ); |
|
| 4827 | - $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content ); |
|
| 4828 | - $content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content ); |
|
| 4825 | + if (false !== strpos($content, '<!--nextpage-->')) { |
|
| 4826 | + $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); |
|
| 4827 | + $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); |
|
| 4828 | + $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); |
|
| 4829 | 4829 | |
| 4830 | 4830 | // Ignore nextpage at the beginning of the content. |
| 4831 | - if ( 0 === strpos( $content, '<!--nextpage-->' ) ) |
|
| 4832 | - $content = substr( $content, 15 ); |
|
| 4831 | + if (0 === strpos($content, '<!--nextpage-->')) |
|
| 4832 | + $content = substr($content, 15); |
|
| 4833 | 4833 | |
| 4834 | 4834 | $pages = explode('<!--nextpage-->', $content); |
| 4835 | 4835 | } else { |
| 4836 | - $pages = array( $post->post_content ); |
|
| 4836 | + $pages = array($post->post_content); |
|
| 4837 | 4837 | } |
| 4838 | 4838 | |
| 4839 | 4839 | /** |
@@ -4848,12 +4848,12 @@ discard block |
||
| 4848 | 4848 | * of `<!-- nextpage -->` tags.. |
| 4849 | 4849 | * @param WP_Post $post Current post object. |
| 4850 | 4850 | */ |
| 4851 | - $pages = apply_filters( 'content_pagination', $pages, $post ); |
|
| 4851 | + $pages = apply_filters('content_pagination', $pages, $post); |
|
| 4852 | 4852 | |
| 4853 | - $numpages = count( $pages ); |
|
| 4853 | + $numpages = count($pages); |
|
| 4854 | 4854 | |
| 4855 | - if ( $numpages > 1 ) { |
|
| 4856 | - if ( $page > 1 ) { |
|
| 4855 | + if ($numpages > 1) { |
|
| 4856 | + if ($page > 1) { |
|
| 4857 | 4857 | $more = 1; |
| 4858 | 4858 | } |
| 4859 | 4859 | $multipage = 1; |
@@ -4870,7 +4870,7 @@ discard block |
||
| 4870 | 4870 | * @param WP_Post &$post The Post object (passed by reference). |
| 4871 | 4871 | * @param WP_Query &$this The current Query object (passed by reference). |
| 4872 | 4872 | */ |
| 4873 | - do_action_ref_array( 'the_post', array( &$post, &$this ) ); |
|
| 4873 | + do_action_ref_array('the_post', array(&$post, &$this)); |
|
| 4874 | 4874 | |
| 4875 | 4875 | return true; |
| 4876 | 4876 | } |
@@ -4883,9 +4883,9 @@ discard block |
||
| 4883 | 4883 | * @global WP_Post $post |
| 4884 | 4884 | */ |
| 4885 | 4885 | public function reset_postdata() { |
| 4886 | - if ( ! empty( $this->post ) ) { |
|
| 4886 | + if ( ! empty($this->post)) { |
|
| 4887 | 4887 | $GLOBALS['post'] = $this->post; |
| 4888 | - $this->setup_postdata( $this->post ); |
|
| 4888 | + $this->setup_postdata($this->post); |
|
| 4889 | 4889 | } |
| 4890 | 4890 | } |
| 4891 | 4891 | |
@@ -4899,8 +4899,8 @@ discard block |
||
| 4899 | 4899 | * @param int $term_id |
| 4900 | 4900 | * @return mixed |
| 4901 | 4901 | */ |
| 4902 | - public function lazyload_term_meta( $check, $term_id ) { |
|
| 4903 | - _deprecated_function( __METHOD__, '4.5.0' ); |
|
| 4902 | + public function lazyload_term_meta($check, $term_id) { |
|
| 4903 | + _deprecated_function(__METHOD__, '4.5.0'); |
|
| 4904 | 4904 | return $check; |
| 4905 | 4905 | } |
| 4906 | 4906 | |
@@ -4914,8 +4914,8 @@ discard block |
||
| 4914 | 4914 | * @param int $comment_id |
| 4915 | 4915 | * @return mixed |
| 4916 | 4916 | */ |
| 4917 | - public function lazyload_comment_meta( $check, $comment_id ) { |
|
| 4918 | - _deprecated_function( __METHOD__, '4.5.0' ); |
|
| 4917 | + public function lazyload_comment_meta($check, $comment_id) { |
|
| 4918 | + _deprecated_function(__METHOD__, '4.5.0'); |
|
| 4919 | 4919 | return $check; |
| 4920 | 4920 | } |
| 4921 | 4921 | } |
@@ -4933,52 +4933,52 @@ discard block |
||
| 4933 | 4933 | function wp_old_slug_redirect() { |
| 4934 | 4934 | global $wp_query; |
| 4935 | 4935 | |
| 4936 | - if ( is_404() && '' !== $wp_query->query_vars['name'] ) : |
|
| 4936 | + if (is_404() && '' !== $wp_query->query_vars['name']) : |
|
| 4937 | 4937 | global $wpdb; |
| 4938 | 4938 | |
| 4939 | 4939 | // Guess the current post_type based on the query vars. |
| 4940 | - if ( get_query_var( 'post_type' ) ) { |
|
| 4941 | - $post_type = get_query_var( 'post_type' ); |
|
| 4942 | - } elseif ( get_query_var( 'attachment' ) ) { |
|
| 4940 | + if (get_query_var('post_type')) { |
|
| 4941 | + $post_type = get_query_var('post_type'); |
|
| 4942 | + } elseif (get_query_var('attachment')) { |
|
| 4943 | 4943 | $post_type = 'attachment'; |
| 4944 | - } elseif ( ! empty( $wp_query->query_vars['pagename'] ) ) { |
|
| 4944 | + } elseif ( ! empty($wp_query->query_vars['pagename'])) { |
|
| 4945 | 4945 | $post_type = 'page'; |
| 4946 | 4946 | } else { |
| 4947 | 4947 | $post_type = 'post'; |
| 4948 | 4948 | } |
| 4949 | 4949 | |
| 4950 | - if ( is_array( $post_type ) ) { |
|
| 4951 | - if ( count( $post_type ) > 1 ) |
|
| 4950 | + if (is_array($post_type)) { |
|
| 4951 | + if (count($post_type) > 1) |
|
| 4952 | 4952 | return; |
| 4953 | - $post_type = reset( $post_type ); |
|
| 4953 | + $post_type = reset($post_type); |
|
| 4954 | 4954 | } |
| 4955 | 4955 | |
| 4956 | 4956 | // Do not attempt redirect for hierarchical post types |
| 4957 | - if ( is_post_type_hierarchical( $post_type ) ) |
|
| 4957 | + if (is_post_type_hierarchical($post_type)) |
|
| 4958 | 4958 | return; |
| 4959 | 4959 | |
| 4960 | 4960 | $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']); |
| 4961 | 4961 | |
| 4962 | 4962 | // if year, monthnum, or day have been specified, make our query more precise |
| 4963 | 4963 | // just in case there are multiple identical _wp_old_slug values |
| 4964 | - if ( '' != $wp_query->query_vars['year'] ) |
|
| 4964 | + if ('' != $wp_query->query_vars['year']) |
|
| 4965 | 4965 | $query .= $wpdb->prepare(" AND YEAR(post_date) = %d", $wp_query->query_vars['year']); |
| 4966 | - if ( '' != $wp_query->query_vars['monthnum'] ) |
|
| 4966 | + if ('' != $wp_query->query_vars['monthnum']) |
|
| 4967 | 4967 | $query .= $wpdb->prepare(" AND MONTH(post_date) = %d", $wp_query->query_vars['monthnum']); |
| 4968 | - if ( '' != $wp_query->query_vars['day'] ) |
|
| 4968 | + if ('' != $wp_query->query_vars['day']) |
|
| 4969 | 4969 | $query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", $wp_query->query_vars['day']); |
| 4970 | 4970 | |
| 4971 | 4971 | $id = (int) $wpdb->get_var($query); |
| 4972 | 4972 | |
| 4973 | - if ( ! $id ) |
|
| 4973 | + if ( ! $id) |
|
| 4974 | 4974 | return; |
| 4975 | 4975 | |
| 4976 | - $link = get_permalink( $id ); |
|
| 4976 | + $link = get_permalink($id); |
|
| 4977 | 4977 | |
| 4978 | - if ( isset( $GLOBALS['wp_query']->query_vars['paged'] ) && $GLOBALS['wp_query']->query_vars['paged'] > 1 ) { |
|
| 4979 | - $link = user_trailingslashit( trailingslashit( $link ) . 'page/' . $GLOBALS['wp_query']->query_vars['paged'] ); |
|
| 4980 | - } elseif( is_embed() ) { |
|
| 4981 | - $link = user_trailingslashit( trailingslashit( $link ) . 'embed' ); |
|
| 4978 | + if (isset($GLOBALS['wp_query']->query_vars['paged']) && $GLOBALS['wp_query']->query_vars['paged'] > 1) { |
|
| 4979 | + $link = user_trailingslashit(trailingslashit($link).'page/'.$GLOBALS['wp_query']->query_vars['paged']); |
|
| 4980 | + } elseif (is_embed()) { |
|
| 4981 | + $link = user_trailingslashit(trailingslashit($link).'embed'); |
|
| 4982 | 4982 | } |
| 4983 | 4983 | |
| 4984 | 4984 | /** |
@@ -4988,13 +4988,13 @@ discard block |
||
| 4988 | 4988 | * |
| 4989 | 4989 | * @param string $link The redirect URL. |
| 4990 | 4990 | */ |
| 4991 | - $link = apply_filters( 'old_slug_redirect_url', $link ); |
|
| 4991 | + $link = apply_filters('old_slug_redirect_url', $link); |
|
| 4992 | 4992 | |
| 4993 | - if ( ! $link ) { |
|
| 4993 | + if ( ! $link) { |
|
| 4994 | 4994 | return; |
| 4995 | 4995 | } |
| 4996 | 4996 | |
| 4997 | - wp_redirect( $link, 301 ); // Permanent redirect |
|
| 4997 | + wp_redirect($link, 301); // Permanent redirect |
|
| 4998 | 4998 | exit; |
| 4999 | 4999 | endif; |
| 5000 | 5000 | } |
@@ -5010,11 +5010,11 @@ discard block |
||
| 5010 | 5010 | * @param WP_Post|object|int $post WP_Post instance or Post ID/object. |
| 5011 | 5011 | * @return bool True when finished. |
| 5012 | 5012 | */ |
| 5013 | -function setup_postdata( $post ) { |
|
| 5013 | +function setup_postdata($post) { |
|
| 5014 | 5014 | global $wp_query; |
| 5015 | 5015 | |
| 5016 | - if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) { |
|
| 5017 | - return $wp_query->setup_postdata( $post ); |
|
| 5016 | + if ( ! empty($wp_query) && $wp_query instanceof WP_Query) { |
|
| 5017 | + return $wp_query->setup_postdata($post); |
|
| 5018 | 5018 | } |
| 5019 | 5019 | |
| 5020 | 5020 | return false; |
@@ -31,226 +31,226 @@ discard block |
||
| 31 | 31 | $caps = array(); |
| 32 | 32 | |
| 33 | 33 | switch ( $cap ) { |
| 34 | - case 'remove_user': |
|
| 35 | - $caps[] = 'remove_users'; |
|
| 36 | - break; |
|
| 37 | - case 'promote_user': |
|
| 38 | - case 'add_users': |
|
| 39 | - $caps[] = 'promote_users'; |
|
| 40 | - break; |
|
| 41 | - case 'edit_user': |
|
| 42 | - case 'edit_users': |
|
| 43 | - // Allow user to edit itself |
|
| 44 | - if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) |
|
| 34 | + case 'remove_user': |
|
| 35 | + $caps[] = 'remove_users'; |
|
| 45 | 36 | break; |
| 46 | - |
|
| 47 | - // In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin. |
|
| 48 | - if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) { |
|
| 49 | - $caps[] = 'do_not_allow'; |
|
| 50 | - } else { |
|
| 51 | - $caps[] = 'edit_users'; // edit_user maps to edit_users. |
|
| 52 | - } |
|
| 53 | - break; |
|
| 54 | - case 'delete_post': |
|
| 55 | - case 'delete_page': |
|
| 56 | - $post = get_post( $args[0] ); |
|
| 57 | - if ( ! $post ) { |
|
| 58 | - $caps[] = 'do_not_allow'; |
|
| 37 | + case 'promote_user': |
|
| 38 | + case 'add_users': |
|
| 39 | + $caps[] = 'promote_users'; |
|
| 59 | 40 | break; |
| 60 | - } |
|
| 41 | + case 'edit_user': |
|
| 42 | + case 'edit_users': |
|
| 43 | + // Allow user to edit itself |
|
| 44 | + if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) |
|
| 45 | + break; |
|
| 61 | 46 | |
| 62 | - if ( 'revision' == $post->post_type ) { |
|
| 63 | - $post = get_post( $post->post_parent ); |
|
| 47 | + // In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin. |
|
| 48 | + if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) { |
|
| 49 | + $caps[] = 'do_not_allow'; |
|
| 50 | + } else { |
|
| 51 | + $caps[] = 'edit_users'; // edit_user maps to edit_users. |
|
| 52 | + } |
|
| 53 | + break; |
|
| 54 | + case 'delete_post': |
|
| 55 | + case 'delete_page': |
|
| 56 | + $post = get_post( $args[0] ); |
|
| 64 | 57 | if ( ! $post ) { |
| 65 | 58 | $caps[] = 'do_not_allow'; |
| 66 | 59 | break; |
| 67 | 60 | } |
| 68 | - } |
|
| 69 | 61 | |
| 70 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 71 | - if ( ! $post_type ) { |
|
| 72 | - /* translators: 1: post type, 2: capability name */ |
|
| 73 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 74 | - $caps[] = 'edit_others_posts'; |
|
| 75 | - break; |
|
| 76 | - } |
|
| 62 | + if ( 'revision' == $post->post_type ) { |
|
| 63 | + $post = get_post( $post->post_parent ); |
|
| 64 | + if ( ! $post ) { |
|
| 65 | + $caps[] = 'do_not_allow'; |
|
| 66 | + break; |
|
| 67 | + } |
|
| 68 | + } |
|
| 77 | 69 | |
| 78 | - if ( ! $post_type->map_meta_cap ) { |
|
| 79 | - $caps[] = $post_type->cap->$cap; |
|
| 80 | - // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 81 | - if ( 'delete_post' == $cap ) |
|
| 82 | - $cap = $post_type->cap->$cap; |
|
| 83 | - break; |
|
| 84 | - } |
|
| 70 | + $post_type = get_post_type_object( $post->post_type ); |
|
| 71 | + if ( ! $post_type ) { |
|
| 72 | + /* translators: 1: post type, 2: capability name */ |
|
| 73 | + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 74 | + $caps[] = 'edit_others_posts'; |
|
| 75 | + break; |
|
| 76 | + } |
|
| 85 | 77 | |
| 86 | - // If the post author is set and the user is the author... |
|
| 87 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 88 | - // If the post is published or scheduled... |
|
| 89 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 90 | - $caps[] = $post_type->cap->delete_published_posts; |
|
| 91 | - } elseif ( 'trash' == $post->post_status ) { |
|
| 92 | - $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 93 | - if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 78 | + if ( ! $post_type->map_meta_cap ) { |
|
| 79 | + $caps[] = $post_type->cap->$cap; |
|
| 80 | + // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 81 | + if ( 'delete_post' == $cap ) |
|
| 82 | + $cap = $post_type->cap->$cap; |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // If the post author is set and the user is the author... |
|
| 87 | + if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 88 | + // If the post is published or scheduled... |
|
| 89 | + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 94 | 90 | $caps[] = $post_type->cap->delete_published_posts; |
| 91 | + } elseif ( 'trash' == $post->post_status ) { |
|
| 92 | + $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 93 | + if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 94 | + $caps[] = $post_type->cap->delete_published_posts; |
|
| 95 | + } else { |
|
| 96 | + $caps[] = $post_type->cap->delete_posts; |
|
| 97 | + } |
|
| 95 | 98 | } else { |
| 99 | + // If the post is draft... |
|
| 96 | 100 | $caps[] = $post_type->cap->delete_posts; |
| 97 | 101 | } |
| 98 | 102 | } else { |
| 99 | - // If the post is draft... |
|
| 100 | - $caps[] = $post_type->cap->delete_posts; |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - // The user is trying to edit someone else's post. |
|
| 104 | - $caps[] = $post_type->cap->delete_others_posts; |
|
| 105 | - // The post is published or scheduled, extra cap required. |
|
| 106 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 107 | - $caps[] = $post_type->cap->delete_published_posts; |
|
| 108 | - } elseif ( 'private' == $post->post_status ) { |
|
| 109 | - $caps[] = $post_type->cap->delete_private_posts; |
|
| 103 | + // The user is trying to edit someone else's post. |
|
| 104 | + $caps[] = $post_type->cap->delete_others_posts; |
|
| 105 | + // The post is published or scheduled, extra cap required. |
|
| 106 | + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 107 | + $caps[] = $post_type->cap->delete_published_posts; |
|
| 108 | + } elseif ( 'private' == $post->post_status ) { |
|
| 109 | + $caps[] = $post_type->cap->delete_private_posts; |
|
| 110 | + } |
|
| 110 | 111 | } |
| 111 | - } |
|
| 112 | - break; |
|
| 113 | - // edit_post breaks down to edit_posts, edit_published_posts, or |
|
| 114 | - // edit_others_posts |
|
| 115 | - case 'edit_post': |
|
| 116 | - case 'edit_page': |
|
| 117 | - $post = get_post( $args[0] ); |
|
| 118 | - if ( ! $post ) { |
|
| 119 | - $caps[] = 'do_not_allow'; |
|
| 120 | 112 | break; |
| 121 | - } |
|
| 122 | - |
|
| 123 | - if ( 'revision' == $post->post_type ) { |
|
| 124 | - $post = get_post( $post->post_parent ); |
|
| 113 | + // edit_post breaks down to edit_posts, edit_published_posts, or |
|
| 114 | + // edit_others_posts |
|
| 115 | + case 'edit_post': |
|
| 116 | + case 'edit_page': |
|
| 117 | + $post = get_post( $args[0] ); |
|
| 125 | 118 | if ( ! $post ) { |
| 126 | 119 | $caps[] = 'do_not_allow'; |
| 127 | 120 | break; |
| 128 | 121 | } |
| 129 | - } |
|
| 130 | 122 | |
| 131 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 132 | - if ( ! $post_type ) { |
|
| 133 | - /* translators: 1: post type, 2: capability name */ |
|
| 134 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 135 | - $caps[] = 'edit_others_posts'; |
|
| 136 | - break; |
|
| 137 | - } |
|
| 123 | + if ( 'revision' == $post->post_type ) { |
|
| 124 | + $post = get_post( $post->post_parent ); |
|
| 125 | + if ( ! $post ) { |
|
| 126 | + $caps[] = 'do_not_allow'; |
|
| 127 | + break; |
|
| 128 | + } |
|
| 129 | + } |
|
| 138 | 130 | |
| 139 | - if ( ! $post_type->map_meta_cap ) { |
|
| 140 | - $caps[] = $post_type->cap->$cap; |
|
| 141 | - // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 142 | - if ( 'edit_post' == $cap ) |
|
| 143 | - $cap = $post_type->cap->$cap; |
|
| 144 | - break; |
|
| 145 | - } |
|
| 131 | + $post_type = get_post_type_object( $post->post_type ); |
|
| 132 | + if ( ! $post_type ) { |
|
| 133 | + /* translators: 1: post type, 2: capability name */ |
|
| 134 | + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 135 | + $caps[] = 'edit_others_posts'; |
|
| 136 | + break; |
|
| 137 | + } |
|
| 146 | 138 | |
| 147 | - // If the post author is set and the user is the author... |
|
| 148 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 149 | - // If the post is published or scheduled... |
|
| 150 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 151 | - $caps[] = $post_type->cap->edit_published_posts; |
|
| 152 | - } elseif ( 'trash' == $post->post_status ) { |
|
| 153 | - $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 154 | - if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 139 | + if ( ! $post_type->map_meta_cap ) { |
|
| 140 | + $caps[] = $post_type->cap->$cap; |
|
| 141 | + // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 142 | + if ( 'edit_post' == $cap ) |
|
| 143 | + $cap = $post_type->cap->$cap; |
|
| 144 | + break; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // If the post author is set and the user is the author... |
|
| 148 | + if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 149 | + // If the post is published or scheduled... |
|
| 150 | + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 155 | 151 | $caps[] = $post_type->cap->edit_published_posts; |
| 152 | + } elseif ( 'trash' == $post->post_status ) { |
|
| 153 | + $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 154 | + if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 155 | + $caps[] = $post_type->cap->edit_published_posts; |
|
| 156 | + } else { |
|
| 157 | + $caps[] = $post_type->cap->edit_posts; |
|
| 158 | + } |
|
| 156 | 159 | } else { |
| 160 | + // If the post is draft... |
|
| 157 | 161 | $caps[] = $post_type->cap->edit_posts; |
| 158 | 162 | } |
| 159 | 163 | } else { |
| 160 | - // If the post is draft... |
|
| 161 | - $caps[] = $post_type->cap->edit_posts; |
|
| 162 | - } |
|
| 163 | - } else { |
|
| 164 | - // The user is trying to edit someone else's post. |
|
| 165 | - $caps[] = $post_type->cap->edit_others_posts; |
|
| 166 | - // The post is published or scheduled, extra cap required. |
|
| 167 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 168 | - $caps[] = $post_type->cap->edit_published_posts; |
|
| 169 | - } elseif ( 'private' == $post->post_status ) { |
|
| 170 | - $caps[] = $post_type->cap->edit_private_posts; |
|
| 164 | + // The user is trying to edit someone else's post. |
|
| 165 | + $caps[] = $post_type->cap->edit_others_posts; |
|
| 166 | + // The post is published or scheduled, extra cap required. |
|
| 167 | + if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 168 | + $caps[] = $post_type->cap->edit_published_posts; |
|
| 169 | + } elseif ( 'private' == $post->post_status ) { |
|
| 170 | + $caps[] = $post_type->cap->edit_private_posts; |
|
| 171 | + } |
|
| 171 | 172 | } |
| 172 | - } |
|
| 173 | - break; |
|
| 174 | - case 'read_post': |
|
| 175 | - case 'read_page': |
|
| 176 | - $post = get_post( $args[0] ); |
|
| 177 | - if ( ! $post ) { |
|
| 178 | - $caps[] = 'do_not_allow'; |
|
| 179 | 173 | break; |
| 180 | - } |
|
| 181 | - |
|
| 182 | - if ( 'revision' == $post->post_type ) { |
|
| 183 | - $post = get_post( $post->post_parent ); |
|
| 174 | + case 'read_post': |
|
| 175 | + case 'read_page': |
|
| 176 | + $post = get_post( $args[0] ); |
|
| 184 | 177 | if ( ! $post ) { |
| 185 | 178 | $caps[] = 'do_not_allow'; |
| 186 | 179 | break; |
| 187 | 180 | } |
| 188 | - } |
|
| 189 | 181 | |
| 190 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 191 | - if ( ! $post_type ) { |
|
| 192 | - /* translators: 1: post type, 2: capability name */ |
|
| 193 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 194 | - $caps[] = 'edit_others_posts'; |
|
| 195 | - break; |
|
| 196 | - } |
|
| 182 | + if ( 'revision' == $post->post_type ) { |
|
| 183 | + $post = get_post( $post->post_parent ); |
|
| 184 | + if ( ! $post ) { |
|
| 185 | + $caps[] = 'do_not_allow'; |
|
| 186 | + break; |
|
| 187 | + } |
|
| 188 | + } |
|
| 197 | 189 | |
| 198 | - if ( ! $post_type->map_meta_cap ) { |
|
| 199 | - $caps[] = $post_type->cap->$cap; |
|
| 200 | - // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 201 | - if ( 'read_post' == $cap ) |
|
| 202 | - $cap = $post_type->cap->$cap; |
|
| 203 | - break; |
|
| 204 | - } |
|
| 190 | + $post_type = get_post_type_object( $post->post_type ); |
|
| 191 | + if ( ! $post_type ) { |
|
| 192 | + /* translators: 1: post type, 2: capability name */ |
|
| 193 | + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 194 | + $caps[] = 'edit_others_posts'; |
|
| 195 | + break; |
|
| 196 | + } |
|
| 205 | 197 | |
| 206 | - $status_obj = get_post_status_object( $post->post_status ); |
|
| 207 | - if ( $status_obj->public ) { |
|
| 208 | - $caps[] = $post_type->cap->read; |
|
| 209 | - break; |
|
| 210 | - } |
|
| 198 | + if ( ! $post_type->map_meta_cap ) { |
|
| 199 | + $caps[] = $post_type->cap->$cap; |
|
| 200 | + // Prior to 3.1 we would re-call map_meta_cap here. |
|
| 201 | + if ( 'read_post' == $cap ) |
|
| 202 | + $cap = $post_type->cap->$cap; |
|
| 203 | + break; |
|
| 204 | + } |
|
| 211 | 205 | |
| 212 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 213 | - $caps[] = $post_type->cap->read; |
|
| 214 | - } elseif ( $status_obj->private ) { |
|
| 215 | - $caps[] = $post_type->cap->read_private_posts; |
|
| 216 | - } else { |
|
| 217 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 218 | - } |
|
| 219 | - break; |
|
| 220 | - case 'publish_post': |
|
| 221 | - $post = get_post( $args[0] ); |
|
| 222 | - if ( ! $post ) { |
|
| 223 | - $caps[] = 'do_not_allow'; |
|
| 224 | - break; |
|
| 225 | - } |
|
| 206 | + $status_obj = get_post_status_object( $post->post_status ); |
|
| 207 | + if ( $status_obj->public ) { |
|
| 208 | + $caps[] = $post_type->cap->read; |
|
| 209 | + break; |
|
| 210 | + } |
|
| 226 | 211 | |
| 227 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 228 | - if ( ! $post_type ) { |
|
| 229 | - /* translators: 1: post type, 2: capability name */ |
|
| 230 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 231 | - $caps[] = 'edit_others_posts'; |
|
| 212 | + if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 213 | + $caps[] = $post_type->cap->read; |
|
| 214 | + } elseif ( $status_obj->private ) { |
|
| 215 | + $caps[] = $post_type->cap->read_private_posts; |
|
| 216 | + } else { |
|
| 217 | + $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 218 | + } |
|
| 232 | 219 | break; |
| 233 | - } |
|
| 220 | + case 'publish_post': |
|
| 221 | + $post = get_post( $args[0] ); |
|
| 222 | + if ( ! $post ) { |
|
| 223 | + $caps[] = 'do_not_allow'; |
|
| 224 | + break; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $post_type = get_post_type_object( $post->post_type ); |
|
| 228 | + if ( ! $post_type ) { |
|
| 229 | + /* translators: 1: post type, 2: capability name */ |
|
| 230 | + _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 231 | + $caps[] = 'edit_others_posts'; |
|
| 232 | + break; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - $caps[] = $post_type->cap->publish_posts; |
|
| 236 | - break; |
|
| 237 | - case 'edit_post_meta': |
|
| 238 | - case 'delete_post_meta': |
|
| 239 | - case 'add_post_meta': |
|
| 240 | - $post = get_post( $args[0] ); |
|
| 241 | - if ( ! $post ) { |
|
| 242 | - $caps[] = 'do_not_allow'; |
|
| 235 | + $caps[] = $post_type->cap->publish_posts; |
|
| 243 | 236 | break; |
| 244 | - } |
|
| 237 | + case 'edit_post_meta': |
|
| 238 | + case 'delete_post_meta': |
|
| 239 | + case 'add_post_meta': |
|
| 240 | + $post = get_post( $args[0] ); |
|
| 241 | + if ( ! $post ) { |
|
| 242 | + $caps[] = 'do_not_allow'; |
|
| 243 | + break; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - $post_type = get_post_type( $post ); |
|
| 246 | + $post_type = get_post_type( $post ); |
|
| 247 | 247 | |
| 248 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 248 | + $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 249 | 249 | |
| 250 | - $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; |
|
| 250 | + $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; |
|
| 251 | 251 | |
| 252 | - if ( $meta_key && ( has_filter( "auth_post_meta_{$meta_key}" ) || has_filter( "auth_post_{$post_type}_meta_{$meta_key}" ) ) ) { |
|
| 253 | - /** |
|
| 252 | + if ( $meta_key && ( has_filter( "auth_post_meta_{$meta_key}" ) || has_filter( "auth_post_{$post_type}_meta_{$meta_key}" ) ) ) { |
|
| 253 | + /** |
|
| 254 | 254 | * Filters whether the user is allowed to add post meta to a post. |
| 255 | 255 | * |
| 256 | 256 | * The dynamic portion of the hook name, `$meta_key`, refers to the |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | * @param string $cap Capability name. |
| 266 | 266 | * @param array $caps User capabilities. |
| 267 | 267 | */ |
| 268 | - $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 268 | + $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 269 | 269 | |
| 270 | - /** |
|
| 270 | + /** |
|
| 271 | 271 | * Filters whether the user is allowed to add post meta to a post of a given type. |
| 272 | 272 | * |
| 273 | 273 | * The dynamic portions of the hook name, `$meta_key` and `$post_type`, |
@@ -282,131 +282,131 @@ discard block |
||
| 282 | 282 | * @param string $cap Capability name. |
| 283 | 283 | * @param array $caps User capabilities. |
| 284 | 284 | */ |
| 285 | - $allowed = apply_filters( "auth_post_{$post_type}_meta_{$meta_key}", $allowed, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 285 | + $allowed = apply_filters( "auth_post_{$post_type}_meta_{$meta_key}", $allowed, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 286 | 286 | |
| 287 | - if ( ! $allowed ) |
|
| 287 | + if ( ! $allowed ) |
|
| 288 | + $caps[] = $cap; |
|
| 289 | + } elseif ( $meta_key && is_protected_meta( $meta_key, 'post' ) ) { |
|
| 288 | 290 | $caps[] = $cap; |
| 289 | - } elseif ( $meta_key && is_protected_meta( $meta_key, 'post' ) ) { |
|
| 290 | - $caps[] = $cap; |
|
| 291 | - } |
|
| 292 | - break; |
|
| 293 | - case 'edit_comment': |
|
| 294 | - $comment = get_comment( $args[0] ); |
|
| 295 | - if ( ! $comment ) { |
|
| 296 | - $caps[] = 'do_not_allow'; |
|
| 291 | + } |
|
| 297 | 292 | break; |
| 298 | - } |
|
| 293 | + case 'edit_comment': |
|
| 294 | + $comment = get_comment( $args[0] ); |
|
| 295 | + if ( ! $comment ) { |
|
| 296 | + $caps[] = 'do_not_allow'; |
|
| 297 | + break; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - $post = get_post( $comment->comment_post_ID ); |
|
| 300 | + $post = get_post( $comment->comment_post_ID ); |
|
| 301 | 301 | |
| 302 | - /* |
|
| 302 | + /* |
|
| 303 | 303 | * If the post doesn't exist, we have an orphaned comment. |
| 304 | 304 | * Fall back to the edit_posts capability, instead. |
| 305 | 305 | */ |
| 306 | - if ( $post ) { |
|
| 307 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 308 | - } else { |
|
| 309 | - $caps = map_meta_cap( 'edit_posts', $user_id ); |
|
| 310 | - } |
|
| 311 | - break; |
|
| 312 | - case 'unfiltered_upload': |
|
| 313 | - if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) |
|
| 314 | - $caps[] = $cap; |
|
| 315 | - else |
|
| 316 | - $caps[] = 'do_not_allow'; |
|
| 317 | - break; |
|
| 318 | - case 'unfiltered_html' : |
|
| 319 | - // Disallow unfiltered_html for all users, even admins and super admins. |
|
| 320 | - if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) |
|
| 321 | - $caps[] = 'do_not_allow'; |
|
| 322 | - elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 323 | - $caps[] = 'do_not_allow'; |
|
| 324 | - else |
|
| 325 | - $caps[] = $cap; |
|
| 326 | - break; |
|
| 327 | - case 'edit_files': |
|
| 328 | - case 'edit_plugins': |
|
| 329 | - case 'edit_themes': |
|
| 330 | - // Disallow the file editors. |
|
| 331 | - if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) |
|
| 332 | - $caps[] = 'do_not_allow'; |
|
| 333 | - elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) |
|
| 334 | - $caps[] = 'do_not_allow'; |
|
| 335 | - elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 336 | - $caps[] = 'do_not_allow'; |
|
| 337 | - else |
|
| 338 | - $caps[] = $cap; |
|
| 339 | - break; |
|
| 340 | - case 'update_plugins': |
|
| 341 | - case 'delete_plugins': |
|
| 342 | - case 'install_plugins': |
|
| 343 | - case 'upload_plugins': |
|
| 344 | - case 'update_themes': |
|
| 345 | - case 'delete_themes': |
|
| 346 | - case 'install_themes': |
|
| 347 | - case 'upload_themes': |
|
| 348 | - case 'update_core': |
|
| 349 | - // Disallow anything that creates, deletes, or updates core, plugin, or theme files. |
|
| 350 | - // Files in uploads are excepted. |
|
| 351 | - if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) { |
|
| 352 | - $caps[] = 'do_not_allow'; |
|
| 353 | - } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { |
|
| 354 | - $caps[] = 'do_not_allow'; |
|
| 355 | - } elseif ( 'upload_themes' === $cap ) { |
|
| 356 | - $caps[] = 'install_themes'; |
|
| 357 | - } elseif ( 'upload_plugins' === $cap ) { |
|
| 358 | - $caps[] = 'install_plugins'; |
|
| 359 | - } else { |
|
| 360 | - $caps[] = $cap; |
|
| 361 | - } |
|
| 362 | - break; |
|
| 363 | - case 'activate_plugins': |
|
| 364 | - $caps[] = $cap; |
|
| 365 | - if ( is_multisite() ) { |
|
| 366 | - // update_, install_, and delete_ are handled above with is_super_admin(). |
|
| 367 | - $menu_perms = get_site_option( 'menu_items', array() ); |
|
| 368 | - if ( empty( $menu_perms['plugins'] ) ) |
|
| 369 | - $caps[] = 'manage_network_plugins'; |
|
| 370 | - } |
|
| 371 | - break; |
|
| 372 | - case 'delete_user': |
|
| 373 | - case 'delete_users': |
|
| 374 | - // If multisite only super admins can delete users. |
|
| 375 | - if ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 376 | - $caps[] = 'do_not_allow'; |
|
| 377 | - else |
|
| 378 | - $caps[] = 'delete_users'; // delete_user maps to delete_users. |
|
| 379 | - break; |
|
| 380 | - case 'create_users': |
|
| 381 | - if ( !is_multisite() ) |
|
| 382 | - $caps[] = $cap; |
|
| 383 | - elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) |
|
| 384 | - $caps[] = $cap; |
|
| 385 | - else |
|
| 386 | - $caps[] = 'do_not_allow'; |
|
| 387 | - break; |
|
| 388 | - case 'manage_links' : |
|
| 389 | - if ( get_option( 'link_manager_enabled' ) ) |
|
| 306 | + if ( $post ) { |
|
| 307 | + $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 308 | + } else { |
|
| 309 | + $caps = map_meta_cap( 'edit_posts', $user_id ); |
|
| 310 | + } |
|
| 311 | + break; |
|
| 312 | + case 'unfiltered_upload': |
|
| 313 | + if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) |
|
| 314 | + $caps[] = $cap; |
|
| 315 | + else |
|
| 316 | + $caps[] = 'do_not_allow'; |
|
| 317 | + break; |
|
| 318 | + case 'unfiltered_html' : |
|
| 319 | + // Disallow unfiltered_html for all users, even admins and super admins. |
|
| 320 | + if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) |
|
| 321 | + $caps[] = 'do_not_allow'; |
|
| 322 | + elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 323 | + $caps[] = 'do_not_allow'; |
|
| 324 | + else |
|
| 325 | + $caps[] = $cap; |
|
| 326 | + break; |
|
| 327 | + case 'edit_files': |
|
| 328 | + case 'edit_plugins': |
|
| 329 | + case 'edit_themes': |
|
| 330 | + // Disallow the file editors. |
|
| 331 | + if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) |
|
| 332 | + $caps[] = 'do_not_allow'; |
|
| 333 | + elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) |
|
| 334 | + $caps[] = 'do_not_allow'; |
|
| 335 | + elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 336 | + $caps[] = 'do_not_allow'; |
|
| 337 | + else |
|
| 338 | + $caps[] = $cap; |
|
| 339 | + break; |
|
| 340 | + case 'update_plugins': |
|
| 341 | + case 'delete_plugins': |
|
| 342 | + case 'install_plugins': |
|
| 343 | + case 'upload_plugins': |
|
| 344 | + case 'update_themes': |
|
| 345 | + case 'delete_themes': |
|
| 346 | + case 'install_themes': |
|
| 347 | + case 'upload_themes': |
|
| 348 | + case 'update_core': |
|
| 349 | + // Disallow anything that creates, deletes, or updates core, plugin, or theme files. |
|
| 350 | + // Files in uploads are excepted. |
|
| 351 | + if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) { |
|
| 352 | + $caps[] = 'do_not_allow'; |
|
| 353 | + } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { |
|
| 354 | + $caps[] = 'do_not_allow'; |
|
| 355 | + } elseif ( 'upload_themes' === $cap ) { |
|
| 356 | + $caps[] = 'install_themes'; |
|
| 357 | + } elseif ( 'upload_plugins' === $cap ) { |
|
| 358 | + $caps[] = 'install_plugins'; |
|
| 359 | + } else { |
|
| 360 | + $caps[] = $cap; |
|
| 361 | + } |
|
| 362 | + break; |
|
| 363 | + case 'activate_plugins': |
|
| 390 | 364 | $caps[] = $cap; |
| 391 | - else |
|
| 392 | - $caps[] = 'do_not_allow'; |
|
| 393 | - break; |
|
| 394 | - case 'customize' : |
|
| 395 | - $caps[] = 'edit_theme_options'; |
|
| 396 | - break; |
|
| 397 | - case 'delete_site': |
|
| 398 | - $caps[] = 'manage_options'; |
|
| 399 | - break; |
|
| 400 | - default: |
|
| 401 | - // Handle meta capabilities for custom post types. |
|
| 402 | - global $post_type_meta_caps; |
|
| 403 | - if ( isset( $post_type_meta_caps[ $cap ] ) ) { |
|
| 404 | - $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); |
|
| 405 | - return call_user_func_array( 'map_meta_cap', $args ); |
|
| 406 | - } |
|
| 365 | + if ( is_multisite() ) { |
|
| 366 | + // update_, install_, and delete_ are handled above with is_super_admin(). |
|
| 367 | + $menu_perms = get_site_option( 'menu_items', array() ); |
|
| 368 | + if ( empty( $menu_perms['plugins'] ) ) |
|
| 369 | + $caps[] = 'manage_network_plugins'; |
|
| 370 | + } |
|
| 371 | + break; |
|
| 372 | + case 'delete_user': |
|
| 373 | + case 'delete_users': |
|
| 374 | + // If multisite only super admins can delete users. |
|
| 375 | + if ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 376 | + $caps[] = 'do_not_allow'; |
|
| 377 | + else |
|
| 378 | + $caps[] = 'delete_users'; // delete_user maps to delete_users. |
|
| 379 | + break; |
|
| 380 | + case 'create_users': |
|
| 381 | + if ( !is_multisite() ) |
|
| 382 | + $caps[] = $cap; |
|
| 383 | + elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) |
|
| 384 | + $caps[] = $cap; |
|
| 385 | + else |
|
| 386 | + $caps[] = 'do_not_allow'; |
|
| 387 | + break; |
|
| 388 | + case 'manage_links' : |
|
| 389 | + if ( get_option( 'link_manager_enabled' ) ) |
|
| 390 | + $caps[] = $cap; |
|
| 391 | + else |
|
| 392 | + $caps[] = 'do_not_allow'; |
|
| 393 | + break; |
|
| 394 | + case 'customize' : |
|
| 395 | + $caps[] = 'edit_theme_options'; |
|
| 396 | + break; |
|
| 397 | + case 'delete_site': |
|
| 398 | + $caps[] = 'manage_options'; |
|
| 399 | + break; |
|
| 400 | + default: |
|
| 401 | + // Handle meta capabilities for custom post types. |
|
| 402 | + global $post_type_meta_caps; |
|
| 403 | + if ( isset( $post_type_meta_caps[ $cap ] ) ) { |
|
| 404 | + $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); |
|
| 405 | + return call_user_func_array( 'map_meta_cap', $args ); |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - // If no meta caps match, return the original cap. |
|
| 409 | - $caps[] = $cap; |
|
| 408 | + // If no meta caps match, return the original cap. |
|
| 409 | + $caps[] = $cap; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | * 'edit_others_posts', etc. The parameter is accessed via func_get_args(). |
| 27 | 27 | * @return array Actual capabilities for meta capability. |
| 28 | 28 | */ |
| 29 | -function map_meta_cap( $cap, $user_id ) { |
|
| 30 | - $args = array_slice( func_get_args(), 2 ); |
|
| 29 | +function map_meta_cap($cap, $user_id) { |
|
| 30 | + $args = array_slice(func_get_args(), 2); |
|
| 31 | 31 | $caps = array(); |
| 32 | 32 | |
| 33 | - switch ( $cap ) { |
|
| 33 | + switch ($cap) { |
|
| 34 | 34 | case 'remove_user': |
| 35 | 35 | $caps[] = 'remove_users'; |
| 36 | 36 | break; |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | case 'edit_user': |
| 42 | 42 | case 'edit_users': |
| 43 | 43 | // Allow user to edit itself |
| 44 | - if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) |
|
| 44 | + if ('edit_user' == $cap && isset($args[0]) && $user_id == $args[0]) |
|
| 45 | 45 | break; |
| 46 | 46 | |
| 47 | 47 | // In multisite the user must have manage_network_users caps. If editing a super admin, the user must be a super admin. |
| 48 | - if ( is_multisite() && ( ( ! is_super_admin( $user_id ) && 'edit_user' === $cap && is_super_admin( $args[0] ) ) || ! user_can( $user_id, 'manage_network_users' ) ) ) { |
|
| 48 | + if (is_multisite() && (( ! is_super_admin($user_id) && 'edit_user' === $cap && is_super_admin($args[0])) || ! user_can($user_id, 'manage_network_users'))) { |
|
| 49 | 49 | $caps[] = 'do_not_allow'; |
| 50 | 50 | } else { |
| 51 | 51 | $caps[] = 'edit_users'; // edit_user maps to edit_users. |
@@ -53,44 +53,44 @@ discard block |
||
| 53 | 53 | break; |
| 54 | 54 | case 'delete_post': |
| 55 | 55 | case 'delete_page': |
| 56 | - $post = get_post( $args[0] ); |
|
| 57 | - if ( ! $post ) { |
|
| 56 | + $post = get_post($args[0]); |
|
| 57 | + if ( ! $post) { |
|
| 58 | 58 | $caps[] = 'do_not_allow'; |
| 59 | 59 | break; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( 'revision' == $post->post_type ) { |
|
| 63 | - $post = get_post( $post->post_parent ); |
|
| 64 | - if ( ! $post ) { |
|
| 62 | + if ('revision' == $post->post_type) { |
|
| 63 | + $post = get_post($post->post_parent); |
|
| 64 | + if ( ! $post) { |
|
| 65 | 65 | $caps[] = 'do_not_allow'; |
| 66 | 66 | break; |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 71 | - if ( ! $post_type ) { |
|
| 70 | + $post_type = get_post_type_object($post->post_type); |
|
| 71 | + if ( ! $post_type) { |
|
| 72 | 72 | /* translators: 1: post type, 2: capability name */ |
| 73 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 73 | + _doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0'); |
|
| 74 | 74 | $caps[] = 'edit_others_posts'; |
| 75 | 75 | break; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( ! $post_type->map_meta_cap ) { |
|
| 78 | + if ( ! $post_type->map_meta_cap) { |
|
| 79 | 79 | $caps[] = $post_type->cap->$cap; |
| 80 | 80 | // Prior to 3.1 we would re-call map_meta_cap here. |
| 81 | - if ( 'delete_post' == $cap ) |
|
| 81 | + if ('delete_post' == $cap) |
|
| 82 | 82 | $cap = $post_type->cap->$cap; |
| 83 | 83 | break; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // If the post author is set and the user is the author... |
| 87 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 87 | + if ($post->post_author && $user_id == $post->post_author) { |
|
| 88 | 88 | // If the post is published or scheduled... |
| 89 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 89 | + if (in_array($post->post_status, array('publish', 'future'), true)) { |
|
| 90 | 90 | $caps[] = $post_type->cap->delete_published_posts; |
| 91 | - } elseif ( 'trash' == $post->post_status ) { |
|
| 92 | - $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 93 | - if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 91 | + } elseif ('trash' == $post->post_status) { |
|
| 92 | + $status = get_post_meta($post->ID, '_wp_trash_meta_status', true); |
|
| 93 | + if (in_array($status, array('publish', 'future'), true)) { |
|
| 94 | 94 | $caps[] = $post_type->cap->delete_published_posts; |
| 95 | 95 | } else { |
| 96 | 96 | $caps[] = $post_type->cap->delete_posts; |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | // The user is trying to edit someone else's post. |
| 104 | 104 | $caps[] = $post_type->cap->delete_others_posts; |
| 105 | 105 | // The post is published or scheduled, extra cap required. |
| 106 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 106 | + if (in_array($post->post_status, array('publish', 'future'), true)) { |
|
| 107 | 107 | $caps[] = $post_type->cap->delete_published_posts; |
| 108 | - } elseif ( 'private' == $post->post_status ) { |
|
| 108 | + } elseif ('private' == $post->post_status) { |
|
| 109 | 109 | $caps[] = $post_type->cap->delete_private_posts; |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -114,44 +114,44 @@ discard block |
||
| 114 | 114 | // edit_others_posts |
| 115 | 115 | case 'edit_post': |
| 116 | 116 | case 'edit_page': |
| 117 | - $post = get_post( $args[0] ); |
|
| 118 | - if ( ! $post ) { |
|
| 117 | + $post = get_post($args[0]); |
|
| 118 | + if ( ! $post) { |
|
| 119 | 119 | $caps[] = 'do_not_allow'; |
| 120 | 120 | break; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( 'revision' == $post->post_type ) { |
|
| 124 | - $post = get_post( $post->post_parent ); |
|
| 125 | - if ( ! $post ) { |
|
| 123 | + if ('revision' == $post->post_type) { |
|
| 124 | + $post = get_post($post->post_parent); |
|
| 125 | + if ( ! $post) { |
|
| 126 | 126 | $caps[] = 'do_not_allow'; |
| 127 | 127 | break; |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 132 | - if ( ! $post_type ) { |
|
| 131 | + $post_type = get_post_type_object($post->post_type); |
|
| 132 | + if ( ! $post_type) { |
|
| 133 | 133 | /* translators: 1: post type, 2: capability name */ |
| 134 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 134 | + _doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0'); |
|
| 135 | 135 | $caps[] = 'edit_others_posts'; |
| 136 | 136 | break; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( ! $post_type->map_meta_cap ) { |
|
| 139 | + if ( ! $post_type->map_meta_cap) { |
|
| 140 | 140 | $caps[] = $post_type->cap->$cap; |
| 141 | 141 | // Prior to 3.1 we would re-call map_meta_cap here. |
| 142 | - if ( 'edit_post' == $cap ) |
|
| 142 | + if ('edit_post' == $cap) |
|
| 143 | 143 | $cap = $post_type->cap->$cap; |
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // If the post author is set and the user is the author... |
| 148 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 148 | + if ($post->post_author && $user_id == $post->post_author) { |
|
| 149 | 149 | // If the post is published or scheduled... |
| 150 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 150 | + if (in_array($post->post_status, array('publish', 'future'), true)) { |
|
| 151 | 151 | $caps[] = $post_type->cap->edit_published_posts; |
| 152 | - } elseif ( 'trash' == $post->post_status ) { |
|
| 153 | - $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
| 154 | - if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
| 152 | + } elseif ('trash' == $post->post_status) { |
|
| 153 | + $status = get_post_meta($post->ID, '_wp_trash_meta_status', true); |
|
| 154 | + if (in_array($status, array('publish', 'future'), true)) { |
|
| 155 | 155 | $caps[] = $post_type->cap->edit_published_posts; |
| 156 | 156 | } else { |
| 157 | 157 | $caps[] = $post_type->cap->edit_posts; |
@@ -164,70 +164,70 @@ discard block |
||
| 164 | 164 | // The user is trying to edit someone else's post. |
| 165 | 165 | $caps[] = $post_type->cap->edit_others_posts; |
| 166 | 166 | // The post is published or scheduled, extra cap required. |
| 167 | - if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
| 167 | + if (in_array($post->post_status, array('publish', 'future'), true)) { |
|
| 168 | 168 | $caps[] = $post_type->cap->edit_published_posts; |
| 169 | - } elseif ( 'private' == $post->post_status ) { |
|
| 169 | + } elseif ('private' == $post->post_status) { |
|
| 170 | 170 | $caps[] = $post_type->cap->edit_private_posts; |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | break; |
| 174 | 174 | case 'read_post': |
| 175 | 175 | case 'read_page': |
| 176 | - $post = get_post( $args[0] ); |
|
| 177 | - if ( ! $post ) { |
|
| 176 | + $post = get_post($args[0]); |
|
| 177 | + if ( ! $post) { |
|
| 178 | 178 | $caps[] = 'do_not_allow'; |
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if ( 'revision' == $post->post_type ) { |
|
| 183 | - $post = get_post( $post->post_parent ); |
|
| 184 | - if ( ! $post ) { |
|
| 182 | + if ('revision' == $post->post_type) { |
|
| 183 | + $post = get_post($post->post_parent); |
|
| 184 | + if ( ! $post) { |
|
| 185 | 185 | $caps[] = 'do_not_allow'; |
| 186 | 186 | break; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 191 | - if ( ! $post_type ) { |
|
| 190 | + $post_type = get_post_type_object($post->post_type); |
|
| 191 | + if ( ! $post_type) { |
|
| 192 | 192 | /* translators: 1: post type, 2: capability name */ |
| 193 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 193 | + _doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0'); |
|
| 194 | 194 | $caps[] = 'edit_others_posts'; |
| 195 | 195 | break; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( ! $post_type->map_meta_cap ) { |
|
| 198 | + if ( ! $post_type->map_meta_cap) { |
|
| 199 | 199 | $caps[] = $post_type->cap->$cap; |
| 200 | 200 | // Prior to 3.1 we would re-call map_meta_cap here. |
| 201 | - if ( 'read_post' == $cap ) |
|
| 201 | + if ('read_post' == $cap) |
|
| 202 | 202 | $cap = $post_type->cap->$cap; |
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $status_obj = get_post_status_object( $post->post_status ); |
|
| 207 | - if ( $status_obj->public ) { |
|
| 206 | + $status_obj = get_post_status_object($post->post_status); |
|
| 207 | + if ($status_obj->public) { |
|
| 208 | 208 | $caps[] = $post_type->cap->read; |
| 209 | 209 | break; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if ( $post->post_author && $user_id == $post->post_author ) { |
|
| 212 | + if ($post->post_author && $user_id == $post->post_author) { |
|
| 213 | 213 | $caps[] = $post_type->cap->read; |
| 214 | - } elseif ( $status_obj->private ) { |
|
| 214 | + } elseif ($status_obj->private) { |
|
| 215 | 215 | $caps[] = $post_type->cap->read_private_posts; |
| 216 | 216 | } else { |
| 217 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 217 | + $caps = map_meta_cap('edit_post', $user_id, $post->ID); |
|
| 218 | 218 | } |
| 219 | 219 | break; |
| 220 | 220 | case 'publish_post': |
| 221 | - $post = get_post( $args[0] ); |
|
| 222 | - if ( ! $post ) { |
|
| 221 | + $post = get_post($args[0]); |
|
| 222 | + if ( ! $post) { |
|
| 223 | 223 | $caps[] = 'do_not_allow'; |
| 224 | 224 | break; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 228 | - if ( ! $post_type ) { |
|
| 227 | + $post_type = get_post_type_object($post->post_type); |
|
| 228 | + if ( ! $post_type) { |
|
| 229 | 229 | /* translators: 1: post type, 2: capability name */ |
| 230 | - _doing_it_wrong( __FUNCTION__, sprintf( __( 'The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.' ), $post->post_type, $cap ), '4.4.0' ); |
|
| 230 | + _doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0'); |
|
| 231 | 231 | $caps[] = 'edit_others_posts'; |
| 232 | 232 | break; |
| 233 | 233 | } |
@@ -237,19 +237,19 @@ discard block |
||
| 237 | 237 | case 'edit_post_meta': |
| 238 | 238 | case 'delete_post_meta': |
| 239 | 239 | case 'add_post_meta': |
| 240 | - $post = get_post( $args[0] ); |
|
| 241 | - if ( ! $post ) { |
|
| 240 | + $post = get_post($args[0]); |
|
| 241 | + if ( ! $post) { |
|
| 242 | 242 | $caps[] = 'do_not_allow'; |
| 243 | 243 | break; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $post_type = get_post_type( $post ); |
|
| 246 | + $post_type = get_post_type($post); |
|
| 247 | 247 | |
| 248 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 248 | + $caps = map_meta_cap('edit_post', $user_id, $post->ID); |
|
| 249 | 249 | |
| 250 | - $meta_key = isset( $args[ 1 ] ) ? $args[ 1 ] : false; |
|
| 250 | + $meta_key = isset($args[1]) ? $args[1] : false; |
|
| 251 | 251 | |
| 252 | - if ( $meta_key && ( has_filter( "auth_post_meta_{$meta_key}" ) || has_filter( "auth_post_{$post_type}_meta_{$meta_key}" ) ) ) { |
|
| 252 | + if ($meta_key && (has_filter("auth_post_meta_{$meta_key}") || has_filter("auth_post_{$post_type}_meta_{$meta_key}"))) { |
|
| 253 | 253 | /** |
| 254 | 254 | * Filters whether the user is allowed to add post meta to a post. |
| 255 | 255 | * |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param string $cap Capability name. |
| 266 | 266 | * @param array $caps User capabilities. |
| 267 | 267 | */ |
| 268 | - $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 268 | + $allowed = apply_filters("auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps); |
|
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * Filters whether the user is allowed to add post meta to a post of a given type. |
@@ -282,44 +282,44 @@ discard block |
||
| 282 | 282 | * @param string $cap Capability name. |
| 283 | 283 | * @param array $caps User capabilities. |
| 284 | 284 | */ |
| 285 | - $allowed = apply_filters( "auth_post_{$post_type}_meta_{$meta_key}", $allowed, $meta_key, $post->ID, $user_id, $cap, $caps ); |
|
| 285 | + $allowed = apply_filters("auth_post_{$post_type}_meta_{$meta_key}", $allowed, $meta_key, $post->ID, $user_id, $cap, $caps); |
|
| 286 | 286 | |
| 287 | - if ( ! $allowed ) |
|
| 287 | + if ( ! $allowed) |
|
| 288 | 288 | $caps[] = $cap; |
| 289 | - } elseif ( $meta_key && is_protected_meta( $meta_key, 'post' ) ) { |
|
| 289 | + } elseif ($meta_key && is_protected_meta($meta_key, 'post')) { |
|
| 290 | 290 | $caps[] = $cap; |
| 291 | 291 | } |
| 292 | 292 | break; |
| 293 | 293 | case 'edit_comment': |
| 294 | - $comment = get_comment( $args[0] ); |
|
| 295 | - if ( ! $comment ) { |
|
| 294 | + $comment = get_comment($args[0]); |
|
| 295 | + if ( ! $comment) { |
|
| 296 | 296 | $caps[] = 'do_not_allow'; |
| 297 | 297 | break; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - $post = get_post( $comment->comment_post_ID ); |
|
| 300 | + $post = get_post($comment->comment_post_ID); |
|
| 301 | 301 | |
| 302 | 302 | /* |
| 303 | 303 | * If the post doesn't exist, we have an orphaned comment. |
| 304 | 304 | * Fall back to the edit_posts capability, instead. |
| 305 | 305 | */ |
| 306 | - if ( $post ) { |
|
| 307 | - $caps = map_meta_cap( 'edit_post', $user_id, $post->ID ); |
|
| 306 | + if ($post) { |
|
| 307 | + $caps = map_meta_cap('edit_post', $user_id, $post->ID); |
|
| 308 | 308 | } else { |
| 309 | - $caps = map_meta_cap( 'edit_posts', $user_id ); |
|
| 309 | + $caps = map_meta_cap('edit_posts', $user_id); |
|
| 310 | 310 | } |
| 311 | 311 | break; |
| 312 | 312 | case 'unfiltered_upload': |
| 313 | - if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) ) |
|
| 313 | + if (defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( ! is_multisite() || is_super_admin($user_id))) |
|
| 314 | 314 | $caps[] = $cap; |
| 315 | 315 | else |
| 316 | 316 | $caps[] = 'do_not_allow'; |
| 317 | 317 | break; |
| 318 | 318 | case 'unfiltered_html' : |
| 319 | 319 | // Disallow unfiltered_html for all users, even admins and super admins. |
| 320 | - if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) |
|
| 320 | + if (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) |
|
| 321 | 321 | $caps[] = 'do_not_allow'; |
| 322 | - elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 322 | + elseif (is_multisite() && ! is_super_admin($user_id)) |
|
| 323 | 323 | $caps[] = 'do_not_allow'; |
| 324 | 324 | else |
| 325 | 325 | $caps[] = $cap; |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | case 'edit_plugins': |
| 329 | 329 | case 'edit_themes': |
| 330 | 330 | // Disallow the file editors. |
| 331 | - if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT ) |
|
| 331 | + if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) |
|
| 332 | 332 | $caps[] = 'do_not_allow'; |
| 333 | - elseif ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) |
|
| 333 | + elseif (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) |
|
| 334 | 334 | $caps[] = 'do_not_allow'; |
| 335 | - elseif ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 335 | + elseif (is_multisite() && ! is_super_admin($user_id)) |
|
| 336 | 336 | $caps[] = 'do_not_allow'; |
| 337 | 337 | else |
| 338 | 338 | $caps[] = $cap; |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | case 'update_core': |
| 349 | 349 | // Disallow anything that creates, deletes, or updates core, plugin, or theme files. |
| 350 | 350 | // Files in uploads are excepted. |
| 351 | - if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) { |
|
| 351 | + if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) { |
|
| 352 | 352 | $caps[] = 'do_not_allow'; |
| 353 | - } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) { |
|
| 353 | + } elseif (is_multisite() && ! is_super_admin($user_id)) { |
|
| 354 | 354 | $caps[] = 'do_not_allow'; |
| 355 | - } elseif ( 'upload_themes' === $cap ) { |
|
| 355 | + } elseif ('upload_themes' === $cap) { |
|
| 356 | 356 | $caps[] = 'install_themes'; |
| 357 | - } elseif ( 'upload_plugins' === $cap ) { |
|
| 357 | + } elseif ('upload_plugins' === $cap) { |
|
| 358 | 358 | $caps[] = 'install_plugins'; |
| 359 | 359 | } else { |
| 360 | 360 | $caps[] = $cap; |
@@ -362,31 +362,31 @@ discard block |
||
| 362 | 362 | break; |
| 363 | 363 | case 'activate_plugins': |
| 364 | 364 | $caps[] = $cap; |
| 365 | - if ( is_multisite() ) { |
|
| 365 | + if (is_multisite()) { |
|
| 366 | 366 | // update_, install_, and delete_ are handled above with is_super_admin(). |
| 367 | - $menu_perms = get_site_option( 'menu_items', array() ); |
|
| 368 | - if ( empty( $menu_perms['plugins'] ) ) |
|
| 367 | + $menu_perms = get_site_option('menu_items', array()); |
|
| 368 | + if (empty($menu_perms['plugins'])) |
|
| 369 | 369 | $caps[] = 'manage_network_plugins'; |
| 370 | 370 | } |
| 371 | 371 | break; |
| 372 | 372 | case 'delete_user': |
| 373 | 373 | case 'delete_users': |
| 374 | 374 | // If multisite only super admins can delete users. |
| 375 | - if ( is_multisite() && ! is_super_admin( $user_id ) ) |
|
| 375 | + if (is_multisite() && ! is_super_admin($user_id)) |
|
| 376 | 376 | $caps[] = 'do_not_allow'; |
| 377 | 377 | else |
| 378 | 378 | $caps[] = 'delete_users'; // delete_user maps to delete_users. |
| 379 | 379 | break; |
| 380 | 380 | case 'create_users': |
| 381 | - if ( !is_multisite() ) |
|
| 381 | + if ( ! is_multisite()) |
|
| 382 | 382 | $caps[] = $cap; |
| 383 | - elseif ( is_super_admin( $user_id ) || get_site_option( 'add_new_users' ) ) |
|
| 383 | + elseif (is_super_admin($user_id) || get_site_option('add_new_users')) |
|
| 384 | 384 | $caps[] = $cap; |
| 385 | 385 | else |
| 386 | 386 | $caps[] = 'do_not_allow'; |
| 387 | 387 | break; |
| 388 | 388 | case 'manage_links' : |
| 389 | - if ( get_option( 'link_manager_enabled' ) ) |
|
| 389 | + if (get_option('link_manager_enabled')) |
|
| 390 | 390 | $caps[] = $cap; |
| 391 | 391 | else |
| 392 | 392 | $caps[] = 'do_not_allow'; |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | default: |
| 401 | 401 | // Handle meta capabilities for custom post types. |
| 402 | 402 | global $post_type_meta_caps; |
| 403 | - if ( isset( $post_type_meta_caps[ $cap ] ) ) { |
|
| 404 | - $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); |
|
| 405 | - return call_user_func_array( 'map_meta_cap', $args ); |
|
| 403 | + if (isset($post_type_meta_caps[$cap])) { |
|
| 404 | + $args = array_merge(array($post_type_meta_caps[$cap], $user_id), $args); |
|
| 405 | + return call_user_func_array('map_meta_cap', $args); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // If no meta caps match, return the original cap. |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @param int $user_id The user ID. |
| 420 | 420 | * @param array $args Adds the context to the cap. Typically the object ID. |
| 421 | 421 | */ |
| 422 | - return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args ); |
|
| 422 | + return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -444,16 +444,16 @@ discard block |
||
| 444 | 444 | * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is |
| 445 | 445 | * passed, whether the current user has the given meta capability for the given object. |
| 446 | 446 | */ |
| 447 | -function current_user_can( $capability ) { |
|
| 447 | +function current_user_can($capability) { |
|
| 448 | 448 | $current_user = wp_get_current_user(); |
| 449 | 449 | |
| 450 | - if ( empty( $current_user ) ) |
|
| 450 | + if (empty($current_user)) |
|
| 451 | 451 | return false; |
| 452 | 452 | |
| 453 | - $args = array_slice( func_get_args(), 1 ); |
|
| 454 | - $args = array_merge( array( $capability ), $args ); |
|
| 453 | + $args = array_slice(func_get_args(), 1); |
|
| 454 | + $args = array_merge(array($capability), $args); |
|
| 455 | 455 | |
| 456 | - return call_user_func_array( array( $current_user, 'has_cap' ), $args ); |
|
| 456 | + return call_user_func_array(array($current_user, 'has_cap'), $args); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -465,24 +465,24 @@ discard block |
||
| 465 | 465 | * @param string $capability Capability or role name. |
| 466 | 466 | * @return bool |
| 467 | 467 | */ |
| 468 | -function current_user_can_for_blog( $blog_id, $capability ) { |
|
| 469 | - $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; |
|
| 468 | +function current_user_can_for_blog($blog_id, $capability) { |
|
| 469 | + $switched = is_multisite() ? switch_to_blog($blog_id) : false; |
|
| 470 | 470 | |
| 471 | 471 | $current_user = wp_get_current_user(); |
| 472 | 472 | |
| 473 | - if ( empty( $current_user ) ) { |
|
| 474 | - if ( $switched ) { |
|
| 473 | + if (empty($current_user)) { |
|
| 474 | + if ($switched) { |
|
| 475 | 475 | restore_current_blog(); |
| 476 | 476 | } |
| 477 | 477 | return false; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $args = array_slice( func_get_args(), 2 ); |
|
| 481 | - $args = array_merge( array( $capability ), $args ); |
|
| 480 | + $args = array_slice(func_get_args(), 2); |
|
| 481 | + $args = array_merge(array($capability), $args); |
|
| 482 | 482 | |
| 483 | - $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); |
|
| 483 | + $can = call_user_func_array(array($current_user, 'has_cap'), $args); |
|
| 484 | 484 | |
| 485 | - if ( $switched ) { |
|
| 485 | + if ($switched) { |
|
| 486 | 486 | restore_current_blog(); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -498,19 +498,19 @@ discard block |
||
| 498 | 498 | * @param string $capability Capability or role name. |
| 499 | 499 | * @return bool |
| 500 | 500 | */ |
| 501 | -function author_can( $post, $capability ) { |
|
| 502 | - if ( !$post = get_post($post) ) |
|
| 501 | +function author_can($post, $capability) { |
|
| 502 | + if ( ! $post = get_post($post)) |
|
| 503 | 503 | return false; |
| 504 | 504 | |
| 505 | - $author = get_userdata( $post->post_author ); |
|
| 505 | + $author = get_userdata($post->post_author); |
|
| 506 | 506 | |
| 507 | - if ( ! $author ) |
|
| 507 | + if ( ! $author) |
|
| 508 | 508 | return false; |
| 509 | 509 | |
| 510 | - $args = array_slice( func_get_args(), 2 ); |
|
| 511 | - $args = array_merge( array( $capability ), $args ); |
|
| 510 | + $args = array_slice(func_get_args(), 2); |
|
| 511 | + $args = array_merge(array($capability), $args); |
|
| 512 | 512 | |
| 513 | - return call_user_func_array( array( $author, 'has_cap' ), $args ); |
|
| 513 | + return call_user_func_array(array($author, 'has_cap'), $args); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -522,17 +522,17 @@ discard block |
||
| 522 | 522 | * @param string $capability Capability or role name. |
| 523 | 523 | * @return bool |
| 524 | 524 | */ |
| 525 | -function user_can( $user, $capability ) { |
|
| 526 | - if ( ! is_object( $user ) ) |
|
| 527 | - $user = get_userdata( $user ); |
|
| 525 | +function user_can($user, $capability) { |
|
| 526 | + if ( ! is_object($user)) |
|
| 527 | + $user = get_userdata($user); |
|
| 528 | 528 | |
| 529 | - if ( ! $user || ! $user->exists() ) |
|
| 529 | + if ( ! $user || ! $user->exists()) |
|
| 530 | 530 | return false; |
| 531 | 531 | |
| 532 | - $args = array_slice( func_get_args(), 2 ); |
|
| 533 | - $args = array_merge( array( $capability ), $args ); |
|
| 532 | + $args = array_slice(func_get_args(), 2); |
|
| 533 | + $args = array_merge(array($capability), $args); |
|
| 534 | 534 | |
| 535 | - return call_user_func_array( array( $user, 'has_cap' ), $args ); |
|
| 535 | + return call_user_func_array(array($user, 'has_cap'), $args); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | function wp_roles() { |
| 548 | 548 | global $wp_roles; |
| 549 | 549 | |
| 550 | - if ( ! isset( $wp_roles ) ) { |
|
| 550 | + if ( ! isset($wp_roles)) { |
|
| 551 | 551 | $wp_roles = new WP_Roles(); |
| 552 | 552 | } |
| 553 | 553 | return $wp_roles; |
@@ -561,8 +561,8 @@ discard block |
||
| 561 | 561 | * @param string $role Role name. |
| 562 | 562 | * @return WP_Role|null WP_Role object if found, null if the role does not exist. |
| 563 | 563 | */ |
| 564 | -function get_role( $role ) { |
|
| 565 | - return wp_roles()->get_role( $role ); |
|
| 564 | +function get_role($role) { |
|
| 565 | + return wp_roles()->get_role($role); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -575,11 +575,11 @@ discard block |
||
| 575 | 575 | * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false ); |
| 576 | 576 | * @return WP_Role|null WP_Role object if role is added, null if already exists. |
| 577 | 577 | */ |
| 578 | -function add_role( $role, $display_name, $capabilities = array() ) { |
|
| 579 | - if ( empty( $role ) ) { |
|
| 578 | +function add_role($role, $display_name, $capabilities = array()) { |
|
| 579 | + if (empty($role)) { |
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | - return wp_roles()->add_role( $role, $display_name, $capabilities ); |
|
| 582 | + return wp_roles()->add_role($role, $display_name, $capabilities); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
@@ -589,8 +589,8 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @param string $role Role name. |
| 591 | 591 | */ |
| 592 | -function remove_role( $role ) { |
|
| 593 | - wp_roles()->remove_role( $role ); |
|
| 592 | +function remove_role($role) { |
|
| 593 | + wp_roles()->remove_role($role); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -605,10 +605,10 @@ discard block |
||
| 605 | 605 | function get_super_admins() { |
| 606 | 606 | global $super_admins; |
| 607 | 607 | |
| 608 | - if ( isset($super_admins) ) |
|
| 608 | + if (isset($super_admins)) |
|
| 609 | 609 | return $super_admins; |
| 610 | 610 | else |
| 611 | - return get_site_option( 'site_admins', array('admin') ); |
|
| 611 | + return get_site_option('site_admins', array('admin')); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -619,21 +619,21 @@ discard block |
||
| 619 | 619 | * @param int $user_id (Optional) The ID of a user. Defaults to the current user. |
| 620 | 620 | * @return bool True if the user is a site admin. |
| 621 | 621 | */ |
| 622 | -function is_super_admin( $user_id = false ) { |
|
| 623 | - if ( ! $user_id || $user_id == get_current_user_id() ) |
|
| 622 | +function is_super_admin($user_id = false) { |
|
| 623 | + if ( ! $user_id || $user_id == get_current_user_id()) |
|
| 624 | 624 | $user = wp_get_current_user(); |
| 625 | 625 | else |
| 626 | - $user = get_userdata( $user_id ); |
|
| 626 | + $user = get_userdata($user_id); |
|
| 627 | 627 | |
| 628 | - if ( ! $user || ! $user->exists() ) |
|
| 628 | + if ( ! $user || ! $user->exists()) |
|
| 629 | 629 | return false; |
| 630 | 630 | |
| 631 | - if ( is_multisite() ) { |
|
| 631 | + if (is_multisite()) { |
|
| 632 | 632 | $super_admins = get_super_admins(); |
| 633 | - if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) |
|
| 633 | + if (is_array($super_admins) && in_array($user->user_login, $super_admins)) |
|
| 634 | 634 | return true; |
| 635 | 635 | } else { |
| 636 | - if ( $user->has_cap('delete_users') ) |
|
| 636 | + if ($user->has_cap('delete_users')) |
|
| 637 | 637 | return true; |
| 638 | 638 | } |
| 639 | 639 | |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | * @return bool True on success, false on failure. This can fail when the user is |
| 652 | 652 | * already a super admin or when the `$super_admins` global is defined. |
| 653 | 653 | */ |
| 654 | -function grant_super_admin( $user_id ) { |
|
| 654 | +function grant_super_admin($user_id) { |
|
| 655 | 655 | // If global super_admins override is defined, there is nothing to do here. |
| 656 | - if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) { |
|
| 656 | + if (isset($GLOBALS['super_admins']) || ! is_multisite()) { |
|
| 657 | 657 | return false; |
| 658 | 658 | } |
| 659 | 659 | |
@@ -664,15 +664,15 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @param int $user_id ID of the user that is about to be granted Super Admin privileges. |
| 666 | 666 | */ |
| 667 | - do_action( 'grant_super_admin', $user_id ); |
|
| 667 | + do_action('grant_super_admin', $user_id); |
|
| 668 | 668 | |
| 669 | 669 | // Directly fetch site_admins instead of using get_super_admins() |
| 670 | - $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); |
|
| 670 | + $super_admins = get_site_option('site_admins', array('admin')); |
|
| 671 | 671 | |
| 672 | - $user = get_userdata( $user_id ); |
|
| 673 | - if ( $user && ! in_array( $user->user_login, $super_admins ) ) { |
|
| 672 | + $user = get_userdata($user_id); |
|
| 673 | + if ($user && ! in_array($user->user_login, $super_admins)) { |
|
| 674 | 674 | $super_admins[] = $user->user_login; |
| 675 | - update_site_option( 'site_admins' , $super_admins ); |
|
| 675 | + update_site_option('site_admins', $super_admins); |
|
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | 678 | * Fires after the user is granted Super Admin privileges. |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | * |
| 682 | 682 | * @param int $user_id ID of the user that was granted Super Admin privileges. |
| 683 | 683 | */ |
| 684 | - do_action( 'granted_super_admin', $user_id ); |
|
| 684 | + do_action('granted_super_admin', $user_id); |
|
| 685 | 685 | return true; |
| 686 | 686 | } |
| 687 | 687 | return false; |
@@ -698,9 +698,9 @@ discard block |
||
| 698 | 698 | * @return bool True on success, false on failure. This can fail when the user's email |
| 699 | 699 | * is the network admin email or when the `$super_admins` global is defined. |
| 700 | 700 | */ |
| 701 | -function revoke_super_admin( $user_id ) { |
|
| 701 | +function revoke_super_admin($user_id) { |
|
| 702 | 702 | // If global super_admins override is defined, there is nothing to do here. |
| 703 | - if ( isset( $GLOBALS['super_admins'] ) || ! is_multisite() ) { |
|
| 703 | + if (isset($GLOBALS['super_admins']) || ! is_multisite()) { |
|
| 704 | 704 | return false; |
| 705 | 705 | } |
| 706 | 706 | |
@@ -711,16 +711,16 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @param int $user_id ID of the user Super Admin privileges are being revoked from. |
| 713 | 713 | */ |
| 714 | - do_action( 'revoke_super_admin', $user_id ); |
|
| 714 | + do_action('revoke_super_admin', $user_id); |
|
| 715 | 715 | |
| 716 | 716 | // Directly fetch site_admins instead of using get_super_admins() |
| 717 | - $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); |
|
| 717 | + $super_admins = get_site_option('site_admins', array('admin')); |
|
| 718 | 718 | |
| 719 | - $user = get_userdata( $user_id ); |
|
| 720 | - if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) { |
|
| 721 | - if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { |
|
| 722 | - unset( $super_admins[$key] ); |
|
| 723 | - update_site_option( 'site_admins', $super_admins ); |
|
| 719 | + $user = get_userdata($user_id); |
|
| 720 | + if ($user && 0 !== strcasecmp($user->user_email, get_site_option('admin_email'))) { |
|
| 721 | + if (false !== ($key = array_search($user->user_login, $super_admins))) { |
|
| 722 | + unset($super_admins[$key]); |
|
| 723 | + update_site_option('site_admins', $super_admins); |
|
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Fires after the user's Super Admin privileges are revoked. |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | * |
| 730 | 730 | * @param int $user_id ID of the user Super Admin privileges were revoked from. |
| 731 | 731 | */ |
| 732 | - do_action( 'revoked_super_admin', $user_id ); |
|
| 732 | + do_action('revoked_super_admin', $user_id); |
|
| 733 | 733 | return true; |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function wp_styles() { |
| 21 | 21 | global $wp_styles; |
| 22 | - if ( ! ( $wp_styles instanceof WP_Styles ) ) { |
|
| 22 | + if ( ! ($wp_styles instanceof WP_Styles)) { |
|
| 23 | 23 | $wp_styles = new WP_Styles(); |
| 24 | 24 | } |
| 25 | 25 | return $wp_styles; |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * @param string|bool|array $handles Styles to be printed. Default 'false'. |
| 40 | 40 | * @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array. |
| 41 | 41 | */ |
| 42 | -function wp_print_styles( $handles = false ) { |
|
| 43 | - if ( '' === $handles ) { // for wp_head |
|
| 42 | +function wp_print_styles($handles = false) { |
|
| 43 | + if ('' === $handles) { // for wp_head |
|
| 44 | 44 | $handles = false; |
| 45 | 45 | } |
| 46 | 46 | /** |
@@ -48,20 +48,20 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @since 2.6.0 |
| 50 | 50 | */ |
| 51 | - if ( ! $handles ) { |
|
| 52 | - do_action( 'wp_print_styles' ); |
|
| 51 | + if ( ! $handles) { |
|
| 52 | + do_action('wp_print_styles'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 55 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 56 | 56 | |
| 57 | 57 | global $wp_styles; |
| 58 | - if ( ! ( $wp_styles instanceof WP_Styles ) ) { |
|
| 59 | - if ( ! $handles ) { |
|
| 58 | + if ( ! ($wp_styles instanceof WP_Styles)) { |
|
| 59 | + if ( ! $handles) { |
|
| 60 | 60 | return array(); // No need to instantiate if nothing is there. |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - return wp_styles()->do_items( $handles ); |
|
| 64 | + return wp_styles()->do_items($handles); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -80,20 +80,20 @@ discard block |
||
| 80 | 80 | * @param string $data String containing the CSS styles to be added. |
| 81 | 81 | * @return bool True on success, false on failure. |
| 82 | 82 | */ |
| 83 | -function wp_add_inline_style( $handle, $data ) { |
|
| 84 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 83 | +function wp_add_inline_style($handle, $data) { |
|
| 84 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 85 | 85 | |
| 86 | - if ( false !== stripos( $data, '</style>' ) ) { |
|
| 87 | - _doing_it_wrong( __FUNCTION__, sprintf( |
|
| 86 | + if (false !== stripos($data, '</style>')) { |
|
| 87 | + _doing_it_wrong(__FUNCTION__, sprintf( |
|
| 88 | 88 | /* translators: 1: <style>, 2: wp_add_inline_style() */ |
| 89 | - __( 'Do not pass %1$s tags to %2$s.' ), |
|
| 89 | + __('Do not pass %1$s tags to %2$s.'), |
|
| 90 | 90 | '<code><style></code>', |
| 91 | 91 | '<code>wp_add_inline_style()</code>' |
| 92 | - ), '3.7.0' ); |
|
| 93 | - $data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) ); |
|
| 92 | + ), '3.7.0'); |
|
| 93 | + $data = trim(preg_replace('#<style[^>]*>(.*)</style>#is', '$1', $data)); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - return wp_styles()->add_inline_style( $handle, $data ); |
|
| 96 | + return wp_styles()->add_inline_style($handle, $data); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * '(orientation: portrait)' and '(max-width: 640px)'. |
| 118 | 118 | * @return bool Whether the style has been registered. True on success, false on failure. |
| 119 | 119 | */ |
| 120 | -function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) { |
|
| 121 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 120 | +function wp_register_style($handle, $src, $deps = array(), $ver = false, $media = 'all') { |
|
| 121 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 122 | 122 | |
| 123 | - return wp_styles()->add( $handle, $src, $deps, $ver, $media ); |
|
| 123 | + return wp_styles()->add($handle, $src, $deps, $ver, $media); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @param string $handle Name of the stylesheet to be removed. |
| 134 | 134 | */ |
| 135 | -function wp_deregister_style( $handle ) { |
|
| 136 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 135 | +function wp_deregister_style($handle) { |
|
| 136 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 137 | 137 | |
| 138 | - wp_styles()->remove( $handle ); |
|
| 138 | + wp_styles()->remove($handle); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -160,16 +160,16 @@ discard block |
||
| 160 | 160 | * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like |
| 161 | 161 | * '(orientation: portrait)' and '(max-width: 640px)'. |
| 162 | 162 | */ |
| 163 | -function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) { |
|
| 164 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 163 | +function wp_enqueue_style($handle, $src = false, $deps = array(), $ver = false, $media = 'all') { |
|
| 164 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 165 | 165 | |
| 166 | 166 | $wp_styles = wp_styles(); |
| 167 | 167 | |
| 168 | - if ( $src ) { |
|
| 168 | + if ($src) { |
|
| 169 | 169 | $_handle = explode('?', $handle); |
| 170 | - $wp_styles->add( $_handle[0], $src, $deps, $ver, $media ); |
|
| 170 | + $wp_styles->add($_handle[0], $src, $deps, $ver, $media); |
|
| 171 | 171 | } |
| 172 | - $wp_styles->enqueue( $handle ); |
|
| 172 | + $wp_styles->enqueue($handle); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @param string $handle Name of the stylesheet to be removed. |
| 183 | 183 | */ |
| 184 | -function wp_dequeue_style( $handle ) { |
|
| 185 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 184 | +function wp_dequeue_style($handle) { |
|
| 185 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 186 | 186 | |
| 187 | - wp_styles()->dequeue( $handle ); |
|
| 187 | + wp_styles()->dequeue($handle); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | * Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. |
| 198 | 198 | * @return bool Whether style is queued. |
| 199 | 199 | */ |
| 200 | -function wp_style_is( $handle, $list = 'enqueued' ) { |
|
| 201 | - _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); |
|
| 200 | +function wp_style_is($handle, $list = 'enqueued') { |
|
| 201 | + _wp_scripts_maybe_doing_it_wrong(__FUNCTION__); |
|
| 202 | 202 | |
| 203 | - return (bool) wp_styles()->query( $handle, $list ); |
|
| 203 | + return (bool) wp_styles()->query($handle, $list); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -225,6 +225,6 @@ discard block |
||
| 225 | 225 | * @param mixed $value String containing the CSS data to be added. |
| 226 | 226 | * @return bool True on success, false on failure. |
| 227 | 227 | */ |
| 228 | -function wp_style_add_data( $handle, $key, $value ) { |
|
| 229 | - return wp_styles()->add_data( $handle, $key, $value ); |
|
| 228 | +function wp_style_add_data($handle, $key, $value) { |
|
| 229 | + return wp_styles()->add_data($handle, $key, $value); |
|
| 230 | 230 | } |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * Deprecated. Use WP_HTTP (http.php) instead. |
| 5 | 5 | */ |
| 6 | -_deprecated_file( basename( __FILE__ ), '3.0.0', WPINC . '/http.php' ); |
|
| 6 | +_deprecated_file(basename(__FILE__), '3.0.0', WPINC.'/http.php'); |
|
| 7 | 7 | |
| 8 | -if ( ! class_exists( 'Snoopy', false ) ) : |
|
| 8 | +if ( ! class_exists('Snoopy', false)) : |
|
| 9 | 9 | /************************************************* |
| 10 | 10 | |
| 11 | 11 | Snoopy - the PHP net client |
@@ -41,54 +41,54 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | /* user definable vars */ |
| 43 | 43 | |
| 44 | - var $host = "www.php.net"; // host name we are connecting to |
|
| 45 | - var $port = 80; // port we are connecting to |
|
| 46 | - var $proxy_host = ""; // proxy host to use |
|
| 47 | - var $proxy_port = ""; // proxy port to use |
|
| 48 | - var $proxy_user = ""; // proxy user to use |
|
| 49 | - var $proxy_pass = ""; // proxy password to use |
|
| 44 | + var $host = "www.php.net"; // host name we are connecting to |
|
| 45 | + var $port = 80; // port we are connecting to |
|
| 46 | + var $proxy_host = ""; // proxy host to use |
|
| 47 | + var $proxy_port = ""; // proxy port to use |
|
| 48 | + var $proxy_user = ""; // proxy user to use |
|
| 49 | + var $proxy_pass = ""; // proxy password to use |
|
| 50 | 50 | |
| 51 | - var $agent = "Snoopy v1.2.4"; // agent we masquerade as |
|
| 52 | - var $referer = ""; // referer info to pass |
|
| 53 | - var $cookies = array(); // array of cookies to pass |
|
| 51 | + var $agent = "Snoopy v1.2.4"; // agent we masquerade as |
|
| 52 | + var $referer = ""; // referer info to pass |
|
| 53 | + var $cookies = array(); // array of cookies to pass |
|
| 54 | 54 | // $cookies["username"]="joe"; |
| 55 | - var $rawheaders = array(); // array of raw headers to send |
|
| 55 | + var $rawheaders = array(); // array of raw headers to send |
|
| 56 | 56 | // $rawheaders["Content-type"]="text/html"; |
| 57 | 57 | |
| 58 | - var $maxredirs = 5; // http redirection depth maximum. 0 = disallow |
|
| 59 | - var $lastredirectaddr = ""; // contains address of last redirected address |
|
| 60 | - var $offsiteok = true; // allows redirection off-site |
|
| 61 | - var $maxframes = 0; // frame content depth maximum. 0 = disallow |
|
| 62 | - var $expandlinks = true; // expand links to fully qualified URLs. |
|
| 58 | + var $maxredirs = 5; // http redirection depth maximum. 0 = disallow |
|
| 59 | + var $lastredirectaddr = ""; // contains address of last redirected address |
|
| 60 | + var $offsiteok = true; // allows redirection off-site |
|
| 61 | + var $maxframes = 0; // frame content depth maximum. 0 = disallow |
|
| 62 | + var $expandlinks = true; // expand links to fully qualified URLs. |
|
| 63 | 63 | // this only applies to fetchlinks() |
| 64 | 64 | // submitlinks(), and submittext() |
| 65 | - var $passcookies = true; // pass set cookies back through redirects |
|
| 65 | + var $passcookies = true; // pass set cookies back through redirects |
|
| 66 | 66 | // NOTE: this currently does not respect |
| 67 | 67 | // dates, domains or paths. |
| 68 | 68 | |
| 69 | - var $user = ""; // user for http authentication |
|
| 70 | - var $pass = ""; // password for http authentication |
|
| 69 | + var $user = ""; // user for http authentication |
|
| 70 | + var $pass = ""; // password for http authentication |
|
| 71 | 71 | |
| 72 | 72 | // http accept types |
| 73 | - var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
| 73 | + var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
| 74 | 74 | |
| 75 | - var $results = ""; // where the content is put |
|
| 75 | + var $results = ""; // where the content is put |
|
| 76 | 76 | |
| 77 | - var $error = ""; // error messages sent here |
|
| 78 | - var $response_code = ""; // response code returned from server |
|
| 79 | - var $headers = array(); // headers returned from server sent here |
|
| 80 | - var $maxlength = 500000; // max return data length (body) |
|
| 81 | - var $read_timeout = 0; // timeout on read operations, in seconds |
|
| 77 | + var $error = ""; // error messages sent here |
|
| 78 | + var $response_code = ""; // response code returned from server |
|
| 79 | + var $headers = array(); // headers returned from server sent here |
|
| 80 | + var $maxlength = 500000; // max return data length (body) |
|
| 81 | + var $read_timeout = 0; // timeout on read operations, in seconds |
|
| 82 | 82 | // supported only since PHP 4 Beta 4 |
| 83 | 83 | // set to 0 to disallow timeouts |
| 84 | - var $timed_out = false; // if a read operation timed out |
|
| 85 | - var $status = 0; // http request status |
|
| 84 | + var $timed_out = false; // if a read operation timed out |
|
| 85 | + var $status = 0; // http request status |
|
| 86 | 86 | |
| 87 | - var $temp_dir = "/tmp"; // temporary directory that the webserver |
|
| 87 | + var $temp_dir = "/tmp"; // temporary directory that the webserver |
|
| 88 | 88 | // has permission to write to. |
| 89 | 89 | // under Windows, this should be C:\temp |
| 90 | 90 | |
| 91 | - var $curl_path = "/usr/local/bin/curl"; |
|
| 91 | + var $curl_path = "/usr/local/bin/curl"; |
|
| 92 | 92 | // Snoopy will use cURL for fetching |
| 93 | 93 | // SSL content if a full system path to |
| 94 | 94 | // the cURL binary is supplied here. |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | /**** Private variables ****/ |
| 104 | 104 | |
| 105 | - var $_maxlinelen = 4096; // max line length (headers) |
|
| 105 | + var $_maxlinelen = 4096; // max line length (headers) |
|
| 106 | 106 | |
| 107 | - var $_httpmethod = "GET"; // default http request method |
|
| 108 | - var $_httpversion = "HTTP/1.0"; // default http request version |
|
| 109 | - var $_submit_method = "POST"; // default submit method |
|
| 110 | - var $_submit_type = "application/x-www-form-urlencoded"; // default submit type |
|
| 111 | - var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type |
|
| 112 | - var $_redirectaddr = false; // will be set if page fetched is a redirect |
|
| 113 | - var $_redirectdepth = 0; // increments on an http redirect |
|
| 114 | - var $_frameurls = array(); // frame src urls |
|
| 115 | - var $_framedepth = 0; // increments on frame depth |
|
| 107 | + var $_httpmethod = "GET"; // default http request method |
|
| 108 | + var $_httpversion = "HTTP/1.0"; // default http request version |
|
| 109 | + var $_submit_method = "POST"; // default submit method |
|
| 110 | + var $_submit_type = "application/x-www-form-urlencoded"; // default submit type |
|
| 111 | + var $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type |
|
| 112 | + var $_redirectaddr = false; // will be set if page fetched is a redirect |
|
| 113 | + var $_redirectdepth = 0; // increments on an http redirect |
|
| 114 | + var $_frameurls = array(); // frame src urls |
|
| 115 | + var $_framedepth = 0; // increments on frame depth |
|
| 116 | 116 | |
| 117 | - var $_isproxy = false; // set if using a proxy server |
|
| 118 | - var $_fp_timeout = 30; // timeout for socket connection |
|
| 117 | + var $_isproxy = false; // set if using a proxy server |
|
| 118 | + var $_fp_timeout = 30; // timeout for socket connection |
|
| 119 | 119 | |
| 120 | 120 | /*======================================================================*\ |
| 121 | 121 | Function: fetch |
@@ -131,27 +131,27 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); |
| 133 | 133 | $URI_PARTS = parse_url($URI); |
| 134 | - if (!empty($URI_PARTS["user"])) |
|
| 134 | + if ( ! empty($URI_PARTS["user"])) |
|
| 135 | 135 | $this->user = $URI_PARTS["user"]; |
| 136 | - if (!empty($URI_PARTS["pass"])) |
|
| 136 | + if ( ! empty($URI_PARTS["pass"])) |
|
| 137 | 137 | $this->pass = $URI_PARTS["pass"]; |
| 138 | 138 | if (empty($URI_PARTS["query"])) |
| 139 | 139 | $URI_PARTS["query"] = ''; |
| 140 | 140 | if (empty($URI_PARTS["path"])) |
| 141 | 141 | $URI_PARTS["path"] = ''; |
| 142 | 142 | |
| 143 | - switch(strtolower($URI_PARTS["scheme"])) |
|
| 143 | + switch (strtolower($URI_PARTS["scheme"])) |
|
| 144 | 144 | { |
| 145 | 145 | case "http": |
| 146 | 146 | $this->host = $URI_PARTS["host"]; |
| 147 | - if(!empty($URI_PARTS["port"])) |
|
| 147 | + if ( ! empty($URI_PARTS["port"])) |
|
| 148 | 148 | $this->port = $URI_PARTS["port"]; |
| 149 | - if($this->_connect($fp)) |
|
| 149 | + if ($this->_connect($fp)) |
|
| 150 | 150 | { |
| 151 | - if($this->_isproxy) |
|
| 151 | + if ($this->_isproxy) |
|
| 152 | 152 | { |
| 153 | 153 | // using proxy, send entire URI |
| 154 | - $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); |
|
| 154 | + $this->_httprequest($URI, $fp, $URI, $this->_httpmethod); |
|
| 155 | 155 | } |
| 156 | 156 | else |
| 157 | 157 | { |
@@ -162,30 +162,30 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $this->_disconnect($fp); |
| 164 | 164 | |
| 165 | - if($this->_redirectaddr) |
|
| 165 | + if ($this->_redirectaddr) |
|
| 166 | 166 | { |
| 167 | 167 | /* url was redirected, check if we've hit the max depth */ |
| 168 | - if($this->maxredirs > $this->_redirectdepth) |
|
| 168 | + if ($this->maxredirs > $this->_redirectdepth) |
|
| 169 | 169 | { |
| 170 | 170 | // only follow redirect if it's on this site, or offsiteok is true |
| 171 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
| 171 | + if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) |
|
| 172 | 172 | { |
| 173 | 173 | /* follow the redirect */ |
| 174 | 174 | $this->_redirectdepth++; |
| 175 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
| 175 | + $this->lastredirectaddr = $this->_redirectaddr; |
|
| 176 | 176 | $this->fetch($this->_redirectaddr); |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 181 | + if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 182 | 182 | { |
| 183 | 183 | $frameurls = $this->_frameurls; |
| 184 | 184 | $this->_frameurls = array(); |
| 185 | 185 | |
| 186 | - while(list(,$frameurl) = each($frameurls)) |
|
| 186 | + while (list(,$frameurl) = each($frameurls)) |
|
| 187 | 187 | { |
| 188 | - if($this->_framedepth < $this->maxframes) |
|
| 188 | + if ($this->_framedepth < $this->maxframes) |
|
| 189 | 189 | { |
| 190 | 190 | $this->fetch($frameurl); |
| 191 | 191 | $this->_framedepth++; |
@@ -202,18 +202,18 @@ discard block |
||
| 202 | 202 | return true; |
| 203 | 203 | break; |
| 204 | 204 | case "https": |
| 205 | - if(!$this->curl_path) |
|
| 205 | + if ( ! $this->curl_path) |
|
| 206 | 206 | return false; |
| 207 | - if(function_exists("is_executable")) |
|
| 208 | - if (!is_executable($this->curl_path)) |
|
| 207 | + if (function_exists("is_executable")) |
|
| 208 | + if ( ! is_executable($this->curl_path)) |
|
| 209 | 209 | return false; |
| 210 | 210 | $this->host = $URI_PARTS["host"]; |
| 211 | - if(!empty($URI_PARTS["port"])) |
|
| 211 | + if ( ! empty($URI_PARTS["port"])) |
|
| 212 | 212 | $this->port = $URI_PARTS["port"]; |
| 213 | - if($this->_isproxy) |
|
| 213 | + if ($this->_isproxy) |
|
| 214 | 214 | { |
| 215 | 215 | // using proxy, send entire URI |
| 216 | - $this->_httpsrequest($URI,$URI,$this->_httpmethod); |
|
| 216 | + $this->_httpsrequest($URI, $URI, $this->_httpmethod); |
|
| 217 | 217 | } |
| 218 | 218 | else |
| 219 | 219 | { |
@@ -222,30 +222,30 @@ discard block |
||
| 222 | 222 | $this->_httpsrequest($path, $URI, $this->_httpmethod); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if($this->_redirectaddr) |
|
| 225 | + if ($this->_redirectaddr) |
|
| 226 | 226 | { |
| 227 | 227 | /* url was redirected, check if we've hit the max depth */ |
| 228 | - if($this->maxredirs > $this->_redirectdepth) |
|
| 228 | + if ($this->maxredirs > $this->_redirectdepth) |
|
| 229 | 229 | { |
| 230 | 230 | // only follow redirect if it's on this site, or offsiteok is true |
| 231 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
| 231 | + if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) |
|
| 232 | 232 | { |
| 233 | 233 | /* follow the redirect */ |
| 234 | 234 | $this->_redirectdepth++; |
| 235 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
| 235 | + $this->lastredirectaddr = $this->_redirectaddr; |
|
| 236 | 236 | $this->fetch($this->_redirectaddr); |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 241 | + if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 242 | 242 | { |
| 243 | 243 | $frameurls = $this->_frameurls; |
| 244 | 244 | $this->_frameurls = array(); |
| 245 | 245 | |
| 246 | - while(list(,$frameurl) = each($frameurls)) |
|
| 246 | + while (list(,$frameurl) = each($frameurls)) |
|
| 247 | 247 | { |
| 248 | - if($this->_framedepth < $this->maxframes) |
|
| 248 | + if ($this->_framedepth < $this->maxframes) |
|
| 249 | 249 | { |
| 250 | 250 | $this->fetch($frameurl); |
| 251 | 251 | $this->_framedepth++; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | break; |
| 259 | 259 | default: |
| 260 | 260 | // not a valid protocol |
| 261 | - $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 261 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 262 | 262 | return false; |
| 263 | 263 | break; |
| 264 | 264 | } |
@@ -276,34 +276,34 @@ discard block |
||
| 276 | 276 | Output: $this->results the text output from the post |
| 277 | 277 | \*======================================================================*/ |
| 278 | 278 | |
| 279 | - function submit($URI, $formvars="", $formfiles="") |
|
| 279 | + function submit($URI, $formvars = "", $formfiles = "") |
|
| 280 | 280 | { |
| 281 | 281 | unset($postdata); |
| 282 | 282 | |
| 283 | 283 | $postdata = $this->_prepare_post_body($formvars, $formfiles); |
| 284 | 284 | |
| 285 | 285 | $URI_PARTS = parse_url($URI); |
| 286 | - if (!empty($URI_PARTS["user"])) |
|
| 286 | + if ( ! empty($URI_PARTS["user"])) |
|
| 287 | 287 | $this->user = $URI_PARTS["user"]; |
| 288 | - if (!empty($URI_PARTS["pass"])) |
|
| 288 | + if ( ! empty($URI_PARTS["pass"])) |
|
| 289 | 289 | $this->pass = $URI_PARTS["pass"]; |
| 290 | 290 | if (empty($URI_PARTS["query"])) |
| 291 | 291 | $URI_PARTS["query"] = ''; |
| 292 | 292 | if (empty($URI_PARTS["path"])) |
| 293 | 293 | $URI_PARTS["path"] = ''; |
| 294 | 294 | |
| 295 | - switch(strtolower($URI_PARTS["scheme"])) |
|
| 295 | + switch (strtolower($URI_PARTS["scheme"])) |
|
| 296 | 296 | { |
| 297 | 297 | case "http": |
| 298 | 298 | $this->host = $URI_PARTS["host"]; |
| 299 | - if(!empty($URI_PARTS["port"])) |
|
| 299 | + if ( ! empty($URI_PARTS["port"])) |
|
| 300 | 300 | $this->port = $URI_PARTS["port"]; |
| 301 | - if($this->_connect($fp)) |
|
| 301 | + if ($this->_connect($fp)) |
|
| 302 | 302 | { |
| 303 | - if($this->_isproxy) |
|
| 303 | + if ($this->_isproxy) |
|
| 304 | 304 | { |
| 305 | 305 | // using proxy, send entire URI |
| 306 | - $this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata); |
|
| 306 | + $this->_httprequest($URI, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
|
| 307 | 307 | } |
| 308 | 308 | else |
| 309 | 309 | { |
@@ -314,36 +314,36 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | $this->_disconnect($fp); |
| 316 | 316 | |
| 317 | - if($this->_redirectaddr) |
|
| 317 | + if ($this->_redirectaddr) |
|
| 318 | 318 | { |
| 319 | 319 | /* url was redirected, check if we've hit the max depth */ |
| 320 | - if($this->maxredirs > $this->_redirectdepth) |
|
| 320 | + if ($this->maxredirs > $this->_redirectdepth) |
|
| 321 | 321 | { |
| 322 | - if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 323 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 322 | + if ( ! preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 323 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 324 | 324 | |
| 325 | 325 | // only follow redirect if it's on this site, or offsiteok is true |
| 326 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
| 326 | + if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) |
|
| 327 | 327 | { |
| 328 | 328 | /* follow the redirect */ |
| 329 | 329 | $this->_redirectdepth++; |
| 330 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
| 331 | - if( strpos( $this->_redirectaddr, "?" ) > 0 ) |
|
| 330 | + $this->lastredirectaddr = $this->_redirectaddr; |
|
| 331 | + if (strpos($this->_redirectaddr, "?") > 0) |
|
| 332 | 332 | $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
| 333 | 333 | else |
| 334 | - $this->submit($this->_redirectaddr,$formvars, $formfiles); |
|
| 334 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 339 | + if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 340 | 340 | { |
| 341 | 341 | $frameurls = $this->_frameurls; |
| 342 | 342 | $this->_frameurls = array(); |
| 343 | 343 | |
| 344 | - while(list(,$frameurl) = each($frameurls)) |
|
| 344 | + while (list(,$frameurl) = each($frameurls)) |
|
| 345 | 345 | { |
| 346 | - if($this->_framedepth < $this->maxframes) |
|
| 346 | + if ($this->_framedepth < $this->maxframes) |
|
| 347 | 347 | { |
| 348 | 348 | $this->fetch($frameurl); |
| 349 | 349 | $this->_framedepth++; |
@@ -361,15 +361,15 @@ discard block |
||
| 361 | 361 | return true; |
| 362 | 362 | break; |
| 363 | 363 | case "https": |
| 364 | - if(!$this->curl_path) |
|
| 364 | + if ( ! $this->curl_path) |
|
| 365 | 365 | return false; |
| 366 | - if(function_exists("is_executable")) |
|
| 367 | - if (!is_executable($this->curl_path)) |
|
| 366 | + if (function_exists("is_executable")) |
|
| 367 | + if ( ! is_executable($this->curl_path)) |
|
| 368 | 368 | return false; |
| 369 | 369 | $this->host = $URI_PARTS["host"]; |
| 370 | - if(!empty($URI_PARTS["port"])) |
|
| 370 | + if ( ! empty($URI_PARTS["port"])) |
|
| 371 | 371 | $this->port = $URI_PARTS["port"]; |
| 372 | - if($this->_isproxy) |
|
| 372 | + if ($this->_isproxy) |
|
| 373 | 373 | { |
| 374 | 374 | // using proxy, send entire URI |
| 375 | 375 | $this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
@@ -381,36 +381,36 @@ discard block |
||
| 381 | 381 | $this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if($this->_redirectaddr) |
|
| 384 | + if ($this->_redirectaddr) |
|
| 385 | 385 | { |
| 386 | 386 | /* url was redirected, check if we've hit the max depth */ |
| 387 | - if($this->maxredirs > $this->_redirectdepth) |
|
| 387 | + if ($this->maxredirs > $this->_redirectdepth) |
|
| 388 | 388 | { |
| 389 | - if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 390 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 389 | + if ( ! preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr)) |
|
| 390 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"]."://".$URI_PARTS["host"]); |
|
| 391 | 391 | |
| 392 | 392 | // only follow redirect if it's on this site, or offsiteok is true |
| 393 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
| 393 | + if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok) |
|
| 394 | 394 | { |
| 395 | 395 | /* follow the redirect */ |
| 396 | 396 | $this->_redirectdepth++; |
| 397 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
| 398 | - if( strpos( $this->_redirectaddr, "?" ) > 0 ) |
|
| 397 | + $this->lastredirectaddr = $this->_redirectaddr; |
|
| 398 | + if (strpos($this->_redirectaddr, "?") > 0) |
|
| 399 | 399 | $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
| 400 | 400 | else |
| 401 | - $this->submit($this->_redirectaddr,$formvars, $formfiles); |
|
| 401 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 406 | + if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
| 407 | 407 | { |
| 408 | 408 | $frameurls = $this->_frameurls; |
| 409 | 409 | $this->_frameurls = array(); |
| 410 | 410 | |
| 411 | - while(list(,$frameurl) = each($frameurls)) |
|
| 411 | + while (list(,$frameurl) = each($frameurls)) |
|
| 412 | 412 | { |
| 413 | - if($this->_framedepth < $this->maxframes) |
|
| 413 | + if ($this->_framedepth < $this->maxframes) |
|
| 414 | 414 | { |
| 415 | 415 | $this->fetch($frameurl); |
| 416 | 416 | $this->_framedepth++; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | default: |
| 426 | 426 | // not a valid protocol |
| 427 | - $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 427 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
| 428 | 428 | return false; |
| 429 | 429 | break; |
| 430 | 430 | } |
@@ -442,17 +442,17 @@ discard block |
||
| 442 | 442 | { |
| 443 | 443 | if ($this->fetch($URI)) |
| 444 | 444 | { |
| 445 | - if($this->lastredirectaddr) |
|
| 445 | + if ($this->lastredirectaddr) |
|
| 446 | 446 | $URI = $this->lastredirectaddr; |
| 447 | - if(is_array($this->results)) |
|
| 447 | + if (is_array($this->results)) |
|
| 448 | 448 | { |
| 449 | - for($x=0;$x<count($this->results);$x++) |
|
| 449 | + for ($x = 0; $x < count($this->results); $x++) |
|
| 450 | 450 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
| 451 | 451 | } |
| 452 | 452 | else |
| 453 | 453 | $this->results = $this->_striplinks($this->results); |
| 454 | 454 | |
| 455 | - if($this->expandlinks) |
|
| 455 | + if ($this->expandlinks) |
|
| 456 | 456 | $this->results = $this->_expandlinks($this->results, $URI); |
| 457 | 457 | return true; |
| 458 | 458 | } |
@@ -473,9 +473,9 @@ discard block |
||
| 473 | 473 | if ($this->fetch($URI)) |
| 474 | 474 | { |
| 475 | 475 | |
| 476 | - if(is_array($this->results)) |
|
| 476 | + if (is_array($this->results)) |
|
| 477 | 477 | { |
| 478 | - for($x=0;$x<count($this->results);$x++) |
|
| 478 | + for ($x = 0; $x < count($this->results); $x++) |
|
| 479 | 479 | $this->results[$x] = $this->_stripform($this->results[$x]); |
| 480 | 480 | } |
| 481 | 481 | else |
@@ -497,11 +497,11 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | function fetchtext($URI) |
| 499 | 499 | { |
| 500 | - if($this->fetch($URI)) |
|
| 500 | + if ($this->fetch($URI)) |
|
| 501 | 501 | { |
| 502 | - if(is_array($this->results)) |
|
| 502 | + if (is_array($this->results)) |
|
| 503 | 503 | { |
| 504 | - for($x=0;$x<count($this->results);$x++) |
|
| 504 | + for ($x = 0; $x < count($this->results); $x++) |
|
| 505 | 505 | $this->results[$x] = $this->_striptext($this->results[$x]); |
| 506 | 506 | } |
| 507 | 507 | else |
@@ -519,26 +519,26 @@ discard block |
||
| 519 | 519 | Output: $this->results an array of the links from the post |
| 520 | 520 | \*======================================================================*/ |
| 521 | 521 | |
| 522 | - function submitlinks($URI, $formvars="", $formfiles="") |
|
| 522 | + function submitlinks($URI, $formvars = "", $formfiles = "") |
|
| 523 | 523 | { |
| 524 | - if($this->submit($URI,$formvars, $formfiles)) |
|
| 524 | + if ($this->submit($URI, $formvars, $formfiles)) |
|
| 525 | 525 | { |
| 526 | - if($this->lastredirectaddr) |
|
| 526 | + if ($this->lastredirectaddr) |
|
| 527 | 527 | $URI = $this->lastredirectaddr; |
| 528 | - if(is_array($this->results)) |
|
| 528 | + if (is_array($this->results)) |
|
| 529 | 529 | { |
| 530 | - for($x=0;$x<count($this->results);$x++) |
|
| 530 | + for ($x = 0; $x < count($this->results); $x++) |
|
| 531 | 531 | { |
| 532 | 532 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
| 533 | - if($this->expandlinks) |
|
| 534 | - $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); |
|
| 533 | + if ($this->expandlinks) |
|
| 534 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | else |
| 538 | 538 | { |
| 539 | 539 | $this->results = $this->_striplinks($this->results); |
| 540 | - if($this->expandlinks) |
|
| 541 | - $this->results = $this->_expandlinks($this->results,$URI); |
|
| 540 | + if ($this->expandlinks) |
|
| 541 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 542 | 542 | } |
| 543 | 543 | return true; |
| 544 | 544 | } |
@@ -555,24 +555,24 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | function submittext($URI, $formvars = "", $formfiles = "") |
| 557 | 557 | { |
| 558 | - if($this->submit($URI,$formvars, $formfiles)) |
|
| 558 | + if ($this->submit($URI, $formvars, $formfiles)) |
|
| 559 | 559 | { |
| 560 | - if($this->lastredirectaddr) |
|
| 560 | + if ($this->lastredirectaddr) |
|
| 561 | 561 | $URI = $this->lastredirectaddr; |
| 562 | - if(is_array($this->results)) |
|
| 562 | + if (is_array($this->results)) |
|
| 563 | 563 | { |
| 564 | - for($x=0;$x<count($this->results);$x++) |
|
| 564 | + for ($x = 0; $x < count($this->results); $x++) |
|
| 565 | 565 | { |
| 566 | 566 | $this->results[$x] = $this->_striptext($this->results[$x]); |
| 567 | - if($this->expandlinks) |
|
| 568 | - $this->results[$x] = $this->_expandlinks($this->results[$x],$URI); |
|
| 567 | + if ($this->expandlinks) |
|
| 568 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | else |
| 572 | 572 | { |
| 573 | 573 | $this->results = $this->_striptext($this->results); |
| 574 | - if($this->expandlinks) |
|
| 575 | - $this->results = $this->_expandlinks($this->results,$URI); |
|
| 574 | + if ($this->expandlinks) |
|
| 575 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
| 576 | 576 | } |
| 577 | 577 | return true; |
| 578 | 578 | } |
@@ -624,20 +624,20 @@ discard block |
||
| 624 | 624 | ([\"\'])? # find single or double quote |
| 625 | 625 | (?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching |
| 626 | 626 | # quote, otherwise match up to next space |
| 627 | - 'isx",$document,$links); |
|
| 627 | + 'isx",$document, $links); |
|
| 628 | 628 | |
| 629 | 629 | |
| 630 | 630 | // catenate the non-empty matches from the conditional subpattern |
| 631 | 631 | |
| 632 | - while(list($key,$val) = each($links[2])) |
|
| 632 | + while (list($key, $val) = each($links[2])) |
|
| 633 | 633 | { |
| 634 | - if(!empty($val)) |
|
| 634 | + if ( ! empty($val)) |
|
| 635 | 635 | $match[] = $val; |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - while(list($key,$val) = each($links[3])) |
|
| 638 | + while (list($key, $val) = each($links[3])) |
|
| 639 | 639 | { |
| 640 | - if(!empty($val)) |
|
| 640 | + if ( ! empty($val)) |
|
| 641 | 641 | $match[] = $val; |
| 642 | 642 | } |
| 643 | 643 | |
@@ -654,10 +654,10 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | function _stripform($document) |
| 656 | 656 | { |
| 657 | - preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); |
|
| 657 | + preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi", $document, $elements); |
|
| 658 | 658 | |
| 659 | 659 | // catenate the matches |
| 660 | - $match = implode("\r\n",$elements[0]); |
|
| 660 | + $match = implode("\r\n", $elements[0]); |
|
| 661 | 661 | |
| 662 | 662 | // return the links |
| 663 | 663 | return $match; |
@@ -679,11 +679,11 @@ discard block |
||
| 679 | 679 | // so, list your entities one by one here. I included some of the |
| 680 | 680 | // more common ones. |
| 681 | 681 | |
| 682 | - $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript |
|
| 683 | - "'<[\/\!]*?[^<>]*?>'si", // strip out html tags |
|
| 684 | - "'([\r\n])[\s]+'", // strip out white space |
|
| 685 | - "'&(quot|#34|#034|#x22);'i", // replace html entities |
|
| 686 | - "'&(amp|#38|#038|#x26);'i", // added hexadecimal values |
|
| 682 | + $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript |
|
| 683 | + "'<[\/\!]*?[^<>]*?>'si", // strip out html tags |
|
| 684 | + "'([\r\n])[\s]+'", // strip out white space |
|
| 685 | + "'&(quot|#34|#034|#x22);'i", // replace html entities |
|
| 686 | + "'&(amp|#38|#038|#x26);'i", // added hexadecimal values |
|
| 687 | 687 | "'&(lt|#60|#060|#x3c);'i", |
| 688 | 688 | "'&(gt|#62|#062|#x3e);'i", |
| 689 | 689 | "'&(nbsp|#160|#xa0);'i", |
@@ -694,8 +694,8 @@ discard block |
||
| 694 | 694 | "'&(reg|#174);'i", |
| 695 | 695 | "'&(deg|#176);'i", |
| 696 | 696 | "'&(#39|#039|#x27);'", |
| 697 | - "'&(euro|#8364);'i", // europe |
|
| 698 | - "'&a(uml|UML);'", // german |
|
| 697 | + "'&(euro|#8364);'i", // europe |
|
| 698 | + "'&a(uml|UML);'", // german |
|
| 699 | 699 | "'&o(uml|UML);'", |
| 700 | 700 | "'&u(uml|UML);'", |
| 701 | 701 | "'&A(uml|UML);'", |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | "'&U(uml|UML);'", |
| 704 | 704 | "'ß'i", |
| 705 | 705 | ); |
| 706 | - $replace = array( "", |
|
| 706 | + $replace = array("", |
|
| 707 | 707 | "", |
| 708 | 708 | "\\1", |
| 709 | 709 | "\"", |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | chr(0xDF), // ANSI ß |
| 729 | 729 | ); |
| 730 | 730 | |
| 731 | - $text = preg_replace($search,$replace,$document); |
|
| 731 | + $text = preg_replace($search, $replace, $document); |
|
| 732 | 732 | |
| 733 | 733 | return $text; |
| 734 | 734 | } |
@@ -741,32 +741,32 @@ discard block |
||
| 741 | 741 | Output: $expandedLinks the expanded links |
| 742 | 742 | \*======================================================================*/ |
| 743 | 743 | |
| 744 | - function _expandlinks($links,$URI) |
|
| 744 | + function _expandlinks($links, $URI) |
|
| 745 | 745 | { |
| 746 | 746 | |
| 747 | - preg_match("/^[^\?]+/",$URI,$match); |
|
| 747 | + preg_match("/^[^\?]+/", $URI, $match); |
|
| 748 | 748 | |
| 749 | - $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); |
|
| 750 | - $match = preg_replace("|/$|","",$match); |
|
| 749 | + $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|", "", $match[0]); |
|
| 750 | + $match = preg_replace("|/$|", "", $match); |
|
| 751 | 751 | $match_part = parse_url($match); |
| 752 | 752 | $match_root = |
| 753 | 753 | $match_part["scheme"]."://".$match_part["host"]; |
| 754 | 754 | |
| 755 | - $search = array( "|^http://".preg_quote($this->host)."|i", |
|
| 755 | + $search = array("|^http://".preg_quote($this->host)."|i", |
|
| 756 | 756 | "|^(\/)|i", |
| 757 | 757 | "|^(?!http://)(?!mailto:)|i", |
| 758 | 758 | "|/\./|", |
| 759 | 759 | "|/[^\/]+/\.\./|" |
| 760 | 760 | ); |
| 761 | 761 | |
| 762 | - $replace = array( "", |
|
| 762 | + $replace = array("", |
|
| 763 | 763 | $match_root."/", |
| 764 | 764 | $match."/", |
| 765 | 765 | "/", |
| 766 | 766 | "/" |
| 767 | 767 | ); |
| 768 | 768 | |
| 769 | - $expandedLinks = preg_replace($search,$replace,$links); |
|
| 769 | + $expandedLinks = preg_replace($search, $replace, $links); |
|
| 770 | 770 | |
| 771 | 771 | return $expandedLinks; |
| 772 | 772 | } |
@@ -781,63 +781,63 @@ discard block |
||
| 781 | 781 | Output: |
| 782 | 782 | \*======================================================================*/ |
| 783 | 783 | |
| 784 | - function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") |
|
| 784 | + function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
|
| 785 | 785 | { |
| 786 | 786 | $cookie_headers = ''; |
| 787 | - if($this->passcookies && $this->_redirectaddr) |
|
| 787 | + if ($this->passcookies && $this->_redirectaddr) |
|
| 788 | 788 | $this->setcookies(); |
| 789 | 789 | |
| 790 | 790 | $URI_PARTS = parse_url($URI); |
| 791 | - if(empty($url)) |
|
| 791 | + if (empty($url)) |
|
| 792 | 792 | $url = "/"; |
| 793 | 793 | $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; |
| 794 | - if(!empty($this->agent)) |
|
| 794 | + if ( ! empty($this->agent)) |
|
| 795 | 795 | $headers .= "User-Agent: ".$this->agent."\r\n"; |
| 796 | - if(!empty($this->host) && !isset($this->rawheaders['Host'])) { |
|
| 796 | + if ( ! empty($this->host) && ! isset($this->rawheaders['Host'])) { |
|
| 797 | 797 | $headers .= "Host: ".$this->host; |
| 798 | - if(!empty($this->port) && $this->port != 80) |
|
| 798 | + if ( ! empty($this->port) && $this->port != 80) |
|
| 799 | 799 | $headers .= ":".$this->port; |
| 800 | 800 | $headers .= "\r\n"; |
| 801 | 801 | } |
| 802 | - if(!empty($this->accept)) |
|
| 802 | + if ( ! empty($this->accept)) |
|
| 803 | 803 | $headers .= "Accept: ".$this->accept."\r\n"; |
| 804 | - if(!empty($this->referer)) |
|
| 804 | + if ( ! empty($this->referer)) |
|
| 805 | 805 | $headers .= "Referer: ".$this->referer."\r\n"; |
| 806 | - if(!empty($this->cookies)) |
|
| 806 | + if ( ! empty($this->cookies)) |
|
| 807 | 807 | { |
| 808 | - if(!is_array($this->cookies)) |
|
| 809 | - $this->cookies = (array)$this->cookies; |
|
| 808 | + if ( ! is_array($this->cookies)) |
|
| 809 | + $this->cookies = (array) $this->cookies; |
|
| 810 | 810 | |
| 811 | 811 | reset($this->cookies); |
| 812 | - if ( count($this->cookies) > 0 ) { |
|
| 812 | + if (count($this->cookies) > 0) { |
|
| 813 | 813 | $cookie_headers .= 'Cookie: '; |
| 814 | - foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
| 814 | + foreach ($this->cookies as $cookieKey => $cookieVal) { |
|
| 815 | 815 | $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; |
| 816 | 816 | } |
| 817 | - $headers .= substr($cookie_headers,0,-2) . "\r\n"; |
|
| 817 | + $headers .= substr($cookie_headers, 0, -2)."\r\n"; |
|
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | - if(!empty($this->rawheaders)) |
|
| 820 | + if ( ! empty($this->rawheaders)) |
|
| 821 | 821 | { |
| 822 | - if(!is_array($this->rawheaders)) |
|
| 823 | - $this->rawheaders = (array)$this->rawheaders; |
|
| 824 | - while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
| 822 | + if ( ! is_array($this->rawheaders)) |
|
| 823 | + $this->rawheaders = (array) $this->rawheaders; |
|
| 824 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
| 825 | 825 | $headers .= $headerKey.": ".$headerVal."\r\n"; |
| 826 | 826 | } |
| 827 | - if(!empty($content_type)) { |
|
| 827 | + if ( ! empty($content_type)) { |
|
| 828 | 828 | $headers .= "Content-type: $content_type"; |
| 829 | 829 | if ($content_type == "multipart/form-data") |
| 830 | 830 | $headers .= "; boundary=".$this->_mime_boundary; |
| 831 | 831 | $headers .= "\r\n"; |
| 832 | 832 | } |
| 833 | - if(!empty($body)) |
|
| 833 | + if ( ! empty($body)) |
|
| 834 | 834 | $headers .= "Content-length: ".strlen($body)."\r\n"; |
| 835 | - if(!empty($this->user) || !empty($this->pass)) |
|
| 835 | + if ( ! empty($this->user) || ! empty($this->pass)) |
|
| 836 | 836 | $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; |
| 837 | 837 | |
| 838 | 838 | //add proxy auth headers |
| 839 | - if(!empty($this->proxy_user)) |
|
| 840 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n"; |
|
| 839 | + if ( ! empty($this->proxy_user)) |
|
| 840 | + $headers .= 'Proxy-Authorization: '.'Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass)."\r\n"; |
|
| 841 | 841 | |
| 842 | 842 | |
| 843 | 843 | $headers .= "\r\n"; |
@@ -847,34 +847,34 @@ discard block |
||
| 847 | 847 | socket_set_timeout($fp, $this->read_timeout); |
| 848 | 848 | $this->timed_out = false; |
| 849 | 849 | |
| 850 | - fwrite($fp,$headers.$body,strlen($headers.$body)); |
|
| 850 | + fwrite($fp, $headers.$body, strlen($headers.$body)); |
|
| 851 | 851 | |
| 852 | 852 | $this->_redirectaddr = false; |
| 853 | 853 | unset($this->headers); |
| 854 | 854 | |
| 855 | - while($currentHeader = fgets($fp,$this->_maxlinelen)) |
|
| 855 | + while ($currentHeader = fgets($fp, $this->_maxlinelen)) |
|
| 856 | 856 | { |
| 857 | 857 | if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
| 858 | 858 | { |
| 859 | - $this->status=-100; |
|
| 859 | + $this->status = -100; |
|
| 860 | 860 | return false; |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | - if($currentHeader == "\r\n") |
|
| 863 | + if ($currentHeader == "\r\n") |
|
| 864 | 864 | break; |
| 865 | 865 | |
| 866 | 866 | // if a header begins with Location: or URI:, set the redirect |
| 867 | - if(preg_match("/^(Location:|URI:)/i",$currentHeader)) |
|
| 867 | + if (preg_match("/^(Location:|URI:)/i", $currentHeader)) |
|
| 868 | 868 | { |
| 869 | 869 | // get URL portion of the redirect |
| 870 | - preg_match("/^(Location:|URI:)[ ]+(.*)/i",chop($currentHeader),$matches); |
|
| 870 | + preg_match("/^(Location:|URI:)[ ]+(.*)/i", chop($currentHeader), $matches); |
|
| 871 | 871 | // look for :// in the Location header to see if hostname is included |
| 872 | - if(!preg_match("|\:\/\/|",$matches[2])) |
|
| 872 | + if ( ! preg_match("|\:\/\/|", $matches[2])) |
|
| 873 | 873 | { |
| 874 | 874 | // no host in the path, so prepend |
| 875 | 875 | $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
| 876 | 876 | // eliminate double slash |
| 877 | - if(!preg_match("|^/|",$matches[2])) |
|
| 877 | + if ( ! preg_match("|^/|", $matches[2])) |
|
| 878 | 878 | $this->_redirectaddr .= "/".$matches[2]; |
| 879 | 879 | else |
| 880 | 880 | $this->_redirectaddr .= $matches[2]; |
@@ -883,11 +883,11 @@ discard block |
||
| 883 | 883 | $this->_redirectaddr = $matches[2]; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - if(preg_match("|^HTTP/|",$currentHeader)) |
|
| 886 | + if (preg_match("|^HTTP/|", $currentHeader)) |
|
| 887 | 887 | { |
| 888 | - if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) |
|
| 888 | + if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $currentHeader, $status)) |
|
| 889 | 889 | { |
| 890 | - $this->status= $status[1]; |
|
| 890 | + $this->status = $status[1]; |
|
| 891 | 891 | } |
| 892 | 892 | $this->response_code = $currentHeader; |
| 893 | 893 | } |
@@ -902,31 +902,31 @@ discard block |
||
| 902 | 902 | break; |
| 903 | 903 | } |
| 904 | 904 | $results .= $_data; |
| 905 | - } while(true); |
|
| 905 | + } while (true); |
|
| 906 | 906 | |
| 907 | 907 | if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
| 908 | 908 | { |
| 909 | - $this->status=-100; |
|
| 909 | + $this->status = -100; |
|
| 910 | 910 | return false; |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | // check if there is a redirect meta tag |
| 914 | 914 | |
| 915 | - if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
| 915 | + if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match)) |
|
| 916 | 916 | |
| 917 | 917 | { |
| 918 | - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
| 918 | + $this->_redirectaddr = $this->_expandlinks($match[1], $URI); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | // have we hit our frame depth and is there frame src to fetch? |
| 922 | - if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
| 922 | + if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) |
|
| 923 | 923 | { |
| 924 | 924 | $this->results[] = $results; |
| 925 | - for($x=0; $x<count($match[1]); $x++) |
|
| 926 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
| 925 | + for ($x = 0; $x < count($match[1]); $x++) |
|
| 926 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host); |
|
| 927 | 927 | } |
| 928 | 928 | // have we already fetched framed content? |
| 929 | - elseif(is_array($this->results)) |
|
| 929 | + elseif (is_array($this->results)) |
|
| 930 | 930 | $this->results[] = $results; |
| 931 | 931 | // no framed content |
| 932 | 932 | else |
@@ -944,108 +944,108 @@ discard block |
||
| 944 | 944 | Output: |
| 945 | 945 | \*======================================================================*/ |
| 946 | 946 | |
| 947 | - function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") |
|
| 947 | + function _httpsrequest($url, $URI, $http_method, $content_type = "", $body = "") |
|
| 948 | 948 | { |
| 949 | - if($this->passcookies && $this->_redirectaddr) |
|
| 949 | + if ($this->passcookies && $this->_redirectaddr) |
|
| 950 | 950 | $this->setcookies(); |
| 951 | 951 | |
| 952 | 952 | $headers = array(); |
| 953 | 953 | |
| 954 | 954 | $URI_PARTS = parse_url($URI); |
| 955 | - if(empty($url)) |
|
| 955 | + if (empty($url)) |
|
| 956 | 956 | $url = "/"; |
| 957 | 957 | // GET ... header not needed for curl |
| 958 | 958 | //$headers[] = $http_method." ".$url." ".$this->_httpversion; |
| 959 | - if(!empty($this->agent)) |
|
| 959 | + if ( ! empty($this->agent)) |
|
| 960 | 960 | $headers[] = "User-Agent: ".$this->agent; |
| 961 | - if(!empty($this->host)) |
|
| 962 | - if(!empty($this->port)) |
|
| 961 | + if ( ! empty($this->host)) |
|
| 962 | + if ( ! empty($this->port)) |
|
| 963 | 963 | $headers[] = "Host: ".$this->host.":".$this->port; |
| 964 | 964 | else |
| 965 | 965 | $headers[] = "Host: ".$this->host; |
| 966 | - if(!empty($this->accept)) |
|
| 966 | + if ( ! empty($this->accept)) |
|
| 967 | 967 | $headers[] = "Accept: ".$this->accept; |
| 968 | - if(!empty($this->referer)) |
|
| 968 | + if ( ! empty($this->referer)) |
|
| 969 | 969 | $headers[] = "Referer: ".$this->referer; |
| 970 | - if(!empty($this->cookies)) |
|
| 970 | + if ( ! empty($this->cookies)) |
|
| 971 | 971 | { |
| 972 | - if(!is_array($this->cookies)) |
|
| 973 | - $this->cookies = (array)$this->cookies; |
|
| 972 | + if ( ! is_array($this->cookies)) |
|
| 973 | + $this->cookies = (array) $this->cookies; |
|
| 974 | 974 | |
| 975 | 975 | reset($this->cookies); |
| 976 | - if ( count($this->cookies) > 0 ) { |
|
| 976 | + if (count($this->cookies) > 0) { |
|
| 977 | 977 | $cookie_str = 'Cookie: '; |
| 978 | - foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
| 978 | + foreach ($this->cookies as $cookieKey => $cookieVal) { |
|
| 979 | 979 | $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; |
| 980 | 980 | } |
| 981 | - $headers[] = substr($cookie_str,0,-2); |
|
| 981 | + $headers[] = substr($cookie_str, 0, -2); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | - if(!empty($this->rawheaders)) |
|
| 984 | + if ( ! empty($this->rawheaders)) |
|
| 985 | 985 | { |
| 986 | - if(!is_array($this->rawheaders)) |
|
| 987 | - $this->rawheaders = (array)$this->rawheaders; |
|
| 988 | - while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
| 986 | + if ( ! is_array($this->rawheaders)) |
|
| 987 | + $this->rawheaders = (array) $this->rawheaders; |
|
| 988 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
| 989 | 989 | $headers[] = $headerKey.": ".$headerVal; |
| 990 | 990 | } |
| 991 | - if(!empty($content_type)) { |
|
| 991 | + if ( ! empty($content_type)) { |
|
| 992 | 992 | if ($content_type == "multipart/form-data") |
| 993 | 993 | $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; |
| 994 | 994 | else |
| 995 | 995 | $headers[] = "Content-type: $content_type"; |
| 996 | 996 | } |
| 997 | - if(!empty($body)) |
|
| 997 | + if ( ! empty($body)) |
|
| 998 | 998 | $headers[] = "Content-length: ".strlen($body); |
| 999 | - if(!empty($this->user) || !empty($this->pass)) |
|
| 999 | + if ( ! empty($this->user) || ! empty($this->pass)) |
|
| 1000 | 1000 | $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); |
| 1001 | 1001 | |
| 1002 | - $headerfile = tempnam( $this->temp_dir, "sno" ); |
|
| 1003 | - $cmdline_params = '-k -D ' . escapeshellarg( $headerfile ); |
|
| 1002 | + $headerfile = tempnam($this->temp_dir, "sno"); |
|
| 1003 | + $cmdline_params = '-k -D '.escapeshellarg($headerfile); |
|
| 1004 | 1004 | |
| 1005 | - foreach ( $headers as $header ) { |
|
| 1006 | - $cmdline_params .= ' -H ' . escapeshellarg( $header ); |
|
| 1005 | + foreach ($headers as $header) { |
|
| 1006 | + $cmdline_params .= ' -H '.escapeshellarg($header); |
|
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( ! empty( $body ) ) { |
|
| 1010 | - $cmdline_params .= ' -d ' . escapeshellarg( $body ); |
|
| 1009 | + if ( ! empty($body)) { |
|
| 1010 | + $cmdline_params .= ' -d '.escapeshellarg($body); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( $this->read_timeout > 0 ) { |
|
| 1014 | - $cmdline_params .= ' -m ' . escapeshellarg( $this->read_timeout ); |
|
| 1013 | + if ($this->read_timeout > 0) { |
|
| 1014 | + $cmdline_params .= ' -m '.escapeshellarg($this->read_timeout); |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | |
| 1018 | - exec( $this->curl_path . ' ' . $cmdline_params . ' ' . escapeshellarg( $URI ), $results, $return ); |
|
| 1018 | + exec($this->curl_path.' '.$cmdline_params.' '.escapeshellarg($URI), $results, $return); |
|
| 1019 | 1019 | |
| 1020 | - if($return) |
|
| 1020 | + if ($return) |
|
| 1021 | 1021 | { |
| 1022 | 1022 | $this->error = "Error: cURL could not retrieve the document, error $return."; |
| 1023 | 1023 | return false; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | |
| 1027 | - $results = implode("\r\n",$results); |
|
| 1027 | + $results = implode("\r\n", $results); |
|
| 1028 | 1028 | |
| 1029 | 1029 | $result_headers = file("$headerfile"); |
| 1030 | 1030 | |
| 1031 | 1031 | $this->_redirectaddr = false; |
| 1032 | 1032 | unset($this->headers); |
| 1033 | 1033 | |
| 1034 | - for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) |
|
| 1034 | + for ($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) |
|
| 1035 | 1035 | { |
| 1036 | 1036 | |
| 1037 | 1037 | // if a header begins with Location: or URI:, set the redirect |
| 1038 | - if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) |
|
| 1038 | + if (preg_match("/^(Location: |URI: )/i", $result_headers[$currentHeader])) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | // get URL portion of the redirect |
| 1041 | - preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches); |
|
| 1041 | + preg_match("/^(Location: |URI:)\s+(.*)/", chop($result_headers[$currentHeader]), $matches); |
|
| 1042 | 1042 | // look for :// in the Location header to see if hostname is included |
| 1043 | - if(!preg_match("|\:\/\/|",$matches[2])) |
|
| 1043 | + if ( ! preg_match("|\:\/\/|", $matches[2])) |
|
| 1044 | 1044 | { |
| 1045 | 1045 | // no host in the path, so prepend |
| 1046 | 1046 | $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
| 1047 | 1047 | // eliminate double slash |
| 1048 | - if(!preg_match("|^/|",$matches[2])) |
|
| 1048 | + if ( ! preg_match("|^/|", $matches[2])) |
|
| 1049 | 1049 | $this->_redirectaddr .= "/".$matches[2]; |
| 1050 | 1050 | else |
| 1051 | 1051 | $this->_redirectaddr .= $matches[2]; |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | $this->_redirectaddr = $matches[2]; |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) |
|
| 1057 | + if (preg_match("|^HTTP/|", $result_headers[$currentHeader])) |
|
| 1058 | 1058 | $this->response_code = $result_headers[$currentHeader]; |
| 1059 | 1059 | |
| 1060 | 1060 | $this->headers[] = $result_headers[$currentHeader]; |
@@ -1062,20 +1062,20 @@ discard block |
||
| 1062 | 1062 | |
| 1063 | 1063 | // check if there is a redirect meta tag |
| 1064 | 1064 | |
| 1065 | - if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
| 1065 | + if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match)) |
|
| 1066 | 1066 | { |
| 1067 | - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
| 1067 | + $this->_redirectaddr = $this->_expandlinks($match[1], $URI); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | // have we hit our frame depth and is there frame src to fetch? |
| 1071 | - if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
| 1071 | + if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) |
|
| 1072 | 1072 | { |
| 1073 | 1073 | $this->results[] = $results; |
| 1074 | - for($x=0; $x<count($match[1]); $x++) |
|
| 1075 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
| 1074 | + for ($x = 0; $x < count($match[1]); $x++) |
|
| 1075 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | // have we already fetched framed content? |
| 1078 | - elseif(is_array($this->results)) |
|
| 1078 | + elseif (is_array($this->results)) |
|
| 1079 | 1079 | $this->results[] = $results; |
| 1080 | 1080 | // no framed content |
| 1081 | 1081 | else |
@@ -1093,9 +1093,9 @@ discard block |
||
| 1093 | 1093 | |
| 1094 | 1094 | function setcookies() |
| 1095 | 1095 | { |
| 1096 | - for($x=0; $x<count($this->headers); $x++) |
|
| 1096 | + for ($x = 0; $x < count($this->headers); $x++) |
|
| 1097 | 1097 | { |
| 1098 | - if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match)) |
|
| 1098 | + if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) |
|
| 1099 | 1099 | $this->cookies[$match[1]] = urldecode($match[2]); |
| 1100 | 1100 | } |
| 1101 | 1101 | } |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | |
| 1128 | 1128 | function _connect(&$fp) |
| 1129 | 1129 | { |
| 1130 | - if(!empty($this->proxy_host) && !empty($this->proxy_port)) |
|
| 1130 | + if ( ! empty($this->proxy_host) && ! empty($this->proxy_port)) |
|
| 1131 | 1131 | { |
| 1132 | 1132 | $this->_isproxy = true; |
| 1133 | 1133 | |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | |
| 1143 | 1143 | $this->status = 0; |
| 1144 | 1144 | |
| 1145 | - if($fp = fsockopen( |
|
| 1145 | + if ($fp = fsockopen( |
|
| 1146 | 1146 | $host, |
| 1147 | 1147 | $port, |
| 1148 | 1148 | $errno, |
@@ -1158,16 +1158,16 @@ discard block |
||
| 1158 | 1158 | { |
| 1159 | 1159 | // socket connection failed |
| 1160 | 1160 | $this->status = $errno; |
| 1161 | - switch($errno) |
|
| 1161 | + switch ($errno) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | case -3: |
| 1164 | - $this->error="socket creation failed (-3)"; |
|
| 1164 | + $this->error = "socket creation failed (-3)"; |
|
| 1165 | 1165 | case -4: |
| 1166 | - $this->error="dns lookup failure (-4)"; |
|
| 1166 | + $this->error = "dns lookup failure (-4)"; |
|
| 1167 | 1167 | case -5: |
| 1168 | - $this->error="connection refused or timed out (-5)"; |
|
| 1168 | + $this->error = "connection refused or timed out (-5)"; |
|
| 1169 | 1169 | default: |
| 1170 | - $this->error="connection failed (".$errno.")"; |
|
| 1170 | + $this->error = "connection failed (".$errno.")"; |
|
| 1171 | 1171 | } |
| 1172 | 1172 | return false; |
| 1173 | 1173 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | switch ($this->_submit_type) { |
| 1205 | 1205 | case "application/x-www-form-urlencoded": |
| 1206 | 1206 | reset($formvars); |
| 1207 | - while(list($key,$val) = each($formvars)) { |
|
| 1207 | + while (list($key, $val) = each($formvars)) { |
|
| 1208 | 1208 | if (is_array($val) || is_object($val)) { |
| 1209 | 1209 | while (list($cur_key, $cur_val) = each($val)) { |
| 1210 | 1210 | $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); |
| 1219 | 1219 | |
| 1220 | 1220 | reset($formvars); |
| 1221 | - while(list($key,$val) = each($formvars)) { |
|
| 1221 | + while (list($key, $val) = each($formvars)) { |
|
| 1222 | 1222 | if (is_array($val) || is_object($val)) { |
| 1223 | 1223 | while (list($cur_key, $cur_val) = each($val)) { |
| 1224 | 1224 | $postdata .= "--".$this->_mime_boundary."\r\n"; |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | while (list($field_name, $file_names) = each($formfiles)) { |
| 1237 | 1237 | settype($file_names, "array"); |
| 1238 | 1238 | while (list(, $file_name) = each($file_names)) { |
| 1239 | - if (!is_readable($file_name)) continue; |
|
| 1239 | + if ( ! is_readable($file_name)) continue; |
|
| 1240 | 1240 | |
| 1241 | 1241 | $fp = fopen($file_name, "r"); |
| 1242 | 1242 | $file_content = fread($fp, filesize($file_name)); |
@@ -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,14 +174,14 @@ 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 | 187 | /** |
@@ -197,31 +197,31 @@ discard block |
||
| 197 | 197 | * @param bool $enable_checks Whether to enable maintenance mode. Default true. |
| 198 | 198 | * @param int $upgrading The timestamp set in the .maintenance file. |
| 199 | 199 | */ |
| 200 | - if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
|
| 200 | + if ( ! apply_filters('enable_maintenance_mode', true, $upgrading)) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { |
|
| 205 | - require_once( WP_CONTENT_DIR . '/maintenance.php' ); |
|
| 204 | + if (file_exists(WP_CONTENT_DIR.'/maintenance.php')) { |
|
| 205 | + require_once(WP_CONTENT_DIR.'/maintenance.php'); |
|
| 206 | 206 | die(); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | wp_load_translations_early(); |
| 210 | 210 | |
| 211 | 211 | $protocol = wp_get_server_protocol(); |
| 212 | - header( "$protocol 503 Service Unavailable", true, 503 ); |
|
| 213 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 214 | - header( 'Retry-After: 600' ); |
|
| 212 | + header("$protocol 503 Service Unavailable", true, 503); |
|
| 213 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 214 | + header('Retry-After: 600'); |
|
| 215 | 215 | ?> |
| 216 | 216 | <!DOCTYPE html> |
| 217 | - <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
| 217 | + <html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>> |
|
| 218 | 218 | <head> |
| 219 | 219 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 220 | - <title><?php _e( 'Maintenance' ); ?></title> |
|
| 220 | + <title><?php _e('Maintenance'); ?></title> |
|
| 221 | 221 | |
| 222 | 222 | </head> |
| 223 | 223 | <body> |
| 224 | - <h1><?php _e( 'Briefly unavailable for scheduled maintenance. Check back in a minute.' ); ?></h1> |
|
| 224 | + <h1><?php _e('Briefly unavailable for scheduled maintenance. Check back in a minute.'); ?></h1> |
|
| 225 | 225 | </body> |
| 226 | 226 | </html> |
| 227 | 227 | <?php |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | function timer_start() { |
| 243 | 243 | global $timestart; |
| 244 | - $timestart = microtime( true ); |
|
| 244 | + $timestart = microtime(true); |
|
| 245 | 245 | return true; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | * @return string The "second.microsecond" finished time calculation. The number is formatted |
| 261 | 261 | * for human consumption, both localized and rounded. |
| 262 | 262 | */ |
| 263 | -function timer_stop( $display = 0, $precision = 3 ) { |
|
| 263 | +function timer_stop($display = 0, $precision = 3) { |
|
| 264 | 264 | global $timestart, $timeend; |
| 265 | - $timeend = microtime( true ); |
|
| 265 | + $timeend = microtime(true); |
|
| 266 | 266 | $timetotal = $timeend - $timestart; |
| 267 | - $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); |
|
| 268 | - if ( $display ) |
|
| 267 | + $r = (function_exists('number_format_i18n')) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); |
|
| 268 | + if ($display) |
|
| 269 | 269 | echo $r; |
| 270 | 270 | return $r; |
| 271 | 271 | } |
@@ -314,28 +314,28 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true. |
| 316 | 316 | */ |
| 317 | - if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ){ |
|
| 317 | + if ( ! apply_filters('enable_wp_debug_mode_checks', true)) { |
|
| 318 | 318 | return; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if ( WP_DEBUG ) { |
|
| 322 | - error_reporting( E_ALL ); |
|
| 321 | + if (WP_DEBUG) { |
|
| 322 | + error_reporting(E_ALL); |
|
| 323 | 323 | |
| 324 | - if ( WP_DEBUG_DISPLAY ) |
|
| 325 | - ini_set( 'display_errors', 1 ); |
|
| 326 | - elseif ( null !== WP_DEBUG_DISPLAY ) |
|
| 327 | - ini_set( 'display_errors', 0 ); |
|
| 324 | + if (WP_DEBUG_DISPLAY) |
|
| 325 | + ini_set('display_errors', 1); |
|
| 326 | + elseif (null !== WP_DEBUG_DISPLAY) |
|
| 327 | + ini_set('display_errors', 0); |
|
| 328 | 328 | |
| 329 | - if ( WP_DEBUG_LOG ) { |
|
| 330 | - ini_set( 'log_errors', 1 ); |
|
| 331 | - ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' ); |
|
| 329 | + if (WP_DEBUG_LOG) { |
|
| 330 | + ini_set('log_errors', 1); |
|
| 331 | + ini_set('error_log', WP_CONTENT_DIR.'/debug.log'); |
|
| 332 | 332 | } |
| 333 | 333 | } else { |
| 334 | - 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 ); |
|
| 334 | + 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); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 338 | - @ini_set( 'display_errors', 0 ); |
|
| 337 | + if (defined('XMLRPC_REQUEST') || defined('REST_REQUEST') || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 338 | + @ini_set('display_errors', 0); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | * @access private |
| 354 | 354 | */ |
| 355 | 355 | function wp_set_lang_dir() { |
| 356 | - if ( !defined( 'WP_LANG_DIR' ) ) { |
|
| 357 | - if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) { |
|
| 356 | + if ( ! defined('WP_LANG_DIR')) { |
|
| 357 | + if (file_exists(WP_CONTENT_DIR.'/languages') && @is_dir(WP_CONTENT_DIR.'/languages') || ! @is_dir(ABSPATH.WPINC.'/languages')) { |
|
| 358 | 358 | /** |
| 359 | 359 | * Server path of the language directory. |
| 360 | 360 | * |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @since 2.1.0 |
| 364 | 364 | */ |
| 365 | - define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); |
|
| 366 | - if ( !defined( 'LANGDIR' ) ) { |
|
| 365 | + define('WP_LANG_DIR', WP_CONTENT_DIR.'/languages'); |
|
| 366 | + if ( ! defined('LANGDIR')) { |
|
| 367 | 367 | // Old static relative path maintained for limited backward compatibility - won't work in some cases. |
| 368 | - define( 'LANGDIR', 'wp-content/languages' ); |
|
| 368 | + define('LANGDIR', 'wp-content/languages'); |
|
| 369 | 369 | } |
| 370 | 370 | } else { |
| 371 | 371 | /** |
@@ -375,10 +375,10 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @since 2.1.0 |
| 377 | 377 | */ |
| 378 | - define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); |
|
| 379 | - if ( !defined( 'LANGDIR' ) ) { |
|
| 378 | + define('WP_LANG_DIR', ABSPATH.WPINC.'/languages'); |
|
| 379 | + if ( ! defined('LANGDIR')) { |
|
| 380 | 380 | // Old relative path maintained for backward compatibility. |
| 381 | - define( 'LANGDIR', WPINC . '/languages' ); |
|
| 381 | + define('LANGDIR', WPINC.'/languages'); |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -394,14 +394,14 @@ discard block |
||
| 394 | 394 | function require_wp_db() { |
| 395 | 395 | global $wpdb; |
| 396 | 396 | |
| 397 | - require_once( ABSPATH . WPINC . '/wp-db.php' ); |
|
| 398 | - if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) |
|
| 399 | - require_once( WP_CONTENT_DIR . '/db.php' ); |
|
| 397 | + require_once(ABSPATH.WPINC.'/wp-db.php'); |
|
| 398 | + if (file_exists(WP_CONTENT_DIR.'/db.php')) |
|
| 399 | + require_once(WP_CONTENT_DIR.'/db.php'); |
|
| 400 | 400 | |
| 401 | - if ( isset( $wpdb ) ) |
|
| 401 | + if (isset($wpdb)) |
|
| 402 | 402 | return; |
| 403 | 403 | |
| 404 | - $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); |
|
| 404 | + $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -418,24 +418,24 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | function wp_set_wpdb_vars() { |
| 420 | 420 | global $wpdb, $table_prefix; |
| 421 | - if ( !empty( $wpdb->error ) ) |
|
| 421 | + if ( ! empty($wpdb->error)) |
|
| 422 | 422 | dead_db(); |
| 423 | 423 | |
| 424 | - $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
| 425 | - 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
| 424 | + $wpdb->field_types = array('post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', |
|
| 425 | + 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', |
|
| 426 | 426 | 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', |
| 427 | 427 | 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', |
| 428 | 428 | // multisite: |
| 429 | 429 | 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', |
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | - $prefix = $wpdb->set_prefix( $table_prefix ); |
|
| 432 | + $prefix = $wpdb->set_prefix($table_prefix); |
|
| 433 | 433 | |
| 434 | - if ( is_wp_error( $prefix ) ) { |
|
| 434 | + if (is_wp_error($prefix)) { |
|
| 435 | 435 | wp_load_translations_early(); |
| 436 | 436 | wp_die( |
| 437 | 437 | /* translators: 1: $table_prefix 2: wp-config.php */ |
| 438 | - sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), |
|
| 438 | + sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'), |
|
| 439 | 439 | '<code>$table_prefix</code>', |
| 440 | 440 | '<code>wp-config.php</code>' |
| 441 | 441 | ) |
@@ -454,10 +454,10 @@ discard block |
||
| 454 | 454 | * @param bool $using Whether external object cache is being used. |
| 455 | 455 | * @return bool The current 'using' setting. |
| 456 | 456 | */ |
| 457 | -function wp_using_ext_object_cache( $using = null ) { |
|
| 457 | +function wp_using_ext_object_cache($using = null) { |
|
| 458 | 458 | global $_wp_using_ext_object_cache; |
| 459 | 459 | $current_using = $_wp_using_ext_object_cache; |
| 460 | - if ( null !== $using ) |
|
| 460 | + if (null !== $using) |
|
| 461 | 461 | $_wp_using_ext_object_cache = $using; |
| 462 | 462 | return $current_using; |
| 463 | 463 | } |
@@ -477,40 +477,40 @@ discard block |
||
| 477 | 477 | global $blog_id; |
| 478 | 478 | |
| 479 | 479 | $first_init = false; |
| 480 | - if ( ! function_exists( 'wp_cache_init' ) ) { |
|
| 481 | - if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
| 482 | - require_once ( WP_CONTENT_DIR . '/object-cache.php' ); |
|
| 483 | - if ( function_exists( 'wp_cache_init' ) ) |
|
| 484 | - wp_using_ext_object_cache( true ); |
|
| 480 | + if ( ! function_exists('wp_cache_init')) { |
|
| 481 | + if (file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
| 482 | + require_once (WP_CONTENT_DIR.'/object-cache.php'); |
|
| 483 | + if (function_exists('wp_cache_init')) |
|
| 484 | + wp_using_ext_object_cache(true); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | $first_init = true; |
| 488 | - } elseif ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { |
|
| 488 | + } elseif ( ! wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR.'/object-cache.php')) { |
|
| 489 | 489 | /* |
| 490 | 490 | * Sometimes advanced-cache.php can load object-cache.php before |
| 491 | 491 | * it is loaded here. This breaks the function_exists check above |
| 492 | 492 | * and can result in `$_wp_using_ext_object_cache` being set |
| 493 | 493 | * incorrectly. Double check if an external cache exists. |
| 494 | 494 | */ |
| 495 | - wp_using_ext_object_cache( true ); |
|
| 495 | + wp_using_ext_object_cache(true); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - if ( ! wp_using_ext_object_cache() ) |
|
| 499 | - require_once ( ABSPATH . WPINC . '/cache.php' ); |
|
| 498 | + if ( ! wp_using_ext_object_cache()) |
|
| 499 | + require_once (ABSPATH.WPINC.'/cache.php'); |
|
| 500 | 500 | |
| 501 | 501 | /* |
| 502 | 502 | * If cache supports reset, reset instead of init if already |
| 503 | 503 | * initialized. Reset signals to the cache that global IDs |
| 504 | 504 | * have changed and it may need to update keys and cleanup caches. |
| 505 | 505 | */ |
| 506 | - if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) |
|
| 507 | - wp_cache_switch_to_blog( $blog_id ); |
|
| 508 | - elseif ( function_exists( 'wp_cache_init' ) ) |
|
| 506 | + if ( ! $first_init && function_exists('wp_cache_switch_to_blog')) |
|
| 507 | + wp_cache_switch_to_blog($blog_id); |
|
| 508 | + elseif (function_exists('wp_cache_init')) |
|
| 509 | 509 | wp_cache_init(); |
| 510 | 510 | |
| 511 | - if ( function_exists( 'wp_cache_add_global_groups' ) ) { |
|
| 512 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) ); |
|
| 513 | - wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
|
| 511 | + if (function_exists('wp_cache_add_global_groups')) { |
|
| 512 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites')); |
|
| 513 | + wp_cache_add_non_persistent_groups(array('counts', 'plugins')); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
@@ -523,22 +523,22 @@ discard block |
||
| 523 | 523 | * @access private |
| 524 | 524 | */ |
| 525 | 525 | function wp_not_installed() { |
| 526 | - if ( is_multisite() ) { |
|
| 527 | - if ( ! is_blog_installed() && ! wp_installing() ) { |
|
| 526 | + if (is_multisite()) { |
|
| 527 | + if ( ! is_blog_installed() && ! wp_installing()) { |
|
| 528 | 528 | nocache_headers(); |
| 529 | 529 | |
| 530 | - wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) ); |
|
| 530 | + wp_die(__('The site you have requested is not installed properly. Please contact the system administrator.')); |
|
| 531 | 531 | } |
| 532 | - } elseif ( ! is_blog_installed() && ! wp_installing() ) { |
|
| 532 | + } elseif ( ! is_blog_installed() && ! wp_installing()) { |
|
| 533 | 533 | nocache_headers(); |
| 534 | 534 | |
| 535 | - require( ABSPATH . WPINC . '/kses.php' ); |
|
| 536 | - require( ABSPATH . WPINC . '/pluggable.php' ); |
|
| 537 | - require( ABSPATH . WPINC . '/formatting.php' ); |
|
| 535 | + require(ABSPATH.WPINC.'/kses.php'); |
|
| 536 | + require(ABSPATH.WPINC.'/pluggable.php'); |
|
| 537 | + require(ABSPATH.WPINC.'/formatting.php'); |
|
| 538 | 538 | |
| 539 | - $link = wp_guess_url() . '/wp-admin/install.php'; |
|
| 539 | + $link = wp_guess_url().'/wp-admin/install.php'; |
|
| 540 | 540 | |
| 541 | - wp_redirect( $link ); |
|
| 541 | + wp_redirect($link); |
|
| 542 | 542 | die(); |
| 543 | 543 | } |
| 544 | 544 | } |
@@ -557,16 +557,16 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | function wp_get_mu_plugins() { |
| 559 | 559 | $mu_plugins = array(); |
| 560 | - if ( !is_dir( WPMU_PLUGIN_DIR ) ) |
|
| 560 | + if ( ! is_dir(WPMU_PLUGIN_DIR)) |
|
| 561 | 561 | return $mu_plugins; |
| 562 | - if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) |
|
| 562 | + if ( ! $dh = opendir(WPMU_PLUGIN_DIR)) |
|
| 563 | 563 | return $mu_plugins; |
| 564 | - while ( ( $plugin = readdir( $dh ) ) !== false ) { |
|
| 565 | - if ( substr( $plugin, -4 ) == '.php' ) |
|
| 566 | - $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; |
|
| 564 | + while (($plugin = readdir($dh)) !== false) { |
|
| 565 | + if (substr($plugin, -4) == '.php') |
|
| 566 | + $mu_plugins[] = WPMU_PLUGIN_DIR.'/'.$plugin; |
|
| 567 | 567 | } |
| 568 | - closedir( $dh ); |
|
| 569 | - sort( $mu_plugins ); |
|
| 568 | + closedir($dh); |
|
| 569 | + sort($mu_plugins); |
|
| 570 | 570 | |
| 571 | 571 | return $mu_plugins; |
| 572 | 572 | } |
@@ -587,27 +587,27 @@ discard block |
||
| 587 | 587 | */ |
| 588 | 588 | function wp_get_active_and_valid_plugins() { |
| 589 | 589 | $plugins = array(); |
| 590 | - $active_plugins = (array) get_option( 'active_plugins', array() ); |
|
| 590 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
| 591 | 591 | |
| 592 | 592 | // Check for hacks file if the option is enabled |
| 593 | - if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { |
|
| 594 | - _deprecated_file( 'my-hacks.php', '1.5.0' ); |
|
| 595 | - array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); |
|
| 593 | + if (get_option('hack_file') && file_exists(ABSPATH.'my-hacks.php')) { |
|
| 594 | + _deprecated_file('my-hacks.php', '1.5.0'); |
|
| 595 | + array_unshift($plugins, ABSPATH.'my-hacks.php'); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - if ( empty( $active_plugins ) || wp_installing() ) |
|
| 598 | + if (empty($active_plugins) || wp_installing()) |
|
| 599 | 599 | return $plugins; |
| 600 | 600 | |
| 601 | 601 | $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; |
| 602 | 602 | |
| 603 | - foreach ( $active_plugins as $plugin ) { |
|
| 604 | - if ( ! validate_file( $plugin ) // $plugin must validate as file |
|
| 605 | - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' |
|
| 606 | - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist |
|
| 603 | + foreach ($active_plugins as $plugin) { |
|
| 604 | + if ( ! validate_file($plugin) // $plugin must validate as file |
|
| 605 | + && '.php' == substr($plugin, -4) // $plugin must end with '.php' |
|
| 606 | + && file_exists(WP_PLUGIN_DIR.'/'.$plugin) // $plugin must exist |
|
| 607 | 607 | // not already included as a network plugin |
| 608 | - && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) |
|
| 608 | + && ( ! $network_plugins || ! in_array(WP_PLUGIN_DIR.'/'.$plugin, $network_plugins)) |
|
| 609 | 609 | ) |
| 610 | - $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
| 610 | + $plugins[] = WP_PLUGIN_DIR.'/'.$plugin; |
|
| 611 | 611 | } |
| 612 | 612 | return $plugins; |
| 613 | 613 | } |
@@ -622,10 +622,10 @@ discard block |
||
| 622 | 622 | * @access private |
| 623 | 623 | */ |
| 624 | 624 | function wp_set_internal_encoding() { |
| 625 | - if ( function_exists( 'mb_internal_encoding' ) ) { |
|
| 626 | - $charset = get_option( 'blog_charset' ); |
|
| 627 | - if ( ! $charset || ! @mb_internal_encoding( $charset ) ) |
|
| 628 | - mb_internal_encoding( 'UTF-8' ); |
|
| 625 | + if (function_exists('mb_internal_encoding')) { |
|
| 626 | + $charset = get_option('blog_charset'); |
|
| 627 | + if ( ! $charset || ! @mb_internal_encoding($charset)) |
|
| 628 | + mb_internal_encoding('UTF-8'); |
|
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
@@ -640,20 +640,20 @@ discard block |
||
| 640 | 640 | */ |
| 641 | 641 | function wp_magic_quotes() { |
| 642 | 642 | // If already slashed, strip. |
| 643 | - if ( get_magic_quotes_gpc() ) { |
|
| 644 | - $_GET = stripslashes_deep( $_GET ); |
|
| 645 | - $_POST = stripslashes_deep( $_POST ); |
|
| 646 | - $_COOKIE = stripslashes_deep( $_COOKIE ); |
|
| 643 | + if (get_magic_quotes_gpc()) { |
|
| 644 | + $_GET = stripslashes_deep($_GET); |
|
| 645 | + $_POST = stripslashes_deep($_POST); |
|
| 646 | + $_COOKIE = stripslashes_deep($_COOKIE); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | // Escape with wpdb. |
| 650 | - $_GET = add_magic_quotes( $_GET ); |
|
| 651 | - $_POST = add_magic_quotes( $_POST ); |
|
| 652 | - $_COOKIE = add_magic_quotes( $_COOKIE ); |
|
| 653 | - $_SERVER = add_magic_quotes( $_SERVER ); |
|
| 650 | + $_GET = add_magic_quotes($_GET); |
|
| 651 | + $_POST = add_magic_quotes($_POST); |
|
| 652 | + $_COOKIE = add_magic_quotes($_COOKIE); |
|
| 653 | + $_SERVER = add_magic_quotes($_SERVER); |
|
| 654 | 654 | |
| 655 | 655 | // Force REQUEST to be GET + POST. |
| 656 | - $_REQUEST = array_merge( $_GET, $_POST ); |
|
| 656 | + $_REQUEST = array_merge($_GET, $_POST); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | * |
| 669 | 669 | * @since 1.2.0 |
| 670 | 670 | */ |
| 671 | - do_action( 'shutdown' ); |
|
| 671 | + do_action('shutdown'); |
|
| 672 | 672 | |
| 673 | 673 | wp_cache_close(); |
| 674 | 674 | } |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | * @param object $object The object to clone. |
| 683 | 683 | * @return object The cloned object. |
| 684 | 684 | */ |
| 685 | -function wp_clone( $object ) { |
|
| 685 | +function wp_clone($object) { |
|
| 686 | 686 | // Use parens for clone to accommodate PHP 4. See #17880 |
| 687 | - return clone( $object ); |
|
| 687 | + return clone($object); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | /** |
@@ -700,9 +700,9 @@ discard block |
||
| 700 | 700 | * @return bool True if inside WordPress administration interface, false otherwise. |
| 701 | 701 | */ |
| 702 | 702 | function is_admin() { |
| 703 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 703 | + if (isset($GLOBALS['current_screen'])) |
|
| 704 | 704 | return $GLOBALS['current_screen']->in_admin(); |
| 705 | - elseif ( defined( 'WP_ADMIN' ) ) |
|
| 705 | + elseif (defined('WP_ADMIN')) |
|
| 706 | 706 | return WP_ADMIN; |
| 707 | 707 | |
| 708 | 708 | return false; |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | * @return bool True if inside WordPress blog administration pages. |
| 724 | 724 | */ |
| 725 | 725 | function is_blog_admin() { |
| 726 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 727 | - return $GLOBALS['current_screen']->in_admin( 'site' ); |
|
| 728 | - elseif ( defined( 'WP_BLOG_ADMIN' ) ) |
|
| 726 | + if (isset($GLOBALS['current_screen'])) |
|
| 727 | + return $GLOBALS['current_screen']->in_admin('site'); |
|
| 728 | + elseif (defined('WP_BLOG_ADMIN')) |
|
| 729 | 729 | return WP_BLOG_ADMIN; |
| 730 | 730 | |
| 731 | 731 | return false; |
@@ -746,9 +746,9 @@ discard block |
||
| 746 | 746 | * @return bool True if inside WordPress network administration pages. |
| 747 | 747 | */ |
| 748 | 748 | function is_network_admin() { |
| 749 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 750 | - return $GLOBALS['current_screen']->in_admin( 'network' ); |
|
| 751 | - elseif ( defined( 'WP_NETWORK_ADMIN' ) ) |
|
| 749 | + if (isset($GLOBALS['current_screen'])) |
|
| 750 | + return $GLOBALS['current_screen']->in_admin('network'); |
|
| 751 | + elseif (defined('WP_NETWORK_ADMIN')) |
|
| 752 | 752 | return WP_NETWORK_ADMIN; |
| 753 | 753 | |
| 754 | 754 | return false; |
@@ -770,9 +770,9 @@ discard block |
||
| 770 | 770 | * @return bool True if inside WordPress user administration pages. |
| 771 | 771 | */ |
| 772 | 772 | function is_user_admin() { |
| 773 | - if ( isset( $GLOBALS['current_screen'] ) ) |
|
| 774 | - return $GLOBALS['current_screen']->in_admin( 'user' ); |
|
| 775 | - elseif ( defined( 'WP_USER_ADMIN' ) ) |
|
| 773 | + if (isset($GLOBALS['current_screen'])) |
|
| 774 | + return $GLOBALS['current_screen']->in_admin('user'); |
|
| 775 | + elseif (defined('WP_USER_ADMIN')) |
|
| 776 | 776 | return WP_USER_ADMIN; |
| 777 | 777 | |
| 778 | 778 | return false; |
@@ -786,10 +786,10 @@ discard block |
||
| 786 | 786 | * @return bool True if Multisite is enabled, false otherwise. |
| 787 | 787 | */ |
| 788 | 788 | function is_multisite() { |
| 789 | - if ( defined( 'MULTISITE' ) ) |
|
| 789 | + if (defined('MULTISITE')) |
|
| 790 | 790 | return MULTISITE; |
| 791 | 791 | |
| 792 | - if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) |
|
| 792 | + if (defined('SUBDOMAIN_INSTALL') || defined('VHOST') || defined('SUNRISE')) |
|
| 793 | 793 | return true; |
| 794 | 794 | |
| 795 | 795 | return false; |
@@ -819,17 +819,17 @@ discard block |
||
| 819 | 819 | * @return int The ID of the current network. |
| 820 | 820 | */ |
| 821 | 821 | function get_current_network_id() { |
| 822 | - if ( ! is_multisite() ) { |
|
| 822 | + if ( ! is_multisite()) { |
|
| 823 | 823 | return 1; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | $current_site = get_current_site(); |
| 827 | 827 | |
| 828 | - if ( ! isset( $current_site->id ) ) { |
|
| 828 | + if ( ! isset($current_site->id)) { |
|
| 829 | 829 | return get_main_network_id(); |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - return absint( $current_site->id ); |
|
| 832 | + return absint($current_site->id); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -854,62 +854,62 @@ discard block |
||
| 854 | 854 | global $text_direction, $wp_locale; |
| 855 | 855 | |
| 856 | 856 | static $loaded = false; |
| 857 | - if ( $loaded ) |
|
| 857 | + if ($loaded) |
|
| 858 | 858 | return; |
| 859 | 859 | $loaded = true; |
| 860 | 860 | |
| 861 | - if ( function_exists( 'did_action' ) && did_action( 'init' ) ) |
|
| 861 | + if (function_exists('did_action') && did_action('init')) |
|
| 862 | 862 | return; |
| 863 | 863 | |
| 864 | 864 | // We need $wp_local_package |
| 865 | - require ABSPATH . WPINC . '/version.php'; |
|
| 865 | + require ABSPATH.WPINC.'/version.php'; |
|
| 866 | 866 | |
| 867 | 867 | // Translation and localization |
| 868 | - require_once ABSPATH . WPINC . '/pomo/mo.php'; |
|
| 869 | - require_once ABSPATH . WPINC . '/l10n.php'; |
|
| 870 | - require_once ABSPATH . WPINC . '/locale.php'; |
|
| 868 | + require_once ABSPATH.WPINC.'/pomo/mo.php'; |
|
| 869 | + require_once ABSPATH.WPINC.'/l10n.php'; |
|
| 870 | + require_once ABSPATH.WPINC.'/locale.php'; |
|
| 871 | 871 | |
| 872 | 872 | // General libraries |
| 873 | - require_once ABSPATH . WPINC . '/plugin.php'; |
|
| 873 | + require_once ABSPATH.WPINC.'/plugin.php'; |
|
| 874 | 874 | |
| 875 | 875 | $locales = $locations = array(); |
| 876 | 876 | |
| 877 | - while ( true ) { |
|
| 878 | - if ( defined( 'WPLANG' ) ) { |
|
| 879 | - if ( '' == WPLANG ) |
|
| 877 | + while (true) { |
|
| 878 | + if (defined('WPLANG')) { |
|
| 879 | + if ('' == WPLANG) |
|
| 880 | 880 | break; |
| 881 | 881 | $locales[] = WPLANG; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - if ( isset( $wp_local_package ) ) |
|
| 884 | + if (isset($wp_local_package)) |
|
| 885 | 885 | $locales[] = $wp_local_package; |
| 886 | 886 | |
| 887 | - if ( ! $locales ) |
|
| 887 | + if ( ! $locales) |
|
| 888 | 888 | break; |
| 889 | 889 | |
| 890 | - if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) |
|
| 890 | + if (defined('WP_LANG_DIR') && @is_dir(WP_LANG_DIR)) |
|
| 891 | 891 | $locations[] = WP_LANG_DIR; |
| 892 | 892 | |
| 893 | - if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) |
|
| 894 | - $locations[] = WP_CONTENT_DIR . '/languages'; |
|
| 893 | + if (defined('WP_CONTENT_DIR') && @is_dir(WP_CONTENT_DIR.'/languages')) |
|
| 894 | + $locations[] = WP_CONTENT_DIR.'/languages'; |
|
| 895 | 895 | |
| 896 | - if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) |
|
| 897 | - $locations[] = ABSPATH . 'wp-content/languages'; |
|
| 896 | + if (@is_dir(ABSPATH.'wp-content/languages')) |
|
| 897 | + $locations[] = ABSPATH.'wp-content/languages'; |
|
| 898 | 898 | |
| 899 | - if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) |
|
| 900 | - $locations[] = ABSPATH . WPINC . '/languages'; |
|
| 899 | + if (@is_dir(ABSPATH.WPINC.'/languages')) |
|
| 900 | + $locations[] = ABSPATH.WPINC.'/languages'; |
|
| 901 | 901 | |
| 902 | - if ( ! $locations ) |
|
| 902 | + if ( ! $locations) |
|
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | - $locations = array_unique( $locations ); |
|
| 905 | + $locations = array_unique($locations); |
|
| 906 | 906 | |
| 907 | - foreach ( $locales as $locale ) { |
|
| 908 | - foreach ( $locations as $location ) { |
|
| 909 | - if ( file_exists( $location . '/' . $locale . '.mo' ) ) { |
|
| 910 | - load_textdomain( 'default', $location . '/' . $locale . '.mo' ); |
|
| 911 | - if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) |
|
| 912 | - load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); |
|
| 907 | + foreach ($locales as $locale) { |
|
| 908 | + foreach ($locations as $location) { |
|
| 909 | + if (file_exists($location.'/'.$locale.'.mo')) { |
|
| 910 | + load_textdomain('default', $location.'/'.$locale.'.mo'); |
|
| 911 | + if (defined('WP_SETUP_CONFIG') && file_exists($location.'/admin-'.$locale.'.mo')) |
|
| 912 | + load_textdomain('default', $location.'/admin-'.$locale.'.mo'); |
|
| 913 | 913 | break 2; |
| 914 | 914 | } |
| 915 | 915 | } |
@@ -935,15 +935,15 @@ discard block |
||
| 935 | 935 | * @return bool True if WP is installing, otherwise false. When a `$is_installing` is passed, the function will |
| 936 | 936 | * report whether WP was in installing mode prior to the change to `$is_installing`. |
| 937 | 937 | */ |
| 938 | -function wp_installing( $is_installing = null ) { |
|
| 938 | +function wp_installing($is_installing = null) { |
|
| 939 | 939 | static $installing = null; |
| 940 | 940 | |
| 941 | 941 | // Support for the `WP_INSTALLING` constant, defined before WP is loaded. |
| 942 | - if ( is_null( $installing ) ) { |
|
| 943 | - $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; |
|
| 942 | + if (is_null($installing)) { |
|
| 943 | + $installing = defined('WP_INSTALLING') && WP_INSTALLING; |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - if ( ! is_null( $is_installing ) ) { |
|
| 946 | + if ( ! is_null($is_installing)) { |
|
| 947 | 947 | $old_installing = $installing; |
| 948 | 948 | $installing = $is_installing; |
| 949 | 949 | return (bool) $old_installing; |
@@ -961,15 +961,15 @@ discard block |
||
| 961 | 961 | * @return bool True if SSL, otherwise false. |
| 962 | 962 | */ |
| 963 | 963 | function is_ssl() { |
| 964 | - if ( isset( $_SERVER['HTTPS'] ) ) { |
|
| 965 | - if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) { |
|
| 964 | + if (isset($_SERVER['HTTPS'])) { |
|
| 965 | + if ('on' == strtolower($_SERVER['HTTPS'])) { |
|
| 966 | 966 | return true; |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - if ( '1' == $_SERVER['HTTPS'] ) { |
|
| 969 | + if ('1' == $_SERVER['HTTPS']) { |
|
| 970 | 970 | return true; |
| 971 | 971 | } |
| 972 | - } elseif ( isset($_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { |
|
| 972 | + } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) { |
|
| 973 | 973 | return true; |
| 974 | 974 | } |
| 975 | 975 | return false; |
@@ -987,20 +987,20 @@ discard block |
||
| 987 | 987 | * @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
| 988 | 988 | * @return int An integer byte value. |
| 989 | 989 | */ |
| 990 | -function wp_convert_hr_to_bytes( $value ) { |
|
| 991 | - $value = strtolower( trim( $value ) ); |
|
| 990 | +function wp_convert_hr_to_bytes($value) { |
|
| 991 | + $value = strtolower(trim($value)); |
|
| 992 | 992 | $bytes = (int) $value; |
| 993 | 993 | |
| 994 | - if ( false !== strpos( $value, 'g' ) ) { |
|
| 994 | + if (false !== strpos($value, 'g')) { |
|
| 995 | 995 | $bytes *= GB_IN_BYTES; |
| 996 | - } elseif ( false !== strpos( $value, 'm' ) ) { |
|
| 996 | + } elseif (false !== strpos($value, 'm')) { |
|
| 997 | 997 | $bytes *= MB_IN_BYTES; |
| 998 | - } elseif ( false !== strpos( $value, 'k' ) ) { |
|
| 998 | + } elseif (false !== strpos($value, 'k')) { |
|
| 999 | 999 | $bytes *= KB_IN_BYTES; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | // Deal with large (float) values which run into the maximum integer size. |
| 1003 | - return min( $bytes, PHP_INT_MAX ); |
|
| 1003 | + return min($bytes, PHP_INT_MAX); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
@@ -1013,15 +1013,15 @@ discard block |
||
| 1013 | 1013 | * @param string $setting The name of the ini setting to check. |
| 1014 | 1014 | * @return bool True if the value is changeable at runtime. False otherwise. |
| 1015 | 1015 | */ |
| 1016 | -function wp_is_ini_value_changeable( $setting ) { |
|
| 1016 | +function wp_is_ini_value_changeable($setting) { |
|
| 1017 | 1017 | static $ini_all; |
| 1018 | 1018 | |
| 1019 | - if ( ! isset( $ini_all ) ) { |
|
| 1019 | + if ( ! isset($ini_all)) { |
|
| 1020 | 1020 | $ini_all = ini_get_all(); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | // Bit operator to workaround https://bugs.php.net/bug.php?id=44936 which changes access level to 63 in PHP 5.2.6 - 5.2.17. |
| 1024 | - if ( isset( $ini_all[ $setting ]['access'] ) && ( INI_ALL === ( $ini_all[ $setting ]['access'] & 7 ) || INI_USER === ( $ini_all[ $setting ]['access'] & 7 ) ) ) { |
|
| 1024 | + if (isset($ini_all[$setting]['access']) && (INI_ALL === ($ini_all[$setting]['access'] & 7) || INI_USER === ($ini_all[$setting]['access'] & 7))) { |
|
| 1025 | 1025 | return true; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @access private |
| 51 | 51 | * @var string |
| 52 | 52 | */ |
| 53 | - private static $no_results = array( 'join' => array( '' ), 'where' => array( '0 = 1' ) ); |
|
| 53 | + private static $no_results = array('join' => array(''), 'where' => array('0 = 1')); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * A flat list of table aliases used in the JOIN clauses. |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | * } |
| 119 | 119 | * } |
| 120 | 120 | */ |
| 121 | - public function __construct( $tax_query ) { |
|
| 122 | - if ( isset( $tax_query['relation'] ) ) { |
|
| 123 | - $this->relation = $this->sanitize_relation( $tax_query['relation'] ); |
|
| 121 | + public function __construct($tax_query) { |
|
| 122 | + if (isset($tax_query['relation'])) { |
|
| 123 | + $this->relation = $this->sanitize_relation($tax_query['relation']); |
|
| 124 | 124 | } else { |
| 125 | 125 | $this->relation = 'AND'; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->queries = $this->sanitize_query( $tax_query ); |
|
| 128 | + $this->queries = $this->sanitize_query($tax_query); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param array $queries Array of queries clauses. |
| 141 | 141 | * @return array Sanitized array of query clauses. |
| 142 | 142 | */ |
| 143 | - public function sanitize_query( $queries ) { |
|
| 143 | + public function sanitize_query($queries) { |
|
| 144 | 144 | $cleaned_query = array(); |
| 145 | 145 | |
| 146 | 146 | $defaults = array( |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | 'include_children' => true, |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - foreach ( $queries as $key => $query ) { |
|
| 155 | - if ( 'relation' === $key ) { |
|
| 156 | - $cleaned_query['relation'] = $this->sanitize_relation( $query ); |
|
| 154 | + foreach ($queries as $key => $query) { |
|
| 155 | + if ('relation' === $key) { |
|
| 156 | + $cleaned_query['relation'] = $this->sanitize_relation($query); |
|
| 157 | 157 | |
| 158 | 158 | // First-order clause. |
| 159 | - } elseif ( self::is_first_order_clause( $query ) ) { |
|
| 159 | + } elseif (self::is_first_order_clause($query)) { |
|
| 160 | 160 | |
| 161 | - $cleaned_clause = array_merge( $defaults, $query ); |
|
| 161 | + $cleaned_clause = array_merge($defaults, $query); |
|
| 162 | 162 | $cleaned_clause['terms'] = (array) $cleaned_clause['terms']; |
| 163 | 163 | $cleaned_query[] = $cleaned_clause; |
| 164 | 164 | |
@@ -166,32 +166,32 @@ discard block |
||
| 166 | 166 | * Keep a copy of the clause in the flate |
| 167 | 167 | * $queried_terms array, for use in WP_Query. |
| 168 | 168 | */ |
| 169 | - if ( ! empty( $cleaned_clause['taxonomy'] ) && 'NOT IN' !== $cleaned_clause['operator'] ) { |
|
| 169 | + if ( ! empty($cleaned_clause['taxonomy']) && 'NOT IN' !== $cleaned_clause['operator']) { |
|
| 170 | 170 | $taxonomy = $cleaned_clause['taxonomy']; |
| 171 | - if ( ! isset( $this->queried_terms[ $taxonomy ] ) ) { |
|
| 172 | - $this->queried_terms[ $taxonomy ] = array(); |
|
| 171 | + if ( ! isset($this->queried_terms[$taxonomy])) { |
|
| 172 | + $this->queried_terms[$taxonomy] = array(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /* |
| 176 | 176 | * Backward compatibility: Only store the first |
| 177 | 177 | * 'terms' and 'field' found for a given taxonomy. |
| 178 | 178 | */ |
| 179 | - if ( ! empty( $cleaned_clause['terms'] ) && ! isset( $this->queried_terms[ $taxonomy ]['terms'] ) ) { |
|
| 180 | - $this->queried_terms[ $taxonomy ]['terms'] = $cleaned_clause['terms']; |
|
| 179 | + if ( ! empty($cleaned_clause['terms']) && ! isset($this->queried_terms[$taxonomy]['terms'])) { |
|
| 180 | + $this->queried_terms[$taxonomy]['terms'] = $cleaned_clause['terms']; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ! empty( $cleaned_clause['field'] ) && ! isset( $this->queried_terms[ $taxonomy ]['field'] ) ) { |
|
| 184 | - $this->queried_terms[ $taxonomy ]['field'] = $cleaned_clause['field']; |
|
| 183 | + if ( ! empty($cleaned_clause['field']) && ! isset($this->queried_terms[$taxonomy]['field'])) { |
|
| 184 | + $this->queried_terms[$taxonomy]['field'] = $cleaned_clause['field']; |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Otherwise, it's a nested query, so we recurse. |
| 189 | - } elseif ( is_array( $query ) ) { |
|
| 190 | - $cleaned_subquery = $this->sanitize_query( $query ); |
|
| 189 | + } elseif (is_array($query)) { |
|
| 190 | + $cleaned_subquery = $this->sanitize_query($query); |
|
| 191 | 191 | |
| 192 | - if ( ! empty( $cleaned_subquery ) ) { |
|
| 192 | + if ( ! empty($cleaned_subquery)) { |
|
| 193 | 193 | // All queries with children must have a relation. |
| 194 | - if ( ! isset( $cleaned_subquery['relation'] ) ) { |
|
| 194 | + if ( ! isset($cleaned_subquery['relation'])) { |
|
| 195 | 195 | $cleaned_subquery['relation'] = 'AND'; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * @param string $relation Raw relation key from the query argument. |
| 213 | 213 | * @return string Sanitized relation ('AND' or 'OR'). |
| 214 | 214 | */ |
| 215 | - public function sanitize_relation( $relation ) { |
|
| 216 | - if ( 'OR' === strtoupper( $relation ) ) { |
|
| 215 | + public function sanitize_relation($relation) { |
|
| 216 | + if ('OR' === strtoupper($relation)) { |
|
| 217 | 217 | return 'OR'; |
| 218 | 218 | } else { |
| 219 | 219 | return 'AND'; |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | * @param array $query Tax query arguments. |
| 238 | 238 | * @return bool Whether the query clause is a first-order clause. |
| 239 | 239 | */ |
| 240 | - protected static function is_first_order_clause( $query ) { |
|
| 241 | - return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) ); |
|
| 240 | + protected static function is_first_order_clause($query) { |
|
| 241 | + return is_array($query) && (empty($query) || array_key_exists('terms', $query) || array_key_exists('taxonomy', $query) || array_key_exists('include_children', $query) || array_key_exists('field', $query) || array_key_exists('operator', $query)); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 259 | 259 | * } |
| 260 | 260 | */ |
| 261 | - public function get_sql( $primary_table, $primary_id_column ) { |
|
| 261 | + public function get_sql($primary_table, $primary_id_column) { |
|
| 262 | 262 | $this->primary_table = $primary_table; |
| 263 | 263 | $this->primary_id_column = $primary_id_column; |
| 264 | 264 | |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | * To keep $this->queries unaltered, pass a copy. |
| 288 | 288 | */ |
| 289 | 289 | $queries = $this->queries; |
| 290 | - $sql = $this->get_sql_for_query( $queries ); |
|
| 290 | + $sql = $this->get_sql_for_query($queries); |
|
| 291 | 291 | |
| 292 | - if ( ! empty( $sql['where'] ) ) { |
|
| 293 | - $sql['where'] = ' AND ' . $sql['where']; |
|
| 292 | + if ( ! empty($sql['where'])) { |
|
| 293 | + $sql['where'] = ' AND '.$sql['where']; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | return $sql; |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 316 | 316 | * } |
| 317 | 317 | */ |
| 318 | - protected function get_sql_for_query( &$query, $depth = 0 ) { |
|
| 318 | + protected function get_sql_for_query(&$query, $depth = 0) { |
|
| 319 | 319 | $sql_chunks = array( |
| 320 | 320 | 'join' => array(), |
| 321 | 321 | 'where' => array(), |
@@ -327,32 +327,32 @@ discard block |
||
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | 329 | $indent = ''; |
| 330 | - for ( $i = 0; $i < $depth; $i++ ) { |
|
| 330 | + for ($i = 0; $i < $depth; $i++) { |
|
| 331 | 331 | $indent .= " "; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - foreach ( $query as $key => &$clause ) { |
|
| 335 | - if ( 'relation' === $key ) { |
|
| 334 | + foreach ($query as $key => &$clause) { |
|
| 335 | + if ('relation' === $key) { |
|
| 336 | 336 | $relation = $query['relation']; |
| 337 | - } elseif ( is_array( $clause ) ) { |
|
| 337 | + } elseif (is_array($clause)) { |
|
| 338 | 338 | |
| 339 | 339 | // This is a first-order clause. |
| 340 | - if ( $this->is_first_order_clause( $clause ) ) { |
|
| 341 | - $clause_sql = $this->get_sql_for_clause( $clause, $query ); |
|
| 340 | + if ($this->is_first_order_clause($clause)) { |
|
| 341 | + $clause_sql = $this->get_sql_for_clause($clause, $query); |
|
| 342 | 342 | |
| 343 | - $where_count = count( $clause_sql['where'] ); |
|
| 344 | - if ( ! $where_count ) { |
|
| 343 | + $where_count = count($clause_sql['where']); |
|
| 344 | + if ( ! $where_count) { |
|
| 345 | 345 | $sql_chunks['where'][] = ''; |
| 346 | - } elseif ( 1 === $where_count ) { |
|
| 346 | + } elseif (1 === $where_count) { |
|
| 347 | 347 | $sql_chunks['where'][] = $clause_sql['where'][0]; |
| 348 | 348 | } else { |
| 349 | - $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; |
|
| 349 | + $sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); |
|
| 352 | + $sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']); |
|
| 353 | 353 | // This is a subquery, so we recurse. |
| 354 | 354 | } else { |
| 355 | - $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); |
|
| 355 | + $clause_sql = $this->get_sql_for_query($clause, $depth + 1); |
|
| 356 | 356 | |
| 357 | 357 | $sql_chunks['where'][] = $clause_sql['where']; |
| 358 | 358 | $sql_chunks['join'][] = $clause_sql['join']; |
@@ -361,21 +361,21 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // Filter to remove empties. |
| 364 | - $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); |
|
| 365 | - $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); |
|
| 364 | + $sql_chunks['join'] = array_filter($sql_chunks['join']); |
|
| 365 | + $sql_chunks['where'] = array_filter($sql_chunks['where']); |
|
| 366 | 366 | |
| 367 | - if ( empty( $relation ) ) { |
|
| 367 | + if (empty($relation)) { |
|
| 368 | 368 | $relation = 'AND'; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | // Filter duplicate JOIN clauses and combine into a single string. |
| 372 | - if ( ! empty( $sql_chunks['join'] ) ) { |
|
| 373 | - $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); |
|
| 372 | + if ( ! empty($sql_chunks['join'])) { |
|
| 373 | + $sql['join'] = implode(' ', array_unique($sql_chunks['join'])); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Generate a single WHERE clause with proper brackets and indentation. |
| 377 | - if ( ! empty( $sql_chunks['where'] ) ) { |
|
| 378 | - $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; |
|
| 377 | + if ( ! empty($sql_chunks['where'])) { |
|
| 378 | + $sql['where'] = '( '."\n ".$indent.implode(' '."\n ".$indent.$relation.' '."\n ".$indent, $sql_chunks['where'])."\n".$indent.')'; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | return $sql; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 399 | 399 | * } |
| 400 | 400 | */ |
| 401 | - public function get_sql_for_clause( &$clause, $parent_query ) { |
|
| 401 | + public function get_sql_for_clause(&$clause, $parent_query) { |
|
| 402 | 402 | global $wpdb; |
| 403 | 403 | |
| 404 | 404 | $sql = array( |
@@ -408,31 +408,31 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | $join = $where = ''; |
| 410 | 410 | |
| 411 | - $this->clean_query( $clause ); |
|
| 411 | + $this->clean_query($clause); |
|
| 412 | 412 | |
| 413 | - if ( is_wp_error( $clause ) ) { |
|
| 413 | + if (is_wp_error($clause)) { |
|
| 414 | 414 | return self::$no_results; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $terms = $clause['terms']; |
| 418 | - $operator = strtoupper( $clause['operator'] ); |
|
| 418 | + $operator = strtoupper($clause['operator']); |
|
| 419 | 419 | |
| 420 | - if ( 'IN' == $operator ) { |
|
| 420 | + if ('IN' == $operator) { |
|
| 421 | 421 | |
| 422 | - if ( empty( $terms ) ) { |
|
| 422 | + if (empty($terms)) { |
|
| 423 | 423 | return self::$no_results; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - $terms = implode( ',', $terms ); |
|
| 426 | + $terms = implode(',', $terms); |
|
| 427 | 427 | |
| 428 | 428 | /* |
| 429 | 429 | * Before creating another table join, see if this clause has a |
| 430 | 430 | * sibling with an existing join that can be shared. |
| 431 | 431 | */ |
| 432 | - $alias = $this->find_compatible_table_alias( $clause, $parent_query ); |
|
| 433 | - if ( false === $alias ) { |
|
| 434 | - $i = count( $this->table_aliases ); |
|
| 435 | - $alias = $i ? 'tt' . $i : $wpdb->term_relationships; |
|
| 432 | + $alias = $this->find_compatible_table_alias($clause, $parent_query); |
|
| 433 | + if (false === $alias) { |
|
| 434 | + $i = count($this->table_aliases); |
|
| 435 | + $alias = $i ? 'tt'.$i : $wpdb->term_relationships; |
|
| 436 | 436 | |
| 437 | 437 | // Store the alias as part of a flat array to build future iterators. |
| 438 | 438 | $this->table_aliases[] = $alias; |
@@ -448,13 +448,13 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | $where = "$alias.term_taxonomy_id $operator ($terms)"; |
| 450 | 450 | |
| 451 | - } elseif ( 'NOT IN' == $operator ) { |
|
| 451 | + } elseif ('NOT IN' == $operator) { |
|
| 452 | 452 | |
| 453 | - if ( empty( $terms ) ) { |
|
| 453 | + if (empty($terms)) { |
|
| 454 | 454 | return $sql; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $terms = implode( ',', $terms ); |
|
| 457 | + $terms = implode(',', $terms); |
|
| 458 | 458 | |
| 459 | 459 | $where = "$this->primary_table.$this->primary_id_column NOT IN ( |
| 460 | 460 | SELECT object_id |
@@ -462,15 +462,15 @@ discard block |
||
| 462 | 462 | WHERE term_taxonomy_id IN ($terms) |
| 463 | 463 | )"; |
| 464 | 464 | |
| 465 | - } elseif ( 'AND' == $operator ) { |
|
| 465 | + } elseif ('AND' == $operator) { |
|
| 466 | 466 | |
| 467 | - if ( empty( $terms ) ) { |
|
| 467 | + if (empty($terms)) { |
|
| 468 | 468 | return $sql; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - $num_terms = count( $terms ); |
|
| 471 | + $num_terms = count($terms); |
|
| 472 | 472 | |
| 473 | - $terms = implode( ',', $terms ); |
|
| 473 | + $terms = implode(',', $terms); |
|
| 474 | 474 | |
| 475 | 475 | $where = "( |
| 476 | 476 | SELECT COUNT(1) |
@@ -479,16 +479,16 @@ discard block |
||
| 479 | 479 | AND object_id = $this->primary_table.$this->primary_id_column |
| 480 | 480 | ) = $num_terms"; |
| 481 | 481 | |
| 482 | - } elseif ( 'NOT EXISTS' === $operator || 'EXISTS' === $operator ) { |
|
| 482 | + } elseif ('NOT EXISTS' === $operator || 'EXISTS' === $operator) { |
|
| 483 | 483 | |
| 484 | - $where = $wpdb->prepare( "$operator ( |
|
| 484 | + $where = $wpdb->prepare("$operator ( |
|
| 485 | 485 | SELECT 1 |
| 486 | 486 | FROM $wpdb->term_relationships |
| 487 | 487 | INNER JOIN $wpdb->term_taxonomy |
| 488 | 488 | ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id |
| 489 | 489 | WHERE $wpdb->term_taxonomy.taxonomy = %s |
| 490 | 490 | AND $wpdb->term_relationships.object_id = $this->primary_table.$this->primary_id_column |
| 491 | - )", $clause['taxonomy'] ); |
|
| 491 | + )", $clause['taxonomy']); |
|
| 492 | 492 | |
| 493 | 493 | } |
| 494 | 494 | |
@@ -517,32 +517,32 @@ discard block |
||
| 517 | 517 | * @param array $parent_query Parent query of $clause. |
| 518 | 518 | * @return string|false Table alias if found, otherwise false. |
| 519 | 519 | */ |
| 520 | - protected function find_compatible_table_alias( $clause, $parent_query ) { |
|
| 520 | + protected function find_compatible_table_alias($clause, $parent_query) { |
|
| 521 | 521 | $alias = false; |
| 522 | 522 | |
| 523 | 523 | // Sanity check. Only IN queries use the JOIN syntax . |
| 524 | - if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) { |
|
| 524 | + if ( ! isset($clause['operator']) || 'IN' !== $clause['operator']) { |
|
| 525 | 525 | return $alias; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // Since we're only checking IN queries, we're only concerned with OR relations. |
| 529 | - if ( ! isset( $parent_query['relation'] ) || 'OR' !== $parent_query['relation'] ) { |
|
| 529 | + if ( ! isset($parent_query['relation']) || 'OR' !== $parent_query['relation']) { |
|
| 530 | 530 | return $alias; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $compatible_operators = array( 'IN' ); |
|
| 533 | + $compatible_operators = array('IN'); |
|
| 534 | 534 | |
| 535 | - foreach ( $parent_query as $sibling ) { |
|
| 536 | - if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) { |
|
| 535 | + foreach ($parent_query as $sibling) { |
|
| 536 | + if ( ! is_array($sibling) || ! $this->is_first_order_clause($sibling)) { |
|
| 537 | 537 | continue; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if ( empty( $sibling['alias'] ) || empty( $sibling['operator'] ) ) { |
|
| 540 | + if (empty($sibling['alias']) || empty($sibling['operator'])) { |
|
| 541 | 541 | continue; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | // The sibling must both have compatible operator to share its alias. |
| 545 | - if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) { |
|
| 545 | + if (in_array(strtoupper($sibling['operator']), $compatible_operators)) { |
|
| 546 | 546 | $alias = $sibling['alias']; |
| 547 | 547 | break; |
| 548 | 548 | } |
@@ -559,37 +559,37 @@ discard block |
||
| 559 | 559 | * |
| 560 | 560 | * @param array $query The single query. Passed by reference. |
| 561 | 561 | */ |
| 562 | - private function clean_query( &$query ) { |
|
| 563 | - if ( empty( $query['taxonomy'] ) ) { |
|
| 564 | - if ( 'term_taxonomy_id' !== $query['field'] ) { |
|
| 565 | - $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 562 | + private function clean_query(&$query) { |
|
| 563 | + if (empty($query['taxonomy'])) { |
|
| 564 | + if ('term_taxonomy_id' !== $query['field']) { |
|
| 565 | + $query = new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 566 | 566 | return; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | // so long as there are shared terms, include_children requires that a taxonomy is set |
| 570 | 570 | $query['include_children'] = false; |
| 571 | - } elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) { |
|
| 572 | - $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); |
|
| 571 | + } elseif ( ! taxonomy_exists($query['taxonomy'])) { |
|
| 572 | + $query = new WP_Error('invalid_taxonomy', __('Invalid taxonomy.')); |
|
| 573 | 573 | return; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - $query['terms'] = array_unique( (array) $query['terms'] ); |
|
| 576 | + $query['terms'] = array_unique((array) $query['terms']); |
|
| 577 | 577 | |
| 578 | - if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) { |
|
| 579 | - $this->transform_query( $query, 'term_id' ); |
|
| 578 | + if (is_taxonomy_hierarchical($query['taxonomy']) && $query['include_children']) { |
|
| 579 | + $this->transform_query($query, 'term_id'); |
|
| 580 | 580 | |
| 581 | - if ( is_wp_error( $query ) ) |
|
| 581 | + if (is_wp_error($query)) |
|
| 582 | 582 | return; |
| 583 | 583 | |
| 584 | 584 | $children = array(); |
| 585 | - foreach ( $query['terms'] as $term ) { |
|
| 586 | - $children = array_merge( $children, get_term_children( $term, $query['taxonomy'] ) ); |
|
| 585 | + foreach ($query['terms'] as $term) { |
|
| 586 | + $children = array_merge($children, get_term_children($term, $query['taxonomy'])); |
|
| 587 | 587 | $children[] = $term; |
| 588 | 588 | } |
| 589 | 589 | $query['terms'] = $children; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $this->transform_query( $query, 'term_taxonomy_id' ); |
|
| 592 | + $this->transform_query($query, 'term_taxonomy_id'); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -603,59 +603,59 @@ discard block |
||
| 603 | 603 | * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id', |
| 604 | 604 | * or 'term_id'. Default 'term_id'. |
| 605 | 605 | */ |
| 606 | - public function transform_query( &$query, $resulting_field ) { |
|
| 606 | + public function transform_query(&$query, $resulting_field) { |
|
| 607 | 607 | global $wpdb; |
| 608 | 608 | |
| 609 | - if ( empty( $query['terms'] ) ) |
|
| 609 | + if (empty($query['terms'])) |
|
| 610 | 610 | return; |
| 611 | 611 | |
| 612 | - if ( $query['field'] == $resulting_field ) |
|
| 612 | + if ($query['field'] == $resulting_field) |
|
| 613 | 613 | return; |
| 614 | 614 | |
| 615 | - $resulting_field = sanitize_key( $resulting_field ); |
|
| 615 | + $resulting_field = sanitize_key($resulting_field); |
|
| 616 | 616 | |
| 617 | - switch ( $query['field'] ) { |
|
| 617 | + switch ($query['field']) { |
|
| 618 | 618 | case 'slug': |
| 619 | 619 | case 'name': |
| 620 | - foreach ( $query['terms'] as &$term ) { |
|
| 620 | + foreach ($query['terms'] as &$term) { |
|
| 621 | 621 | /* |
| 622 | 622 | * 0 is the $term_id parameter. We don't have a term ID yet, but it doesn't |
| 623 | 623 | * matter because `sanitize_term_field()` ignores the $term_id param when the |
| 624 | 624 | * context is 'db'. |
| 625 | 625 | */ |
| 626 | - $term = "'" . esc_sql( sanitize_term_field( $query['field'], $term, 0, $query['taxonomy'], 'db' ) ) . "'"; |
|
| 626 | + $term = "'".esc_sql(sanitize_term_field($query['field'], $term, 0, $query['taxonomy'], 'db'))."'"; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - $terms = implode( ",", $query['terms'] ); |
|
| 629 | + $terms = implode(",", $query['terms']); |
|
| 630 | 630 | |
| 631 | - $terms = $wpdb->get_col( " |
|
| 631 | + $terms = $wpdb->get_col(" |
|
| 632 | 632 | SELECT $wpdb->term_taxonomy.$resulting_field |
| 633 | 633 | FROM $wpdb->term_taxonomy |
| 634 | 634 | INNER JOIN $wpdb->terms USING (term_id) |
| 635 | 635 | WHERE taxonomy = '{$query['taxonomy']}' |
| 636 | 636 | AND $wpdb->terms.{$query['field']} IN ($terms) |
| 637 | - " ); |
|
| 637 | + "); |
|
| 638 | 638 | break; |
| 639 | 639 | case 'term_taxonomy_id': |
| 640 | - $terms = implode( ',', array_map( 'intval', $query['terms'] ) ); |
|
| 641 | - $terms = $wpdb->get_col( " |
|
| 640 | + $terms = implode(',', array_map('intval', $query['terms'])); |
|
| 641 | + $terms = $wpdb->get_col(" |
|
| 642 | 642 | SELECT $resulting_field |
| 643 | 643 | FROM $wpdb->term_taxonomy |
| 644 | 644 | WHERE term_taxonomy_id IN ($terms) |
| 645 | - " ); |
|
| 645 | + "); |
|
| 646 | 646 | break; |
| 647 | 647 | default: |
| 648 | - $terms = implode( ',', array_map( 'intval', $query['terms'] ) ); |
|
| 649 | - $terms = $wpdb->get_col( " |
|
| 648 | + $terms = implode(',', array_map('intval', $query['terms'])); |
|
| 649 | + $terms = $wpdb->get_col(" |
|
| 650 | 650 | SELECT $resulting_field |
| 651 | 651 | FROM $wpdb->term_taxonomy |
| 652 | 652 | WHERE taxonomy = '{$query['taxonomy']}' |
| 653 | 653 | AND term_id IN ($terms) |
| 654 | - " ); |
|
| 654 | + "); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if ( 'AND' == $query['operator'] && count( $terms ) < count( $query['terms'] ) ) { |
|
| 658 | - $query = new WP_Error( 'inexistent_terms', __( 'Inexistent terms.' ) ); |
|
| 657 | + if ('AND' == $query['operator'] && count($terms) < count($query['terms'])) { |
|
| 658 | + $query = new WP_Error('inexistent_terms', __('Inexistent terms.')); |
|
| 659 | 659 | return; |
| 660 | 660 | } |
| 661 | 661 | |
@@ -23,19 +23,19 @@ discard block |
||
| 23 | 23 | global $current_site, $current_blog; |
| 24 | 24 | |
| 25 | 25 | /** WP_Network class */ |
| 26 | -require_once( ABSPATH . WPINC . '/class-wp-network.php' ); |
|
| 26 | +require_once(ABSPATH.WPINC.'/class-wp-network.php'); |
|
| 27 | 27 | |
| 28 | 28 | /** WP_Site class */ |
| 29 | -require_once( ABSPATH . WPINC . '/class-wp-site.php' ); |
|
| 29 | +require_once(ABSPATH.WPINC.'/class-wp-site.php'); |
|
| 30 | 30 | |
| 31 | 31 | /** Multisite loader */ |
| 32 | -require_once( ABSPATH . WPINC . '/ms-load.php' ); |
|
| 32 | +require_once(ABSPATH.WPINC.'/ms-load.php'); |
|
| 33 | 33 | |
| 34 | 34 | /** Default Multisite constants */ |
| 35 | -require_once( ABSPATH . WPINC . '/ms-default-constants.php' ); |
|
| 35 | +require_once(ABSPATH.WPINC.'/ms-default-constants.php'); |
|
| 36 | 36 | |
| 37 | -if ( defined( 'SUNRISE' ) ) { |
|
| 38 | - include_once( WP_CONTENT_DIR . '/sunrise.php' ); |
|
| 37 | +if (defined('SUNRISE')) { |
|
| 38 | + include_once(WP_CONTENT_DIR.'/sunrise.php'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ |
@@ -43,50 +43,50 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | // This block will process a request if the current network or current site objects |
| 45 | 45 | // have not been populated in the global scope through something like `sunrise.php`. |
| 46 | -if ( !isset( $current_site ) || !isset( $current_blog ) ) { |
|
| 47 | - |
|
| 48 | - $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); |
|
| 49 | - if ( substr( $domain, -3 ) == ':80' ) { |
|
| 50 | - $domain = substr( $domain, 0, -3 ); |
|
| 51 | - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); |
|
| 52 | - } elseif ( substr( $domain, -4 ) == ':443' ) { |
|
| 53 | - $domain = substr( $domain, 0, -4 ); |
|
| 54 | - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); |
|
| 46 | +if ( ! isset($current_site) || ! isset($current_blog)) { |
|
| 47 | + |
|
| 48 | + $domain = strtolower(stripslashes($_SERVER['HTTP_HOST'])); |
|
| 49 | + if (substr($domain, -3) == ':80') { |
|
| 50 | + $domain = substr($domain, 0, -3); |
|
| 51 | + $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -3); |
|
| 52 | + } elseif (substr($domain, -4) == ':443') { |
|
| 53 | + $domain = substr($domain, 0, -4); |
|
| 54 | + $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -4); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $path = stripslashes( $_SERVER['REQUEST_URI'] ); |
|
| 58 | - if ( is_admin() ) { |
|
| 59 | - $path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path ); |
|
| 57 | + $path = stripslashes($_SERVER['REQUEST_URI']); |
|
| 58 | + if (is_admin()) { |
|
| 59 | + $path = preg_replace('#(.*)/wp-admin/.*#', '$1/', $path); |
|
| 60 | 60 | } |
| 61 | - list( $path ) = explode( '?', $path ); |
|
| 61 | + list($path) = explode('?', $path); |
|
| 62 | 62 | |
| 63 | - $bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() ); |
|
| 63 | + $bootstrap_result = ms_load_current_site_and_network($domain, $path, is_subdomain_install()); |
|
| 64 | 64 | |
| 65 | - if ( true === $bootstrap_result ) { |
|
| 65 | + if (true === $bootstrap_result) { |
|
| 66 | 66 | // `$current_blog` and `$current_site are now populated. |
| 67 | - } elseif ( false === $bootstrap_result ) { |
|
| 68 | - ms_not_installed( $domain, $path ); |
|
| 67 | + } elseif (false === $bootstrap_result) { |
|
| 68 | + ms_not_installed($domain, $path); |
|
| 69 | 69 | } else { |
| 70 | - header( 'Location: ' . $bootstrap_result ); |
|
| 70 | + header('Location: '.$bootstrap_result); |
|
| 71 | 71 | exit; |
| 72 | 72 | } |
| 73 | - unset( $bootstrap_result ); |
|
| 73 | + unset($bootstrap_result); |
|
| 74 | 74 | |
| 75 | 75 | $blog_id = $current_blog->blog_id; |
| 76 | 76 | $public = $current_blog->public; |
| 77 | 77 | |
| 78 | - if ( empty( $current_blog->site_id ) ) { |
|
| 78 | + if (empty($current_blog->site_id)) { |
|
| 79 | 79 | // This dates to [MU134] and shouldn't be relevant anymore, |
| 80 | 80 | // but it could be possible for arguments passed to insert_blog() etc. |
| 81 | 81 | $current_blog->site_id = 1; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $site_id = $current_blog->site_id; |
| 85 | - wp_load_core_site_options( $site_id ); |
|
| 85 | + wp_load_core_site_options($site_id); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php |
|
| 89 | -$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); |
|
| 88 | +$wpdb->set_prefix($table_prefix, false); // $table_prefix can be set in sunrise.php |
|
| 89 | +$wpdb->set_blog_id($current_blog->blog_id, $current_blog->site_id); |
|
| 90 | 90 | $table_prefix = $wpdb->get_blog_prefix(); |
| 91 | 91 | $_wp_switched_stack = array(); |
| 92 | 92 | $switched = false; |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | // need to init cache again after blog_id is set |
| 95 | 95 | wp_start_object_cache(); |
| 96 | 96 | |
| 97 | -if ( ! $current_site instanceof WP_Network ) { |
|
| 98 | - $current_site = new WP_Network( $current_site ); |
|
| 97 | +if ( ! $current_site instanceof WP_Network) { |
|
| 98 | + $current_site = new WP_Network($current_site); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | -if ( ! $current_blog instanceof WP_Site ) { |
|
| 102 | - $current_blog = new WP_Site( $current_blog ); |
|
| 101 | +if ( ! $current_blog instanceof WP_Site) { |
|
| 102 | + $current_blog = new WP_Site($current_blog); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Define upload directory constants |
@@ -111,4 +111,4 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @since 4.6.0 |
| 113 | 113 | */ |
| 114 | -do_action( 'ms_loaded' ); |
|
| 114 | +do_action('ms_loaded'); |
|
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`. |
| 16 | 16 | */ |
| 17 | -function the_permalink( $post = 0 ) { |
|
| 17 | +function the_permalink($post = 0) { |
|
| 18 | 18 | /** |
| 19 | 19 | * Filters the display of the permalink for the current post. |
| 20 | 20 | * |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param string $permalink The permalink for the current post. |
| 25 | 25 | * @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0. |
| 26 | 26 | */ |
| 27 | - echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ); |
|
| 27 | + echo esc_url(apply_filters('the_permalink', get_permalink($post), $post)); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function user_trailingslashit($string, $type_of_url = '') { |
| 48 | 48 | global $wp_rewrite; |
| 49 | - if ( $wp_rewrite->use_trailing_slashes ) |
|
| 49 | + if ($wp_rewrite->use_trailing_slashes) |
|
| 50 | 50 | $string = trailingslashit($string); |
| 51 | 51 | else |
| 52 | 52 | $string = untrailingslashit($string); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * 'single_feed', 'single_paged', 'feed', 'category', 'page', 'year', |
| 62 | 62 | * 'month', 'day', 'paged', 'post_type_archive'. |
| 63 | 63 | */ |
| 64 | - return apply_filters( 'user_trailingslashit', $string, $type_of_url ); |
|
| 64 | + return apply_filters('user_trailingslashit', $string, $type_of_url); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @param string $mode Optional. Permalink mode. Accepts 'title' or 'id'. Default 'id'. |
| 76 | 76 | */ |
| 77 | -function permalink_anchor( $mode = 'id' ) { |
|
| 77 | +function permalink_anchor($mode = 'id') { |
|
| 78 | 78 | $post = get_post(); |
| 79 | - switch ( strtolower( $mode ) ) { |
|
| 79 | + switch (strtolower($mode)) { |
|
| 80 | 80 | case 'title': |
| 81 | - $title = sanitize_title( $post->post_title ) . '-' . $post->ID; |
|
| 81 | + $title = sanitize_title($post->post_title).'-'.$post->ID; |
|
| 82 | 82 | echo '<a id="'.$title.'"></a>'; |
| 83 | 83 | break; |
| 84 | 84 | case 'id': |
| 85 | 85 | default: |
| 86 | - echo '<a id="post-' . $post->ID . '"></a>'; |
|
| 86 | + echo '<a id="post-'.$post->ID.'"></a>'; |
|
| 87 | 87 | break; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return string|false The permalink URL or false if post does not exist. |
| 104 | 104 | */ |
| 105 | -function get_the_permalink( $post = 0, $leavename = false ) { |
|
| 106 | - return get_permalink( $post, $leavename ); |
|
| 105 | +function get_the_permalink($post = 0, $leavename = false) { |
|
| 106 | + return get_permalink($post, $leavename); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param bool $leavename Optional. Whether to keep post name or page name. Default false. |
| 116 | 116 | * @return string|false The permalink URL or false if post does not exist. |
| 117 | 117 | */ |
| 118 | -function get_permalink( $post = 0, $leavename = false ) { |
|
| 118 | +function get_permalink($post = 0, $leavename = false) { |
|
| 119 | 119 | $rewritecode = array( |
| 120 | 120 | '%year%', |
| 121 | 121 | '%monthnum%', |
@@ -123,28 +123,28 @@ discard block |
||
| 123 | 123 | '%hour%', |
| 124 | 124 | '%minute%', |
| 125 | 125 | '%second%', |
| 126 | - $leavename? '' : '%postname%', |
|
| 126 | + $leavename ? '' : '%postname%', |
|
| 127 | 127 | '%post_id%', |
| 128 | 128 | '%category%', |
| 129 | 129 | '%author%', |
| 130 | - $leavename? '' : '%pagename%', |
|
| 130 | + $leavename ? '' : '%pagename%', |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | - if ( is_object( $post ) && isset( $post->filter ) && 'sample' == $post->filter ) { |
|
| 133 | + if (is_object($post) && isset($post->filter) && 'sample' == $post->filter) { |
|
| 134 | 134 | $sample = true; |
| 135 | 135 | } else { |
| 136 | - $post = get_post( $post ); |
|
| 136 | + $post = get_post($post); |
|
| 137 | 137 | $sample = false; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( empty($post->ID) ) |
|
| 140 | + if (empty($post->ID)) |
|
| 141 | 141 | return false; |
| 142 | 142 | |
| 143 | - if ( $post->post_type == 'page' ) |
|
| 143 | + if ($post->post_type == 'page') |
|
| 144 | 144 | return get_page_link($post, $leavename, $sample); |
| 145 | - elseif ( $post->post_type == 'attachment' ) |
|
| 146 | - return get_attachment_link( $post, $leavename ); |
|
| 147 | - elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) |
|
| 145 | + elseif ($post->post_type == 'attachment') |
|
| 146 | + return get_attachment_link($post, $leavename); |
|
| 147 | + elseif (in_array($post->post_type, get_post_types(array('_builtin' => false)))) |
|
| 148 | 148 | return get_post_permalink($post, $leavename, $sample); |
| 149 | 149 | |
| 150 | 150 | $permalink = get_option('permalink_structure'); |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | * @param WP_Post $post The post in question. |
| 161 | 161 | * @param bool $leavename Whether to keep the post name. |
| 162 | 162 | */ |
| 163 | - $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); |
|
| 163 | + $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); |
|
| 164 | 164 | |
| 165 | - if ( '' != $permalink && !in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) { |
|
| 165 | + if ('' != $permalink && ! in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future'))) { |
|
| 166 | 166 | $unixtime = strtotime($post->post_date); |
| 167 | 167 | |
| 168 | 168 | $category = ''; |
| 169 | - if ( strpos($permalink, '%category%') !== false ) { |
|
| 169 | + if (strpos($permalink, '%category%') !== false) { |
|
| 170 | 170 | $cats = get_the_category($post->ID); |
| 171 | - if ( $cats ) { |
|
| 171 | + if ($cats) { |
|
| 172 | 172 | usort($cats, '_usort_terms_by_ID'); // order by ID |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | * @param array $cats Array of all categories associated with the post. |
| 181 | 181 | * @param WP_Post $post The post in question. |
| 182 | 182 | */ |
| 183 | - $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); |
|
| 183 | + $category_object = apply_filters('post_link_category', $cats[0], $cats, $post); |
|
| 184 | 184 | |
| 185 | - $category_object = get_term( $category_object, 'category' ); |
|
| 185 | + $category_object = get_term($category_object, 'category'); |
|
| 186 | 186 | $category = $category_object->slug; |
| 187 | - if ( $parent = $category_object->parent ) |
|
| 188 | - $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 187 | + if ($parent = $category_object->parent) |
|
| 188 | + $category = get_category_parents($parent, false, '/', true).$category; |
|
| 189 | 189 | } |
| 190 | 190 | // show default category in permalinks, without |
| 191 | 191 | // having to assign it explicitly |
| 192 | - if ( empty($category) ) { |
|
| 193 | - $default_category = get_term( get_option( 'default_category' ), 'category' ); |
|
| 194 | - if ( $default_category && ! is_wp_error( $default_category ) ) { |
|
| 192 | + if (empty($category)) { |
|
| 193 | + $default_category = get_term(get_option('default_category'), 'category'); |
|
| 194 | + if ($default_category && ! is_wp_error($default_category)) { |
|
| 195 | 195 | $category = $default_category->slug; |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | $author = ''; |
| 201 | - if ( strpos($permalink, '%author%') !== false ) { |
|
| 201 | + if (strpos($permalink, '%author%') !== false) { |
|
| 202 | 202 | $authordata = get_userdata($post->post_author); |
| 203 | 203 | $author = $authordata->user_nicename; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - $date = explode(" ",date('Y m d H i s', $unixtime)); |
|
| 206 | + $date = explode(" ", date('Y m d H i s', $unixtime)); |
|
| 207 | 207 | $rewritereplace = |
| 208 | 208 | array( |
| 209 | 209 | $date[0], |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | $author, |
| 219 | 219 | $post->post_name, |
| 220 | 220 | ); |
| 221 | - $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) ); |
|
| 221 | + $permalink = home_url(str_replace($rewritecode, $rewritereplace, $permalink)); |
|
| 222 | 222 | $permalink = user_trailingslashit($permalink, 'single'); |
| 223 | 223 | } else { // if they're not using the fancy permalink option |
| 224 | - $permalink = home_url('?p=' . $post->ID); |
|
| 224 | + $permalink = home_url('?p='.$post->ID); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param WP_Post $post The post in question. |
| 236 | 236 | * @param bool $leavename Whether to keep the post name. |
| 237 | 237 | */ |
| 238 | - return apply_filters( 'post_link', $permalink, $post, $leavename ); |
|
| 238 | + return apply_filters('post_link', $permalink, $post, $leavename); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -250,33 +250,33 @@ discard block |
||
| 250 | 250 | * @param bool $sample Optional, defaults to false. Is it a sample permalink. Default false. |
| 251 | 251 | * @return string|WP_Error The post permalink. |
| 252 | 252 | */ |
| 253 | -function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { |
|
| 253 | +function get_post_permalink($id = 0, $leavename = false, $sample = false) { |
|
| 254 | 254 | global $wp_rewrite; |
| 255 | 255 | |
| 256 | 256 | $post = get_post($id); |
| 257 | 257 | |
| 258 | - if ( is_wp_error( $post ) ) |
|
| 258 | + if (is_wp_error($post)) |
|
| 259 | 259 | return $post; |
| 260 | 260 | |
| 261 | 261 | $post_link = $wp_rewrite->get_extra_permastruct($post->post_type); |
| 262 | 262 | |
| 263 | 263 | $slug = $post->post_name; |
| 264 | 264 | |
| 265 | - $draft_or_pending = get_post_status( $id ) && in_array( get_post_status( $id ), array( 'draft', 'pending', 'auto-draft', 'future' ) ); |
|
| 265 | + $draft_or_pending = get_post_status($id) && in_array(get_post_status($id), array('draft', 'pending', 'auto-draft', 'future')); |
|
| 266 | 266 | |
| 267 | 267 | $post_type = get_post_type_object($post->post_type); |
| 268 | 268 | |
| 269 | - if ( $post_type->hierarchical ) { |
|
| 270 | - $slug = get_page_uri( $id ); |
|
| 269 | + if ($post_type->hierarchical) { |
|
| 270 | + $slug = get_page_uri($id); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) { |
|
| 274 | - if ( ! $leavename ) { |
|
| 273 | + if ( ! empty($post_link) && ( ! $draft_or_pending || $sample)) { |
|
| 274 | + if ( ! $leavename) { |
|
| 275 | 275 | $post_link = str_replace("%$post->post_type%", $slug, $post_link); |
| 276 | 276 | } |
| 277 | - $post_link = home_url( user_trailingslashit($post_link) ); |
|
| 277 | + $post_link = home_url(user_trailingslashit($post_link)); |
|
| 278 | 278 | } else { |
| 279 | - if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) |
|
| 279 | + if ($post_type->query_var && (isset($post->post_status) && ! $draft_or_pending)) |
|
| 280 | 280 | $post_link = add_query_arg($post_type->query_var, $slug, ''); |
| 281 | 281 | else |
| 282 | 282 | $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param bool $leavename Whether to keep the post name. |
| 294 | 294 | * @param bool $sample Is it a sample permalink. |
| 295 | 295 | */ |
| 296 | - return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample ); |
|
| 296 | + return apply_filters('post_type_link', $post_link, $post, $leavename, $sample); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -309,13 +309,13 @@ discard block |
||
| 309 | 309 | * Default false. |
| 310 | 310 | * @return string The page permalink. |
| 311 | 311 | */ |
| 312 | -function get_page_link( $post = false, $leavename = false, $sample = false ) { |
|
| 313 | - $post = get_post( $post ); |
|
| 312 | +function get_page_link($post = false, $leavename = false, $sample = false) { |
|
| 313 | + $post = get_post($post); |
|
| 314 | 314 | |
| 315 | - if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) |
|
| 315 | + if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) |
|
| 316 | 316 | $link = home_url('/'); |
| 317 | 317 | else |
| 318 | - $link = _get_page_link( $post, $leavename, $sample ); |
|
| 318 | + $link = _get_page_link($post, $leavename, $sample); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Filters the permalink for a page. |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param int $post_id The ID of the page. |
| 327 | 327 | * @param bool $sample Is it a sample permalink. |
| 328 | 328 | */ |
| 329 | - return apply_filters( 'page_link', $link, $post->ID, $sample ); |
|
| 329 | + return apply_filters('page_link', $link, $post->ID, $sample); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** |
@@ -345,24 +345,24 @@ discard block |
||
| 345 | 345 | * Default false. |
| 346 | 346 | * @return string The page permalink. |
| 347 | 347 | */ |
| 348 | -function _get_page_link( $post = false, $leavename = false, $sample = false ) { |
|
| 348 | +function _get_page_link($post = false, $leavename = false, $sample = false) { |
|
| 349 | 349 | global $wp_rewrite; |
| 350 | 350 | |
| 351 | - $post = get_post( $post ); |
|
| 351 | + $post = get_post($post); |
|
| 352 | 352 | |
| 353 | - $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); |
|
| 353 | + $draft_or_pending = in_array($post->post_status, array('draft', 'pending', 'auto-draft')); |
|
| 354 | 354 | |
| 355 | 355 | $link = $wp_rewrite->get_page_permastruct(); |
| 356 | 356 | |
| 357 | - if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { |
|
| 358 | - if ( ! $leavename ) { |
|
| 359 | - $link = str_replace('%pagename%', get_page_uri( $post ), $link); |
|
| 357 | + if ( ! empty($link) && ((isset($post->post_status) && ! $draft_or_pending) || $sample)) { |
|
| 358 | + if ( ! $leavename) { |
|
| 359 | + $link = str_replace('%pagename%', get_page_uri($post), $link); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $link = home_url($link); |
| 363 | 363 | $link = user_trailingslashit($link, 'page'); |
| 364 | 364 | } else { |
| 365 | - $link = home_url( '?page_id=' . $post->ID ); |
|
| 365 | + $link = home_url('?page_id='.$post->ID); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @param string $link The page's permalink. |
| 374 | 374 | * @param int $post_id The ID of the page. |
| 375 | 375 | */ |
| 376 | - return apply_filters( '_get_page_link', $link, $post->ID ); |
|
| 376 | + return apply_filters('_get_page_link', $link, $post->ID); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -389,39 +389,39 @@ discard block |
||
| 389 | 389 | * @param bool $leavename Optional. Whether to keep the page name. Default false. |
| 390 | 390 | * @return string The attachment permalink. |
| 391 | 391 | */ |
| 392 | -function get_attachment_link( $post = null, $leavename = false ) { |
|
| 392 | +function get_attachment_link($post = null, $leavename = false) { |
|
| 393 | 393 | global $wp_rewrite; |
| 394 | 394 | |
| 395 | 395 | $link = false; |
| 396 | 396 | |
| 397 | - $post = get_post( $post ); |
|
| 398 | - $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false; |
|
| 399 | - if ( $parent && ! in_array( $parent->post_type, get_post_types() ) ) { |
|
| 397 | + $post = get_post($post); |
|
| 398 | + $parent = ($post->post_parent > 0 && $post->post_parent != $post->ID) ? get_post($post->post_parent) : false; |
|
| 399 | + if ($parent && ! in_array($parent->post_type, get_post_types())) { |
|
| 400 | 400 | $parent = false; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if ( $wp_rewrite->using_permalinks() && $parent ) { |
|
| 404 | - if ( 'page' == $parent->post_type ) |
|
| 405 | - $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front |
|
| 403 | + if ($wp_rewrite->using_permalinks() && $parent) { |
|
| 404 | + if ('page' == $parent->post_type) |
|
| 405 | + $parentlink = _get_page_link($post->post_parent); // Ignores page_on_front |
|
| 406 | 406 | else |
| 407 | - $parentlink = get_permalink( $post->post_parent ); |
|
| 407 | + $parentlink = get_permalink($post->post_parent); |
|
| 408 | 408 | |
| 409 | - if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) |
|
| 410 | - $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 409 | + if (is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%')) |
|
| 410 | + $name = 'attachment/'.$post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 411 | 411 | else |
| 412 | 412 | $name = $post->post_name; |
| 413 | 413 | |
| 414 | - if ( strpos($parentlink, '?') === false ) |
|
| 415 | - $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 414 | + if (strpos($parentlink, '?') === false) |
|
| 415 | + $link = user_trailingslashit(trailingslashit($parentlink).'%postname%'); |
|
| 416 | 416 | |
| 417 | - if ( ! $leavename ) |
|
| 418 | - $link = str_replace( '%postname%', $name, $link ); |
|
| 419 | - } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) { |
|
| 420 | - $link = home_url( user_trailingslashit( $post->post_name ) ); |
|
| 417 | + if ( ! $leavename) |
|
| 418 | + $link = str_replace('%postname%', $name, $link); |
|
| 419 | + } elseif ($wp_rewrite->using_permalinks() && ! $leavename) { |
|
| 420 | + $link = home_url(user_trailingslashit($post->post_name)); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ( ! $link ) |
|
| 424 | - $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 423 | + if ( ! $link) |
|
| 424 | + $link = home_url('/?attachment_id='.$post->ID); |
|
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * Filters the permalink for an attachment. |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * @param string $link The attachment's permalink. |
| 432 | 432 | * @param int $post_id Attachment ID. |
| 433 | 433 | */ |
| 434 | - return apply_filters( 'attachment_link', $link, $post->ID ); |
|
| 434 | + return apply_filters('attachment_link', $link, $post->ID); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -444,16 +444,16 @@ discard block |
||
| 444 | 444 | * @param int|bool $year False for current year or year for permalink. |
| 445 | 445 | * @return string The permalink for the specified year archive. |
| 446 | 446 | */ |
| 447 | -function get_year_link( $year ) { |
|
| 447 | +function get_year_link($year) { |
|
| 448 | 448 | global $wp_rewrite; |
| 449 | - if ( !$year ) |
|
| 449 | + if ( ! $year) |
|
| 450 | 450 | $year = gmdate('Y', current_time('timestamp')); |
| 451 | 451 | $yearlink = $wp_rewrite->get_year_permastruct(); |
| 452 | - if ( !empty($yearlink) ) { |
|
| 452 | + if ( ! empty($yearlink)) { |
|
| 453 | 453 | $yearlink = str_replace('%year%', $year, $yearlink); |
| 454 | - $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); |
|
| 454 | + $yearlink = home_url(user_trailingslashit($yearlink, 'year')); |
|
| 455 | 455 | } else { |
| 456 | - $yearlink = home_url( '?m=' . $year ); |
|
| 456 | + $yearlink = home_url('?m='.$year); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @param string $yearlink Permalink for the year archive. |
| 465 | 465 | * @param int $year Year for the archive. |
| 466 | 466 | */ |
| 467 | - return apply_filters( 'year_link', $yearlink, $year ); |
|
| 467 | + return apply_filters('year_link', $yearlink, $year); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -480,17 +480,17 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | function get_month_link($year, $month) { |
| 482 | 482 | global $wp_rewrite; |
| 483 | - if ( !$year ) |
|
| 483 | + if ( ! $year) |
|
| 484 | 484 | $year = gmdate('Y', current_time('timestamp')); |
| 485 | - if ( !$month ) |
|
| 485 | + if ( ! $month) |
|
| 486 | 486 | $month = gmdate('m', current_time('timestamp')); |
| 487 | 487 | $monthlink = $wp_rewrite->get_month_permastruct(); |
| 488 | - if ( !empty($monthlink) ) { |
|
| 488 | + if ( ! empty($monthlink)) { |
|
| 489 | 489 | $monthlink = str_replace('%year%', $year, $monthlink); |
| 490 | 490 | $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); |
| 491 | - $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); |
|
| 491 | + $monthlink = home_url(user_trailingslashit($monthlink, 'month')); |
|
| 492 | 492 | } else { |
| 493 | - $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); |
|
| 493 | + $monthlink = home_url('?m='.$year.zeroise($month, 2)); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | /** |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * @param int $year Year for the archive. |
| 503 | 503 | * @param int $month The month for the archive. |
| 504 | 504 | */ |
| 505 | - return apply_filters( 'month_link', $monthlink, $year, $month ); |
|
| 505 | + return apply_filters('month_link', $monthlink, $year, $month); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -519,21 +519,21 @@ discard block |
||
| 519 | 519 | */ |
| 520 | 520 | function get_day_link($year, $month, $day) { |
| 521 | 521 | global $wp_rewrite; |
| 522 | - if ( !$year ) |
|
| 522 | + if ( ! $year) |
|
| 523 | 523 | $year = gmdate('Y', current_time('timestamp')); |
| 524 | - if ( !$month ) |
|
| 524 | + if ( ! $month) |
|
| 525 | 525 | $month = gmdate('m', current_time('timestamp')); |
| 526 | - if ( !$day ) |
|
| 526 | + if ( ! $day) |
|
| 527 | 527 | $day = gmdate('j', current_time('timestamp')); |
| 528 | 528 | |
| 529 | 529 | $daylink = $wp_rewrite->get_day_permastruct(); |
| 530 | - if ( !empty($daylink) ) { |
|
| 530 | + if ( ! empty($daylink)) { |
|
| 531 | 531 | $daylink = str_replace('%year%', $year, $daylink); |
| 532 | 532 | $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); |
| 533 | 533 | $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); |
| 534 | - $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); |
|
| 534 | + $daylink = home_url(user_trailingslashit($daylink, 'day')); |
|
| 535 | 535 | } else { |
| 536 | - $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); |
|
| 536 | + $daylink = home_url('?m='.$year.zeroise($month, 2).zeroise($day, 2)); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @param int $month Month for the archive. |
| 547 | 547 | * @param int $day The day for the archive. |
| 548 | 548 | */ |
| 549 | - return apply_filters( 'day_link', $daylink, $year, $month, $day ); |
|
| 549 | + return apply_filters('day_link', $daylink, $year, $month, $day); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -557,8 +557,8 @@ discard block |
||
| 557 | 557 | * @param string $anchor The link's anchor text. |
| 558 | 558 | * @param string $feed Optional. Feed type. Default empty. |
| 559 | 559 | */ |
| 560 | -function the_feed_link( $anchor, $feed = '' ) { |
|
| 561 | - $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; |
|
| 560 | +function the_feed_link($anchor, $feed = '') { |
|
| 561 | + $link = '<a href="'.esc_url(get_feed_link($feed)).'">'.$anchor.'</a>'; |
|
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | 564 | * Filters the feed link anchor tag. |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param string $feed The feed type, or an empty string for the |
| 570 | 570 | * default feed type. |
| 571 | 571 | */ |
| 572 | - echo apply_filters( 'the_feed_link', $link, $feed ); |
|
| 572 | + echo apply_filters('the_feed_link', $link, $feed); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -582,27 +582,27 @@ discard block |
||
| 582 | 582 | * @param string $feed Optional. Feed type. Default empty. |
| 583 | 583 | * @return string The feed permalink. |
| 584 | 584 | */ |
| 585 | -function get_feed_link( $feed = '' ) { |
|
| 585 | +function get_feed_link($feed = '') { |
|
| 586 | 586 | global $wp_rewrite; |
| 587 | 587 | |
| 588 | 588 | $permalink = $wp_rewrite->get_feed_permastruct(); |
| 589 | - if ( '' != $permalink ) { |
|
| 590 | - if ( false !== strpos($feed, 'comments_') ) { |
|
| 589 | + if ('' != $permalink) { |
|
| 590 | + if (false !== strpos($feed, 'comments_')) { |
|
| 591 | 591 | $feed = str_replace('comments_', '', $feed); |
| 592 | 592 | $permalink = $wp_rewrite->get_comment_feed_permastruct(); |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - if ( get_default_feed() == $feed ) |
|
| 595 | + if (get_default_feed() == $feed) |
|
| 596 | 596 | $feed = ''; |
| 597 | 597 | |
| 598 | 598 | $permalink = str_replace('%feed%', $feed, $permalink); |
| 599 | 599 | $permalink = preg_replace('#/+#', '/', "/$permalink"); |
| 600 | - $output = home_url( user_trailingslashit($permalink, 'feed') ); |
|
| 600 | + $output = home_url(user_trailingslashit($permalink, 'feed')); |
|
| 601 | 601 | } else { |
| 602 | - if ( empty($feed) ) |
|
| 602 | + if (empty($feed)) |
|
| 603 | 603 | $feed = get_default_feed(); |
| 604 | 604 | |
| 605 | - if ( false !== strpos($feed, 'comments_') ) |
|
| 605 | + if (false !== strpos($feed, 'comments_')) |
|
| 606 | 606 | $feed = str_replace('comments_', 'comments-', $feed); |
| 607 | 607 | |
| 608 | 608 | $output = home_url("?feed={$feed}"); |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | * @param string $output The feed permalink. |
| 617 | 617 | * @param string $feed Feed type. |
| 618 | 618 | */ |
| 619 | - return apply_filters( 'feed_link', $output, $feed ); |
|
| 619 | + return apply_filters('feed_link', $output, $feed); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
@@ -628,43 +628,43 @@ discard block |
||
| 628 | 628 | * @param string $feed Optional. Feed type. Default empty. |
| 629 | 629 | * @return string The permalink for the comments feed for the given post. |
| 630 | 630 | */ |
| 631 | -function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { |
|
| 632 | - $post_id = absint( $post_id ); |
|
| 631 | +function get_post_comments_feed_link($post_id = 0, $feed = '') { |
|
| 632 | + $post_id = absint($post_id); |
|
| 633 | 633 | |
| 634 | - if ( ! $post_id ) |
|
| 634 | + if ( ! $post_id) |
|
| 635 | 635 | $post_id = get_the_ID(); |
| 636 | 636 | |
| 637 | - if ( empty( $feed ) ) |
|
| 637 | + if (empty($feed)) |
|
| 638 | 638 | $feed = get_default_feed(); |
| 639 | 639 | |
| 640 | - $post = get_post( $post_id ); |
|
| 640 | + $post = get_post($post_id); |
|
| 641 | 641 | $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; |
| 642 | 642 | |
| 643 | - if ( '' != get_option('permalink_structure') ) { |
|
| 644 | - if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) |
|
| 645 | - $url = _get_page_link( $post_id ); |
|
| 643 | + if ('' != get_option('permalink_structure')) { |
|
| 644 | + if ('page' == get_option('show_on_front') && $post_id == get_option('page_on_front')) |
|
| 645 | + $url = _get_page_link($post_id); |
|
| 646 | 646 | else |
| 647 | 647 | $url = get_permalink($post_id); |
| 648 | 648 | |
| 649 | - if ( $unattached ) { |
|
| 650 | - $url = home_url( '/feed/' ); |
|
| 651 | - if ( $feed !== get_default_feed() ) { |
|
| 649 | + if ($unattached) { |
|
| 650 | + $url = home_url('/feed/'); |
|
| 651 | + if ($feed !== get_default_feed()) { |
|
| 652 | 652 | $url .= "$feed/"; |
| 653 | 653 | } |
| 654 | - $url = add_query_arg( 'attachment_id', $post_id, $url ); |
|
| 654 | + $url = add_query_arg('attachment_id', $post_id, $url); |
|
| 655 | 655 | } else { |
| 656 | - $url = trailingslashit($url) . 'feed'; |
|
| 657 | - if ( $feed != get_default_feed() ) |
|
| 656 | + $url = trailingslashit($url).'feed'; |
|
| 657 | + if ($feed != get_default_feed()) |
|
| 658 | 658 | $url .= "/$feed"; |
| 659 | 659 | $url = user_trailingslashit($url, 'single_feed'); |
| 660 | 660 | } |
| 661 | 661 | } else { |
| 662 | - if ( $unattached ) { |
|
| 663 | - $url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id ), home_url( '/' ) ); |
|
| 664 | - } elseif ( 'page' == $post->post_type ) { |
|
| 665 | - $url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) ); |
|
| 662 | + if ($unattached) { |
|
| 663 | + $url = add_query_arg(array('feed' => $feed, 'attachment_id' => $post_id), home_url('/')); |
|
| 664 | + } elseif ('page' == $post->post_type) { |
|
| 665 | + $url = add_query_arg(array('feed' => $feed, 'page_id' => $post_id), home_url('/')); |
|
| 666 | 666 | } else { |
| 667 | - $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); |
|
| 667 | + $url = add_query_arg(array('feed' => $feed, 'p' => $post_id), home_url('/')); |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * |
| 676 | 676 | * @param string $url Post comments feed permalink. |
| 677 | 677 | */ |
| 678 | - return apply_filters( 'post_comments_feed_link', $url ); |
|
| 678 | + return apply_filters('post_comments_feed_link', $url); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -691,13 +691,13 @@ discard block |
||
| 691 | 691 | * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`. |
| 692 | 692 | * @param string $feed Optional. Feed format. Default empty. |
| 693 | 693 | */ |
| 694 | -function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { |
|
| 695 | - $url = get_post_comments_feed_link( $post_id, $feed ); |
|
| 696 | - if ( empty( $link_text ) ) { |
|
| 694 | +function post_comments_feed_link($link_text = '', $post_id = '', $feed = '') { |
|
| 695 | + $url = get_post_comments_feed_link($post_id, $feed); |
|
| 696 | + if (empty($link_text)) { |
|
| 697 | 697 | $link_text = __('Comments Feed'); |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - $link = '<a href="' . esc_url( $url ) . '">' . $link_text . '</a>'; |
|
| 700 | + $link = '<a href="'.esc_url($url).'">'.$link_text.'</a>'; |
|
| 701 | 701 | /** |
| 702 | 702 | * Filters the post comment feed link anchor tag. |
| 703 | 703 | * |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @param int $post_id Post ID. |
| 708 | 708 | * @param string $feed The feed type, or an empty string for the default feed type. |
| 709 | 709 | */ |
| 710 | - echo apply_filters( 'post_comments_feed_link_html', $link, $post_id, $feed ); |
|
| 710 | + echo apply_filters('post_comments_feed_link_html', $link, $post_id, $feed); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
@@ -722,23 +722,23 @@ discard block |
||
| 722 | 722 | * @param string $feed Optional. Feed type. Default empty. |
| 723 | 723 | * @return string Link to the feed for the author specified by $author_id. |
| 724 | 724 | */ |
| 725 | -function get_author_feed_link( $author_id, $feed = '' ) { |
|
| 725 | +function get_author_feed_link($author_id, $feed = '') { |
|
| 726 | 726 | $author_id = (int) $author_id; |
| 727 | 727 | $permalink_structure = get_option('permalink_structure'); |
| 728 | 728 | |
| 729 | - if ( empty($feed) ) |
|
| 729 | + if (empty($feed)) |
|
| 730 | 730 | $feed = get_default_feed(); |
| 731 | 731 | |
| 732 | - if ( '' == $permalink_structure ) { |
|
| 733 | - $link = home_url("?feed=$feed&author=" . $author_id); |
|
| 732 | + if ('' == $permalink_structure) { |
|
| 733 | + $link = home_url("?feed=$feed&author=".$author_id); |
|
| 734 | 734 | } else { |
| 735 | 735 | $link = get_author_posts_url($author_id); |
| 736 | - if ( $feed == get_default_feed() ) |
|
| 736 | + if ($feed == get_default_feed()) |
|
| 737 | 737 | $feed_link = 'feed'; |
| 738 | 738 | else |
| 739 | 739 | $feed_link = "feed/$feed"; |
| 740 | 740 | |
| 741 | - $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); |
|
| 741 | + $link = trailingslashit($link).user_trailingslashit($feed_link, 'feed'); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | * @param string $link The author feed link. |
| 750 | 750 | * @param string $feed Feed type. |
| 751 | 751 | */ |
| 752 | - $link = apply_filters( 'author_feed_link', $link, $feed ); |
|
| 752 | + $link = apply_filters('author_feed_link', $link, $feed); |
|
| 753 | 753 | |
| 754 | 754 | return $link; |
| 755 | 755 | } |
@@ -766,8 +766,8 @@ discard block |
||
| 766 | 766 | * @param string $feed Optional. Feed type. Default empty. |
| 767 | 767 | * @return string Link to the feed for the category specified by $cat_id. |
| 768 | 768 | */ |
| 769 | -function get_category_feed_link( $cat_id, $feed = '' ) { |
|
| 770 | - return get_term_feed_link( $cat_id, 'category', $feed ); |
|
| 769 | +function get_category_feed_link($cat_id, $feed = '') { |
|
| 770 | + return get_term_feed_link($cat_id, 'category', $feed); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
@@ -783,40 +783,40 @@ discard block |
||
| 783 | 783 | * @param string $feed Optional. Feed type. Default empty. |
| 784 | 784 | * @return string|false Link to the feed for the term specified by $term_id and $taxonomy. |
| 785 | 785 | */ |
| 786 | -function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { |
|
| 787 | - $term_id = ( int ) $term_id; |
|
| 786 | +function get_term_feed_link($term_id, $taxonomy = 'category', $feed = '') { |
|
| 787 | + $term_id = (int) $term_id; |
|
| 788 | 788 | |
| 789 | - $term = get_term( $term_id, $taxonomy ); |
|
| 789 | + $term = get_term($term_id, $taxonomy); |
|
| 790 | 790 | |
| 791 | - if ( empty( $term ) || is_wp_error( $term ) ) |
|
| 791 | + if (empty($term) || is_wp_error($term)) |
|
| 792 | 792 | return false; |
| 793 | 793 | |
| 794 | - if ( empty( $feed ) ) |
|
| 794 | + if (empty($feed)) |
|
| 795 | 795 | $feed = get_default_feed(); |
| 796 | 796 | |
| 797 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
| 797 | + $permalink_structure = get_option('permalink_structure'); |
|
| 798 | 798 | |
| 799 | - if ( '' == $permalink_structure ) { |
|
| 800 | - if ( 'category' == $taxonomy ) { |
|
| 799 | + if ('' == $permalink_structure) { |
|
| 800 | + if ('category' == $taxonomy) { |
|
| 801 | 801 | $link = home_url("?feed=$feed&cat=$term_id"); |
| 802 | 802 | } |
| 803 | - elseif ( 'post_tag' == $taxonomy ) { |
|
| 803 | + elseif ('post_tag' == $taxonomy) { |
|
| 804 | 804 | $link = home_url("?feed=$feed&tag=$term->slug"); |
| 805 | 805 | } else { |
| 806 | - $t = get_taxonomy( $taxonomy ); |
|
| 806 | + $t = get_taxonomy($taxonomy); |
|
| 807 | 807 | $link = home_url("?feed=$feed&$t->query_var=$term->slug"); |
| 808 | 808 | } |
| 809 | 809 | } else { |
| 810 | - $link = get_term_link( $term_id, $term->taxonomy ); |
|
| 811 | - if ( $feed == get_default_feed() ) |
|
| 810 | + $link = get_term_link($term_id, $term->taxonomy); |
|
| 811 | + if ($feed == get_default_feed()) |
|
| 812 | 812 | $feed_link = 'feed'; |
| 813 | 813 | else |
| 814 | 814 | $feed_link = "feed/$feed"; |
| 815 | 815 | |
| 816 | - $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); |
|
| 816 | + $link = trailingslashit($link).user_trailingslashit($feed_link, 'feed'); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - if ( 'category' == $taxonomy ) { |
|
| 819 | + if ('category' == $taxonomy) { |
|
| 820 | 820 | /** |
| 821 | 821 | * Filters the category feed link. |
| 822 | 822 | * |
@@ -825,8 +825,8 @@ discard block |
||
| 825 | 825 | * @param string $link The category feed link. |
| 826 | 826 | * @param string $feed Feed type. |
| 827 | 827 | */ |
| 828 | - $link = apply_filters( 'category_feed_link', $link, $feed ); |
|
| 829 | - } elseif ( 'post_tag' == $taxonomy ) { |
|
| 828 | + $link = apply_filters('category_feed_link', $link, $feed); |
|
| 829 | + } elseif ('post_tag' == $taxonomy) { |
|
| 830 | 830 | /** |
| 831 | 831 | * Filters the post tag feed link. |
| 832 | 832 | * |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param string $link The tag feed link. |
| 836 | 836 | * @param string $feed Feed type. |
| 837 | 837 | */ |
| 838 | - $link = apply_filters( 'tag_feed_link', $link, $feed ); |
|
| 838 | + $link = apply_filters('tag_feed_link', $link, $feed); |
|
| 839 | 839 | } else { |
| 840 | 840 | /** |
| 841 | 841 | * Filters the feed link for a taxonomy other than 'category' or 'post_tag'. |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | * @param string $feed Feed type. |
| 847 | 847 | * @param string $feed The taxonomy name. |
| 848 | 848 | */ |
| 849 | - $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); |
|
| 849 | + $link = apply_filters('taxonomy_feed_link', $link, $feed, $taxonomy); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | return $link; |
@@ -861,8 +861,8 @@ discard block |
||
| 861 | 861 | * @param string $feed Optional. Feed type. Default empty. |
| 862 | 862 | * @return string The feed permalink for the given tag. |
| 863 | 863 | */ |
| 864 | -function get_tag_feed_link( $tag_id, $feed = '' ) { |
|
| 865 | - return get_term_feed_link( $tag_id, 'post_tag', $feed ); |
|
| 864 | +function get_tag_feed_link($tag_id, $feed = '') { |
|
| 865 | + return get_term_feed_link($tag_id, 'post_tag', $feed); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'. |
| 875 | 875 | * @return string The edit tag link URL for the given tag. |
| 876 | 876 | */ |
| 877 | -function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { |
|
| 877 | +function get_edit_tag_link($tag_id, $taxonomy = 'post_tag') { |
|
| 878 | 878 | /** |
| 879 | 879 | * Filters the edit link for a tag (or term in another taxonomy). |
| 880 | 880 | * |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param string $link The term edit link. |
| 884 | 884 | */ |
| 885 | - return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) ); |
|
| 885 | + return apply_filters('get_edit_tag_link', get_edit_term_link($tag_id, $taxonomy)); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | /** |
@@ -896,8 +896,8 @@ discard block |
||
| 896 | 896 | * @param WP_Term $tag Optional. Term object. If null, the queried object will be inspected. |
| 897 | 897 | * Default null. |
| 898 | 898 | */ |
| 899 | -function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { |
|
| 900 | - $link = edit_term_link( $link, '', '', $tag, false ); |
|
| 899 | +function edit_tag_link($link = '', $before = '', $after = '', $tag = null) { |
|
| 900 | + $link = edit_term_link($link, '', '', $tag, false); |
|
| 901 | 901 | |
| 902 | 902 | /** |
| 903 | 903 | * Filters the anchor tag for the edit link for a tag (or term in another taxonomy). |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | * |
| 907 | 907 | * @param string $link The anchor tag for the edit link. |
| 908 | 908 | */ |
| 909 | - echo $before . apply_filters( 'edit_tag_link', $link ) . $after; |
|
| 909 | + echo $before.apply_filters('edit_tag_link', $link).$after; |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | /** |
@@ -923,14 +923,14 @@ discard block |
||
| 923 | 923 | * with the taxonomy. |
| 924 | 924 | * @return string|null The edit term link URL for the given term, or null on failure. |
| 925 | 925 | */ |
| 926 | -function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) { |
|
| 927 | - $term = get_term( $term_id, $taxonomy ); |
|
| 928 | - if ( ! $term || is_wp_error( $term ) ) { |
|
| 926 | +function get_edit_term_link($term_id, $taxonomy = '', $object_type = '') { |
|
| 927 | + $term = get_term($term_id, $taxonomy); |
|
| 928 | + if ( ! $term || is_wp_error($term)) { |
|
| 929 | 929 | return; |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | - $tax = get_taxonomy( $term->taxonomy ); |
|
| 933 | - if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) { |
|
| 932 | + $tax = get_taxonomy($term->taxonomy); |
|
| 933 | + if ( ! $tax || ! current_user_can($tax->cap->edit_terms)) { |
|
| 934 | 934 | return; |
| 935 | 935 | } |
| 936 | 936 | |
@@ -939,14 +939,14 @@ discard block |
||
| 939 | 939 | 'tag_ID' => $term->term_id, |
| 940 | 940 | ); |
| 941 | 941 | |
| 942 | - if ( $object_type ) { |
|
| 942 | + if ($object_type) { |
|
| 943 | 943 | $args['post_type'] = $object_type; |
| 944 | - } elseif ( ! empty( $tax->object_type ) ) { |
|
| 945 | - $args['post_type'] = reset( $tax->object_type ); |
|
| 944 | + } elseif ( ! empty($tax->object_type)) { |
|
| 945 | + $args['post_type'] = reset($tax->object_type); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | - if ( $tax->show_ui ) { |
|
| 949 | - $location = add_query_arg( $args, admin_url( 'term.php' ) ); |
|
| 948 | + if ($tax->show_ui) { |
|
| 949 | + $location = add_query_arg($args, admin_url('term.php')); |
|
| 950 | 950 | } else { |
| 951 | 951 | $location = ''; |
| 952 | 952 | } |
@@ -961,7 +961,7 @@ discard block |
||
| 961 | 961 | * @param string $taxonomy Taxonomy name. |
| 962 | 962 | * @param string $object_type The object type (eg. the post type). |
| 963 | 963 | */ |
| 964 | - return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); |
|
| 964 | + return apply_filters('get_edit_term_link', $location, $term_id, $taxonomy, $object_type); |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | /** |
@@ -976,21 +976,21 @@ discard block |
||
| 976 | 976 | * @param bool $echo Optional. Whether or not to echo the return. Default true. |
| 977 | 977 | * @return string|void HTML content. |
| 978 | 978 | */ |
| 979 | -function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { |
|
| 980 | - if ( is_null( $term ) ) |
|
| 979 | +function edit_term_link($link = '', $before = '', $after = '', $term = null, $echo = true) { |
|
| 980 | + if (is_null($term)) |
|
| 981 | 981 | $term = get_queried_object(); |
| 982 | 982 | |
| 983 | - if ( ! $term ) |
|
| 983 | + if ( ! $term) |
|
| 984 | 984 | return; |
| 985 | 985 | |
| 986 | - $tax = get_taxonomy( $term->taxonomy ); |
|
| 987 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
| 986 | + $tax = get_taxonomy($term->taxonomy); |
|
| 987 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
| 988 | 988 | return; |
| 989 | 989 | |
| 990 | - if ( empty( $link ) ) |
|
| 990 | + if (empty($link)) |
|
| 991 | 991 | $link = __('Edit This'); |
| 992 | 992 | |
| 993 | - $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; |
|
| 993 | + $link = '<a href="'.get_edit_term_link($term->term_id, $term->taxonomy).'">'.$link.'</a>'; |
|
| 994 | 994 | |
| 995 | 995 | /** |
| 996 | 996 | * Filters the anchor tag for the edit link of a term. |
@@ -1000,9 +1000,9 @@ discard block |
||
| 1000 | 1000 | * @param string $link The anchor tag for the edit link. |
| 1001 | 1001 | * @param int $term_id Term ID. |
| 1002 | 1002 | */ |
| 1003 | - $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; |
|
| 1003 | + $link = $before.apply_filters('edit_term_link', $link, $term->term_id).$after; |
|
| 1004 | 1004 | |
| 1005 | - if ( $echo ) |
|
| 1005 | + if ($echo) |
|
| 1006 | 1006 | echo $link; |
| 1007 | 1007 | else |
| 1008 | 1008 | return $link; |
@@ -1018,23 +1018,23 @@ discard block |
||
| 1018 | 1018 | * @param string $query Optional. The query string to use. If empty the current query is used. Default empty. |
| 1019 | 1019 | * @return string The search permalink. |
| 1020 | 1020 | */ |
| 1021 | -function get_search_link( $query = '' ) { |
|
| 1021 | +function get_search_link($query = '') { |
|
| 1022 | 1022 | global $wp_rewrite; |
| 1023 | 1023 | |
| 1024 | - if ( empty($query) ) |
|
| 1025 | - $search = get_search_query( false ); |
|
| 1024 | + if (empty($query)) |
|
| 1025 | + $search = get_search_query(false); |
|
| 1026 | 1026 | else |
| 1027 | 1027 | $search = stripslashes($query); |
| 1028 | 1028 | |
| 1029 | 1029 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1030 | 1030 | |
| 1031 | - if ( empty( $permastruct ) ) { |
|
| 1032 | - $link = home_url('?s=' . urlencode($search) ); |
|
| 1031 | + if (empty($permastruct)) { |
|
| 1032 | + $link = home_url('?s='.urlencode($search)); |
|
| 1033 | 1033 | } else { |
| 1034 | 1034 | $search = urlencode($search); |
| 1035 | 1035 | $search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it un-encoded. |
| 1036 | - $link = str_replace( '%search%', $search, $permastruct ); |
|
| 1037 | - $link = home_url( user_trailingslashit( $link, 'search' ) ); |
|
| 1036 | + $link = str_replace('%search%', $search, $permastruct); |
|
| 1037 | + $link = home_url(user_trailingslashit($link, 'search')); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | /** |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | * @param string $link Search permalink. |
| 1046 | 1046 | * @param string $search The URL-encoded search term. |
| 1047 | 1047 | */ |
| 1048 | - return apply_filters( 'search_link', $link, $search ); |
|
| 1048 | + return apply_filters('search_link', $link, $search); |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | /** |
@@ -1063,12 +1063,12 @@ discard block |
||
| 1063 | 1063 | global $wp_rewrite; |
| 1064 | 1064 | $link = get_search_link($search_query); |
| 1065 | 1065 | |
| 1066 | - if ( empty($feed) ) |
|
| 1066 | + if (empty($feed)) |
|
| 1067 | 1067 | $feed = get_default_feed(); |
| 1068 | 1068 | |
| 1069 | 1069 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1070 | 1070 | |
| 1071 | - if ( empty($permastruct) ) { |
|
| 1071 | + if (empty($permastruct)) { |
|
| 1072 | 1072 | $link = add_query_arg('feed', $feed, $link); |
| 1073 | 1073 | } else { |
| 1074 | 1074 | $link = trailingslashit($link); |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | * @param string $feed Feed type. |
| 1085 | 1085 | * @param string $type The search type. One of 'posts' or 'comments'. |
| 1086 | 1086 | */ |
| 1087 | - return apply_filters( 'search_feed_link', $link, $feed, 'posts' ); |
|
| 1087 | + return apply_filters('search_feed_link', $link, $feed, 'posts'); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | /** |
@@ -1101,20 +1101,20 @@ discard block |
||
| 1101 | 1101 | function get_search_comments_feed_link($search_query = '', $feed = '') { |
| 1102 | 1102 | global $wp_rewrite; |
| 1103 | 1103 | |
| 1104 | - if ( empty($feed) ) |
|
| 1104 | + if (empty($feed)) |
|
| 1105 | 1105 | $feed = get_default_feed(); |
| 1106 | 1106 | |
| 1107 | 1107 | $link = get_search_feed_link($search_query, $feed); |
| 1108 | 1108 | |
| 1109 | 1109 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1110 | 1110 | |
| 1111 | - if ( empty($permastruct) ) |
|
| 1112 | - $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1111 | + if (empty($permastruct)) |
|
| 1112 | + $link = add_query_arg('feed', 'comments-'.$feed, $link); |
|
| 1113 | 1113 | else |
| 1114 | 1114 | $link = add_query_arg('withcomments', 1, $link); |
| 1115 | 1115 | |
| 1116 | 1116 | /** This filter is documented in wp-includes/link-template.php */ |
| 1117 | - return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); |
|
| 1117 | + return apply_filters('search_feed_link', $link, $feed, 'comments'); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
@@ -1128,36 +1128,36 @@ discard block |
||
| 1128 | 1128 | * @param string $post_type Post type. |
| 1129 | 1129 | * @return string|false The post type archive permalink. |
| 1130 | 1130 | */ |
| 1131 | -function get_post_type_archive_link( $post_type ) { |
|
| 1131 | +function get_post_type_archive_link($post_type) { |
|
| 1132 | 1132 | global $wp_rewrite; |
| 1133 | - if ( ! $post_type_obj = get_post_type_object( $post_type ) ) |
|
| 1133 | + if ( ! $post_type_obj = get_post_type_object($post_type)) |
|
| 1134 | 1134 | return false; |
| 1135 | 1135 | |
| 1136 | - if ( 'post' === $post_type ) { |
|
| 1137 | - $show_on_front = get_option( 'show_on_front' ); |
|
| 1138 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
| 1136 | + if ('post' === $post_type) { |
|
| 1137 | + $show_on_front = get_option('show_on_front'); |
|
| 1138 | + $page_for_posts = get_option('page_for_posts'); |
|
| 1139 | 1139 | |
| 1140 | - if ( 'page' == $show_on_front && $page_for_posts ) { |
|
| 1141 | - $link = get_permalink( $page_for_posts ); |
|
| 1140 | + if ('page' == $show_on_front && $page_for_posts) { |
|
| 1141 | + $link = get_permalink($page_for_posts); |
|
| 1142 | 1142 | } else { |
| 1143 | 1143 | $link = get_home_url(); |
| 1144 | 1144 | } |
| 1145 | 1145 | /** This filter is documented in wp-includes/link-template.php */ |
| 1146 | - return apply_filters( 'post_type_archive_link', $link, $post_type ); |
|
| 1146 | + return apply_filters('post_type_archive_link', $link, $post_type); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - if ( ! $post_type_obj->has_archive ) |
|
| 1149 | + if ( ! $post_type_obj->has_archive) |
|
| 1150 | 1150 | return false; |
| 1151 | 1151 | |
| 1152 | - if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { |
|
| 1153 | - $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
|
| 1154 | - if ( $post_type_obj->rewrite['with_front'] ) |
|
| 1155 | - $struct = $wp_rewrite->front . $struct; |
|
| 1152 | + if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) { |
|
| 1153 | + $struct = (true === $post_type_obj->has_archive) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
|
| 1154 | + if ($post_type_obj->rewrite['with_front']) |
|
| 1155 | + $struct = $wp_rewrite->front.$struct; |
|
| 1156 | 1156 | else |
| 1157 | - $struct = $wp_rewrite->root . $struct; |
|
| 1158 | - $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); |
|
| 1157 | + $struct = $wp_rewrite->root.$struct; |
|
| 1158 | + $link = home_url(user_trailingslashit($struct, 'post_type_archive')); |
|
| 1159 | 1159 | } else { |
| 1160 | - $link = home_url( '?post_type=' . $post_type ); |
|
| 1160 | + $link = home_url('?post_type='.$post_type); |
|
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | 1163 | /** |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | * @param string $link The post type archive permalink. |
| 1169 | 1169 | * @param string $post_type Post type name. |
| 1170 | 1170 | */ |
| 1171 | - return apply_filters( 'post_type_archive_link', $link, $post_type ); |
|
| 1171 | + return apply_filters('post_type_archive_link', $link, $post_type); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | /** |
@@ -1180,22 +1180,22 @@ discard block |
||
| 1180 | 1180 | * @param string $feed Optional. Feed type. Default empty. |
| 1181 | 1181 | * @return string|false The post type feed permalink. |
| 1182 | 1182 | */ |
| 1183 | -function get_post_type_archive_feed_link( $post_type, $feed = '' ) { |
|
| 1183 | +function get_post_type_archive_feed_link($post_type, $feed = '') { |
|
| 1184 | 1184 | $default_feed = get_default_feed(); |
| 1185 | - if ( empty( $feed ) ) |
|
| 1185 | + if (empty($feed)) |
|
| 1186 | 1186 | $feed = $default_feed; |
| 1187 | 1187 | |
| 1188 | - if ( ! $link = get_post_type_archive_link( $post_type ) ) |
|
| 1188 | + if ( ! $link = get_post_type_archive_link($post_type)) |
|
| 1189 | 1189 | return false; |
| 1190 | 1190 | |
| 1191 | - $post_type_obj = get_post_type_object( $post_type ); |
|
| 1192 | - if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { |
|
| 1193 | - $link = trailingslashit( $link ); |
|
| 1191 | + $post_type_obj = get_post_type_object($post_type); |
|
| 1192 | + if (get_option('permalink_structure') && is_array($post_type_obj->rewrite) && $post_type_obj->rewrite['feeds']) { |
|
| 1193 | + $link = trailingslashit($link); |
|
| 1194 | 1194 | $link .= 'feed/'; |
| 1195 | - if ( $feed != $default_feed ) |
|
| 1195 | + if ($feed != $default_feed) |
|
| 1196 | 1196 | $link .= "$feed/"; |
| 1197 | 1197 | } else { |
| 1198 | - $link = add_query_arg( 'feed', $feed, $link ); |
|
| 1198 | + $link = add_query_arg('feed', $feed, $link); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | /** |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | * @param string $link The post type archive feed link. |
| 1207 | 1207 | * @param string $feed Feed type. |
| 1208 | 1208 | */ |
| 1209 | - return apply_filters( 'post_type_archive_feed_link', $link, $feed ); |
|
| 1209 | + return apply_filters('post_type_archive_feed_link', $link, $feed); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -1223,20 +1223,20 @@ discard block |
||
| 1223 | 1223 | * post permalink. Default empty. |
| 1224 | 1224 | * @return string|null URL used for the post preview, or null if the post does not exist. |
| 1225 | 1225 | */ |
| 1226 | -function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) { |
|
| 1227 | - $post = get_post( $post ); |
|
| 1228 | - if ( ! $post ) { |
|
| 1226 | +function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') { |
|
| 1227 | + $post = get_post($post); |
|
| 1228 | + if ( ! $post) { |
|
| 1229 | 1229 | return; |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1233 | - if ( is_post_type_viewable( $post_type_object ) ) { |
|
| 1234 | - if ( ! $preview_link ) { |
|
| 1235 | - $preview_link = set_url_scheme( get_permalink( $post ) ); |
|
| 1232 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1233 | + if (is_post_type_viewable($post_type_object)) { |
|
| 1234 | + if ( ! $preview_link) { |
|
| 1235 | + $preview_link = set_url_scheme(get_permalink($post)); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | $query_args['preview'] = 'true'; |
| 1239 | - $preview_link = add_query_arg( $query_args, $preview_link ); |
|
| 1239 | + $preview_link = add_query_arg($query_args, $preview_link); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | /** |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | * @param string $preview_link URL used for the post preview. |
| 1249 | 1249 | * @param WP_Post $post Post object. |
| 1250 | 1250 | */ |
| 1251 | - return apply_filters( 'preview_post_link', $preview_link, $post ); |
|
| 1251 | + return apply_filters('preview_post_link', $preview_link, $post); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | /** |
@@ -1264,26 +1264,26 @@ discard block |
||
| 1264 | 1264 | * @return string|null The edit post link for the given post. null if the post type is invalid or does |
| 1265 | 1265 | * not allow an editing UI. |
| 1266 | 1266 | */ |
| 1267 | -function get_edit_post_link( $id = 0, $context = 'display' ) { |
|
| 1268 | - if ( ! $post = get_post( $id ) ) |
|
| 1267 | +function get_edit_post_link($id = 0, $context = 'display') { |
|
| 1268 | + if ( ! $post = get_post($id)) |
|
| 1269 | 1269 | return; |
| 1270 | 1270 | |
| 1271 | - if ( 'revision' === $post->post_type ) |
|
| 1271 | + if ('revision' === $post->post_type) |
|
| 1272 | 1272 | $action = ''; |
| 1273 | - elseif ( 'display' == $context ) |
|
| 1273 | + elseif ('display' == $context) |
|
| 1274 | 1274 | $action = '&action=edit'; |
| 1275 | 1275 | else |
| 1276 | 1276 | $action = '&action=edit'; |
| 1277 | 1277 | |
| 1278 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1279 | - if ( !$post_type_object ) |
|
| 1278 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1279 | + if ( ! $post_type_object) |
|
| 1280 | 1280 | return; |
| 1281 | 1281 | |
| 1282 | - if ( !current_user_can( 'edit_post', $post->ID ) ) |
|
| 1282 | + if ( ! current_user_can('edit_post', $post->ID)) |
|
| 1283 | 1283 | return; |
| 1284 | 1284 | |
| 1285 | - if ( $post_type_object->_edit_link ) { |
|
| 1286 | - $link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ); |
|
| 1285 | + if ($post_type_object->_edit_link) { |
|
| 1286 | + $link = admin_url(sprintf($post_type_object->_edit_link.$action, $post->ID)); |
|
| 1287 | 1287 | } else { |
| 1288 | 1288 | $link = ''; |
| 1289 | 1289 | } |
@@ -1298,7 +1298,7 @@ discard block |
||
| 1298 | 1298 | * @param string $context The link context. If set to 'display' then ampersands |
| 1299 | 1299 | * are encoded. |
| 1300 | 1300 | */ |
| 1301 | - return apply_filters( 'get_edit_post_link', $link, $post->ID, $context ); |
|
| 1301 | + return apply_filters('get_edit_post_link', $link, $post->ID, $context); |
|
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | /** |
@@ -1313,20 +1313,20 @@ discard block |
||
| 1313 | 1313 | * @param int $id Optional. Post ID. Default is the ID of the global `$post`. |
| 1314 | 1314 | * @param string $class Optional. Add custom class to link. Default 'post-edit-link'. |
| 1315 | 1315 | */ |
| 1316 | -function edit_post_link( $text = null, $before = '', $after = '', $id = 0, $class = 'post-edit-link' ) { |
|
| 1317 | - if ( ! $post = get_post( $id ) ) { |
|
| 1316 | +function edit_post_link($text = null, $before = '', $after = '', $id = 0, $class = 'post-edit-link') { |
|
| 1317 | + if ( ! $post = get_post($id)) { |
|
| 1318 | 1318 | return; |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | - if ( ! $url = get_edit_post_link( $post->ID ) ) { |
|
| 1321 | + if ( ! $url = get_edit_post_link($post->ID)) { |
|
| 1322 | 1322 | return; |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | - if ( null === $text ) { |
|
| 1326 | - $text = __( 'Edit This' ); |
|
| 1325 | + if (null === $text) { |
|
| 1326 | + $text = __('Edit This'); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | - $link = '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>'; |
|
| 1329 | + $link = '<a class="'.esc_attr($class).'" href="'.esc_url($url).'">'.$text.'</a>'; |
|
| 1330 | 1330 | |
| 1331 | 1331 | /** |
| 1332 | 1332 | * Filters the post edit link anchor tag. |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | * @param int $post_id Post ID. |
| 1338 | 1338 | * @param string $text Anchor text. |
| 1339 | 1339 | */ |
| 1340 | - echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; |
|
| 1340 | + echo $before.apply_filters('edit_post_link', $link, $post->ID, $text).$after; |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | /** |
@@ -1352,23 +1352,23 @@ discard block |
||
| 1352 | 1352 | * @param bool $force_delete Optional. Whether to bypass trash and force deletion. Default false. |
| 1353 | 1353 | * @return string|void The delete post link URL for the given post. |
| 1354 | 1354 | */ |
| 1355 | -function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) { |
|
| 1356 | - if ( ! empty( $deprecated ) ) |
|
| 1357 | - _deprecated_argument( __FUNCTION__, '3.0.0' ); |
|
| 1355 | +function get_delete_post_link($id = 0, $deprecated = '', $force_delete = false) { |
|
| 1356 | + if ( ! empty($deprecated)) |
|
| 1357 | + _deprecated_argument(__FUNCTION__, '3.0.0'); |
|
| 1358 | 1358 | |
| 1359 | - if ( !$post = get_post( $id ) ) |
|
| 1359 | + if ( ! $post = get_post($id)) |
|
| 1360 | 1360 | return; |
| 1361 | 1361 | |
| 1362 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1363 | - if ( !$post_type_object ) |
|
| 1362 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1363 | + if ( ! $post_type_object) |
|
| 1364 | 1364 | return; |
| 1365 | 1365 | |
| 1366 | - if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
| 1366 | + if ( ! current_user_can('delete_post', $post->ID)) |
|
| 1367 | 1367 | return; |
| 1368 | 1368 | |
| 1369 | - $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; |
|
| 1369 | + $action = ($force_delete || ! EMPTY_TRASH_DAYS) ? 'delete' : 'trash'; |
|
| 1370 | 1370 | |
| 1371 | - $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); |
|
| 1371 | + $delete_link = add_query_arg('action', $action, admin_url(sprintf($post_type_object->_edit_link, $post->ID))); |
|
| 1372 | 1372 | |
| 1373 | 1373 | /** |
| 1374 | 1374 | * Filters the post delete link. |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | * @param int $post_id Post ID. |
| 1380 | 1380 | * @param bool $force_delete Whether to bypass the trash and force deletion. Default false. |
| 1381 | 1381 | */ |
| 1382 | - return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); |
|
| 1382 | + return apply_filters('get_delete_post_link', wp_nonce_url($delete_link, "$action-post_{$post->ID}"), $post->ID, $force_delete); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | /** |
@@ -1390,13 +1390,13 @@ discard block |
||
| 1390 | 1390 | * @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object. |
| 1391 | 1391 | * @return string|void The edit comment link URL for the given comment. |
| 1392 | 1392 | */ |
| 1393 | -function get_edit_comment_link( $comment_id = 0 ) { |
|
| 1394 | - $comment = get_comment( $comment_id ); |
|
| 1393 | +function get_edit_comment_link($comment_id = 0) { |
|
| 1394 | + $comment = get_comment($comment_id); |
|
| 1395 | 1395 | |
| 1396 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
| 1396 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) |
|
| 1397 | 1397 | return; |
| 1398 | 1398 | |
| 1399 | - $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; |
|
| 1399 | + $location = admin_url('comment.php?action=editcomment&c=').$comment->comment_ID; |
|
| 1400 | 1400 | |
| 1401 | 1401 | /** |
| 1402 | 1402 | * Filters the comment edit link. |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | * |
| 1406 | 1406 | * @param string $location The edit link. |
| 1407 | 1407 | */ |
| 1408 | - return apply_filters( 'get_edit_comment_link', $location ); |
|
| 1408 | + return apply_filters('get_edit_comment_link', $location); |
|
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | 1411 | /** |
@@ -1417,18 +1417,18 @@ discard block |
||
| 1417 | 1417 | * @param string $before Optional. Display before edit link. Default empty. |
| 1418 | 1418 | * @param string $after Optional. Display after edit link. Default empty. |
| 1419 | 1419 | */ |
| 1420 | -function edit_comment_link( $text = null, $before = '', $after = '' ) { |
|
| 1420 | +function edit_comment_link($text = null, $before = '', $after = '') { |
|
| 1421 | 1421 | $comment = get_comment(); |
| 1422 | 1422 | |
| 1423 | - if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
| 1423 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) { |
|
| 1424 | 1424 | return; |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - if ( null === $text ) { |
|
| 1428 | - $text = __( 'Edit This' ); |
|
| 1427 | + if (null === $text) { |
|
| 1428 | + $text = __('Edit This'); |
|
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | - $link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>'; |
|
| 1431 | + $link = '<a class="comment-edit-link" href="'.esc_url(get_edit_comment_link($comment)).'">'.$text.'</a>'; |
|
| 1432 | 1432 | |
| 1433 | 1433 | /** |
| 1434 | 1434 | * Filters the comment edit link anchor tag. |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | * @param int $comment_id Comment ID. |
| 1440 | 1440 | * @param string $text Anchor text. |
| 1441 | 1441 | */ |
| 1442 | - echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; |
|
| 1442 | + echo $before.apply_filters('edit_comment_link', $link, $comment->comment_ID, $text).$after; |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | /** |
@@ -1450,13 +1450,13 @@ discard block |
||
| 1450 | 1450 | * @param int|stdClass $link Optional. Bookmark ID. Default is the id of the current bookmark. |
| 1451 | 1451 | * @return string|void The edit bookmark link URL. |
| 1452 | 1452 | */ |
| 1453 | -function get_edit_bookmark_link( $link = 0 ) { |
|
| 1454 | - $link = get_bookmark( $link ); |
|
| 1453 | +function get_edit_bookmark_link($link = 0) { |
|
| 1454 | + $link = get_bookmark($link); |
|
| 1455 | 1455 | |
| 1456 | - if ( !current_user_can('manage_links') ) |
|
| 1456 | + if ( ! current_user_can('manage_links')) |
|
| 1457 | 1457 | return; |
| 1458 | 1458 | |
| 1459 | - $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; |
|
| 1459 | + $location = admin_url('link.php?action=edit&link_id=').$link->link_id; |
|
| 1460 | 1460 | |
| 1461 | 1461 | /** |
| 1462 | 1462 | * Filters the bookmark edit link. |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | * @param string $location The edit link. |
| 1467 | 1467 | * @param int $link_id Bookmark ID. |
| 1468 | 1468 | */ |
| 1469 | - return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); |
|
| 1469 | + return apply_filters('get_edit_bookmark_link', $location, $link->link_id); |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | /** |
@@ -1479,16 +1479,16 @@ discard block |
||
| 1479 | 1479 | * @param string $after Optional. Display after edit link. Default empty. |
| 1480 | 1480 | * @param int $bookmark Optional. Bookmark ID. Default is the current bookmark. |
| 1481 | 1481 | */ |
| 1482 | -function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { |
|
| 1482 | +function edit_bookmark_link($link = '', $before = '', $after = '', $bookmark = null) { |
|
| 1483 | 1483 | $bookmark = get_bookmark($bookmark); |
| 1484 | 1484 | |
| 1485 | - if ( !current_user_can('manage_links') ) |
|
| 1485 | + if ( ! current_user_can('manage_links')) |
|
| 1486 | 1486 | return; |
| 1487 | 1487 | |
| 1488 | - if ( empty($link) ) |
|
| 1488 | + if (empty($link)) |
|
| 1489 | 1489 | $link = __('Edit This'); |
| 1490 | 1490 | |
| 1491 | - $link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>'; |
|
| 1491 | + $link = '<a href="'.esc_url(get_edit_bookmark_link($bookmark)).'">'.$link.'</a>'; |
|
| 1492 | 1492 | |
| 1493 | 1493 | /** |
| 1494 | 1494 | * Filters the bookmark edit link anchor tag. |
@@ -1498,7 +1498,7 @@ discard block |
||
| 1498 | 1498 | * @param string $link Anchor tag for the edit link. |
| 1499 | 1499 | * @param int $link_id Bookmark ID. |
| 1500 | 1500 | */ |
| 1501 | - echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; |
|
| 1501 | + echo $before.apply_filters('edit_bookmark_link', $link, $bookmark->link_id).$after; |
|
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | /** |
@@ -1509,22 +1509,22 @@ discard block |
||
| 1509 | 1509 | * @param int $user_id Optional. User ID. Defaults to the current user. |
| 1510 | 1510 | * @return string URL to edit user page or empty string. |
| 1511 | 1511 | */ |
| 1512 | -function get_edit_user_link( $user_id = null ) { |
|
| 1513 | - if ( ! $user_id ) |
|
| 1512 | +function get_edit_user_link($user_id = null) { |
|
| 1513 | + if ( ! $user_id) |
|
| 1514 | 1514 | $user_id = get_current_user_id(); |
| 1515 | 1515 | |
| 1516 | - if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) |
|
| 1516 | + if (empty($user_id) || ! current_user_can('edit_user', $user_id)) |
|
| 1517 | 1517 | return ''; |
| 1518 | 1518 | |
| 1519 | - $user = get_userdata( $user_id ); |
|
| 1519 | + $user = get_userdata($user_id); |
|
| 1520 | 1520 | |
| 1521 | - if ( ! $user ) |
|
| 1521 | + if ( ! $user) |
|
| 1522 | 1522 | return ''; |
| 1523 | 1523 | |
| 1524 | - if ( get_current_user_id() == $user->ID ) |
|
| 1525 | - $link = get_edit_profile_url( $user->ID ); |
|
| 1524 | + if (get_current_user_id() == $user->ID) |
|
| 1525 | + $link = get_edit_profile_url($user->ID); |
|
| 1526 | 1526 | else |
| 1527 | - $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1527 | + $link = add_query_arg('user_id', $user->ID, self_admin_url('user-edit.php')); |
|
| 1528 | 1528 | |
| 1529 | 1529 | /** |
| 1530 | 1530 | * Filters the user edit link. |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | * @param string $link The edit link. |
| 1535 | 1535 | * @param int $user_id User ID. |
| 1536 | 1536 | */ |
| 1537 | - return apply_filters( 'get_edit_user_link', $link, $user->ID ); |
|
| 1537 | + return apply_filters('get_edit_user_link', $link, $user->ID); |
|
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | // Navigation links |
@@ -1550,8 +1550,8 @@ discard block |
||
| 1550 | 1550 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no |
| 1551 | 1551 | * corresponding post exists. |
| 1552 | 1552 | */ |
| 1553 | -function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1554 | - return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1553 | +function get_previous_post($in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1554 | + return get_adjacent_post($in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | 1557 | /** |
@@ -1565,8 +1565,8 @@ discard block |
||
| 1565 | 1565 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no |
| 1566 | 1566 | * corresponding post exists. |
| 1567 | 1567 | */ |
| 1568 | -function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1569 | - return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1568 | +function get_next_post($in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1569 | + return get_adjacent_post($in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | /** |
@@ -1585,10 +1585,10 @@ discard block |
||
| 1585 | 1585 | * @return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no |
| 1586 | 1586 | * corresponding post exists. |
| 1587 | 1587 | */ |
| 1588 | -function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1588 | +function get_adjacent_post($in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1589 | 1589 | global $wpdb; |
| 1590 | 1590 | |
| 1591 | - if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) |
|
| 1591 | + if (( ! $post = get_post()) || ! taxonomy_exists($taxonomy)) |
|
| 1592 | 1592 | return null; |
| 1593 | 1593 | |
| 1594 | 1594 | $current_post_date = $post->post_date; |
@@ -1597,35 +1597,35 @@ discard block |
||
| 1597 | 1597 | $where = ''; |
| 1598 | 1598 | $adjacent = $previous ? 'previous' : 'next'; |
| 1599 | 1599 | |
| 1600 | - if ( $in_same_term || ! empty( $excluded_terms ) ) { |
|
| 1601 | - if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { |
|
| 1600 | + if ($in_same_term || ! empty($excluded_terms)) { |
|
| 1601 | + if ( ! empty($excluded_terms) && ! is_array($excluded_terms)) { |
|
| 1602 | 1602 | // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " |
| 1603 | - if ( false !== strpos( $excluded_terms, ' and ' ) ) { |
|
| 1604 | - _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); |
|
| 1605 | - $excluded_terms = explode( ' and ', $excluded_terms ); |
|
| 1603 | + if (false !== strpos($excluded_terms, ' and ')) { |
|
| 1604 | + _deprecated_argument(__FUNCTION__, '3.3.0', sprintf(__('Use commas instead of %s to separate excluded terms.'), "'and'")); |
|
| 1605 | + $excluded_terms = explode(' and ', $excluded_terms); |
|
| 1606 | 1606 | } else { |
| 1607 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1607 | + $excluded_terms = explode(',', $excluded_terms); |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | - $excluded_terms = array_map( 'intval', $excluded_terms ); |
|
| 1610 | + $excluded_terms = array_map('intval', $excluded_terms); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | - if ( $in_same_term ) { |
|
| 1613 | + if ($in_same_term) { |
|
| 1614 | 1614 | $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; |
| 1615 | - $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); |
|
| 1615 | + $where .= $wpdb->prepare("AND tt.taxonomy = %s", $taxonomy); |
|
| 1616 | 1616 | |
| 1617 | - if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
|
| 1617 | + if ( ! is_object_in_taxonomy($post->post_type, $taxonomy)) |
|
| 1618 | 1618 | return ''; |
| 1619 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1619 | + $term_array = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); |
|
| 1620 | 1620 | |
| 1621 | 1621 | // Remove any exclusions from the term array to include. |
| 1622 | - $term_array = array_diff( $term_array, (array) $excluded_terms ); |
|
| 1623 | - $term_array = array_map( 'intval', $term_array ); |
|
| 1622 | + $term_array = array_diff($term_array, (array) $excluded_terms); |
|
| 1623 | + $term_array = array_map('intval', $term_array); |
|
| 1624 | 1624 | |
| 1625 | - if ( ! $term_array || is_wp_error( $term_array ) ) |
|
| 1625 | + if ( ! $term_array || is_wp_error($term_array)) |
|
| 1626 | 1626 | return ''; |
| 1627 | 1627 | |
| 1628 | - $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; |
|
| 1628 | + $where .= " AND tt.term_id IN (".implode(',', $term_array).")"; |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | /** |
@@ -1638,21 +1638,21 @@ discard block |
||
| 1638 | 1638 | * |
| 1639 | 1639 | * @param string $excluded_terms Array of excluded term IDs. |
| 1640 | 1640 | */ |
| 1641 | - $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); |
|
| 1641 | + $excluded_terms = apply_filters("get_{$adjacent}_post_excluded_terms", $excluded_terms); |
|
| 1642 | 1642 | |
| 1643 | - if ( ! empty( $excluded_terms ) ) { |
|
| 1644 | - $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', array_map( 'intval', $excluded_terms ) ) . ') )'; |
|
| 1643 | + if ( ! empty($excluded_terms)) { |
|
| 1644 | + $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (".implode(',', array_map('intval', $excluded_terms)).') )'; |
|
| 1645 | 1645 | } |
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | // 'post_status' clause depends on the current user. |
| 1649 | - if ( is_user_logged_in() ) { |
|
| 1649 | + if (is_user_logged_in()) { |
|
| 1650 | 1650 | $user_id = get_current_user_id(); |
| 1651 | 1651 | |
| 1652 | - $post_type_object = get_post_type_object( $post->post_type ); |
|
| 1653 | - if ( empty( $post_type_object ) ) { |
|
| 1652 | + $post_type_object = get_post_type_object($post->post_type); |
|
| 1653 | + if (empty($post_type_object)) { |
|
| 1654 | 1654 | $post_type_cap = $post->post_type; |
| 1655 | - $read_private_cap = 'read_private_' . $post_type_cap . 's'; |
|
| 1655 | + $read_private_cap = 'read_private_'.$post_type_cap.'s'; |
|
| 1656 | 1656 | } else { |
| 1657 | 1657 | $read_private_cap = $post_type_object->cap->read_private_posts; |
| 1658 | 1658 | } |
@@ -1661,13 +1661,13 @@ discard block |
||
| 1661 | 1661 | * Results should include private posts belonging to the current user, or private posts where the |
| 1662 | 1662 | * current user has the 'read_private_posts' cap. |
| 1663 | 1663 | */ |
| 1664 | - $private_states = get_post_stati( array( 'private' => true ) ); |
|
| 1664 | + $private_states = get_post_stati(array('private' => true)); |
|
| 1665 | 1665 | $where .= " AND ( p.post_status = 'publish'"; |
| 1666 | - foreach ( (array) $private_states as $state ) { |
|
| 1667 | - if ( current_user_can( $read_private_cap ) ) { |
|
| 1668 | - $where .= $wpdb->prepare( " OR p.post_status = %s", $state ); |
|
| 1666 | + foreach ((array) $private_states as $state) { |
|
| 1667 | + if (current_user_can($read_private_cap)) { |
|
| 1668 | + $where .= $wpdb->prepare(" OR p.post_status = %s", $state); |
|
| 1669 | 1669 | } else { |
| 1670 | - $where .= $wpdb->prepare( " OR (p.post_author = %d AND p.post_status = %s)", $user_id, $state ); |
|
| 1670 | + $where .= $wpdb->prepare(" OR (p.post_author = %d AND p.post_status = %s)", $user_id, $state); |
|
| 1671 | 1671 | } |
| 1672 | 1672 | } |
| 1673 | 1673 | $where .= " )"; |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true. |
| 1694 | 1694 | * @param WP_Post $post WP_Post object. |
| 1695 | 1695 | */ |
| 1696 | - $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post ); |
|
| 1696 | + $join = apply_filters("get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post); |
|
| 1697 | 1697 | |
| 1698 | 1698 | /** |
| 1699 | 1699 | * Filters the WHERE clause in the SQL for an adjacent post query. |
@@ -1710,7 +1710,7 @@ discard block |
||
| 1710 | 1710 | * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true. |
| 1711 | 1711 | * @param WP_Post $post WP_Post object. |
| 1712 | 1712 | */ |
| 1713 | - $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post ); |
|
| 1713 | + $where = apply_filters("get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type), $in_same_term, $excluded_terms, $taxonomy, $post); |
|
| 1714 | 1714 | |
| 1715 | 1715 | /** |
| 1716 | 1716 | * Filters the ORDER BY clause in the SQL for an adjacent post query. |
@@ -1724,25 +1724,25 @@ discard block |
||
| 1724 | 1724 | * @param string $order_by The `ORDER BY` clause in the SQL. |
| 1725 | 1725 | * @param WP_Post $post WP_Post object. |
| 1726 | 1726 | */ |
| 1727 | - $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post ); |
|
| 1727 | + $sort = apply_filters("get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post); |
|
| 1728 | 1728 | |
| 1729 | 1729 | $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; |
| 1730 | - $query_key = 'adjacent_post_' . md5( $query ); |
|
| 1731 | - $result = wp_cache_get( $query_key, 'counts' ); |
|
| 1732 | - if ( false !== $result ) { |
|
| 1733 | - if ( $result ) |
|
| 1734 | - $result = get_post( $result ); |
|
| 1730 | + $query_key = 'adjacent_post_'.md5($query); |
|
| 1731 | + $result = wp_cache_get($query_key, 'counts'); |
|
| 1732 | + if (false !== $result) { |
|
| 1733 | + if ($result) |
|
| 1734 | + $result = get_post($result); |
|
| 1735 | 1735 | return $result; |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | - $result = $wpdb->get_var( $query ); |
|
| 1739 | - if ( null === $result ) |
|
| 1738 | + $result = $wpdb->get_var($query); |
|
| 1739 | + if (null === $result) |
|
| 1740 | 1740 | $result = ''; |
| 1741 | 1741 | |
| 1742 | - wp_cache_set( $query_key, $result, 'counts' ); |
|
| 1742 | + wp_cache_set($query_key, $result, 'counts'); |
|
| 1743 | 1743 | |
| 1744 | - if ( $result ) |
|
| 1745 | - $result = get_post( $result ); |
|
| 1744 | + if ($result) |
|
| 1745 | + $result = get_post($result); |
|
| 1746 | 1746 | |
| 1747 | 1747 | return $result; |
| 1748 | 1748 | } |
@@ -1761,28 +1761,28 @@ discard block |
||
| 1761 | 1761 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1762 | 1762 | * @return string|void The adjacent post relational link URL. |
| 1763 | 1763 | */ |
| 1764 | -function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 1765 | - if ( $previous && is_attachment() && $post = get_post() ) |
|
| 1766 | - $post = get_post( $post->post_parent ); |
|
| 1764 | +function get_adjacent_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 1765 | + if ($previous && is_attachment() && $post = get_post()) |
|
| 1766 | + $post = get_post($post->post_parent); |
|
| 1767 | 1767 | else |
| 1768 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1768 | + $post = get_adjacent_post($in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 1769 | 1769 | |
| 1770 | - if ( empty( $post ) ) |
|
| 1770 | + if (empty($post)) |
|
| 1771 | 1771 | return; |
| 1772 | 1772 | |
| 1773 | - $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) ); |
|
| 1773 | + $post_title = the_title_attribute(array('echo' => false, 'post' => $post)); |
|
| 1774 | 1774 | |
| 1775 | - if ( empty( $post_title ) ) |
|
| 1776 | - $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1775 | + if (empty($post_title)) |
|
| 1776 | + $post_title = $previous ? __('Previous Post') : __('Next Post'); |
|
| 1777 | 1777 | |
| 1778 | - $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
|
| 1778 | + $date = mysql2date(get_option('date_format'), $post->post_date); |
|
| 1779 | 1779 | |
| 1780 | - $title = str_replace( '%title', $post_title, $title ); |
|
| 1781 | - $title = str_replace( '%date', $date, $title ); |
|
| 1780 | + $title = str_replace('%title', $post_title, $title); |
|
| 1781 | + $title = str_replace('%date', $date, $title); |
|
| 1782 | 1782 | |
| 1783 | 1783 | $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; |
| 1784 | - $link .= esc_attr( $title ); |
|
| 1785 | - $link .= "' href='" . get_permalink( $post ) . "' />\n"; |
|
| 1784 | + $link .= esc_attr($title); |
|
| 1785 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
| 1786 | 1786 | |
| 1787 | 1787 | $adjacent = $previous ? 'previous' : 'next'; |
| 1788 | 1788 | |
@@ -1796,7 +1796,7 @@ discard block |
||
| 1796 | 1796 | * |
| 1797 | 1797 | * @param string $link The relational link. |
| 1798 | 1798 | */ |
| 1799 | - return apply_filters( "{$adjacent}_post_rel_link", $link ); |
|
| 1799 | + return apply_filters("{$adjacent}_post_rel_link", $link); |
|
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | /** |
@@ -1809,9 +1809,9 @@ discard block |
||
| 1809 | 1809 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. |
| 1810 | 1810 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1811 | 1811 | */ |
| 1812 | -function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1813 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1814 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1812 | +function adjacent_posts_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1813 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1814 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | /** |
@@ -1825,7 +1825,7 @@ discard block |
||
| 1825 | 1825 | * @see adjacent_posts_rel_link() |
| 1826 | 1826 | */ |
| 1827 | 1827 | function adjacent_posts_rel_link_wp_head() { |
| 1828 | - if ( ! is_single() || is_attachment() ) { |
|
| 1828 | + if ( ! is_single() || is_attachment()) { |
|
| 1829 | 1829 | return; |
| 1830 | 1830 | } |
| 1831 | 1831 | adjacent_posts_rel_link(); |
@@ -1843,8 +1843,8 @@ discard block |
||
| 1843 | 1843 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. |
| 1844 | 1844 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1845 | 1845 | */ |
| 1846 | -function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1847 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1846 | +function next_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1847 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | /** |
@@ -1859,8 +1859,8 @@ discard block |
||
| 1859 | 1859 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default true. |
| 1860 | 1860 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1861 | 1861 | */ |
| 1862 | -function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1863 | - echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1862 | +function prev_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1863 | + echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | 1866 | /** |
@@ -1879,9 +1879,9 @@ discard block |
||
| 1879 | 1879 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1880 | 1880 | * @return null|array Array containing the boundary post object if successful, null otherwise. |
| 1881 | 1881 | */ |
| 1882 | -function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { |
|
| 1882 | +function get_boundary_post($in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category') { |
|
| 1883 | 1883 | $post = get_post(); |
| 1884 | - if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) |
|
| 1884 | + if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists($taxonomy)) |
|
| 1885 | 1885 | return null; |
| 1886 | 1886 | |
| 1887 | 1887 | $query_args = array( |
@@ -1893,34 +1893,34 @@ discard block |
||
| 1893 | 1893 | |
| 1894 | 1894 | $term_array = array(); |
| 1895 | 1895 | |
| 1896 | - if ( ! is_array( $excluded_terms ) ) { |
|
| 1897 | - if ( ! empty( $excluded_terms ) ) |
|
| 1898 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1896 | + if ( ! is_array($excluded_terms)) { |
|
| 1897 | + if ( ! empty($excluded_terms)) |
|
| 1898 | + $excluded_terms = explode(',', $excluded_terms); |
|
| 1899 | 1899 | else |
| 1900 | 1900 | $excluded_terms = array(); |
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | - if ( $in_same_term || ! empty( $excluded_terms ) ) { |
|
| 1904 | - if ( $in_same_term ) |
|
| 1905 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1903 | + if ($in_same_term || ! empty($excluded_terms)) { |
|
| 1904 | + if ($in_same_term) |
|
| 1905 | + $term_array = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); |
|
| 1906 | 1906 | |
| 1907 | - if ( ! empty( $excluded_terms ) ) { |
|
| 1908 | - $excluded_terms = array_map( 'intval', $excluded_terms ); |
|
| 1909 | - $excluded_terms = array_diff( $excluded_terms, $term_array ); |
|
| 1907 | + if ( ! empty($excluded_terms)) { |
|
| 1908 | + $excluded_terms = array_map('intval', $excluded_terms); |
|
| 1909 | + $excluded_terms = array_diff($excluded_terms, $term_array); |
|
| 1910 | 1910 | |
| 1911 | 1911 | $inverse_terms = array(); |
| 1912 | - foreach ( $excluded_terms as $excluded_term ) |
|
| 1912 | + foreach ($excluded_terms as $excluded_term) |
|
| 1913 | 1913 | $inverse_terms[] = $excluded_term * -1; |
| 1914 | 1914 | $excluded_terms = $inverse_terms; |
| 1915 | 1915 | } |
| 1916 | 1916 | |
| 1917 | - $query_args[ 'tax_query' ] = array( array( |
|
| 1917 | + $query_args['tax_query'] = array(array( |
|
| 1918 | 1918 | 'taxonomy' => $taxonomy, |
| 1919 | - 'terms' => array_merge( $term_array, $excluded_terms ) |
|
| 1920 | - ) ); |
|
| 1919 | + 'terms' => array_merge($term_array, $excluded_terms) |
|
| 1920 | + )); |
|
| 1921 | 1921 | } |
| 1922 | 1922 | |
| 1923 | - return get_posts( $query_args ); |
|
| 1923 | + return get_posts($query_args); |
|
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | 1926 | /** |
@@ -1935,8 +1935,8 @@ discard block |
||
| 1935 | 1935 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1936 | 1936 | * @return string The link URL of the previous post in relation to the current post. |
| 1937 | 1937 | */ |
| 1938 | -function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1939 | - return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy ); |
|
| 1938 | +function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1939 | + return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | 1942 | /** |
@@ -1952,8 +1952,8 @@ discard block |
||
| 1952 | 1952 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. |
| 1953 | 1953 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1954 | 1954 | */ |
| 1955 | -function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1956 | - echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); |
|
| 1955 | +function previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1956 | + echo get_previous_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy); |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
@@ -1968,8 +1968,8 @@ discard block |
||
| 1968 | 1968 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1969 | 1969 | * @return string The link URL of the next post in relation to the current post. |
| 1970 | 1970 | */ |
| 1971 | -function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1972 | - return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy ); |
|
| 1971 | +function get_next_post_link($format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1972 | + return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, false, $taxonomy); |
|
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | 1975 | /** |
@@ -1984,8 +1984,8 @@ discard block |
||
| 1984 | 1984 | * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty. |
| 1985 | 1985 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 1986 | 1986 | */ |
| 1987 | -function next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { |
|
| 1988 | - echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy ); |
|
| 1987 | +function next_post_link($format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category') { |
|
| 1988 | + echo get_next_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy); |
|
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | 1991 | /** |
@@ -2003,32 +2003,32 @@ discard block |
||
| 2003 | 2003 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 2004 | 2004 | * @return string The link URL of the previous or next post in relation to the current post. |
| 2005 | 2005 | */ |
| 2006 | -function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 2007 | - if ( $previous && is_attachment() ) |
|
| 2008 | - $post = get_post( get_post()->post_parent ); |
|
| 2006 | +function get_adjacent_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 2007 | + if ($previous && is_attachment()) |
|
| 2008 | + $post = get_post(get_post()->post_parent); |
|
| 2009 | 2009 | else |
| 2010 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 2010 | + $post = get_adjacent_post($in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 2011 | 2011 | |
| 2012 | - if ( ! $post ) { |
|
| 2012 | + if ( ! $post) { |
|
| 2013 | 2013 | $output = ''; |
| 2014 | 2014 | } else { |
| 2015 | 2015 | $title = $post->post_title; |
| 2016 | 2016 | |
| 2017 | - if ( empty( $post->post_title ) ) |
|
| 2018 | - $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 2017 | + if (empty($post->post_title)) |
|
| 2018 | + $title = $previous ? __('Previous Post') : __('Next Post'); |
|
| 2019 | 2019 | |
| 2020 | 2020 | /** This filter is documented in wp-includes/post-template.php */ |
| 2021 | - $title = apply_filters( 'the_title', $title, $post->ID ); |
|
| 2021 | + $title = apply_filters('the_title', $title, $post->ID); |
|
| 2022 | 2022 | |
| 2023 | - $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
|
| 2023 | + $date = mysql2date(get_option('date_format'), $post->post_date); |
|
| 2024 | 2024 | $rel = $previous ? 'prev' : 'next'; |
| 2025 | 2025 | |
| 2026 | - $string = '<a href="' . get_permalink( $post ) . '" rel="'.$rel.'">'; |
|
| 2027 | - $inlink = str_replace( '%title', $title, $link ); |
|
| 2028 | - $inlink = str_replace( '%date', $date, $inlink ); |
|
| 2029 | - $inlink = $string . $inlink . '</a>'; |
|
| 2026 | + $string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">'; |
|
| 2027 | + $inlink = str_replace('%title', $title, $link); |
|
| 2028 | + $inlink = str_replace('%date', $date, $inlink); |
|
| 2029 | + $inlink = $string.$inlink.'</a>'; |
|
| 2030 | 2030 | |
| 2031 | - $output = str_replace( '%link', $inlink, $format ); |
|
| 2031 | + $output = str_replace('%link', $inlink, $format); |
|
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | 2034 | $adjacent = $previous ? 'previous' : 'next'; |
@@ -2048,7 +2048,7 @@ discard block |
||
| 2048 | 2048 | * @param WP_Post $post The adjacent post. |
| 2049 | 2049 | * @param string $adjacent Whether the post is previous or next. |
| 2050 | 2050 | */ |
| 2051 | - return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent ); |
|
| 2051 | + return apply_filters("{$adjacent}_post_link", $output, $format, $link, $post, $adjacent); |
|
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | /** |
@@ -2065,8 +2065,8 @@ discard block |
||
| 2065 | 2065 | * @param bool $previous Optional. Whether to display link to previous or next post. Default true. |
| 2066 | 2066 | * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. |
| 2067 | 2067 | */ |
| 2068 | -function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
|
| 2069 | - echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 2068 | +function adjacent_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category') { |
|
| 2069 | + echo get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy); |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | /** |
@@ -2081,53 +2081,53 @@ discard block |
||
| 2081 | 2081 | * Otherwise, prepares the URL with esc_url_raw(). |
| 2082 | 2082 | * @return string The link URL for the given page number. |
| 2083 | 2083 | */ |
| 2084 | -function get_pagenum_link($pagenum = 1, $escape = true ) { |
|
| 2084 | +function get_pagenum_link($pagenum = 1, $escape = true) { |
|
| 2085 | 2085 | global $wp_rewrite; |
| 2086 | 2086 | |
| 2087 | 2087 | $pagenum = (int) $pagenum; |
| 2088 | 2088 | |
| 2089 | - $request = remove_query_arg( 'paged' ); |
|
| 2089 | + $request = remove_query_arg('paged'); |
|
| 2090 | 2090 | |
| 2091 | 2091 | $home_root = parse_url(home_url()); |
| 2092 | - $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : ''; |
|
| 2093 | - $home_root = preg_quote( $home_root, '|' ); |
|
| 2092 | + $home_root = (isset($home_root['path'])) ? $home_root['path'] : ''; |
|
| 2093 | + $home_root = preg_quote($home_root, '|'); |
|
| 2094 | 2094 | |
| 2095 | - $request = preg_replace('|^'. $home_root . '|i', '', $request); |
|
| 2095 | + $request = preg_replace('|^'.$home_root.'|i', '', $request); |
|
| 2096 | 2096 | $request = preg_replace('|^/+|', '', $request); |
| 2097 | 2097 | |
| 2098 | - if ( !$wp_rewrite->using_permalinks() || is_admin() ) { |
|
| 2099 | - $base = trailingslashit( get_bloginfo( 'url' ) ); |
|
| 2098 | + if ( ! $wp_rewrite->using_permalinks() || is_admin()) { |
|
| 2099 | + $base = trailingslashit(get_bloginfo('url')); |
|
| 2100 | 2100 | |
| 2101 | - if ( $pagenum > 1 ) { |
|
| 2102 | - $result = add_query_arg( 'paged', $pagenum, $base . $request ); |
|
| 2101 | + if ($pagenum > 1) { |
|
| 2102 | + $result = add_query_arg('paged', $pagenum, $base.$request); |
|
| 2103 | 2103 | } else { |
| 2104 | - $result = $base . $request; |
|
| 2104 | + $result = $base.$request; |
|
| 2105 | 2105 | } |
| 2106 | 2106 | } else { |
| 2107 | 2107 | $qs_regex = '|\?.*?$|'; |
| 2108 | - preg_match( $qs_regex, $request, $qs_match ); |
|
| 2108 | + preg_match($qs_regex, $request, $qs_match); |
|
| 2109 | 2109 | |
| 2110 | - if ( !empty( $qs_match[0] ) ) { |
|
| 2110 | + if ( ! empty($qs_match[0])) { |
|
| 2111 | 2111 | $query_string = $qs_match[0]; |
| 2112 | - $request = preg_replace( $qs_regex, '', $request ); |
|
| 2112 | + $request = preg_replace($qs_regex, '', $request); |
|
| 2113 | 2113 | } else { |
| 2114 | 2114 | $query_string = ''; |
| 2115 | 2115 | } |
| 2116 | 2116 | |
| 2117 | - $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request); |
|
| 2118 | - $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request); |
|
| 2117 | + $request = preg_replace("|$wp_rewrite->pagination_base/\d+/?$|", '', $request); |
|
| 2118 | + $request = preg_replace('|^'.preg_quote($wp_rewrite->index, '|').'|i', '', $request); |
|
| 2119 | 2119 | $request = ltrim($request, '/'); |
| 2120 | 2120 | |
| 2121 | - $base = trailingslashit( get_bloginfo( 'url' ) ); |
|
| 2121 | + $base = trailingslashit(get_bloginfo('url')); |
|
| 2122 | 2122 | |
| 2123 | - if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) |
|
| 2124 | - $base .= $wp_rewrite->index . '/'; |
|
| 2123 | + if ($wp_rewrite->using_index_permalinks() && ($pagenum > 1 || '' != $request)) |
|
| 2124 | + $base .= $wp_rewrite->index.'/'; |
|
| 2125 | 2125 | |
| 2126 | - if ( $pagenum > 1 ) { |
|
| 2127 | - $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' ); |
|
| 2126 | + if ($pagenum > 1) { |
|
| 2127 | + $request = (( ! empty($request)) ? trailingslashit($request) : $request).user_trailingslashit($wp_rewrite->pagination_base."/".$pagenum, 'paged'); |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $result = $base . $request . $query_string; |
|
| 2130 | + $result = $base.$request.$query_string; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | /** |
@@ -2137,12 +2137,12 @@ discard block |
||
| 2137 | 2137 | * |
| 2138 | 2138 | * @param string $result The page number link. |
| 2139 | 2139 | */ |
| 2140 | - $result = apply_filters( 'get_pagenum_link', $result ); |
|
| 2140 | + $result = apply_filters('get_pagenum_link', $result); |
|
| 2141 | 2141 | |
| 2142 | - if ( $escape ) |
|
| 2143 | - return esc_url( $result ); |
|
| 2142 | + if ($escape) |
|
| 2143 | + return esc_url($result); |
|
| 2144 | 2144 | else |
| 2145 | - return esc_url_raw( $result ); |
|
| 2145 | + return esc_url_raw($result); |
|
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | 2148 | /** |
@@ -2160,11 +2160,11 @@ discard block |
||
| 2160 | 2160 | function get_next_posts_page_link($max_page = 0) { |
| 2161 | 2161 | global $paged; |
| 2162 | 2162 | |
| 2163 | - if ( !is_single() ) { |
|
| 2164 | - if ( !$paged ) |
|
| 2163 | + if ( ! is_single()) { |
|
| 2164 | + if ( ! $paged) |
|
| 2165 | 2165 | $paged = 1; |
| 2166 | 2166 | $nextpage = intval($paged) + 1; |
| 2167 | - if ( !$max_page || $max_page >= $nextpage ) |
|
| 2167 | + if ( ! $max_page || $max_page >= $nextpage) |
|
| 2168 | 2168 | return get_pagenum_link($nextpage); |
| 2169 | 2169 | } |
| 2170 | 2170 | } |
@@ -2178,10 +2178,10 @@ discard block |
||
| 2178 | 2178 | * @param bool $echo Optional. Whether to echo the link. Default true. |
| 2179 | 2179 | * @return string|void The link URL for next posts page if `$echo = false`. |
| 2180 | 2180 | */ |
| 2181 | -function next_posts( $max_page = 0, $echo = true ) { |
|
| 2182 | - $output = esc_url( get_next_posts_page_link( $max_page ) ); |
|
| 2181 | +function next_posts($max_page = 0, $echo = true) { |
|
| 2182 | + $output = esc_url(get_next_posts_page_link($max_page)); |
|
| 2183 | 2183 | |
| 2184 | - if ( $echo ) |
|
| 2184 | + if ($echo) |
|
| 2185 | 2185 | echo $output; |
| 2186 | 2186 | else |
| 2187 | 2187 | return $output; |
@@ -2199,21 +2199,21 @@ discard block |
||
| 2199 | 2199 | * @param int $max_page Optional. Max pages. Default 0. |
| 2200 | 2200 | * @return string|void HTML-formatted next posts page link. |
| 2201 | 2201 | */ |
| 2202 | -function get_next_posts_link( $label = null, $max_page = 0 ) { |
|
| 2202 | +function get_next_posts_link($label = null, $max_page = 0) { |
|
| 2203 | 2203 | global $paged, $wp_query; |
| 2204 | 2204 | |
| 2205 | - if ( !$max_page ) |
|
| 2205 | + if ( ! $max_page) |
|
| 2206 | 2206 | $max_page = $wp_query->max_num_pages; |
| 2207 | 2207 | |
| 2208 | - if ( !$paged ) |
|
| 2208 | + if ( ! $paged) |
|
| 2209 | 2209 | $paged = 1; |
| 2210 | 2210 | |
| 2211 | 2211 | $nextpage = intval($paged) + 1; |
| 2212 | 2212 | |
| 2213 | - if ( null === $label ) |
|
| 2214 | - $label = __( 'Next Page »' ); |
|
| 2213 | + if (null === $label) |
|
| 2214 | + $label = __('Next Page »'); |
|
| 2215 | 2215 | |
| 2216 | - if ( !is_single() && ( $nextpage <= $max_page ) ) { |
|
| 2216 | + if ( ! is_single() && ($nextpage <= $max_page)) { |
|
| 2217 | 2217 | /** |
| 2218 | 2218 | * Filters the anchor tag attributes for the next posts page link. |
| 2219 | 2219 | * |
@@ -2221,9 +2221,9 @@ discard block |
||
| 2221 | 2221 | * |
| 2222 | 2222 | * @param string $attributes Attributes for the anchor tag. |
| 2223 | 2223 | */ |
| 2224 | - $attr = apply_filters( 'next_posts_link_attributes', '' ); |
|
| 2224 | + $attr = apply_filters('next_posts_link_attributes', ''); |
|
| 2225 | 2225 | |
| 2226 | - return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>'; |
|
| 2226 | + return '<a href="'.next_posts($max_page, false)."\" $attr>".preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2227 | 2227 | } |
| 2228 | 2228 | } |
| 2229 | 2229 | |
@@ -2235,8 +2235,8 @@ discard block |
||
| 2235 | 2235 | * @param string $label Content for link text. |
| 2236 | 2236 | * @param int $max_page Optional. Max pages. Default 0. |
| 2237 | 2237 | */ |
| 2238 | -function next_posts_link( $label = null, $max_page = 0 ) { |
|
| 2239 | - echo get_next_posts_link( $label, $max_page ); |
|
| 2238 | +function next_posts_link($label = null, $max_page = 0) { |
|
| 2239 | + echo get_next_posts_link($label, $max_page); |
|
| 2240 | 2240 | } |
| 2241 | 2241 | |
| 2242 | 2242 | /** |
@@ -2255,9 +2255,9 @@ discard block |
||
| 2255 | 2255 | function get_previous_posts_page_link() { |
| 2256 | 2256 | global $paged; |
| 2257 | 2257 | |
| 2258 | - if ( !is_single() ) { |
|
| 2258 | + if ( ! is_single()) { |
|
| 2259 | 2259 | $nextpage = intval($paged) - 1; |
| 2260 | - if ( $nextpage < 1 ) |
|
| 2260 | + if ($nextpage < 1) |
|
| 2261 | 2261 | $nextpage = 1; |
| 2262 | 2262 | return get_pagenum_link($nextpage); |
| 2263 | 2263 | } |
@@ -2271,10 +2271,10 @@ discard block |
||
| 2271 | 2271 | * @param bool $echo Optional. Whether to echo the link. Default true. |
| 2272 | 2272 | * @return string|void The previous posts page link if `$echo = false`. |
| 2273 | 2273 | */ |
| 2274 | -function previous_posts( $echo = true ) { |
|
| 2275 | - $output = esc_url( get_previous_posts_page_link() ); |
|
| 2274 | +function previous_posts($echo = true) { |
|
| 2275 | + $output = esc_url(get_previous_posts_page_link()); |
|
| 2276 | 2276 | |
| 2277 | - if ( $echo ) |
|
| 2277 | + if ($echo) |
|
| 2278 | 2278 | echo $output; |
| 2279 | 2279 | else |
| 2280 | 2280 | return $output; |
@@ -2290,13 +2290,13 @@ discard block |
||
| 2290 | 2290 | * @param string $label Optional. Previous page link text. |
| 2291 | 2291 | * @return string|void HTML-formatted previous page link. |
| 2292 | 2292 | */ |
| 2293 | -function get_previous_posts_link( $label = null ) { |
|
| 2293 | +function get_previous_posts_link($label = null) { |
|
| 2294 | 2294 | global $paged; |
| 2295 | 2295 | |
| 2296 | - if ( null === $label ) |
|
| 2297 | - $label = __( '« Previous Page' ); |
|
| 2296 | + if (null === $label) |
|
| 2297 | + $label = __('« Previous Page'); |
|
| 2298 | 2298 | |
| 2299 | - if ( !is_single() && $paged > 1 ) { |
|
| 2299 | + if ( ! is_single() && $paged > 1) { |
|
| 2300 | 2300 | /** |
| 2301 | 2301 | * Filters the anchor tag attributes for the previous posts page link. |
| 2302 | 2302 | * |
@@ -2304,8 +2304,8 @@ discard block |
||
| 2304 | 2304 | * |
| 2305 | 2305 | * @param string $attributes Attributes for the anchor tag. |
| 2306 | 2306 | */ |
| 2307 | - $attr = apply_filters( 'previous_posts_link_attributes', '' ); |
|
| 2308 | - return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'</a>'; |
|
| 2307 | + $attr = apply_filters('previous_posts_link_attributes', ''); |
|
| 2308 | + return '<a href="'.previous_posts(false)."\" $attr>".preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2309 | 2309 | } |
| 2310 | 2310 | } |
| 2311 | 2311 | |
@@ -2316,8 +2316,8 @@ discard block |
||
| 2316 | 2316 | * |
| 2317 | 2317 | * @param string $label Optional. Previous page link text. |
| 2318 | 2318 | */ |
| 2319 | -function previous_posts_link( $label = null ) { |
|
| 2320 | - echo get_previous_posts_link( $label ); |
|
| 2319 | +function previous_posts_link($label = null) { |
|
| 2320 | + echo get_previous_posts_link($label); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2338,18 +2338,18 @@ discard block |
||
| 2338 | 2338 | * } |
| 2339 | 2339 | * @return string The posts link navigation. |
| 2340 | 2340 | */ |
| 2341 | -function get_posts_nav_link( $args = array() ) { |
|
| 2341 | +function get_posts_nav_link($args = array()) { |
|
| 2342 | 2342 | global $wp_query; |
| 2343 | 2343 | |
| 2344 | 2344 | $return = ''; |
| 2345 | 2345 | |
| 2346 | - if ( !is_singular() ) { |
|
| 2346 | + if ( ! is_singular()) { |
|
| 2347 | 2347 | $defaults = array( |
| 2348 | 2348 | 'sep' => ' — ', |
| 2349 | 2349 | 'prelabel' => __('« Previous Page'), |
| 2350 | 2350 | 'nxtlabel' => __('Next Page »'), |
| 2351 | 2351 | ); |
| 2352 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2352 | + $args = wp_parse_args($args, $defaults); |
|
| 2353 | 2353 | |
| 2354 | 2354 | $max_num_pages = $wp_query->max_num_pages; |
| 2355 | 2355 | $paged = get_query_var('paged'); |
@@ -2359,7 +2359,7 @@ discard block |
||
| 2359 | 2359 | $args['sep'] = ''; |
| 2360 | 2360 | } |
| 2361 | 2361 | |
| 2362 | - if ( $max_num_pages > 1 ) { |
|
| 2362 | + if ($max_num_pages > 1) { |
|
| 2363 | 2363 | $return = get_previous_posts_link($args['prelabel']); |
| 2364 | 2364 | $return .= preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $args['sep']); |
| 2365 | 2365 | $return .= get_next_posts_link($args['nxtlabel']); |
@@ -2378,8 +2378,8 @@ discard block |
||
| 2378 | 2378 | * @param string $prelabel Optional. Label for previous pages. Default empty. |
| 2379 | 2379 | * @param string $nxtlabel Optional Label for next pages. Default empty. |
| 2380 | 2380 | */ |
| 2381 | -function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { |
|
| 2382 | - $args = array_filter( compact('sep', 'prelabel', 'nxtlabel') ); |
|
| 2381 | +function posts_nav_link($sep = '', $prelabel = '', $nxtlabel = '') { |
|
| 2382 | + $args = array_filter(compact('sep', 'prelabel', 'nxtlabel')); |
|
| 2383 | 2383 | echo get_posts_nav_link($args); |
| 2384 | 2384 | } |
| 2385 | 2385 | |
@@ -2401,15 +2401,15 @@ discard block |
||
| 2401 | 2401 | * } |
| 2402 | 2402 | * @return string Markup for post links. |
| 2403 | 2403 | */ |
| 2404 | -function get_the_post_navigation( $args = array() ) { |
|
| 2405 | - $args = wp_parse_args( $args, array( |
|
| 2404 | +function get_the_post_navigation($args = array()) { |
|
| 2405 | + $args = wp_parse_args($args, array( |
|
| 2406 | 2406 | 'prev_text' => '%title', |
| 2407 | 2407 | 'next_text' => '%title', |
| 2408 | 2408 | 'in_same_term' => false, |
| 2409 | 2409 | 'excluded_terms' => '', |
| 2410 | 2410 | 'taxonomy' => 'category', |
| 2411 | - 'screen_reader_text' => __( 'Post navigation' ), |
|
| 2412 | - ) ); |
|
| 2411 | + 'screen_reader_text' => __('Post navigation'), |
|
| 2412 | + )); |
|
| 2413 | 2413 | |
| 2414 | 2414 | $navigation = ''; |
| 2415 | 2415 | |
@@ -2430,8 +2430,8 @@ discard block |
||
| 2430 | 2430 | ); |
| 2431 | 2431 | |
| 2432 | 2432 | // Only add markup if there's somewhere to navigate to. |
| 2433 | - if ( $previous || $next ) { |
|
| 2434 | - $navigation = _navigation_markup( $previous . $next, 'post-navigation', $args['screen_reader_text'] ); |
|
| 2433 | + if ($previous || $next) { |
|
| 2434 | + $navigation = _navigation_markup($previous.$next, 'post-navigation', $args['screen_reader_text']); |
|
| 2435 | 2435 | } |
| 2436 | 2436 | |
| 2437 | 2437 | return $navigation; |
@@ -2445,8 +2445,8 @@ discard block |
||
| 2445 | 2445 | * @param array $args Optional. See get_the_post_navigation() for available arguments. |
| 2446 | 2446 | * Default empty array. |
| 2447 | 2447 | */ |
| 2448 | -function the_post_navigation( $args = array() ) { |
|
| 2449 | - echo get_the_post_navigation( $args ); |
|
| 2448 | +function the_post_navigation($args = array()) { |
|
| 2449 | + echo get_the_post_navigation($args); |
|
| 2450 | 2450 | } |
| 2451 | 2451 | |
| 2452 | 2452 | /** |
@@ -2468,29 +2468,29 @@ discard block |
||
| 2468 | 2468 | * } |
| 2469 | 2469 | * @return string Markup for posts links. |
| 2470 | 2470 | */ |
| 2471 | -function get_the_posts_navigation( $args = array() ) { |
|
| 2471 | +function get_the_posts_navigation($args = array()) { |
|
| 2472 | 2472 | $navigation = ''; |
| 2473 | 2473 | |
| 2474 | 2474 | // Don't print empty markup if there's only one page. |
| 2475 | - if ( $GLOBALS['wp_query']->max_num_pages > 1 ) { |
|
| 2476 | - $args = wp_parse_args( $args, array( |
|
| 2477 | - 'prev_text' => __( 'Older posts' ), |
|
| 2478 | - 'next_text' => __( 'Newer posts' ), |
|
| 2479 | - 'screen_reader_text' => __( 'Posts navigation' ), |
|
| 2480 | - ) ); |
|
| 2481 | - |
|
| 2482 | - $next_link = get_previous_posts_link( $args['next_text'] ); |
|
| 2483 | - $prev_link = get_next_posts_link( $args['prev_text'] ); |
|
| 2484 | - |
|
| 2485 | - if ( $prev_link ) { |
|
| 2486 | - $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; |
|
| 2475 | + if ($GLOBALS['wp_query']->max_num_pages > 1) { |
|
| 2476 | + $args = wp_parse_args($args, array( |
|
| 2477 | + 'prev_text' => __('Older posts'), |
|
| 2478 | + 'next_text' => __('Newer posts'), |
|
| 2479 | + 'screen_reader_text' => __('Posts navigation'), |
|
| 2480 | + )); |
|
| 2481 | + |
|
| 2482 | + $next_link = get_previous_posts_link($args['next_text']); |
|
| 2483 | + $prev_link = get_next_posts_link($args['prev_text']); |
|
| 2484 | + |
|
| 2485 | + if ($prev_link) { |
|
| 2486 | + $navigation .= '<div class="nav-previous">'.$prev_link.'</div>'; |
|
| 2487 | 2487 | } |
| 2488 | 2488 | |
| 2489 | - if ( $next_link ) { |
|
| 2490 | - $navigation .= '<div class="nav-next">' . $next_link . '</div>'; |
|
| 2489 | + if ($next_link) { |
|
| 2490 | + $navigation .= '<div class="nav-next">'.$next_link.'</div>'; |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | - $navigation = _navigation_markup( $navigation, 'posts-navigation', $args['screen_reader_text'] ); |
|
| 2493 | + $navigation = _navigation_markup($navigation, 'posts-navigation', $args['screen_reader_text']); |
|
| 2494 | 2494 | } |
| 2495 | 2495 | |
| 2496 | 2496 | return $navigation; |
@@ -2504,8 +2504,8 @@ discard block |
||
| 2504 | 2504 | * @param array $args Optional. See get_the_posts_navigation() for available arguments. |
| 2505 | 2505 | * Default empty array. |
| 2506 | 2506 | */ |
| 2507 | -function the_posts_navigation( $args = array() ) { |
|
| 2508 | - echo get_the_posts_navigation( $args ); |
|
| 2507 | +function the_posts_navigation($args = array()) { |
|
| 2508 | + echo get_the_posts_navigation($args); |
|
| 2509 | 2509 | } |
| 2510 | 2510 | |
| 2511 | 2511 | /** |
@@ -2521,28 +2521,28 @@ discard block |
||
| 2521 | 2521 | * } |
| 2522 | 2522 | * @return string Markup for pagination links. |
| 2523 | 2523 | */ |
| 2524 | -function get_the_posts_pagination( $args = array() ) { |
|
| 2524 | +function get_the_posts_pagination($args = array()) { |
|
| 2525 | 2525 | $navigation = ''; |
| 2526 | 2526 | |
| 2527 | 2527 | // Don't print empty markup if there's only one page. |
| 2528 | - if ( $GLOBALS['wp_query']->max_num_pages > 1 ) { |
|
| 2529 | - $args = wp_parse_args( $args, array( |
|
| 2528 | + if ($GLOBALS['wp_query']->max_num_pages > 1) { |
|
| 2529 | + $args = wp_parse_args($args, array( |
|
| 2530 | 2530 | 'mid_size' => 1, |
| 2531 | - 'prev_text' => _x( 'Previous', 'previous post' ), |
|
| 2532 | - 'next_text' => _x( 'Next', 'next post' ), |
|
| 2533 | - 'screen_reader_text' => __( 'Posts navigation' ), |
|
| 2534 | - ) ); |
|
| 2531 | + 'prev_text' => _x('Previous', 'previous post'), |
|
| 2532 | + 'next_text' => _x('Next', 'next post'), |
|
| 2533 | + 'screen_reader_text' => __('Posts navigation'), |
|
| 2534 | + )); |
|
| 2535 | 2535 | |
| 2536 | 2536 | // Make sure we get a string back. Plain is the next best thing. |
| 2537 | - if ( isset( $args['type'] ) && 'array' == $args['type'] ) { |
|
| 2537 | + if (isset($args['type']) && 'array' == $args['type']) { |
|
| 2538 | 2538 | $args['type'] = 'plain'; |
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | 2541 | // Set up paginated links. |
| 2542 | - $links = paginate_links( $args ); |
|
| 2542 | + $links = paginate_links($args); |
|
| 2543 | 2543 | |
| 2544 | - if ( $links ) { |
|
| 2545 | - $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] ); |
|
| 2544 | + if ($links) { |
|
| 2545 | + $navigation = _navigation_markup($links, 'pagination', $args['screen_reader_text']); |
|
| 2546 | 2546 | } |
| 2547 | 2547 | } |
| 2548 | 2548 | |
@@ -2557,8 +2557,8 @@ discard block |
||
| 2557 | 2557 | * @param array $args Optional. See get_the_posts_pagination() for available arguments. |
| 2558 | 2558 | * Default empty array. |
| 2559 | 2559 | */ |
| 2560 | -function the_posts_pagination( $args = array() ) { |
|
| 2561 | - echo get_the_posts_pagination( $args ); |
|
| 2560 | +function the_posts_pagination($args = array()) { |
|
| 2561 | + echo get_the_posts_pagination($args); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | 2564 | /** |
@@ -2572,9 +2572,9 @@ discard block |
||
| 2572 | 2572 | * @param string $screen_reader_text Optional. Screen reader text for nav element. Default: 'Posts navigation'. |
| 2573 | 2573 | * @return string Navigation template tag. |
| 2574 | 2574 | */ |
| 2575 | -function _navigation_markup( $links, $class = 'posts-navigation', $screen_reader_text = '' ) { |
|
| 2576 | - if ( empty( $screen_reader_text ) ) { |
|
| 2577 | - $screen_reader_text = __( 'Posts navigation' ); |
|
| 2575 | +function _navigation_markup($links, $class = 'posts-navigation', $screen_reader_text = '') { |
|
| 2576 | + if (empty($screen_reader_text)) { |
|
| 2577 | + $screen_reader_text = __('Posts navigation'); |
|
| 2578 | 2578 | } |
| 2579 | 2579 | |
| 2580 | 2580 | $template = ' |
@@ -2601,9 +2601,9 @@ discard block |
||
| 2601 | 2601 | * @param string $class The class passed by the calling function. |
| 2602 | 2602 | * @return string Navigation template. |
| 2603 | 2603 | */ |
| 2604 | - $template = apply_filters( 'navigation_markup_template', $template, $class ); |
|
| 2604 | + $template = apply_filters('navigation_markup_template', $template, $class); |
|
| 2605 | 2605 | |
| 2606 | - return sprintf( $template, sanitize_html_class( $class ), esc_html( $screen_reader_text ), $links ); |
|
| 2606 | + return sprintf($template, sanitize_html_class($class), esc_html($screen_reader_text), $links); |
|
| 2607 | 2607 | } |
| 2608 | 2608 | |
| 2609 | 2609 | /** |
@@ -2617,25 +2617,25 @@ discard block |
||
| 2617 | 2617 | * @param int $max_page Optional. The maximum number of comment pages. Default 0. |
| 2618 | 2618 | * @return string The comments page number link URL. |
| 2619 | 2619 | */ |
| 2620 | -function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { |
|
| 2620 | +function get_comments_pagenum_link($pagenum = 1, $max_page = 0) { |
|
| 2621 | 2621 | global $wp_rewrite; |
| 2622 | 2622 | |
| 2623 | 2623 | $pagenum = (int) $pagenum; |
| 2624 | 2624 | |
| 2625 | 2625 | $result = get_permalink(); |
| 2626 | 2626 | |
| 2627 | - if ( 'newest' == get_option('default_comments_page') ) { |
|
| 2628 | - if ( $pagenum != $max_page ) { |
|
| 2629 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2630 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2627 | + if ('newest' == get_option('default_comments_page')) { |
|
| 2628 | + if ($pagenum != $max_page) { |
|
| 2629 | + if ($wp_rewrite->using_permalinks()) |
|
| 2630 | + $result = user_trailingslashit(trailingslashit($result).$wp_rewrite->comments_pagination_base.'-'.$pagenum, 'commentpaged'); |
|
| 2631 | 2631 | else |
| 2632 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2632 | + $result = add_query_arg('cpage', $pagenum, $result); |
|
| 2633 | 2633 | } |
| 2634 | - } elseif ( $pagenum > 1 ) { |
|
| 2635 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2636 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2634 | + } elseif ($pagenum > 1) { |
|
| 2635 | + if ($wp_rewrite->using_permalinks()) |
|
| 2636 | + $result = user_trailingslashit(trailingslashit($result).$wp_rewrite->comments_pagination_base.'-'.$pagenum, 'commentpaged'); |
|
| 2637 | 2637 | else |
| 2638 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2638 | + $result = add_query_arg('cpage', $pagenum, $result); |
|
| 2639 | 2639 | } |
| 2640 | 2640 | |
| 2641 | 2641 | $result .= '#comments'; |
@@ -2647,7 +2647,7 @@ discard block |
||
| 2647 | 2647 | * |
| 2648 | 2648 | * @param string $result The comments page number link. |
| 2649 | 2649 | */ |
| 2650 | - return apply_filters( 'get_comments_pagenum_link', $result ); |
|
| 2650 | + return apply_filters('get_comments_pagenum_link', $result); |
|
| 2651 | 2651 | } |
| 2652 | 2652 | |
| 2653 | 2653 | /** |
@@ -2661,30 +2661,30 @@ discard block |
||
| 2661 | 2661 | * @param int $max_page Optional. Max page. Default 0. |
| 2662 | 2662 | * @return string|void HTML-formatted link for the next page of comments. |
| 2663 | 2663 | */ |
| 2664 | -function get_next_comments_link( $label = '', $max_page = 0 ) { |
|
| 2664 | +function get_next_comments_link($label = '', $max_page = 0) { |
|
| 2665 | 2665 | global $wp_query; |
| 2666 | 2666 | |
| 2667 | - if ( ! is_singular() ) |
|
| 2667 | + if ( ! is_singular()) |
|
| 2668 | 2668 | return; |
| 2669 | 2669 | |
| 2670 | 2670 | $page = get_query_var('cpage'); |
| 2671 | 2671 | |
| 2672 | - if ( ! $page ) { |
|
| 2672 | + if ( ! $page) { |
|
| 2673 | 2673 | $page = 1; |
| 2674 | 2674 | } |
| 2675 | 2675 | |
| 2676 | 2676 | $nextpage = intval($page) + 1; |
| 2677 | 2677 | |
| 2678 | - if ( empty($max_page) ) |
|
| 2678 | + if (empty($max_page)) |
|
| 2679 | 2679 | $max_page = $wp_query->max_num_comment_pages; |
| 2680 | 2680 | |
| 2681 | - if ( empty($max_page) ) |
|
| 2681 | + if (empty($max_page)) |
|
| 2682 | 2682 | $max_page = get_comment_pages_count(); |
| 2683 | 2683 | |
| 2684 | - if ( $nextpage > $max_page ) |
|
| 2684 | + if ($nextpage > $max_page) |
|
| 2685 | 2685 | return; |
| 2686 | 2686 | |
| 2687 | - if ( empty($label) ) |
|
| 2687 | + if (empty($label)) |
|
| 2688 | 2688 | $label = __('Newer Comments »'); |
| 2689 | 2689 | |
| 2690 | 2690 | /** |
@@ -2694,7 +2694,7 @@ discard block |
||
| 2694 | 2694 | * |
| 2695 | 2695 | * @param string $attributes Attributes for the anchor tag. |
| 2696 | 2696 | */ |
| 2697 | - return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; |
|
| 2697 | + return '<a href="'.esc_url(get_comments_pagenum_link($nextpage, $max_page)).'" '.apply_filters('next_comments_link_attributes', '').'>'.preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2698 | 2698 | } |
| 2699 | 2699 | |
| 2700 | 2700 | /** |
@@ -2705,8 +2705,8 @@ discard block |
||
| 2705 | 2705 | * @param string $label Optional. Label for link text. Default empty. |
| 2706 | 2706 | * @param int $max_page Optional. Max page. Default 0. |
| 2707 | 2707 | */ |
| 2708 | -function next_comments_link( $label = '', $max_page = 0 ) { |
|
| 2709 | - echo get_next_comments_link( $label, $max_page ); |
|
| 2708 | +function next_comments_link($label = '', $max_page = 0) { |
|
| 2709 | + echo get_next_comments_link($label, $max_page); |
|
| 2710 | 2710 | } |
| 2711 | 2711 | |
| 2712 | 2712 | /** |
@@ -2717,18 +2717,18 @@ discard block |
||
| 2717 | 2717 | * @param string $label Optional. Label for comments link text. Default empty. |
| 2718 | 2718 | * @return string|void HTML-formatted link for the previous page of comments. |
| 2719 | 2719 | */ |
| 2720 | -function get_previous_comments_link( $label = '' ) { |
|
| 2721 | - if ( ! is_singular() ) |
|
| 2720 | +function get_previous_comments_link($label = '') { |
|
| 2721 | + if ( ! is_singular()) |
|
| 2722 | 2722 | return; |
| 2723 | 2723 | |
| 2724 | 2724 | $page = get_query_var('cpage'); |
| 2725 | 2725 | |
| 2726 | - if ( intval($page) <= 1 ) |
|
| 2726 | + if (intval($page) <= 1) |
|
| 2727 | 2727 | return; |
| 2728 | 2728 | |
| 2729 | 2729 | $prevpage = intval($page) - 1; |
| 2730 | 2730 | |
| 2731 | - if ( empty($label) ) |
|
| 2731 | + if (empty($label)) |
|
| 2732 | 2732 | $label = __('« Older Comments'); |
| 2733 | 2733 | |
| 2734 | 2734 | /** |
@@ -2738,7 +2738,7 @@ discard block |
||
| 2738 | 2738 | * |
| 2739 | 2739 | * @param string $attributes Attributes for the anchor tag. |
| 2740 | 2740 | */ |
| 2741 | - return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; |
|
| 2741 | + return '<a href="'.esc_url(get_comments_pagenum_link($prevpage)).'" '.apply_filters('previous_comments_link_attributes', '').'>'.preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label).'</a>'; |
|
| 2742 | 2742 | } |
| 2743 | 2743 | |
| 2744 | 2744 | /** |
@@ -2748,8 +2748,8 @@ discard block |
||
| 2748 | 2748 | * |
| 2749 | 2749 | * @param string $label Optional. Label for comments link text. Default empty. |
| 2750 | 2750 | */ |
| 2751 | -function previous_comments_link( $label = '' ) { |
|
| 2752 | - echo get_previous_comments_link( $label ); |
|
| 2751 | +function previous_comments_link($label = '') { |
|
| 2752 | + echo get_previous_comments_link($label); |
|
| 2753 | 2753 | } |
| 2754 | 2754 | |
| 2755 | 2755 | /** |
@@ -2763,31 +2763,31 @@ discard block |
||
| 2763 | 2763 | * @param string|array $args Optional args. See paginate_links(). Default empty array. |
| 2764 | 2764 | * @return string|void Markup for pagination links. |
| 2765 | 2765 | */ |
| 2766 | -function paginate_comments_links( $args = array() ) { |
|
| 2766 | +function paginate_comments_links($args = array()) { |
|
| 2767 | 2767 | global $wp_rewrite; |
| 2768 | 2768 | |
| 2769 | - if ( ! is_singular() ) |
|
| 2769 | + if ( ! is_singular()) |
|
| 2770 | 2770 | return; |
| 2771 | 2771 | |
| 2772 | 2772 | $page = get_query_var('cpage'); |
| 2773 | - if ( !$page ) |
|
| 2773 | + if ( ! $page) |
|
| 2774 | 2774 | $page = 1; |
| 2775 | 2775 | $max_page = get_comment_pages_count(); |
| 2776 | 2776 | $defaults = array( |
| 2777 | - 'base' => add_query_arg( 'cpage', '%#%' ), |
|
| 2777 | + 'base' => add_query_arg('cpage', '%#%'), |
|
| 2778 | 2778 | 'format' => '', |
| 2779 | 2779 | 'total' => $max_page, |
| 2780 | 2780 | 'current' => $page, |
| 2781 | 2781 | 'echo' => true, |
| 2782 | 2782 | 'add_fragment' => '#comments' |
| 2783 | 2783 | ); |
| 2784 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2785 | - $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2784 | + if ($wp_rewrite->using_permalinks()) |
|
| 2785 | + $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()).$wp_rewrite->comments_pagination_base.'-%#%', 'commentpaged'); |
|
| 2786 | 2786 | |
| 2787 | - $args = wp_parse_args( $args, $defaults ); |
|
| 2788 | - $page_links = paginate_links( $args ); |
|
| 2787 | + $args = wp_parse_args($args, $defaults); |
|
| 2788 | + $page_links = paginate_links($args); |
|
| 2789 | 2789 | |
| 2790 | - if ( $args['echo'] ) |
|
| 2790 | + if ($args['echo']) |
|
| 2791 | 2791 | echo $page_links; |
| 2792 | 2792 | else |
| 2793 | 2793 | return $page_links; |
@@ -2809,29 +2809,29 @@ discard block |
||
| 2809 | 2809 | * } |
| 2810 | 2810 | * @return string Markup for comments links. |
| 2811 | 2811 | */ |
| 2812 | -function get_the_comments_navigation( $args = array() ) { |
|
| 2812 | +function get_the_comments_navigation($args = array()) { |
|
| 2813 | 2813 | $navigation = ''; |
| 2814 | 2814 | |
| 2815 | 2815 | // Are there comments to navigate through? |
| 2816 | - if ( get_comment_pages_count() > 1 ) { |
|
| 2817 | - $args = wp_parse_args( $args, array( |
|
| 2818 | - 'prev_text' => __( 'Older comments' ), |
|
| 2819 | - 'next_text' => __( 'Newer comments' ), |
|
| 2820 | - 'screen_reader_text' => __( 'Comments navigation' ), |
|
| 2821 | - ) ); |
|
| 2822 | - |
|
| 2823 | - $prev_link = get_previous_comments_link( $args['prev_text'] ); |
|
| 2824 | - $next_link = get_next_comments_link( $args['next_text'] ); |
|
| 2825 | - |
|
| 2826 | - if ( $prev_link ) { |
|
| 2827 | - $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; |
|
| 2816 | + if (get_comment_pages_count() > 1) { |
|
| 2817 | + $args = wp_parse_args($args, array( |
|
| 2818 | + 'prev_text' => __('Older comments'), |
|
| 2819 | + 'next_text' => __('Newer comments'), |
|
| 2820 | + 'screen_reader_text' => __('Comments navigation'), |
|
| 2821 | + )); |
|
| 2822 | + |
|
| 2823 | + $prev_link = get_previous_comments_link($args['prev_text']); |
|
| 2824 | + $next_link = get_next_comments_link($args['next_text']); |
|
| 2825 | + |
|
| 2826 | + if ($prev_link) { |
|
| 2827 | + $navigation .= '<div class="nav-previous">'.$prev_link.'</div>'; |
|
| 2828 | 2828 | } |
| 2829 | 2829 | |
| 2830 | - if ( $next_link ) { |
|
| 2831 | - $navigation .= '<div class="nav-next">' . $next_link . '</div>'; |
|
| 2830 | + if ($next_link) { |
|
| 2831 | + $navigation .= '<div class="nav-next">'.$next_link.'</div>'; |
|
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | - $navigation = _navigation_markup( $navigation, 'comment-navigation', $args['screen_reader_text'] ); |
|
| 2834 | + $navigation = _navigation_markup($navigation, 'comment-navigation', $args['screen_reader_text']); |
|
| 2835 | 2835 | } |
| 2836 | 2836 | |
| 2837 | 2837 | return $navigation; |
@@ -2844,8 +2844,8 @@ discard block |
||
| 2844 | 2844 | * |
| 2845 | 2845 | * @param array $args See get_the_comments_navigation() for available arguments. Default empty array. |
| 2846 | 2846 | */ |
| 2847 | -function the_comments_navigation( $args = array() ) { |
|
| 2848 | - echo get_the_comments_navigation( $args ); |
|
| 2847 | +function the_comments_navigation($args = array()) { |
|
| 2848 | + echo get_the_comments_navigation($args); |
|
| 2849 | 2849 | } |
| 2850 | 2850 | |
| 2851 | 2851 | /** |
@@ -2862,20 +2862,20 @@ discard block |
||
| 2862 | 2862 | * } |
| 2863 | 2863 | * @return string Markup for pagination links. |
| 2864 | 2864 | */ |
| 2865 | -function get_the_comments_pagination( $args = array() ) { |
|
| 2865 | +function get_the_comments_pagination($args = array()) { |
|
| 2866 | 2866 | $navigation = ''; |
| 2867 | - $args = wp_parse_args( $args, array( |
|
| 2868 | - 'screen_reader_text' => __( 'Comments navigation' ), |
|
| 2869 | - ) ); |
|
| 2867 | + $args = wp_parse_args($args, array( |
|
| 2868 | + 'screen_reader_text' => __('Comments navigation'), |
|
| 2869 | + )); |
|
| 2870 | 2870 | $args['echo'] = false; |
| 2871 | 2871 | |
| 2872 | 2872 | // Make sure we get plain links, so we get a string we can work with. |
| 2873 | 2873 | $args['type'] = 'plain'; |
| 2874 | 2874 | |
| 2875 | - $links = paginate_comments_links( $args ); |
|
| 2875 | + $links = paginate_comments_links($args); |
|
| 2876 | 2876 | |
| 2877 | - if ( $links ) { |
|
| 2878 | - $navigation = _navigation_markup( $links, 'comments-pagination', $args['screen_reader_text'] ); |
|
| 2877 | + if ($links) { |
|
| 2878 | + $navigation = _navigation_markup($links, 'comments-pagination', $args['screen_reader_text']); |
|
| 2879 | 2879 | } |
| 2880 | 2880 | |
| 2881 | 2881 | return $navigation; |
@@ -2888,8 +2888,8 @@ discard block |
||
| 2888 | 2888 | * |
| 2889 | 2889 | * @param array $args See get_the_comments_pagination() for available arguments. Default empty array. |
| 2890 | 2890 | */ |
| 2891 | -function the_comments_pagination( $args = array() ) { |
|
| 2892 | - echo get_the_comments_pagination( $args ); |
|
| 2891 | +function the_comments_pagination($args = array()) { |
|
| 2892 | + echo get_the_comments_pagination($args); |
|
| 2893 | 2893 | } |
| 2894 | 2894 | |
| 2895 | 2895 | /** |
@@ -2909,11 +2909,11 @@ discard block |
||
| 2909 | 2909 | function get_shortcut_link() { |
| 2910 | 2910 | global $is_IE, $wp_version; |
| 2911 | 2911 | |
| 2912 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' ); |
|
| 2912 | + include_once(ABSPATH.'wp-admin/includes/class-wp-press-this.php'); |
|
| 2913 | 2913 | $bookmarklet_version = $GLOBALS['wp_press_this']->version; |
| 2914 | 2914 | $link = ''; |
| 2915 | 2915 | |
| 2916 | - if ( $is_IE ) { |
|
| 2916 | + if ($is_IE) { |
|
| 2917 | 2917 | /* |
| 2918 | 2918 | * Return the old/shorter bookmarklet code for MSIE 8 and lower, |
| 2919 | 2919 | * since they only support a max length of ~2000 characters for |
@@ -2923,27 +2923,27 @@ discard block |
||
| 2923 | 2923 | */ |
| 2924 | 2924 | $ua = $_SERVER['HTTP_USER_AGENT']; |
| 2925 | 2925 | |
| 2926 | - if ( ! empty( $ua ) && preg_match( '/\bMSIE (\d)/', $ua, $matches ) && (int) $matches[1] <= 8 ) { |
|
| 2927 | - $url = wp_json_encode( admin_url( 'press-this.php' ) ); |
|
| 2926 | + if ( ! empty($ua) && preg_match('/\bMSIE (\d)/', $ua, $matches) && (int) $matches[1] <= 8) { |
|
| 2927 | + $url = wp_json_encode(admin_url('press-this.php')); |
|
| 2928 | 2928 | |
| 2929 | - $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' . |
|
| 2930 | - 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' . |
|
| 2931 | - 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' . |
|
| 2932 | - 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' . |
|
| 2929 | + $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,'. |
|
| 2930 | + 's=(e?e():(k)?k():(x?x.createRange().text:0)),f='.$url.',l=d.location,e=encodeURIComponent,'. |
|
| 2931 | + 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v='.$bookmarklet_version.'";'. |
|
| 2932 | + 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};'. |
|
| 2933 | 2933 | 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)'; |
| 2934 | 2934 | } |
| 2935 | 2935 | } |
| 2936 | 2936 | |
| 2937 | - if ( empty( $link ) ) { |
|
| 2938 | - $src = @file_get_contents( ABSPATH . 'wp-admin/js/bookmarklet.min.js' ); |
|
| 2937 | + if (empty($link)) { |
|
| 2938 | + $src = @file_get_contents(ABSPATH.'wp-admin/js/bookmarklet.min.js'); |
|
| 2939 | 2939 | |
| 2940 | - if ( $src ) { |
|
| 2941 | - $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version ); |
|
| 2942 | - $link = 'javascript:' . str_replace( 'window.pt_url', $url, $src ); |
|
| 2940 | + if ($src) { |
|
| 2941 | + $url = wp_json_encode(admin_url('press-this.php').'?v='.$bookmarklet_version); |
|
| 2942 | + $link = 'javascript:'.str_replace('window.pt_url', $url, $src); |
|
| 2943 | 2943 | } |
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | - $link = str_replace( array( "\r", "\n", "\t" ), '', $link ); |
|
| 2946 | + $link = str_replace(array("\r", "\n", "\t"), '', $link); |
|
| 2947 | 2947 | |
| 2948 | 2948 | /** |
| 2949 | 2949 | * Filters the Press This bookmarklet link. |
@@ -2952,7 +2952,7 @@ discard block |
||
| 2952 | 2952 | * |
| 2953 | 2953 | * @param string $link The Press This bookmarklet link. |
| 2954 | 2954 | */ |
| 2955 | - return apply_filters( 'shortcut_link', $link ); |
|
| 2955 | + return apply_filters('shortcut_link', $link); |
|
| 2956 | 2956 | } |
| 2957 | 2957 | |
| 2958 | 2958 | /** |
@@ -2969,8 +2969,8 @@ discard block |
||
| 2969 | 2969 | * 'http', 'https', 'relative', 'rest', or null. Default null. |
| 2970 | 2970 | * @return string Home URL link with optional path appended. |
| 2971 | 2971 | */ |
| 2972 | -function home_url( $path = '', $scheme = null ) { |
|
| 2973 | - return get_home_url( null, $path, $scheme ); |
|
| 2972 | +function home_url($path = '', $scheme = null) { |
|
| 2973 | + return get_home_url(null, $path, $scheme); |
|
| 2974 | 2974 | } |
| 2975 | 2975 | |
| 2976 | 2976 | /** |
@@ -2990,30 +2990,30 @@ discard block |
||
| 2990 | 2990 | * 'http', 'https', 'relative', 'rest', or null. Default null. |
| 2991 | 2991 | * @return string Home URL link with optional path appended. |
| 2992 | 2992 | */ |
| 2993 | -function get_home_url( $blog_id = null, $path = '', $scheme = null ) { |
|
| 2993 | +function get_home_url($blog_id = null, $path = '', $scheme = null) { |
|
| 2994 | 2994 | global $pagenow; |
| 2995 | 2995 | |
| 2996 | 2996 | $orig_scheme = $scheme; |
| 2997 | 2997 | |
| 2998 | - if ( empty( $blog_id ) || !is_multisite() ) { |
|
| 2999 | - $url = get_option( 'home' ); |
|
| 2998 | + if (empty($blog_id) || ! is_multisite()) { |
|
| 2999 | + $url = get_option('home'); |
|
| 3000 | 3000 | } else { |
| 3001 | - switch_to_blog( $blog_id ); |
|
| 3002 | - $url = get_option( 'home' ); |
|
| 3001 | + switch_to_blog($blog_id); |
|
| 3002 | + $url = get_option('home'); |
|
| 3003 | 3003 | restore_current_blog(); |
| 3004 | 3004 | } |
| 3005 | 3005 | |
| 3006 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
|
| 3007 | - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) |
|
| 3006 | + if ( ! in_array($scheme, array('http', 'https', 'relative'))) { |
|
| 3007 | + if (is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow) |
|
| 3008 | 3008 | $scheme = 'https'; |
| 3009 | 3009 | else |
| 3010 | - $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 3010 | + $scheme = parse_url($url, PHP_URL_SCHEME); |
|
| 3011 | 3011 | } |
| 3012 | 3012 | |
| 3013 | - $url = set_url_scheme( $url, $scheme ); |
|
| 3013 | + $url = set_url_scheme($url, $scheme); |
|
| 3014 | 3014 | |
| 3015 | - if ( $path && is_string( $path ) ) |
|
| 3016 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 3015 | + if ($path && is_string($path)) |
|
| 3016 | + $url .= '/'.ltrim($path, '/'); |
|
| 3017 | 3017 | |
| 3018 | 3018 | /** |
| 3019 | 3019 | * Filters the home URL. |
@@ -3026,7 +3026,7 @@ discard block |
||
| 3026 | 3026 | * 'relative', 'rest', or null. |
| 3027 | 3027 | * @param int|null $blog_id Site ID, or null for the current site. |
| 3028 | 3028 | */ |
| 3029 | - return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); |
|
| 3029 | + return apply_filters('home_url', $url, $path, $orig_scheme, $blog_id); |
|
| 3030 | 3030 | } |
| 3031 | 3031 | |
| 3032 | 3032 | /** |
@@ -3043,8 +3043,8 @@ discard block |
||
| 3043 | 3043 | * @param string $scheme Optional. Scheme to give the site URL context. See set_url_scheme(). |
| 3044 | 3044 | * @return string Site URL link with optional path appended. |
| 3045 | 3045 | */ |
| 3046 | -function site_url( $path = '', $scheme = null ) { |
|
| 3047 | - return get_site_url( null, $path, $scheme ); |
|
| 3046 | +function site_url($path = '', $scheme = null) { |
|
| 3047 | + return get_site_url(null, $path, $scheme); |
|
| 3048 | 3048 | } |
| 3049 | 3049 | |
| 3050 | 3050 | /** |
@@ -3064,19 +3064,19 @@ discard block |
||
| 3064 | 3064 | * 'relative'. Default null. |
| 3065 | 3065 | * @return string Site URL link with optional path appended. |
| 3066 | 3066 | */ |
| 3067 | -function get_site_url( $blog_id = null, $path = '', $scheme = null ) { |
|
| 3068 | - if ( empty( $blog_id ) || !is_multisite() ) { |
|
| 3069 | - $url = get_option( 'siteurl' ); |
|
| 3067 | +function get_site_url($blog_id = null, $path = '', $scheme = null) { |
|
| 3068 | + if (empty($blog_id) || ! is_multisite()) { |
|
| 3069 | + $url = get_option('siteurl'); |
|
| 3070 | 3070 | } else { |
| 3071 | - switch_to_blog( $blog_id ); |
|
| 3072 | - $url = get_option( 'siteurl' ); |
|
| 3071 | + switch_to_blog($blog_id); |
|
| 3072 | + $url = get_option('siteurl'); |
|
| 3073 | 3073 | restore_current_blog(); |
| 3074 | 3074 | } |
| 3075 | 3075 | |
| 3076 | - $url = set_url_scheme( $url, $scheme ); |
|
| 3076 | + $url = set_url_scheme($url, $scheme); |
|
| 3077 | 3077 | |
| 3078 | - if ( $path && is_string( $path ) ) |
|
| 3079 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 3078 | + if ($path && is_string($path)) |
|
| 3079 | + $url .= '/'.ltrim($path, '/'); |
|
| 3080 | 3080 | |
| 3081 | 3081 | /** |
| 3082 | 3082 | * Filters the site URL. |
@@ -3089,7 +3089,7 @@ discard block |
||
| 3089 | 3089 | * 'login_post', 'admin', 'relative' or null. |
| 3090 | 3090 | * @param int|null $blog_id Site ID, or null for the current site. |
| 3091 | 3091 | */ |
| 3092 | - return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); |
|
| 3092 | + return apply_filters('site_url', $url, $path, $scheme, $blog_id); |
|
| 3093 | 3093 | } |
| 3094 | 3094 | |
| 3095 | 3095 | /** |
@@ -3102,8 +3102,8 @@ discard block |
||
| 3102 | 3102 | * 'http' or 'https' can be passed to force those schemes. |
| 3103 | 3103 | * @return string Admin URL link with optional path appended. |
| 3104 | 3104 | */ |
| 3105 | -function admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3106 | - return get_admin_url( null, $path, $scheme ); |
|
| 3105 | +function admin_url($path = '', $scheme = 'admin') { |
|
| 3106 | + return get_admin_url(null, $path, $scheme); |
|
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | /** |
@@ -3118,11 +3118,11 @@ discard block |
||
| 3118 | 3118 | * force_ssl_admin() and is_ssl(). |
| 3119 | 3119 | * @return string Admin URL link with optional path appended. |
| 3120 | 3120 | */ |
| 3121 | -function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { |
|
| 3121 | +function get_admin_url($blog_id = null, $path = '', $scheme = 'admin') { |
|
| 3122 | 3122 | $url = get_site_url($blog_id, 'wp-admin/', $scheme); |
| 3123 | 3123 | |
| 3124 | - if ( $path && is_string( $path ) ) |
|
| 3125 | - $url .= ltrim( $path, '/' ); |
|
| 3124 | + if ($path && is_string($path)) |
|
| 3125 | + $url .= ltrim($path, '/'); |
|
| 3126 | 3126 | |
| 3127 | 3127 | /** |
| 3128 | 3128 | * Filters the admin area URL. |
@@ -3133,7 +3133,7 @@ discard block |
||
| 3133 | 3133 | * @param string $path Path relative to the admin area URL. Blank string if no path is specified. |
| 3134 | 3134 | * @param int|null $blog_id Site ID, or null for the current site. |
| 3135 | 3135 | */ |
| 3136 | - return apply_filters( 'admin_url', $url, $path, $blog_id ); |
|
| 3136 | + return apply_filters('admin_url', $url, $path, $blog_id); |
|
| 3137 | 3137 | } |
| 3138 | 3138 | |
| 3139 | 3139 | /** |
@@ -3146,10 +3146,10 @@ discard block |
||
| 3146 | 3146 | * 'http', 'https', or 'relative'. Default null. |
| 3147 | 3147 | * @return string Includes URL link with optional path appended. |
| 3148 | 3148 | */ |
| 3149 | -function includes_url( $path = '', $scheme = null ) { |
|
| 3150 | - $url = site_url( '/' . WPINC . '/', $scheme ); |
|
| 3149 | +function includes_url($path = '', $scheme = null) { |
|
| 3150 | + $url = site_url('/'.WPINC.'/', $scheme); |
|
| 3151 | 3151 | |
| 3152 | - if ( $path && is_string( $path ) ) |
|
| 3152 | + if ($path && is_string($path)) |
|
| 3153 | 3153 | $url .= ltrim($path, '/'); |
| 3154 | 3154 | |
| 3155 | 3155 | /** |
@@ -3161,7 +3161,7 @@ discard block |
||
| 3161 | 3161 | * @param string $path Path relative to the URL to the wp-includes directory. Blank string |
| 3162 | 3162 | * if no path is specified. |
| 3163 | 3163 | */ |
| 3164 | - return apply_filters( 'includes_url', $url, $path ); |
|
| 3164 | + return apply_filters('includes_url', $url, $path); |
|
| 3165 | 3165 | } |
| 3166 | 3166 | |
| 3167 | 3167 | /** |
@@ -3172,11 +3172,11 @@ discard block |
||
| 3172 | 3172 | * @param string $path Optional. Path relative to the content URL. Default empty. |
| 3173 | 3173 | * @return string Content URL link with optional path appended. |
| 3174 | 3174 | */ |
| 3175 | -function content_url( $path = '' ) { |
|
| 3176 | - $url = set_url_scheme( WP_CONTENT_URL ); |
|
| 3175 | +function content_url($path = '') { |
|
| 3176 | + $url = set_url_scheme(WP_CONTENT_URL); |
|
| 3177 | 3177 | |
| 3178 | - if ( $path && is_string( $path ) ) |
|
| 3179 | - $url .= '/' . ltrim($path, '/'); |
|
| 3178 | + if ($path && is_string($path)) |
|
| 3179 | + $url .= '/'.ltrim($path, '/'); |
|
| 3180 | 3180 | |
| 3181 | 3181 | /** |
| 3182 | 3182 | * Filters the URL to the content directory. |
@@ -3187,7 +3187,7 @@ discard block |
||
| 3187 | 3187 | * @param string $path Path relative to the URL to the content directory. Blank string |
| 3188 | 3188 | * if no path is specified. |
| 3189 | 3189 | */ |
| 3190 | - return apply_filters( 'content_url', $url, $path); |
|
| 3190 | + return apply_filters('content_url', $url, $path); |
|
| 3191 | 3191 | } |
| 3192 | 3192 | |
| 3193 | 3193 | /** |
@@ -3204,28 +3204,28 @@ discard block |
||
| 3204 | 3204 | * Typically this is done by passing `__FILE__` as the argument. |
| 3205 | 3205 | * @return string Plugins URL link with optional paths appended. |
| 3206 | 3206 | */ |
| 3207 | -function plugins_url( $path = '', $plugin = '' ) { |
|
| 3207 | +function plugins_url($path = '', $plugin = '') { |
|
| 3208 | 3208 | |
| 3209 | - $path = wp_normalize_path( $path ); |
|
| 3210 | - $plugin = wp_normalize_path( $plugin ); |
|
| 3211 | - $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); |
|
| 3209 | + $path = wp_normalize_path($path); |
|
| 3210 | + $plugin = wp_normalize_path($plugin); |
|
| 3211 | + $mu_plugin_dir = wp_normalize_path(WPMU_PLUGIN_DIR); |
|
| 3212 | 3212 | |
| 3213 | - if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) |
|
| 3213 | + if ( ! empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir)) |
|
| 3214 | 3214 | $url = WPMU_PLUGIN_URL; |
| 3215 | 3215 | else |
| 3216 | 3216 | $url = WP_PLUGIN_URL; |
| 3217 | 3217 | |
| 3218 | 3218 | |
| 3219 | - $url = set_url_scheme( $url ); |
|
| 3219 | + $url = set_url_scheme($url); |
|
| 3220 | 3220 | |
| 3221 | - if ( !empty($plugin) && is_string($plugin) ) { |
|
| 3221 | + if ( ! empty($plugin) && is_string($plugin)) { |
|
| 3222 | 3222 | $folder = dirname(plugin_basename($plugin)); |
| 3223 | - if ( '.' != $folder ) |
|
| 3224 | - $url .= '/' . ltrim($folder, '/'); |
|
| 3223 | + if ('.' != $folder) |
|
| 3224 | + $url .= '/'.ltrim($folder, '/'); |
|
| 3225 | 3225 | } |
| 3226 | 3226 | |
| 3227 | - if ( $path && is_string( $path ) ) |
|
| 3228 | - $url .= '/' . ltrim($path, '/'); |
|
| 3227 | + if ($path && is_string($path)) |
|
| 3228 | + $url .= '/'.ltrim($path, '/'); |
|
| 3229 | 3229 | |
| 3230 | 3230 | /** |
| 3231 | 3231 | * Filters the URL to the plugins directory. |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | * @param string $plugin The plugin file path to be relative to. Blank string if no plugin |
| 3239 | 3239 | * is specified. |
| 3240 | 3240 | */ |
| 3241 | - return apply_filters( 'plugins_url', $url, $path, $plugin ); |
|
| 3241 | + return apply_filters('plugins_url', $url, $path, $plugin); |
|
| 3242 | 3242 | } |
| 3243 | 3243 | |
| 3244 | 3244 | /** |
@@ -3257,19 +3257,19 @@ discard block |
||
| 3257 | 3257 | * 'http', 'https', or 'relative'. Default null. |
| 3258 | 3258 | * @return string Site URL link with optional path appended. |
| 3259 | 3259 | */ |
| 3260 | -function network_site_url( $path = '', $scheme = null ) { |
|
| 3261 | - if ( ! is_multisite() ) |
|
| 3260 | +function network_site_url($path = '', $scheme = null) { |
|
| 3261 | + if ( ! is_multisite()) |
|
| 3262 | 3262 | return site_url($path, $scheme); |
| 3263 | 3263 | |
| 3264 | 3264 | $current_site = get_current_site(); |
| 3265 | 3265 | |
| 3266 | - if ( 'relative' == $scheme ) |
|
| 3266 | + if ('relative' == $scheme) |
|
| 3267 | 3267 | $url = $current_site->path; |
| 3268 | 3268 | else |
| 3269 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3269 | + $url = set_url_scheme('http://'.$current_site->domain.$current_site->path, $scheme); |
|
| 3270 | 3270 | |
| 3271 | - if ( $path && is_string( $path ) ) |
|
| 3272 | - $url .= ltrim( $path, '/' ); |
|
| 3271 | + if ($path && is_string($path)) |
|
| 3272 | + $url .= ltrim($path, '/'); |
|
| 3273 | 3273 | |
| 3274 | 3274 | /** |
| 3275 | 3275 | * Filters the network site URL. |
@@ -3282,7 +3282,7 @@ discard block |
||
| 3282 | 3282 | * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https', |
| 3283 | 3283 | * 'relative' or null. |
| 3284 | 3284 | */ |
| 3285 | - return apply_filters( 'network_site_url', $url, $path, $scheme ); |
|
| 3285 | + return apply_filters('network_site_url', $url, $path, $scheme); |
|
| 3286 | 3286 | } |
| 3287 | 3287 | |
| 3288 | 3288 | /** |
@@ -3299,23 +3299,23 @@ discard block |
||
| 3299 | 3299 | * 'http', 'https', or 'relative'. Default null. |
| 3300 | 3300 | * @return string Home URL link with optional path appended. |
| 3301 | 3301 | */ |
| 3302 | -function network_home_url( $path = '', $scheme = null ) { |
|
| 3303 | - if ( ! is_multisite() ) |
|
| 3302 | +function network_home_url($path = '', $scheme = null) { |
|
| 3303 | + if ( ! is_multisite()) |
|
| 3304 | 3304 | return home_url($path, $scheme); |
| 3305 | 3305 | |
| 3306 | 3306 | $current_site = get_current_site(); |
| 3307 | 3307 | $orig_scheme = $scheme; |
| 3308 | 3308 | |
| 3309 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) |
|
| 3309 | + if ( ! in_array($scheme, array('http', 'https', 'relative'))) |
|
| 3310 | 3310 | $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
| 3311 | 3311 | |
| 3312 | - if ( 'relative' == $scheme ) |
|
| 3312 | + if ('relative' == $scheme) |
|
| 3313 | 3313 | $url = $current_site->path; |
| 3314 | 3314 | else |
| 3315 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3315 | + $url = set_url_scheme('http://'.$current_site->domain.$current_site->path, $scheme); |
|
| 3316 | 3316 | |
| 3317 | - if ( $path && is_string( $path ) ) |
|
| 3318 | - $url .= ltrim( $path, '/' ); |
|
| 3317 | + if ($path && is_string($path)) |
|
| 3318 | + $url .= ltrim($path, '/'); |
|
| 3319 | 3319 | |
| 3320 | 3320 | /** |
| 3321 | 3321 | * Filters the network home URL. |
@@ -3328,7 +3328,7 @@ discard block |
||
| 3328 | 3328 | * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https', |
| 3329 | 3329 | * 'relative' or null. |
| 3330 | 3330 | */ |
| 3331 | - return apply_filters( 'network_home_url', $url, $path, $orig_scheme); |
|
| 3331 | + return apply_filters('network_home_url', $url, $path, $orig_scheme); |
|
| 3332 | 3332 | } |
| 3333 | 3333 | |
| 3334 | 3334 | /** |
@@ -3341,13 +3341,13 @@ discard block |
||
| 3341 | 3341 | * and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3342 | 3342 | * @return string Admin URL link with optional path appended. |
| 3343 | 3343 | */ |
| 3344 | -function network_admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3345 | - if ( ! is_multisite() ) |
|
| 3346 | - return admin_url( $path, $scheme ); |
|
| 3344 | +function network_admin_url($path = '', $scheme = 'admin') { |
|
| 3345 | + if ( ! is_multisite()) |
|
| 3346 | + return admin_url($path, $scheme); |
|
| 3347 | 3347 | |
| 3348 | 3348 | $url = network_site_url('wp-admin/network/', $scheme); |
| 3349 | 3349 | |
| 3350 | - if ( $path && is_string( $path ) ) |
|
| 3350 | + if ($path && is_string($path)) |
|
| 3351 | 3351 | $url .= ltrim($path, '/'); |
| 3352 | 3352 | |
| 3353 | 3353 | /** |
@@ -3359,7 +3359,7 @@ discard block |
||
| 3359 | 3359 | * @param string $path Path relative to the network admin URL. Blank string if |
| 3360 | 3360 | * no path is specified. |
| 3361 | 3361 | */ |
| 3362 | - return apply_filters( 'network_admin_url', $url, $path ); |
|
| 3362 | + return apply_filters('network_admin_url', $url, $path); |
|
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | /** |
@@ -3372,10 +3372,10 @@ discard block |
||
| 3372 | 3372 | * and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3373 | 3373 | * @return string Admin URL link with optional path appended. |
| 3374 | 3374 | */ |
| 3375 | -function user_admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3375 | +function user_admin_url($path = '', $scheme = 'admin') { |
|
| 3376 | 3376 | $url = network_site_url('wp-admin/user/', $scheme); |
| 3377 | 3377 | |
| 3378 | - if ( $path && is_string( $path ) ) |
|
| 3378 | + if ($path && is_string($path)) |
|
| 3379 | 3379 | $url .= ltrim($path, '/'); |
| 3380 | 3380 | |
| 3381 | 3381 | /** |
@@ -3387,7 +3387,7 @@ discard block |
||
| 3387 | 3387 | * @param string $path Path relative to the URL. Blank string if |
| 3388 | 3388 | * no path is specified. |
| 3389 | 3389 | */ |
| 3390 | - return apply_filters( 'user_admin_url', $url, $path ); |
|
| 3390 | + return apply_filters('user_admin_url', $url, $path); |
|
| 3391 | 3391 | } |
| 3392 | 3392 | |
| 3393 | 3393 | /** |
@@ -3400,10 +3400,10 @@ discard block |
||
| 3400 | 3400 | * and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3401 | 3401 | * @return string Admin URL link with optional path appended. |
| 3402 | 3402 | */ |
| 3403 | -function self_admin_url( $path = '', $scheme = 'admin' ) { |
|
| 3404 | - if ( is_network_admin() ) |
|
| 3403 | +function self_admin_url($path = '', $scheme = 'admin') { |
|
| 3404 | + if (is_network_admin()) |
|
| 3405 | 3405 | return network_admin_url($path, $scheme); |
| 3406 | - elseif ( is_user_admin() ) |
|
| 3406 | + elseif (is_user_admin()) |
|
| 3407 | 3407 | return user_admin_url($path, $scheme); |
| 3408 | 3408 | else |
| 3409 | 3409 | return admin_url($path, $scheme); |
@@ -3420,27 +3420,27 @@ discard block |
||
| 3420 | 3420 | * 'login_post', 'admin', 'relative', 'rest', 'rpc', or null. Default null. |
| 3421 | 3421 | * @return string $url URL with chosen scheme. |
| 3422 | 3422 | */ |
| 3423 | -function set_url_scheme( $url, $scheme = null ) { |
|
| 3423 | +function set_url_scheme($url, $scheme = null) { |
|
| 3424 | 3424 | $orig_scheme = $scheme; |
| 3425 | 3425 | |
| 3426 | - if ( ! $scheme ) { |
|
| 3426 | + if ( ! $scheme) { |
|
| 3427 | 3427 | $scheme = is_ssl() ? 'https' : 'http'; |
| 3428 | - } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) { |
|
| 3428 | + } elseif ($scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc') { |
|
| 3429 | 3429 | $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; |
| 3430 | - } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) { |
|
| 3430 | + } elseif ($scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative') { |
|
| 3431 | 3431 | $scheme = is_ssl() ? 'https' : 'http'; |
| 3432 | 3432 | } |
| 3433 | 3433 | |
| 3434 | - $url = trim( $url ); |
|
| 3435 | - if ( substr( $url, 0, 2 ) === '//' ) |
|
| 3436 | - $url = 'http:' . $url; |
|
| 3434 | + $url = trim($url); |
|
| 3435 | + if (substr($url, 0, 2) === '//') |
|
| 3436 | + $url = 'http:'.$url; |
|
| 3437 | 3437 | |
| 3438 | - if ( 'relative' == $scheme ) { |
|
| 3439 | - $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); |
|
| 3440 | - if ( $url !== '' && $url[0] === '/' ) |
|
| 3441 | - $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3438 | + if ('relative' == $scheme) { |
|
| 3439 | + $url = ltrim(preg_replace('#^\w+://[^/]*#', '', $url)); |
|
| 3440 | + if ($url !== '' && $url[0] === '/') |
|
| 3441 | + $url = '/'.ltrim($url, "/ \t\n\r\0\x0B"); |
|
| 3442 | 3442 | } else { |
| 3443 | - $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); |
|
| 3443 | + $url = preg_replace('#^\w+://#', $scheme.'://', $url); |
|
| 3444 | 3444 | } |
| 3445 | 3445 | |
| 3446 | 3446 | /** |
@@ -3453,7 +3453,7 @@ discard block |
||
| 3453 | 3453 | * @param string|null $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', |
| 3454 | 3454 | * 'login_post', 'admin', 'relative', 'rest', 'rpc', or null. |
| 3455 | 3455 | */ |
| 3456 | - return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); |
|
| 3456 | + return apply_filters('set_url_scheme', $url, $scheme, $orig_scheme); |
|
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | 3459 | /** |
@@ -3472,24 +3472,24 @@ discard block |
||
| 3472 | 3472 | * and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3473 | 3473 | * @return string Dashboard URL link with optional path appended. |
| 3474 | 3474 | */ |
| 3475 | -function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) { |
|
| 3475 | +function get_dashboard_url($user_id = 0, $path = '', $scheme = 'admin') { |
|
| 3476 | 3476 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3477 | 3477 | |
| 3478 | - $blogs = get_blogs_of_user( $user_id ); |
|
| 3479 | - if ( ! is_super_admin() && empty($blogs) ) { |
|
| 3480 | - $url = user_admin_url( $path, $scheme ); |
|
| 3481 | - } elseif ( ! is_multisite() ) { |
|
| 3482 | - $url = admin_url( $path, $scheme ); |
|
| 3478 | + $blogs = get_blogs_of_user($user_id); |
|
| 3479 | + if ( ! is_super_admin() && empty($blogs)) { |
|
| 3480 | + $url = user_admin_url($path, $scheme); |
|
| 3481 | + } elseif ( ! is_multisite()) { |
|
| 3482 | + $url = admin_url($path, $scheme); |
|
| 3483 | 3483 | } else { |
| 3484 | 3484 | $current_blog = get_current_blog_id(); |
| 3485 | - if ( $current_blog && ( is_super_admin( $user_id ) || in_array( $current_blog, array_keys( $blogs ) ) ) ) { |
|
| 3486 | - $url = admin_url( $path, $scheme ); |
|
| 3485 | + if ($current_blog && (is_super_admin($user_id) || in_array($current_blog, array_keys($blogs)))) { |
|
| 3486 | + $url = admin_url($path, $scheme); |
|
| 3487 | 3487 | } else { |
| 3488 | - $active = get_active_blog_for_user( $user_id ); |
|
| 3489 | - if ( $active ) |
|
| 3490 | - $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3488 | + $active = get_active_blog_for_user($user_id); |
|
| 3489 | + if ($active) |
|
| 3490 | + $url = get_admin_url($active->blog_id, $path, $scheme); |
|
| 3491 | 3491 | else |
| 3492 | - $url = user_admin_url( $path, $scheme ); |
|
| 3492 | + $url = user_admin_url($path, $scheme); |
|
| 3493 | 3493 | } |
| 3494 | 3494 | } |
| 3495 | 3495 | |
@@ -3504,7 +3504,7 @@ discard block |
||
| 3504 | 3504 | * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', |
| 3505 | 3505 | * 'login_post', 'admin', 'relative' or null. |
| 3506 | 3506 | */ |
| 3507 | - return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme); |
|
| 3507 | + return apply_filters('user_dashboard_url', $url, $user_id, $path, $scheme); |
|
| 3508 | 3508 | } |
| 3509 | 3509 | |
| 3510 | 3510 | /** |
@@ -3517,15 +3517,15 @@ discard block |
||
| 3517 | 3517 | * and is_ssl(). 'http' or 'https' can be passed to force those schemes. |
| 3518 | 3518 | * @return string Dashboard URL link with optional path appended. |
| 3519 | 3519 | */ |
| 3520 | -function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) { |
|
| 3520 | +function get_edit_profile_url($user_id = 0, $scheme = 'admin') { |
|
| 3521 | 3521 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3522 | 3522 | |
| 3523 | - if ( is_user_admin() ) |
|
| 3524 | - $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3525 | - elseif ( is_network_admin() ) |
|
| 3526 | - $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3523 | + if (is_user_admin()) |
|
| 3524 | + $url = user_admin_url('profile.php', $scheme); |
|
| 3525 | + elseif (is_network_admin()) |
|
| 3526 | + $url = network_admin_url('profile.php', $scheme); |
|
| 3527 | 3527 | else |
| 3528 | - $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3528 | + $url = get_dashboard_url($user_id, 'profile.php', $scheme); |
|
| 3529 | 3529 | |
| 3530 | 3530 | /** |
| 3531 | 3531 | * Filters the URL for a user's profile editor. |
@@ -3537,7 +3537,7 @@ discard block |
||
| 3537 | 3537 | * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', |
| 3538 | 3538 | * 'login_post', 'admin', 'relative' or null. |
| 3539 | 3539 | */ |
| 3540 | - return apply_filters( 'edit_profile_url', $url, $user_id, $scheme); |
|
| 3540 | + return apply_filters('edit_profile_url', $url, $user_id, $scheme); |
|
| 3541 | 3541 | } |
| 3542 | 3542 | |
| 3543 | 3543 | /** |
@@ -3552,33 +3552,33 @@ discard block |
||
| 3552 | 3552 | * @return string|false The canonical URL, or false if the post does not exist or has not |
| 3553 | 3553 | * been published yet. |
| 3554 | 3554 | */ |
| 3555 | -function wp_get_canonical_url( $post = null ) { |
|
| 3556 | - $post = get_post( $post ); |
|
| 3555 | +function wp_get_canonical_url($post = null) { |
|
| 3556 | + $post = get_post($post); |
|
| 3557 | 3557 | |
| 3558 | - if ( ! $post ) { |
|
| 3558 | + if ( ! $post) { |
|
| 3559 | 3559 | return false; |
| 3560 | 3560 | } |
| 3561 | 3561 | |
| 3562 | - if ( 'publish' !== $post->post_status ) { |
|
| 3562 | + if ('publish' !== $post->post_status) { |
|
| 3563 | 3563 | return false; |
| 3564 | 3564 | } |
| 3565 | 3565 | |
| 3566 | - $canonical_url = get_permalink( $post ); |
|
| 3566 | + $canonical_url = get_permalink($post); |
|
| 3567 | 3567 | |
| 3568 | 3568 | // If a canonical is being generated for the current page, make sure it has pagination if needed. |
| 3569 | - if ( $post->ID === get_queried_object_id() ) { |
|
| 3570 | - $page = get_query_var( 'page', 0 ); |
|
| 3571 | - if ( $page >= 2 ) { |
|
| 3572 | - if ( '' == get_option( 'permalink_structure' ) ) { |
|
| 3573 | - $canonical_url = add_query_arg( 'page', $page, $canonical_url ); |
|
| 3569 | + if ($post->ID === get_queried_object_id()) { |
|
| 3570 | + $page = get_query_var('page', 0); |
|
| 3571 | + if ($page >= 2) { |
|
| 3572 | + if ('' == get_option('permalink_structure')) { |
|
| 3573 | + $canonical_url = add_query_arg('page', $page, $canonical_url); |
|
| 3574 | 3574 | } else { |
| 3575 | - $canonical_url = trailingslashit( $canonical_url ) . user_trailingslashit( $page, 'single_paged' ); |
|
| 3575 | + $canonical_url = trailingslashit($canonical_url).user_trailingslashit($page, 'single_paged'); |
|
| 3576 | 3576 | } |
| 3577 | 3577 | } |
| 3578 | 3578 | |
| 3579 | - $cpage = get_query_var( 'cpage', 0 ); |
|
| 3580 | - if ( $cpage ) { |
|
| 3581 | - $canonical_url = get_comments_pagenum_link( $cpage ); |
|
| 3579 | + $cpage = get_query_var('cpage', 0); |
|
| 3580 | + if ($cpage) { |
|
| 3581 | + $canonical_url = get_comments_pagenum_link($cpage); |
|
| 3582 | 3582 | } |
| 3583 | 3583 | } |
| 3584 | 3584 | |
@@ -3590,7 +3590,7 @@ discard block |
||
| 3590 | 3590 | * @param string $string The post's canonical URL. |
| 3591 | 3591 | * @param WP_Post $post Post object. |
| 3592 | 3592 | */ |
| 3593 | - return apply_filters( 'get_canonical_url', $canonical_url, $post ); |
|
| 3593 | + return apply_filters('get_canonical_url', $canonical_url, $post); |
|
| 3594 | 3594 | } |
| 3595 | 3595 | |
| 3596 | 3596 | /** |
@@ -3600,20 +3600,20 @@ discard block |
||
| 3600 | 3600 | * @since 4.6.0 Adjusted to use wp_get_canonical_url(). |
| 3601 | 3601 | */ |
| 3602 | 3602 | function rel_canonical() { |
| 3603 | - if ( ! is_singular() ) { |
|
| 3603 | + if ( ! is_singular()) { |
|
| 3604 | 3604 | return; |
| 3605 | 3605 | } |
| 3606 | 3606 | |
| 3607 | 3607 | $id = get_queried_object_id(); |
| 3608 | 3608 | |
| 3609 | - if ( 0 === $id ) { |
|
| 3609 | + if (0 === $id) { |
|
| 3610 | 3610 | return; |
| 3611 | 3611 | } |
| 3612 | 3612 | |
| 3613 | - $url = wp_get_canonical_url( $id ); |
|
| 3613 | + $url = wp_get_canonical_url($id); |
|
| 3614 | 3614 | |
| 3615 | - if ( ! empty( $url ) ) { |
|
| 3616 | - echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n"; |
|
| 3615 | + if ( ! empty($url)) { |
|
| 3616 | + echo '<link rel="canonical" href="'.esc_url($url).'" />'."\n"; |
|
| 3617 | 3617 | } |
| 3618 | 3618 | } |
| 3619 | 3619 | |
@@ -3637,7 +3637,7 @@ discard block |
||
| 3637 | 3637 | * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks |
| 3638 | 3638 | * are not enabled. |
| 3639 | 3639 | */ |
| 3640 | -function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { |
|
| 3640 | +function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { |
|
| 3641 | 3641 | /** |
| 3642 | 3642 | * Filters whether to preempt generating a shortlink for the given post. |
| 3643 | 3643 | * |
@@ -3651,32 +3651,32 @@ discard block |
||
| 3651 | 3651 | * @param string $context The context for the link. One of 'post' or 'query', |
| 3652 | 3652 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
| 3653 | 3653 | */ |
| 3654 | - $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); |
|
| 3654 | + $shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs); |
|
| 3655 | 3655 | |
| 3656 | - if ( false !== $shortlink ) { |
|
| 3656 | + if (false !== $shortlink) { |
|
| 3657 | 3657 | return $shortlink; |
| 3658 | 3658 | } |
| 3659 | 3659 | |
| 3660 | 3660 | $post_id = 0; |
| 3661 | - if ( 'query' == $context && is_singular() ) { |
|
| 3661 | + if ('query' == $context && is_singular()) { |
|
| 3662 | 3662 | $post_id = get_queried_object_id(); |
| 3663 | - $post = get_post( $post_id ); |
|
| 3664 | - } elseif ( 'post' == $context ) { |
|
| 3665 | - $post = get_post( $id ); |
|
| 3666 | - if ( ! empty( $post->ID ) ) |
|
| 3663 | + $post = get_post($post_id); |
|
| 3664 | + } elseif ('post' == $context) { |
|
| 3665 | + $post = get_post($id); |
|
| 3666 | + if ( ! empty($post->ID)) |
|
| 3667 | 3667 | $post_id = $post->ID; |
| 3668 | 3668 | } |
| 3669 | 3669 | |
| 3670 | 3670 | $shortlink = ''; |
| 3671 | 3671 | |
| 3672 | 3672 | // Return p= link for all public post types. |
| 3673 | - if ( ! empty( $post_id ) ) { |
|
| 3674 | - $post_type = get_post_type_object( $post->post_type ); |
|
| 3673 | + if ( ! empty($post_id)) { |
|
| 3674 | + $post_type = get_post_type_object($post->post_type); |
|
| 3675 | 3675 | |
| 3676 | - if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) { |
|
| 3677 | - $shortlink = home_url( '/' ); |
|
| 3678 | - } elseif ( $post_type->public ) { |
|
| 3679 | - $shortlink = home_url( '?p=' . $post_id ); |
|
| 3676 | + if ('page' === $post->post_type && $post->ID == get_option('page_on_front') && 'page' == get_option('show_on_front')) { |
|
| 3677 | + $shortlink = home_url('/'); |
|
| 3678 | + } elseif ($post_type->public) { |
|
| 3679 | + $shortlink = home_url('?p='.$post_id); |
|
| 3680 | 3680 | } |
| 3681 | 3681 | } |
| 3682 | 3682 | |
@@ -3690,7 +3690,7 @@ discard block |
||
| 3690 | 3690 | * @param string $context The context for the link. One of 'post' or 'query', |
| 3691 | 3691 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default. |
| 3692 | 3692 | */ |
| 3693 | - return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs ); |
|
| 3693 | + return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs); |
|
| 3694 | 3694 | } |
| 3695 | 3695 | |
| 3696 | 3696 | /** |
@@ -3701,12 +3701,12 @@ discard block |
||
| 3701 | 3701 | * @since 3.0.0 |
| 3702 | 3702 | */ |
| 3703 | 3703 | function wp_shortlink_wp_head() { |
| 3704 | - $shortlink = wp_get_shortlink( 0, 'query' ); |
|
| 3704 | + $shortlink = wp_get_shortlink(0, 'query'); |
|
| 3705 | 3705 | |
| 3706 | - if ( empty( $shortlink ) ) |
|
| 3706 | + if (empty($shortlink)) |
|
| 3707 | 3707 | return; |
| 3708 | 3708 | |
| 3709 | - echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n"; |
|
| 3709 | + echo "<link rel='shortlink' href='".esc_url($shortlink)."' />\n"; |
|
| 3710 | 3710 | } |
| 3711 | 3711 | |
| 3712 | 3712 | /** |
@@ -3717,15 +3717,15 @@ discard block |
||
| 3717 | 3717 | * @since 3.0.0 |
| 3718 | 3718 | */ |
| 3719 | 3719 | function wp_shortlink_header() { |
| 3720 | - if ( headers_sent() ) |
|
| 3720 | + if (headers_sent()) |
|
| 3721 | 3721 | return; |
| 3722 | 3722 | |
| 3723 | 3723 | $shortlink = wp_get_shortlink(0, 'query'); |
| 3724 | 3724 | |
| 3725 | - if ( empty($shortlink) ) |
|
| 3725 | + if (empty($shortlink)) |
|
| 3726 | 3726 | return; |
| 3727 | 3727 | |
| 3728 | - header('Link: <' . $shortlink . '>; rel=shortlink', false); |
|
| 3728 | + header('Link: <'.$shortlink.'>; rel=shortlink', false); |
|
| 3729 | 3729 | } |
| 3730 | 3730 | |
| 3731 | 3731 | /** |
@@ -3742,19 +3742,19 @@ discard block |
||
| 3742 | 3742 | * @param string $before Optional HTML to display before the link. Default empty. |
| 3743 | 3743 | * @param string $after Optional HTML to display after the link. Default empty. |
| 3744 | 3744 | */ |
| 3745 | -function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { |
|
| 3745 | +function the_shortlink($text = '', $title = '', $before = '', $after = '') { |
|
| 3746 | 3746 | $post = get_post(); |
| 3747 | 3747 | |
| 3748 | - if ( empty( $text ) ) |
|
| 3748 | + if (empty($text)) |
|
| 3749 | 3749 | $text = __('This is the short link.'); |
| 3750 | 3750 | |
| 3751 | - if ( empty( $title ) ) |
|
| 3752 | - $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3751 | + if (empty($title)) |
|
| 3752 | + $title = the_title_attribute(array('echo' => false)); |
|
| 3753 | 3753 | |
| 3754 | - $shortlink = wp_get_shortlink( $post->ID ); |
|
| 3754 | + $shortlink = wp_get_shortlink($post->ID); |
|
| 3755 | 3755 | |
| 3756 | - if ( !empty( $shortlink ) ) { |
|
| 3757 | - $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; |
|
| 3756 | + if ( ! empty($shortlink)) { |
|
| 3757 | + $link = '<a rel="shortlink" href="'.esc_url($shortlink).'" title="'.$title.'">'.$text.'</a>'; |
|
| 3758 | 3758 | |
| 3759 | 3759 | /** |
| 3760 | 3760 | * Filters the short link anchor tag for a post. |
@@ -3766,7 +3766,7 @@ discard block |
||
| 3766 | 3766 | * @param string $text Shortlink's text. |
| 3767 | 3767 | * @param string $title Shortlink's title attribute. |
| 3768 | 3768 | */ |
| 3769 | - $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); |
|
| 3769 | + $link = apply_filters('the_shortlink', $link, $shortlink, $text, $title); |
|
| 3770 | 3770 | echo $before, $link, $after; |
| 3771 | 3771 | } |
| 3772 | 3772 | } |
@@ -3799,8 +3799,8 @@ discard block |
||
| 3799 | 3799 | * } |
| 3800 | 3800 | * @return false|string The URL of the avatar we found, or false if we couldn't find an avatar. |
| 3801 | 3801 | */ |
| 3802 | -function get_avatar_url( $id_or_email, $args = null ) { |
|
| 3803 | - $args = get_avatar_data( $id_or_email, $args ); |
|
| 3802 | +function get_avatar_url($id_or_email, $args = null) { |
|
| 3803 | + $args = get_avatar_data($id_or_email, $args); |
|
| 3804 | 3804 | return $args['url']; |
| 3805 | 3805 | } |
| 3806 | 3806 | |
@@ -3840,51 +3840,51 @@ discard block |
||
| 3840 | 3840 | * @type string $url The URL of the avatar we found. |
| 3841 | 3841 | * } |
| 3842 | 3842 | */ |
| 3843 | -function get_avatar_data( $id_or_email, $args = null ) { |
|
| 3844 | - $args = wp_parse_args( $args, array( |
|
| 3843 | +function get_avatar_data($id_or_email, $args = null) { |
|
| 3844 | + $args = wp_parse_args($args, array( |
|
| 3845 | 3845 | 'size' => 96, |
| 3846 | 3846 | 'height' => null, |
| 3847 | 3847 | 'width' => null, |
| 3848 | - 'default' => get_option( 'avatar_default', 'mystery' ), |
|
| 3848 | + 'default' => get_option('avatar_default', 'mystery'), |
|
| 3849 | 3849 | 'force_default' => false, |
| 3850 | - 'rating' => get_option( 'avatar_rating' ), |
|
| 3850 | + 'rating' => get_option('avatar_rating'), |
|
| 3851 | 3851 | 'scheme' => null, |
| 3852 | 3852 | 'processed_args' => null, // if used, should be a reference |
| 3853 | 3853 | 'extra_attr' => '', |
| 3854 | - ) ); |
|
| 3854 | + )); |
|
| 3855 | 3855 | |
| 3856 | - if ( is_numeric( $args['size'] ) ) { |
|
| 3857 | - $args['size'] = absint( $args['size'] ); |
|
| 3858 | - if ( ! $args['size'] ) { |
|
| 3856 | + if (is_numeric($args['size'])) { |
|
| 3857 | + $args['size'] = absint($args['size']); |
|
| 3858 | + if ( ! $args['size']) { |
|
| 3859 | 3859 | $args['size'] = 96; |
| 3860 | 3860 | } |
| 3861 | 3861 | } else { |
| 3862 | 3862 | $args['size'] = 96; |
| 3863 | 3863 | } |
| 3864 | 3864 | |
| 3865 | - if ( is_numeric( $args['height'] ) ) { |
|
| 3866 | - $args['height'] = absint( $args['height'] ); |
|
| 3867 | - if ( ! $args['height'] ) { |
|
| 3865 | + if (is_numeric($args['height'])) { |
|
| 3866 | + $args['height'] = absint($args['height']); |
|
| 3867 | + if ( ! $args['height']) { |
|
| 3868 | 3868 | $args['height'] = $args['size']; |
| 3869 | 3869 | } |
| 3870 | 3870 | } else { |
| 3871 | 3871 | $args['height'] = $args['size']; |
| 3872 | 3872 | } |
| 3873 | 3873 | |
| 3874 | - if ( is_numeric( $args['width'] ) ) { |
|
| 3875 | - $args['width'] = absint( $args['width'] ); |
|
| 3876 | - if ( ! $args['width'] ) { |
|
| 3874 | + if (is_numeric($args['width'])) { |
|
| 3875 | + $args['width'] = absint($args['width']); |
|
| 3876 | + if ( ! $args['width']) { |
|
| 3877 | 3877 | $args['width'] = $args['size']; |
| 3878 | 3878 | } |
| 3879 | 3879 | } else { |
| 3880 | 3880 | $args['width'] = $args['size']; |
| 3881 | 3881 | } |
| 3882 | 3882 | |
| 3883 | - if ( empty( $args['default'] ) ) { |
|
| 3884 | - $args['default'] = get_option( 'avatar_default', 'mystery' ); |
|
| 3883 | + if (empty($args['default'])) { |
|
| 3884 | + $args['default'] = get_option('avatar_default', 'mystery'); |
|
| 3885 | 3885 | } |
| 3886 | 3886 | |
| 3887 | - switch ( $args['default'] ) { |
|
| 3887 | + switch ($args['default']) { |
|
| 3888 | 3888 | case 'mm' : |
| 3889 | 3889 | case 'mystery' : |
| 3890 | 3890 | case 'mysteryman' : |
@@ -3897,7 +3897,7 @@ discard block |
||
| 3897 | 3897 | |
| 3898 | 3898 | $args['force_default'] = (bool) $args['force_default']; |
| 3899 | 3899 | |
| 3900 | - $args['rating'] = strtolower( $args['rating'] ); |
|
| 3900 | + $args['rating'] = strtolower($args['rating']); |
|
| 3901 | 3901 | |
| 3902 | 3902 | $args['found_avatar'] = false; |
| 3903 | 3903 | |
@@ -3914,38 +3914,38 @@ discard block |
||
| 3914 | 3914 | * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash, |
| 3915 | 3915 | * user email, WP_User object, WP_Post object, or WP_Comment object. |
| 3916 | 3916 | */ |
| 3917 | - $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email ); |
|
| 3917 | + $args = apply_filters('pre_get_avatar_data', $args, $id_or_email); |
|
| 3918 | 3918 | |
| 3919 | - if ( isset( $args['url'] ) && ! is_null( $args['url'] ) ) { |
|
| 3919 | + if (isset($args['url']) && ! is_null($args['url'])) { |
|
| 3920 | 3920 | /** This filter is documented in wp-includes/link-template.php */ |
| 3921 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 3921 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 3922 | 3922 | } |
| 3923 | 3923 | |
| 3924 | 3924 | $email_hash = ''; |
| 3925 | 3925 | $user = $email = false; |
| 3926 | 3926 | |
| 3927 | - if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) { |
|
| 3928 | - $id_or_email = get_comment( $id_or_email ); |
|
| 3927 | + if (is_object($id_or_email) && isset($id_or_email->comment_ID)) { |
|
| 3928 | + $id_or_email = get_comment($id_or_email); |
|
| 3929 | 3929 | } |
| 3930 | 3930 | |
| 3931 | 3931 | // Process the user identifier. |
| 3932 | - if ( is_numeric( $id_or_email ) ) { |
|
| 3933 | - $user = get_user_by( 'id', absint( $id_or_email ) ); |
|
| 3934 | - } elseif ( is_string( $id_or_email ) ) { |
|
| 3935 | - if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) { |
|
| 3932 | + if (is_numeric($id_or_email)) { |
|
| 3933 | + $user = get_user_by('id', absint($id_or_email)); |
|
| 3934 | + } elseif (is_string($id_or_email)) { |
|
| 3935 | + if (strpos($id_or_email, '@md5.gravatar.com')) { |
|
| 3936 | 3936 | // md5 hash |
| 3937 | - list( $email_hash ) = explode( '@', $id_or_email ); |
|
| 3937 | + list($email_hash) = explode('@', $id_or_email); |
|
| 3938 | 3938 | } else { |
| 3939 | 3939 | // email address |
| 3940 | 3940 | $email = $id_or_email; |
| 3941 | 3941 | } |
| 3942 | - } elseif ( $id_or_email instanceof WP_User ) { |
|
| 3942 | + } elseif ($id_or_email instanceof WP_User) { |
|
| 3943 | 3943 | // User Object |
| 3944 | 3944 | $user = $id_or_email; |
| 3945 | - } elseif ( $id_or_email instanceof WP_Post ) { |
|
| 3945 | + } elseif ($id_or_email instanceof WP_Post) { |
|
| 3946 | 3946 | // Post Object |
| 3947 | - $user = get_user_by( 'id', (int) $id_or_email->post_author ); |
|
| 3948 | - } elseif ( $id_or_email instanceof WP_Comment ) { |
|
| 3947 | + $user = get_user_by('id', (int) $id_or_email->post_author); |
|
| 3948 | + } elseif ($id_or_email instanceof WP_Comment) { |
|
| 3949 | 3949 | /** |
| 3950 | 3950 | * Filters the list of allowed comment types for retrieving avatars. |
| 3951 | 3951 | * |
@@ -3953,36 +3953,36 @@ discard block |
||
| 3953 | 3953 | * |
| 3954 | 3954 | * @param array $types An array of content types. Default only contains 'comment'. |
| 3955 | 3955 | */ |
| 3956 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 3957 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 3956 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 3957 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 3958 | 3958 | $args['url'] = false; |
| 3959 | 3959 | /** This filter is documented in wp-includes/link-template.php */ |
| 3960 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 3960 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 3961 | 3961 | } |
| 3962 | 3962 | |
| 3963 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 3964 | - $user = get_user_by( 'id', (int) $id_or_email->user_id ); |
|
| 3963 | + if ( ! empty($id_or_email->user_id)) { |
|
| 3964 | + $user = get_user_by('id', (int) $id_or_email->user_id); |
|
| 3965 | 3965 | } |
| 3966 | - if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) { |
|
| 3966 | + if (( ! $user || is_wp_error($user)) && ! empty($id_or_email->comment_author_email)) { |
|
| 3967 | 3967 | $email = $id_or_email->comment_author_email; |
| 3968 | 3968 | } |
| 3969 | 3969 | } |
| 3970 | 3970 | |
| 3971 | - if ( ! $email_hash ) { |
|
| 3972 | - if ( $user ) { |
|
| 3971 | + if ( ! $email_hash) { |
|
| 3972 | + if ($user) { |
|
| 3973 | 3973 | $email = $user->user_email; |
| 3974 | 3974 | } |
| 3975 | 3975 | |
| 3976 | - if ( $email ) { |
|
| 3977 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
| 3976 | + if ($email) { |
|
| 3977 | + $email_hash = md5(strtolower(trim($email))); |
|
| 3978 | 3978 | } |
| 3979 | 3979 | } |
| 3980 | 3980 | |
| 3981 | - if ( $email_hash ) { |
|
| 3981 | + if ($email_hash) { |
|
| 3982 | 3982 | $args['found_avatar'] = true; |
| 3983 | - $gravatar_server = hexdec( $email_hash[0] ) % 3; |
|
| 3983 | + $gravatar_server = hexdec($email_hash[0]) % 3; |
|
| 3984 | 3984 | } else { |
| 3985 | - $gravatar_server = rand( 0, 2 ); |
|
| 3985 | + $gravatar_server = rand(0, 2); |
|
| 3986 | 3986 | } |
| 3987 | 3987 | |
| 3988 | 3988 | $url_args = array( |
@@ -3992,15 +3992,15 @@ discard block |
||
| 3992 | 3992 | 'r' => $args['rating'], |
| 3993 | 3993 | ); |
| 3994 | 3994 | |
| 3995 | - if ( is_ssl() ) { |
|
| 3996 | - $url = 'https://secure.gravatar.com/avatar/' . $email_hash; |
|
| 3995 | + if (is_ssl()) { |
|
| 3996 | + $url = 'https://secure.gravatar.com/avatar/'.$email_hash; |
|
| 3997 | 3997 | } else { |
| 3998 | - $url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash ); |
|
| 3998 | + $url = sprintf('http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash); |
|
| 3999 | 3999 | } |
| 4000 | 4000 | |
| 4001 | 4001 | $url = add_query_arg( |
| 4002 | - rawurlencode_deep( array_filter( $url_args ) ), |
|
| 4003 | - set_url_scheme( $url, $args['scheme'] ) |
|
| 4002 | + rawurlencode_deep(array_filter($url_args)), |
|
| 4003 | + set_url_scheme($url, $args['scheme']) |
|
| 4004 | 4004 | ); |
| 4005 | 4005 | |
| 4006 | 4006 | /** |
@@ -4013,7 +4013,7 @@ discard block |
||
| 4013 | 4013 | * user email, WP_User object, WP_Post object, or WP_Comment object. |
| 4014 | 4014 | * @param array $args Arguments passed to get_avatar_data(), after processing. |
| 4015 | 4015 | */ |
| 4016 | - $args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args ); |
|
| 4016 | + $args['url'] = apply_filters('get_avatar_url', $url, $id_or_email, $args); |
|
| 4017 | 4017 | |
| 4018 | 4018 | /** |
| 4019 | 4019 | * Filters the avatar data. |
@@ -4024,5 +4024,5 @@ discard block |
||
| 4024 | 4024 | * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash, |
| 4025 | 4025 | * user email, WP_User object, WP_Post object, or WP_Comment object. |
| 4026 | 4026 | */ |
| 4027 | - return apply_filters( 'get_avatar_data', $args, $id_or_email ); |
|
| 4027 | + return apply_filters('get_avatar_data', $args, $id_or_email); |
|
| 4028 | 4028 | } |
@@ -46,10 +46,11 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function user_trailingslashit($string, $type_of_url = '') { |
| 48 | 48 | global $wp_rewrite; |
| 49 | - if ( $wp_rewrite->use_trailing_slashes ) |
|
| 50 | - $string = trailingslashit($string); |
|
| 51 | - else |
|
| 52 | - $string = untrailingslashit($string); |
|
| 49 | + if ( $wp_rewrite->use_trailing_slashes ) { |
|
| 50 | + $string = trailingslashit($string); |
|
| 51 | + } else { |
|
| 52 | + $string = untrailingslashit($string); |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | 55 | /** |
| 55 | 56 | * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes. |
@@ -137,15 +138,17 @@ discard block |
||
| 137 | 138 | $sample = false; |
| 138 | 139 | } |
| 139 | 140 | |
| 140 | - if ( empty($post->ID) ) |
|
| 141 | - return false; |
|
| 141 | + if ( empty($post->ID) ) { |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 142 | 144 | |
| 143 | - if ( $post->post_type == 'page' ) |
|
| 144 | - return get_page_link($post, $leavename, $sample); |
|
| 145 | - elseif ( $post->post_type == 'attachment' ) |
|
| 146 | - return get_attachment_link( $post, $leavename ); |
|
| 147 | - elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) |
|
| 148 | - return get_post_permalink($post, $leavename, $sample); |
|
| 145 | + if ( $post->post_type == 'page' ) { |
|
| 146 | + return get_page_link($post, $leavename, $sample); |
|
| 147 | + } elseif ( $post->post_type == 'attachment' ) { |
|
| 148 | + return get_attachment_link( $post, $leavename ); |
|
| 149 | + } elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) { |
|
| 150 | + return get_post_permalink($post, $leavename, $sample); |
|
| 151 | + } |
|
| 149 | 152 | |
| 150 | 153 | $permalink = get_option('permalink_structure'); |
| 151 | 154 | |
@@ -184,8 +187,9 @@ discard block |
||
| 184 | 187 | |
| 185 | 188 | $category_object = get_term( $category_object, 'category' ); |
| 186 | 189 | $category = $category_object->slug; |
| 187 | - if ( $parent = $category_object->parent ) |
|
| 188 | - $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 190 | + if ( $parent = $category_object->parent ) { |
|
| 191 | + $category = get_category_parents($parent, false, '/', true) . $category; |
|
| 192 | + } |
|
| 189 | 193 | } |
| 190 | 194 | // show default category in permalinks, without |
| 191 | 195 | // having to assign it explicitly |
@@ -255,8 +259,9 @@ discard block |
||
| 255 | 259 | |
| 256 | 260 | $post = get_post($id); |
| 257 | 261 | |
| 258 | - if ( is_wp_error( $post ) ) |
|
| 259 | - return $post; |
|
| 262 | + if ( is_wp_error( $post ) ) { |
|
| 263 | + return $post; |
|
| 264 | + } |
|
| 260 | 265 | |
| 261 | 266 | $post_link = $wp_rewrite->get_extra_permastruct($post->post_type); |
| 262 | 267 | |
@@ -276,10 +281,11 @@ discard block |
||
| 276 | 281 | } |
| 277 | 282 | $post_link = home_url( user_trailingslashit($post_link) ); |
| 278 | 283 | } else { |
| 279 | - if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) |
|
| 280 | - $post_link = add_query_arg($post_type->query_var, $slug, ''); |
|
| 281 | - else |
|
| 282 | - $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
|
| 284 | + if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) ) { |
|
| 285 | + $post_link = add_query_arg($post_type->query_var, $slug, ''); |
|
| 286 | + } else { |
|
| 287 | + $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), ''); |
|
| 288 | + } |
|
| 283 | 289 | $post_link = home_url($post_link); |
| 284 | 290 | } |
| 285 | 291 | |
@@ -312,10 +318,11 @@ discard block |
||
| 312 | 318 | function get_page_link( $post = false, $leavename = false, $sample = false ) { |
| 313 | 319 | $post = get_post( $post ); |
| 314 | 320 | |
| 315 | - if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) |
|
| 316 | - $link = home_url('/'); |
|
| 317 | - else |
|
| 318 | - $link = _get_page_link( $post, $leavename, $sample ); |
|
| 321 | + if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) { |
|
| 322 | + $link = home_url('/'); |
|
| 323 | + } else { |
|
| 324 | + $link = _get_page_link( $post, $leavename, $sample ); |
|
| 325 | + } |
|
| 319 | 326 | |
| 320 | 327 | /** |
| 321 | 328 | * Filters the permalink for a page. |
@@ -401,27 +408,36 @@ discard block |
||
| 401 | 408 | } |
| 402 | 409 | |
| 403 | 410 | if ( $wp_rewrite->using_permalinks() && $parent ) { |
| 404 | - if ( 'page' == $parent->post_type ) |
|
| 405 | - $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front |
|
| 406 | - else |
|
| 407 | - $parentlink = get_permalink( $post->post_parent ); |
|
| 411 | + if ( 'page' == $parent->post_type ) { |
|
| 412 | + $parentlink = _get_page_link( $post->post_parent ); |
|
| 413 | + } |
|
| 414 | + // Ignores page_on_front |
|
| 415 | + else { |
|
| 416 | + $parentlink = get_permalink( $post->post_parent ); |
|
| 417 | + } |
|
| 408 | 418 | |
| 409 | - if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) |
|
| 410 | - $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 411 | - else |
|
| 412 | - $name = $post->post_name; |
|
| 419 | + if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) { |
|
| 420 | + $name = 'attachment/' . $post->post_name; |
|
| 421 | + } |
|
| 422 | + // <permalink>/<int>/ is paged so we use the explicit attachment marker |
|
| 423 | + else { |
|
| 424 | + $name = $post->post_name; |
|
| 425 | + } |
|
| 413 | 426 | |
| 414 | - if ( strpos($parentlink, '?') === false ) |
|
| 415 | - $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 427 | + if ( strpos($parentlink, '?') === false ) { |
|
| 428 | + $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' ); |
|
| 429 | + } |
|
| 416 | 430 | |
| 417 | - if ( ! $leavename ) |
|
| 418 | - $link = str_replace( '%postname%', $name, $link ); |
|
| 431 | + if ( ! $leavename ) { |
|
| 432 | + $link = str_replace( '%postname%', $name, $link ); |
|
| 433 | + } |
|
| 419 | 434 | } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) { |
| 420 | 435 | $link = home_url( user_trailingslashit( $post->post_name ) ); |
| 421 | 436 | } |
| 422 | 437 | |
| 423 | - if ( ! $link ) |
|
| 424 | - $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 438 | + if ( ! $link ) { |
|
| 439 | + $link = home_url( '/?attachment_id=' . $post->ID ); |
|
| 440 | + } |
|
| 425 | 441 | |
| 426 | 442 | /** |
| 427 | 443 | * Filters the permalink for an attachment. |
@@ -446,8 +462,9 @@ discard block |
||
| 446 | 462 | */ |
| 447 | 463 | function get_year_link( $year ) { |
| 448 | 464 | global $wp_rewrite; |
| 449 | - if ( !$year ) |
|
| 450 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 465 | + if ( !$year ) { |
|
| 466 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 467 | + } |
|
| 451 | 468 | $yearlink = $wp_rewrite->get_year_permastruct(); |
| 452 | 469 | if ( !empty($yearlink) ) { |
| 453 | 470 | $yearlink = str_replace('%year%', $year, $yearlink); |
@@ -480,10 +497,12 @@ discard block |
||
| 480 | 497 | */ |
| 481 | 498 | function get_month_link($year, $month) { |
| 482 | 499 | global $wp_rewrite; |
| 483 | - if ( !$year ) |
|
| 484 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 485 | - if ( !$month ) |
|
| 486 | - $month = gmdate('m', current_time('timestamp')); |
|
| 500 | + if ( !$year ) { |
|
| 501 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 502 | + } |
|
| 503 | + if ( !$month ) { |
|
| 504 | + $month = gmdate('m', current_time('timestamp')); |
|
| 505 | + } |
|
| 487 | 506 | $monthlink = $wp_rewrite->get_month_permastruct(); |
| 488 | 507 | if ( !empty($monthlink) ) { |
| 489 | 508 | $monthlink = str_replace('%year%', $year, $monthlink); |
@@ -519,12 +538,15 @@ discard block |
||
| 519 | 538 | */ |
| 520 | 539 | function get_day_link($year, $month, $day) { |
| 521 | 540 | global $wp_rewrite; |
| 522 | - if ( !$year ) |
|
| 523 | - $year = gmdate('Y', current_time('timestamp')); |
|
| 524 | - if ( !$month ) |
|
| 525 | - $month = gmdate('m', current_time('timestamp')); |
|
| 526 | - if ( !$day ) |
|
| 527 | - $day = gmdate('j', current_time('timestamp')); |
|
| 541 | + if ( !$year ) { |
|
| 542 | + $year = gmdate('Y', current_time('timestamp')); |
|
| 543 | + } |
|
| 544 | + if ( !$month ) { |
|
| 545 | + $month = gmdate('m', current_time('timestamp')); |
|
| 546 | + } |
|
| 547 | + if ( !$day ) { |
|
| 548 | + $day = gmdate('j', current_time('timestamp')); |
|
| 549 | + } |
|
| 528 | 550 | |
| 529 | 551 | $daylink = $wp_rewrite->get_day_permastruct(); |
| 530 | 552 | if ( !empty($daylink) ) { |
@@ -592,18 +614,21 @@ discard block |
||
| 592 | 614 | $permalink = $wp_rewrite->get_comment_feed_permastruct(); |
| 593 | 615 | } |
| 594 | 616 | |
| 595 | - if ( get_default_feed() == $feed ) |
|
| 596 | - $feed = ''; |
|
| 617 | + if ( get_default_feed() == $feed ) { |
|
| 618 | + $feed = ''; |
|
| 619 | + } |
|
| 597 | 620 | |
| 598 | 621 | $permalink = str_replace('%feed%', $feed, $permalink); |
| 599 | 622 | $permalink = preg_replace('#/+#', '/', "/$permalink"); |
| 600 | 623 | $output = home_url( user_trailingslashit($permalink, 'feed') ); |
| 601 | 624 | } else { |
| 602 | - if ( empty($feed) ) |
|
| 603 | - $feed = get_default_feed(); |
|
| 625 | + if ( empty($feed) ) { |
|
| 626 | + $feed = get_default_feed(); |
|
| 627 | + } |
|
| 604 | 628 | |
| 605 | - if ( false !== strpos($feed, 'comments_') ) |
|
| 606 | - $feed = str_replace('comments_', 'comments-', $feed); |
|
| 629 | + if ( false !== strpos($feed, 'comments_') ) { |
|
| 630 | + $feed = str_replace('comments_', 'comments-', $feed); |
|
| 631 | + } |
|
| 607 | 632 | |
| 608 | 633 | $output = home_url("?feed={$feed}"); |
| 609 | 634 | } |
@@ -631,20 +656,23 @@ discard block |
||
| 631 | 656 | function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { |
| 632 | 657 | $post_id = absint( $post_id ); |
| 633 | 658 | |
| 634 | - if ( ! $post_id ) |
|
| 635 | - $post_id = get_the_ID(); |
|
| 659 | + if ( ! $post_id ) { |
|
| 660 | + $post_id = get_the_ID(); |
|
| 661 | + } |
|
| 636 | 662 | |
| 637 | - if ( empty( $feed ) ) |
|
| 638 | - $feed = get_default_feed(); |
|
| 663 | + if ( empty( $feed ) ) { |
|
| 664 | + $feed = get_default_feed(); |
|
| 665 | + } |
|
| 639 | 666 | |
| 640 | 667 | $post = get_post( $post_id ); |
| 641 | 668 | $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; |
| 642 | 669 | |
| 643 | 670 | if ( '' != get_option('permalink_structure') ) { |
| 644 | - if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) |
|
| 645 | - $url = _get_page_link( $post_id ); |
|
| 646 | - else |
|
| 647 | - $url = get_permalink($post_id); |
|
| 671 | + if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') ) { |
|
| 672 | + $url = _get_page_link( $post_id ); |
|
| 673 | + } else { |
|
| 674 | + $url = get_permalink($post_id); |
|
| 675 | + } |
|
| 648 | 676 | |
| 649 | 677 | if ( $unattached ) { |
| 650 | 678 | $url = home_url( '/feed/' ); |
@@ -654,8 +682,9 @@ discard block |
||
| 654 | 682 | $url = add_query_arg( 'attachment_id', $post_id, $url ); |
| 655 | 683 | } else { |
| 656 | 684 | $url = trailingslashit($url) . 'feed'; |
| 657 | - if ( $feed != get_default_feed() ) |
|
| 658 | - $url .= "/$feed"; |
|
| 685 | + if ( $feed != get_default_feed() ) { |
|
| 686 | + $url .= "/$feed"; |
|
| 687 | + } |
|
| 659 | 688 | $url = user_trailingslashit($url, 'single_feed'); |
| 660 | 689 | } |
| 661 | 690 | } else { |
@@ -726,17 +755,19 @@ discard block |
||
| 726 | 755 | $author_id = (int) $author_id; |
| 727 | 756 | $permalink_structure = get_option('permalink_structure'); |
| 728 | 757 | |
| 729 | - if ( empty($feed) ) |
|
| 730 | - $feed = get_default_feed(); |
|
| 758 | + if ( empty($feed) ) { |
|
| 759 | + $feed = get_default_feed(); |
|
| 760 | + } |
|
| 731 | 761 | |
| 732 | 762 | if ( '' == $permalink_structure ) { |
| 733 | 763 | $link = home_url("?feed=$feed&author=" . $author_id); |
| 734 | 764 | } else { |
| 735 | 765 | $link = get_author_posts_url($author_id); |
| 736 | - if ( $feed == get_default_feed() ) |
|
| 737 | - $feed_link = 'feed'; |
|
| 738 | - else |
|
| 739 | - $feed_link = "feed/$feed"; |
|
| 766 | + if ( $feed == get_default_feed() ) { |
|
| 767 | + $feed_link = 'feed'; |
|
| 768 | + } else { |
|
| 769 | + $feed_link = "feed/$feed"; |
|
| 770 | + } |
|
| 740 | 771 | |
| 741 | 772 | $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); |
| 742 | 773 | } |
@@ -788,19 +819,20 @@ discard block |
||
| 788 | 819 | |
| 789 | 820 | $term = get_term( $term_id, $taxonomy ); |
| 790 | 821 | |
| 791 | - if ( empty( $term ) || is_wp_error( $term ) ) |
|
| 792 | - return false; |
|
| 822 | + if ( empty( $term ) || is_wp_error( $term ) ) { |
|
| 823 | + return false; |
|
| 824 | + } |
|
| 793 | 825 | |
| 794 | - if ( empty( $feed ) ) |
|
| 795 | - $feed = get_default_feed(); |
|
| 826 | + if ( empty( $feed ) ) { |
|
| 827 | + $feed = get_default_feed(); |
|
| 828 | + } |
|
| 796 | 829 | |
| 797 | 830 | $permalink_structure = get_option( 'permalink_structure' ); |
| 798 | 831 | |
| 799 | 832 | if ( '' == $permalink_structure ) { |
| 800 | 833 | if ( 'category' == $taxonomy ) { |
| 801 | 834 | $link = home_url("?feed=$feed&cat=$term_id"); |
| 802 | - } |
|
| 803 | - elseif ( 'post_tag' == $taxonomy ) { |
|
| 835 | + } elseif ( 'post_tag' == $taxonomy ) { |
|
| 804 | 836 | $link = home_url("?feed=$feed&tag=$term->slug"); |
| 805 | 837 | } else { |
| 806 | 838 | $t = get_taxonomy( $taxonomy ); |
@@ -808,10 +840,11 @@ discard block |
||
| 808 | 840 | } |
| 809 | 841 | } else { |
| 810 | 842 | $link = get_term_link( $term_id, $term->taxonomy ); |
| 811 | - if ( $feed == get_default_feed() ) |
|
| 812 | - $feed_link = 'feed'; |
|
| 813 | - else |
|
| 814 | - $feed_link = "feed/$feed"; |
|
| 843 | + if ( $feed == get_default_feed() ) { |
|
| 844 | + $feed_link = 'feed'; |
|
| 845 | + } else { |
|
| 846 | + $feed_link = "feed/$feed"; |
|
| 847 | + } |
|
| 815 | 848 | |
| 816 | 849 | $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); |
| 817 | 850 | } |
@@ -977,18 +1010,22 @@ discard block |
||
| 977 | 1010 | * @return string|void HTML content. |
| 978 | 1011 | */ |
| 979 | 1012 | function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { |
| 980 | - if ( is_null( $term ) ) |
|
| 981 | - $term = get_queried_object(); |
|
| 1013 | + if ( is_null( $term ) ) { |
|
| 1014 | + $term = get_queried_object(); |
|
| 1015 | + } |
|
| 982 | 1016 | |
| 983 | - if ( ! $term ) |
|
| 984 | - return; |
|
| 1017 | + if ( ! $term ) { |
|
| 1018 | + return; |
|
| 1019 | + } |
|
| 985 | 1020 | |
| 986 | 1021 | $tax = get_taxonomy( $term->taxonomy ); |
| 987 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
| 988 | - return; |
|
| 1022 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
| 1023 | + return; |
|
| 1024 | + } |
|
| 989 | 1025 | |
| 990 | - if ( empty( $link ) ) |
|
| 991 | - $link = __('Edit This'); |
|
| 1026 | + if ( empty( $link ) ) { |
|
| 1027 | + $link = __('Edit This'); |
|
| 1028 | + } |
|
| 992 | 1029 | |
| 993 | 1030 | $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; |
| 994 | 1031 | |
@@ -1002,11 +1039,12 @@ discard block |
||
| 1002 | 1039 | */ |
| 1003 | 1040 | $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; |
| 1004 | 1041 | |
| 1005 | - if ( $echo ) |
|
| 1006 | - echo $link; |
|
| 1007 | - else |
|
| 1008 | - return $link; |
|
| 1009 | -} |
|
| 1042 | + if ( $echo ) { |
|
| 1043 | + echo $link; |
|
| 1044 | + } else { |
|
| 1045 | + return $link; |
|
| 1046 | + } |
|
| 1047 | + } |
|
| 1010 | 1048 | |
| 1011 | 1049 | /** |
| 1012 | 1050 | * Retrieves the permalink for a search. |
@@ -1021,10 +1059,11 @@ discard block |
||
| 1021 | 1059 | function get_search_link( $query = '' ) { |
| 1022 | 1060 | global $wp_rewrite; |
| 1023 | 1061 | |
| 1024 | - if ( empty($query) ) |
|
| 1025 | - $search = get_search_query( false ); |
|
| 1026 | - else |
|
| 1027 | - $search = stripslashes($query); |
|
| 1062 | + if ( empty($query) ) { |
|
| 1063 | + $search = get_search_query( false ); |
|
| 1064 | + } else { |
|
| 1065 | + $search = stripslashes($query); |
|
| 1066 | + } |
|
| 1028 | 1067 | |
| 1029 | 1068 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1030 | 1069 | |
@@ -1063,8 +1102,9 @@ discard block |
||
| 1063 | 1102 | global $wp_rewrite; |
| 1064 | 1103 | $link = get_search_link($search_query); |
| 1065 | 1104 | |
| 1066 | - if ( empty($feed) ) |
|
| 1067 | - $feed = get_default_feed(); |
|
| 1105 | + if ( empty($feed) ) { |
|
| 1106 | + $feed = get_default_feed(); |
|
| 1107 | + } |
|
| 1068 | 1108 | |
| 1069 | 1109 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1070 | 1110 | |
@@ -1101,17 +1141,19 @@ discard block |
||
| 1101 | 1141 | function get_search_comments_feed_link($search_query = '', $feed = '') { |
| 1102 | 1142 | global $wp_rewrite; |
| 1103 | 1143 | |
| 1104 | - if ( empty($feed) ) |
|
| 1105 | - $feed = get_default_feed(); |
|
| 1144 | + if ( empty($feed) ) { |
|
| 1145 | + $feed = get_default_feed(); |
|
| 1146 | + } |
|
| 1106 | 1147 | |
| 1107 | 1148 | $link = get_search_feed_link($search_query, $feed); |
| 1108 | 1149 | |
| 1109 | 1150 | $permastruct = $wp_rewrite->get_search_permastruct(); |
| 1110 | 1151 | |
| 1111 | - if ( empty($permastruct) ) |
|
| 1112 | - $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1113 | - else |
|
| 1114 | - $link = add_query_arg('withcomments', 1, $link); |
|
| 1152 | + if ( empty($permastruct) ) { |
|
| 1153 | + $link = add_query_arg('feed', 'comments-' . $feed, $link); |
|
| 1154 | + } else { |
|
| 1155 | + $link = add_query_arg('withcomments', 1, $link); |
|
| 1156 | + } |
|
| 1115 | 1157 | |
| 1116 | 1158 | /** This filter is documented in wp-includes/link-template.php */ |
| 1117 | 1159 | return apply_filters( 'search_feed_link', $link, $feed, 'comments' ); |
@@ -1130,8 +1172,9 @@ discard block |
||
| 1130 | 1172 | */ |
| 1131 | 1173 | function get_post_type_archive_link( $post_type ) { |
| 1132 | 1174 | global $wp_rewrite; |
| 1133 | - if ( ! $post_type_obj = get_post_type_object( $post_type ) ) |
|
| 1134 | - return false; |
|
| 1175 | + if ( ! $post_type_obj = get_post_type_object( $post_type ) ) { |
|
| 1176 | + return false; |
|
| 1177 | + } |
|
| 1135 | 1178 | |
| 1136 | 1179 | if ( 'post' === $post_type ) { |
| 1137 | 1180 | $show_on_front = get_option( 'show_on_front' ); |
@@ -1146,15 +1189,17 @@ discard block |
||
| 1146 | 1189 | return apply_filters( 'post_type_archive_link', $link, $post_type ); |
| 1147 | 1190 | } |
| 1148 | 1191 | |
| 1149 | - if ( ! $post_type_obj->has_archive ) |
|
| 1150 | - return false; |
|
| 1192 | + if ( ! $post_type_obj->has_archive ) { |
|
| 1193 | + return false; |
|
| 1194 | + } |
|
| 1151 | 1195 | |
| 1152 | 1196 | if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { |
| 1153 | 1197 | $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive; |
| 1154 | - if ( $post_type_obj->rewrite['with_front'] ) |
|
| 1155 | - $struct = $wp_rewrite->front . $struct; |
|
| 1156 | - else |
|
| 1157 | - $struct = $wp_rewrite->root . $struct; |
|
| 1198 | + if ( $post_type_obj->rewrite['with_front'] ) { |
|
| 1199 | + $struct = $wp_rewrite->front . $struct; |
|
| 1200 | + } else { |
|
| 1201 | + $struct = $wp_rewrite->root . $struct; |
|
| 1202 | + } |
|
| 1158 | 1203 | $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); |
| 1159 | 1204 | } else { |
| 1160 | 1205 | $link = home_url( '?post_type=' . $post_type ); |
@@ -1182,18 +1227,21 @@ discard block |
||
| 1182 | 1227 | */ |
| 1183 | 1228 | function get_post_type_archive_feed_link( $post_type, $feed = '' ) { |
| 1184 | 1229 | $default_feed = get_default_feed(); |
| 1185 | - if ( empty( $feed ) ) |
|
| 1186 | - $feed = $default_feed; |
|
| 1230 | + if ( empty( $feed ) ) { |
|
| 1231 | + $feed = $default_feed; |
|
| 1232 | + } |
|
| 1187 | 1233 | |
| 1188 | - if ( ! $link = get_post_type_archive_link( $post_type ) ) |
|
| 1189 | - return false; |
|
| 1234 | + if ( ! $link = get_post_type_archive_link( $post_type ) ) { |
|
| 1235 | + return false; |
|
| 1236 | + } |
|
| 1190 | 1237 | |
| 1191 | 1238 | $post_type_obj = get_post_type_object( $post_type ); |
| 1192 | 1239 | if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { |
| 1193 | 1240 | $link = trailingslashit( $link ); |
| 1194 | 1241 | $link .= 'feed/'; |
| 1195 | - if ( $feed != $default_feed ) |
|
| 1196 | - $link .= "$feed/"; |
|
| 1242 | + if ( $feed != $default_feed ) { |
|
| 1243 | + $link .= "$feed/"; |
|
| 1244 | + } |
|
| 1197 | 1245 | } else { |
| 1198 | 1246 | $link = add_query_arg( 'feed', $feed, $link ); |
| 1199 | 1247 | } |
@@ -1265,22 +1313,26 @@ discard block |
||
| 1265 | 1313 | * not allow an editing UI. |
| 1266 | 1314 | */ |
| 1267 | 1315 | function get_edit_post_link( $id = 0, $context = 'display' ) { |
| 1268 | - if ( ! $post = get_post( $id ) ) |
|
| 1269 | - return; |
|
| 1316 | + if ( ! $post = get_post( $id ) ) { |
|
| 1317 | + return; |
|
| 1318 | + } |
|
| 1270 | 1319 | |
| 1271 | - if ( 'revision' === $post->post_type ) |
|
| 1272 | - $action = ''; |
|
| 1273 | - elseif ( 'display' == $context ) |
|
| 1274 | - $action = '&action=edit'; |
|
| 1275 | - else |
|
| 1276 | - $action = '&action=edit'; |
|
| 1320 | + if ( 'revision' === $post->post_type ) { |
|
| 1321 | + $action = ''; |
|
| 1322 | + } elseif ( 'display' == $context ) { |
|
| 1323 | + $action = '&action=edit'; |
|
| 1324 | + } else { |
|
| 1325 | + $action = '&action=edit'; |
|
| 1326 | + } |
|
| 1277 | 1327 | |
| 1278 | 1328 | $post_type_object = get_post_type_object( $post->post_type ); |
| 1279 | - if ( !$post_type_object ) |
|
| 1280 | - return; |
|
| 1329 | + if ( !$post_type_object ) { |
|
| 1330 | + return; |
|
| 1331 | + } |
|
| 1281 | 1332 | |
| 1282 | - if ( !current_user_can( 'edit_post', $post->ID ) ) |
|
| 1283 | - return; |
|
| 1333 | + if ( !current_user_can( 'edit_post', $post->ID ) ) { |
|
| 1334 | + return; |
|
| 1335 | + } |
|
| 1284 | 1336 | |
| 1285 | 1337 | if ( $post_type_object->_edit_link ) { |
| 1286 | 1338 | $link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ); |
@@ -1353,18 +1405,22 @@ discard block |
||
| 1353 | 1405 | * @return string|void The delete post link URL for the given post. |
| 1354 | 1406 | */ |
| 1355 | 1407 | function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) { |
| 1356 | - if ( ! empty( $deprecated ) ) |
|
| 1357 | - _deprecated_argument( __FUNCTION__, '3.0.0' ); |
|
| 1408 | + if ( ! empty( $deprecated ) ) { |
|
| 1409 | + _deprecated_argument( __FUNCTION__, '3.0.0' ); |
|
| 1410 | + } |
|
| 1358 | 1411 | |
| 1359 | - if ( !$post = get_post( $id ) ) |
|
| 1360 | - return; |
|
| 1412 | + if ( !$post = get_post( $id ) ) { |
|
| 1413 | + return; |
|
| 1414 | + } |
|
| 1361 | 1415 | |
| 1362 | 1416 | $post_type_object = get_post_type_object( $post->post_type ); |
| 1363 | - if ( !$post_type_object ) |
|
| 1364 | - return; |
|
| 1417 | + if ( !$post_type_object ) { |
|
| 1418 | + return; |
|
| 1419 | + } |
|
| 1365 | 1420 | |
| 1366 | - if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
| 1367 | - return; |
|
| 1421 | + if ( !current_user_can( 'delete_post', $post->ID ) ) { |
|
| 1422 | + return; |
|
| 1423 | + } |
|
| 1368 | 1424 | |
| 1369 | 1425 | $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash'; |
| 1370 | 1426 | |
@@ -1393,8 +1449,9 @@ discard block |
||
| 1393 | 1449 | function get_edit_comment_link( $comment_id = 0 ) { |
| 1394 | 1450 | $comment = get_comment( $comment_id ); |
| 1395 | 1451 | |
| 1396 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
| 1397 | - return; |
|
| 1452 | + if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
| 1453 | + return; |
|
| 1454 | + } |
|
| 1398 | 1455 | |
| 1399 | 1456 | $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; |
| 1400 | 1457 | |
@@ -1453,8 +1510,9 @@ discard block |
||
| 1453 | 1510 | function get_edit_bookmark_link( $link = 0 ) { |
| 1454 | 1511 | $link = get_bookmark( $link ); |
| 1455 | 1512 | |
| 1456 | - if ( !current_user_can('manage_links') ) |
|
| 1457 | - return; |
|
| 1513 | + if ( !current_user_can('manage_links') ) { |
|
| 1514 | + return; |
|
| 1515 | + } |
|
| 1458 | 1516 | |
| 1459 | 1517 | $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; |
| 1460 | 1518 | |
@@ -1482,11 +1540,13 @@ discard block |
||
| 1482 | 1540 | function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) { |
| 1483 | 1541 | $bookmark = get_bookmark($bookmark); |
| 1484 | 1542 | |
| 1485 | - if ( !current_user_can('manage_links') ) |
|
| 1486 | - return; |
|
| 1543 | + if ( !current_user_can('manage_links') ) { |
|
| 1544 | + return; |
|
| 1545 | + } |
|
| 1487 | 1546 | |
| 1488 | - if ( empty($link) ) |
|
| 1489 | - $link = __('Edit This'); |
|
| 1547 | + if ( empty($link) ) { |
|
| 1548 | + $link = __('Edit This'); |
|
| 1549 | + } |
|
| 1490 | 1550 | |
| 1491 | 1551 | $link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>'; |
| 1492 | 1552 | |
@@ -1510,21 +1570,25 @@ discard block |
||
| 1510 | 1570 | * @return string URL to edit user page or empty string. |
| 1511 | 1571 | */ |
| 1512 | 1572 | function get_edit_user_link( $user_id = null ) { |
| 1513 | - if ( ! $user_id ) |
|
| 1514 | - $user_id = get_current_user_id(); |
|
| 1573 | + if ( ! $user_id ) { |
|
| 1574 | + $user_id = get_current_user_id(); |
|
| 1575 | + } |
|
| 1515 | 1576 | |
| 1516 | - if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) |
|
| 1517 | - return ''; |
|
| 1577 | + if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) { |
|
| 1578 | + return ''; |
|
| 1579 | + } |
|
| 1518 | 1580 | |
| 1519 | 1581 | $user = get_userdata( $user_id ); |
| 1520 | 1582 | |
| 1521 | - if ( ! $user ) |
|
| 1522 | - return ''; |
|
| 1583 | + if ( ! $user ) { |
|
| 1584 | + return ''; |
|
| 1585 | + } |
|
| 1523 | 1586 | |
| 1524 | - if ( get_current_user_id() == $user->ID ) |
|
| 1525 | - $link = get_edit_profile_url( $user->ID ); |
|
| 1526 | - else |
|
| 1527 | - $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1587 | + if ( get_current_user_id() == $user->ID ) { |
|
| 1588 | + $link = get_edit_profile_url( $user->ID ); |
|
| 1589 | + } else { |
|
| 1590 | + $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); |
|
| 1591 | + } |
|
| 1528 | 1592 | |
| 1529 | 1593 | /** |
| 1530 | 1594 | * Filters the user edit link. |
@@ -1588,8 +1652,9 @@ discard block |
||
| 1588 | 1652 | function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1589 | 1653 | global $wpdb; |
| 1590 | 1654 | |
| 1591 | - if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) |
|
| 1592 | - return null; |
|
| 1655 | + if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) { |
|
| 1656 | + return null; |
|
| 1657 | + } |
|
| 1593 | 1658 | |
| 1594 | 1659 | $current_post_date = $post->post_date; |
| 1595 | 1660 | |
@@ -1614,16 +1679,18 @@ discard block |
||
| 1614 | 1679 | $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; |
| 1615 | 1680 | $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); |
| 1616 | 1681 | |
| 1617 | - if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) |
|
| 1618 | - return ''; |
|
| 1682 | + if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { |
|
| 1683 | + return ''; |
|
| 1684 | + } |
|
| 1619 | 1685 | $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
| 1620 | 1686 | |
| 1621 | 1687 | // Remove any exclusions from the term array to include. |
| 1622 | 1688 | $term_array = array_diff( $term_array, (array) $excluded_terms ); |
| 1623 | 1689 | $term_array = array_map( 'intval', $term_array ); |
| 1624 | 1690 | |
| 1625 | - if ( ! $term_array || is_wp_error( $term_array ) ) |
|
| 1626 | - return ''; |
|
| 1691 | + if ( ! $term_array || is_wp_error( $term_array ) ) { |
|
| 1692 | + return ''; |
|
| 1693 | + } |
|
| 1627 | 1694 | |
| 1628 | 1695 | $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; |
| 1629 | 1696 | } |
@@ -1730,19 +1797,22 @@ discard block |
||
| 1730 | 1797 | $query_key = 'adjacent_post_' . md5( $query ); |
| 1731 | 1798 | $result = wp_cache_get( $query_key, 'counts' ); |
| 1732 | 1799 | if ( false !== $result ) { |
| 1733 | - if ( $result ) |
|
| 1734 | - $result = get_post( $result ); |
|
| 1800 | + if ( $result ) { |
|
| 1801 | + $result = get_post( $result ); |
|
| 1802 | + } |
|
| 1735 | 1803 | return $result; |
| 1736 | 1804 | } |
| 1737 | 1805 | |
| 1738 | 1806 | $result = $wpdb->get_var( $query ); |
| 1739 | - if ( null === $result ) |
|
| 1740 | - $result = ''; |
|
| 1807 | + if ( null === $result ) { |
|
| 1808 | + $result = ''; |
|
| 1809 | + } |
|
| 1741 | 1810 | |
| 1742 | 1811 | wp_cache_set( $query_key, $result, 'counts' ); |
| 1743 | 1812 | |
| 1744 | - if ( $result ) |
|
| 1745 | - $result = get_post( $result ); |
|
| 1813 | + if ( $result ) { |
|
| 1814 | + $result = get_post( $result ); |
|
| 1815 | + } |
|
| 1746 | 1816 | |
| 1747 | 1817 | return $result; |
| 1748 | 1818 | } |
@@ -1762,18 +1832,21 @@ discard block |
||
| 1762 | 1832 | * @return string|void The adjacent post relational link URL. |
| 1763 | 1833 | */ |
| 1764 | 1834 | function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 1765 | - if ( $previous && is_attachment() && $post = get_post() ) |
|
| 1766 | - $post = get_post( $post->post_parent ); |
|
| 1767 | - else |
|
| 1768 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1835 | + if ( $previous && is_attachment() && $post = get_post() ) { |
|
| 1836 | + $post = get_post( $post->post_parent ); |
|
| 1837 | + } else { |
|
| 1838 | + $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 1839 | + } |
|
| 1769 | 1840 | |
| 1770 | - if ( empty( $post ) ) |
|
| 1771 | - return; |
|
| 1841 | + if ( empty( $post ) ) { |
|
| 1842 | + return; |
|
| 1843 | + } |
|
| 1772 | 1844 | |
| 1773 | 1845 | $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) ); |
| 1774 | 1846 | |
| 1775 | - if ( empty( $post_title ) ) |
|
| 1776 | - $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1847 | + if ( empty( $post_title ) ) { |
|
| 1848 | + $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 1849 | + } |
|
| 1777 | 1850 | |
| 1778 | 1851 | $date = mysql2date( get_option( 'date_format' ), $post->post_date ); |
| 1779 | 1852 | |
@@ -1881,8 +1954,9 @@ discard block |
||
| 1881 | 1954 | */ |
| 1882 | 1955 | function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) { |
| 1883 | 1956 | $post = get_post(); |
| 1884 | - if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) |
|
| 1885 | - return null; |
|
| 1957 | + if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) { |
|
| 1958 | + return null; |
|
| 1959 | + } |
|
| 1886 | 1960 | |
| 1887 | 1961 | $query_args = array( |
| 1888 | 1962 | 'posts_per_page' => 1, |
@@ -1894,23 +1968,26 @@ discard block |
||
| 1894 | 1968 | $term_array = array(); |
| 1895 | 1969 | |
| 1896 | 1970 | if ( ! is_array( $excluded_terms ) ) { |
| 1897 | - if ( ! empty( $excluded_terms ) ) |
|
| 1898 | - $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1899 | - else |
|
| 1900 | - $excluded_terms = array(); |
|
| 1971 | + if ( ! empty( $excluded_terms ) ) { |
|
| 1972 | + $excluded_terms = explode( ',', $excluded_terms ); |
|
| 1973 | + } else { |
|
| 1974 | + $excluded_terms = array(); |
|
| 1975 | + } |
|
| 1901 | 1976 | } |
| 1902 | 1977 | |
| 1903 | 1978 | if ( $in_same_term || ! empty( $excluded_terms ) ) { |
| 1904 | - if ( $in_same_term ) |
|
| 1905 | - $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1979 | + if ( $in_same_term ) { |
|
| 1980 | + $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); |
|
| 1981 | + } |
|
| 1906 | 1982 | |
| 1907 | 1983 | if ( ! empty( $excluded_terms ) ) { |
| 1908 | 1984 | $excluded_terms = array_map( 'intval', $excluded_terms ); |
| 1909 | 1985 | $excluded_terms = array_diff( $excluded_terms, $term_array ); |
| 1910 | 1986 | |
| 1911 | 1987 | $inverse_terms = array(); |
| 1912 | - foreach ( $excluded_terms as $excluded_term ) |
|
| 1913 | - $inverse_terms[] = $excluded_term * -1; |
|
| 1988 | + foreach ( $excluded_terms as $excluded_term ) { |
|
| 1989 | + $inverse_terms[] = $excluded_term * -1; |
|
| 1990 | + } |
|
| 1914 | 1991 | $excluded_terms = $inverse_terms; |
| 1915 | 1992 | } |
| 1916 | 1993 | |
@@ -2004,18 +2081,20 @@ discard block |
||
| 2004 | 2081 | * @return string The link URL of the previous or next post in relation to the current post. |
| 2005 | 2082 | */ |
| 2006 | 2083 | function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { |
| 2007 | - if ( $previous && is_attachment() ) |
|
| 2008 | - $post = get_post( get_post()->post_parent ); |
|
| 2009 | - else |
|
| 2010 | - $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 2084 | + if ( $previous && is_attachment() ) { |
|
| 2085 | + $post = get_post( get_post()->post_parent ); |
|
| 2086 | + } else { |
|
| 2087 | + $post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ); |
|
| 2088 | + } |
|
| 2011 | 2089 | |
| 2012 | 2090 | if ( ! $post ) { |
| 2013 | 2091 | $output = ''; |
| 2014 | 2092 | } else { |
| 2015 | 2093 | $title = $post->post_title; |
| 2016 | 2094 | |
| 2017 | - if ( empty( $post->post_title ) ) |
|
| 2018 | - $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 2095 | + if ( empty( $post->post_title ) ) { |
|
| 2096 | + $title = $previous ? __( 'Previous Post' ) : __( 'Next Post' ); |
|
| 2097 | + } |
|
| 2019 | 2098 | |
| 2020 | 2099 | /** This filter is documented in wp-includes/post-template.php */ |
| 2021 | 2100 | $title = apply_filters( 'the_title', $title, $post->ID ); |
@@ -2120,8 +2199,9 @@ discard block |
||
| 2120 | 2199 | |
| 2121 | 2200 | $base = trailingslashit( get_bloginfo( 'url' ) ); |
| 2122 | 2201 | |
| 2123 | - if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) |
|
| 2124 | - $base .= $wp_rewrite->index . '/'; |
|
| 2202 | + if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) { |
|
| 2203 | + $base .= $wp_rewrite->index . '/'; |
|
| 2204 | + } |
|
| 2125 | 2205 | |
| 2126 | 2206 | if ( $pagenum > 1 ) { |
| 2127 | 2207 | $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' ); |
@@ -2139,11 +2219,12 @@ discard block |
||
| 2139 | 2219 | */ |
| 2140 | 2220 | $result = apply_filters( 'get_pagenum_link', $result ); |
| 2141 | 2221 | |
| 2142 | - if ( $escape ) |
|
| 2143 | - return esc_url( $result ); |
|
| 2144 | - else |
|
| 2145 | - return esc_url_raw( $result ); |
|
| 2146 | -} |
|
| 2222 | + if ( $escape ) { |
|
| 2223 | + return esc_url( $result ); |
|
| 2224 | + } else { |
|
| 2225 | + return esc_url_raw( $result ); |
|
| 2226 | + } |
|
| 2227 | + } |
|
| 2147 | 2228 | |
| 2148 | 2229 | /** |
| 2149 | 2230 | * Retrieves the next posts page link. |
@@ -2161,11 +2242,13 @@ discard block |
||
| 2161 | 2242 | global $paged; |
| 2162 | 2243 | |
| 2163 | 2244 | if ( !is_single() ) { |
| 2164 | - if ( !$paged ) |
|
| 2165 | - $paged = 1; |
|
| 2245 | + if ( !$paged ) { |
|
| 2246 | + $paged = 1; |
|
| 2247 | + } |
|
| 2166 | 2248 | $nextpage = intval($paged) + 1; |
| 2167 | - if ( !$max_page || $max_page >= $nextpage ) |
|
| 2168 | - return get_pagenum_link($nextpage); |
|
| 2249 | + if ( !$max_page || $max_page >= $nextpage ) { |
|
| 2250 | + return get_pagenum_link($nextpage); |
|
| 2251 | + } |
|
| 2169 | 2252 | } |
| 2170 | 2253 | } |
| 2171 | 2254 | |
@@ -2181,11 +2264,12 @@ discard block |
||
| 2181 | 2264 | function next_posts( $max_page = 0, $echo = true ) { |
| 2182 | 2265 | $output = esc_url( get_next_posts_page_link( $max_page ) ); |
| 2183 | 2266 | |
| 2184 | - if ( $echo ) |
|
| 2185 | - echo $output; |
|
| 2186 | - else |
|
| 2187 | - return $output; |
|
| 2188 | -} |
|
| 2267 | + if ( $echo ) { |
|
| 2268 | + echo $output; |
|
| 2269 | + } else { |
|
| 2270 | + return $output; |
|
| 2271 | + } |
|
| 2272 | + } |
|
| 2189 | 2273 | |
| 2190 | 2274 | /** |
| 2191 | 2275 | * Retrieves the next posts page link. |
@@ -2202,16 +2286,19 @@ discard block |
||
| 2202 | 2286 | function get_next_posts_link( $label = null, $max_page = 0 ) { |
| 2203 | 2287 | global $paged, $wp_query; |
| 2204 | 2288 | |
| 2205 | - if ( !$max_page ) |
|
| 2206 | - $max_page = $wp_query->max_num_pages; |
|
| 2289 | + if ( !$max_page ) { |
|
| 2290 | + $max_page = $wp_query->max_num_pages; |
|
| 2291 | + } |
|
| 2207 | 2292 | |
| 2208 | - if ( !$paged ) |
|
| 2209 | - $paged = 1; |
|
| 2293 | + if ( !$paged ) { |
|
| 2294 | + $paged = 1; |
|
| 2295 | + } |
|
| 2210 | 2296 | |
| 2211 | 2297 | $nextpage = intval($paged) + 1; |
| 2212 | 2298 | |
| 2213 | - if ( null === $label ) |
|
| 2214 | - $label = __( 'Next Page »' ); |
|
| 2299 | + if ( null === $label ) { |
|
| 2300 | + $label = __( 'Next Page »' ); |
|
| 2301 | + } |
|
| 2215 | 2302 | |
| 2216 | 2303 | if ( !is_single() && ( $nextpage <= $max_page ) ) { |
| 2217 | 2304 | /** |
@@ -2257,8 +2344,9 @@ discard block |
||
| 2257 | 2344 | |
| 2258 | 2345 | if ( !is_single() ) { |
| 2259 | 2346 | $nextpage = intval($paged) - 1; |
| 2260 | - if ( $nextpage < 1 ) |
|
| 2261 | - $nextpage = 1; |
|
| 2347 | + if ( $nextpage < 1 ) { |
|
| 2348 | + $nextpage = 1; |
|
| 2349 | + } |
|
| 2262 | 2350 | return get_pagenum_link($nextpage); |
| 2263 | 2351 | } |
| 2264 | 2352 | } |
@@ -2274,11 +2362,12 @@ discard block |
||
| 2274 | 2362 | function previous_posts( $echo = true ) { |
| 2275 | 2363 | $output = esc_url( get_previous_posts_page_link() ); |
| 2276 | 2364 | |
| 2277 | - if ( $echo ) |
|
| 2278 | - echo $output; |
|
| 2279 | - else |
|
| 2280 | - return $output; |
|
| 2281 | -} |
|
| 2365 | + if ( $echo ) { |
|
| 2366 | + echo $output; |
|
| 2367 | + } else { |
|
| 2368 | + return $output; |
|
| 2369 | + } |
|
| 2370 | + } |
|
| 2282 | 2371 | |
| 2283 | 2372 | /** |
| 2284 | 2373 | * Retrieves the previous posts page link. |
@@ -2293,8 +2382,9 @@ discard block |
||
| 2293 | 2382 | function get_previous_posts_link( $label = null ) { |
| 2294 | 2383 | global $paged; |
| 2295 | 2384 | |
| 2296 | - if ( null === $label ) |
|
| 2297 | - $label = __( '« Previous Page' ); |
|
| 2385 | + if ( null === $label ) { |
|
| 2386 | + $label = __( '« Previous Page' ); |
|
| 2387 | + } |
|
| 2298 | 2388 | |
| 2299 | 2389 | if ( !is_single() && $paged > 1 ) { |
| 2300 | 2390 | /** |
@@ -2626,16 +2716,18 @@ discard block |
||
| 2626 | 2716 | |
| 2627 | 2717 | if ( 'newest' == get_option('default_comments_page') ) { |
| 2628 | 2718 | if ( $pagenum != $max_page ) { |
| 2629 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2630 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2631 | - else |
|
| 2632 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2719 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2720 | + $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2721 | + } else { |
|
| 2722 | + $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2723 | + } |
|
| 2633 | 2724 | } |
| 2634 | 2725 | } elseif ( $pagenum > 1 ) { |
| 2635 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2636 | - $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2637 | - else |
|
| 2638 | - $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2726 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2727 | + $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged'); |
|
| 2728 | + } else { |
|
| 2729 | + $result = add_query_arg( 'cpage', $pagenum, $result ); |
|
| 2730 | + } |
|
| 2639 | 2731 | } |
| 2640 | 2732 | |
| 2641 | 2733 | $result .= '#comments'; |
@@ -2664,8 +2756,9 @@ discard block |
||
| 2664 | 2756 | function get_next_comments_link( $label = '', $max_page = 0 ) { |
| 2665 | 2757 | global $wp_query; |
| 2666 | 2758 | |
| 2667 | - if ( ! is_singular() ) |
|
| 2668 | - return; |
|
| 2759 | + if ( ! is_singular() ) { |
|
| 2760 | + return; |
|
| 2761 | + } |
|
| 2669 | 2762 | |
| 2670 | 2763 | $page = get_query_var('cpage'); |
| 2671 | 2764 | |
@@ -2675,17 +2768,21 @@ discard block |
||
| 2675 | 2768 | |
| 2676 | 2769 | $nextpage = intval($page) + 1; |
| 2677 | 2770 | |
| 2678 | - if ( empty($max_page) ) |
|
| 2679 | - $max_page = $wp_query->max_num_comment_pages; |
|
| 2771 | + if ( empty($max_page) ) { |
|
| 2772 | + $max_page = $wp_query->max_num_comment_pages; |
|
| 2773 | + } |
|
| 2680 | 2774 | |
| 2681 | - if ( empty($max_page) ) |
|
| 2682 | - $max_page = get_comment_pages_count(); |
|
| 2775 | + if ( empty($max_page) ) { |
|
| 2776 | + $max_page = get_comment_pages_count(); |
|
| 2777 | + } |
|
| 2683 | 2778 | |
| 2684 | - if ( $nextpage > $max_page ) |
|
| 2685 | - return; |
|
| 2779 | + if ( $nextpage > $max_page ) { |
|
| 2780 | + return; |
|
| 2781 | + } |
|
| 2686 | 2782 | |
| 2687 | - if ( empty($label) ) |
|
| 2688 | - $label = __('Newer Comments »'); |
|
| 2783 | + if ( empty($label) ) { |
|
| 2784 | + $label = __('Newer Comments »'); |
|
| 2785 | + } |
|
| 2689 | 2786 | |
| 2690 | 2787 | /** |
| 2691 | 2788 | * Filters the anchor tag attributes for the next comments page link. |
@@ -2718,18 +2815,21 @@ discard block |
||
| 2718 | 2815 | * @return string|void HTML-formatted link for the previous page of comments. |
| 2719 | 2816 | */ |
| 2720 | 2817 | function get_previous_comments_link( $label = '' ) { |
| 2721 | - if ( ! is_singular() ) |
|
| 2722 | - return; |
|
| 2818 | + if ( ! is_singular() ) { |
|
| 2819 | + return; |
|
| 2820 | + } |
|
| 2723 | 2821 | |
| 2724 | 2822 | $page = get_query_var('cpage'); |
| 2725 | 2823 | |
| 2726 | - if ( intval($page) <= 1 ) |
|
| 2727 | - return; |
|
| 2824 | + if ( intval($page) <= 1 ) { |
|
| 2825 | + return; |
|
| 2826 | + } |
|
| 2728 | 2827 | |
| 2729 | 2828 | $prevpage = intval($page) - 1; |
| 2730 | 2829 | |
| 2731 | - if ( empty($label) ) |
|
| 2732 | - $label = __('« Older Comments'); |
|
| 2830 | + if ( empty($label) ) { |
|
| 2831 | + $label = __('« Older Comments'); |
|
| 2832 | + } |
|
| 2733 | 2833 | |
| 2734 | 2834 | /** |
| 2735 | 2835 | * Filters the anchor tag attributes for the previous comments page link. |
@@ -2766,12 +2866,14 @@ discard block |
||
| 2766 | 2866 | function paginate_comments_links( $args = array() ) { |
| 2767 | 2867 | global $wp_rewrite; |
| 2768 | 2868 | |
| 2769 | - if ( ! is_singular() ) |
|
| 2770 | - return; |
|
| 2869 | + if ( ! is_singular() ) { |
|
| 2870 | + return; |
|
| 2871 | + } |
|
| 2771 | 2872 | |
| 2772 | 2873 | $page = get_query_var('cpage'); |
| 2773 | - if ( !$page ) |
|
| 2774 | - $page = 1; |
|
| 2874 | + if ( !$page ) { |
|
| 2875 | + $page = 1; |
|
| 2876 | + } |
|
| 2775 | 2877 | $max_page = get_comment_pages_count(); |
| 2776 | 2878 | $defaults = array( |
| 2777 | 2879 | 'base' => add_query_arg( 'cpage', '%#%' ), |
@@ -2781,17 +2883,19 @@ discard block |
||
| 2781 | 2883 | 'echo' => true, |
| 2782 | 2884 | 'add_fragment' => '#comments' |
| 2783 | 2885 | ); |
| 2784 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 2785 | - $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2886 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 2887 | + $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged'); |
|
| 2888 | + } |
|
| 2786 | 2889 | |
| 2787 | 2890 | $args = wp_parse_args( $args, $defaults ); |
| 2788 | 2891 | $page_links = paginate_links( $args ); |
| 2789 | 2892 | |
| 2790 | - if ( $args['echo'] ) |
|
| 2791 | - echo $page_links; |
|
| 2792 | - else |
|
| 2793 | - return $page_links; |
|
| 2794 | -} |
|
| 2893 | + if ( $args['echo'] ) { |
|
| 2894 | + echo $page_links; |
|
| 2895 | + } else { |
|
| 2896 | + return $page_links; |
|
| 2897 | + } |
|
| 2898 | + } |
|
| 2795 | 2899 | |
| 2796 | 2900 | /** |
| 2797 | 2901 | * Retrieves navigation to next/previous set of comments, when applicable. |
@@ -3004,16 +3108,18 @@ discard block |
||
| 3004 | 3108 | } |
| 3005 | 3109 | |
| 3006 | 3110 | if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
| 3007 | - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) |
|
| 3008 | - $scheme = 'https'; |
|
| 3009 | - else |
|
| 3010 | - $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 3111 | + if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) { |
|
| 3112 | + $scheme = 'https'; |
|
| 3113 | + } else { |
|
| 3114 | + $scheme = parse_url( $url, PHP_URL_SCHEME ); |
|
| 3115 | + } |
|
| 3011 | 3116 | } |
| 3012 | 3117 | |
| 3013 | 3118 | $url = set_url_scheme( $url, $scheme ); |
| 3014 | 3119 | |
| 3015 | - if ( $path && is_string( $path ) ) |
|
| 3016 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 3120 | + if ( $path && is_string( $path ) ) { |
|
| 3121 | + $url .= '/' . ltrim( $path, '/' ); |
|
| 3122 | + } |
|
| 3017 | 3123 | |
| 3018 | 3124 | /** |
| 3019 | 3125 | * Filters the home URL. |
@@ -3075,8 +3181,9 @@ discard block |
||
| 3075 | 3181 | |
| 3076 | 3182 | $url = set_url_scheme( $url, $scheme ); |
| 3077 | 3183 | |
| 3078 | - if ( $path && is_string( $path ) ) |
|
| 3079 | - $url .= '/' . ltrim( $path, '/' ); |
|
| 3184 | + if ( $path && is_string( $path ) ) { |
|
| 3185 | + $url .= '/' . ltrim( $path, '/' ); |
|
| 3186 | + } |
|
| 3080 | 3187 | |
| 3081 | 3188 | /** |
| 3082 | 3189 | * Filters the site URL. |
@@ -3121,8 +3228,9 @@ discard block |
||
| 3121 | 3228 | function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) { |
| 3122 | 3229 | $url = get_site_url($blog_id, 'wp-admin/', $scheme); |
| 3123 | 3230 | |
| 3124 | - if ( $path && is_string( $path ) ) |
|
| 3125 | - $url .= ltrim( $path, '/' ); |
|
| 3231 | + if ( $path && is_string( $path ) ) { |
|
| 3232 | + $url .= ltrim( $path, '/' ); |
|
| 3233 | + } |
|
| 3126 | 3234 | |
| 3127 | 3235 | /** |
| 3128 | 3236 | * Filters the admin area URL. |
@@ -3149,8 +3257,9 @@ discard block |
||
| 3149 | 3257 | function includes_url( $path = '', $scheme = null ) { |
| 3150 | 3258 | $url = site_url( '/' . WPINC . '/', $scheme ); |
| 3151 | 3259 | |
| 3152 | - if ( $path && is_string( $path ) ) |
|
| 3153 | - $url .= ltrim($path, '/'); |
|
| 3260 | + if ( $path && is_string( $path ) ) { |
|
| 3261 | + $url .= ltrim($path, '/'); |
|
| 3262 | + } |
|
| 3154 | 3263 | |
| 3155 | 3264 | /** |
| 3156 | 3265 | * Filters the URL to the includes directory. |
@@ -3175,8 +3284,9 @@ discard block |
||
| 3175 | 3284 | function content_url( $path = '' ) { |
| 3176 | 3285 | $url = set_url_scheme( WP_CONTENT_URL ); |
| 3177 | 3286 | |
| 3178 | - if ( $path && is_string( $path ) ) |
|
| 3179 | - $url .= '/' . ltrim($path, '/'); |
|
| 3287 | + if ( $path && is_string( $path ) ) { |
|
| 3288 | + $url .= '/' . ltrim($path, '/'); |
|
| 3289 | + } |
|
| 3180 | 3290 | |
| 3181 | 3291 | /** |
| 3182 | 3292 | * Filters the URL to the content directory. |
@@ -3210,22 +3320,25 @@ discard block |
||
| 3210 | 3320 | $plugin = wp_normalize_path( $plugin ); |
| 3211 | 3321 | $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); |
| 3212 | 3322 | |
| 3213 | - if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) |
|
| 3214 | - $url = WPMU_PLUGIN_URL; |
|
| 3215 | - else |
|
| 3216 | - $url = WP_PLUGIN_URL; |
|
| 3323 | + if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) { |
|
| 3324 | + $url = WPMU_PLUGIN_URL; |
|
| 3325 | + } else { |
|
| 3326 | + $url = WP_PLUGIN_URL; |
|
| 3327 | + } |
|
| 3217 | 3328 | |
| 3218 | 3329 | |
| 3219 | 3330 | $url = set_url_scheme( $url ); |
| 3220 | 3331 | |
| 3221 | 3332 | if ( !empty($plugin) && is_string($plugin) ) { |
| 3222 | 3333 | $folder = dirname(plugin_basename($plugin)); |
| 3223 | - if ( '.' != $folder ) |
|
| 3224 | - $url .= '/' . ltrim($folder, '/'); |
|
| 3334 | + if ( '.' != $folder ) { |
|
| 3335 | + $url .= '/' . ltrim($folder, '/'); |
|
| 3336 | + } |
|
| 3225 | 3337 | } |
| 3226 | 3338 | |
| 3227 | - if ( $path && is_string( $path ) ) |
|
| 3228 | - $url .= '/' . ltrim($path, '/'); |
|
| 3339 | + if ( $path && is_string( $path ) ) { |
|
| 3340 | + $url .= '/' . ltrim($path, '/'); |
|
| 3341 | + } |
|
| 3229 | 3342 | |
| 3230 | 3343 | /** |
| 3231 | 3344 | * Filters the URL to the plugins directory. |
@@ -3258,18 +3371,21 @@ discard block |
||
| 3258 | 3371 | * @return string Site URL link with optional path appended. |
| 3259 | 3372 | */ |
| 3260 | 3373 | function network_site_url( $path = '', $scheme = null ) { |
| 3261 | - if ( ! is_multisite() ) |
|
| 3262 | - return site_url($path, $scheme); |
|
| 3374 | + if ( ! is_multisite() ) { |
|
| 3375 | + return site_url($path, $scheme); |
|
| 3376 | + } |
|
| 3263 | 3377 | |
| 3264 | 3378 | $current_site = get_current_site(); |
| 3265 | 3379 | |
| 3266 | - if ( 'relative' == $scheme ) |
|
| 3267 | - $url = $current_site->path; |
|
| 3268 | - else |
|
| 3269 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3380 | + if ( 'relative' == $scheme ) { |
|
| 3381 | + $url = $current_site->path; |
|
| 3382 | + } else { |
|
| 3383 | + $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3384 | + } |
|
| 3270 | 3385 | |
| 3271 | - if ( $path && is_string( $path ) ) |
|
| 3272 | - $url .= ltrim( $path, '/' ); |
|
| 3386 | + if ( $path && is_string( $path ) ) { |
|
| 3387 | + $url .= ltrim( $path, '/' ); |
|
| 3388 | + } |
|
| 3273 | 3389 | |
| 3274 | 3390 | /** |
| 3275 | 3391 | * Filters the network site URL. |
@@ -3300,22 +3416,26 @@ discard block |
||
| 3300 | 3416 | * @return string Home URL link with optional path appended. |
| 3301 | 3417 | */ |
| 3302 | 3418 | function network_home_url( $path = '', $scheme = null ) { |
| 3303 | - if ( ! is_multisite() ) |
|
| 3304 | - return home_url($path, $scheme); |
|
| 3419 | + if ( ! is_multisite() ) { |
|
| 3420 | + return home_url($path, $scheme); |
|
| 3421 | + } |
|
| 3305 | 3422 | |
| 3306 | 3423 | $current_site = get_current_site(); |
| 3307 | 3424 | $orig_scheme = $scheme; |
| 3308 | 3425 | |
| 3309 | - if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) |
|
| 3310 | - $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
|
| 3426 | + if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { |
|
| 3427 | + $scheme = is_ssl() && ! is_admin() ? 'https' : 'http'; |
|
| 3428 | + } |
|
| 3311 | 3429 | |
| 3312 | - if ( 'relative' == $scheme ) |
|
| 3313 | - $url = $current_site->path; |
|
| 3314 | - else |
|
| 3315 | - $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3430 | + if ( 'relative' == $scheme ) { |
|
| 3431 | + $url = $current_site->path; |
|
| 3432 | + } else { |
|
| 3433 | + $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme ); |
|
| 3434 | + } |
|
| 3316 | 3435 | |
| 3317 | - if ( $path && is_string( $path ) ) |
|
| 3318 | - $url .= ltrim( $path, '/' ); |
|
| 3436 | + if ( $path && is_string( $path ) ) { |
|
| 3437 | + $url .= ltrim( $path, '/' ); |
|
| 3438 | + } |
|
| 3319 | 3439 | |
| 3320 | 3440 | /** |
| 3321 | 3441 | * Filters the network home URL. |
@@ -3342,13 +3462,15 @@ discard block |
||
| 3342 | 3462 | * @return string Admin URL link with optional path appended. |
| 3343 | 3463 | */ |
| 3344 | 3464 | function network_admin_url( $path = '', $scheme = 'admin' ) { |
| 3345 | - if ( ! is_multisite() ) |
|
| 3346 | - return admin_url( $path, $scheme ); |
|
| 3465 | + if ( ! is_multisite() ) { |
|
| 3466 | + return admin_url( $path, $scheme ); |
|
| 3467 | + } |
|
| 3347 | 3468 | |
| 3348 | 3469 | $url = network_site_url('wp-admin/network/', $scheme); |
| 3349 | 3470 | |
| 3350 | - if ( $path && is_string( $path ) ) |
|
| 3351 | - $url .= ltrim($path, '/'); |
|
| 3471 | + if ( $path && is_string( $path ) ) { |
|
| 3472 | + $url .= ltrim($path, '/'); |
|
| 3473 | + } |
|
| 3352 | 3474 | |
| 3353 | 3475 | /** |
| 3354 | 3476 | * Filters the network admin URL. |
@@ -3375,8 +3497,9 @@ discard block |
||
| 3375 | 3497 | function user_admin_url( $path = '', $scheme = 'admin' ) { |
| 3376 | 3498 | $url = network_site_url('wp-admin/user/', $scheme); |
| 3377 | 3499 | |
| 3378 | - if ( $path && is_string( $path ) ) |
|
| 3379 | - $url .= ltrim($path, '/'); |
|
| 3500 | + if ( $path && is_string( $path ) ) { |
|
| 3501 | + $url .= ltrim($path, '/'); |
|
| 3502 | + } |
|
| 3380 | 3503 | |
| 3381 | 3504 | /** |
| 3382 | 3505 | * Filters the user admin URL for the current user. |
@@ -3401,13 +3524,14 @@ discard block |
||
| 3401 | 3524 | * @return string Admin URL link with optional path appended. |
| 3402 | 3525 | */ |
| 3403 | 3526 | function self_admin_url( $path = '', $scheme = 'admin' ) { |
| 3404 | - if ( is_network_admin() ) |
|
| 3405 | - return network_admin_url($path, $scheme); |
|
| 3406 | - elseif ( is_user_admin() ) |
|
| 3407 | - return user_admin_url($path, $scheme); |
|
| 3408 | - else |
|
| 3409 | - return admin_url($path, $scheme); |
|
| 3410 | -} |
|
| 3527 | + if ( is_network_admin() ) { |
|
| 3528 | + return network_admin_url($path, $scheme); |
|
| 3529 | + } elseif ( is_user_admin() ) { |
|
| 3530 | + return user_admin_url($path, $scheme); |
|
| 3531 | + } else { |
|
| 3532 | + return admin_url($path, $scheme); |
|
| 3533 | + } |
|
| 3534 | + } |
|
| 3411 | 3535 | |
| 3412 | 3536 | /** |
| 3413 | 3537 | * Sets the scheme for a URL. |
@@ -3432,13 +3556,15 @@ discard block |
||
| 3432 | 3556 | } |
| 3433 | 3557 | |
| 3434 | 3558 | $url = trim( $url ); |
| 3435 | - if ( substr( $url, 0, 2 ) === '//' ) |
|
| 3436 | - $url = 'http:' . $url; |
|
| 3559 | + if ( substr( $url, 0, 2 ) === '//' ) { |
|
| 3560 | + $url = 'http:' . $url; |
|
| 3561 | + } |
|
| 3437 | 3562 | |
| 3438 | 3563 | if ( 'relative' == $scheme ) { |
| 3439 | 3564 | $url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) ); |
| 3440 | - if ( $url !== '' && $url[0] === '/' ) |
|
| 3441 | - $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3565 | + if ( $url !== '' && $url[0] === '/' ) { |
|
| 3566 | + $url = '/' . ltrim($url , "/ \t\n\r\0\x0B" ); |
|
| 3567 | + } |
|
| 3442 | 3568 | } else { |
| 3443 | 3569 | $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); |
| 3444 | 3570 | } |
@@ -3486,10 +3612,11 @@ discard block |
||
| 3486 | 3612 | $url = admin_url( $path, $scheme ); |
| 3487 | 3613 | } else { |
| 3488 | 3614 | $active = get_active_blog_for_user( $user_id ); |
| 3489 | - if ( $active ) |
|
| 3490 | - $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3491 | - else |
|
| 3492 | - $url = user_admin_url( $path, $scheme ); |
|
| 3615 | + if ( $active ) { |
|
| 3616 | + $url = get_admin_url( $active->blog_id, $path, $scheme ); |
|
| 3617 | + } else { |
|
| 3618 | + $url = user_admin_url( $path, $scheme ); |
|
| 3619 | + } |
|
| 3493 | 3620 | } |
| 3494 | 3621 | } |
| 3495 | 3622 | |
@@ -3520,12 +3647,13 @@ discard block |
||
| 3520 | 3647 | function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) { |
| 3521 | 3648 | $user_id = $user_id ? (int) $user_id : get_current_user_id(); |
| 3522 | 3649 | |
| 3523 | - if ( is_user_admin() ) |
|
| 3524 | - $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3525 | - elseif ( is_network_admin() ) |
|
| 3526 | - $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3527 | - else |
|
| 3528 | - $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3650 | + if ( is_user_admin() ) { |
|
| 3651 | + $url = user_admin_url( 'profile.php', $scheme ); |
|
| 3652 | + } elseif ( is_network_admin() ) { |
|
| 3653 | + $url = network_admin_url( 'profile.php', $scheme ); |
|
| 3654 | + } else { |
|
| 3655 | + $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); |
|
| 3656 | + } |
|
| 3529 | 3657 | |
| 3530 | 3658 | /** |
| 3531 | 3659 | * Filters the URL for a user's profile editor. |
@@ -3663,8 +3791,9 @@ discard block |
||
| 3663 | 3791 | $post = get_post( $post_id ); |
| 3664 | 3792 | } elseif ( 'post' == $context ) { |
| 3665 | 3793 | $post = get_post( $id ); |
| 3666 | - if ( ! empty( $post->ID ) ) |
|
| 3667 | - $post_id = $post->ID; |
|
| 3794 | + if ( ! empty( $post->ID ) ) { |
|
| 3795 | + $post_id = $post->ID; |
|
| 3796 | + } |
|
| 3668 | 3797 | } |
| 3669 | 3798 | |
| 3670 | 3799 | $shortlink = ''; |
@@ -3703,8 +3832,9 @@ discard block |
||
| 3703 | 3832 | function wp_shortlink_wp_head() { |
| 3704 | 3833 | $shortlink = wp_get_shortlink( 0, 'query' ); |
| 3705 | 3834 | |
| 3706 | - if ( empty( $shortlink ) ) |
|
| 3707 | - return; |
|
| 3835 | + if ( empty( $shortlink ) ) { |
|
| 3836 | + return; |
|
| 3837 | + } |
|
| 3708 | 3838 | |
| 3709 | 3839 | echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n"; |
| 3710 | 3840 | } |
@@ -3717,13 +3847,15 @@ discard block |
||
| 3717 | 3847 | * @since 3.0.0 |
| 3718 | 3848 | */ |
| 3719 | 3849 | function wp_shortlink_header() { |
| 3720 | - if ( headers_sent() ) |
|
| 3721 | - return; |
|
| 3850 | + if ( headers_sent() ) { |
|
| 3851 | + return; |
|
| 3852 | + } |
|
| 3722 | 3853 | |
| 3723 | 3854 | $shortlink = wp_get_shortlink(0, 'query'); |
| 3724 | 3855 | |
| 3725 | - if ( empty($shortlink) ) |
|
| 3726 | - return; |
|
| 3856 | + if ( empty($shortlink) ) { |
|
| 3857 | + return; |
|
| 3858 | + } |
|
| 3727 | 3859 | |
| 3728 | 3860 | header('Link: <' . $shortlink . '>; rel=shortlink', false); |
| 3729 | 3861 | } |
@@ -3745,11 +3877,13 @@ discard block |
||
| 3745 | 3877 | function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { |
| 3746 | 3878 | $post = get_post(); |
| 3747 | 3879 | |
| 3748 | - if ( empty( $text ) ) |
|
| 3749 | - $text = __('This is the short link.'); |
|
| 3880 | + if ( empty( $text ) ) { |
|
| 3881 | + $text = __('This is the short link.'); |
|
| 3882 | + } |
|
| 3750 | 3883 | |
| 3751 | - if ( empty( $title ) ) |
|
| 3752 | - $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3884 | + if ( empty( $title ) ) { |
|
| 3885 | + $title = the_title_attribute( array( 'echo' => false ) ); |
|
| 3886 | + } |
|
| 3753 | 3887 | |
| 3754 | 3888 | $shortlink = wp_get_shortlink( $post->ID ); |
| 3755 | 3889 | |