*/ protected function input_properties(): array { return array( 'id' => array( 'type' => 'integer', 'description' => __( 'Snippet id.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'snippet' => array( 'type' => 'object', 'additionalProperties' => true, 'description' => __( 'The snippet as it now stands, read back after the write.', 'acrossai-abilities-manager' ), ), 'in_cache' => array( 'type' => 'boolean', 'description' => __( 'Whether WPCode\'s loader cache now holds this snippet. This, not the database row, is what decides whether it actually runs.', 'acrossai-abilities-manager' ), ), 'safe_mode' => array( 'type' => 'boolean', 'description' => __( 'True when safe mode is suppressing every snippet on this site, in which case nothing runs regardless of this change.', 'acrossai-abilities-manager' ), ), ); } /** * @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 ) { $snippet = Snippet_Repository::find( (int) ( $input['id'] ?? 0 ) ); if ( is_wp_error( $snippet ) ) { return $snippet; } $shaped = Snippet_Repository::shape( $snippet ); return array( 'snippet' => $shaped, 'in_cache' => $shaped['in_cache'], 'safe_mode' => WPCode_Guard::safe_mode(), ); } }