400 ] ); } $post = get_post( $post_id ); if ( ! $post instanceof \WP_Post ) { return new \WP_Error( 'thinkrank_post_not_found', __( 'No post was found for the provided ID.', 'thinkrank' ), [ 'status' => 404 ] ); } return $post; } /** * The shape one question is reported in, shared by both abilities. * * @return array */ protected function item_properties(): array { return [ 'question' => [ 'type' => 'string' ], 'answer' => [ 'type' => 'string', 'description' => __( 'The answer as stored. May contain inline HTML, which the block renders.', 'thinkrank' ), ], 'source' => [ 'type' => 'string', 'enum' => [ FAQ_Content::SOURCE_BLOCK, FAQ_Content::SOURCE_ELEMENTOR, FAQ_Content::SOURCE_BRICKS, FAQ_Content::SOURCE_BEAVER, ], 'description' => __( 'Which editor surface holds this question. Only block items can be written by update-faq.', 'thinkrank' ), ], 'schema_enabled' => [ 'type' => 'boolean', 'description' => __( 'False when that producer has its schema toggle off, so the question is on the page but contributes nothing to FAQPage.', 'thinkrank' ), ], 'image_id' => [ 'type' => 'integer' ], 'image_url' => [ 'type' => 'string' ], 'image_alt' => [ 'type' => 'string' ], ]; } /** * Which builder renders this post, in the shape the schema reports. * * @param int $post_id Post ID. * @return string One of the builder names, or 'none' for the block editor. */ protected function builder_name( int $post_id ): string { $builder = FAQ_Content::builder( $post_id ); return '' === $builder ? 'none' : $builder; } /** * The builder names a post can report. * * @return string[] */ protected function builder_enum(): array { return [ 'none', FAQ_Content::SOURCE_ELEMENTOR, FAQ_Content::SOURCE_BRICKS, FAQ_Content::SOURCE_BEAVER, ]; } }