PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.4.0
StreamCast – bring live radio to your site with a sleek player v2.4.0
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / class-stp-block.php

class-stp-block.php in StreamCast – bring live radio to your site with a sleek player 2.4.0, at class-stp-block.php

46 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace STP;
3
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 if (!class_exists('STP_Block')) {
7 class STP_Block {
8 public function __construct() {
9 add_action('init', [__CLASS__, 'onInit']);
10 add_action('enqueue_block_assets', [__CLASS__, 'scb_enqueue_block_assets']);
11 }
12 public static function onInit() {
13 register_block_type(STP_PLUGIN_PATH . '/build');
14
15 // Register external Muses player script.
16 wp_register_script('muses-player', STP_PLUGIN_DIR . 'assets/vendor/muses-player/mrp.js', [], '1.0', false);
17 }
18
19 public static function scb_enqueue_block_assets() {
20 wp_enqueue_style('scb-style', STP_PLUGIN_DIR . 'public/css/radio.css', array(), STP_PLUGIN_VERSION, 'all');
21 wp_enqueue_style('scb-player-style', STP_PLUGIN_DIR . 'public/css/styles.css', array(), STP_PLUGIN_VERSION, 'all');
22 wp_enqueue_script('scb-script', STP_PLUGIN_DIR . 'public/js/streamcast-final.js', array('jquery'), STP_PLUGIN_VERSION, true);
23
24 // Enqueue Muses player script.
25 wp_enqueue_script('muses-player');
26
27 $data = array(
28 'iframePath' => STP_PLUGIN_DIR . 'iframe.html',
29 'ajaxUrl' => admin_url('admin-ajax.php'),
30 'plyrSvg' => STP_PLUGIN_DIR . 'assets/vendor/plyr/plyr.svg',
31 'plyrBlankVideo' => STP_PLUGIN_DIR . 'assets/vendor/plyr/blank.mp4',
32 'nonce' => wp_create_nonce('stp_fetch_nonce'),
33 );
34
35 // Pass data to JavaScript.
36 wp_localize_script('scb-streamcast-block-editor-script', 'myScriptData', $data);
37 wp_localize_script('scb-streamcast-block-view-script', 'myScriptData', $data);
38 wp_localize_script('scb-script', 'myScriptData', $data);
39 }
40
41 }
42
43 new STP_Block();
44 }
45
46