PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.14.1
WpStream – Live Streaming, Video on Demand, Pay Per View v4.14.1
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / widgets / start_streaming.php

start_streaming.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.14.1, at widgets/start_streaming.php

181 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor widget: WpStream - Start Streaming.
4 *
5 * Registers the "Start Streaming" Elementor widget under the plugin's own
6 * widget category. It exposes a single product/free-product id control and,
7 * on render, delegates to the plugin's live-stream unit wrapper to print the
8 * broadcaster UI for that channel (or the user's first free/paid channel).
9 *
10 * @package Wpstream
11 * @subpackage Wpstream/widgets
12 */
13 namespace ElementorWpStream\Widgets;
14
15 use Elementor\Widget_Base;
16 use Elementor\Controls_Manager;
17
18 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
20
21 /**
22 * Elementor widget class for the WpStream broadcaster (start streaming).
23 *
24 * Implements the standard Elementor widget contract: identity (name/title/icon),
25 * editor controls, frontend render, and the editor preview template.
26 */
27 class Wpstream_Start_Streaming_Base extends Widget_Base {
28
29 /**
30 * Retrieve the widget name.
31 *
32 * @since 1.0.0
33 *
34 * @access public
35 *
36 * @return string Widget name.
37 */
38 public function get_name() {
39 // Internal identifier Elementor uses to reference this widget.
40 return 'Wpstream_Start_Streaming';
41 }
42
43 /**
44 * Retrieve the widget categories.
45 *
46 * @return array List of Elementor category slugs this widget belongs to.
47 */
48 public function get_categories() {
49 // Group this widget under the plugin's own "wpstream" category.
50 return [ 'wpstream' ];
51 }
52
53
54 /**
55 * Retrieve the widget title.
56 *
57 * @since 1.0.0
58 *
59 * @access public
60 *
61 * @return string Widget title.
62 */
63 public function get_title() {
64 // Wrap the translated label in the theme's widget-title markup.
65 return '<div class="wpstream_elementor_widget_title">'.__( 'WpStream - Start Streaming', 'wpstream' ).'</div>';
66 }
67
68 /**
69 * Retrieve the widget icon.
70 *
71 * @since 1.0.0
72 *
73 * @access public
74 *
75 * @return string Widget icon.
76 */
77 public function get_icon() {
78 // Elementor icon-font class shown for this widget in the panel.
79 return 'eicon-play-o';
80 }
81
82
83
84 /**
85 * Register the widget's editor controls.
86 *
87 * @access protected
88 */
89 protected function register_controls() {
90 // Theme-wide taxonomy list kept in scope (unused by this widget).
91 global $all_tax;
92
93 // Local scratch array; declared but not used by this widget.
94 $featured_places_array =array(1=>1,2=>2,3=>3);
95
96 // Open the "Content" settings section.
97 $this->start_controls_section(
98 'section_content',
99 [
100 'label' => __( 'Content', 'wpstream' ),
101 ]
102 );
103
104
105
106
107 // Text field: the product / free-product id to stream on.
108 // Left blank, we stream on the user's first free/paid channel.
109 $this->add_control(
110 'item_id',
111 [
112 'label' => __( 'Product/Free Product id', 'wpstream' ),
113 'label_block'=>true,
114 'type' => Controls_Manager::TEXT,
115 'description'=>__('If you leave this option blank we will stream on the first free/paid channel for this user','wpstream')
116 ]
117 );
118
119
120
121
122 // Close the "Content" settings section.
123 $this->end_controls_section();
124
125
126 }
127
128 /**
129 * Render the widget output on the frontend.
130 *
131 * Written in PHP and used to generate the final HTML.
132 *
133 * @since 1.0.0
134 *
135 * @access protected
136 */
137
138 /**
139 * Render the widget on the frontend.
140 *
141 * Reads the item id control and delegates to the plugin's live-stream unit
142 * wrapper, which echoes the broadcaster UI for that channel.
143 *
144 * @access protected
145 */
146 protected function render() {
147 // Pull the saved control values for this widget instance.
148 $settings = $this->get_settings_for_display();
149
150 // The chosen product/free-product id to broadcast on.
151 $attributes['id'] = $settings['item_id'] ;
152
153 // Main plugin instance that renders the live-stream unit.
154 global $wpstream_plugin;
155
156
157
158 // echo $wpstream_plugin->admin->wpstream_live_stream_unit( $attributes['id'],'front' );
159 // Echo the broadcaster UI wrapper for the chosen id, in front-end mode.
160 echo $wpstream_plugin->wpstream_live_stream_unit_wrapper( $attributes['id'],'front' );
161 }
162
163 /**
164 * Render the widget output in the editor.
165 *
166 * Written as a Backbone JavaScript template and used to generate the live preview.
167 *
168 * @since 1.0.0
169 *
170 * @access protected
171 */
172 protected function content_template() {
173 ?>
174 <div class="title">
175 <!-- Backbone/Underscore template token echoed as the live editor preview. -->
176 {{{ settings.title }}}
177 </div>
178 <?php
179 }
180 }
181