wp/wp-includes/canonical.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   845  *
   845  *
   846  * @param string $url The URL to strip.
   846  * @param string $url The URL to strip.
   847  * @return string The altered URL.
   847  * @return string The altered URL.
   848  */
   848  */
   849 function strip_fragment_from_url( $url ) {
   849 function strip_fragment_from_url( $url ) {
   850 	$parsed_url = parse_url( $url );
   850 	$parsed_url = wp_parse_url( $url );
   851 
   851 
   852 	if ( ! empty( $parsed_url['host'] ) ) {
   852 	if ( ! empty( $parsed_url['host'] ) ) {
   853 		// This mirrors code in redirect_canonical(). It does not handle every case.
   853 		$url = '';
   854 		$url = $parsed_url['scheme'] . '://' . $parsed_url['host'];
   854 
       
   855 		if ( ! empty( $parsed_url['scheme'] ) ) {
       
   856 			$url = $parsed_url['scheme'] . ':';
       
   857 		}
       
   858 
       
   859 		$url .= '//' . $parsed_url['host'];
       
   860 
   855 		if ( ! empty( $parsed_url['port'] ) ) {
   861 		if ( ! empty( $parsed_url['port'] ) ) {
   856 			$url .= ':' . $parsed_url['port'];
   862 			$url .= ':' . $parsed_url['port'];
   857 		}
   863 		}
   858 
   864 
   859 		if ( ! empty( $parsed_url['path'] ) ) {
   865 		if ( ! empty( $parsed_url['path'] ) ) {
   949 		}
   955 		}
   950 		if ( get_query_var( 'day' ) ) {
   956 		if ( get_query_var( 'day' ) ) {
   951 			$where .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) );
   957 			$where .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) );
   952 		}
   958 		}
   953 
   959 
       
   960 		$publicly_viewable_statuses = array_filter( get_post_stati(), 'is_post_status_viewable' );
   954 		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
   961 		// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
   955 		$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" );
   962 		$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", esc_sql( $publicly_viewable_statuses ) ) . "')" );
   956 
   963 
   957 		if ( ! $post_id ) {
   964 		if ( ! $post_id ) {
   958 			return false;
   965 			return false;
   959 		}
   966 		}
   960 
   967