PluginProbe
Video Grid / 1.24
Video Grid v1.24
1.25 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 All 26 releases
video-grid / wp-video-grid.php

wp-video-grid.php in Video Grid 1.24, at wp-video-grid.php

2,715 lines 159.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Video Grid With Lightbox
4 * Plugin URI:https://www.i13websolution.com/product/wordpress-responsive-video-grid-pro/
5 * Author URI:http://www.i13websolution.com
6 * Description:This is beautiful responsive video grid with responsive lightbox.Add any number of video from admin panel.
7 * Author:I Thirteen Web Solution
8 * Version:1.24
9 * Text Domain:video-grid
10 */
11
12 add_filter ( 'widget_text', 'do_shortcode' );
13 add_action ( 'admin_menu', 'responsive_video_grid_add_admin_menu' );
14 //add_action ( 'admin_init', 'responsive_video_grid_add_admin_init' );
15 register_activation_hook ( __FILE__, 'install_responsive_video_grid' );
16 register_deactivation_hook(__FILE__,'rvg_video_grid_remove_access_capabilities');
17
18 add_action ( 'wp_enqueue_scripts', 'responsive_video_grid_load_styles_and_js' );
19 add_shortcode ( 'print_responsive_video_grid', 'print_responsive_video_grid_func' );
20 add_action ( 'admin_notices', 'responsive_video_grid_admin_notices' );
21
22 add_action( 'wp_ajax_check_file_exist_grid', 'check_file_exist_grid_callback' );
23 add_action( 'wp_ajax_get_youtube_info_grid', 'get_youtube_info_grid_callback' );
24
25 add_action('plugins_loaded', 'vg_load_lang_for_responsive_video_grid');
26 add_filter( 'user_has_cap', 'rvg_video_grid_admin_cap_list' , 10, 4 );
27
28 function vg_load_lang_for_responsive_video_grid() {
29
30 load_plugin_textdomain( 'video-grid', false, basename( dirname( __FILE__ ) ) . '/languages/' );
31 add_filter( 'map_meta_cap', 'map_rvg_video_grid_meta_caps', 10, 4 );
32 }
33
34 function rvg_video_grid_admin_cap_list($allcaps, $caps, $args, $user){
35
36
37 if ( ! in_array( 'administrator', $user->roles ) ) {
38
39 return $allcaps;
40 }
41 else{
42
43 if(!isset($allcaps['rvg_video_grid_settings'])){
44
45 $allcaps['rvg_video_grid_settings']=true;
46 }
47
48 if(!isset($allcaps['rvg_video_grid_view_videos'])){
49
50 $allcaps['rvg_video_grid_view_videos']=true;
51 }
52 if(!isset($allcaps['rvg_video_grid_add_video'])){
53
54 $allcaps['rvg_video_grid_add_video']=true;
55 }
56 if(!isset($allcaps['rvg_video_grid_edit_video'])){
57
58 $allcaps['rvg_video_grid_edit_video']=true;
59 }
60 if(!isset($allcaps['rvg_video_grid_delete_video'])){
61
62 $allcaps['rvg_video_grid_delete_video']=true;
63 }
64 if(!isset($allcaps['rvg_video_grid_preview'])){
65
66 $allcaps['rvg_video_grid_preview']=true;
67 }
68
69
70 }
71
72 return $allcaps;
73
74 }
75
76 function map_rvg_video_grid_meta_caps( array $caps, $cap, $user_id, array $args ) {
77
78
79 if ( ! in_array( $cap, array(
80 'rvg_video_grid_settings',
81 'rvg_video_grid_view_videos',
82 'rvg_video_grid_add_video',
83 'rvg_video_grid_edit_video',
84 'rvg_video_grid_delete_video',
85 'rvg_video_grid_preview',
86
87 ), true ) ) {
88
89 return $caps;
90 }
91
92
93
94
95 $caps = array();
96
97 switch ( $cap ) {
98
99 case 'rvg_video_grid_settings':
100 $caps[] = 'rvg_video_grid_settings';
101 break;
102
103 case 'rvg_video_grid_view_videos':
104 $caps[] = 'rvg_video_grid_view_videos';
105 break;
106
107 case 'rvg_video_grid_add_video':
108 $caps[] = 'rvg_video_grid_add_video';
109 break;
110
111 case 'rvg_video_grid_edit_video':
112 $caps[] = 'rvg_video_grid_edit_video';
113 break;
114
115 case 'rvg_video_grid_delete_video':
116 $caps[] = 'rvg_video_grid_delete_video';
117 break;
118
119 case 'rvg_video_grid_preview':
120 $caps[] = 'rvg_video_grid_preview';
121 break;
122
123 default:
124
125 $caps[] = 'do_not_allow';
126 break;
127 }
128
129
130 return apply_filters( 'rvg_video_grid_meta_caps', $caps, $cap, $user_id, $args );
131 }
132
133 function rvg_video_grid_add_access_capabilities() {
134
135 // Capabilities for all roles.
136 $roles = array( 'administrator' );
137 foreach ( $roles as $role ) {
138
139 $role = get_role( $role );
140 if ( empty( $role ) ) {
141 continue;
142 }
143
144
145 if(!$role->has_cap( 'rvg_video_grid_settings' ) ){
146
147 $role->add_cap( 'rvg_video_grid_settings' );
148 }
149
150 if(!$role->has_cap( 'rvg_video_grid_view_videos' ) ){
151
152 $role->add_cap( 'rvg_video_grid_view_videos' );
153 }
154
155
156 if(!$role->has_cap( 'rvg_video_grid_add_video' ) ){
157
158 $role->add_cap( 'rvg_video_grid_add_video' );
159 }
160
161 if(!$role->has_cap( 'rvg_video_grid_edit_video' ) ){
162
163 $role->add_cap( 'rvg_video_grid_edit_video' );
164 }
165
166 if(!$role->has_cap( 'rvg_video_grid_delete_video' ) ){
167
168 $role->add_cap( 'rvg_video_grid_delete_video' );
169 }
170
171 if(!$role->has_cap( 'rvg_video_grid_preview' ) ){
172
173 $role->add_cap( 'rvg_video_grid_preview' );
174 }
175
176
177
178 }
179
180 $user = wp_get_current_user();
181 $user->get_role_caps();
182
183 }
184
185 function rvg_video_grid_remove_access_capabilities(){
186
187 global $wp_roles;
188
189 if ( ! isset( $wp_roles ) ) {
190 $wp_roles = new WP_Roles();
191 }
192
193 foreach ( $wp_roles->roles as $role => $details ) {
194 $role = $wp_roles->get_role( $role );
195 if ( empty( $role ) ) {
196 continue;
197 }
198
199 $role->remove_cap( 'rvg_video_grid_settings');
200 $role->remove_cap( 'rvg_video_grid_view_videos');
201 $role->remove_cap( 'rvg_video_grid_add_video');
202 $role->remove_cap( 'rvg_video_grid_edit_video');
203 $role->remove_cap( 'rvg_video_grid_delete_video');
204 $role->remove_cap( 'rvg_video_grid_preview');
205
206
207 }
208
209 // Refresh current set of capabilities of the user, to be able to directly use the new caps.
210 $user = wp_get_current_user();
211 $user->get_role_caps();
212
213 }
214
215 function get_youtube_info_grid_callback() {
216
217 if (isset($_POST) and is_array($_POST) and isset($_POST['url'])) {
218
219 $retrieved_nonce = '';
220
221 if (isset($_POST['vNonce']) and $_POST['vNonce'] != '') {
222
223 $retrieved_nonce = sanitize_text_field($_POST['vNonce']);
224 }
225 if (!wp_verify_nonce($retrieved_nonce, 'vNonce')) {
226
227
228 wp_die('Security check fail');
229 }
230
231 if (isset($_POST) and is_array($_POST) and isset($_POST['url'])) {
232
233 $vid = htmlentities(sanitize_text_field($_POST['vid']),ENT_QUOTES);
234 $url = esc_url_raw($_POST['url']);
235 $output= wp_remote_retrieve_body( wp_remote_get( $url ) );
236 $output=json_decode($output);
237
238
239 $videoInfo= wp_remote_retrieve_body( wp_remote_get( "https://www.youtube.com/watch?v=$vid"));
240
241 $pattern = '/\\"shortDescription\\":(.*)\\"isCrawlable\\"/Uis';
242 $vinfo='';
243 if(preg_match_all($pattern, $videoInfo, $matches)) {
244 if(is_array($matches) and isset($matches[1])){
245 if(isset($matches[1][0])){
246 $vinfo= stripcslashes($matches[1][0]);
247 }
248 }
249 }
250
251 $breaks = array("<br />","<br>","<br/>");
252 $vinfo = str_ireplace($breaks, "\r\n", $vinfo);
253 $vinfo=trim($vinfo);
254 $vinfo=trim($vinfo,',');
255 $vinfo=trim($vinfo,'"');
256 $vinfo=rtrim($vinfo,'"');
257 $vinfo=ltrim($vinfo,'"');
258 $vinfo=trim($vinfo,'"');
259 $vinfo=trim($vinfo,',');
260
261 $return=array();
262 if(is_object($output)){
263
264 $return['title']=$output->title;
265 $return['thumbnail_url']=$output->thumbnail_url;
266 $return['description']=$vinfo;
267
268 }
269
270 echo json_encode($return);
271 exit;
272 }
273 }
274 }
275
276 function vg_save_image($url,$saveto){
277
278 $raw = wp_remote_retrieve_body( wp_remote_get( $url ) );
279
280 if(file_exists($saveto)){
281 @unlink($saveto);
282 }
283 $fp = @fopen($saveto,'x');
284 @fwrite($fp, $raw);
285 @fclose($fp);
286
287 }
288
289 function check_file_exist_grid_callback() {
290
291 if(isset($_POST) and is_array($_POST) and isset($_POST['url'])){
292
293
294 $retrieved_nonce = '';
295
296 if (isset($_POST['vNonce']) and $_POST['vNonce'] != '') {
297
298 $retrieved_nonce = sanitize_text_field($_POST['vNonce']);
299 }
300 if (!wp_verify_nonce($retrieved_nonce, 'vNonce')) {
301
302
303 wp_die('Security check fail');
304 }
305
306 $response = wp_remote_get(sanitize_text_field($_POST['url']));
307 $httpCode = wp_remote_retrieve_response_code( $response );
308
309 echo trim((string)$httpCode);die;
310
311 }
312 //echo die;
313
314 }
315
316
317 function responsive_video_grid_admin_notices() {
318
319 if (is_plugin_active ( 'wp-video-grid/wp-video-grid.php' )) {
320
321 $uploads = wp_upload_dir();
322 $baseDir = $uploads ['basedir'];
323 $baseDir = str_replace ( "\\", "/", $baseDir );
324 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
325
326 if (file_exists ( $pathToImagesFolder ) and is_dir ( $pathToImagesFolder )) {
327
328 if (! is_writable ( $pathToImagesFolder )) {
329 echo "<div class='updated'><p>".__( 'Video Grid With Lightbox is active but does not have write permission on','video-grid')."</p><p><b>" . $pathToImagesFolder . "</b>".__( 'directory.Please allow write permission.','video-grid')."</p></div> ";
330 }
331 } else {
332
333 wp_mkdir_p ( $pathToImagesFolder );
334 if (! file_exists ( $pathToImagesFolder ) and ! is_dir ( $pathToImagesFolder )) {
335 echo "<div class='updated'><p>".__( 'Video Grid With Lightbox is active but plugin does not have permission to create directory','video-grid')."</p><p><b>" . $pathToImagesFolder . "</b> ".__( '.Please create wp-responsive-video-grid directory inside upload directory and allow write permission.','video-grid')."</p></div> ";
336 }
337 }
338 }
339
340 }
341 function responsive_video_grid_load_styles_and_js() {
342
343 if (! is_admin()) {
344
345
346 wp_register_style('wp-video-grid-lighbox-style', plugins_url('/css/wp-video-grid-lighbox-style.css', __FILE__),array(),'1.17');
347 wp_register_style('vl-box-grid-css', plugins_url('/css/vl-box-grid-css.css', __FILE__),array(),'1.11');
348 wp_register_script('vl-grid-js', plugins_url('/js/vl-grid-js.js', __FILE__),array('jquery'),'1.11');
349 wp_register_script('v_grid', plugins_url('/js/v_grid.js', __FILE__),array('jquery'),'1.11');
350
351
352 }
353 }
354 function install_responsive_video_grid() {
355 global $wpdb;
356 $table_name = $wpdb->prefix . "responsive_video_grid";
357
358 $sql = "CREATE TABLE " . $table_name . " (
359 `id` int(10) NOT NULL AUTO_INCREMENT,
360 `vtype` varchar(50) NOT NULL,
361 `vid` varchar(500) NOT NULL,
362 `video_url` varchar(1000) DEFAULT NULL,
363 `embed_url` varchar(300) NOT NULL,
364 `HdnMediaSelection` varchar(500) NOT NULL,
365 `image_name` varchar(500) NOT NULL,
366 `videotitle` varchar(1000) NOT NULL,
367 `videotitleurl` varchar(1000) DEFAULT NULL,
368 `video_description` text DEFAULT NULL,
369 `video_order` int(11) NOT NULL DEFAULT '0',
370 `open_link_in` tinyint(1) NOT NULL DEFAULT '1',
371 `enable_light_box_video_desc` tinyint(1) NOT NULL DEFAULT '1',
372 `createdon` datetime NOT NULL,
373 `slider_id` int(10) NOT NULL DEFAULT '1',
374 PRIMARY KEY (`id`)
375 );
376 ";
377
378 $responsive_video_grid_settings=array(
379 'display_video_lightbox' => '1',
380 'scollerBackground'=>'#FFFFFF',
381 'resize_images'=>'1'
382
383 );
384
385
386 $existingopt=get_option('responsive_video_grid_settings');
387 if(!is_array($existingopt)){
388
389 update_option('responsive_video_grid_settings',$responsive_video_grid_settings);
390
391 }
392 else{
393
394 $flag=false;
395 if(!isset($existingopt['resize_images'])){
396
397 $flag=true;
398 $existingopt['resize_images']='1';
399
400 }
401
402 if($flag==true){
403
404 update_option('responsive_video_grid_settings', $existingopt);
405
406 }
407 }
408
409
410 require_once (ABSPATH . 'wp-admin/includes/upgrade.php');
411 dbDelta ( $sql );
412
413 $uploads = wp_upload_dir();
414 $baseDir = $uploads ['basedir'];
415 $baseDir = str_replace ( "\\", "/", $baseDir );
416 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
417 wp_mkdir_p ( $pathToImagesFolder );
418 rvg_video_grid_add_access_capabilities();
419
420
421
422 }
423
424 function responsive_video_grid_add_admin_menu() {
425
426 $hook_suffix=add_menu_page ( __ ( 'Video Grid Plus Lightbox','video-grid' ), __ ( 'Video Grid With Lightbox','video-grid' ), 'rvg_video_grid_settings', 'video_grid_with_lightbox', 'video_grid_with_lightbox_admin_options_func' );
427 $hook_suffix=add_submenu_page ( 'video_grid_with_lightbox', __ ( 'Gallery Settings','video-grid' ), __ ( 'Gallery Settings','video-grid' ), 'rvg_video_grid_settings', 'video_grid_with_lightbox', 'video_grid_with_lightbox_admin_options_func' );
428 $hook_suffix_image=add_submenu_page ( 'video_grid_with_lightbox', __ ( 'Manage Videos','video-grid' ), __ ( 'Manage Videos','video-grid' ), 'rvg_video_grid_view_videos', 'video_grid_with_lightbox_video_management', 'video_grid_with_lightbox_video_management_func' );
429 $hook_suffix_prev=add_submenu_page ( 'video_grid_with_lightbox', __ ( 'Preview Gallery','video-grid' ), __ ( 'Preview Gallery','video-grid' ), 'rvg_video_grid_preview', 'video_grid_with_lightbox_video_preview', 'video_grid_with_lightbox_video_preview_func' );
430
431 add_action( 'load-' . $hook_suffix , 'responsive_video_grid_add_admin_init' );
432 add_action( 'load-' . $hook_suffix_image , 'responsive_video_grid_add_admin_init' );
433 add_action( 'load-' . $hook_suffix_prev , 'responsive_video_grid_add_admin_init' );
434
435 }
436 function responsive_video_grid_add_admin_init() {
437
438 $url = plugin_dir_url ( __FILE__ );
439
440 wp_enqueue_style ( 'wp-video-grid-lighbox-style', plugins_url ( '/css/wp-video-grid-lighbox-style.css', __FILE__ ) );
441 wp_enqueue_style ( 'vl-box-grid-css', plugins_url ( '/css/vl-box-grid-css.css', __FILE__ ) );
442 wp_enqueue_style ( 'admin_css', plugins_url ( '/css/admin_css.css', __FILE__ ) );
443 wp_enqueue_script ( 'jquery' );
444 wp_enqueue_script ( 'jquery.validate', $url . 'js/jquery.validate.js' );
445 wp_enqueue_script ( 'vl-grid-js', plugins_url ( '/js/vl-grid-js.js', __FILE__ ) );
446 wp_enqueue_script ( 'v_grid', plugins_url ( '/js/v_grid.js', __FILE__ ) );
447
448 responsive_video_grid_admin_scripts_init();
449 }
450
451
452 function video_grid_with_lightbox_admin_options_func(){
453
454 if ( ! current_user_can( 'rvg_video_grid_settings' ) ) {
455
456 wp_die( __( "Access Denied", "video-grid" ) );
457
458 }
459
460 if(isset($_POST['btnsave'])){
461
462 if (!check_admin_referer('action_image_add_edit', 'add_edit_image_nonce')) {
463
464 wp_die(__( 'Security check fail','video-grid'));
465 }
466
467
468 if(isset($_POST['display_video_lightbox']))
469 $display_video_lightbox=true;
470 else
471 $display_video_lightbox=false;
472
473
474 $scollerBackground=trim(htmlentities(sanitize_text_field($_POST['scollerBackground']),ENT_QUOTES));
475 $resize_images = htmlentities(sanitize_text_field($_POST['resize_images']),ENT_QUOTES);
476
477
478 $options=array();
479 $options['display_video_lightbox']=$display_video_lightbox;
480 $options['scollerBackground']=$scollerBackground;
481 $options['resize_images']=$resize_images;
482
483
484 $settings=update_option('responsive_video_grid_settings',$options);
485 $responsive_video_grid_messages=array();
486 $responsive_video_grid_messages['type']='succ';
487 $responsive_video_grid_messages['message']=__( 'Settings saved successfully.','video-grid');
488 update_option('responsive_video_grid_messages', $responsive_video_grid_messages);
489
490
491
492 }
493 $settings=get_option('responsive_video_grid_settings');
494
495 if(!isset($settings['resize_images'])){
496
497 $settings['resize_images']=1;
498
499 }
500
501 ?>
502 <div id="poststuff" >
503 <div id="post-body" class="metabox-holder columns-2" >
504 <div id="post-body-content">
505 <div class="wrap">
506 <table><tr>
507 <td>
508 <div class="fb-like" data-href="https://www.facebook.com/i13websolution" data-layout="button" data-action="like" data-size="large" data-show-faces="false" data-share="false"></div>
509 <div id="fb-root"></div>
510 <script>(function(d, s, id) {
511 var js, fjs = d.getElementsByTagName(s)[0];
512 if (d.getElementById(id)) return;
513 js = d.createElement(s); js.id = id;
514 js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2&appId=158817690866061&autoLogAppEvents=1';
515 fjs.parentNode.insertBefore(js, fjs);
516 }(document, 'script', 'facebook-jssdk'));</script>
517 </td>
518 <td>
519 <a target="_blank" title="Donate" href="https://www.i13websolution.com/donate-wordpress_image_thumbnail.php">
520 <img id="<?php echo __( 'help us for free plugin','video-grid');?>" height="30" width="90" src="<?php echo plugins_url( 'images/paypaldonate.jpg', __FILE__ ) ;?>" border="0" alt="<?php echo __( 'help us for free plugin','video-grid');?>" title="<?php echo __( 'help us for free plugin','video-grid');?>">
521 </a>
522 </td>
523 </tr>
524 </table>
525 <span><h3 style="color: blue;"><a target="_blank" href="https://www.i13websolution.com/wordpress-responsive-video-grid-pro.html"><?php echo __( 'UPGRADE TO PRO VERSION','video-grid');?></a></h3></span>
526 <?php
527 $messages=get_option('responsive_video_grid_messages');
528 $type='';
529 $message='';
530 if(isset($messages['type']) and $messages['type']!=""){
531
532 $type=$messages['type'];
533 $message=$messages['message'];
534
535 }
536
537
538 if(trim($type)=='err'){ echo "<div class='notice notice-error is-dismissible'><p>"; echo $message; echo "</p></div>";}
539 else if(trim($type)=='succ'){ echo "<div class='notice notice-success is-dismissible'><p>"; echo $message; echo "</p></div>";}
540
541
542 update_option('responsive_video_grid_messages', array());
543 ?>
544
545 <h2><?php echo __( 'Gallery Grid Settings','video-grid');?></h2>
546 <div id="poststuff">
547 <div id="post-body" class="metabox-holder columns-2">
548 <div id="post-body-content">
549 <form method="post" action="" id="scrollersettiings" name="scrollersettiings" >
550
551
552 <div class="stuffbox" id="namediv" style="width:100%;">
553 <h3><label ><?php echo __( 'Play Video In Lightbox ?','video-grid');?></label></h3>
554 <div class="inside">
555 <table>
556 <tr>
557 <td>
558 <input type="checkbox" id="display_video_lightbox" size="30" name="display_video_lightbox" value="" <?php if($settings['display_video_lightbox']==true){echo "checked='checked'";} ?> style="width:20px;">&nbsp;Play Video in Lightbox ?
559 <div style="clear:both"></div>
560 <div></div>
561 </td>
562 </tr>
563 </table>
564 <div style="clear:both"></div>
565
566 </div>
567 </div>
568 <div class="stuffbox" id="namediv" style="width:100%;">
569 <h3><label><?php echo __( 'Video Grid Background color','video-grid');?></label></h3>
570 <div class="inside">
571 <table>
572 <tr>
573 <td>
574 <input type="text" id="scollerBackground" size="30" name="scollerBackground" value="<?php echo $settings['scollerBackground']; ?>" style="width:100px;">
575 <div style="clear:both"></div>
576 <div></div>
577 </td>
578 </tr>
579 </table>
580
581 <div style="clear:both"></div>
582 </div>
583 </div>
584
585 <div class="stuffbox" id="namediv" style="width: 100%;">
586 <h3>
587 <label><?php echo __('Resize image physically?','video-grid');?></label>
588 </h3>
589 <div class="inside">
590 <table>
591 <tr>
592 <td><input style="width: 20px;" type='radio'
593 <?php
594 if ($settings ['resize_images'] == true) {
595 echo "checked='checked'";
596 }
597 ?>
598 name='resize_images' value='1'><?php echo __('yes','video-grid');?> &nbsp;<input
599 style="width: 20px;" type='radio' name='resize_images'
600 <?php
601 if ($settings ['resize_images'] == false) {
602 echo "checked='checked'";
603 }
604 ?>
605 value='0'><?php echo __('No','video-grid');?>
606 <div style="clear: both"></div>
607 <div></div></td>
608 </tr>
609 </table>
610 <div style="clear: both"></div>
611 </div>
612 </div>
613 <?php wp_nonce_field('action_image_add_edit', 'add_edit_image_nonce'); ?>
614 <input type="submit" name="btnsave" id="btnsave" value="<?php echo __( 'Save Changes','video-grid');?>" class="button-primary">&nbsp;&nbsp;<input type="button" name="cancle" id="cancle" value="<?php echo __( 'Cancle','video-grid');?>" class="button-primary" onclick="location.href='admin.php?page=video_grid_with_lightbox_video_management'">
615
616 </form>
617 <script type="text/javascript">
618
619 jQuery(document).ready(function() {
620
621 jQuery("#scrollersettiings").validate({
622 rules: {
623 scollerBackground:{
624 required:true,
625 maxlength:7
626 }
627
628
629 },
630 errorClass: "image_error",
631 errorPlacement: function(error, element) {
632 error.appendTo( element.next().next());
633 }
634
635
636 })
637
638 jQuery('#scollerBackground').wpColorPicker();
639 });
640
641 </script>
642
643 </div>
644 </div>
645 </div>
646 </div>
647 </div>
648 <div id="postbox-container-1" class="postbox-container" >
649
650 <div class="postbox">
651 <h3 class="hndle"><span></span><?php echo __( 'Access All Themes In One Price','video-grid');?></h3>
652 <div class="inside">
653 <center><a href="https://www.elegantthemes.com/affiliates/idevaffiliate.php?id=11715_0_1_10" target="_blank">
654 <img border="0" src="<?php echo plugins_url( 'images/300x250.gif', __FILE__);?>" width="250" height="250">
655 </a></center>
656
657 <div style="margin:10px 5px">
658
659 </div>
660 </div></div>
661 <div class="postbox">
662 <h3 class="hndle"><span></span><?php echo __('Google For Business Coupon','video-grid');?></h3>
663 <div class="inside">
664 <center><a href="https://goo.gl/OJBuHT" target="_blank">
665 <img src="<?php echo plugins_url( 'images/g-suite-promo-code-4.png', __FILE__ );?>" width="250" height="250" border="0">
666 </a></center>
667 <div style="margin:10px 5px">
668 </div>
669 </div>
670
671 </div>
672
673 </div>
674
675 <div class="clear"></div>
676 </div>
677 </div>
678 <?php
679 }
680
681 function video_grid_with_lightbox_video_management_func() {
682
683 $action = 'gridview';
684 global $wpdb;
685
686
687
688 if (isset ( $_GET ['action'] ) and $_GET ['action'] != '') {
689
690 $action = trim ( sanitize_text_field($_GET ['action'] ));
691 }
692 ?>
693
694 <?php
695 if (strtolower ( $action ) == strtolower ( 'gridview' )) {
696
697 $wpcurrentdir = dirname ( __FILE__ );
698 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
699
700 $uploads = wp_upload_dir();
701 $baseurl = $uploads ['baseurl'];
702 $baseurl .= '/wp-responsive-video-grid/';
703
704 if ( ! current_user_can( 'rvg_video_grid_view_videos' ) ) {
705
706 wp_die( __( "Access Denied", "video-grid" ) );
707
708 }
709 ?>
710 <div class="wrap">
711
712 <?php
713 $messages = get_option ( 'responsive_video_grid_messages' );
714 $type = '';
715 $message = '';
716 if (isset ( $messages ['type'] ) and $messages ['type'] != "") {
717
718 $type = $messages ['type'];
719 $message = $messages ['message'];
720 }
721
722 if(trim($type)=='err'){ echo "<div class='notice notice-error is-dismissible'><p>"; echo $message; echo "</p></div>";}
723 else if(trim($type)=='succ'){ echo "<div class='notice notice-success is-dismissible'><p>"; echo $message; echo "</p></div>";}
724
725
726 update_option ( 'responsive_video_grid_messages', array() );
727 ?>
728 <div id="poststuff" >
729 <div id="post-body" class="metabox-holder columns-2" >
730 <div id="post-body-content">
731 <div class="wrap">
732 <span><h3 style="color: blue;"><a target="_blank" href="https://www.i13websolution.com/wordpress-responsive-video-grid-pro.html"><?php echo __( 'UPGRADE TO PRO VERSION','video-grid');?></a></h3></span>
733 <div style="width: 100%;">
734 <div style="float: left; width: 100%;">
735 <div class="icon32 icon32-posts-post" id="icon-edit">
736 <br>
737 </div>
738 <h1>
739 <?php echo __( 'Videos','video-grid');?><a class="button add-new-h2" href="admin.php?page=video_grid_with_lightbox_video_management&action=addedit"><?php echo __( 'Add New','video-grid');?></a>
740 </h1>
741 <br />
742
743 <form method="POST" action="admin.php?page=video_grid_with_lightbox_video_management&action=deleteselected" id="posts-filter" onkeypress="return event.keyCode != 13;">
744 <div class="alignleft actions">
745 <select name="action_upper" id="action_upper">
746 <option selected="selected" value="-1"><?php echo __( 'Bulk Actions','video-grid');?></option>
747 <option value="delete"><?php echo __( 'Delete','video-grid');?></option>
748 </select>
749 <input type="submit" value="<?php echo __( 'Apply','video-grid');?>" class="button-secondary action" id="deleteselected" name="deleteselected" onclick="return confirmDelete_bulk();">
750 </div>
751 <br class="clear">
752
753 <?php
754
755 $sliderid="0";
756 if(isset($_GET['sliderid']) and $_GET['sliderid']!=""){
757 $sliderid=intval(trim($_GET['sliderid']));
758 }
759
760 $setacrionpage='admin.php?page=video_grid_with_lightbox_video_management';
761
762 if(isset($_GET['order_by']) and $_GET['order_by']!=""){
763 $setacrionpage.='&order_by='.esc_html(sanitize_text_field($_GET['order_by']));
764 }
765
766 if(isset($_GET['order_pos']) and $_GET['order_pos']!=""){
767 $setacrionpage.='&order_pos='.esc_html(sanitize_text_field($_GET['order_pos']));
768 }
769
770 $seval="";
771 if(isset($_GET['search_term']) and $_GET['search_term']!=""){
772 $seval=trim(esc_html(sanitize_text_field($_GET['search_term'])));
773 }
774 $search_term_='';
775 if(isset($_GET['search_term'])){
776
777 $search_term_='&search_term='.esc_html(sanitize_text_field($_GET['search_term']));
778 }
779
780 ?>
781 <br class="clear">
782 <?php
783 global $wpdb;
784 $settings=get_option('responsive_video_grid_settings');
785
786
787 $order_by='id';
788 $order_pos="asc";
789
790 if(isset($_GET['order_by'])){
791
792 $order_by=esc_html(sanitize_text_field($_GET['order_by']));
793 }
794
795 if(isset($_GET['order_pos'])){
796
797 $order_pos=esc_html(sanitize_text_field($_GET['order_pos']));
798 }
799 $search_term='';
800 if(isset($_GET['search_term'])){
801
802 $search_term= esc_sql(sanitize_text_field($_GET['search_term']));
803 }
804
805 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid ";
806 $queryCount = "SELECT count(*) FROM " . $wpdb->prefix . "responsive_video_grid ";
807 if($search_term!=''){
808 $query.=" where id like '%$search_term%' or videotitle like '%$search_term%' ";
809 $queryCount.=" where id like '%$search_term%' or videotitle like '%$search_term%' ";
810 }
811
812 $order_by=sanitize_text_field(sanitize_sql_orderby($order_by));
813 $order_pos=sanitize_text_field(sanitize_sql_orderby($order_pos));
814
815 $query.=" order by $order_by $order_pos";
816
817
818 $rowsCount=$wpdb->get_var($queryCount);
819
820 ?>
821 <div style="padding-top:5px;padding-bottom:5px">
822 <b><?php echo __( 'Search','best-testimonial-slider');?> : </b>
823 <input type="text" value="<?php echo $seval;?>" id="search_term" name="search_term">&nbsp;
824 <input type='button' value='<?php echo __( 'Search','video-grid');?>' name='searchusrsubmit' class='button-primary' id='searchusrsubmit' onclick="SearchredirectTO();" >&nbsp;
825 <input type='button' value='<?php echo __( 'Reset Search','video-grid');?>' name='searchreset' class='button-primary' id='searchreset' onclick="ResetSearch();" >
826 </div>
827 <script type="text/javascript" >
828 jQuery('#search_term').on("keyup", function(e) {
829 if (e.which == 13) {
830
831 SearchredirectTO();
832 }
833 });
834 function SearchredirectTO(){
835 var redirectto='<?php echo $setacrionpage; ?>';
836 var searchval=jQuery('#search_term').val();
837 redirectto=redirectto+'&search_term='+jQuery.trim(encodeURIComponent(searchval));
838 window.location.href=redirectto;
839 }
840 function ResetSearch(){
841
842 var redirectto='<?php echo $setacrionpage; ?>';
843 window.location.href=redirectto;
844 exit;
845 }
846 </script>
847
848 <br/>
849 <div id="no-more-tables">
850 <table cellspacing="0" id="gridTbl"
851 class="table-bordered table-striped table-condensed cf">
852 <thead>
853 <tr>
854 <th class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th>
855 <?php if($order_by=="id" and $order_pos=="asc"):?>
856 <th><a href="<?php echo $setacrionpage;?>&order_by=id&order_pos=desc<?php echo $search_term_;?>"><?php echo __('Id','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/desc.png', __FILE__); ?>"/></a></th>
857 <?php else:?>
858 <?php if($order_by=="id"):?>
859 <th><a href="<?php echo $setacrionpage;?>&order_by=id&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Id','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/asc.png', __FILE__); ?>"/></a></th>
860 <?php else:?>
861 <th><a href="<?php echo $setacrionpage;?>&order_by=id&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Id','video-grid');?></a></th>
862 <?php endif;?>
863 <?php endif;?>
864 <?php if($order_by=="vtype" and $order_pos=="asc"):?>
865 <th><a href="<?php echo $setacrionpage;?>&order_by=vtype&order_pos=desc<?php echo $search_term_;?>"><?php echo __('Video Type','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/desc.png', __FILE__); ?>"/></a></th>
866 <?php else:?>
867 <?php if($order_by=="vtype"):?>
868 <th><a href="<?php echo $setacrionpage;?>&order_by=vtype&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Video Type','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/asc.png', __FILE__); ?>"/></a></th>
869 <?php else:?>
870 <th><a href="<?php echo $setacrionpage;?>&order_by=vtype&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Video Type','video-grid');?></a></th>
871 <?php endif;?>
872 <?php endif;?>
873 <?php if($order_by=="videotitle" and $order_pos=="asc"):?>
874 <th><a href="<?php echo $setacrionpage;?>&order_by=videotitle&order_pos=desc<?php echo $search_term_;?>"><?php echo __('Title','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/desc.png', __FILE__); ?>"/></a></th>
875 <?php else:?>
876 <?php if($order_by=="videotitle"):?>
877 <th><a href="<?php echo $setacrionpage;?>&order_by=videotitle&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Title','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/asc.png', __FILE__); ?>"/></a></th>
878 <?php else:?>
879 <th><a href="<?php echo $setacrionpage;?>&order_by=videotitle&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Title','video-grid');?></a></th>
880 <?php endif;?>
881 <?php endif;?>
882 <th><span></span></th>
883 <?php if($order_by=="createdon" and $order_pos=="asc"):?>
884 <th><a href="<?php echo $setacrionpage;?>&order_by=createdon&order_pos=desc<?php echo $search_term_;?>"><?php echo __('Published On','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/desc.png', __FILE__); ?>"/></a></th>
885 <?php else:?>
886 <?php if($order_by=="createdon"):?>
887 <th><a href="<?php echo $setacrionpage;?>&order_by=createdon&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Published On','video-grid');?><img style="vertical-align:middle" src="<?php echo plugins_url('/images/asc.png', __FILE__); ?>"/></a></th>
888 <?php else:?>
889 <th><a href="<?php echo $setacrionpage;?>&order_by=createdon&order_pos=asc<?php echo $search_term_;?>"><?php echo __('Published On','video-grid');?></a></th>
890 <?php endif;?>
891 <?php endif;?>
892 <th><span><?php echo __( 'Edit','video-grid');?></span></th>
893 <th><span><?php echo __( 'Delete','video-grid');?></span></th>
894 </tr>
895 </thead>
896
897 <tbody id="the-list">
898 <?php
899 if ($rowsCount > 0) {
900
901 global $wp_rewrite;
902 $rows_per_page = 15;
903
904 $current = (isset ( $_GET ['paged'] )) ? (intval($_GET ['paged'])) : 1;
905 $pagination_args = array (
906 'base' => @add_query_arg ( 'paged', '%#%' ),
907 'format' => '',
908 'total' => ceil ( $rowsCount/ $rows_per_page ),
909 'current' => $current,
910 'show_all' => false,
911 'type' => 'plain'
912 );
913
914 $offset = ($current - 1) * $rows_per_page;
915 $query.=" limit $offset, $rows_per_page";
916 $rows = $wpdb->get_results ( $query,ARRAY_A);
917 $delRecNonce = wp_create_nonce('delete_image');
918 foreach($rows as $row) {
919
920
921 $id = $row ['id'];
922 $editlink = "admin.php?page=video_grid_with_lightbox_video_management&action=addedit&id=$id";
923 $deletelink = "admin.php?page=video_grid_with_lightbox_video_management&action=delete&id=$id&nonce=$delRecNonce";
924
925 $outputimgmain = $baseurl . $row ['image_name'].'?rand='. rand(0, 5000);
926 ?>
927 <tr valign="top">
928 <td class="alignCenter check-column" data-title="<?php echo __( 'Select Record','video-grid');?>">
929 <input type="checkbox" value="<?php echo $row['id'] ?>" name="thumbnails[]">
930 </td>
931 <td data-title="<?php echo __( 'Id','video-grid');?>" class="alignCenter"><?php echo $row['id']; ?></td>
932 <td data-title="<?php echo __( 'Video Type','video-grid');?>" class="alignCenter">
933 <div>
934 <strong><?php echo $row['vtype']; ?></strong>
935 </div>
936 </td>
937 <td data-title="<?php echo __( 'Title','video-grid');?>" class="alignCenter">
938 <div>
939 <strong><?php echo $row['videotitle']; ?></strong>
940 </div>
941 </td>
942 <td class="alignCenter">
943 <img src="<?php echo $outputimgmain; ?>" style="width: 50px" height="50px" />
944 </td>
945 <td data-title="<?php echo __( 'Published On','video-grid');?>" class="alignCenter"><?php echo $row['createdon'] ?></td>
946 <td data-title="<?php echo __( 'Edit','video-grid');?>" class="alignCenter">
947 <strong>
948 <a href='<?php echo $editlink; ?>' title="<?php echo __( 'Edit','video-grid');?>">
949 <?php echo __( 'Edit','video-grid');?>
950 </a>
951 </strong>
952 </td>
953 <td data-title="<?php echo __( 'Delete','video-grid');?>" class="alignCenter">
954 <strong>
955 <a href='<?php echo $deletelink; ?>' onclick="return confirmDelete();" title="<?php echo __( 'Delete','video-grid');?>">
956 <?php echo __( 'Delete','video-grid');?>
957 </a>
958 </strong>
959 </td>
960 </tr>
961 <?php
962 }
963 } else {
964 ?>
965 <tr valign="top" class=""
966 id="">
967 <td colspan="8" data-title="<?php echo __( 'No Records','video-grid');?>" align="center">
968 <strong>
969 <?php echo __( 'No Videos Found','video-grid');?>
970 </strong>
971 </td>
972 </tr>
973 <?php
974 }
975 ?>
976 </tbody>
977 </table>
978 </div>
979 <?php
980 if ($rowsCount > 0) {
981 echo "<div class='pagination' style='padding-top:10px'>";
982 echo paginate_links ( $pagination_args );
983 echo "</div>";
984 }
985 ?>
986 <br />
987 <div class="alignleft actions">
988 <select name="action" id="action_bottom">
989 <option selected="selected" value="-1">
990 <?php echo __( 'Bulk Actions','video-grid');?>
991 </option>
992 <option value="delete">
993 <?php echo __( 'Delete','video-grid');?>
994 </option>
995 </select>
996 <?php wp_nonce_field('action_settings_mass_delete', 'mass_delete_nonce'); ?>
997 <input type="submit" value="<?php echo __( 'Apply','video-grid');?>" class="button-secondary action" id="deleteselected" name="deleteselected" onclick="return confirmDelete_bulk();">
998 </div>
999
1000 </form>
1001 <script type="text/JavaScript">
1002
1003 function confirmDelete_bulk(){
1004 var topval=document.getElementById("action_bottom").value;
1005 var bottomVal=document.getElementById("action_upper").value;
1006
1007 if(topval=='delete' || bottomVal=='delete'){
1008
1009
1010 var agree=confirm("<?php echo __( 'Are you sure you want to delete selected videos?','video-grid');?>");
1011 if (agree)
1012 return true ;
1013 else
1014 return false;
1015 }
1016 }
1017 function confirmDelete(){
1018 var agree=confirm("<?php echo __( 'Are you sure you want to delete this video?','video-grid');?>");
1019 if (agree)
1020 return true ;
1021 else
1022 return false;
1023 }
1024 </script>
1025
1026 <br class="clear">
1027 </div>
1028 <div style="clear: both;"></div>
1029 <?php $url = plugin_dir_url(__FILE__); ?>
1030
1031
1032 </div>
1033 <h3><?php echo __( 'To print this video gallery into WordPress Post/Page use below code','video-grid');?></h3>
1034 <input type="text" value='[print_responsive_video_grid] ' style="width: 400px; height: 30px" onclick="this.focus(); this.select()" />
1035 <div class="clear"></div>
1036 <h3><?php echo __( 'To print this video gallery into WordPress theme/template PHP files use below code','video-grid');?></h3>
1037 <?php
1038 $shortcode = '[print_responsive_video_grid]';
1039 ?>
1040 <input type="text" value="&lt;?php echo do_shortcode('<?php echo htmlentities($shortcode, ENT_QUOTES); ?>'); ?&gt;" style="width: 400px; height: 30px" onclick="this.focus(); this.select()" />
1041 <div class="clear"></div>
1042 </div>
1043 </div>
1044 <div id="postbox-container-1" class="postbox-container" >
1045
1046 <div class="postbox">
1047 <h3 class="hndle"><span></span><?php echo __( 'Access All Themes In One Price','video-grid');?></h3>
1048 <div class="inside">
1049 <center><a href="http://www.elegantthemes.com/affiliates/idevaffiliate.php?id=11715_0_1_10" target="_blank">
1050 <img border="0" src="<?php echo plugins_url( 'images/300x250.gif', __FILE__ );?>" width="250" height="250">
1051 </a></center>
1052
1053 <div style="margin:10px 5px">
1054
1055 </div>
1056 </div></div>
1057 <div class="postbox">
1058 <h3 class="hndle"><span></span><?php echo __('Google For Business Coupon','video-grid');?></h3>
1059 <div class="inside">
1060 <center><a href="https://goo.gl/OJBuHT" target="_blank">
1061 <img src="<?php echo plugins_url( 'images/g-suite-promo-code-4.png', __FILE__ );?>" width="250" height="250" border="0">
1062 </a></center>
1063 <div style="margin:10px 5px">
1064 </div>
1065 </div>
1066
1067 </div>
1068
1069 </div>
1070 </div>
1071 </div>
1072 <?php
1073 } else if (strtolower ( $action ) == strtolower ( 'addedit' )) {
1074 $url = plugin_dir_url ( __FILE__ );
1075 $vNonce = wp_create_nonce('vNonce');
1076 ?><?php
1077 if (isset ( $_POST ['btnsave'] )) {
1078
1079 if (!check_admin_referer('action_image_add_edit', 'add_edit_image_nonce')) {
1080
1081 wp_die(__( 'Security check fail','video-grid'));
1082 }
1083
1084 $uploads = wp_upload_dir();
1085 $baseDir = $uploads ['basedir'];
1086 $baseDir = str_replace ( "\\", "/", $baseDir );
1087 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
1088
1089 $vtype = trim ( htmlentities(sanitize_text_field ( $_POST ['vtype'] ),ENT_QUOTES) );
1090 $videourl = trim ( htmlentities(esc_url_raw($_POST ['videourl'] ),ENT_QUOTES));
1091
1092
1093 // echo $videourl;die;
1094 $vid = uniqid ( 'vid_' );
1095 $embed_url='';
1096 if ($vtype == 'youtube') {
1097 // parse
1098
1099 $parseUrl = @parse_url ( $videourl );
1100 if (is_array ( $parseUrl )) {
1101
1102 $queryStr = $parseUrl ['query'];
1103 parse_str ( $queryStr, $array );
1104 if (is_array ( $array ) and isset ( $array ['v'] )) {
1105
1106 $vid = $array ['v'];
1107 }
1108 }
1109
1110 $embed_url="//www.youtube.com/embed/$vid";
1111 }
1112 else if($vtype=='dailymotion'){
1113
1114 $url_arr = parse_url($videourl);
1115 if(isset($url_arr['query'])){
1116
1117 $query = $url_arr['query'];
1118 $videourl = str_replace(array($query,'?'), '', $videourl);
1119
1120 }
1121
1122 $pos = strpos($videourl, '/video/');
1123 $vid=0;
1124 if ($pos !== false){
1125
1126 $vid=substr($videourl, $pos+strlen('/video/'));
1127
1128 }
1129
1130
1131 $embed_url="//www.dailymotion.com/embed/video/$vid";
1132
1133 }
1134
1135
1136 $HdnMediaSelection = trim ( htmlentities(esc_url_raw($_POST ['HdnMediaSelection'] ),ENT_QUOTES));
1137 $videotitle = trim ( htmlentities(sanitize_text_field($_POST ['videotitle'] ),ENT_QUOTES));
1138 $videotitleurl = trim ( htmlentities(esc_url_raw($_POST ['videotitleurl'] ),ENT_QUOTES));
1139 $video_order = 0;
1140
1141 $video_description = '';
1142
1143 $videotitle = str_replace("'","",$videotitle);
1144 $videotitle = str_replace('"', '&quot;', $videotitle);
1145
1146 $open_link_in = 0;
1147
1148 $enable_light_box_video_desc = 0;
1149
1150 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1151 // edit save
1152 if (isset ( $_POST ['videoid'] )) {
1153
1154 if ( ! current_user_can( 'rvg_video_grid_edit_video' ) ) {
1155
1156 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1157 $responsive_video_grid_messages = array ();
1158 $responsive_video_grid_messages ['type'] = 'err';
1159 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1160 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1161 echo "<script type='text/javascript'> location.href='$location';</script>";
1162 exit ();
1163
1164
1165 }
1166
1167 try {
1168
1169 $videoidEdit=intval($_POST ['videoid']);
1170 if (trim ( $_POST ['HdnMediaSelection'] ) != '') {
1171 $pInfo = pathinfo ( $HdnMediaSelection );
1172 $ext = $pInfo ['extension'];
1173 if($ext==''){
1174 if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_PNG) {
1175
1176 $ext='png';
1177 }
1178 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_JPEG) {
1179
1180 $ext='jpeg';
1181 }
1182 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_GIF) {
1183
1184 $ext='gif';
1185 }
1186 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_WEBP) {
1187
1188 $ext='webp';
1189 }
1190
1191 }
1192 $imagename = $vid . '_big.' . $ext;
1193 $imageUploadTo = $pathToImagesFolder . '/' . $imagename;
1194 //@copy ( $HdnMediaSelection, $imageUploadTo );
1195
1196 @copy ( $HdnMediaSelection, $imageUploadTo );
1197 if(!file_exists($imageUploadTo)){
1198 vg_save_image($HdnMediaSelection,$imageUploadTo);
1199 }
1200
1201 $settings=get_option('responsive_video_grid_settings');
1202 $imageheight = 270;
1203 $imagewidth = 360;
1204 @unlink($pathToImagesFolder.'/'.$vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext);
1205 }
1206
1207 $query = "update " . $wpdb->prefix . "responsive_video_grid
1208 set vtype='$vtype',vid='$vid',video_url='$videourl',embed_url='$embed_url',image_name='$imagename',HdnMediaSelection='$HdnMediaSelection',
1209 videotitle='$videotitle',videotitleurl='$videotitleurl',video_description='$video_description',video_order=$video_order,
1210 open_link_in=$open_link_in,enable_light_box_video_desc=$enable_light_box_video_desc where id=$videoidEdit";
1211
1212
1213 $wpdb->query ( $query );
1214
1215 $responsive_video_grid_messages = array();
1216 $responsive_video_grid_messages ['type'] = 'succ';
1217 $responsive_video_grid_messages ['message'] = __( 'Video updated successfully.','video-grid');
1218 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1219
1220 } catch ( Exception $e ) {
1221
1222 $responsive_video_grid_messages = array();
1223 $responsive_video_grid_messages ['type'] = 'err';
1224 $responsive_video_grid_messages ['message'] = __( 'Error while adding video','video-grid');
1225 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1226 }
1227
1228
1229
1230 echo "<script type='text/javascript'> location.href='$location';</script>";
1231 exit();
1232 } else {
1233
1234 // add new
1235
1236 if ( ! current_user_can( 'rvg_video_grid_add_video' ) ) {
1237
1238 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1239 $responsive_video_grid_messages = array ();
1240 $responsive_video_grid_messages ['type'] = 'err';
1241 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1242 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1243 echo "<script type='text/javascript'> location.href='$location';</script>";
1244 exit ();
1245
1246
1247 }
1248
1249 $createdOn = current_time ( 'Y-m-d h:i:s' );
1250
1251 try {
1252
1253 if (trim ( $_POST ['HdnMediaSelection'] ) != '') {
1254 $pInfo = pathinfo ( $HdnMediaSelection );
1255 $ext = isset($pInfo ['extension'])?$pInfo ['extension']:'';
1256 if($ext==''){
1257 if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_PNG) {
1258
1259 $ext='png';
1260 }
1261 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_JPEG) {
1262
1263 $ext='jpeg';
1264 }
1265 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_GIF) {
1266
1267 $ext='gif';
1268 }
1269 else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_WEBP) {
1270
1271 $ext='webp';
1272 }
1273
1274 }
1275 $imagename = $vid . '_big.' . $ext;
1276 $imageUploadTo = $pathToImagesFolder . '/' . $imagename;
1277 //@copy ( $HdnMediaSelection, $imageUploadTo );
1278
1279 @copy ( $HdnMediaSelection, $imageUploadTo );
1280 if(!file_exists($imageUploadTo)){
1281 vg_save_image($HdnMediaSelection,$imageUploadTo);
1282 }
1283
1284 }
1285
1286 $query = "INSERT INTO " . $wpdb->prefix . "responsive_video_grid
1287 (vtype, vid,video_url,embed_url,image_name,HdnMediaSelection,videotitle,videotitleurl,video_description,video_order,open_link_in,
1288 enable_light_box_video_desc,createdon)
1289 VALUES ('$vtype','$vid','$videourl','$embed_url','$imagename','$HdnMediaSelection','$videotitle','$videotitleurl','$video_description',
1290 $video_order,$open_link_in,$enable_light_box_video_desc,'$createdOn')";
1291
1292 //echo $query;die;
1293 $wpdb->query ( $query );
1294
1295 $responsive_video_grid_messages = array();
1296 $responsive_video_grid_messages ['type'] = 'succ';
1297 $responsive_video_grid_messages ['message'] = __( 'New video added successfully.','video-grid');
1298 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1299 }
1300 catch ( Exception $e ) {
1301
1302 $responsive_video_grid_messages = array();
1303 $responsive_video_grid_messages ['type'] = 'err';
1304 $responsive_video_grid_messages ['message'] = __( 'Error while adding video','video-grid');
1305 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1306 }
1307
1308 echo "<script type='text/javascript'> location.href='$location';</script>";
1309 exit();
1310 }
1311 }
1312 else {
1313
1314 $uploads = wp_upload_dir();
1315 $baseurl = $uploads ['baseurl'];
1316 $baseurl .= '/wp-responsive-video-grid/';
1317 ?>
1318 <div id="poststuff" >
1319 <div id="post-body" class="metabox-holder columns-2" >
1320 <div id="post-body-content">
1321 <div class="wrap">
1322 <div style="float: left; width: 100%;">
1323 <div class="wrap">
1324 <?php
1325 if (isset ( $_GET ['id'] ) and intval($_GET ['id']) > 0) {
1326
1327
1328 if ( ! current_user_can( 'rvg_video_grid_edit_video' ) ) {
1329
1330 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1331 $responsive_video_grid_messages = array ();
1332 $responsive_video_grid_messages ['type'] = 'err';
1333 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1334 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1335 echo "<script type='text/javascript'> location.href='$location';</script>";
1336 exit ();
1337
1338
1339 }
1340
1341 $id = intval($_GET ['id']);
1342 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$id";
1343
1344 $myrow = $wpdb->get_row ( $query );
1345
1346 if (is_object ( $myrow )) {
1347
1348 $vtype = $myrow->vtype;
1349 $title = $myrow->videotitle;
1350 $image_name = $myrow->image_name;
1351 $video_url = $myrow->video_url;
1352 $HdnMediaSelection = $myrow->HdnMediaSelection;
1353 $videotitle = $myrow->videotitle;
1354 $videotitleurl=$myrow->videotitleurl;
1355 $video_order = $myrow->video_order;
1356 $video_description = $myrow->video_description;
1357 $open_link_in = $myrow->open_link_in ;
1358 $enable_light_box_video_desc = $myrow->enable_light_box_video_desc;
1359 }
1360 ?>
1361 <h2><?php echo __( 'Update Video','video-grid');?></h2>
1362 <?php
1363 }
1364
1365 else {
1366
1367 $vtype='';
1368 $title = '';
1369 $videotitle='';
1370 $videotitleurl='';
1371 $HdnMediaSelection='';
1372 $video_url = '';
1373 $image_link = '';
1374 $image_name = '';
1375 $video_order = '';
1376 $video_description = '';
1377 $open_link_in = true;
1378 $enable_light_box_video_desc = true;
1379
1380 if ( ! current_user_can( 'rvg_video_grid_add_video' ) ) {
1381
1382 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1383 $responsive_video_grid_messages = array ();
1384 $responsive_video_grid_messages ['type'] = 'err';
1385 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1386 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1387 echo "<script type='text/javascript'> location.href='$location';</script>";
1388 exit ();
1389
1390
1391 }
1392
1393 ?>
1394 <div style="clear:both">
1395 <span><h3 style="color: blue;">
1396 <a target="_blank" href="https://www.i13websolution.com/wordpress-responsive-video-grid-pro.html"><?php echo __( 'UPGRADE TO PRO VERSION','video-grid');?></a>
1397 </h3>
1398 </span>
1399 </div>
1400 <h2><?php echo __( 'Add Video','video-grid');?></h2>
1401 <?php } ?>
1402 <br />
1403 <div id="poststuff">
1404 <div id="post-body" class="metabox-holder columns-2">
1405 <div id="post-body-content">
1406 <form method="post" action="" id="addimage" name="addimage" enctype="multipart/form-data">
1407 <div class="stuffbox" id="namediv" style="width: 100%">
1408 <h3>
1409 <label for="link_name"><?php echo __( 'Video Information','video-grid');?> (<span
1410 style="font-size: 11px; font-weight: normal"><?php echo __('Choose Video Site','video-grid'); ?></span>)
1411 </label>
1412 </h3>
1413 <div class="inside">
1414 <div>
1415 <input type="radio" value="youtube" name="vtype" <?php if($vtype=='youtube'): ?> checked='checked' <?php endif;?> style="width: 15px" id="type_youtube" /><?php echo __( 'Youtube','video-grid');?>&nbsp;&nbsp;
1416 <input <?php if($vtype=='dailymotion'): ?> checked='checked' <?php endif;?> type="radio" value="dailymotion" name="vtype" style="width: 15px" id="type_DailyMotion" /><?php echo __( 'DailyMotion','video-grid');?>&nbsp;&nbsp;
1417 </div>
1418 <div style="clear: both"></div>
1419 <div></div>
1420 <div style="clear: both"></div>
1421 <br />
1422 <div>
1423 <b><?php echo __( 'Video Url','video-grid');?></b>
1424 <input type="text" id="videourl" class="url" tabindex="1" size="30" name="videourl" value="<?php echo $video_url; ?>">
1425 </div>
1426 <div style="clear: both"></div>
1427 <div></div>
1428 <div style="clear: both">
1429 <div id="youtube_note" style="font-size:12px;display:none">
1430 <?php echo __('Please do not use youtube.be, instead of use youtube.com','video-grid');?>
1431 </div>
1432 </div>
1433 </div>
1434 </div>
1435 <div class="stuffbox" id="namediv" style="width: 100%">
1436 <h3>
1437 <label for="link_name"><?php echo __( 'Video Thumbnail Information','video-grid');?></label>
1438 </h3>
1439 <div class="inside" id="fileuploaddiv">
1440 <?php if ($image_name != "") { ?>
1441 <div>
1442 <b><?php echo __( 'Current Image','video-grid');?> : </b>
1443 <br/>
1444 <img id="img_disp" name="img_disp" src="<?php echo $baseurl . $image_name; ?>" />
1445 </div>
1446 <?php }else{ ?>
1447 <img src="<?php echo plugins_url('/images/no-img.jpeg', __FILE__); ?>" id="img_disp" name="img_disp" />
1448
1449 <?php } ?>
1450 <br /> <a href="javascript:;" class="niks_media" id="videoFromExternalSite" ><b><?php echo __( 'Click Here to get video information and thumbnail','video-grid');?><span id='fromval'> <?php echo __( 'from','video-grid');?> <?php echo $vtype;?></span>
1451 </b></a>&nbsp;<img src="<?php echo plugins_url('/images/ajax-loader.gif', __FILE__); ?>" style="display: none" id="loading_img" name="loading_img" />
1452 <div style="clear: both"></div>
1453 <div></div>
1454 <div class="uploader">
1455 <br /> <b style="margin-left: 50px;">OR</b>
1456 <div style="clear: both; margin-top: 15px;"></div>
1457 <a href="javascript:;" class="niks_media" id="myMediaUploader"><b><?php echo __( 'Click Here to upload custom video thumbnail','video-grid');?></b></a>
1458 <br /> <br />
1459 <div>
1460 <input id="HdnMediaSelection" name="HdnMediaSelection" type="hidden" value="<?php echo $HdnMediaSelection;?>" />
1461 </div>
1462 <div style="clear: both"></div>
1463 <div></div>
1464 <div style="clear: both"></div>
1465
1466 <br />
1467 </div>
1468 <script>
1469
1470 function GetParameterValues(param,str) {
1471 var return_p='';
1472 var url = str.slice(str.indexOf('?') + 1).split('&');
1473 for (var i = 0; i < url.length; i++) {
1474 var urlparam = url[i].split('=');
1475 if (urlparam[0] == param) {
1476 return_p= urlparam[1];
1477 }
1478 }
1479 return return_p;
1480 }
1481
1482
1483 function UrlExists(url, cb){
1484 jQuery.ajax({
1485 url: url,
1486 dataType: 'text',
1487 type: 'GET',
1488 complete: function(xhr){
1489 if(typeof cb === 'function')
1490 cb.apply(this, [xhr.status]);
1491 }
1492 });
1493 }
1494
1495 function getDailyMotionId(url) {
1496
1497 if (url.indexOf("?") > 0) {
1498 url = url.substring(0, url.indexOf("?"));
1499 }
1500
1501 var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
1502 if (m !== null) {
1503 if(m[4] !== undefined) {
1504 return m[4];
1505 }
1506 return m[2];
1507 }
1508 return null;
1509 }
1510
1511
1512 jQuery(document).ready(function() {
1513
1514
1515 jQuery("input:radio[name=vtype]").click(function() {
1516
1517
1518 var value = jQuery(this).val();
1519 jQuery("#fromval").html(" from " + value);
1520 if(value=="youtube"){
1521
1522 jQuery("#youtube_note").show();
1523 }
1524 else{
1525
1526 jQuery("#youtube_note").hide();
1527 }
1528 });
1529
1530 jQuery("#videoFromExternalSite").click(function() {
1531
1532
1533 var videoService = jQuery('input[name="vtype"]:checked').length;
1534 var videourlVal = jQuery.trim(jQuery("#videourl").val());
1535 var flag = true;
1536 if (videourlVal == '' && videoService == 0){
1537
1538 alert('<?php echo __( 'Please select video site','video-grid');?>.\n <?php echo __( 'Please enter video url.','video-grid');?>');
1539 jQuery("input:radio[name=vtype]").focus();
1540 flag = false;
1541
1542 }
1543 else if (videoService == 0){
1544
1545 alert('Please select video site.');
1546 jQuery("input:radio[name=vtype]").focus();
1547 flag = false;
1548 }
1549 else if (videourlVal == ''){
1550
1551 alert('Please enter video url.');
1552 jQuery("#videourl").focus();
1553 flag = false;
1554 }
1555
1556 if (flag){
1557
1558 setTimeout(function() {
1559 jQuery("#loading_img").show();
1560 }, 100);
1561
1562 var selectedRadio = jQuery('input[name=vtype]');
1563 var checkedValueRadio = selectedRadio.filter(':checked').val();
1564 if (checkedValueRadio == 'youtube') {
1565 var vId = GetParameterValues('v', videourlVal);
1566 if(vId!=''){
1567
1568
1569 var tumbnailImg='https://img.youtube.com/vi/'+vId+'/maxresdefault.jpg';
1570
1571 var data = {
1572 'action': 'check_file_exist_grid',
1573 'url': tumbnailImg,
1574 'vNonce':'<?php echo $vNonce; ?>'
1575 };
1576
1577 jQuery.post(ajaxurl, data, function(response) {
1578
1579
1580
1581 var youtubeJsonUri='https://www.youtube.com/oembed?url=https://www.youtube.com/watch%3Fv='+vId+'&format=json';
1582 var data_youtube = {
1583 'action': 'get_youtube_info_grid',
1584 'url': youtubeJsonUri,
1585 'vid':vId,
1586 'vNonce':'<?php echo $vNonce; ?>'
1587 };
1588
1589 jQuery.post(ajaxurl, data_youtube, function(data) {
1590
1591 data = jQuery.parseJSON(data);
1592
1593 if(typeof data =='object'){
1594 if(typeof data =='object'){
1595
1596 if(data.title!='' && data.title!=''){
1597 jQuery("#videotitle").val(data.title);
1598 }
1599 jQuery("#videotitleurl").val(videourlVal);
1600 if(data.description!='' && data.description!=''){
1601 jQuery("#video_description").val(data.description);
1602 }
1603 if(response=='404' && data.thumbnail_url!=''){
1604 tumbnailImg=data.thumbnail_url;
1605 }
1606 else{
1607 tumbnailImg='https://img.youtube.com/vi/'+vId+'/0.jpg';
1608 }
1609
1610 jQuery("#img_disp").attr('src', tumbnailImg);
1611 jQuery("#HdnMediaSelection").val(tumbnailImg);
1612 jQuery("#loading_img").hide();
1613
1614 }
1615
1616 }
1617 jQuery("#loading_img").hide();
1618 })
1619
1620
1621 });
1622
1623 }
1624 else{
1625 alert('<?php echo __( 'Could not found such video','video-grid');?>');
1626 jQuery("#loading_img").hide();
1627 }
1628 }
1629 else if(checkedValueRadio == 'dailymotion'){
1630
1631 var vid=getDailyMotionId(videourlVal);
1632 var apiUrl='https://api.dailymotion.com/video/'+vid+'?fields=description,id,thumbnail_720_url,title';
1633 jQuery.getJSON( apiUrl, function( data ) {
1634 if(typeof data =='object'){
1635
1636
1637 jQuery("#HdnMediaSelection").val(data.thumbnail_720_url);
1638 jQuery("#videotitle").val(jQuery.trim(data.title));
1639 jQuery("#videotitleurl").val(videourlVal);
1640 jQuery("#img_disp").attr('src', data.thumbnail_720_url);
1641 jQuery("#loading_img").hide();
1642 }
1643 jQuery("#loading_img").hide();
1644 })
1645
1646
1647 jQuery("#loading_img").hide();
1648 }
1649
1650 jQuery("#loading_img").hide();
1651 }
1652
1653 setTimeout(function() {
1654 jQuery("#loading_img").hide();
1655 }, 2000);
1656
1657 });
1658 //uploading files variable
1659 var custom_file_frame;
1660 jQuery("#myMediaUploader").click(function(event) {
1661
1662 event.preventDefault();
1663 //If the frame already exists, reopen it
1664 if (typeof (custom_file_frame) !== "undefined") {
1665 custom_file_frame.close();
1666 }
1667
1668 //Create WP media frame.
1669 custom_file_frame = wp.media.frames.customHeader = wp.media({
1670 //Title of media manager frame
1671 title: "WP Media Uploader",
1672 library: {
1673 type: 'image'
1674 },
1675 button: {
1676 //Button text
1677 text: "Set Image"
1678 },
1679 //Do not allow multiple files, if you want multiple, set true
1680 multiple: false
1681 });
1682 //callback for selected image
1683 custom_file_frame.on('select', function() {
1684
1685 var attachment = custom_file_frame.state().get('selection').first().toJSON();
1686 var validExtensions = new Array();
1687 validExtensions[0] = 'jpg';
1688 validExtensions[1] = 'jpeg';
1689 validExtensions[2] = 'png';
1690 validExtensions[3] = 'gif';
1691 validExtensions[4] = 'webp';
1692
1693 var inarr = parseInt(jQuery.inArray(attachment.subtype, validExtensions));
1694 if (inarr > 0 && attachment.type.toLowerCase() == 'image'){
1695
1696 var titleTouse = "";
1697 var imageDescriptionTouse = "";
1698 if (jQuery.trim(attachment.title) != ''){
1699
1700 titleTouse = jQuery.trim(attachment.title);
1701 }
1702 else if (jQuery.trim(attachment.caption) != ''){
1703
1704 titleTouse = jQuery.trim(attachment.caption);
1705 }
1706
1707 if (jQuery.trim(attachment.description) != ''){
1708
1709 imageDescriptionTouse = jQuery.trim(attachment.description);
1710 }
1711 else if (jQuery.trim(attachment.caption) != ''){
1712
1713 imageDescriptionTouse = jQuery.trim(attachment.caption);
1714 }
1715
1716 // jQuery("#videotitle").val(titleTouse);
1717 // jQuery("#video_description").val(imageDescriptionTouse);
1718
1719 if (attachment.id != ''){
1720
1721 jQuery("#HdnMediaSelection").val(attachment.url);
1722 jQuery("#img_disp").attr('src', attachment.url);
1723
1724 }
1725
1726 }
1727 else{
1728
1729 alert('<?php echo __( 'Invalid image selection.','video-grid');?>');
1730 }
1731 //do something with attachment variable, for example attachment.filename
1732 //Object:
1733 //attachment.alt - image alt
1734 //attachment.author - author id
1735 //attachment.caption
1736 //attachment.dateFormatted - date of image uploaded
1737 //attachment.description
1738 //attachment.editLink - edit link of media
1739 //attachment.filename
1740 //attachment.height
1741 //attachment.icon - don't know WTF?))
1742 //attachment.id - id of attachment
1743 //attachment.link - public link of attachment, for example ""http://site.com/?attachment_id=115""
1744 //attachment.menuOrder
1745 //attachment.mime - mime type, for example image/jpeg"
1746 //attachment.name - name of attachment file, for example "my-image"
1747 //attachment.status - usual is "inherit"
1748 //attachment.subtype - "jpeg" if is "jpg"
1749 //attachment.title
1750 //attachment.type - "image"
1751 //attachment.uploadedTo
1752 //attachment.url - http url of image, for example "http://site.com/wp-content/uploads/2012/12/my-image.jpg"
1753 //attachment.width
1754 });
1755 //Open modal
1756 custom_file_frame.open();
1757 });
1758 })
1759 </script>
1760 </div>
1761 </div>
1762
1763 <div class="stuffbox" id="namediv" style="width: 100%">
1764 <h3>
1765 <label for="link_name"><?php echo __( 'Video Title','video-grid');?> (<span
1766 style="font-size: 11px; font-weight: normal"><?php echo __('Used into lightbox','video-grid'); ?></span>)
1767 </label>
1768 </h3>
1769 <div class="inside">
1770 <div>
1771 <input type="text" id="videotitle" tabindex="1" size="30" name="videotitle" value="<?php echo $videotitle; ?>">
1772 </div>
1773 <div style="clear: both"></div>
1774 <div></div>
1775 <div style="clear: both"></div>
1776 </div>
1777 </div>
1778 <div class="stuffbox" id="namediv" style="width: 100%">
1779 <h3>
1780 <label for="link_name"><?php echo __( 'Video Title Url','video-grid');?> (<span
1781 style="font-size: 11px; font-weight: normal"><?php echo __('Click on title redirect to this url.Used in lightbox for video title','video-grid'); ?></span>)
1782 </label>
1783 </h3>
1784 <div class="inside">
1785 <div>
1786 <input type="text" id="videotitleurl" class="url" tabindex="1" size="30" name="videotitleurl" value="<?php echo $videotitleurl; ?>">
1787 </div>
1788 <div style="clear: both"></div>
1789 <div></div>
1790 <div style="clear: both"></div>
1791
1792 </div>
1793 </div>
1794
1795
1796 <?php if (isset($_GET['id']) and intval($_GET['id']) > 0) { ?>
1797 <input type="hidden" name="videoid" id="videoid" value="<?php echo intval($_GET['id']); ?>">
1798 <?php
1799 }
1800 ?>
1801 <?php wp_nonce_field('action_image_add_edit','add_edit_image_nonce'); ?>
1802 <input type="submit" onclick="" name="btnsave" id="btnsave" value="<?php echo __( 'Save Changes','video-grid');?>" class="button-primary">&nbsp;&nbsp;<input type="button" name="cancle" id="cancle" value="<?php echo __( 'Cancel','video-grid');?>" class="button-primary" onclick="location.href = 'admin.php?page=video_grid_with_lightbox_video_management'">
1803
1804 </form>
1805 <script type="text/javascript">
1806
1807
1808 jQuery(document).ready(function() {
1809
1810 jQuery.validator.setDefaults({
1811 ignore: [],
1812 // any other default options and/or rules
1813 });
1814
1815 jQuery("#addimage").validate({
1816 rules: {
1817 videotitle: {
1818 required:true,
1819 maxlength: 200
1820 },
1821 vtype: {
1822 required:true
1823
1824 },
1825 videourl: {
1826 required:true,
1827 url:true,
1828 maxlength: 500
1829 },
1830 HdnMediaSelection:{
1831 required:true
1832 },
1833 videotitleurl: {
1834
1835 url:true,
1836 maxlength: 500
1837 }
1838
1839 },
1840 errorClass: "image_error",
1841 errorPlacement: function(error, element) {
1842 error.appendTo(element.parent().next().next());
1843 }, messages: {
1844 HdnMediaSelection: "<?php echo __( 'Please select video thumbnail or Upload by wordpress media uploader.','video-grid');?>",
1845
1846 }
1847
1848 })
1849 });
1850
1851 function validateFile(){
1852
1853 if(jQuery('#currImg').length>0 || jQuery.trim(jQuery("#HdnMediaSelection").val())!="" ){
1854 return true;
1855 }
1856 else
1857 {
1858 jQuery("#err_daynamic").remove();
1859 jQuery("#myMediaUploader").after('<br/><label class="image_error" id="err_daynamic">Please select file.</label>');
1860 return false;
1861 }
1862
1863 }
1864 </script>
1865
1866 </div>
1867 </div>
1868 </div>
1869
1870 </div>
1871 </div>
1872 </div>
1873 </div>
1874 <div id="postbox-container-1" class="postbox-container" >
1875
1876 <div class="postbox">
1877 <h3 class="hndle"><span></span><?php echo __( 'Access All Themes In One Price','video-grid');?></h3>
1878 <div class="inside">
1879 <center><a href="http://www.elegantthemes.com/affiliates/idevaffiliate.php?id=11715_0_1_10" target="_blank">
1880 <img border="0" src="<?php echo plugins_url( 'images/300x250.gif', __FILE__ );?>" width="250" height="250">
1881 </a></center>
1882
1883 <div style="margin:10px 5px">
1884
1885 </div>
1886 </div></div>
1887 <div class="postbox">
1888 <h3 class="hndle"><span></span><?php echo __('Google For Business Coupon','video-grid');?></h3>
1889 <div class="inside">
1890 <center><a href="https://goo.gl/OJBuHT" target="_blank">
1891 <img src="<?php echo plugins_url( 'images/g-suite-promo-code-4.png', __FILE__ );?>" width="250" height="250" border="0">
1892 </a></center>
1893 <div style="margin:10px 5px">
1894 </div>
1895 </div>
1896
1897 </div>
1898
1899 </div>
1900 </div>
1901 </div>
1902 <?php
1903 }
1904 } else if (strtolower ( $action ) == strtolower ( 'delete' )) {
1905
1906 $retrieved_nonce = '';
1907
1908 if(isset($_GET['nonce']) and $_GET['nonce']!=''){
1909
1910 $retrieved_nonce=sanitize_text_field($_GET['nonce']);
1911
1912 }
1913 if (!wp_verify_nonce($retrieved_nonce, 'delete_image' ) ){
1914
1915
1916 wp_die('Security check fail');
1917 }
1918
1919 if ( ! current_user_can( 'rvg_video_grid_delete_video' ) ) {
1920
1921 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1922 $responsive_video_grid_messages = array ();
1923 $responsive_video_grid_messages ['type'] = 'err';
1924 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1925 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1926 echo "<script type='text/javascript'> location.href='$location';</script>";
1927 exit ();
1928
1929
1930 }
1931
1932 $uploads = wp_upload_dir();
1933 $baseDir = $uploads ['basedir'];
1934 $baseDir = str_replace ( "\\", "/", $baseDir );
1935 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
1936
1937
1938 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1939 $deleteId = intval($_GET ['id']);
1940
1941 try {
1942
1943 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$deleteId";
1944 $myrow = $wpdb->get_row ( $query );
1945
1946 if (is_object ( $myrow )) {
1947
1948 $image_name = $myrow->image_name;
1949 $wpcurrentdir = dirname ( __FILE__ );
1950 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
1951 $imagetoDel = $pathToImagesFolder . '/' . $image_name;
1952 $settings=get_option('responsive_video_grid_settings');
1953 $imageheight = 270;
1954 $imagewidth = 360;
1955
1956 $pInfo = pathinfo ( $myrow->HdnMediaSelection );
1957 $ext = $pInfo ['extension'];
1958
1959 @unlink ( $imagetoDel );
1960 @unlink($pathToImagesFolder.'/'.$myrow->vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext);
1961
1962
1963 $query = "delete from " . $wpdb->prefix . "responsive_video_grid where id=$deleteId";
1964 $wpdb->query ( $query );
1965
1966 $responsive_video_grid_messages = array();
1967 $responsive_video_grid_messages ['type'] = 'succ';
1968 $responsive_video_grid_messages ['message'] = __( 'Video deleted successfully.','video-grid');
1969 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1970
1971 }
1972
1973 }
1974 catch ( Exception $e ) {
1975
1976 $responsive_video_grid_messages = array();
1977 $responsive_video_grid_messages ['type'] = 'err';
1978 $responsive_video_grid_messages ['message'] = __( 'Error while deleting video.','video-grid');
1979 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
1980 }
1981
1982 echo "<script type='text/javascript'> location.href='$location';</script>";
1983 exit();
1984 }
1985 else if (strtolower ( $action ) == strtolower ( 'deleteselected' )) {
1986
1987
1988 if(!check_admin_referer('action_settings_mass_delete','mass_delete_nonce')){
1989
1990 wp_die(__( 'Security check fail','video-grid'));
1991 }
1992
1993 if ( ! current_user_can( 'rvg_video_grid_delete_video' ) ) {
1994
1995 $location = "admin.php?page=video_grid_with_lightbox_video_management";
1996 $responsive_video_grid_messages = array ();
1997 $responsive_video_grid_messages ['type'] = 'err';
1998 $responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid');
1999 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
2000 echo "<script type='text/javascript'> location.href='$location';</script>";
2001 exit ();
2002
2003
2004 }
2005
2006 $location = "admin.php?page=video_grid_with_lightbox_video_management";
2007
2008 if (isset ( $_POST ) and isset ( $_POST ['deleteselected'] ) and ($_POST ['action'] == 'delete' or $_POST ['action_upper'] == 'delete')) {
2009
2010 $uploads = wp_upload_dir();
2011 $baseDir = $uploads ['basedir'];
2012 $baseDir = str_replace ( "\\", "/", $baseDir );
2013 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
2014
2015 if (sizeof ( $_POST ['thumbnails'] ) > 0) {
2016
2017 $deleteto = $_POST ['thumbnails'];
2018 $implode = implode ( ',', $deleteto );
2019
2020 try {
2021
2022 $settings=get_option('responsive_video_grid_settings');
2023 $imageheight = 270;
2024 $imagewidth = 360;
2025
2026 foreach ( $deleteto as $img ) {
2027
2028 $img=intval($img);
2029 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$img";
2030 $myrow = $wpdb->get_row ( $query );
2031
2032 if (is_object ( $myrow )) {
2033
2034 $image_name = $myrow->image_name;
2035 $wpcurrentdir = dirname ( __FILE__ );
2036 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
2037 $imagetoDel = $pathToImagesFolder . '/' . $image_name;
2038
2039 $pInfo = pathinfo ( $myrow->HdnMediaSelection );
2040 $ext = $pInfo ['extension'];
2041
2042 @unlink ( $imagetoDel );
2043 @unlink($pathToImagesFolder.'/'.$myrow->vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext);
2044
2045
2046
2047 $query = "delete from " . $wpdb->prefix . "responsive_video_grid where id=$img";
2048 $wpdb->query ( $query );
2049
2050 $responsive_video_grid_messages = array();
2051 $responsive_video_grid_messages ['type'] = 'succ';
2052 $responsive_video_grid_messages ['message'] = __( 'selected videos deleted successfully.','video-grid');
2053 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
2054 }
2055 }
2056 } catch ( Exception $e ) {
2057
2058 $responsive_video_grid_messages = array();
2059 $responsive_video_grid_messages ['type'] = 'err';
2060 $responsive_video_grid_messages ['message'] = __( 'Error while deleting videos.','video-grid');
2061 update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages );
2062 }
2063
2064 echo "<script type='text/javascript'> location.href='$location';</script>";
2065 exit();
2066 } else {
2067
2068 echo "<script type='text/javascript'> location.href='$location';</script>";
2069 exit();
2070 }
2071 } else {
2072
2073 echo "<script type='text/javascript'> location.href='$location';</script>";
2074 exit();
2075 }
2076 }
2077 }
2078 function video_grid_with_lightbox_video_preview_func() {
2079
2080 global $wpdb;
2081
2082
2083 if ( ! current_user_can( 'rvg_video_grid_preview' ) ) {
2084
2085 wp_die( __( "Access Denied", "video-grid" ) );
2086
2087 }
2088
2089 $settings=get_option('responsive_video_grid_settings');
2090
2091 $rand_Numb = uniqid ( 'thumnail_slider' );
2092 $rand_Num_td = uniqid ( 'divSliderMain' );
2093 $rand_var_name = uniqid ( 'rand_' );
2094
2095
2096 $wpcurrentdir = dirname ( __FILE__ );
2097 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
2098 // $settings=get_option('thumbnail_slider_settings');
2099
2100 $uploads = wp_upload_dir();
2101 $baseDir = $uploads ['basedir'];
2102 $baseDir = str_replace ( "\\", "/", $baseDir );
2103 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
2104 $baseurl = $uploads ['baseurl'];
2105 $baseurl .= '/wp-responsive-video-grid/';
2106 ?>
2107 <style type='text/css'>
2108 #<?php echo $rand_Num_td;?> {background: none repeat scroll 0 0<?php echo $settings ['scollerBackground'];?> ! important;
2109 border: 0px none !important;
2110 box-shadow: 0 0 0 0 !important;
2111
2112 }
2113 #poststuff #post-body.columns-2{margin-right: 0px}
2114 </style>
2115 <?php
2116 $wpcurrentdir = dirname ( __FILE__ );
2117 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
2118 $randOmeAlbName = uniqid ( 'alb_' );
2119 $randOmeRel = uniqid ( 'rel_' );
2120
2121 if(!isset($settings['resize_images'])){
2122
2123 $settings['resize_images']=1;
2124
2125 }
2126
2127 ?>
2128 <div style="width: 100%;">
2129 <div style="float: left; width: 100%;">
2130 <div class="wrap_grid">
2131 <h2><?php echo __( 'Grid Preview','video-grid');?></h2>
2132
2133 <?php if (is_array($settings)) { ?>
2134 <div id="poststuff">
2135 <div id="post-body" class="metabox-holder columns-2">
2136 <div id="post-body-content">
2137 <div style="clear: both;"></div>
2138 <?php $url = plugin_dir_url(__FILE__); ?>
2139
2140 <div class="wrap_grid" id="<?php echo $rand_Num_td; ?>">
2141 <div id="<?php echo $rand_Numb; ?>" class="responsivegrid" style="margin-top: 2px !important;">
2142 <div class="box_parent">
2143 <?php
2144 global $wpdb;
2145 $imageheight = 270;
2146 $imagewidth = 360;
2147 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid order by createdon desc";
2148 $rows = $wpdb->get_results ( $query, 'ARRAY_A' );
2149
2150 if (count ( $rows ) > 0) {
2151
2152 foreach ( $rows as $row ) {
2153
2154 $imagename = $row ['image_name'];
2155 $video_url = $row ['video_url'];
2156 $imageUploadTo = $pathToImagesFolder . '/' . $imagename;
2157 $imageUploadTo = str_replace ( "\\", "/", $imageUploadTo );
2158 $pathinfo = pathinfo ( $imageUploadTo );
2159 $filenamewithoutextension = $pathinfo ['filename'];
2160 $outputimg = "";
2161
2162 if($settings['resize_images']==0){
2163
2164 $outputimg = $baseurl . $row ['image_name'];
2165 }
2166 else{
2167
2168 $imagetoCheck = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2169
2170 /* if (file_exists ( $imagetoCheck )) {
2171 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2172
2173 } else {*/
2174
2175 if (function_exists ( 'wp_get_image_editor' )) {
2176
2177 $image = wp_get_image_editor ( $pathToImagesFolder . "/" . $row ['image_name'] );
2178
2179 if (! is_wp_error ( $image )) {
2180 $image->resize ( $imagewidth, $imageheight, true );
2181 $image->save ( $imagetoCheck );
2182 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2183 } else {
2184 $outputimg = $baseurl . $row ['image_name'];
2185 }
2186 } else if (function_exists ( 'image_resize' )) {
2187
2188 $return = image_resize ( $pathToImagesFolder . "/" . $row ['image_name'], $imagewidth, $imageheight );
2189 if (! is_wp_error ( $return )) {
2190
2191 $isrenamed = rename ( $return, $imagetoCheck );
2192 if ($isrenamed) {
2193 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2194 } else {
2195 $outputimg = $baseurl . $row ['image_name'];
2196 }
2197 } else {
2198 $outputimg = $baseurl . $row ['image_name'];
2199 }
2200 } else {
2201
2202 $outputimg = $baseurl . $row ['image_name'];
2203 }
2204
2205 // $url = plugin_dir_url(__FILE__)."imagestoscroll/".$filenamewithoutextension.'_'.$imageheight.'_'.$imagewidth.'.'.$pathinfo['extension'];
2206 //}
2207 }
2208
2209 $embed_url=$row['embed_url'];
2210
2211 $title="";
2212
2213 $rowTitle = stripslashes_deep($row['videotitle']);
2214 $rowTitle = str_replace('"', "'", $rowTitle);
2215 $rowTitle=str_replace("'","",$rowTitle);
2216 $rowTitle=preg_replace('/\\\\/', '', $rowTitle);
2217
2218
2219 $rowDescrption=$row['video_description'];
2220 $rowDescrption=str_replace("'","",$rowDescrption);
2221 $rowDescrption=str_replace('"','',$rowDescrption);
2222 $rowDescrption=strip_tags($rowDescrption);
2223
2224 if(strlen($rowDescrption)>300){
2225
2226 $rowDescrption=substr($rowDescrption,0,300)."...";
2227 }
2228 //$openImageInNewTab='_blank';
2229 $open_link_in=$row['open_link_in'];
2230 // if($open_link_in==0){
2231 $openImageInNewTab='_self';
2232 //}
2233
2234 if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])!=''){
2235
2236 $title="<a class='Imglink' target='$openImageInNewTab' href='{$row['videotitleurl']}'>{$rowTitle}</a>";
2237 if($row['video_description']!=''){
2238 $title.="<div class='clear_description_'>{$rowDescrption}</div>";
2239 }
2240 }
2241 else if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])==''){
2242
2243 $title="<a class='Imglink' href='#'>{$rowTitle}</a>";
2244 if($row['video_description']!=''){
2245 $title.="<div class='clear_description_'>{$rowDescrption}</div>";
2246 }
2247 }
2248 else{
2249
2250 if($row['video_description']!='')
2251 $title="<div class='clear_description_'>{$row['video_description']}</div>";
2252 }
2253
2254 $title= htmlentities($title);
2255 $rowDescrption= htmlentities($rowDescrption);
2256 //$rowTitle= htmlentities($rowTitle);
2257
2258 ?>
2259
2260
2261 <div class="box_grid">
2262 <div class="boxInner_grid">
2263
2264 <?php if($settings['display_video_lightbox']==true):?>
2265 <a rel="<?php echo $randOmeRel;?>" data-overlay="1" data-title="<?php echo $title;?>" class="video_lbox" href="<?php echo $embed_url;?>">
2266 <img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/>
2267 <span class="playbtnCss"></span>
2268 <div class="titleBox"><?php echo $rowTitle;?></div>
2269 </a>
2270 <?php else : ?>
2271
2272 <a href="<?php echo $video_url;?>">
2273 <img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/>
2274 <span class="playbtnCss"></span>
2275 <div class="titleBox"><?php echo $rowTitle;?></div>
2276 </a>
2277
2278 <?php endif;?>
2279 </div>
2280 </div>
2281
2282 <?php } ?>
2283 <?php } ?>
2284 </div>
2285 </div>
2286 </div>
2287 <script>
2288 var uniqObj=jQuery("a[rel='<?php echo $randOmeRel;?>']");
2289
2290 jQuery(document).ready(function(){
2291
2292 videoPlacements('<?php echo $rand_Numb; ?>',jQuery);
2293 jQuery(".video_lbox").fancybox_vg({
2294 'type' : "iframe",
2295 'overlayColor':'#000000',
2296 'padding': 10,
2297 'autoScale': true,
2298 'autoDimensions':true,
2299 'transitionIn': 'none',
2300 'uniqObj':uniqObj,
2301 'transitionOut': 'none',
2302 'titlePosition': 'outside',
2303 'hideOnContentClick':false,
2304 'width' : 650,
2305 'height' : 400,
2306 'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
2307
2308 var currtElem = jQuery('#<?php echo $rand_Numb; ?> a[href="'+currentOpts.href+'"]');
2309
2310 var isoverlay = jQuery(currtElem).attr('data-overlay')
2311
2312 if(isoverlay=="1" && jQuery.trim(title)!=""){
2313 return '<span id="fancybox_vg-title-over">' + title + '</span>';
2314 }
2315 else{
2316 return '';
2317 }
2318
2319 },
2320
2321 });
2322
2323 });
2324
2325
2326
2327 var width__ = jQuery(window).width();
2328 var timer__;
2329 jQuery(window).bind('resize', function(){
2330 if(jQuery(window).width() != width__){
2331
2332 width__ = jQuery(window).width();
2333 timer__ && clearTimeout(timer__);
2334 timer__ = setTimeout(function(){
2335
2336 videoPlacements('<?php echo $rand_Numb; ?>',jQuery);
2337
2338 }, 200);
2339
2340 }
2341 });
2342
2343 </script>
2344
2345 </div>
2346 </div>
2347 </div>
2348 <?php } ?>
2349 </div>
2350 </div>
2351 <div class="clear"></div>
2352 </div>
2353 <?php if (is_array($settings)) { ?>
2354
2355 <h3><?php echo __( 'To print this video gallery into WordPress Post/Page use below code','video-grid');?></h3>
2356 <input type="text" value='[print_responsive_video_grid] ' style="width: 400px; height: 30px" onclick="this.focus(); this.select()" />
2357 <div class="clear"></div>
2358 <h3><?php echo __( 'To print this video gallery into WordPress theme/template PHP files use below code','video-grid');?></h3>
2359 <?php
2360 $shortcode = '[print_responsive_video_grid]';
2361 ?>
2362 <input type="text" value="&lt;?php echo do_shortcode('<?php echo htmlentities($shortcode, ENT_QUOTES); ?>'); ?&gt;" style="width: 400px; height: 30px" onclick="this.focus(); this.select()" />
2363 <?php } ?>
2364 <div class="clear"></div>
2365 <?php
2366 }
2367 function print_responsive_video_grid_func($atts) {
2368
2369
2370 wp_enqueue_style('wp-video-grid-lighbox-style');
2371 wp_enqueue_style('vl-box-grid-css');
2372 wp_enqueue_script('jquery');
2373 wp_enqueue_script('vl-grid-js');
2374 wp_enqueue_script('v_grid');
2375
2376 ob_start();
2377
2378 global $wpdb;
2379
2380 $settings=get_option('responsive_video_grid_settings');
2381 $rand_Numb = uniqid ( 'thumnail_slider' );
2382 $rand_Num_td = uniqid ( 'divSliderMain' );
2383 $rand_var_name = uniqid ( 'rand_' );
2384
2385
2386 $wpcurrentdir = dirname ( __FILE__ );
2387 $wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir );
2388 // $settings=get_option('thumbnail_slider_settings');
2389
2390 $uploads = wp_upload_dir();
2391 $baseDir = $uploads ['basedir'];
2392 $baseDir = str_replace ( "\\", "/", $baseDir );
2393 $pathToImagesFolder = $baseDir . '/wp-responsive-video-grid';
2394 $baseurl = $uploads ['baseurl'];
2395 $baseurl .= '/wp-responsive-video-grid/';
2396 $randOmeRel = uniqid ( 'rel_' );
2397 $randOmVlBox= uniqid('video_lbox_');
2398 ?><!-- print_responsive_video_grid_func --><style type='text/css'>
2399 #<?php echo $rand_Num_td;?> {background: none repeat scroll 0 0<?php echo $settings['scollerBackground'];?> ! important;
2400 border: 0px none !important;
2401 box-shadow: 0 0 0 0 !important;
2402
2403 }
2404 </style>
2405 <?php
2406
2407 if (is_array($settings))
2408
2409 {
2410
2411
2412 if(!isset($settings['resize_images'])){
2413
2414 $settings['resize_images']=1;
2415
2416 }
2417 ?>
2418 <div style="clear: both;"></div>
2419 <?php $url = plugin_dir_url(__FILE__); ?>
2420
2421 <div style="width: auto; postion: relative" id="<?php echo $rand_Num_td; ?>">
2422
2423 <div id="<?php echo $rand_Numb; ?>" class="wrap_grid" style="margin-top: 2px !important;">
2424 <div class="box_parent">
2425 <?php
2426 global $wpdb;
2427 $imageheight = 270;
2428 $imagewidth = 360;
2429 $query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid order by createdon desc";
2430 $rows = $wpdb->get_results ( $query, 'ARRAY_A' );
2431
2432 if (count ( $rows ) > 0) {
2433
2434 foreach ( $rows as $row ) {
2435
2436 $imagename = $row ['image_name'];
2437 $video_url = $row ['video_url'];
2438 $imageUploadTo = $pathToImagesFolder . '/' . $imagename;
2439 $imageUploadTo = str_replace ( "\\", "/", $imageUploadTo );
2440 $pathinfo = pathinfo ( $imageUploadTo );
2441 $filenamewithoutextension = $pathinfo ['filename'];
2442 $outputimg = "";
2443
2444 if($settings['resize_images']==0){
2445
2446 $outputimg = $baseurl . $row ['image_name'];
2447 }
2448 else{
2449
2450 $imagetoCheck = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2451
2452 if (file_exists ( $imagetoCheck )) {
2453 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2454
2455 } else {
2456
2457 if (function_exists ( 'wp_get_image_editor' )) {
2458
2459 $image = wp_get_image_editor ( $pathToImagesFolder . "/" . $row ['image_name'] );
2460
2461 if (! is_wp_error ( $image )) {
2462 $image->resize ( $imagewidth, $imageheight, true );
2463 $image->save ( $imagetoCheck );
2464 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2465 } else {
2466 $outputimg = $baseurl . $row ['image_name'];
2467 }
2468 } else if (function_exists ( 'image_resize' )) {
2469
2470 $return = image_resize ( $pathToImagesFolder . "/" . $row ['image_name'], $imagewidth, $imageheight );
2471 if (! is_wp_error ( $return )) {
2472
2473 $isrenamed = rename ( $return, $imagetoCheck );
2474 if ($isrenamed) {
2475 $outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension'];
2476 } else {
2477 $outputimg = $baseurl . $row ['image_name'];
2478 }
2479 } else {
2480 $outputimg = $baseurl . $row ['image_name'];
2481 }
2482 } else {
2483
2484 $outputimg = $baseurl . $row ['image_name'];
2485 }
2486
2487 // $url = plugin_dir_url(__FILE__)."imagestoscroll/".$filenamewithoutextension.'_'.$imageheight.'_'.$imagewidth.'.'.$pathinfo['extension'];
2488 }
2489 }
2490
2491 $embed_url=$row['embed_url'];
2492
2493
2494 $title="";
2495 $rowTitle = stripslashes_deep($row['videotitle']);
2496 $rowTitle = str_replace('"', "'", $rowTitle);
2497 $rowTitle=str_replace("'","",$rowTitle);
2498 $rowTitle=preg_replace('/\\\\/', '', $rowTitle);
2499
2500
2501 $rowDescrption=$row['video_description'];
2502 $rowDescrption=str_replace("'","",$rowDescrption);
2503 $rowDescrption=str_replace('"','',$rowDescrption);
2504 $rowDescrption=strip_tags($rowDescrption);
2505
2506 if(strlen($rowDescrption)>300){
2507
2508 $rowDescrption=substr($rowDescrption,0,300)."...";
2509 }
2510 //$openImageInNewTab='_blank';
2511 $open_link_in=$row['open_link_in'];
2512 // if($open_link_in==0){
2513 $openImageInNewTab='_self';
2514 //}
2515
2516 if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])!=''){
2517
2518 $title="<a class='Imglink' target='$openImageInNewTab' href='{$row['videotitleurl']}'>{$rowTitle}</a>";
2519 if($row['video_description']!=''){
2520 $title.="<div class='clear_description_'>{$rowDescrption}</div>";
2521 }
2522 }
2523 else if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])==''){
2524
2525 $title="<a class='Imglink' href='#'>{$rowTitle}</a>";
2526 if($row['video_description']!=''){
2527 $title.="<div class='clear_description_'>{$rowDescrption}</div>";
2528 }
2529 }
2530 else{
2531
2532 if($row['video_description']!='')
2533 $title="<div class='clear_description_'>{$row['video_description']}</div>";
2534 }
2535
2536 $title= htmlentities($title);
2537 $rowDescrption= htmlentities($rowDescrption);
2538 //$rowTitle= htmlentities($rowTitle);
2539 ?>
2540
2541
2542 <div class="box_grid">
2543 <div class="boxInner_grid">
2544
2545 <?php if($settings['display_video_lightbox']==true):?>
2546 <a rel="<?php echo $randOmeRel;?>" data-overlay="1" data-title="<?php echo $title;?>" class="video_lbox" href="<?php echo $embed_url;?>">
2547 <img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/>
2548 <span class="playbtnCss"></span>
2549 <div class="titleBox"><?php echo $rowTitle;?></div>
2550 </a>
2551 <?php else : ?>
2552
2553 <a href="<?php echo $video_url;?>">
2554 <img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/>
2555 <span class="playbtnCss"></span>
2556 <div class="titleBox"><?php echo $rowTitle;?></div>
2557 </a>
2558
2559 <?php endif;?>
2560 </div>
2561 </div>
2562
2563 <?php } ?>
2564 <?php } ?>
2565 </div>
2566 </div>
2567 </div>
2568 <script>
2569
2570 <?php $intval= uniqid('interval_');?>
2571
2572 var <?php echo $intval;?> = setInterval(function() {
2573
2574 if(document.readyState === 'complete') {
2575
2576 clearInterval(<?php echo $intval;?>);
2577
2578 var uniqObj=jQuery("a[rel='<?php echo $randOmeRel;?>']");
2579
2580
2581 videoPlacements('<?php echo $rand_Numb; ?>',jQuery);
2582 jQuery(".video_lbox").fancybox_vg({
2583 'type' : "iframe",
2584 'overlayColor':'#000000',
2585 'padding': 10,
2586 'autoScale': true,
2587 'autoDimensions':true,
2588 'transitionIn': 'none',
2589 'uniqObj':uniqObj,
2590 'transitionOut': 'none',
2591 'titlePosition': 'outside',
2592 'hideOnContentClick':false,
2593 'width' : 650,
2594 'height' : 400,
2595 'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
2596
2597 var currtElem = jQuery('#<?php echo $rand_Numb; ?> a[href="'+currentOpts.href+'"]');
2598
2599 var isoverlay = jQuery(currtElem).attr('data-overlay')
2600
2601 if(isoverlay=="1" && jQuery.trim(title)!=""){
2602 return '<span id="fancybox_vg-title-over">' + title + '</span>';
2603 }
2604 else{
2605 return '';
2606 }
2607
2608 }
2609
2610 });
2611
2612
2613 var width__ = jQuery(window).width();
2614 var timer__;
2615 jQuery(window).bind('resize', function(){
2616 if(jQuery(window).width() != width__){
2617
2618 width__ = jQuery(window).width();
2619 timer__ && clearTimeout(timer__);
2620 timer__ = setTimeout(function(){
2621
2622 videoPlacements('<?php echo $rand_Numb; ?>',jQuery);
2623
2624 }, 200);
2625
2626 }
2627 });
2628 }
2629 }, 100);
2630
2631 </script>
2632 <div class="clear_div"></div><!-- end print_responsive_video_grid_func -->
2633
2634
2635 <?php }
2636 $output = ob_get_clean();
2637 return $output;
2638 }
2639 function responsive_video_grid_get_wp_version() {
2640 global $wp_version;
2641 return $wp_version;
2642 }
2643
2644 // also we will add an option function that will check for plugin admin page or not
2645 function responsive_video_grid_is_plugin_page() {
2646 $server_uri = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
2647
2648 foreach ( array (
2649 'video_grid_with_lightbox_video_management','video_grid_with_lightbox'
2650 ) as $allowURI ) {
2651 if (stristr ( $server_uri, $allowURI ))
2652 return true;
2653 }
2654 return false;
2655 }
2656
2657 // add media WP scripts
2658 function responsive_video_grid_admin_scripts_init() {
2659 if (responsive_video_grid_is_plugin_page()) {
2660 // double check for WordPress version and function exists
2661 if (function_exists ( 'wp_enqueue_media' ) && version_compare ( responsive_video_grid_get_wp_version(), '3.5', '>=' )) {
2662 // call for new media manager
2663 wp_enqueue_media();
2664 }
2665 wp_enqueue_style ( 'media' );
2666 wp_enqueue_style( 'wp-color-picker' );
2667 wp_enqueue_script( 'wp-color-picker' );
2668 }
2669 }
2670
2671 function prvg_remove_extra_p_tags($content){
2672
2673 if(strpos($content, 'print_responsive_video_grid_func')!==false){
2674
2675
2676 $pattern = "/<!-- print_responsive_video_grid_func -->(.*)<!-- end print_responsive_video_grid_func -->/Uis";
2677 $content = preg_replace_callback($pattern, function($matches) {
2678
2679
2680 $altered = str_replace("<p>","",$matches[1]);
2681 $altered = str_replace("</p>","",$altered);
2682
2683 $altered=str_replace("&#038;","&",$altered);
2684 $altered=str_replace("&#8221;",'"',$altered);
2685
2686
2687 return @str_replace($matches[1], $altered, $matches[0]);
2688 }, $content);
2689
2690
2691
2692 }
2693
2694 $content = str_replace("<p><!-- print_responsive_video_grid_func -->","<!-- print_responsive_video_grid_func -->",$content);
2695 $content = str_replace("<!-- end print_responsive_video_grid_func --></p>","<!-- end print_responsive_video_grid_func -->",$content);
2696
2697
2698 return $content;
2699 }
2700
2701 add_filter('widget_text_content', 'prvg_remove_extra_p_tags', 999);
2702 add_filter('the_content', 'prvg_remove_extra_p_tags', 999);
2703
2704
2705 function i13_video_grid_pro_render_block_defaults($block_content, $block) {
2706
2707 $block_content=prvg_remove_extra_p_tags($block_content);
2708 return $block_content;
2709
2710 }
2711
2712
2713 add_filter( 'render_block', 'i13_video_grid_pro_render_block_defaults', 10, 2 );
2714
2715