PluginProbe
BeyondWords – AI audio for publishers / 7.0.0
BeyondWords – AI audio for publishers v7.0.0
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / editor / components / select-voice / class-assets.php

class-assets.php in BeyondWords – AI audio for publishers 7.0.0, at src/editor/components/select-voice/class-assets.php

81 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * BeyondWords Select Voice — asset enqueue.
4 *
5 * @package BeyondWords\Editor\Components\SelectVoice
6 * @since 7.0.0
7 */
8
9 declare( strict_types = 1 );
10
11 namespace BeyondWords\Editor\Components\SelectVoice;
12
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * Select Voice asset enqueue.
17 *
18 * @since 7.0.0
19 */
20 class Assets {
21
22 /**
23 * Register WordPress hooks.
24 */
25 public static function init(): void {
26 add_action( 'admin_enqueue_scripts', [ self::class, 'admin_enqueue_scripts' ] );
27 }
28
29 /**
30 * Enqueue the Select Voice JS on classic-editor post screens.
31 *
32 * @param string $hook Current admin page hook.
33 */
34 public static function admin_enqueue_scripts( $hook ): void {
35 if ( \BeyondWords\Core\Utils::is_gutenberg_page() ) {
36 return;
37 }
38
39 if ( 'post.php' !== $hook && 'post-new.php' !== $hook ) {
40 return;
41 }
42
43 if ( ! in_array( get_post_type(), \BeyondWords\Settings\Utils::get_compatible_post_types(), true ) ) {
44 return;
45 }
46
47 wp_register_script(
48 'beyondwords-metabox--select-voice',
49 BEYONDWORDS__PLUGIN_URI . 'src/editor/components/select-voice/classic-metabox.js',
50 [],
51 BEYONDWORDS__PLUGIN_VERSION,
52 true
53 );
54
55 wp_localize_script(
56 'beyondwords-metabox--select-voice',
57 'beyondwordsData',
58 [
59 'nonce' => wp_create_nonce( 'wp_rest' ),
60 'root' => esc_url_raw( rest_url() ),
61 'projectId' => (string) get_option( 'beyondwords_project_id', '' ),
62 // Lets the script rebuild the Accent dropdown when a language name is picked.
63 'languages' => \BeyondWords\Editor\Components\SelectVoice::languages_for_script(),
64 'selectVoice' => __( 'Select a voice', 'speechkit' ),
65 'selectModel' => __( 'Select a model', 'speechkit' ),
66 'standardModel' => __( 'Legacy', 'speechkit' ),
67 'elevenLabs' => \BeyondWords\Editor\Components\SelectVoice::ELEVENLABS_SERVICE,
68 'defaultModelId' => \BeyondWords\Editor\Components\SelectVoice::DEFAULT_ELEVENLABS_VOICE_MODEL_ID,
69 'voiceModelLabels' => [
70 'eleven_v3' => __( 'v3', 'speechkit' ),
71 'eleven_multilingual_v2' => __( 'Multilingual v2', 'speechkit' ),
72 'eleven_flash_v2_5' => __( 'Flash v2.5', 'speechkit' ),
73 'eleven_turbo_v2_5' => __( 'Turbo v2.5', 'speechkit' ),
74 ],
75 ]
76 );
77
78 wp_enqueue_script( 'beyondwords-metabox--select-voice' );
79 }
80 }
81