Changeset 42401
- Timestamp:
- 12/15/2017 08:30:50 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r42343 r42401 355 355 add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 ); 356 356 357 358 359 360 357 361 // Nonce check for Post Previews 358 362 add_action( 'init', '_show_post_preview' ); -
trunk/src/wp-includes/post.php
r42398 r42401 5709 5709 5710 5710 /** 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5711 5752 * Retrieve the private post SQL based on capability. 5712 5753 * -
trunk/src/wp-includes/query.php
r42355 r42401 846 846 * 847 847 * @since 2.1.0 848 *849 * @global wpdb $wpdb WordPress database abstraction object.850 848 */ 851 849 function wp_old_slug_redirect() { 852 850 if ( is_404() && '' !== get_query_var( 'name' ) ) { 853 global $wpdb;854 855 851 // Guess the current post_type based on the query vars. 856 852 if ( get_query_var( 'post_type' ) ) { … … 876 872 } 877 873 878 $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, get_query_var( 'name' ) ); 879 880 // if year, monthnum, or day have been specified, make our query more precise 881 // just in case there are multiple identical _wp_old_slug values 882 if ( get_query_var( 'year' ) ) { 883 $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', get_query_var( 'year' ) ); 874 $id = _find_post_by_old_slug( $post_type ); 875 876 if ( ! $id ) { 877 $id = _find_post_by_old_date( $post_type ); 884 878 } 885 if ( get_query_var( 'monthnum' ) ) { 886 $query .= $wpdb->prepare( ' AND MONTH(post_date) = %d', get_query_var( 'monthnum' ) ); 887 } 888 if ( get_query_var( 'day' ) ) { 889 $query .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) ); 890 } 891 892 $id = (int) $wpdb->get_var( $query ); 879 880 /** 881 * Filters the old slug redirect post ID. 882 * 883 * @since 4.9.2 884 * 885 * @param string $id The redirect post ID. 886 */ 887 $id = apply_filters( 'old_slug_redirect_post_id', $id ); 893 888 894 889 if ( ! $id ) { … … 923 918 924 919 /** 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 925 996 * Set up global post data. 926 997 *
Note: See TracChangeset
for help on using the changeset viewer.