# streamcast/2.2.5/inc/class-streamcast.php

StreamCast – bring live radio to your site with a sleek player, version 2.2.5. 155 lines.

- Page: https://pluginprobe.com/plugins/streamcast/2.2.5/code/inc/class-streamcast.php
- Raw: https://pluginprobe.com/plugins/streamcast/2.2.5/raw/inc/class-streamcast.php
- Modified: 2025-04-16T21:12:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/streamcast/2.2.5/code/inc/class-streamcast.php#L10-L20`.

```php
<?php

class StreamCast {

    public static function init() {
        self::load_dependencies();
        self::setup_hooks();
    }

    private static function load_dependencies() {
        require_once STP_PLUGIN_PATH . 'mimes/enable-mime-type.php';
        require_once STP_PLUGIN_PATH . 'inc/Streamcast_Admin.php';
        require_once STP_PLUGIN_PATH . 'inc/functions.php'; // For All Nessesary Functions
        require_once STP_PLUGIN_PATH . 'streamcast-block.php';
 
        if (!class_exists('CSF')) {
            require_once STP_PLUGIN_PATH . 'admin/codestar-framework/codestar-framework.php';
        } 

        if (str_fs()->is_free_plan()) {
            require_once STP_PLUGIN_PATH . 'admin/inc/metabox-free.php';
            require_once STP_PLUGIN_PATH . 'public/shortcode-free.php';
        }

        if (str_fs()->can_use_premium_code__premium_only() && file_exists(STP_PLUGIN_PATH . 'premium-files/metabox-pro.php')) {
            require_once STP_PLUGIN_PATH . 'premium-files/metabox-pro.php';
            require_once STP_PLUGIN_PATH . 'premium-files/shortcode-pro.php';
            require_once STP_PLUGIN_PATH . 'premium-files/widgets.php';
            require_once STP_PLUGIN_PATH . 'premium-files/blocks/index.php';
            require_once STP_PLUGIN_PATH . 'premium-files/assets.php';
        }

        if (str_fs()->can_use_premium_code__premium_only() && !file_exists(STP_PLUGIN_PATH . 'premium-files/shortcode-pro.php')) {
            require_once STP_PLUGIN_PATH . 'public/shortcode-free.php';
        }
    }

    private static function setup_hooks() {
        add_action('plugins_loaded', [__CLASS__, 'load_textdomain']);
        add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_admin_assets']);
        add_action('admin_menu', [__CLASS__, 'add_help_pages']);
        add_filter('admin_footer_text', [__CLASS__, 'admin_footer']);
        add_shortcode('stream', [__CLASS__, 'stream_shortcode']);
    }

    public static function load_textdomain() {
        load_plugin_textdomain('streamcast', false, dirname(__FILE__) . "/../languages");
    }

    public static function enqueue_admin_assets($hook) {
        global $typenow;
        if ('streamcast' === $typenow) {
            wp_enqueue_script('stp-admin-post-js', STP_PLUGIN_DIR . 'build/admin-post.js', [], STP_PLUGIN_VERSION, true);
            wp_enqueue_style('stp-admin-post-css', STP_PLUGIN_DIR . 'build/admin-post.css', [], STP_PLUGIN_VERSION);
        }

        if ('streamcast_page_help' === $hook) {
            wp_enqueue_style('stp-admin', STP_PLUGIN_DIR . 'admin/css/admin.css', [], STP_PLUGIN_VERSION);
        } elseif ('streamcast_page_dashboard' === $hook) {
            wp_enqueue_script('stp-dashboard-js', STP_PLUGIN_DIR . 'build/admin-help.js', ['react', 'react-dom'], STP_PLUGIN_VERSION, true);
            wp_enqueue_script('stp-fs-js', STP_PLUGIN_DIR . 'public/js/fs.js', [], STP_PLUGIN_VERSION, true);
            wp_enqueue_style('tlgb-dashboard-css', STP_PLUGIN_DIR . 'build/admin-help.css', [], STP_PLUGIN_VERSION);
        }
    }

    public static function add_help_pages() {
        add_submenu_page(
            'edit.php?post_type=streamcast',
            'Getting Started',
            'Getting Started',
            'manage_options',
            'help',
            [__CLASS__, 'render_help_page']
        );

        add_submenu_page(
            'edit.php?post_type=streamcast',
            'Demo & Help',
            'Demo & Help',
            'manage_options',
            'dashboard',
            [__CLASS__, 'render_dashboard']
        );
    }

    public static function render_help_page() {
        include_once STP_PLUGIN_PATH . 'admin/whats-new.php';
    }

    public static function render_dashboard() {
        ?>
        <style>#wpcontent { padding-left: 0 !important; }</style>
        <div id="bplAdminHelpPage"
             data-version="<?php echo esc_attr(STP_PLUGIN_VERSION); ?>"
             data-is-premium="<?php echo esc_attr(stpIsPremium()); ?>">
        </div>
        <?php
    }

    public static function admin_footer($text) {
        if ('streamcast' === get_post_type()) {
            $url = 'https://wordpress.org/support/plugin/streamcast/reviews/?filter=5#new-post';
            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);
        }
        return $text;
    }

    public static function stream_shortcode($atts) {
        extract(shortcode_atts([
            'url'        => null,
            'background' => null,
        ], $atts));

        ob_start();
        ?>
        <div style="width:200px;">
            <audio id="player" controls>
                <source src="<?php echo esc_url($url); ?>" type="audio/mp3" />
            </audio>
        </div>

        <style>
            .plyr__control {
                margin-right: 0 !important;
            }

            .plyr--audio .plyr__controls {
                <?php echo 'background:' . esc_html($background ?? 'transparent') . '!important; border-radius:3px !important;'; ?>
            }
        </style>

        <script>
            const player = new Plyr('#player', {
                controls: ['play', 'mute', 'volume']
            });
        </script>
        <?php
        return ob_get_clean();
    }

    public static function activation_redirect() {
        add_option('stp_do_activation_redirect', true);
    }

    public static function do_redirect_to_dashboard() {
        if (get_option('stp_do_activation_redirect')) {
            delete_option('stp_do_activation_redirect');
            if (!is_network_admin() && !isset($_GET['activate-multi'])) {
                wp_safe_redirect(admin_url('edit.php?post_type=streamcast&page=dashboard#/dashboard'));
                exit;
            }
        }
    }
}

```
