__( 'Editorial Updates', 'ai' ), 'description' => __( 'Applies pending editorial Notes to your content and saves the post, without a preview. Use revisions to review or undo the changes. Requires an AI connector that includes support for text generation models.', 'ai' ), 'category' => Experiment_Category::EDITOR, 'usage' => array( 'trigger' => 'on_demand', 'runs' => __( 'When you click Apply Editorial Updates, which also saves the post', 'ai' ), 'sends' => __( 'Each block with pending Notes, with surrounding content', 'ai' ), 'requests' => __( 'One request per block with Notes', 'ai' ), ), ); } /** * {@inheritDoc} * * @since 0.8.0 */ public function register(): void { add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_assets' ) ); } /** * Registers any needed abilities. * * @since 0.8.0 */ public function register_abilities(): void { wp_register_ability( 'ai/' . $this->get_id(), array( 'label' => $this->get_label(), 'description' => $this->get_description(), 'ability_class' => Editorial_Updates_Ability::class, ), ); } /** * Enqueues and localizes the block editor script. * * @since 0.8.0 */ public function enqueue_assets(): void { Asset_Loader::enqueue_script( 'editorial_updates', 'experiments/editorial-updates', array( 'include_core_abilities' => true ) ); $post_type = get_post_type(); $post_type_object = $post_type ? get_post_type_object( $post_type ) : null; $rest_base = $post_type_object && $post_type_object->rest_base ? $post_type_object->rest_base : null; Asset_Loader::localize_script( 'editorial_updates', 'EditorialUpdatesData', array( 'enabled' => $this->is_enabled(), 'rest_base' => $rest_base, 'admin_url' => admin_url(), ) ); } }