PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.3
WpStream – Live Streaming, Video on Demand, Pay Per View v4.3
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 4.3, at libs/shortcodes.php

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