prepare( 'p.ID > %d', $after_id ); } /** * Filter extra product WHERE fragments of an index build, its progress * count and the admin estimate. The Premium build adds the category * and tag filters here. Each fragment must be prepared SQL on the `p` * posts alias. * * @since 2.8.0 * @param string[] $fragments Fragments (none by default). * @param array $filters The build's filters. */ $fragments = apply_filters( 'aipt_index_product_where', array(), $filters ); foreach ( is_array( $fragments ) ? $fragments : array() as $fragment ) { if ( is_string( $fragment ) && '' !== trim( $fragment ) ) { $where[] = $fragment; } } $stock_filter = (string) ( $filters['stock_filter'] ?? 'all' ); if ( 'all' !== $stock_filter ) { $where[] = $wpdb->prepare( "p.ID IN ( SELECT pm.post_id FROM {$wpdb->postmeta} pm WHERE pm.meta_key = '_stock_status' AND pm.meta_value = %s )", $stock_filter ); } $date_filter_days = absint( $filters['date_filter_days'] ?? 0 ); if ( $date_filter_days > 0 ) { $date_cutoff = date( 'Y-m-d H:i:s', strtotime( "-{$date_filter_days} days", current_time( 'timestamp' ) ) ); $where[] = $wpdb->prepare( 'p.post_date >= %s', $date_cutoff ); } return $where; } }