query( 'wp-dataviews' ) && file_exists( $dataviews_css ) ) { wp_enqueue_style( 'ai-dataviews', WPAI_PLUGIN_URL . 'build/admin/dataviews.css', array(), (string) filemtime( $dataviews_css ) ); } Asset_Loader::enqueue_script( self::ASSET_HANDLE, self::ASSET_PATH ); Asset_Loader::enqueue_style( self::ASSET_HANDLE, self::ASSET_PATH ); // WordPress only loads DataViews' strings in block-editor contexts. wp_set_script_translations( 'wp-dataviews', 'default' ); Asset_Loader::localize_script( self::ASSET_HANDLE, 'AbilitiesExplorer', array( 'rest' => array( 'nonce' => wp_create_nonce( 'wp_rest' ), 'root' => esc_url_raw( rest_url() ), 'routes' => array( 'abilities' => Abilities_Controller::ABILITIES_ROUTE, 'item' => Abilities_Controller::ITEM_ROUTE, 'invoke' => Abilities_Controller::INVOKE_ROUTE, ), ), 'pageSlug' => self::PAGE_SLUG, 'providerLabels' => Ability_Handler::get_provider_labels(), ) ); } /** * Outputs the root DOM node the React application mounts into. * * @since 0.2.0 * @since 1.5.0 Renders only the React root. */ public function render_page(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } echo '
'; } /** * Add contextual help tabs to the screen. * * @since 0.4.0 */ public function add_help_tabs(): void { $screen = get_current_screen(); if ( ! $screen ) { return; } $screen->add_help_tab( array( 'id' => 'abilities-overview', 'title' => __( 'Overview', 'ai' ), 'content' => '

' . esc_html__( 'Abilities are a standardized way for WordPress core, plugins, and themes to expose discrete units of functionality. Each ability has a name, optional input/output schemas, and can be invoked programmatically.', 'ai' ) . '

' . '

' . esc_html__( 'The Abilities Explorer lets you browse every registered ability, inspect its schemas, and test it with custom input right from the admin.', 'ai' ) . '

', ) ); $provider_tags = array( 'strong' => array() ); $screen->add_help_tab( array( 'id' => 'abilities-providers', 'title' => esc_html__( 'Providers', 'ai' ), 'content' => '

' . esc_html__( 'Every ability is associated with a provider that indicates where it comes from:', 'ai' ) . '

' . '', ) ); $screen->add_help_tab( array( 'id' => 'abilities-testing', 'title' => esc_html__( 'Testing', 'ai' ), 'content' => '

' . esc_html__( 'You can test any ability directly from this screen:', 'ai' ) . '

' . '
    ' . '
  1. ' . esc_html__( 'Choose the "Test" action from an ability\'s row actions in the list.', 'ai' ) . '
  2. ' . '
  3. ' . __( 'Edit the pre-filled Input Data if the ability accepts JSON parameters.', 'ai' ) . '
  4. ' . '
  5. ' . __( 'Use "Validate Input" to check your JSON against the schema.', 'ai' ) . '
  6. ' . '
  7. ' . __( 'Click "Invoke Ability" to execute it and see the result.', 'ai' ) . '
  8. ' . '
', ) ); $screen->set_help_sidebar( '

' . esc_html__( 'For more information:', 'ai' ) . '

' . '

' . esc_html__( 'Abilities API Documentation', 'ai' ) . '

' ); } }