Make WordPress Core

Ticket #56399: 56399.diff

File 56399.diff, 2.1 KB (added by xmic, 4 years ago)
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index b434ae52e4..3f6260e586 100644
    a b function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {  
    57575757 *
    57585758 * @global wpdb $wpdb WordPress database abstraction object.
    57595759 *
    5760  * @param string       $page_title Page title.
    5761  * @param string       $output     Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
    5762  *                                 correspond to a WP_Post object, an associative array, or a numeric array,
    5763  *                                 respectively. Default OBJECT.
    5764  * @param string|array $post_type  Optional. Post type or array of post types. Default 'page'.
     5760 * @param string       $page_title  Page title.
     5761 * @param string       $output      Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
     5762 *                                  correspond to a WP_Post object, an associative array, or a numeric array,
     5763 *                                  respectively. Default OBJECT.
     5764 * @param string|array $post_type   Optional. Post type or array of post types. Default 'page'.
     5765 * @param string|array $post_status Optional. Post status or array of post statuses. Default 'publish'.
    57655766 * @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
    57665767 */
    5767 function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) {
     5768function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page', $post_status = 'publish' ) {
    57685769        global $wpdb;
    57695770
    57705771        if ( is_array( $post_type ) ) {
    … … function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' )  
    57925793                );
    57935794        }
    57945795
     5796        if ( is_array( $post_status ) ) {
     5797                $post_status           = esc_sql( $post_status );
     5798                $post_status_in_string = "'" . implode( "','", $post_status ) . "'";
     5799
     5800                $sql .= $wpdb->prepare( " AND post_status IN ($post_status_in_string)", null );
     5801        } else {
     5802                $sql .= $wpdb->prepare( " AND post_status = %s", $post_status );
     5803        }
     5804
    57955805        $page = $wpdb->get_var( $sql );
    57965806
    57975807        if ( $page ) {