Changeset 47557 for trunk/src/wp-includes/post.php
- Timestamp:
- 04/09/2020 03:41:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r47550 r47557 2285 2285 $stickies = get_option( 'sticky_posts' ); 2286 2286 2287 $is_sticky = is_array( $stickies ) && in_array( $post_id, $stickies ); 2287 if ( is_array( $stickies ) ) { 2288 $stickies = array_map( 'intval', $stickies ); 2289 $is_sticky = in_array( $post_id, $stickies, true ); 2290 } else { 2291 $is_sticky = false; 2292 } 2288 2293 2289 2294 /** … … 2512 2517 */ 2513 2518 function stick_post( $post_id ) { 2519 $post_id = (int) $post_id; 2514 2520 $stickies = get_option( 'sticky_posts' ); 2515 2521 2516 2522 if ( ! is_array( $stickies ) ) { 2517 $stickies = array( $post_id ); 2518 } 2519 2520 if ( ! in_array( $post_id, $stickies ) ) { 2523 $stickies = array(); 2524 } 2525 2526 $stickies = array_map( 'intval', $stickies ); 2527 2528 if ( ! in_array( $post_id, $stickies, true ) ) { 2521 2529 $stickies[] = $post_id; 2522 2530 } … … 2546 2554 */ 2547 2555 function unstick_post( $post_id ) { 2556 $post_id = (int) $post_id; 2548 2557 $stickies = get_option( 'sticky_posts' ); 2549 2558 … … 2552 2561 } 2553 2562 2554 if ( ! in_array( $post_id, $stickies ) ) { 2563 $stickies = array_map( 'intval', $stickies ); 2564 2565 if ( ! in_array( $post_id, $stickies, true ) ) { 2555 2566 return; 2556 2567 } 2557 2568 2558 $offset = array_search( $post_id, $stickies );2569 $offset = array_search( $post_id, $stickies, true ); 2559 2570 if ( false === $offset ) { 2560 2571 return; … … 2842 2853 $mimes = array_map( 'trim', explode( ',', $type ) ); 2843 2854 foreach ( $mimes as $mime ) { 2844 $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) ); 2855 $regex = str_replace( '__wildcard__', $wild, preg_quote( str_replace( '*', '__wildcard__', $mime ) ) ); 2856 2845 2857 $patternses[][ $type ] = "^$regex$"; 2858 2846 2859 if ( false === strpos( $mime, '/' ) ) { 2847 2860 $patternses[][ $type ] = "^$regex/"; … … 2855 2868 foreach ( $patterns as $type => $pattern ) { 2856 2869 foreach ( (array) $real_mime_types as $real ) { 2857 if ( preg_match( "#$pattern#", $real ) && ( empty( $matches[ $type ] ) || false === array_search( $real, $matches[ $type ] ) ) ) { 2870 if ( preg_match( "#$pattern#", $real ) 2871 && ( empty( $matches[ $type ] ) || false === array_search( $real, $matches[ $type ], true ) ) 2872 ) { 2858 2873 $matches[ $type ][] = $real; 2859 2874 } … … 2861 2876 } 2862 2877 } 2878 2863 2879 return $matches; 2864 2880 } … … 2915 2931 } 2916 2932 } 2933 2917 2934 if ( ! empty( $wheres ) ) { 2918 2935 $where = ' AND (' . join( ' OR ', $wheres ) . ') '; 2919 2936 } 2937 2920 2938 return $where; 2921 2939 } … … 4437 4455 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 4438 4456 4457 $post = get_post( $post_ID ); 4458 4439 4459 // Prevent new post slugs that could result in URLs that conflict with date archives. 4440 $post = get_post( $post_ID );4441 4460 $conflicts_with_date_archive = false; 4442 4461 if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) { … … 4445 4464 if ( $slug_num ) { 4446 4465 $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); 4447 $postname_index = array_search( '%postname%', $permastructs );4466 $postname_index = array_search( '%postname%', $permastructs, true ); 4448 4467 4449 4468 /* … … 5501 5520 $num_pages = count( $pages ); 5502 5521 for ( $i = 0; $i < $num_pages; $i++ ) { 5503 if ( in_array( $pages[ $i ]->ID, $exclude ) ) {5522 if ( in_array( $pages[ $i ]->ID, $exclude, true ) ) { 5504 5523 unset( $pages[ $i ] ); 5505 5524 } … … 5812 5831 function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) { 5813 5832 $attachment_id = (int) $attachment_id; 5814 $post = get_post( $attachment_id ); 5833 5834 $post = get_post( $attachment_id ); 5815 5835 if ( ! $post ) { 5816 5836 return false; … … 5846 5866 function wp_update_attachment_metadata( $attachment_id, $data ) { 5847 5867 $attachment_id = (int) $attachment_id; 5848 $post = get_post( $attachment_id ); 5868 5869 $post = get_post( $attachment_id ); 5849 5870 if ( ! $post ) { 5850 5871 return false; … … 5879 5900 function wp_get_attachment_url( $attachment_id = 0 ) { 5880 5901 $attachment_id = (int) $attachment_id; 5881 $post = get_post( $attachment_id ); 5902 5903 $post = get_post( $attachment_id ); 5882 5904 if ( ! $post ) { 5883 5905 return false;
Note: See TracChangeset
for help on using the changeset viewer.