PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 1.1
WpStream – Live Streaming, Video on Demand, Pay Per View v1.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 4.5.12 All 180 releases
wpstream / libs / shortcodes.php

shortcodes.php in WpStream – Live Streaming, Video on Demand, Pay Per View 1.1, at libs/shortcodes.php

330 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 function wpstream_shortcodes(){
5 wpstream_register_shortcodes();
6 wpstream_tiny_short_codes_register();
7 }
8
9
10
11 function wpstream_register_shortcodes() {
12 add_shortcode('wpstream_player', 'wpstream_insert_player_inpage');
13 add_shortcode('wpstream_list_products', 'wpstream_list_products_function');
14 }
15
16
17
18 function wpstream_tiny_short_codes_register() {
19 if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
20 return;
21 }
22
23 if (get_user_option('rich_editing') == 'true') {
24 add_filter('mce_external_plugins', 'wpstream_add_plugin');
25 add_filter('mce_buttons_2', 'wpstream_register_button');
26 }
27
28 }
29
30
31
32 function wpstream_register_button($buttons) {
33 array_push($buttons, "|", "wpstream_player");
34 array_push($buttons, "|", "wpstream_list_products");
35 return $buttons;
36 }
37
38
39
40 function wpstream_add_plugin($plugin_array) {
41 $plugin_array['wpstream_player'] = WPSTREAM_PLUGIN_DIR_URL. '/js/shortcodes.js';
42 $plugin_array['wpstream_list_products'] = WPSTREAM_PLUGIN_DIR_URL. '/js/shortcodes.js';
43 return $plugin_array;
44 }
45
46
47
48
49
50 function wpstream_insert_player_inpage($attributes, $content = null){
51 $product_id = '';
52 $return_string = '';
53 $attributes = shortcode_atts(
54 array(
55 'id' => 0,
56 ), $attributes) ;
57
58
59 if ( isset($attributes['id']) ){
60 $product_id=$attributes['id'];
61 }
62
63 ob_start();
64 wpstream_video_player_shortcode($product_id);
65 $return_string= ob_get_contents();
66 ob_end_clean();
67
68 return $return_string;
69 }
70
71
72
73
74 function wpstream_video_player_shortcode($from_sh_id='') {
75
76 if ( is_user_logged_in() ) {
77 global $product;
78 $current_user = wp_get_current_user();
79 $product_id = intval($from_sh_id);
80
81
82 if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || get_post_type($product_id)=='wpstream_product' ){
83 global $product;
84 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
85
86
87 if( get_post_type($product_id) == 'wpstream_product' ){
88
89 $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
90 if($wpstream_product_type==1){
91 wpstream_live_event_player($product_id);
92 } else if($wpstream_product_type==2){
93 wpstream_video_on_demand_player($product_id);
94 }
95
96 }else{
97 $term_list = wp_get_post_terms($product_id, 'product_type');
98 if( $term_list[0]->name=='live_stream'){
99 wpstream_live_event_player($product_id);
100 }else if( $term_list[0]->name=='video_on_demand'){
101 wpstream_video_on_demand_player($product_id);
102 }
103 }
104
105
106
107 }else{
108 $thumb_id = get_post_thumbnail_id($product_id);
109 $thumb = wp_get_attachment_image_src($thumb_id,'medium_large');
110
111 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
112 echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').
113 '</div><img src="'.$thumb[0].'" alt="product_thumb">';
114 }
115
116 echo '</div></div>';
117 }
118 }
119
120
121
122
123
124
125
126
127
128 function wpestate_stream_validate_keys($attributes, $content = null){
129 global $wp_query;
130 $current_user = wp_get_current_user();
131 $stream_key = $wp_query->query_vars['streamname'];
132 $stream_key_array = explode('-', $stream_key);
133 $real_stream_key = $stream_key_array[0];
134
135
136 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
137
138 $args = array(
139 'posts_per_page' => -1,
140 'post_type' => 'product',
141 'meta_query' => array(
142 array(
143 'key' => 'live_event_stream_name',
144 'value' => $real_stream_key,
145 'compare' => '=',
146 ),
147 ),
148 'tax_query' => array(
149 'relation' => 'AND',
150 array(
151 'taxonomy' => 'product_type',
152 'field' => 'slug',
153 'terms' => 'live_stream'
154 )
155 ),
156 );
157
158
159 $event_list = new WP_Query($args);
160
161 if ($event_list->have_posts() ){
162 while ( $event_list->have_posts() ):
163 $event_list->the_post();
164 $the_id = get_the_ID();
165 $event_data = get_post_meta($the_id,'live_event_uri',true);
166 $show_id = $event_data['show_id'];
167
168 endwhile;
169 $get_key = wpstream_get_encryption_key($stream_key,$event_data['ip']);
170 return $get_key;
171 } else{
172 exit('not query');
173 }
174
175 }else{
176 exit('not log');
177 }
178
179 }
180
181
182
183
184
185
186
187
188
189 function wpstream_list_products_function($atts, $content=null){
190
191 $media_number = "";
192 $product_type = "";
193 $attributes = shortcode_atts(
194 array(
195 'media_number' => '4',
196 'product_type' => __('Free Live Channel','wpstream'),
197
198 ), $atts);
199
200 if ( isset($attributes['media_number']) ){
201 $media_number=$attributes['media_number'];
202 }
203
204 if ( isset($attributes['product_type']) ){
205 $product_type=$attributes['product_type'];
206 }
207
208 if($product_type== __('Free Live Channel','wpstream') ){
209 $product_type=1;
210 }else{
211 $product_type=2;
212 }
213
214 $return_string="";
215
216
217
218 $args = array(
219 'post_type' => 'wpstream_product',
220 'post_status' => 'publish',
221 'meta_query' =>array(
222 array(
223 'key' => 'wpstream_product_type',
224 'value' => $product_type,
225 'compare' => '=',
226 ),
227 ),
228 'post_per_page' =>$media_number
229 );
230
231
232 $media_list= new WP_Query($args);
233
234 if($product_type==1){
235 $see_product= __('See Free Live Chanel','wpstream');
236 }else{
237 $see_product =_('See Free Video','wpstream');
238 }
239
240
241
242 while($media_list->have_posts()):$media_list->the_post();
243 $return_string.='<div class="wpstream_product_unit">'
244 .'<div class="product_image" style="background-image:url('.wp_get_attachment_thumb_url(get_post_thumbnail_id()).')"></div>'
245 .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>'
246 .'<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>'
247 .'</div>';
248 endwhile;
249
250 wp_reset_postdata();
251 wp_reset_query();
252
253
254 return '<div class="shortcode_list_wrapper">'.$return_string.'</div>';
255
256 }
257
258
259
260
261 if( function_exists('vc_map') ):
262 vc_map(
263 array(
264 "name" => esc_html__( "WpStream Player","wpestate"),
265 "base" => "wpstream_player",
266 "class" => "",
267 "category" => esc_html__( 'WpStream','wpestate'),
268 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
269 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
270 'weight'=>100,
271 'icon' =>'',
272 'description'=>esc_html__( 'Insert WpStream Player','wpestate'),
273 "params" => array(
274 array(
275 "type" => "textfield",
276 "holder" => "div",
277 "class" => "",
278 "heading" => esc_html__( "Content Id","wpestate"),
279 "param_name" => "id",
280 "value" => "0",
281 "description" => esc_html__( "Add here the live stream id or the video id","wpestate")
282 ),
283
284 )
285 )
286 );
287
288
289
290 $product_type=array(
291 '1' => __('Free Live Channel','wpstream'),
292 '2' => __('Free Video','wpstream')
293 );
294
295 vc_map(
296 array(
297 "name" => esc_html__( "WpStream Products List","wpestate"),
298 "base" => "wpstream_list_products",
299 "class" => "",
300 "category" => esc_html__( 'WpStream','wpestate'),
301 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
302 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
303 'weight'=>100,
304 'icon' =>'',
305 'description'=>esc_html__( ' List wpstream products','wpestate'),
306 "params" => array(
307 array(
308 "type" => "textfield",
309 "holder" => "div",
310 "class" => "",
311 "heading" => esc_html__( "Media number","wpestate"),
312 "param_name" => "media_number",
313 "value" => "",
314 "description" => esc_html__( "No of media ","wpestate")
315 ),
316
317 array(
318 "type" => "dropdown",
319 "holder" => "div",
320 "class" => "",
321 "heading" => esc_html__( "Product type","wpestate"),
322 "param_name" => "product_type",
323 "value" => $product_type,
324 "description" => esc_html__( "What type of products ","wpestate")
325 ),
326
327 )
328 )
329 );
330 endif;