sanitize_relation example


    public function __construct( $date_query$default_column = 'post_date' ) {
        if ( empty( $date_query ) || ! is_array( $date_query ) ) {
            return;
        }

        if ( isset( $date_query['relation'] ) ) {
            $this->relation = $this->sanitize_relation( $date_query['relation'] );
        } else {
            $this->relation = 'AND';
        }

        // Support for passing time-based keys in the top level of the $date_query array.         if ( ! isset( $date_query[0] ) ) {
            $date_query = array( $date_query );
        }

        if ( ! empty( $date_query['column'] ) ) {
            $date_query['column'] = esc_sql( $date_query['column'] );
        }

    public function __construct( $tax_query ) {
        if ( isset( $tax_query['relation'] ) ) {
            $this->relation = $this->sanitize_relation( $tax_query['relation'] );
        } else {
            $this->relation = 'AND';
        }

        $this->queries = $this->sanitize_query( $tax_query );
    }

    /** * Ensures the 'tax_query' argument passed to the class constructor is well-formed. * * Ensures that each query-level clause has a 'relation' key, and that * each first-order clause contains all the necessary keys from `$defaults`. * * @since 4.1.0 * * @param array $queries Array of queries clauses. * @return array Sanitized array of query clauses. */
Home | Imprint | This part of the site doesn't use cookies.