sanitize_query example


    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. */
if ( ! empty( $date_query['column'] ) ) {
            $date_query['column'] = esc_sql( $date_query['column'] );
        } else {
            $date_query['column'] = esc_sql( $default_column );
        }

        $this->column = $this->validate_column( $this->column );

        $this->compare = $this->get_compare( $date_query );

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

    /** * Recursive-friendly query sanitizer. * * 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 * @param array $parent_query * @return array Sanitized queries. */
public function __construct( $meta_query = false ) {
        if ( ! $meta_query ) {
            return;
        }

        if ( isset( $meta_query['relation'] ) && 'OR' === strtoupper( $meta_query['relation'] ) ) {
            $this->relation = 'OR';
        } else {
            $this->relation = 'AND';
        }

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

    /** * Ensures the 'meta_query' argument passed to the class constructor is well-formed. * * Eliminates empty items and ensures that a 'relation' is set. * * @since 4.1.0 * * @param array $queries Array of query clauses. * @return array Sanitized array of query clauses. */
Home | Imprint | This part of the site doesn't use cookies.