*/ protected function input_properties(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'errors' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'additionalProperties' => true ), 'description' => __( 'One row per snippet with a recorded error.', 'acrossai-abilities-manager' ), ), 'count' => array( 'type' => 'integer' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $posts = get_posts( array( 'post_type' => Snippet_Repository::POST_TYPE, 'post_status' => array( 'publish', 'draft' ), 'numberposts' => -1, 'suppress_filters' => false, ) ); $rows = array(); foreach ( $posts as $post ) { $snippet = new WPCode_Snippet( $post ); $error = Snippet_Repository::last_error( $snippet ); if ( '' === $error ) { continue; } $rows[] = array( 'id' => (int) $snippet->get_id(), 'title' => (string) $snippet->get_title(), 'code_type' => (string) $snippet->get_code_type(), 'active' => (bool) $snippet->is_active(), 'error' => $error, ); } return array( 'errors' => $rows, 'count' => count( $rows ), ); } }