fix(2meet-data-optimizer): filter REST listings collection by post_status and post_type
- GET /wpdo/v1/listings rejects unregistered or non-viewable post types (400) and joins posts so Zone A only lists published posts of that type - WP_Query fallback now returns only show_in_rest hot columns, matching the Zone A path - Verify: core unit 605 / integration 432 OK (new RestApi tests); 1M bench: page 7ms, total COUNT 0.12s → 1.7s (tracked in PR-030) - PR: PR-015
This commit is contained in:
+13
-1
@@ -426,6 +426,18 @@ if ( ! function_exists( 'wp_cache_delete' ) ) {
|
||||
function wp_cache_delete( $key, $group = '' ): bool { unset( $GLOBALS['_wp_cache'][ $group ][ $key ] ); return true; }
|
||||
}
|
||||
|
||||
// Registered post types: name => publicly viewable (bool).
|
||||
if ( ! function_exists( 'post_type_exists' ) ) {
|
||||
function post_type_exists( string $post_type ): bool {
|
||||
return isset( $GLOBALS['_wp_registered_post_types'][ $post_type ] );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'is_post_type_viewable' ) ) {
|
||||
function is_post_type_viewable( $post_type ): bool {
|
||||
return ! empty( $GLOBALS['_wp_registered_post_types'][ (string) $post_type ] );
|
||||
}
|
||||
}
|
||||
|
||||
// ── Stub classes ───────────────────────────────────────────────────────────
|
||||
|
||||
if ( ! class_exists( 'WP_Query' ) ) {
|
||||
@@ -434,7 +446,7 @@ if ( ! class_exists( 'WP_Query' ) ) {
|
||||
public int $found_posts = 0;
|
||||
public int $max_num_pages = 0;
|
||||
private array $args = [];
|
||||
public function __construct( array $args = [] ) { $this->args = $args; }
|
||||
public function __construct( array $args = [] ) { $this->args = $args; $this->posts = $GLOBALS['_wp_query_posts'] ?? []; }
|
||||
public function get( string $key, $default = '' ) { return $this->args[ $key ] ?? $default; }
|
||||
public function set( string $key, $value ): void { $this->args[ $key ] = $value; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user