PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.3.2
StreamCast – bring live radio to your site with a sleek player v2.3.2
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 / streamcast-block.php

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

73 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function stpIsPremium()
4 {
5 return STP_HAS_PRO ? str_fs()->can_use_premium_code() : false;
6 }
7
8
9 if (!class_exists('SCBPlugin')) {
10 class SCBPlugin
11 {
12 function __construct()
13 {
14 add_action('init', [$this, 'onInit']);
15 add_action('enqueue_block_assets', [$this, 'scb_enqueue_block_assets']);
16
17 add_action('wp_ajax_stpPipeChecker', [$this, 'stpPipeChecker']);
18 add_action('wp_ajax_nopriv_stpPipeChecker', [$this, 'stpPipeChecker']);
19 add_action('admin_init', [$this, 'registerSettings']);
20 add_action('rest_api_init', [$this, 'registerSettings']);
21 }
22
23 function stpPipeChecker()
24 {
25 $nonce = $_POST['_wpnonce'] ?? null;
26
27 if (!wp_verify_nonce($nonce, 'wp_ajax')) {
28 wp_send_json_error('Invalid Request');
29 }
30
31 wp_send_json_success([
32 'isPipe' => stpIsPremium()
33 ]);
34 }
35
36 function registerSettings()
37 {
38 register_setting('stpUtils', 'stpUtils', [
39 'show_in_rest' => [
40 'name' => 'stpUtils',
41 'schema' => ['type' => 'string']
42 ],
43 'type' => 'string',
44 'default' => wp_json_encode(['nonce' => wp_create_nonce('wp_ajax')]),
45 'sanitize_callback' => 'sanitize_text_field'
46 ]);
47 }
48
49 function onInit()
50 {
51 register_block_type(__DIR__ . '/build');
52 }
53
54 function scb_enqueue_block_assets()
55 {
56 wp_enqueue_style('scb-style', STP_PLUGIN_DIR . 'public/css/radio.css', array(), STP_PLUGIN_VERSION, 'all');
57 wp_enqueue_style('scb-player-style', STP_PLUGIN_DIR . 'public/css/styles.css', array(), STP_PLUGIN_VERSION, 'all');
58
59 wp_enqueue_script('scb-script', STP_PLUGIN_DIR . 'public/js/streamcast-final.js', array('jquery'), STP_PLUGIN_VERSION, true);
60
61 $data = array(
62 'iframePath' => STP_PLUGIN_DIR . 'iframe.html',
63 "ajaxUrl" => admin_url( 'admin-ajax.php' )
64 );
65
66 // Pass data to JavaScript
67 wp_localize_script( 'scb-streamcast-block-editor-script', 'myScriptData', $data );
68 wp_localize_script( 'scb-streamcast-block-view-script', 'myScriptData', $data );
69 }
70 }
71 new SCBPlugin();
72 }
73