Changeset 47550 for trunk/src/wp-includes/post.php
- Timestamp:
- 04/05/2020 03:00:44 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r47461 r47550 816 816 while ( $ancestor = get_post( $id ) ) { 817 817 // Loop detection: If the ancestor has been seen before, break. 818 if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) ) {818 if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) { 819 819 break; 820 820 } … … 1617 1617 1618 1618 foreach ( $capabilities as $core => $custom ) { 1619 if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) {1619 if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ), true ) ) { 1620 1620 $post_type_meta_caps[ $custom ] = $core; 1621 1621 } … … 2363 2363 function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) { 2364 2364 $int_fields = array( 'ID', 'post_parent', 'menu_order' ); 2365 if ( in_array( $field, $int_fields ) ) {2365 if ( in_array( $field, $int_fields, true ) ) { 2366 2366 $value = (int) $value; 2367 2367 } … … 2369 2369 // Fields which contain arrays of integers. 2370 2370 $array_int_fields = array( 'ancestors' ); 2371 if ( in_array( $field, $array_int_fields ) ) {2371 if ( in_array( $field, $array_int_fields, true ) ) { 2372 2372 $value = array_map( 'absint', $value ); 2373 2373 return $value; … … 2418 2418 } 2419 2419 2420 if ( in_array( $field, $format_to_edit ) ) {2420 if ( in_array( $field, $format_to_edit, true ) ) { 2421 2421 if ( 'post_content' == $field ) { 2422 2422 $value = format_to_edit( $value, user_can_richedit() ); … … 2779 2779 2780 2780 foreach ( $post_mime_types as $group => $labels ) { 2781 if ( in_array( $group, array( 'image', 'audio', 'video' ) ) ) {2781 if ( in_array( $group, array( 'image', 'audio', 'video' ), true ) ) { 2782 2782 continue; 2783 2783 } … … 2905 2905 $mime_pattern = preg_replace( '/\*+/', '%', $mime_pattern ); 2906 2906 2907 if ( in_array( $mime_type, $wildcards ) ) {2907 if ( in_array( $mime_type, $wildcards, true ) ) { 2908 2908 return ''; 2909 2909 } … … 3698 3698 */ 3699 3699 if ( empty( $post_name ) ) { 3700 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {3700 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) ) { 3701 3701 $post_name = sanitize_title( $post_title ); 3702 3702 } else { … … 3947 3947 } 3948 3948 3949 if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {3949 if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) { 3950 3950 $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent ); 3951 3951 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); … … 4200 4200 4201 4201 // Drafts shouldn't be assigned a date unless explicitly done so by the user. 4202 if ( isset( $post['post_status'] ) && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) && empty( $postarr['edit_date'] ) && 4203 ( '0000-00-00 00:00:00' == $post['post_date_gmt'] ) ) { 4202 if ( isset( $post['post_status'] ) 4203 && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) 4204 && empty( $postarr['edit_date'] ) && ( '0000-00-00 00:00:00' == $post['post_date_gmt'] ) 4205 ) { 4204 4206 $clear_date = true; 4205 4207 } else { … … 4331 4333 */ 4332 4334 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { 4333 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type ) { 4335 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) 4336 || ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type 4337 ) { 4334 4338 return $slug; 4335 4339 } … … 4377 4381 * @param string $slug The post slug. 4378 4382 */ 4379 if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 4383 $is_bad_attachment_slug = apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ); 4384 4385 if ( $post_name_check 4386 || in_array( $slug, $feeds, true ) || 'embed' === $slug 4387 || $is_bad_attachment_slug 4388 ) { 4380 4389 $suffix = 2; 4381 4390 do { … … 4408 4417 * @param int $post_parent Post parent ID. 4409 4418 */ 4410 if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) { 4419 $is_bad_hierarchical_slug = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ); 4420 4421 if ( $post_name_check 4422 || in_array( $slug, $feeds, true ) || 'embed' === $slug 4423 || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) 4424 || $is_bad_hierarchical_slug 4425 ) { 4411 4426 $suffix = 2; 4412 4427 do { … … 4457 4472 * @param string $post_type Post type. 4458 4473 */ 4459 if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 4474 $is_bad_flat_slug = apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ); 4475 4476 if ( $post_name_check 4477 || in_array( $slug, $feeds, true ) || 'embed' === $slug 4478 || $conflicts_with_date_archive 4479 || $is_bad_flat_slug 4480 ) { 4460 4481 $suffix = 2; 4461 4482 do { … … 5266 5287 // Make sure the post type is hierarchical. 5267 5288 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 5268 if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types ) ) {5289 if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types, true ) ) { 5269 5290 return false; 5270 5291 } … … 5404 5425 foreach ( explode( ',', $parsed_args['sort_column'] ) as $orderby ) { 5405 5426 $orderby = trim( $orderby ); 5406 if ( ! in_array( $orderby, $allowed_keys ) ) {5427 if ( ! in_array( $orderby, $allowed_keys, true ) ) { 5407 5428 continue; 5408 5429 } … … 5434 5455 5435 5456 $sort_order = strtoupper( $parsed_args['sort_order'] ); 5436 if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {5457 if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ), true ) ) { 5437 5458 $sort_order = 'ASC'; 5438 5459 } … … 6070 6091 case 'image': 6071 6092 $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); 6072 return in_array( $ext, $image_exts );6093 return in_array( $ext, $image_exts, true ); 6073 6094 6074 6095 case 'audio': 6075 return in_array( $ext, wp_get_audio_extensions() );6096 return in_array( $ext, wp_get_audio_extensions(), true ); 6076 6097 6077 6098 case 'video': 6078 return in_array( $ext, wp_get_video_extensions() );6099 return in_array( $ext, wp_get_video_extensions(), true ); 6079 6100 6080 6101 default: … … 6180 6201 continue; 6181 6202 } 6182 if ( ! in_array( strtolower( substr( $file, -4 ) ), array( '.png', '.gif', '.jpg' ) ) ) { 6203 6204 $ext = strtolower( substr( $file, -4 ) ); 6205 if ( ! in_array( $ext, array( '.png', '.gif', '.jpg' ), true ) ) { 6183 6206 if ( is_dir( "$dir/$file" ) ) { 6184 6207 $dirs[ "$dir/$file" ] = "$uri/$file"; … … 6270 6293 6271 6294 // If we haven't added this old slug before, add it now. 6272 if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs ) ) {6295 if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs, true ) ) { 6273 6296 add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name ); 6274 6297 } 6275 6298 6276 6299 // If the new slug was used previously, delete it from the list. 6277 if ( in_array( $post->post_name, $old_slugs ) ) {6300 if ( in_array( $post->post_name, $old_slugs, true ) ) { 6278 6301 delete_post_meta( $post_id, '_wp_old_slug', $post->post_name ); 6279 6302 } … … 6302 6325 $previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) ); 6303 6326 $new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) ); 6327 6304 6328 // Don't bother if it hasn't changed. 6305 6329 if ( $new_date == $previous_date ) { 6306 6330 return; 6307 6331 } 6332 6308 6333 // We're only concerned with published, non-hierarchical objects. 6309 6334 if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) { 6310 6335 return; 6311 6336 } 6337 6312 6338 $old_dates = (array) get_post_meta( $post_id, '_wp_old_date' ); 6339 6313 6340 // If we haven't added this old date before, add it now. 6314 if ( ! empty( $previous_date ) && ! in_array( $previous_date, $old_dates ) ) {6341 if ( ! empty( $previous_date ) && ! in_array( $previous_date, $old_dates, true ) ) { 6315 6342 add_post_meta( $post_id, '_wp_old_date', $previous_date ); 6316 6343 } 6344 6317 6345 // If the new slug was used previously, delete it from the list. 6318 if ( in_array( $new_date, $old_dates ) ) {6346 if ( in_array( $new_date, $old_dates, true ) ) { 6319 6347 delete_post_meta( $post_id, '_wp_old_date', $new_date ); 6320 6348 } … … 6525 6553 global $wpdb; 6526 6554 6527 if ( ! in_array( $field, array( 'date', 'modified' ) ) ) {6555 if ( ! in_array( $field, array( 'date', 'modified' ), true ) ) { 6528 6556 return false; 6529 6557 }
Note: See TracChangeset
for help on using the changeset viewer.