__( 'Content Resizing', 'ai' ), 'description' => __( 'Shorten, expand, or rephrase selected block content. Requires an AI connector that includes support for text generation models.', 'ai' ), 'category' => Experiment_Category::EDITOR, 'usage' => array( 'trigger' => 'on_demand', 'runs' => __( 'When you choose Shorten, Expand, or Rephrase', 'ai' ), 'sends' => __( 'The selected paragraph', 'ai' ), 'requests' => __( 'One request per click', 'ai' ), ), ); } /** * {@inheritDoc} */ public function register(): void { add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * Registers any needed abilities. * * @since 0.9.0 */ public function register_abilities(): void { wp_register_ability( 'ai/' . $this->get_id(), array( 'label' => $this->get_label(), 'description' => $this->get_description(), 'ability_class' => Content_Resizing_Ability::class, ), ); } /** * Enqueues and localizes the admin script. * * @since 0.9.0 * * @param string $hook_suffix The current admin page hook suffix. */ public function enqueue_assets( string $hook_suffix ): void { // Load asset in new post and edit post screens only. if ( 'post.php' !== $hook_suffix && 'post-new.php' !== $hook_suffix ) { return; } Asset_Loader::enqueue_script( 'content_resizing', 'experiments/content-resizing', array( 'include_core_abilities' => true ) ); Asset_Loader::enqueue_style( 'content_resizing', 'experiments/content-resizing' ); Asset_Loader::localize_script( 'content_resizing', 'ContentResizingData', array( 'enabled' => $this->is_enabled(), 'minContentLength' => get_min_content_length( 'content-resizing', Content_Resizing_Ability::DEFAULT_MIN_CONTENT_LENGTH ), ) ); } }