' . __( '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 WP_PLUGIN_DIR . '/admin-bar-tools/build/index.asset.php'; wp_enqueue_style( 'admin-bar-tools-settings-style', WP_PLUGIN_URL . '/admin-bar-tools/build/index.css', [ 'wp-components' ], $asset_file['version'], ); wp_enqueue_script( 'admin-bar-tools-settings-script', WP_PLUGIN_URL . '/admin-bar-tools/build/index.js', $asset_file['dependencies'], $asset_file['version'], true ); } /** * Set JavaScript translations. */ public function script_translations() { wp_set_script_translations( 'admin-bar-tools-settings-script', 'admin-bar-tools' ); } /** * Set register. */ public function register() { $array_item = [ 'type' => 'object', 'properties' => [ 'name' => [ 'type' => 'string' ], 'shortname' => [ 'type' => 'string' ], 'status' => [ 'type' => 'boolean' ], 'url' => [ 'type' => 'string' ], 'adminurl' => [ 'type' => 'string' ], 'order' => [ 'type' => 'number' ], ], ]; register_setting( 'admin-bar-tools-settings', 'abt_status', [ 'show_in_rest' => [ 'schema' => [ 'type' => 'object', 'properties' => [ 'psi' => $array_item, 'lh' => $array_item, 'gsc' => $array_item, 'gc' => $array_item, 'gi' => $array_item, 'twitter' => $array_item, 'facebook' => $array_item, 'hatena' => $array_item, 'bi' => $array_item, ], ], ], ] ); register_setting( 'admin-bar-tools-settings', 'abt_sc', [ 'type' => 'number', 'show_in_rest' => true, 'default' => get_option( 'abt_sc' ), ], ); register_setting( 'admin-bar-tools-settings', 'abt_locale', [ 'type' => 'string', 'show_in_rest' => true, 'default' => get_option( 'abt_locale' ), ], ); } /** * Settings page. */ public function abt_settings() { echo '
'; } }