PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.14.0
WpStream – Live Streaming, Video on Demand, Pay Per View v4.14.0
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 / player.php

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

178 lines 4.7 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 Player.
4 *
5 * Registers the "WpStream Player" Elementor widget under the plugin's own
6 * widget category. It exposes a product/free-product id plus an optional user
7 * id and, on render, delegates to the main plugin object to print the player.
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/widgets
11 */
12 namespace ElementorWpStream\Widgets;
13
14 use Elementor\Widget_Base;
15 use Elementor\Controls_Manager;
16
17 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
19
20 /**
21 * Elementor widget class for the WpStream player.
22 *
23 * Implements the standard Elementor widget contract: identity (name/title/icon),
24 * editor controls, frontend render, and the editor preview template.
25 */
26 class Wpstream_Player_Base extends Widget_Base {
27
28 /**
29 * Retrieve the widget name.
30 *
31 * @since 1.0.0
32 *
33 * @access public
34 *
35 * @return string Widget name.
36 */
37 public function get_name() {
38 // Internal identifier Elementor uses to reference this widget.
39 return 'Wpstream_Player';
40 }
41
42 /**
43 * Retrieve the widget categories.
44 *
45 * @return array List of Elementor category slugs this widget belongs to.
46 */
47 public function get_categories() {
48 // Group this widget under the plugin's own "wpstream" category.
49 return [ 'wpstream' ];
50 }
51
52
53 /**
54 * Retrieve the widget title.
55 *
56 * @since 1.0.0
57 *
58 * @access public
59 *
60 * @return string Widget title.
61 */
62 public function get_title() {
63 // Wrap the translated label in the theme's widget-title markup.
64 return '<div class="wpstream_elementor_widget_title">'.__( 'WpStream Player', 'wpstream' ).'</div>';
65 }
66
67 /**
68 * Retrieve the widget icon.
69 *
70 * @since 1.0.0
71 *
72 * @access public
73 *
74 * @return string Widget icon.
75 */
76 public function get_icon() {
77 // Elementor icon-font class shown for this widget in the panel.
78 return 'eicon-play-o';
79 }
80
81
82
83 /**
84 * Register the widget's editor controls.
85 *
86 * @access protected
87 */
88 protected function register_controls() {
89 // Theme-wide taxonomy list kept in scope (unused by this widget).
90 global $all_tax;
91
92 // Open the "Content" settings section.
93 $this->start_controls_section(
94 'section_content',
95 [
96 'label' => __( 'Content', 'wpstream' ),
97 ]
98 );
99
100 // Text field: product / free-product id to build the player for.
101 $this->add_control(
102 'item_id',
103 [
104 'label' => __( 'Product/Free Product id', 'wpstream' ),
105 'label_block'=>true,
106 'type' => Controls_Manager::TEXT,
107 ]
108 );
109
110
111 // Text field: optional user id; its first channel overrides the product id.
112 $this->add_control(
113 'user_id',
114 [
115 'label' => __( 'User Id', 'wpstream' ),
116 'label_block'=>true,
117 'type' => Controls_Manager::TEXT,
118 'description' => esc_html__( "We will use the first channel of this user id(product id will be ignored.).","wpstream")
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 * Collects the control values and delegates to the plugin to echo the player.
142 *
143 * @access protected
144 */
145 protected function render() {
146 // Pull the saved control values for this widget instance.
147 $settings = $this->get_settings_for_display();
148
149 // Map the control values onto the attribute array the player expects.
150 $attributes['id'] = $settings['item_id'] ;
151 $attributes['user_id'] = $settings['user_id'] ;
152
153
154 // Main plugin instance that knows how to build the player markup.
155 global $wpstream_plugin;
156 // Echo the assembled player for the chosen product/user.
157 echo $wpstream_plugin->wpstream_insert_player_elementor($attributes);
158 }
159
160 /**
161 * Render the widget output in the editor.
162 *
163 * Written as a Backbone JavaScript template and used to generate the live preview.
164 *
165 * @since 1.0.0
166 *
167 * @access protected
168 */
169 protected function content_template() {
170 ?>
171 <div class="title">
172 <!-- Backbone/Underscore template token echoed as the live editor preview. -->
173 {{{ settings.title }}}
174 </div>
175 <?php
176 }
177 }
178