2011-09-16 08:10:12 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-11-03 13:53:50 +00:00
|
|
|
* Contains the query functions for WooCommerce which alter the front-end post queries and loops
|
2011-09-16 08:10:12 +00:00
|
|
|
*
|
2012-01-27 16:38:39 +00:00
|
|
|
* @class WC_Query
|
2016-02-09 21:14:55 +00:00
|
|
|
* @version 2.6.0
|
2012-08-14 22:43:48 +00:00
|
|
|
* @package WooCommerce/Classes
|
2013-02-20 17:14:46 +00:00
|
|
|
* @category Class
|
2012-08-14 19:42:38 +00:00
|
|
|
* @author WooThemes
|
2011-09-16 08:10:12 +00:00
|
|
|
*/
|
2013-07-23 16:05:01 +00:00
|
|
|
|
2014-09-20 18:58:54 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2015-01-28 17:50:58 +00:00
|
|
|
exit;
|
2014-09-20 18:58:54 +00:00
|
|
|
}
|
2013-07-23 16:05:01 +00:00
|
|
|
|
|
|
|
if ( ! class_exists( 'WC_Query' ) ) :
|
|
|
|
|
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* WC_Query Class.
|
2013-07-23 16:05:01 +00:00
|
|
|
*/
|
2012-01-27 16:38:39 +00:00
|
|
|
class WC_Query {
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-06-04 16:33:43 +00:00
|
|
|
/** @public array Query vars to add to wp */
|
2013-09-03 15:14:56 +00:00
|
|
|
public $query_vars = array();
|
2013-06-04 16:33:43 +00:00
|
|
|
|
2016-02-10 10:19:32 +00:00
|
|
|
/**
|
|
|
|
* Stores chosen attributes
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private static $_chosen_attributes;
|
|
|
|
|
2012-08-14 19:42:38 +00:00
|
|
|
/**
|
2012-08-15 17:08:42 +00:00
|
|
|
* Constructor for the query class. Hooks in methods.
|
2012-08-14 19:42:38 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function __construct() {
|
2013-07-23 16:05:01 +00:00
|
|
|
add_action( 'init', array( $this, 'add_endpoints' ) );
|
|
|
|
if ( ! is_admin() ) {
|
2015-01-05 14:43:01 +00:00
|
|
|
add_action( 'wp_loaded', array( $this, 'get_errors' ), 20 );
|
2013-07-23 16:05:01 +00:00
|
|
|
add_filter( 'query_vars', array( $this, 'add_query_vars'), 0 );
|
|
|
|
add_action( 'parse_request', array( $this, 'parse_request'), 0 );
|
2014-06-30 10:41:21 +00:00
|
|
|
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
2013-10-21 12:05:34 +00:00
|
|
|
add_action( 'wp', array( $this, 'remove_product_query' ) );
|
|
|
|
add_action( 'wp', array( $this, 'remove_ordering_args' ) );
|
2013-07-23 16:05:01 +00:00
|
|
|
}
|
2013-09-03 15:14:56 +00:00
|
|
|
$this->init_query_vars();
|
|
|
|
}
|
|
|
|
|
2014-12-05 13:42:19 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get any errors from querystring.
|
2014-12-05 13:42:19 +00:00
|
|
|
*/
|
|
|
|
public function get_errors() {
|
|
|
|
if ( ! empty( $_GET['wc_error'] ) && ( $error = sanitize_text_field( $_GET['wc_error'] ) ) && ! wc_has_notice( $error, 'error' ) ) {
|
|
|
|
wc_add_notice( $error, 'error' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-03 15:14:56 +00:00
|
|
|
/**
|
|
|
|
* Init query vars by loading options.
|
|
|
|
*/
|
|
|
|
public function init_query_vars() {
|
2016-01-19 19:47:17 +00:00
|
|
|
// Query vars to add to WP.
|
2013-09-03 15:14:56 +00:00
|
|
|
$this->query_vars = array(
|
2016-01-19 19:47:17 +00:00
|
|
|
// Checkout actions.
|
2013-11-01 17:08:22 +00:00
|
|
|
'order-pay' => get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' ),
|
|
|
|
'order-received' => get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' ),
|
2016-01-19 19:47:17 +00:00
|
|
|
// My account actions.
|
2016-02-09 20:19:34 +00:00
|
|
|
'orders' => get_option( 'woocommerce_myaccount_orders_endpoint', 'orders' ),
|
|
|
|
'view-order' => get_option( 'woocommerce_myaccount_view_order_endpoint', 'view-order' ),
|
|
|
|
'downloads' => get_option( 'woocommerce_myaccount_downloads_endpoint', 'downloads' ),
|
|
|
|
'edit-account' => get_option( 'woocommerce_myaccount_edit_account_endpoint', 'edit-account' ),
|
|
|
|
'edit-address' => get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ),
|
|
|
|
'payment-methods' => get_option( 'woocommerce_myaccount_payment_methods_endpoint', 'payment-methods' ),
|
|
|
|
'lost-password' => get_option( 'woocommerce_myaccount_lost_password_endpoint', 'lost-password' ),
|
|
|
|
'customer-logout' => get_option( 'woocommerce_logout_endpoint', 'customer-logout' ),
|
|
|
|
'add-payment-method' => get_option( 'woocommerce_myaccount_add_payment_method_endpoint', 'add-payment-method' ),
|
|
|
|
'delete-payment-method' => get_option( 'woocommerce_myaccount_delete_payment_method_endpoint', 'delete-payment-method' ),
|
|
|
|
'set-default-payment-method' => get_option( 'woocommerce_myaccount_set_default_payment_method_endpoint', 'set-default-payment-method' ),
|
2013-09-03 15:14:56 +00:00
|
|
|
);
|
2013-07-23 16:05:01 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 14:36:28 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get page title for an endpoint.
|
2014-12-05 13:42:19 +00:00
|
|
|
* @param string
|
|
|
|
* @return string
|
2013-07-26 14:36:28 +00:00
|
|
|
*/
|
2014-12-05 13:42:19 +00:00
|
|
|
public function get_endpoint_title( $endpoint ) {
|
|
|
|
global $wp;
|
|
|
|
|
|
|
|
switch ( $endpoint ) {
|
|
|
|
case 'order-pay' :
|
|
|
|
$title = __( 'Pay for Order', 'woocommerce' );
|
|
|
|
break;
|
|
|
|
case 'order-received' :
|
|
|
|
$title = __( 'Order Received', 'woocommerce' );
|
|
|
|
break;
|
2016-01-19 19:47:17 +00:00
|
|
|
case 'orders' :
|
2016-01-20 15:46:59 +00:00
|
|
|
if ( ! empty( $wp->query_vars['orders'] ) ) {
|
|
|
|
$title = sprintf( __( 'Orders (page %d)', 'woocommerce' ), intval( $wp->query_vars['orders'] ) );
|
2016-01-19 21:02:26 +00:00
|
|
|
} else {
|
|
|
|
$title = __( 'Orders', 'woocommerce' );
|
|
|
|
}
|
2016-01-19 19:47:17 +00:00
|
|
|
break;
|
2014-12-05 13:42:19 +00:00
|
|
|
case 'view-order' :
|
|
|
|
$order = wc_get_order( $wp->query_vars['view-order'] );
|
2015-06-10 15:09:18 +00:00
|
|
|
$title = ( $order ) ? sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ) : '';
|
2014-12-05 13:42:19 +00:00
|
|
|
break;
|
2016-01-19 19:47:17 +00:00
|
|
|
case 'downloads' :
|
|
|
|
$title = __( 'Downloads', 'woocommerce' );
|
|
|
|
break;
|
2014-12-05 13:42:19 +00:00
|
|
|
case 'edit-account' :
|
|
|
|
$title = __( 'Edit Account Details', 'woocommerce' );
|
|
|
|
break;
|
|
|
|
case 'edit-address' :
|
|
|
|
$title = __( 'Edit Address', 'woocommerce' );
|
|
|
|
break;
|
2016-01-20 20:13:17 +00:00
|
|
|
case 'payment-methods' :
|
|
|
|
$title = __( 'Payment Methods', 'woocommerce' );
|
|
|
|
break;
|
2014-12-05 13:42:19 +00:00
|
|
|
case 'add-payment-method' :
|
|
|
|
$title = __( 'Add Payment Method', 'woocommerce' );
|
|
|
|
break;
|
|
|
|
case 'lost-password' :
|
|
|
|
$title = __( 'Lost Password', 'woocommerce' );
|
|
|
|
break;
|
|
|
|
default :
|
2016-01-19 21:06:34 +00:00
|
|
|
$title = apply_filters( 'woocommerce_endpoint_' . $endpoint . '_title', '' );
|
2014-12-05 13:42:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-19 19:47:17 +00:00
|
|
|
|
2016-01-19 21:06:34 +00:00
|
|
|
return $title;
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 16:05:01 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Add endpoints for query vars.
|
2013-07-23 16:05:01 +00:00
|
|
|
*/
|
|
|
|
public function add_endpoints() {
|
2014-12-05 13:42:19 +00:00
|
|
|
foreach ( $this->query_vars as $key => $var ) {
|
2014-06-25 10:10:05 +00:00
|
|
|
add_rewrite_endpoint( $var, EP_ROOT | EP_PAGES );
|
2014-12-05 13:42:19 +00:00
|
|
|
}
|
2011-09-16 08:10:12 +00:00
|
|
|
}
|
2011-12-22 19:55:08 +00:00
|
|
|
|
2013-05-31 15:13:14 +00:00
|
|
|
/**
|
2016-01-06 15:17:26 +00:00
|
|
|
* Add query vars.
|
2013-05-31 15:13:14 +00:00
|
|
|
*
|
|
|
|
* @access public
|
2013-11-29 18:50:31 +00:00
|
|
|
* @param array $vars
|
|
|
|
* @return array
|
2013-05-31 15:13:14 +00:00
|
|
|
*/
|
|
|
|
public function add_query_vars( $vars ) {
|
2014-12-05 13:42:19 +00:00
|
|
|
foreach ( $this->query_vars as $key => $var ) {
|
2013-09-03 15:14:56 +00:00
|
|
|
$vars[] = $key;
|
2014-12-05 13:42:19 +00:00
|
|
|
}
|
2013-05-31 15:13:14 +00:00
|
|
|
return $vars;
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:18:36 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get query vars.
|
2014-09-02 19:50:19 +00:00
|
|
|
*
|
|
|
|
* @return array
|
2014-02-12 12:18:36 +00:00
|
|
|
*/
|
|
|
|
public function get_query_vars() {
|
|
|
|
return $this->query_vars;
|
|
|
|
}
|
|
|
|
|
2014-12-05 13:42:19 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Get query current active query var.
|
2014-12-05 13:42:19 +00:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_current_endpoint() {
|
|
|
|
global $wp;
|
|
|
|
foreach ( $this->get_query_vars() as $key => $value ) {
|
|
|
|
if ( isset( $wp->query_vars[ $key ] ) ) {
|
|
|
|
return $key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2013-05-31 15:13:14 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Parse the request and look for query vars - endpoints may not be supported.
|
2013-05-31 15:13:14 +00:00
|
|
|
*/
|
|
|
|
public function parse_request() {
|
|
|
|
global $wp;
|
|
|
|
|
2013-09-03 15:14:56 +00:00
|
|
|
// Map query vars to their keys, or get them if endpoints are not supported
|
|
|
|
foreach ( $this->query_vars as $key => $var ) {
|
|
|
|
if ( isset( $_GET[ $var ] ) ) {
|
|
|
|
$wp->query_vars[ $key ] = $_GET[ $var ];
|
|
|
|
}
|
|
|
|
|
|
|
|
elseif ( isset( $wp->query_vars[ $var ] ) ) {
|
|
|
|
$wp->query_vars[ $key ] = $wp->query_vars[ $var ];
|
|
|
|
}
|
|
|
|
}
|
2013-05-31 15:13:14 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 08:10:12 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Hook into pre_get_posts to do the main product query.
|
2012-08-14 20:19:41 +00:00
|
|
|
*
|
|
|
|
* @param mixed $q query object
|
2011-09-16 08:10:12 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function pre_get_posts( $q ) {
|
2012-06-13 23:52:21 +00:00
|
|
|
// We only want to affect the main query
|
2014-06-25 10:10:05 +00:00
|
|
|
if ( ! $q->is_main_query() ) {
|
2012-06-13 23:52:21 +00:00
|
|
|
return;
|
2014-06-25 10:10:05 +00:00
|
|
|
}
|
|
|
|
|
2014-07-03 14:14:00 +00:00
|
|
|
// Fix for verbose page rules
|
2016-01-13 10:33:07 +00:00
|
|
|
if ( $GLOBALS['wp_rewrite']->use_verbose_page_rules && isset( $q->queried_object->ID ) && $q->queried_object->ID === wc_get_page_id( 'shop' ) ) {
|
2014-07-03 14:14:00 +00:00
|
|
|
$q->set( 'post_type', 'product' );
|
|
|
|
$q->set( 'page', '' );
|
|
|
|
$q->set( 'pagename', '' );
|
|
|
|
|
|
|
|
// Fix conditional Functions
|
|
|
|
$q->is_archive = true;
|
|
|
|
$q->is_post_type_archive = true;
|
|
|
|
$q->is_singular = false;
|
|
|
|
$q->is_page = false;
|
|
|
|
}
|
|
|
|
|
2014-06-25 10:10:05 +00:00
|
|
|
// Fix for endpoints on the homepage
|
2016-01-14 15:25:21 +00:00
|
|
|
if ( $q->is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) !== absint( $q->get( 'page_id' ) ) ) {
|
2014-06-25 10:10:05 +00:00
|
|
|
$_query = wp_parse_args( $q->query );
|
|
|
|
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->query_vars ) ) ) {
|
|
|
|
$q->is_page = true;
|
|
|
|
$q->is_home = false;
|
|
|
|
$q->is_singular = true;
|
2016-01-13 11:01:08 +00:00
|
|
|
$q->set( 'page_id', (int) get_option( 'page_on_front' ) );
|
|
|
|
add_filter( 'redirect_canonical', '__return_false' );
|
2014-06-25 10:10:05 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-29 09:26:21 +00:00
|
|
|
|
2013-03-04 22:49:17 +00:00
|
|
|
// When orderby is set, WordPress shows posts. Get around that here.
|
2016-01-13 11:01:08 +00:00
|
|
|
if ( $q->is_home() && 'page' === get_option( 'show_on_front' ) && absint( get_option( 'page_on_front' ) ) === wc_get_page_id( 'shop' ) ) {
|
2013-03-04 22:49:17 +00:00
|
|
|
$_query = wp_parse_args( $q->query );
|
|
|
|
if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) ) ) {
|
|
|
|
$q->is_page = true;
|
|
|
|
$q->is_home = false;
|
2016-01-13 11:01:08 +00:00
|
|
|
$q->set( 'page_id', (int) get_option( 'page_on_front' ) );
|
2013-03-04 22:49:17 +00:00
|
|
|
$q->set( 'post_type', 'product' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-13 23:52:21 +00:00
|
|
|
// Special check for shops with the product archive on front
|
2016-01-14 15:25:21 +00:00
|
|
|
if ( $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
|
2012-08-02 21:54:26 +00:00
|
|
|
|
|
|
|
// This is a front-page shop
|
2012-06-13 23:52:21 +00:00
|
|
|
$q->set( 'post_type', 'product' );
|
|
|
|
$q->set( 'page_id', '' );
|
2015-12-10 10:42:54 +00:00
|
|
|
|
2014-07-03 14:14:00 +00:00
|
|
|
if ( isset( $q->query['paged'] ) ) {
|
2012-06-13 23:52:21 +00:00
|
|
|
$q->set( 'paged', $q->query['paged'] );
|
2014-07-03 14:14:00 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2012-06-29 09:23:21 +00:00
|
|
|
// Define a variable so we know this is the front page shop later on
|
|
|
|
define( 'SHOP_IS_ON_FRONT', true );
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2012-06-29 09:23:21 +00:00
|
|
|
// Get the actual WP page to avoid errors and let us use is_front_page()
|
|
|
|
// This is hacky but works. Awaiting http://core.trac.wordpress.org/ticket/21096
|
|
|
|
global $wp_post_types;
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2015-12-10 10:42:54 +00:00
|
|
|
$shop_page = get_post( wc_get_page_id( 'shop' ) );
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2012-06-29 09:23:21 +00:00
|
|
|
$wp_post_types['product']->ID = $shop_page->ID;
|
|
|
|
$wp_post_types['product']->post_title = $shop_page->post_title;
|
|
|
|
$wp_post_types['product']->post_name = $shop_page->post_name;
|
2014-05-21 13:30:51 +00:00
|
|
|
$wp_post_types['product']->post_type = $shop_page->post_type;
|
|
|
|
$wp_post_types['product']->ancestors = get_ancestors( $shop_page->ID, $shop_page->post_type );
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2012-06-29 09:23:21 +00:00
|
|
|
// Fix conditional Functions like is_front_page
|
2014-07-03 14:14:00 +00:00
|
|
|
$q->is_singular = false;
|
2013-01-02 20:11:17 +00:00
|
|
|
$q->is_post_type_archive = true;
|
2014-07-03 14:14:00 +00:00
|
|
|
$q->is_archive = true;
|
|
|
|
$q->is_page = true;
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2015-12-10 10:42:54 +00:00
|
|
|
// Remove post type archive name from front page title tag
|
|
|
|
add_filter( 'post_type_archive_title', '__return_empty_string', 5 );
|
|
|
|
|
2013-01-02 20:11:17 +00:00
|
|
|
// Fix WP SEO
|
2014-05-07 10:40:21 +00:00
|
|
|
if ( class_exists( 'WPSEO_Meta' ) ) {
|
2013-01-02 20:11:17 +00:00
|
|
|
add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) );
|
|
|
|
add_filter( 'wpseo_metakey', array( $this, 'wpseo_metakey' ) );
|
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2014-06-25 10:10:05 +00:00
|
|
|
// Only apply to product categories, the product post archive, the shop page, product tags, and product attribute taxonomies
|
|
|
|
} elseif ( ! $q->is_post_type_archive( 'product' ) && ! $q->is_tax( get_object_taxonomies( 'product' ) ) ) {
|
|
|
|
return;
|
2012-06-13 23:52:21 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-01-02 20:11:17 +00:00
|
|
|
$this->product_query( $q );
|
2013-01-12 10:53:08 +00:00
|
|
|
|
2013-01-02 20:47:56 +00:00
|
|
|
if ( is_search() ) {
|
2015-06-09 13:58:27 +00:00
|
|
|
add_filter( 'posts_where', array( $this, 'search_post_excerpt' ) );
|
|
|
|
add_filter( 'wp', array( $this, 'remove_posts_where' ) );
|
2013-01-02 20:47:56 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-01-02 20:11:17 +00:00
|
|
|
// And remove the pre_get_posts hook
|
|
|
|
$this->remove_product_query();
|
2011-12-22 19:55:08 +00:00
|
|
|
}
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2013-01-02 20:47:56 +00:00
|
|
|
/**
|
2016-01-06 15:17:26 +00:00
|
|
|
* Search post excerpt.
|
2013-01-02 20:47:56 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param string $where (default: '')
|
|
|
|
* @return string (modified where clause)
|
|
|
|
*/
|
|
|
|
public function search_post_excerpt( $where = '' ) {
|
|
|
|
global $wp_the_query;
|
2013-01-12 10:53:08 +00:00
|
|
|
|
2013-01-02 20:47:56 +00:00
|
|
|
// If this is not a WC Query, do not modify the query
|
2013-09-13 14:14:19 +00:00
|
|
|
if ( empty( $wp_the_query->query_vars['wc_query'] ) || empty( $wp_the_query->query_vars['s'] ) )
|
2015-06-09 13:58:27 +00:00
|
|
|
return $where;
|
2013-01-02 20:47:56 +00:00
|
|
|
|
|
|
|
$where = preg_replace(
|
2015-06-09 13:58:27 +00:00
|
|
|
"/post_title\s+LIKE\s*(\'\%[^\%]+\%\')/",
|
|
|
|
"post_title LIKE $1) OR (post_excerpt LIKE $1", $where );
|
2013-01-12 10:53:08 +00:00
|
|
|
|
2013-01-02 20:47:56 +00:00
|
|
|
return $where;
|
|
|
|
}
|
2012-08-22 19:44:27 +00:00
|
|
|
|
|
|
|
/**
|
2016-01-06 15:17:26 +00:00
|
|
|
* WP SEO meta description.
|
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Hooked into wpseo_ hook already, so no need for function_exist.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-08-22 19:44:27 +00:00
|
|
|
* @access public
|
2013-11-29 18:50:31 +00:00
|
|
|
* @return string
|
2012-08-22 19:44:27 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function wpseo_metadesc() {
|
2016-02-09 21:14:55 +00:00
|
|
|
return WPSEO_Meta::get_value( 'metadesc', wc_get_page_id( 'shop' ) );
|
2012-08-22 19:44:27 +00:00
|
|
|
}
|
2012-11-27 16:22:47 +00:00
|
|
|
|
2012-08-22 19:44:27 +00:00
|
|
|
/**
|
2016-01-06 15:17:26 +00:00
|
|
|
* WP SEO meta key.
|
|
|
|
*
|
2015-11-03 13:31:20 +00:00
|
|
|
* Hooked into wpseo_ hook already, so no need for function_exist.
|
2012-11-27 16:22:47 +00:00
|
|
|
*
|
2012-08-22 19:44:27 +00:00
|
|
|
* @access public
|
2013-11-29 18:50:31 +00:00
|
|
|
* @return string
|
2012-08-22 19:44:27 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function wpseo_metakey() {
|
2016-02-09 21:14:55 +00:00
|
|
|
return WPSEO_Meta::get_value( 'metakey', wc_get_page_id( 'shop' ) );
|
2012-03-26 14:34:23 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2011-12-22 19:55:08 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Query the products, applying sorting/ordering etc. This applies to the main wordpress loop.
|
2012-08-14 20:19:41 +00:00
|
|
|
*
|
|
|
|
* @param mixed $q
|
2011-12-22 19:55:08 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function product_query( $q ) {
|
2011-09-16 08:10:12 +00:00
|
|
|
// Ordering query vars
|
2016-02-09 23:11:38 +00:00
|
|
|
$ordering = $this->get_catalog_ordering_args();
|
2011-09-23 11:04:51 +00:00
|
|
|
$q->set( 'orderby', $ordering['orderby'] );
|
|
|
|
$q->set( 'order', $ordering['order'] );
|
2014-12-09 08:33:29 +00:00
|
|
|
if ( isset( $ordering['meta_key'] ) ) {
|
2012-05-17 12:56:18 +00:00
|
|
|
$q->set( 'meta_key', $ordering['meta_key'] );
|
2014-12-09 08:33:29 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2011-09-16 08:10:12 +00:00
|
|
|
// Query vars that affect posts shown
|
2016-02-09 21:14:55 +00:00
|
|
|
$q->set( 'meta_query', $this->get_meta_query( $q->get( 'meta_query' ) ) );
|
|
|
|
$q->set( 'tax_query', $this->get_tax_query( $q->get( 'tax_query' ) ) );
|
2013-01-02 20:11:17 +00:00
|
|
|
$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', get_option( 'posts_per_page' ) ) );
|
2015-03-13 10:33:36 +00:00
|
|
|
$q->set( 'wc_query', 'product_query' );
|
2016-02-09 21:14:55 +00:00
|
|
|
$q->set( 'post__in', array_unique( apply_filters( 'loop_shop_post_in', array() ) ) );
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-01-02 20:11:17 +00:00
|
|
|
do_action( 'woocommerce_product_query', $q, $this );
|
2011-09-16 08:10:12 +00:00
|
|
|
}
|
2011-12-22 19:55:08 +00:00
|
|
|
|
2012-08-14 20:19:41 +00:00
|
|
|
|
2011-09-16 08:10:12 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Remove the query.
|
2011-09-16 08:10:12 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function remove_product_query() {
|
2014-06-30 10:41:21 +00:00
|
|
|
remove_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
2011-09-16 08:10:12 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-10-21 12:05:34 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Remove ordering queries.
|
2013-10-21 12:05:34 +00:00
|
|
|
*/
|
|
|
|
public function remove_ordering_args() {
|
|
|
|
remove_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
|
|
|
|
remove_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) );
|
|
|
|
}
|
|
|
|
|
2013-01-02 21:43:52 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Remove the posts_where filter.
|
2013-01-02 21:43:52 +00:00
|
|
|
*/
|
2013-01-12 10:53:08 +00:00
|
|
|
public function remove_posts_where() {
|
2013-01-02 21:43:52 +00:00
|
|
|
remove_filter( 'posts_where', array( $this, 'search_post_excerpt' ) );
|
|
|
|
}
|
2013-01-12 10:53:08 +00:00
|
|
|
|
2011-09-23 11:04:51 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Returns an array of arguments for ordering products based on the selected values.
|
2012-08-14 20:19:41 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return array
|
2011-09-23 11:04:51 +00:00
|
|
|
*/
|
2012-12-18 06:57:44 +00:00
|
|
|
public function get_catalog_ordering_args( $orderby = '', $order = '' ) {
|
2014-08-29 09:26:21 +00:00
|
|
|
global $wpdb;
|
|
|
|
|
2013-01-12 10:53:08 +00:00
|
|
|
// Get ordering from query string unless defined
|
|
|
|
if ( ! $orderby ) {
|
2013-11-25 13:34:21 +00:00
|
|
|
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
2013-01-12 10:53:08 +00:00
|
|
|
|
|
|
|
// Get order + orderby args from string
|
|
|
|
$orderby_value = explode( '-', $orderby_value );
|
|
|
|
$orderby = esc_attr( $orderby_value[0] );
|
|
|
|
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
|
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-03-22 17:06:06 +00:00
|
|
|
$orderby = strtolower( $orderby );
|
|
|
|
$order = strtoupper( $order );
|
2014-08-29 09:26:21 +00:00
|
|
|
$args = array();
|
2012-12-18 06:57:44 +00:00
|
|
|
|
2013-07-17 10:21:48 +00:00
|
|
|
// default - menu_order
|
|
|
|
$args['orderby'] = 'menu_order title';
|
|
|
|
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
|
|
|
|
$args['meta_key'] = '';
|
|
|
|
|
2012-12-18 06:57:44 +00:00
|
|
|
switch ( $orderby ) {
|
2013-12-05 12:53:22 +00:00
|
|
|
case 'rand' :
|
|
|
|
$args['orderby'] = 'rand';
|
|
|
|
break;
|
2011-09-23 11:04:51 +00:00
|
|
|
case 'date' :
|
2016-03-08 12:54:07 +00:00
|
|
|
$args['orderby'] = 'date ID';
|
2013-03-22 17:06:06 +00:00
|
|
|
$args['order'] = $order == 'ASC' ? 'ASC' : 'DESC';
|
2011-09-23 11:04:51 +00:00
|
|
|
break;
|
|
|
|
case 'price' :
|
2015-11-17 15:59:53 +00:00
|
|
|
$args['orderby'] = "meta_value_num ID";
|
2013-03-22 17:06:06 +00:00
|
|
|
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
|
2012-12-18 06:57:44 +00:00
|
|
|
$args['meta_key'] = '_price';
|
2011-09-23 11:04:51 +00:00
|
|
|
break;
|
2013-01-12 10:53:08 +00:00
|
|
|
case 'popularity' :
|
|
|
|
$args['meta_key'] = 'total_sales';
|
2013-07-17 10:21:48 +00:00
|
|
|
|
|
|
|
// Sorting handled later though a hook
|
|
|
|
add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
|
2012-10-14 12:06:37 +00:00
|
|
|
break;
|
2013-01-12 10:53:08 +00:00
|
|
|
case 'rating' :
|
2013-07-17 10:21:48 +00:00
|
|
|
// Sorting handled later though a hook
|
2013-01-12 10:53:08 +00:00
|
|
|
add_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) );
|
2011-09-23 11:04:51 +00:00
|
|
|
break;
|
2013-03-22 17:06:06 +00:00
|
|
|
case 'title' :
|
|
|
|
$args['orderby'] = 'title';
|
|
|
|
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
|
2012-05-08 19:30:18 +00:00
|
|
|
break;
|
2012-06-13 23:52:21 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2012-12-18 06:57:44 +00:00
|
|
|
return apply_filters( 'woocommerce_get_catalog_ordering_args', $args );
|
2011-09-23 11:04:51 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-07-17 10:21:48 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* WP Core doens't let us change the sort direction for invidual orderby params - http://core.trac.wordpress.org/ticket/17065.
|
2013-07-17 10:21:48 +00:00
|
|
|
*
|
|
|
|
* This lets us sort by meta value desc, and have a second orderby param.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param array $args
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function order_by_popularity_post_clauses( $args ) {
|
|
|
|
global $wpdb;
|
|
|
|
$args['orderby'] = "$wpdb->postmeta.meta_value+0 DESC, $wpdb->posts.post_date DESC";
|
|
|
|
return $args;
|
|
|
|
}
|
|
|
|
|
2013-01-12 10:53:08 +00:00
|
|
|
/**
|
2016-01-06 15:17:26 +00:00
|
|
|
* Order by rating post clauses.
|
2013-01-12 10:53:08 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param array $args
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function order_by_rating_post_clauses( $args ) {
|
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
$args['fields'] .= ", AVG( $wpdb->commentmeta.meta_value ) as average_rating ";
|
2016-02-09 23:11:38 +00:00
|
|
|
$args['where'] .= " AND ( $wpdb->commentmeta.meta_key = 'rating' OR $wpdb->commentmeta.meta_key IS null ) ";
|
|
|
|
$args['join'] .= "
|
2013-01-12 10:53:08 +00:00
|
|
|
LEFT OUTER JOIN $wpdb->comments ON($wpdb->posts.ID = $wpdb->comments.comment_post_ID)
|
|
|
|
LEFT JOIN $wpdb->commentmeta ON($wpdb->comments.comment_ID = $wpdb->commentmeta.comment_id)
|
|
|
|
";
|
2013-07-17 10:21:48 +00:00
|
|
|
$args['orderby'] = "average_rating DESC, $wpdb->posts.post_date DESC";
|
2013-01-12 10:53:08 +00:00
|
|
|
$args['groupby'] = "$wpdb->posts.ID";
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
}
|
2012-08-14 20:19:41 +00:00
|
|
|
|
2013-04-17 15:29:43 +00:00
|
|
|
/**
|
|
|
|
* Appends meta queries to an array.
|
|
|
|
* @access public
|
2013-10-04 16:48:50 +00:00
|
|
|
* @param array $meta_query
|
|
|
|
* @return array
|
2013-04-17 15:29:43 +00:00
|
|
|
*/
|
|
|
|
public function get_meta_query( $meta_query = array() ) {
|
2016-02-09 21:14:55 +00:00
|
|
|
if ( ! is_array( $meta_query ) ) {
|
2013-04-17 15:29:43 +00:00
|
|
|
$meta_query = array();
|
2016-02-09 21:14:55 +00:00
|
|
|
}
|
2013-04-17 15:29:43 +00:00
|
|
|
|
|
|
|
$meta_query[] = $this->visibility_meta_query();
|
|
|
|
$meta_query[] = $this->stock_status_meta_query();
|
2016-02-09 21:14:55 +00:00
|
|
|
$meta_query[] = $this->price_filter_meta_query();
|
|
|
|
$meta_query[] = $this->rating_filter_meta_query();
|
|
|
|
|
|
|
|
return array_filter( apply_filters( 'woocommerce_product_query_meta_query', $meta_query, $this ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a meta query for filtering by price.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function price_filter_meta_query() {
|
|
|
|
if ( isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) ) {
|
2016-02-11 11:13:48 +00:00
|
|
|
$min = isset( $_GET['min_price'] ) ? floatval( $_GET['min_price'] ) : 0;
|
|
|
|
$max = isset( $_GET['max_price'] ) ? floatval( $_GET['max_price'] ) : 9999999999;
|
2016-02-09 21:14:55 +00:00
|
|
|
|
2016-02-22 13:23:22 +00:00
|
|
|
/**
|
|
|
|
* Adjust if the store taxes are not displayed how they are stored.
|
|
|
|
* Max is left alone because the filter was already increased.
|
|
|
|
* Kicks in when prices excluding tax are displayed including tax.
|
|
|
|
*/
|
2016-02-09 21:14:55 +00:00
|
|
|
if ( wc_tax_enabled() && 'incl' === get_option( 'woocommerce_tax_display_shop' ) && ! wc_prices_include_tax() ) {
|
|
|
|
$tax_classes = array_merge( array( '' ), WC_Tax::get_tax_classes() );
|
2016-02-22 13:23:22 +00:00
|
|
|
$class_min = $min;
|
2016-02-09 21:14:55 +00:00
|
|
|
|
|
|
|
foreach ( $tax_classes as $tax_class ) {
|
2016-02-22 13:23:22 +00:00
|
|
|
if ( $tax_rates = WC_Tax::get_rates( $tax_class ) ) {
|
|
|
|
$class_min = $min - WC_Tax::get_tax_total( WC_Tax::calc_exclusive_tax( $min, $tax_rates ) );
|
2016-02-09 21:14:55 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-22 13:23:22 +00:00
|
|
|
|
|
|
|
$min = $class_min;
|
2016-02-09 21:14:55 +00:00
|
|
|
}
|
2013-04-17 15:29:43 +00:00
|
|
|
|
2016-02-09 21:14:55 +00:00
|
|
|
return array(
|
|
|
|
'key' => '_price',
|
|
|
|
'value' => array( $min, $max ),
|
|
|
|
'compare' => 'BETWEEN',
|
|
|
|
'type' => 'DECIMAL',
|
2016-02-11 11:13:48 +00:00
|
|
|
'price_filter' => true,
|
2016-02-09 21:14:55 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a meta query for filtering by rating.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rating_filter_meta_query() {
|
2016-02-09 23:11:38 +00:00
|
|
|
return isset( $_GET['min_rating'] ) ? array(
|
|
|
|
'key' => '_wc_average_rating',
|
|
|
|
'value' => isset( $_GET['min_rating'] ) ? floatval( $_GET['min_rating'] ) : 0,
|
|
|
|
'compare' => '>=',
|
|
|
|
'type' => 'DECIMAL',
|
2016-02-11 11:13:48 +00:00
|
|
|
'rating_filter' => true,
|
2016-02-09 23:11:38 +00:00
|
|
|
) : array();
|
2013-04-17 15:29:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-23 11:04:51 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Returns a meta query to handle product visibility.
|
2012-08-14 20:19:41 +00:00
|
|
|
* @param string $compare (default: 'IN')
|
|
|
|
* @return array
|
2011-09-23 11:04:51 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function visibility_meta_query( $compare = 'IN' ) {
|
2016-02-09 21:14:55 +00:00
|
|
|
return array(
|
2015-06-09 13:58:27 +00:00
|
|
|
'key' => '_visibility',
|
2016-02-09 21:14:55 +00:00
|
|
|
'value' => is_search() ? array( 'visible', 'search' ) : array( 'visible', 'catalog' ),
|
2016-02-11 11:13:48 +00:00
|
|
|
'compare' => $compare,
|
2013-01-02 20:11:17 +00:00
|
|
|
);
|
2011-09-23 11:04:51 +00:00
|
|
|
}
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2011-09-23 11:04:51 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Returns a meta query to handle product stock status.
|
2012-08-14 20:19:41 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @param string $status (default: 'instock')
|
|
|
|
* @return array
|
2011-09-23 11:04:51 +00:00
|
|
|
*/
|
2012-12-14 21:55:19 +00:00
|
|
|
public function stock_status_meta_query( $status = 'instock' ) {
|
2016-02-09 21:14:55 +00:00
|
|
|
return 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ? array(
|
|
|
|
'key' => '_stock_status',
|
|
|
|
'value' => $status,
|
2016-02-11 11:13:48 +00:00
|
|
|
'compare' => '=',
|
2016-02-09 21:14:55 +00:00
|
|
|
) : array();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends tax queries to an array.
|
|
|
|
* @param array $tax_query
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_tax_query( $tax_query = array() ) {
|
|
|
|
if ( ! is_array( $tax_query ) ) {
|
|
|
|
$tax_query = array();
|
2012-06-13 23:52:21 +00:00
|
|
|
}
|
2016-02-09 21:14:55 +00:00
|
|
|
|
|
|
|
// Layered nav filters on terms
|
2016-02-10 10:19:32 +00:00
|
|
|
if ( $_chosen_attributes = $this->get_layered_nav_chosen_attributes() ) {
|
2016-02-09 21:14:55 +00:00
|
|
|
foreach ( $_chosen_attributes as $taxonomy => $data ) {
|
|
|
|
$tax_query[] = array(
|
|
|
|
'taxonomy' => $taxonomy,
|
|
|
|
'field' => 'slug',
|
|
|
|
'terms' => $data['terms'],
|
2016-02-09 23:11:38 +00:00
|
|
|
'operator' => 'and' === $data['query_type'] ? 'AND' : 'IN',
|
2016-02-11 11:13:48 +00:00
|
|
|
'include_children' => false,
|
2016-02-09 21:14:55 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array_filter( apply_filters( 'woocommerce_product_query_tax_query', $tax_query, $this ) );
|
2011-09-23 11:04:51 +00:00
|
|
|
}
|
2013-08-09 16:11:15 +00:00
|
|
|
|
2016-02-10 10:02:50 +00:00
|
|
|
/**
|
|
|
|
* Get the tax query which was used by the main query.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function get_main_tax_query() {
|
|
|
|
global $wp_the_query;
|
|
|
|
|
|
|
|
$args = $wp_the_query->query_vars;
|
|
|
|
$tax_query = isset( $args['tax_query'] ) ? $args['tax_query'] : array();
|
|
|
|
|
|
|
|
if ( ! empty( $args['taxonomy'] ) && ! empty( $args['term'] ) ) {
|
|
|
|
$tax_query[] = array(
|
|
|
|
'taxonomy' => $args['taxonomy'],
|
|
|
|
'terms' => array( $args['term'] ),
|
2016-02-11 11:13:48 +00:00
|
|
|
'field' => 'slug',
|
2016-02-10 10:02:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tax_query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the meta query which was used by the main query.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function get_main_meta_query() {
|
|
|
|
global $wp_the_query;
|
|
|
|
|
|
|
|
$args = $wp_the_query->query_vars;
|
|
|
|
$meta_query = isset( $args['meta_query'] ) ? $args['meta_query'] : array();
|
|
|
|
|
|
|
|
return $meta_query;
|
|
|
|
}
|
|
|
|
|
2013-08-09 16:11:15 +00:00
|
|
|
/**
|
2015-11-03 13:31:20 +00:00
|
|
|
* Layered Nav Init.
|
2013-08-09 16:11:15 +00:00
|
|
|
*/
|
2016-02-10 10:19:32 +00:00
|
|
|
public static function get_layered_nav_chosen_attributes() {
|
|
|
|
if ( ! is_array( self::$_chosen_attributes ) ) {
|
|
|
|
self::$_chosen_attributes = array();
|
|
|
|
|
|
|
|
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) {
|
|
|
|
foreach ( $attribute_taxonomies as $tax ) {
|
|
|
|
$attribute = wc_sanitize_taxonomy_name( $tax->attribute_name );
|
|
|
|
$taxonomy = wc_attribute_taxonomy_name( $attribute );
|
|
|
|
$filter_terms = ! empty( $_GET[ 'filter_' . $attribute ] ) ? explode( ',', wc_clean( $_GET[ 'filter_' . $attribute ] ) ) : array();
|
|
|
|
|
|
|
|
if ( empty( $filter_terms ) || ! taxonomy_exists( $taxonomy ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-08-09 16:11:15 +00:00
|
|
|
|
2016-02-10 10:19:32 +00:00
|
|
|
$query_type = ! empty( $_GET[ 'query_type_' . $attribute ] ) && in_array( $_GET[ 'query_type_' . $attribute ], array( 'and', 'or' ) ) ? wc_clean( $_GET[ 'query_type_' . $attribute ] ) : '';
|
|
|
|
self::$_chosen_attributes[ $taxonomy ]['terms'] = array_map( 'sanitize_title', $filter_terms ); // Ensures correct encoding
|
|
|
|
self::$_chosen_attributes[ $taxonomy ]['query_type'] = $query_type ? $query_type : apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
|
2013-08-09 16:11:15 +00:00
|
|
|
}
|
2015-06-09 13:58:27 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-10 10:19:32 +00:00
|
|
|
return self::$_chosen_attributes;
|
2013-08-09 16:11:15 +00:00
|
|
|
}
|
|
|
|
|
2016-02-10 10:19:32 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.6.0
|
|
|
|
*/
|
2016-02-11 11:13:48 +00:00
|
|
|
public function layered_nav_init() {
|
|
|
|
_deprecated_function( 'layered_nav_init', '2.6', '' );
|
|
|
|
}
|
2016-02-10 10:19:32 +00:00
|
|
|
|
2015-11-13 09:41:44 +00:00
|
|
|
/**
|
2016-02-09 21:14:55 +00:00
|
|
|
* Get an unpaginated list all product ID's (both filtered and unfiltered). Makes use of transients.
|
|
|
|
* @deprecated 2.6.0 due to performance concerns
|
2015-11-13 09:41:44 +00:00
|
|
|
*/
|
2016-02-09 21:14:55 +00:00
|
|
|
public function get_products_in_view() {
|
|
|
|
_deprecated_function( 'get_products_in_view', '2.6', '' );
|
2015-11-13 09:41:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-02-09 21:14:55 +00:00
|
|
|
* Layered Nav post filter.
|
|
|
|
* @deprecated 2.6.0 due to performance concerns
|
2015-11-13 09:41:44 +00:00
|
|
|
*/
|
2016-02-09 21:14:55 +00:00
|
|
|
public function layered_nav_query( $filtered_posts ) {
|
|
|
|
_deprecated_function( 'layered_nav_query', '2.6', '' );
|
2016-02-09 15:18:27 +00:00
|
|
|
}
|
2013-07-23 16:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|
2012-08-02 21:54:26 +00:00
|
|
|
|
2013-12-02 11:34:27 +00:00
|
|
|
return new WC_Query();
|