namespace, '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_mapping' ), 'permission_callback' => function ( \WP_REST_Request $r ) { return $this->check_scope( $r, \GeniusCommerce\GC_Scope_Map::for_request( $r ) ); }, ), ) ); } /** * Get the current mapping configuration. * * Returns the full mapping configuration including taxonomy mappings, * meta field mappings, and discovery timestamp for schema compatibility. * * @param WP_REST_Request $request The request object. * @return WP_REST_Response|WP_Error The response object or error. */ public function get_mapping( WP_REST_Request $request ) { $this->log_request( 'GET /mapping' ); // Load the mapping class if not already loaded. if ( ! class_exists( 'GeniusCommerce\Mapping\GC_Sync_Mapping' ) ) { require_once GENIUS_COMMERCE_PLUGIN_PATH . 'includes/mapping/GC_Sync_Mapping.php'; } // Get the current mapping configuration. $mapping = GC_Sync_Mapping::get(); // Build the response with the required fields. $response_data = array( 'version' => $mapping['version'] ?? '1.0', 'taxonomy_mappings' => $mapping['taxonomy_mappings'] ?? array(), 'meta_field_mappings' => $mapping['meta_field_mappings'] ?? array(), 'discovered_at' => $mapping['discovered_at'] ?? null, 'updated_at' => $mapping['updated_at'] ?? null, ); return new WP_REST_Response( $response_data, 200 ); } }