PluginProbe
StreamCast – bring live radio to your site with a sleek player / trunk
StreamCast – bring live radio to your site with a sleek player vtrunk
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 / inc / class-streamcast-block.php

class-streamcast-block.php in StreamCast – bring live radio to your site with a sleek player trunk, at inc/class-streamcast-block.php

44 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace StreamCast;
3
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 if (!class_exists('STREAMCAST_Block')) {
7 class STREAMCAST_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(STREAMCAST_PLUGIN_PATH . '/build');
14
15 // Register external Muses player script.
16 wp_register_script('muses-player', STREAMCAST_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', STREAMCAST_PLUGIN_DIR . 'public/css/radio.css', array(), STREAMCAST_PLUGIN_VERSION, 'all');
21 wp_enqueue_style('scb-player-style', STREAMCAST_PLUGIN_DIR . 'public/css/styles.css', array(), STREAMCAST_PLUGIN_VERSION, 'all');
22 wp_enqueue_script('scb-script', STREAMCAST_PLUGIN_DIR . 'public/js/streamcast-final.js', array('jquery'), STREAMCAST_PLUGIN_VERSION, true);
23
24 // Enqueue Muses player script.
25 wp_enqueue_script('muses-player');
26
27 $data = array(
28 'iframePath' => STREAMCAST_PLUGIN_DIR . 'iframe.html',
29 'ajaxUrl' => admin_url('admin-ajax.php'),
30 'plyrSvg' => STREAMCAST_PLUGIN_DIR . 'assets/vendor/plyr/plyr.svg',
31 'plyrBlankVideo' => STREAMCAST_PLUGIN_DIR . 'assets/vendor/plyr/blank.mp4',
32 'nonce' => wp_create_nonce('streamcast_fetch_nonce'),
33 );
34
35 // Pass data to JavaScript.
36 wp_localize_script('scb-streamcast-block-editor-script', 'streamcastData', $data);
37 wp_localize_script('scb-streamcast-block-view-script', 'streamcastData', $data);
38 wp_localize_script('scb-script', 'streamcastData', $data);
39 }
40
41 }
42 }
43
44