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

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

188 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class StreamCast {
4 public static $_instance = null;
5
6 public static function instance() {
7 if ( is_null( self::$_instance ) ) {
8 self::$_instance = new self();
9 }
10 return self::$_instance;
11 }
12
13 public function __construct() {
14 add_action( 'init', [$this, 'init'], 0 );
15 add_action( 'plugins_loaded', [$this, 'plugins_loaded'] );
16 add_action( 'plugins_loaded', [__CLASS__, 'load_textdomain'] );
17 add_action( 'admin_enqueue_scripts', [__CLASS__, 'enqueue_admin_assets'] );
18 add_action( 'admin_menu', [__CLASS__, 'add_help_pages'] );
19 add_filter( 'admin_footer_text', [__CLASS__, 'admin_footer'] );
20 add_shortcode( 'stream', [__CLASS__, 'stream_shortcode'] );
21 }
22
23 public static function init() {
24 if ( !class_exists( 'CSF' ) ) {
25 require_once STP_PLUGIN_PATH . 'admin/codestar-framework/codestar-framework.php';
26 }
27 if ( str_fs()->can_use_premium_code__premium_only() && file_exists( STP_PLUGIN_PATH . 'premium-files/metabox-pro.php' ) ) {
28 require_once STP_PLUGIN_PATH . 'premium-files/metabox-pro.php';
29 }
30 if ( str_fs()->is_free_plan() && file_exists( STP_PLUGIN_PATH . 'admin/inc/metabox-free.php' ) ) {
31 require_once STP_PLUGIN_PATH . 'admin/inc/metabox-free.php';
32 }
33 }
34
35 public function plugins_loaded() {
36 self::load_dependencies();
37 }
38
39 private static function load_dependencies() {
40 require_once STP_PLUGIN_PATH . 'mimes/enable-mime-type.php';
41 require_once STP_PLUGIN_PATH . 'inc/Streamcast_Admin.php';
42 require_once STP_PLUGIN_PATH . 'inc/functions.php';
43 // For All Nessesary Functions
44 require_once STP_PLUGIN_PATH . 'streamcast-block.php';
45 if ( str_fs()->is_free_plan() ) {
46 require_once STP_PLUGIN_PATH . 'public/shortcode-free.php';
47 }
48 if ( str_fs()->can_use_premium_code__premium_only() && !file_exists( STP_PLUGIN_PATH . 'premium-files/shortcode-pro.php' ) ) {
49 require_once STP_PLUGIN_PATH . 'public/shortcode-free.php';
50 }
51 }
52
53 public static function load_textdomain() {
54 load_plugin_textdomain( 'streamcast', false, dirname( __FILE__ ) . "/../languages" );
55 }
56
57 public static function enqueue_admin_assets( $hook ) {
58 global $typenow;
59 if ( 'streamcast' === $typenow ) {
60 wp_enqueue_script(
61 'stp-admin-post-js',
62 STP_PLUGIN_DIR . 'build/admin-post.js',
63 [],
64 STP_PLUGIN_VERSION,
65 true
66 );
67 wp_enqueue_style(
68 'stp-admin-post-css',
69 STP_PLUGIN_DIR . 'build/admin-post.css',
70 [],
71 STP_PLUGIN_VERSION
72 );
73 }
74 if ( 'streamcast_page_help' === $hook ) {
75 wp_enqueue_style(
76 'stp-admin',
77 STP_PLUGIN_DIR . 'admin/css/admin.css',
78 [],
79 STP_PLUGIN_VERSION
80 );
81 } elseif ( 'streamcast_page_streamcast' === $hook ) {
82 wp_enqueue_script(
83 'stp-dashboard-js',
84 STP_PLUGIN_DIR . 'build/admin-help.js',
85 ['react', 'react-dom'],
86 STP_PLUGIN_VERSION,
87 true
88 );
89 wp_enqueue_script(
90 'stp-fs-js',
91 STP_PLUGIN_DIR . 'public/js/fs.js',
92 [],
93 STP_PLUGIN_VERSION,
94 true
95 );
96 wp_enqueue_style(
97 'tlgb-dashboard-css',
98 STP_PLUGIN_DIR . 'build/admin-help.css',
99 [],
100 STP_PLUGIN_VERSION
101 );
102 }
103 }
104
105 public static function add_help_pages() {
106 add_submenu_page(
107 'edit.php?post_type=streamcast',
108 'Demo & Help',
109 'Demo & Help',
110 'manage_options',
111 'streamcast',
112 [__CLASS__, 'render_dashboard']
113 );
114 }
115
116 public static function render_dashboard() {
117 ?>
118 <style>#wpcontent { padding-left: 0 !important; }</style>
119 <div id="bplAdminHelpPage"
120 data-version="<?php
121 echo esc_attr( STP_PLUGIN_VERSION );
122 ?>"
123 data-is-premium="<?php
124 echo esc_attr( stpIsPremium() );
125 ?>">
126 </div>
127 <?php
128 }
129
130 public static function admin_footer( $text ) {
131 if ( 'streamcast' === get_post_type() ) {
132 $url = 'https://wordpress.org/support/plugin/streamcast/reviews/?filter=5#new-post';
133 return sprintf( __( 'If you like <strong>StreamCast Radio Player</strong> plugin, please leave us a <a href="%s" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating.', 'streamcast' ), $url );
134 }
135 return $text;
136 }
137
138 public static function stream_shortcode( $atts ) {
139 extract( shortcode_atts( [
140 'url' => null,
141 'background' => null,
142 ], $atts ) );
143 ob_start();
144 ?>
145 <div style="width:200px;">
146 <audio id="player" controls>
147 <source src="<?php
148 echo esc_url( $url );
149 ?>" type="audio/mp3" />
150 </audio>
151 </div>
152
153 <style>
154 .plyr__control {
155 margin-right: 0 !important;
156 }
157
158 .plyr--audio .plyr__controls {
159 <?php
160 echo 'background:' . esc_html( $background ?? 'transparent' ) . '!important; border-radius:3px !important;';
161 ?>
162 }
163 </style>
164
165 <script>
166 const player = new Plyr('#player', {
167 controls: ['play', 'mute', 'volume']
168 });
169 </script>
170 <?php
171 return ob_get_clean();
172 }
173
174 public static function activation_redirect() {
175 add_option( 'stp_do_activation_redirect', true );
176 }
177
178 // public static function do_redirect_to_dashboard() {
179 // if (get_option('stp_do_activation_redirect')) {
180 // delete_option('stp_do_activation_redirect');
181 // if (!is_network_admin() && !isset($_GET['activate-multi'])) {
182 // wp_safe_redirect(admin_url('edit.php?post_type=streamcast&page=streamcast#/dashboard'));
183 // exit;
184 // }
185 // }
186 // }
187 }
188