refactor(2meet-data-optimizer): resolve post_type/group/table mappings through the registry
- TMDO_Post_Fields::post_type_for_group() / groups_for_post_type() derive HivePress-style groups from their registry post_type scope (core keeps its own attachment / wc_product / nav_menu_item map); the three copy-pasted switches and the query router's POST_TYPE_GROUP_MAP use them - Term/comment backfill, shadow verifier and CLI take their groups from the registry (TMDO_Term_Comment_Backfill::registered_groups()); installer drops the hp_* entries already covered by its table patterns; REST listings default post type is filterable (tmdo_rest_default_post_type, default 'post') - Verify: NoHpMappingsTest guard + mapping/default tests; core unit 640 / integration 449, HP 146/49, WC 10/22 OK - PR: PR-020e
This commit is contained in:
@@ -529,7 +529,7 @@ class TMDO_REST_API {
|
||||
* @return WP_REST_Response REST response.
|
||||
*/
|
||||
public function get_listings( WP_REST_Request $request ): WP_REST_Response {
|
||||
$post_type = $request->get_param( 'post_type' ) ?? 'hp_listing';
|
||||
$post_type = $request->get_param( 'post_type' ) ?? self::default_post_type();
|
||||
if ( ! post_type_exists( $post_type ) || ! is_post_type_viewable( $post_type ) ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
@@ -1550,13 +1550,25 @@ class TMDO_REST_API {
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post type GET /listings serves when the request names none.
|
||||
*
|
||||
* Filter `tmdo_rest_default_post_type` lets an integration (e.g. the
|
||||
* HivePress AddOn) make its own post type the default.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function default_post_type(): string {
|
||||
return (string) apply_filters( 'tmdo_rest_default_post_type', 'post' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Argument definitions for GET /listings.
|
||||
*/
|
||||
private function listings_args(): array {
|
||||
return array(
|
||||
'post_type' => array(
|
||||
'default' => 'hp_listing',
|
||||
'default' => self::default_post_type(),
|
||||
'sanitize_callback' => 'sanitize_key',
|
||||
),
|
||||
'per_page' => array(
|
||||
|
||||
Reference in New Issue
Block a user