b4400a68e5
Baseline before backporting wp-data-optimizer v3.0.1-v3.4.6. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
65 lines
1.3 KiB
PHP
65 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* WP_Query interceptor for hp_review post type.
|
|
*
|
|
* @package WP_Data_Optimizer
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* WP_Query interceptor for hp_review post type.
|
|
*
|
|
* Rewrites meta_query conditions for known review meta keys to query
|
|
* hpct_reviews directly, eliminating wp_postmeta JOIN for review queries.
|
|
*
|
|
* Intercepted meta keys:
|
|
* hp_listing => listing_id (BIGINT)
|
|
* _hp_vendor => vendor_id (BIGINT)
|
|
* hp_rating => rating (TINYINT)
|
|
*/
|
|
class TMDO_Reviews_Query extends TMDO_Query_Interceptor_Base {
|
|
|
|
/**
|
|
* Returns the module identifier.
|
|
*
|
|
* @return string Module name.
|
|
*/
|
|
protected function get_module(): string {
|
|
return 'reviews';
|
|
}
|
|
|
|
/**
|
|
* Returns the post types this interceptor handles.
|
|
*
|
|
* @return string[] Post type slugs.
|
|
*/
|
|
protected function get_post_types(): array {
|
|
return array( 'hp_review' );
|
|
}
|
|
|
|
/**
|
|
* Returns the custom table name.
|
|
*
|
|
* @return string Table name without prefix.
|
|
*/
|
|
protected function get_table(): string {
|
|
return 'hpct_reviews';
|
|
}
|
|
|
|
/**
|
|
* Returns the meta_key to column mapping for hpct_reviews.
|
|
*
|
|
* @return array<string, string> Meta key to column name map.
|
|
*/
|
|
protected function get_meta_key_map(): array {
|
|
return array(
|
|
'hp_listing' => 'listing_id',
|
|
'_hp_vendor' => 'vendor_id',
|
|
'hp_rating' => 'rating',
|
|
);
|
|
}
|
|
}
|