get_plugin_path() ), [ $this, 'add_settings_links' ] ); } /** * Add WordPress menu. */ public function add_menu() { add_options_page( 'Admin Bar Tools', 'Admin Bar Tools', 'administrator', 'admin-bar-tools', [ $this, $this->add_prefix( 'settings' ) ] ); } /** * Add configuration link to plugin page. * * @param array|string $links plugin page setting links. */ public function add_settings_links( array $links ): array { $add_link = '' . __( 'Settings', 'admin-bar-tools' ) . ''; array_unshift( $links, $add_link ); return $links; } /** * Enqueue scripts. * * @param string $hook_shuffix WordPress hook_shuffix. */ public function add_scripts( string $hook_shuffix ) { if ( 'settings_page_admin-bar-tools' !== $hook_shuffix ) { return; } $asset_file = require_once $this->get_plugin_dir() . '/build/index.asset.php'; wp_enqueue_style( $this->add_prefix( 'style' ), $this->get_plugin_url() . '/build/index.css', [ 'wp-components' ], $asset_file['version'], ); wp_enqueue_script( $this->add_prefix( 'script' ), $this->get_plugin_url() . '/build/index.js', $asset_file['dependencies'], $asset_file['version'], true ); wp_set_script_translations( $this->add_prefix( 'script' ), self::PLUGIN_SLUG, $this->get_plugin_dir() . '/languages/js', ); } /** * Set register. */ public function register() { register_setting( $this->get_option_group(), $this->add_prefix( 'options' ), [ 'show_in_rest' => [ 'schema' => [ 'type' => 'object', 'properties' => [ 'items' => [], 'locale' => [], 'sc' => [], 'version' => [], ], ], ], ], ); } /** * Settings page. */ public function abt_settings() { echo '
'; } }