array( 'type' => 'string', 'enum' => array( 'category', 'post_tag' ), 'description' => __( 'Which taxonomy.', 'acrossai-abilities-manager' ), ), 'terms' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ), 'description' => __( 'Term slugs or numeric IDs.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'taxonomy', 'terms', ); } protected function output_properties(): array { return array( 'purged' => array( 'type' => 'array' ), 'missing' => array( 'type' => 'array' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => true, ); } protected function run( array $input ) { $taxonomy = isset( $input['taxonomy'] ) ? (string) $input['taxonomy'] : ''; $terms = isset( $input['terms'] ) && is_array( $input['terms'] ) ? $input['terms'] : array(); $result = Purge_Repository::purge_taxonomy( $taxonomy, $terms ); if ( is_wp_error( $result ) ) { return $result; } return array( 'purged' => $result['purged'], 'missing' => $result['missing'], 'message' => sprintf( /* translators: 1: number purged, 2: number missing */ __( 'Purged %1$d archive(s); %2$d term(s) did not exist.', 'acrossai-abilities-manager' ), count( $result['purged'] ), count( $result['missing'] ) ), ); } }