*/ 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( 'safe_mode' => array( 'type' => 'boolean' ), 'php_disabled' => array( 'type' => 'boolean' ), 'total' => array( 'type' => 'integer' ), 'active' => array( 'type' => 'integer' ), 'cached' => array( 'type' => 'integer' ), 'with_errors' => array( 'type' => 'integer' ), 'cache_in_sync' => array( 'type' => 'boolean', 'description' => __( 'False when the number of active snippets and the number in the loader cache disagree, which means some snippet is not running or is still running after a change.', 'acrossai-abilities-manager' ), ), 'wpcode_version' => array( 'type' => 'string' ), ); } /** * @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, 'fields' => 'ids', 'suppress_filters' => false, ) ); $active = 0; $with_errors = 0; foreach ( $posts as $post_id ) { $snippet = new WPCode_Snippet( (int) $post_id ); if ( $snippet->is_active() ) { ++$active; } if ( '' !== Snippet_Repository::last_error( $snippet ) ) { ++$with_errors; } } $cached = count( Snippet_Repository::cached_ids() ); return array( 'safe_mode' => WPCode_Guard::safe_mode(), 'php_disabled' => WPCode_Guard::php_disabled(), 'total' => count( $posts ), 'active' => $active, 'cached' => $cached, 'with_errors' => $with_errors, 'cache_in_sync' => $active === $cached, 'wpcode_version' => defined( 'WPCODE_VERSION' ) ? (string) WPCODE_VERSION : '', ); } }