add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue' ) ) ); } /** * The admin app and what it needs to know. */ public static function enqueue(): void { wp_enqueue_media(); Assets::enqueue( 'settings', array( 'apiUrl' => Settings::api_url(), 'dashboardUrl' => Settings::dashboard_url(), 'adminPostUrl' => admin_url( 'admin-post.php' ), 'exportNonce' => wp_create_nonce( 'vocalstack_export' ), 'schema' => Widgets::schema(), 'maxUploadSize' => (int) wp_max_upload_size(), 'previewUrl' => WidgetPreview::url(), ) ); } /** * The VocalStack mark as a data URI. WordPress repaints SVG menu icons in * the admin colour scheme, so it matches the other menu icons. */ private static function icon(): string { $svg = file_get_contents( VOCALSTACK_DIR . 'assets/images/mark-white.svg' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- A local file. return $svg ? 'data:image/svg+xml;base64,' . base64_encode( $svg ) : 'dashicons-microphone'; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- The data URI WordPress expects for menu icons. } /** * The React root. */ public static function render(): void { printf( '

%3$s


', esc_url( VOCALSTACK_URL . 'assets/images/logo-light.svg' ), esc_attr__( 'VocalStack', 'vocalstack' ), esc_html__( 'VocalStack', 'vocalstack' ), esc_attr__( 'VocalStack dashboard', 'vocalstack' ) ); } /** * A Settings link on the Plugins screen. * * @param array $links Existing links. * @return array */ public static function action_links( array $links ): array { array_unshift( $links, '' . esc_html__( 'Settings', 'vocalstack' ) . '' ); return $links; } /** * The settings page URL. */ public static function url(): string { return admin_url( 'admin.php?page=' . self::SLUG ); } }