| 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.19 |
| 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 = $_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 = $_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 = $_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;"> 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');?> <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"> <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 ( $_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=(int)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='.$_GET['order_by']; |
| 764 |
} |
| 765 |
|
| 766 |
if(isset($_GET['order_pos']) and $_GET['order_pos']!=""){ |
| 767 |
$setacrionpage.='&order_pos='.$_GET['order_pos']; |
| 768 |
} |
| 769 |
|
| 770 |
$seval=""; |
| 771 |
if(isset($_GET['search_term']) and $_GET['search_term']!=""){ |
| 772 |
$seval=trim($_GET['search_term']); |
| 773 |
} |
| 774 |
$search_term_=''; |
| 775 |
if(isset($_GET['search_term'])){ |
| 776 |
|
| 777 |
$search_term_='&search_term='.urlencode($_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=trim($_GET['order_by']); |
| 793 |
} |
| 794 |
|
| 795 |
if(isset($_GET['order_pos'])){ |
| 796 |
|
| 797 |
$order_pos=trim($_GET['order_pos']); |
| 798 |
} |
| 799 |
$search_term=''; |
| 800 |
if(isset($_GET['search_term'])){ |
| 801 |
|
| 802 |
$search_term= sanitize_text_field(esc_sql($_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"> |
| 824 |
<input type='button' value='<?php echo __( 'Search','video-grid');?>' name='searchusrsubmit' class='button-primary' id='searchusrsubmit' onclick="SearchredirectTO();" > |
| 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="<?php echo do_shortcode('<?php echo htmlentities($shortcode, ENT_QUOTES); ?>'); ?>" 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('"', '"', $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 |
|
| 1187 |
} |
| 1188 |
$imagename = $vid . '_big.' . $ext; |
| 1189 |
$imageUploadTo = $pathToImagesFolder . '/' . $imagename; |
| 1190 |
//@copy ( $HdnMediaSelection, $imageUploadTo ); |
| 1191 |
|
| 1192 |
@copy ( $HdnMediaSelection, $imageUploadTo ); |
| 1193 |
if(!file_exists($imageUploadTo)){ |
| 1194 |
vg_save_image($HdnMediaSelection,$imageUploadTo); |
| 1195 |
} |
| 1196 |
|
| 1197 |
$settings=get_option('responsive_video_grid_settings'); |
| 1198 |
$imageheight = 270; |
| 1199 |
$imagewidth = 360; |
| 1200 |
@unlink($pathToImagesFolder.'/'.$vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext); |
| 1201 |
} |
| 1202 |
|
| 1203 |
$query = "update " . $wpdb->prefix . "responsive_video_grid |
| 1204 |
set vtype='$vtype',vid='$vid',video_url='$videourl',embed_url='$embed_url',image_name='$imagename',HdnMediaSelection='$HdnMediaSelection', |
| 1205 |
videotitle='$videotitle',videotitleurl='$videotitleurl',video_description='$video_description',video_order=$video_order, |
| 1206 |
open_link_in=$open_link_in,enable_light_box_video_desc=$enable_light_box_video_desc where id=$videoidEdit"; |
| 1207 |
|
| 1208 |
|
| 1209 |
$wpdb->query ( $query ); |
| 1210 |
|
| 1211 |
$responsive_video_grid_messages = array(); |
| 1212 |
$responsive_video_grid_messages ['type'] = 'succ'; |
| 1213 |
$responsive_video_grid_messages ['message'] = __( 'Video updated successfully.','video-grid'); |
| 1214 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1215 |
|
| 1216 |
} catch ( Exception $e ) { |
| 1217 |
|
| 1218 |
$responsive_video_grid_messages = array(); |
| 1219 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1220 |
$responsive_video_grid_messages ['message'] = __( 'Error while adding video','video-grid'); |
| 1221 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1222 |
} |
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1227 |
exit(); |
| 1228 |
} else { |
| 1229 |
|
| 1230 |
// add new |
| 1231 |
|
| 1232 |
if ( ! current_user_can( 'rvg_video_grid_add_video' ) ) { |
| 1233 |
|
| 1234 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1235 |
$responsive_video_grid_messages = array (); |
| 1236 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1237 |
$responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid'); |
| 1238 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1239 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1240 |
exit (); |
| 1241 |
|
| 1242 |
|
| 1243 |
} |
| 1244 |
|
| 1245 |
$createdOn = current_time ( 'Y-m-d h:i:s' ); |
| 1246 |
|
| 1247 |
try { |
| 1248 |
|
| 1249 |
if (trim ( $_POST ['HdnMediaSelection'] ) != '') { |
| 1250 |
$pInfo = pathinfo ( $HdnMediaSelection ); |
| 1251 |
$ext = $pInfo ['extension']; |
| 1252 |
if($ext==''){ |
| 1253 |
if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_PNG) { |
| 1254 |
|
| 1255 |
$ext='png'; |
| 1256 |
} |
| 1257 |
else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_JPEG) { |
| 1258 |
|
| 1259 |
$ext='jpeg'; |
| 1260 |
} |
| 1261 |
else if (exif_imagetype($HdnMediaSelection) == IMAGETYPE_GIF) { |
| 1262 |
|
| 1263 |
$ext='gif'; |
| 1264 |
} |
| 1265 |
|
| 1266 |
} |
| 1267 |
$imagename = $vid . '_big.' . $ext; |
| 1268 |
$imageUploadTo = $pathToImagesFolder . '/' . $imagename; |
| 1269 |
//@copy ( $HdnMediaSelection, $imageUploadTo ); |
| 1270 |
|
| 1271 |
@copy ( $HdnMediaSelection, $imageUploadTo ); |
| 1272 |
if(!file_exists($imageUploadTo)){ |
| 1273 |
vg_save_image($HdnMediaSelection,$imageUploadTo); |
| 1274 |
} |
| 1275 |
|
| 1276 |
} |
| 1277 |
|
| 1278 |
$query = "INSERT INTO " . $wpdb->prefix . "responsive_video_grid |
| 1279 |
(vtype, vid,video_url,embed_url,image_name,HdnMediaSelection,videotitle,videotitleurl,video_description,video_order,open_link_in, |
| 1280 |
enable_light_box_video_desc,createdon) |
| 1281 |
VALUES ('$vtype','$vid','$videourl','$embed_url','$imagename','$HdnMediaSelection','$videotitle','$videotitleurl','$video_description', |
| 1282 |
$video_order,$open_link_in,$enable_light_box_video_desc,'$createdOn')"; |
| 1283 |
|
| 1284 |
//echo $query;die; |
| 1285 |
$wpdb->query ( $query ); |
| 1286 |
|
| 1287 |
$responsive_video_grid_messages = array(); |
| 1288 |
$responsive_video_grid_messages ['type'] = 'succ'; |
| 1289 |
$responsive_video_grid_messages ['message'] = __( 'New video added successfully.','video-grid'); |
| 1290 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1291 |
} |
| 1292 |
catch ( Exception $e ) { |
| 1293 |
|
| 1294 |
$responsive_video_grid_messages = array(); |
| 1295 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1296 |
$responsive_video_grid_messages ['message'] = __( 'Error while adding video','video-grid'); |
| 1297 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1298 |
} |
| 1299 |
|
| 1300 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1301 |
exit(); |
| 1302 |
} |
| 1303 |
} |
| 1304 |
else { |
| 1305 |
|
| 1306 |
$uploads = wp_upload_dir(); |
| 1307 |
$baseurl = $uploads ['baseurl']; |
| 1308 |
$baseurl .= '/wp-responsive-video-grid/'; |
| 1309 |
?> |
| 1310 |
<div id="poststuff" > |
| 1311 |
<div id="post-body" class="metabox-holder columns-2" > |
| 1312 |
<div id="post-body-content"> |
| 1313 |
<div class="wrap"> |
| 1314 |
<div style="float: left; width: 100%;"> |
| 1315 |
<div class="wrap"> |
| 1316 |
<?php |
| 1317 |
if (isset ( $_GET ['id'] ) and intval($_GET ['id']) > 0) { |
| 1318 |
|
| 1319 |
|
| 1320 |
if ( ! current_user_can( 'rvg_video_grid_edit_video' ) ) { |
| 1321 |
|
| 1322 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1323 |
$responsive_video_grid_messages = array (); |
| 1324 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1325 |
$responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid'); |
| 1326 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1327 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1328 |
exit (); |
| 1329 |
|
| 1330 |
|
| 1331 |
} |
| 1332 |
|
| 1333 |
$id = intval($_GET ['id']); |
| 1334 |
$query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$id"; |
| 1335 |
|
| 1336 |
$myrow = $wpdb->get_row ( $query ); |
| 1337 |
|
| 1338 |
if (is_object ( $myrow )) { |
| 1339 |
|
| 1340 |
$vtype = $myrow->vtype; |
| 1341 |
$title = $myrow->videotitle; |
| 1342 |
$image_name = $myrow->image_name; |
| 1343 |
$video_url = $myrow->video_url; |
| 1344 |
$HdnMediaSelection = $myrow->HdnMediaSelection; |
| 1345 |
$videotitle = $myrow->videotitle; |
| 1346 |
$videotitleurl=$myrow->videotitleurl; |
| 1347 |
$video_order = $myrow->video_order; |
| 1348 |
$video_description = $myrow->video_description; |
| 1349 |
$open_link_in = $myrow->open_link_in ; |
| 1350 |
$enable_light_box_video_desc = $myrow->enable_light_box_video_desc; |
| 1351 |
} |
| 1352 |
?> |
| 1353 |
<h2><?php echo __( 'Update Video','video-grid');?></h2> |
| 1354 |
<?php |
| 1355 |
} |
| 1356 |
|
| 1357 |
else { |
| 1358 |
|
| 1359 |
$vtype=''; |
| 1360 |
$title = ''; |
| 1361 |
$videotitle=''; |
| 1362 |
$videotitleurl=''; |
| 1363 |
$HdnMediaSelection=''; |
| 1364 |
$video_url = ''; |
| 1365 |
$image_link = ''; |
| 1366 |
$image_name = ''; |
| 1367 |
$video_order = ''; |
| 1368 |
$video_description = ''; |
| 1369 |
$open_link_in = true; |
| 1370 |
$enable_light_box_video_desc = true; |
| 1371 |
|
| 1372 |
if ( ! current_user_can( 'rvg_video_grid_add_video' ) ) { |
| 1373 |
|
| 1374 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1375 |
$responsive_video_grid_messages = array (); |
| 1376 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1377 |
$responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid'); |
| 1378 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1379 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1380 |
exit (); |
| 1381 |
|
| 1382 |
|
| 1383 |
} |
| 1384 |
|
| 1385 |
?> |
| 1386 |
<div style="clear:both"> |
| 1387 |
<span><h3 style="color: blue;"> |
| 1388 |
<a target="_blank" href="https://www.i13websolution.com/wordpress-responsive-video-grid-pro.html"><?php echo __( 'UPGRADE TO PRO VERSION','video-grid');?></a> |
| 1389 |
</h3> |
| 1390 |
</span> |
| 1391 |
</div> |
| 1392 |
<h2><?php echo __( 'Add Video','video-grid');?></h2> |
| 1393 |
<?php } ?> |
| 1394 |
<br /> |
| 1395 |
<div id="poststuff"> |
| 1396 |
<div id="post-body" class="metabox-holder columns-2"> |
| 1397 |
<div id="post-body-content"> |
| 1398 |
<form method="post" action="" id="addimage" name="addimage" enctype="multipart/form-data"> |
| 1399 |
<div class="stuffbox" id="namediv" style="width: 100%"> |
| 1400 |
<h3> |
| 1401 |
<label for="link_name"><?php echo __( 'Video Information','video-grid');?> (<span |
| 1402 |
style="font-size: 11px; font-weight: normal"><?php echo __('Choose Video Site','video-grid'); ?></span>) |
| 1403 |
</label> |
| 1404 |
</h3> |
| 1405 |
<div class="inside"> |
| 1406 |
<div> |
| 1407 |
<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');?> |
| 1408 |
<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');?> |
| 1409 |
</div> |
| 1410 |
<div style="clear: both"></div> |
| 1411 |
<div></div> |
| 1412 |
<div style="clear: both"></div> |
| 1413 |
<br /> |
| 1414 |
<div> |
| 1415 |
<b><?php echo __( 'Video Url','video-grid');?></b> |
| 1416 |
<input type="text" id="videourl" class="url" tabindex="1" size="30" name="videourl" value="<?php echo $video_url; ?>"> |
| 1417 |
</div> |
| 1418 |
<div style="clear: both"></div> |
| 1419 |
<div></div> |
| 1420 |
<div style="clear: both"> |
| 1421 |
<div id="youtube_note" style="font-size:12px;display:none"> |
| 1422 |
<?php echo __('Please do not use youtube.be, instead of use youtube.com','video-grid');?> |
| 1423 |
</div> |
| 1424 |
</div> |
| 1425 |
</div> |
| 1426 |
</div> |
| 1427 |
<div class="stuffbox" id="namediv" style="width: 100%"> |
| 1428 |
<h3> |
| 1429 |
<label for="link_name"><?php echo __( 'Video Thumbnail Information','video-grid');?></label> |
| 1430 |
</h3> |
| 1431 |
<div class="inside" id="fileuploaddiv"> |
| 1432 |
<?php if ($image_name != "") { ?> |
| 1433 |
<div> |
| 1434 |
<b><?php echo __( 'Current Image','video-grid');?> : </b> |
| 1435 |
<br/> |
| 1436 |
<img id="img_disp" name="img_disp" src="<?php echo $baseurl . $image_name; ?>" /> |
| 1437 |
</div> |
| 1438 |
<?php }else{ ?> |
| 1439 |
<img src="<?php echo plugins_url('/images/no-img.jpeg', __FILE__); ?>" id="img_disp" name="img_disp" /> |
| 1440 |
|
| 1441 |
<?php } ?> |
| 1442 |
<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> |
| 1443 |
</b></a> <img src="<?php echo plugins_url('/images/ajax-loader.gif', __FILE__); ?>" style="display: none" id="loading_img" name="loading_img" /> |
| 1444 |
<div style="clear: both"></div> |
| 1445 |
<div></div> |
| 1446 |
<div class="uploader"> |
| 1447 |
<br /> <b style="margin-left: 50px;">OR</b> |
| 1448 |
<div style="clear: both; margin-top: 15px;"></div> |
| 1449 |
<a href="javascript:;" class="niks_media" id="myMediaUploader"><b><?php echo __( 'Click Here to upload custom video thumbnail','video-grid');?></b></a> |
| 1450 |
<br /> <br /> |
| 1451 |
<div> |
| 1452 |
<input id="HdnMediaSelection" name="HdnMediaSelection" type="hidden" value="<?php echo $HdnMediaSelection;?>" /> |
| 1453 |
</div> |
| 1454 |
<div style="clear: both"></div> |
| 1455 |
<div></div> |
| 1456 |
<div style="clear: both"></div> |
| 1457 |
|
| 1458 |
<br /> |
| 1459 |
</div> |
| 1460 |
<script> |
| 1461 |
|
| 1462 |
function GetParameterValues(param,str) { |
| 1463 |
var return_p=''; |
| 1464 |
var url = str.slice(str.indexOf('?') + 1).split('&'); |
| 1465 |
for (var i = 0; i < url.length; i++) { |
| 1466 |
var urlparam = url[i].split('='); |
| 1467 |
if (urlparam[0] == param) { |
| 1468 |
return_p= urlparam[1]; |
| 1469 |
} |
| 1470 |
} |
| 1471 |
return return_p; |
| 1472 |
} |
| 1473 |
|
| 1474 |
|
| 1475 |
function UrlExists(url, cb){ |
| 1476 |
jQuery.ajax({ |
| 1477 |
url: url, |
| 1478 |
dataType: 'text', |
| 1479 |
type: 'GET', |
| 1480 |
complete: function(xhr){ |
| 1481 |
if(typeof cb === 'function') |
| 1482 |
cb.apply(this, [xhr.status]); |
| 1483 |
} |
| 1484 |
}); |
| 1485 |
} |
| 1486 |
|
| 1487 |
function getDailyMotionId(url) { |
| 1488 |
|
| 1489 |
if (url.indexOf("?") > 0) { |
| 1490 |
url = url.substring(0, url.indexOf("?")); |
| 1491 |
} |
| 1492 |
|
| 1493 |
var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/); |
| 1494 |
if (m !== null) { |
| 1495 |
if(m[4] !== undefined) { |
| 1496 |
return m[4]; |
| 1497 |
} |
| 1498 |
return m[2]; |
| 1499 |
} |
| 1500 |
return null; |
| 1501 |
} |
| 1502 |
|
| 1503 |
|
| 1504 |
jQuery(document).ready(function() { |
| 1505 |
|
| 1506 |
|
| 1507 |
jQuery("input:radio[name=vtype]").click(function() { |
| 1508 |
|
| 1509 |
|
| 1510 |
var value = jQuery(this).val(); |
| 1511 |
jQuery("#fromval").html(" from " + value); |
| 1512 |
if(value=="youtube"){ |
| 1513 |
|
| 1514 |
jQuery("#youtube_note").show(); |
| 1515 |
} |
| 1516 |
else{ |
| 1517 |
|
| 1518 |
jQuery("#youtube_note").hide(); |
| 1519 |
} |
| 1520 |
}); |
| 1521 |
|
| 1522 |
jQuery("#videoFromExternalSite").click(function() { |
| 1523 |
|
| 1524 |
|
| 1525 |
var videoService = jQuery('input[name="vtype"]:checked').length; |
| 1526 |
var videourlVal = jQuery.trim(jQuery("#videourl").val()); |
| 1527 |
var flag = true; |
| 1528 |
if (videourlVal == '' && videoService == 0){ |
| 1529 |
|
| 1530 |
alert('<?php echo __( 'Please select video site','video-grid');?>.\n <?php echo __( 'Please enter video url.','video-grid');?>'); |
| 1531 |
jQuery("input:radio[name=vtype]").focus(); |
| 1532 |
flag = false; |
| 1533 |
|
| 1534 |
} |
| 1535 |
else if (videoService == 0){ |
| 1536 |
|
| 1537 |
alert('Please select video site.'); |
| 1538 |
jQuery("input:radio[name=vtype]").focus(); |
| 1539 |
flag = false; |
| 1540 |
} |
| 1541 |
else if (videourlVal == ''){ |
| 1542 |
|
| 1543 |
alert('Please enter video url.'); |
| 1544 |
jQuery("#videourl").focus(); |
| 1545 |
flag = false; |
| 1546 |
} |
| 1547 |
|
| 1548 |
if (flag){ |
| 1549 |
|
| 1550 |
setTimeout(function() { |
| 1551 |
jQuery("#loading_img").show(); |
| 1552 |
}, 100); |
| 1553 |
|
| 1554 |
var selectedRadio = jQuery('input[name=vtype]'); |
| 1555 |
var checkedValueRadio = selectedRadio.filter(':checked').val(); |
| 1556 |
if (checkedValueRadio == 'youtube') { |
| 1557 |
var vId = GetParameterValues('v', videourlVal); |
| 1558 |
if(vId!=''){ |
| 1559 |
|
| 1560 |
|
| 1561 |
var tumbnailImg='https://img.youtube.com/vi/'+vId+'/maxresdefault.jpg'; |
| 1562 |
|
| 1563 |
var data = { |
| 1564 |
'action': 'check_file_exist_grid', |
| 1565 |
'url': tumbnailImg, |
| 1566 |
'vNonce':'<?php echo $vNonce; ?>' |
| 1567 |
}; |
| 1568 |
|
| 1569 |
jQuery.post(ajaxurl, data, function(response) { |
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
var youtubeJsonUri='https://www.youtube.com/oembed?url=https://www.youtube.com/watch%3Fv='+vId+'&format=json'; |
| 1574 |
var data_youtube = { |
| 1575 |
'action': 'get_youtube_info_grid', |
| 1576 |
'url': youtubeJsonUri, |
| 1577 |
'vid':vId, |
| 1578 |
'vNonce':'<?php echo $vNonce; ?>' |
| 1579 |
}; |
| 1580 |
|
| 1581 |
jQuery.post(ajaxurl, data_youtube, function(data) { |
| 1582 |
|
| 1583 |
data = jQuery.parseJSON(data); |
| 1584 |
|
| 1585 |
if(typeof data =='object'){ |
| 1586 |
if(typeof data =='object'){ |
| 1587 |
|
| 1588 |
if(data.title!='' && data.title!=''){ |
| 1589 |
jQuery("#videotitle").val(data.title); |
| 1590 |
} |
| 1591 |
jQuery("#videotitleurl").val(videourlVal); |
| 1592 |
if(data.description!='' && data.description!=''){ |
| 1593 |
jQuery("#video_description").val(data.description); |
| 1594 |
} |
| 1595 |
if(response=='404' && data.thumbnail_url!=''){ |
| 1596 |
tumbnailImg=data.thumbnail_url; |
| 1597 |
} |
| 1598 |
else{ |
| 1599 |
tumbnailImg='https://img.youtube.com/vi/'+vId+'/0.jpg'; |
| 1600 |
} |
| 1601 |
|
| 1602 |
jQuery("#img_disp").attr('src', tumbnailImg); |
| 1603 |
jQuery("#HdnMediaSelection").val(tumbnailImg); |
| 1604 |
jQuery("#loading_img").hide(); |
| 1605 |
|
| 1606 |
} |
| 1607 |
|
| 1608 |
} |
| 1609 |
jQuery("#loading_img").hide(); |
| 1610 |
}) |
| 1611 |
|
| 1612 |
|
| 1613 |
}); |
| 1614 |
|
| 1615 |
} |
| 1616 |
else{ |
| 1617 |
alert('<?php echo __( 'Could not found such video','video-grid');?>'); |
| 1618 |
jQuery("#loading_img").hide(); |
| 1619 |
} |
| 1620 |
} |
| 1621 |
else if(checkedValueRadio == 'dailymotion'){ |
| 1622 |
|
| 1623 |
var vid=getDailyMotionId(videourlVal); |
| 1624 |
var apiUrl='https://api.dailymotion.com/video/'+vid+'?fields=description,id,thumbnail_720_url,title'; |
| 1625 |
jQuery.getJSON( apiUrl, function( data ) { |
| 1626 |
if(typeof data =='object'){ |
| 1627 |
|
| 1628 |
|
| 1629 |
jQuery("#HdnMediaSelection").val(data.thumbnail_720_url); |
| 1630 |
jQuery("#videotitle").val(jQuery.trim(data.title)); |
| 1631 |
jQuery("#videotitleurl").val(videourlVal); |
| 1632 |
jQuery("#img_disp").attr('src', data.thumbnail_720_url); |
| 1633 |
jQuery("#loading_img").hide(); |
| 1634 |
} |
| 1635 |
jQuery("#loading_img").hide(); |
| 1636 |
}) |
| 1637 |
|
| 1638 |
|
| 1639 |
jQuery("#loading_img").hide(); |
| 1640 |
} |
| 1641 |
|
| 1642 |
jQuery("#loading_img").hide(); |
| 1643 |
} |
| 1644 |
|
| 1645 |
setTimeout(function() { |
| 1646 |
jQuery("#loading_img").hide(); |
| 1647 |
}, 2000); |
| 1648 |
|
| 1649 |
}); |
| 1650 |
//uploading files variable |
| 1651 |
var custom_file_frame; |
| 1652 |
jQuery("#myMediaUploader").click(function(event) { |
| 1653 |
|
| 1654 |
event.preventDefault(); |
| 1655 |
//If the frame already exists, reopen it |
| 1656 |
if (typeof (custom_file_frame) !== "undefined") { |
| 1657 |
custom_file_frame.close(); |
| 1658 |
} |
| 1659 |
|
| 1660 |
//Create WP media frame. |
| 1661 |
custom_file_frame = wp.media.frames.customHeader = wp.media({ |
| 1662 |
//Title of media manager frame |
| 1663 |
title: "WP Media Uploader", |
| 1664 |
library: { |
| 1665 |
type: 'image' |
| 1666 |
}, |
| 1667 |
button: { |
| 1668 |
//Button text |
| 1669 |
text: "Set Image" |
| 1670 |
}, |
| 1671 |
//Do not allow multiple files, if you want multiple, set true |
| 1672 |
multiple: false |
| 1673 |
}); |
| 1674 |
//callback for selected image |
| 1675 |
custom_file_frame.on('select', function() { |
| 1676 |
|
| 1677 |
var attachment = custom_file_frame.state().get('selection').first().toJSON(); |
| 1678 |
var validExtensions = new Array(); |
| 1679 |
validExtensions[0] = 'jpg'; |
| 1680 |
validExtensions[1] = 'jpeg'; |
| 1681 |
validExtensions[2] = 'png'; |
| 1682 |
validExtensions[3] = 'gif'; |
| 1683 |
|
| 1684 |
var inarr = parseInt(jQuery.inArray(attachment.subtype, validExtensions)); |
| 1685 |
if (inarr > 0 && attachment.type.toLowerCase() == 'image'){ |
| 1686 |
|
| 1687 |
var titleTouse = ""; |
| 1688 |
var imageDescriptionTouse = ""; |
| 1689 |
if (jQuery.trim(attachment.title) != ''){ |
| 1690 |
|
| 1691 |
titleTouse = jQuery.trim(attachment.title); |
| 1692 |
} |
| 1693 |
else if (jQuery.trim(attachment.caption) != ''){ |
| 1694 |
|
| 1695 |
titleTouse = jQuery.trim(attachment.caption); |
| 1696 |
} |
| 1697 |
|
| 1698 |
if (jQuery.trim(attachment.description) != ''){ |
| 1699 |
|
| 1700 |
imageDescriptionTouse = jQuery.trim(attachment.description); |
| 1701 |
} |
| 1702 |
else if (jQuery.trim(attachment.caption) != ''){ |
| 1703 |
|
| 1704 |
imageDescriptionTouse = jQuery.trim(attachment.caption); |
| 1705 |
} |
| 1706 |
|
| 1707 |
// jQuery("#videotitle").val(titleTouse); |
| 1708 |
// jQuery("#video_description").val(imageDescriptionTouse); |
| 1709 |
|
| 1710 |
if (attachment.id != ''){ |
| 1711 |
|
| 1712 |
jQuery("#HdnMediaSelection").val(attachment.url); |
| 1713 |
jQuery("#img_disp").attr('src', attachment.url); |
| 1714 |
|
| 1715 |
} |
| 1716 |
|
| 1717 |
} |
| 1718 |
else{ |
| 1719 |
|
| 1720 |
alert('<?php echo __( 'Invalid image selection.','video-grid');?>'); |
| 1721 |
} |
| 1722 |
//do something with attachment variable, for example attachment.filename |
| 1723 |
//Object: |
| 1724 |
//attachment.alt - image alt |
| 1725 |
//attachment.author - author id |
| 1726 |
//attachment.caption |
| 1727 |
//attachment.dateFormatted - date of image uploaded |
| 1728 |
//attachment.description |
| 1729 |
//attachment.editLink - edit link of media |
| 1730 |
//attachment.filename |
| 1731 |
//attachment.height |
| 1732 |
//attachment.icon - don't know WTF?)) |
| 1733 |
//attachment.id - id of attachment |
| 1734 |
//attachment.link - public link of attachment, for example ""http://site.com/?attachment_id=115"" |
| 1735 |
//attachment.menuOrder |
| 1736 |
//attachment.mime - mime type, for example image/jpeg" |
| 1737 |
//attachment.name - name of attachment file, for example "my-image" |
| 1738 |
//attachment.status - usual is "inherit" |
| 1739 |
//attachment.subtype - "jpeg" if is "jpg" |
| 1740 |
//attachment.title |
| 1741 |
//attachment.type - "image" |
| 1742 |
//attachment.uploadedTo |
| 1743 |
//attachment.url - http url of image, for example "http://site.com/wp-content/uploads/2012/12/my-image.jpg" |
| 1744 |
//attachment.width |
| 1745 |
}); |
| 1746 |
//Open modal |
| 1747 |
custom_file_frame.open(); |
| 1748 |
}); |
| 1749 |
}) |
| 1750 |
</script> |
| 1751 |
</div> |
| 1752 |
</div> |
| 1753 |
|
| 1754 |
<div class="stuffbox" id="namediv" style="width: 100%"> |
| 1755 |
<h3> |
| 1756 |
<label for="link_name"><?php echo __( 'Video Title','video-grid');?> (<span |
| 1757 |
style="font-size: 11px; font-weight: normal"><?php echo __('Used into lightbox','video-grid'); ?></span>) |
| 1758 |
</label> |
| 1759 |
</h3> |
| 1760 |
<div class="inside"> |
| 1761 |
<div> |
| 1762 |
<input type="text" id="videotitle" tabindex="1" size="30" name="videotitle" value="<?php echo $videotitle; ?>"> |
| 1763 |
</div> |
| 1764 |
<div style="clear: both"></div> |
| 1765 |
<div></div> |
| 1766 |
<div style="clear: both"></div> |
| 1767 |
</div> |
| 1768 |
</div> |
| 1769 |
<div class="stuffbox" id="namediv" style="width: 100%"> |
| 1770 |
<h3> |
| 1771 |
<label for="link_name"><?php echo __( 'Video Title Url','video-grid');?> (<span |
| 1772 |
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>) |
| 1773 |
</label> |
| 1774 |
</h3> |
| 1775 |
<div class="inside"> |
| 1776 |
<div> |
| 1777 |
<input type="text" id="videotitleurl" class="url" tabindex="1" size="30" name="videotitleurl" value="<?php echo $videotitleurl; ?>"> |
| 1778 |
</div> |
| 1779 |
<div style="clear: both"></div> |
| 1780 |
<div></div> |
| 1781 |
<div style="clear: both"></div> |
| 1782 |
|
| 1783 |
</div> |
| 1784 |
</div> |
| 1785 |
|
| 1786 |
|
| 1787 |
<?php if (isset($_GET['id']) and intval($_GET['id']) > 0) { ?> |
| 1788 |
<input type="hidden" name="videoid" id="videoid" value="<?php echo (int) htmlentities(sanitize_text_field(intval($_GET['id'])),ENT_QUOTES); ?>"> |
| 1789 |
<?php |
| 1790 |
} |
| 1791 |
?> |
| 1792 |
<?php wp_nonce_field('action_image_add_edit','add_edit_image_nonce'); ?> |
| 1793 |
<input type="submit" onclick="" name="btnsave" id="btnsave" value="<?php echo __( 'Save Changes','video-grid');?>" class="button-primary"> <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'"> |
| 1794 |
|
| 1795 |
</form> |
| 1796 |
<script type="text/javascript"> |
| 1797 |
|
| 1798 |
|
| 1799 |
jQuery(document).ready(function() { |
| 1800 |
|
| 1801 |
jQuery.validator.setDefaults({ |
| 1802 |
ignore: [], |
| 1803 |
// any other default options and/or rules |
| 1804 |
}); |
| 1805 |
|
| 1806 |
jQuery("#addimage").validate({ |
| 1807 |
rules: { |
| 1808 |
videotitle: { |
| 1809 |
required:true, |
| 1810 |
maxlength: 200 |
| 1811 |
}, |
| 1812 |
vtype: { |
| 1813 |
required:true |
| 1814 |
|
| 1815 |
}, |
| 1816 |
videourl: { |
| 1817 |
required:true, |
| 1818 |
url:true, |
| 1819 |
maxlength: 500 |
| 1820 |
}, |
| 1821 |
HdnMediaSelection:{ |
| 1822 |
required:true |
| 1823 |
}, |
| 1824 |
videotitleurl: { |
| 1825 |
|
| 1826 |
url:true, |
| 1827 |
maxlength: 500 |
| 1828 |
} |
| 1829 |
|
| 1830 |
}, |
| 1831 |
errorClass: "image_error", |
| 1832 |
errorPlacement: function(error, element) { |
| 1833 |
error.appendTo(element.parent().next().next()); |
| 1834 |
}, messages: { |
| 1835 |
HdnMediaSelection: "<?php echo __( 'Please select video thumbnail or Upload by wordpress media uploader.','video-grid');?>", |
| 1836 |
|
| 1837 |
} |
| 1838 |
|
| 1839 |
}) |
| 1840 |
}); |
| 1841 |
|
| 1842 |
function validateFile(){ |
| 1843 |
|
| 1844 |
if(jQuery('#currImg').length>0 || jQuery.trim(jQuery("#HdnMediaSelection").val())!="" ){ |
| 1845 |
return true; |
| 1846 |
} |
| 1847 |
else |
| 1848 |
{ |
| 1849 |
jQuery("#err_daynamic").remove(); |
| 1850 |
jQuery("#myMediaUploader").after('<br/><label class="image_error" id="err_daynamic">Please select file.</label>'); |
| 1851 |
return false; |
| 1852 |
} |
| 1853 |
|
| 1854 |
} |
| 1855 |
</script> |
| 1856 |
|
| 1857 |
</div> |
| 1858 |
</div> |
| 1859 |
</div> |
| 1860 |
|
| 1861 |
</div> |
| 1862 |
</div> |
| 1863 |
</div> |
| 1864 |
</div> |
| 1865 |
<div id="postbox-container-1" class="postbox-container" > |
| 1866 |
|
| 1867 |
<div class="postbox"> |
| 1868 |
<h3 class="hndle"><span></span><?php echo __( 'Access All Themes In One Price','video-grid');?></h3> |
| 1869 |
<div class="inside"> |
| 1870 |
<center><a href="http://www.elegantthemes.com/affiliates/idevaffiliate.php?id=11715_0_1_10" target="_blank"> |
| 1871 |
<img border="0" src="<?php echo plugins_url( 'images/300x250.gif', __FILE__ );?>" width="250" height="250"> |
| 1872 |
</a></center> |
| 1873 |
|
| 1874 |
<div style="margin:10px 5px"> |
| 1875 |
|
| 1876 |
</div> |
| 1877 |
</div></div> |
| 1878 |
<div class="postbox"> |
| 1879 |
<h3 class="hndle"><span></span><?php echo __('Google For Business Coupon','video-grid');?></h3> |
| 1880 |
<div class="inside"> |
| 1881 |
<center><a href="https://goo.gl/OJBuHT" target="_blank"> |
| 1882 |
<img src="<?php echo plugins_url( 'images/g-suite-promo-code-4.png', __FILE__ );?>" width="250" height="250" border="0"> |
| 1883 |
</a></center> |
| 1884 |
<div style="margin:10px 5px"> |
| 1885 |
</div> |
| 1886 |
</div> |
| 1887 |
|
| 1888 |
</div> |
| 1889 |
|
| 1890 |
</div> |
| 1891 |
</div> |
| 1892 |
</div> |
| 1893 |
<?php |
| 1894 |
} |
| 1895 |
} else if (strtolower ( $action ) == strtolower ( 'delete' )) { |
| 1896 |
|
| 1897 |
$retrieved_nonce = ''; |
| 1898 |
|
| 1899 |
if(isset($_GET['nonce']) and $_GET['nonce']!=''){ |
| 1900 |
|
| 1901 |
$retrieved_nonce=$_GET['nonce']; |
| 1902 |
|
| 1903 |
} |
| 1904 |
if (!wp_verify_nonce($retrieved_nonce, 'delete_image' ) ){ |
| 1905 |
|
| 1906 |
|
| 1907 |
wp_die('Security check fail'); |
| 1908 |
} |
| 1909 |
|
| 1910 |
if ( ! current_user_can( 'rvg_video_grid_delete_video' ) ) { |
| 1911 |
|
| 1912 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1913 |
$responsive_video_grid_messages = array (); |
| 1914 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1915 |
$responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid'); |
| 1916 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1917 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1918 |
exit (); |
| 1919 |
|
| 1920 |
|
| 1921 |
} |
| 1922 |
|
| 1923 |
$uploads = wp_upload_dir(); |
| 1924 |
$baseDir = $uploads ['basedir']; |
| 1925 |
$baseDir = str_replace ( "\\", "/", $baseDir ); |
| 1926 |
$pathToImagesFolder = $baseDir . '/wp-responsive-video-grid'; |
| 1927 |
|
| 1928 |
|
| 1929 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1930 |
$deleteId = ( int ) htmlentities(sanitize_text_field($_GET ['id']),ENT_QUOTES); |
| 1931 |
|
| 1932 |
try { |
| 1933 |
|
| 1934 |
$query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$deleteId"; |
| 1935 |
$myrow = $wpdb->get_row ( $query ); |
| 1936 |
|
| 1937 |
if (is_object ( $myrow )) { |
| 1938 |
|
| 1939 |
$image_name = $myrow->image_name; |
| 1940 |
$wpcurrentdir = dirname ( __FILE__ ); |
| 1941 |
$wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir ); |
| 1942 |
$imagetoDel = $pathToImagesFolder . '/' . $image_name; |
| 1943 |
$settings=get_option('responsive_video_grid_settings'); |
| 1944 |
$imageheight = 270; |
| 1945 |
$imagewidth = 360; |
| 1946 |
|
| 1947 |
$pInfo = pathinfo ( $myrow->HdnMediaSelection ); |
| 1948 |
$ext = $pInfo ['extension']; |
| 1949 |
|
| 1950 |
@unlink ( $imagetoDel ); |
| 1951 |
@unlink($pathToImagesFolder.'/'.$myrow->vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext); |
| 1952 |
|
| 1953 |
|
| 1954 |
$query = "delete from " . $wpdb->prefix . "responsive_video_grid where id=$deleteId"; |
| 1955 |
$wpdb->query ( $query ); |
| 1956 |
|
| 1957 |
$responsive_video_grid_messages = array(); |
| 1958 |
$responsive_video_grid_messages ['type'] = 'succ'; |
| 1959 |
$responsive_video_grid_messages ['message'] = __( 'Video deleted successfully.','video-grid'); |
| 1960 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1961 |
|
| 1962 |
} |
| 1963 |
|
| 1964 |
} |
| 1965 |
catch ( Exception $e ) { |
| 1966 |
|
| 1967 |
$responsive_video_grid_messages = array(); |
| 1968 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1969 |
$responsive_video_grid_messages ['message'] = __( 'Error while deleting video.','video-grid'); |
| 1970 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1971 |
} |
| 1972 |
|
| 1973 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1974 |
exit(); |
| 1975 |
} |
| 1976 |
else if (strtolower ( $action ) == strtolower ( 'deleteselected' )) { |
| 1977 |
|
| 1978 |
|
| 1979 |
if(!check_admin_referer('action_settings_mass_delete','mass_delete_nonce')){ |
| 1980 |
|
| 1981 |
wp_die(__( 'Security check fail','video-grid')); |
| 1982 |
} |
| 1983 |
|
| 1984 |
if ( ! current_user_can( 'rvg_video_grid_delete_video' ) ) { |
| 1985 |
|
| 1986 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1987 |
$responsive_video_grid_messages = array (); |
| 1988 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 1989 |
$responsive_video_grid_messages ['message'] = __('Access Denied. Please contact your administrator','video-grid'); |
| 1990 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 1991 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 1992 |
exit (); |
| 1993 |
|
| 1994 |
|
| 1995 |
} |
| 1996 |
|
| 1997 |
$location = "admin.php?page=video_grid_with_lightbox_video_management"; |
| 1998 |
|
| 1999 |
if (isset ( $_POST ) and isset ( $_POST ['deleteselected'] ) and ($_POST ['action'] == 'delete' or $_POST ['action_upper'] == 'delete')) { |
| 2000 |
|
| 2001 |
$uploads = wp_upload_dir(); |
| 2002 |
$baseDir = $uploads ['basedir']; |
| 2003 |
$baseDir = str_replace ( "\\", "/", $baseDir ); |
| 2004 |
$pathToImagesFolder = $baseDir . '/wp-responsive-video-grid'; |
| 2005 |
|
| 2006 |
if (sizeof ( $_POST ['thumbnails'] ) > 0) { |
| 2007 |
|
| 2008 |
$deleteto = $_POST ['thumbnails']; |
| 2009 |
$implode = implode ( ',', $deleteto ); |
| 2010 |
|
| 2011 |
try { |
| 2012 |
|
| 2013 |
$settings=get_option('responsive_video_grid_settings'); |
| 2014 |
$imageheight = 270; |
| 2015 |
$imagewidth = 360; |
| 2016 |
|
| 2017 |
foreach ( $deleteto as $img ) { |
| 2018 |
|
| 2019 |
$img=intval($img); |
| 2020 |
$query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid WHERE id=$img"; |
| 2021 |
$myrow = $wpdb->get_row ( $query ); |
| 2022 |
|
| 2023 |
if (is_object ( $myrow )) { |
| 2024 |
|
| 2025 |
$image_name = $myrow->image_name; |
| 2026 |
$wpcurrentdir = dirname ( __FILE__ ); |
| 2027 |
$wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir ); |
| 2028 |
$imagetoDel = $pathToImagesFolder . '/' . $image_name; |
| 2029 |
|
| 2030 |
$pInfo = pathinfo ( $myrow->HdnMediaSelection ); |
| 2031 |
$ext = $pInfo ['extension']; |
| 2032 |
|
| 2033 |
@unlink ( $imagetoDel ); |
| 2034 |
@unlink($pathToImagesFolder.'/'.$myrow->vid . '_big_'.$imageheight.'_'.$imagewidth.'.'.$ext); |
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
$query = "delete from " . $wpdb->prefix . "responsive_video_grid where id=$img"; |
| 2039 |
$wpdb->query ( $query ); |
| 2040 |
|
| 2041 |
$responsive_video_grid_messages = array(); |
| 2042 |
$responsive_video_grid_messages ['type'] = 'succ'; |
| 2043 |
$responsive_video_grid_messages ['message'] = __( 'selected videos deleted successfully.','video-grid'); |
| 2044 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 2045 |
} |
| 2046 |
} |
| 2047 |
} catch ( Exception $e ) { |
| 2048 |
|
| 2049 |
$responsive_video_grid_messages = array(); |
| 2050 |
$responsive_video_grid_messages ['type'] = 'err'; |
| 2051 |
$responsive_video_grid_messages ['message'] = __( 'Error while deleting videos.','video-grid'); |
| 2052 |
update_option ( 'responsive_video_grid_messages', $responsive_video_grid_messages ); |
| 2053 |
} |
| 2054 |
|
| 2055 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 2056 |
exit(); |
| 2057 |
} else { |
| 2058 |
|
| 2059 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 2060 |
exit(); |
| 2061 |
} |
| 2062 |
} else { |
| 2063 |
|
| 2064 |
echo "<script type='text/javascript'> location.href='$location';</script>"; |
| 2065 |
exit(); |
| 2066 |
} |
| 2067 |
} |
| 2068 |
} |
| 2069 |
function video_grid_with_lightbox_video_preview_func() { |
| 2070 |
|
| 2071 |
global $wpdb; |
| 2072 |
|
| 2073 |
|
| 2074 |
if ( ! current_user_can( 'rvg_video_grid_preview' ) ) { |
| 2075 |
|
| 2076 |
wp_die( __( "Access Denied", "video-grid" ) ); |
| 2077 |
|
| 2078 |
} |
| 2079 |
|
| 2080 |
$settings=get_option('responsive_video_grid_settings'); |
| 2081 |
|
| 2082 |
$rand_Numb = uniqid ( 'thumnail_slider' ); |
| 2083 |
$rand_Num_td = uniqid ( 'divSliderMain' ); |
| 2084 |
$rand_var_name = uniqid ( 'rand_' ); |
| 2085 |
|
| 2086 |
|
| 2087 |
$wpcurrentdir = dirname ( __FILE__ ); |
| 2088 |
$wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir ); |
| 2089 |
// $settings=get_option('thumbnail_slider_settings'); |
| 2090 |
|
| 2091 |
$uploads = wp_upload_dir(); |
| 2092 |
$baseDir = $uploads ['basedir']; |
| 2093 |
$baseDir = str_replace ( "\\", "/", $baseDir ); |
| 2094 |
$pathToImagesFolder = $baseDir . '/wp-responsive-video-grid'; |
| 2095 |
$baseurl = $uploads ['baseurl']; |
| 2096 |
$baseurl .= '/wp-responsive-video-grid/'; |
| 2097 |
?> |
| 2098 |
<style type='text/css'> |
| 2099 |
#<?php echo $rand_Num_td;?> {background: none repeat scroll 0 0<?php echo $settings ['scollerBackground'];?> ! important; |
| 2100 |
border: 0px none !important; |
| 2101 |
box-shadow: 0 0 0 0 !important; |
| 2102 |
|
| 2103 |
} |
| 2104 |
#poststuff #post-body.columns-2{margin-right: 0px} |
| 2105 |
</style> |
| 2106 |
<?php |
| 2107 |
$wpcurrentdir = dirname ( __FILE__ ); |
| 2108 |
$wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir ); |
| 2109 |
$randOmeAlbName = uniqid ( 'alb_' ); |
| 2110 |
$randOmeRel = uniqid ( 'rel_' ); |
| 2111 |
|
| 2112 |
if(!isset($settings['resize_images'])){ |
| 2113 |
|
| 2114 |
$settings['resize_images']=1; |
| 2115 |
|
| 2116 |
} |
| 2117 |
|
| 2118 |
?> |
| 2119 |
<div style="width: 100%;"> |
| 2120 |
<div style="float: left; width: 100%;"> |
| 2121 |
<div class="wrap_grid"> |
| 2122 |
<h2><?php echo __( 'Grid Preview','video-grid');?></h2> |
| 2123 |
|
| 2124 |
<?php if (is_array($settings)) { ?> |
| 2125 |
<div id="poststuff"> |
| 2126 |
<div id="post-body" class="metabox-holder columns-2"> |
| 2127 |
<div id="post-body-content"> |
| 2128 |
<div style="clear: both;"></div> |
| 2129 |
<?php $url = plugin_dir_url(__FILE__); ?> |
| 2130 |
|
| 2131 |
<div class="wrap_grid" id="<?php echo $rand_Num_td; ?>"> |
| 2132 |
<div id="<?php echo $rand_Numb; ?>" class="responsivegrid" style="margin-top: 2px !important;"> |
| 2133 |
<div class="box_parent"> |
| 2134 |
<?php |
| 2135 |
global $wpdb; |
| 2136 |
$imageheight = 270; |
| 2137 |
$imagewidth = 360; |
| 2138 |
$query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid order by createdon desc"; |
| 2139 |
$rows = $wpdb->get_results ( $query, 'ARRAY_A' ); |
| 2140 |
|
| 2141 |
if (count ( $rows ) > 0) { |
| 2142 |
|
| 2143 |
foreach ( $rows as $row ) { |
| 2144 |
|
| 2145 |
$imagename = $row ['image_name']; |
| 2146 |
$video_url = $row ['video_url']; |
| 2147 |
$imageUploadTo = $pathToImagesFolder . '/' . $imagename; |
| 2148 |
$imageUploadTo = str_replace ( "\\", "/", $imageUploadTo ); |
| 2149 |
$pathinfo = pathinfo ( $imageUploadTo ); |
| 2150 |
$filenamewithoutextension = $pathinfo ['filename']; |
| 2151 |
$outputimg = ""; |
| 2152 |
|
| 2153 |
if($settings['resize_images']==0){ |
| 2154 |
|
| 2155 |
$outputimg = $baseurl . $row ['image_name']; |
| 2156 |
} |
| 2157 |
else{ |
| 2158 |
|
| 2159 |
$imagetoCheck = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2160 |
|
| 2161 |
/* if (file_exists ( $imagetoCheck )) { |
| 2162 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2163 |
|
| 2164 |
} else {*/ |
| 2165 |
|
| 2166 |
if (function_exists ( 'wp_get_image_editor' )) { |
| 2167 |
|
| 2168 |
$image = wp_get_image_editor ( $pathToImagesFolder . "/" . $row ['image_name'] ); |
| 2169 |
|
| 2170 |
if (! is_wp_error ( $image )) { |
| 2171 |
$image->resize ( $imagewidth, $imageheight, true ); |
| 2172 |
$image->save ( $imagetoCheck ); |
| 2173 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2174 |
} else { |
| 2175 |
$outputimg = $baseurl . $row ['image_name']; |
| 2176 |
} |
| 2177 |
} else if (function_exists ( 'image_resize' )) { |
| 2178 |
|
| 2179 |
$return = image_resize ( $pathToImagesFolder . "/" . $row ['image_name'], $imagewidth, $imageheight ); |
| 2180 |
if (! is_wp_error ( $return )) { |
| 2181 |
|
| 2182 |
$isrenamed = rename ( $return, $imagetoCheck ); |
| 2183 |
if ($isrenamed) { |
| 2184 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2185 |
} else { |
| 2186 |
$outputimg = $baseurl . $row ['image_name']; |
| 2187 |
} |
| 2188 |
} else { |
| 2189 |
$outputimg = $baseurl . $row ['image_name']; |
| 2190 |
} |
| 2191 |
} else { |
| 2192 |
|
| 2193 |
$outputimg = $baseurl . $row ['image_name']; |
| 2194 |
} |
| 2195 |
|
| 2196 |
// $url = plugin_dir_url(__FILE__)."imagestoscroll/".$filenamewithoutextension.'_'.$imageheight.'_'.$imagewidth.'.'.$pathinfo['extension']; |
| 2197 |
//} |
| 2198 |
} |
| 2199 |
|
| 2200 |
$embed_url=$row['embed_url']; |
| 2201 |
|
| 2202 |
$title=""; |
| 2203 |
$rowTitle=$row['videotitle']; |
| 2204 |
$rowTitle=str_replace("'","’",$rowTitle); |
| 2205 |
$rowTitle=str_replace('"','”',$rowTitle); |
| 2206 |
|
| 2207 |
$rowDescrption=$row['video_description']; |
| 2208 |
$rowDescrption=str_replace("'","’",$rowDescrption); |
| 2209 |
$rowDescrption=str_replace('"','”',$rowDescrption); |
| 2210 |
$rowDescrption=strip_tags($rowDescrption); |
| 2211 |
|
| 2212 |
if(strlen($rowDescrption)>300){ |
| 2213 |
|
| 2214 |
$rowDescrption=substr($rowDescrption,0,300)."..."; |
| 2215 |
} |
| 2216 |
//$openImageInNewTab='_blank'; |
| 2217 |
$open_link_in=$row['open_link_in']; |
| 2218 |
// if($open_link_in==0){ |
| 2219 |
$openImageInNewTab='_self'; |
| 2220 |
//} |
| 2221 |
|
| 2222 |
if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])!=''){ |
| 2223 |
|
| 2224 |
$title="<a class='Imglink' target='$openImageInNewTab' href='{$row['videotitleurl']}'>{$rowTitle}</a>"; |
| 2225 |
if($row['video_description']!=''){ |
| 2226 |
$title.="<div class='clear_description_'>{$rowDescrption}</div>"; |
| 2227 |
} |
| 2228 |
} |
| 2229 |
else if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])==''){ |
| 2230 |
|
| 2231 |
$title="<a class='Imglink' href='#'>{$rowTitle}</a>"; |
| 2232 |
if($row['video_description']!=''){ |
| 2233 |
$title.="<div class='clear_description_'>{$rowDescrption}</div>"; |
| 2234 |
} |
| 2235 |
} |
| 2236 |
else{ |
| 2237 |
|
| 2238 |
if($row['video_description']!='') |
| 2239 |
$title="<div class='clear_description_'>{$row['video_description']}</div>"; |
| 2240 |
} |
| 2241 |
|
| 2242 |
|
| 2243 |
?> |
| 2244 |
|
| 2245 |
|
| 2246 |
<div class="box_grid"> |
| 2247 |
<div class="boxInner_grid"> |
| 2248 |
|
| 2249 |
<?php if($settings['display_video_lightbox']==true):?> |
| 2250 |
<a rel="<?php echo $randOmeRel;?>" data-overlay="1" data-title="<?php echo $title;?>" class="video_lbox" href="<?php echo $embed_url;?>"> |
| 2251 |
<img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/> |
| 2252 |
<span class="playbtnCss"></span> |
| 2253 |
<div class="titleBox"><?php echo $rowTitle;?></div> |
| 2254 |
</a> |
| 2255 |
<?php else : ?> |
| 2256 |
|
| 2257 |
<a href="<?php echo $video_url;?>"> |
| 2258 |
<img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/> |
| 2259 |
<span class="playbtnCss"></span> |
| 2260 |
<div class="titleBox"><?php echo $rowTitle;?></div> |
| 2261 |
</a> |
| 2262 |
|
| 2263 |
<?php endif;?> |
| 2264 |
</div> |
| 2265 |
</div> |
| 2266 |
|
| 2267 |
<?php } ?> |
| 2268 |
<?php } ?> |
| 2269 |
</div> |
| 2270 |
</div> |
| 2271 |
</div> |
| 2272 |
<script> |
| 2273 |
var uniqObj=jQuery("a[rel='<?php echo $randOmeRel;?>']"); |
| 2274 |
|
| 2275 |
jQuery(document).ready(function(){ |
| 2276 |
|
| 2277 |
videoPlacements('<?php echo $rand_Numb; ?>',jQuery); |
| 2278 |
jQuery(".video_lbox").fancybox_vg({ |
| 2279 |
'type' : "iframe", |
| 2280 |
'overlayColor':'#000000', |
| 2281 |
'padding': 10, |
| 2282 |
'autoScale': true, |
| 2283 |
'autoDimensions':true, |
| 2284 |
'transitionIn': 'none', |
| 2285 |
'uniqObj':uniqObj, |
| 2286 |
'transitionOut': 'none', |
| 2287 |
'titlePosition': 'outside', |
| 2288 |
'hideOnContentClick':false, |
| 2289 |
'width' : 650, |
| 2290 |
'height' : 400, |
| 2291 |
'titleFormat': function(title, currentArray, currentIndex, currentOpts) { |
| 2292 |
|
| 2293 |
var currtElem = jQuery('#<?php echo $rand_Numb; ?> a[href="'+currentOpts.href+'"]'); |
| 2294 |
|
| 2295 |
var isoverlay = jQuery(currtElem).attr('data-overlay') |
| 2296 |
|
| 2297 |
if(isoverlay=="1" && jQuery.trim(title)!=""){ |
| 2298 |
return '<span id="fancybox_vg-title-over">' + title + '</span>'; |
| 2299 |
} |
| 2300 |
else{ |
| 2301 |
return ''; |
| 2302 |
} |
| 2303 |
|
| 2304 |
}, |
| 2305 |
|
| 2306 |
}); |
| 2307 |
|
| 2308 |
}); |
| 2309 |
|
| 2310 |
|
| 2311 |
|
| 2312 |
var width__ = jQuery(window).width(); |
| 2313 |
var timer__; |
| 2314 |
jQuery(window).bind('resize', function(){ |
| 2315 |
if(jQuery(window).width() != width__){ |
| 2316 |
|
| 2317 |
width__ = jQuery(window).width(); |
| 2318 |
timer__ && clearTimeout(timer__); |
| 2319 |
timer__ = setTimeout(function(){ |
| 2320 |
|
| 2321 |
videoPlacements('<?php echo $rand_Numb; ?>',jQuery); |
| 2322 |
|
| 2323 |
}, 200); |
| 2324 |
|
| 2325 |
} |
| 2326 |
}); |
| 2327 |
|
| 2328 |
</script> |
| 2329 |
|
| 2330 |
</div> |
| 2331 |
</div> |
| 2332 |
</div> |
| 2333 |
<?php } ?> |
| 2334 |
</div> |
| 2335 |
</div> |
| 2336 |
<div class="clear"></div> |
| 2337 |
</div> |
| 2338 |
<?php if (is_array($settings)) { ?> |
| 2339 |
|
| 2340 |
<h3><?php echo __( 'To print this video gallery into WordPress Post/Page use below code','video-grid');?></h3> |
| 2341 |
<input type="text" value='[print_responsive_video_grid] ' style="width: 400px; height: 30px" onclick="this.focus(); this.select()" /> |
| 2342 |
<div class="clear"></div> |
| 2343 |
<h3><?php echo __( 'To print this video gallery into WordPress theme/template PHP files use below code','video-grid');?></h3> |
| 2344 |
<?php |
| 2345 |
$shortcode = '[print_responsive_video_grid]'; |
| 2346 |
?> |
| 2347 |
<input type="text" value="<?php echo do_shortcode('<?php echo htmlentities($shortcode, ENT_QUOTES); ?>'); ?>" style="width: 400px; height: 30px" onclick="this.focus(); this.select()" /> |
| 2348 |
<?php } ?> |
| 2349 |
<div class="clear"></div> |
| 2350 |
<?php |
| 2351 |
} |
| 2352 |
function print_responsive_video_grid_func($atts) { |
| 2353 |
|
| 2354 |
|
| 2355 |
wp_enqueue_style('wp-video-grid-lighbox-style'); |
| 2356 |
wp_enqueue_style('vl-box-grid-css'); |
| 2357 |
wp_enqueue_script('jquery'); |
| 2358 |
wp_enqueue_script('vl-grid-js'); |
| 2359 |
wp_enqueue_script('v_grid'); |
| 2360 |
|
| 2361 |
ob_start(); |
| 2362 |
|
| 2363 |
global $wpdb; |
| 2364 |
|
| 2365 |
$settings=get_option('responsive_video_grid_settings'); |
| 2366 |
$rand_Numb = uniqid ( 'thumnail_slider' ); |
| 2367 |
$rand_Num_td = uniqid ( 'divSliderMain' ); |
| 2368 |
$rand_var_name = uniqid ( 'rand_' ); |
| 2369 |
|
| 2370 |
|
| 2371 |
$wpcurrentdir = dirname ( __FILE__ ); |
| 2372 |
$wpcurrentdir = str_replace ( "\\", "/", $wpcurrentdir ); |
| 2373 |
// $settings=get_option('thumbnail_slider_settings'); |
| 2374 |
|
| 2375 |
$uploads = wp_upload_dir(); |
| 2376 |
$baseDir = $uploads ['basedir']; |
| 2377 |
$baseDir = str_replace ( "\\", "/", $baseDir ); |
| 2378 |
$pathToImagesFolder = $baseDir . '/wp-responsive-video-grid'; |
| 2379 |
$baseurl = $uploads ['baseurl']; |
| 2380 |
$baseurl .= '/wp-responsive-video-grid/'; |
| 2381 |
$randOmeRel = uniqid ( 'rel_' ); |
| 2382 |
$randOmVlBox= uniqid('video_lbox_'); |
| 2383 |
?><!-- print_responsive_video_grid_func --><style type='text/css'> |
| 2384 |
#<?php echo $rand_Num_td;?> {background: none repeat scroll 0 0<?php echo $settings['scollerBackground'];?> ! important; |
| 2385 |
border: 0px none !important; |
| 2386 |
box-shadow: 0 0 0 0 !important; |
| 2387 |
|
| 2388 |
} |
| 2389 |
</style> |
| 2390 |
<?php |
| 2391 |
|
| 2392 |
if (is_array($settings)) |
| 2393 |
|
| 2394 |
{ |
| 2395 |
|
| 2396 |
|
| 2397 |
if(!isset($settings['resize_images'])){ |
| 2398 |
|
| 2399 |
$settings['resize_images']=1; |
| 2400 |
|
| 2401 |
} |
| 2402 |
?> |
| 2403 |
<div style="clear: both;"></div> |
| 2404 |
<?php $url = plugin_dir_url(__FILE__); ?> |
| 2405 |
|
| 2406 |
<div style="width: auto; postion: relative" id="<?php echo $rand_Num_td; ?>"> |
| 2407 |
|
| 2408 |
<div id="<?php echo $rand_Numb; ?>" class="wrap_grid" style="margin-top: 2px !important;"> |
| 2409 |
<div class="box_parent"> |
| 2410 |
<?php |
| 2411 |
global $wpdb; |
| 2412 |
$imageheight = 270; |
| 2413 |
$imagewidth = 360; |
| 2414 |
$query = "SELECT * FROM " . $wpdb->prefix . "responsive_video_grid order by createdon desc"; |
| 2415 |
$rows = $wpdb->get_results ( $query, 'ARRAY_A' ); |
| 2416 |
|
| 2417 |
if (count ( $rows ) > 0) { |
| 2418 |
|
| 2419 |
foreach ( $rows as $row ) { |
| 2420 |
|
| 2421 |
$imagename = $row ['image_name']; |
| 2422 |
$video_url = $row ['video_url']; |
| 2423 |
$imageUploadTo = $pathToImagesFolder . '/' . $imagename; |
| 2424 |
$imageUploadTo = str_replace ( "\\", "/", $imageUploadTo ); |
| 2425 |
$pathinfo = pathinfo ( $imageUploadTo ); |
| 2426 |
$filenamewithoutextension = $pathinfo ['filename']; |
| 2427 |
$outputimg = ""; |
| 2428 |
|
| 2429 |
if($settings['resize_images']==0){ |
| 2430 |
|
| 2431 |
$outputimg = $baseurl . $row ['image_name']; |
| 2432 |
} |
| 2433 |
else{ |
| 2434 |
|
| 2435 |
$imagetoCheck = $pathToImagesFolder . '/' . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2436 |
|
| 2437 |
if (file_exists ( $imagetoCheck )) { |
| 2438 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2439 |
|
| 2440 |
} else { |
| 2441 |
|
| 2442 |
if (function_exists ( 'wp_get_image_editor' )) { |
| 2443 |
|
| 2444 |
$image = wp_get_image_editor ( $pathToImagesFolder . "/" . $row ['image_name'] ); |
| 2445 |
|
| 2446 |
if (! is_wp_error ( $image )) { |
| 2447 |
$image->resize ( $imagewidth, $imageheight, true ); |
| 2448 |
$image->save ( $imagetoCheck ); |
| 2449 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2450 |
} else { |
| 2451 |
$outputimg = $baseurl . $row ['image_name']; |
| 2452 |
} |
| 2453 |
} else if (function_exists ( 'image_resize' )) { |
| 2454 |
|
| 2455 |
$return = image_resize ( $pathToImagesFolder . "/" . $row ['image_name'], $imagewidth, $imageheight ); |
| 2456 |
if (! is_wp_error ( $return )) { |
| 2457 |
|
| 2458 |
$isrenamed = rename ( $return, $imagetoCheck ); |
| 2459 |
if ($isrenamed) { |
| 2460 |
$outputimg = $baseurl . $filenamewithoutextension . '_' . $imageheight . '_' . $imagewidth . '.' . $pathinfo ['extension']; |
| 2461 |
} else { |
| 2462 |
$outputimg = $baseurl . $row ['image_name']; |
| 2463 |
} |
| 2464 |
} else { |
| 2465 |
$outputimg = $baseurl . $row ['image_name']; |
| 2466 |
} |
| 2467 |
} else { |
| 2468 |
|
| 2469 |
$outputimg = $baseurl . $row ['image_name']; |
| 2470 |
} |
| 2471 |
|
| 2472 |
// $url = plugin_dir_url(__FILE__)."imagestoscroll/".$filenamewithoutextension.'_'.$imageheight.'_'.$imagewidth.'.'.$pathinfo['extension']; |
| 2473 |
} |
| 2474 |
} |
| 2475 |
|
| 2476 |
$embed_url=$row['embed_url']; |
| 2477 |
|
| 2478 |
|
| 2479 |
$title=""; |
| 2480 |
$rowTitle=$row['videotitle']; |
| 2481 |
$rowTitle=str_replace("'","’",$rowTitle); |
| 2482 |
$rowTitle=str_replace('"','”',$rowTitle); |
| 2483 |
|
| 2484 |
$rowDescrption=$row['video_description']; |
| 2485 |
$rowDescrption=str_replace("'","’",$rowDescrption); |
| 2486 |
$rowDescrption=str_replace('"','”',$rowDescrption); |
| 2487 |
$rowDescrption=strip_tags($rowDescrption); |
| 2488 |
|
| 2489 |
if(strlen($rowDescrption)>300){ |
| 2490 |
|
| 2491 |
$rowDescrption=substr($rowDescrption,0,300)."..."; |
| 2492 |
} |
| 2493 |
//$openImageInNewTab='_blank'; |
| 2494 |
$open_link_in=$row['open_link_in']; |
| 2495 |
// if($open_link_in==0){ |
| 2496 |
$openImageInNewTab='_self'; |
| 2497 |
//} |
| 2498 |
|
| 2499 |
if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])!=''){ |
| 2500 |
|
| 2501 |
$title="<a class='Imglink' target='$openImageInNewTab' href='{$row['videotitleurl']}'>{$rowTitle}</a>"; |
| 2502 |
if($row['video_description']!=''){ |
| 2503 |
$title.="<div class='clear_description_'>{$rowDescrption}</div>"; |
| 2504 |
} |
| 2505 |
} |
| 2506 |
else if(trim($row['videotitle'])!='' and trim($row['videotitleurl'])==''){ |
| 2507 |
|
| 2508 |
$title="<a class='Imglink' href='#'>{$rowTitle}</a>"; |
| 2509 |
if($row['video_description']!=''){ |
| 2510 |
$title.="<div class='clear_description_'>{$rowDescrption}</div>"; |
| 2511 |
} |
| 2512 |
} |
| 2513 |
else{ |
| 2514 |
|
| 2515 |
if($row['video_description']!='') |
| 2516 |
$title="<div class='clear_description_'>{$row['video_description']}</div>"; |
| 2517 |
} |
| 2518 |
|
| 2519 |
|
| 2520 |
?> |
| 2521 |
|
| 2522 |
|
| 2523 |
<div class="box_grid"> |
| 2524 |
<div class="boxInner_grid"> |
| 2525 |
|
| 2526 |
<?php if($settings['display_video_lightbox']==true):?> |
| 2527 |
<a rel="<?php echo $randOmeRel;?>" data-overlay="1" data-title="<?php echo htmlentities($title);?>" class="video_lbox" href="<?php echo $embed_url;?>"> |
| 2528 |
<img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/> |
| 2529 |
<span class="playbtnCss"></span> |
| 2530 |
<div class="titleBox"><?php echo $rowTitle;?></div> |
| 2531 |
</a> |
| 2532 |
<?php else : ?> |
| 2533 |
|
| 2534 |
<a href="<?php echo $video_url;?>"> |
| 2535 |
<img loading="lazy" class="thumb_img__ <?php if($settings['resize_images']==0):?>fit_img <?php endif;?> " src="<?php echo $outputimg; ?>" alt="<?php echo $rowTitle; ?>"/> |
| 2536 |
<span class="playbtnCss"></span> |
| 2537 |
<div class="titleBox"><?php echo $rowTitle;?></div> |
| 2538 |
</a> |
| 2539 |
|
| 2540 |
<?php endif;?> |
| 2541 |
</div> |
| 2542 |
</div> |
| 2543 |
|
| 2544 |
<?php } ?> |
| 2545 |
<?php } ?> |
| 2546 |
</div> |
| 2547 |
</div> |
| 2548 |
</div> |
| 2549 |
<script> |
| 2550 |
|
| 2551 |
<?php $intval= uniqid('interval_');?> |
| 2552 |
|
| 2553 |
var <?php echo $intval;?> = setInterval(function() { |
| 2554 |
|
| 2555 |
if(document.readyState === 'complete') { |
| 2556 |
|
| 2557 |
clearInterval(<?php echo $intval;?>); |
| 2558 |
|
| 2559 |
var uniqObj=jQuery("a[rel='<?php echo $randOmeRel;?>']"); |
| 2560 |
|
| 2561 |
|
| 2562 |
videoPlacements('<?php echo $rand_Numb; ?>',jQuery); |
| 2563 |
jQuery(".video_lbox").fancybox_vg({ |
| 2564 |
'type' : "iframe", |
| 2565 |
'overlayColor':'#000000', |
| 2566 |
'padding': 10, |
| 2567 |
'autoScale': true, |
| 2568 |
'autoDimensions':true, |
| 2569 |
'transitionIn': 'none', |
| 2570 |
'uniqObj':uniqObj, |
| 2571 |
'transitionOut': 'none', |
| 2572 |
'titlePosition': 'outside', |
| 2573 |
'hideOnContentClick':false, |
| 2574 |
'width' : 650, |
| 2575 |
'height' : 400, |
| 2576 |
'titleFormat': function(title, currentArray, currentIndex, currentOpts) { |
| 2577 |
|
| 2578 |
var currtElem = jQuery('#<?php echo $rand_Numb; ?> a[href="'+currentOpts.href+'"]'); |
| 2579 |
|
| 2580 |
var isoverlay = jQuery(currtElem).attr('data-overlay') |
| 2581 |
|
| 2582 |
if(isoverlay=="1" && jQuery.trim(title)!=""){ |
| 2583 |
return '<span id="fancybox_vg-title-over">' + title + '</span>'; |
| 2584 |
} |
| 2585 |
else{ |
| 2586 |
return ''; |
| 2587 |
} |
| 2588 |
|
| 2589 |
} |
| 2590 |
|
| 2591 |
}); |
| 2592 |
|
| 2593 |
|
| 2594 |
var width__ = jQuery(window).width(); |
| 2595 |
var timer__; |
| 2596 |
jQuery(window).bind('resize', function(){ |
| 2597 |
if(jQuery(window).width() != width__){ |
| 2598 |
|
| 2599 |
width__ = jQuery(window).width(); |
| 2600 |
timer__ && clearTimeout(timer__); |
| 2601 |
timer__ = setTimeout(function(){ |
| 2602 |
|
| 2603 |
videoPlacements('<?php echo $rand_Numb; ?>',jQuery); |
| 2604 |
|
| 2605 |
}, 200); |
| 2606 |
|
| 2607 |
} |
| 2608 |
}); |
| 2609 |
} |
| 2610 |
}, 100); |
| 2611 |
|
| 2612 |
</script> |
| 2613 |
<div class="clear_div"></div><!-- end print_responsive_video_grid_func --> |
| 2614 |
|
| 2615 |
|
| 2616 |
<?php } |
| 2617 |
$output = ob_get_clean(); |
| 2618 |
return $output; |
| 2619 |
} |
| 2620 |
function responsive_video_grid_get_wp_version() { |
| 2621 |
global $wp_version; |
| 2622 |
return $wp_version; |
| 2623 |
} |
| 2624 |
|
| 2625 |
// also we will add an option function that will check for plugin admin page or not |
| 2626 |
function responsive_video_grid_is_plugin_page() { |
| 2627 |
$server_uri = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; |
| 2628 |
|
| 2629 |
foreach ( array ( |
| 2630 |
'video_grid_with_lightbox_video_management','video_grid_with_lightbox' |
| 2631 |
) as $allowURI ) { |
| 2632 |
if (stristr ( $server_uri, $allowURI )) |
| 2633 |
return true; |
| 2634 |
} |
| 2635 |
return false; |
| 2636 |
} |
| 2637 |
|
| 2638 |
// add media WP scripts |
| 2639 |
function responsive_video_grid_admin_scripts_init() { |
| 2640 |
if (responsive_video_grid_is_plugin_page()) { |
| 2641 |
// double check for WordPress version and function exists |
| 2642 |
if (function_exists ( 'wp_enqueue_media' ) && version_compare ( responsive_video_grid_get_wp_version(), '3.5', '>=' )) { |
| 2643 |
// call for new media manager |
| 2644 |
wp_enqueue_media(); |
| 2645 |
} |
| 2646 |
wp_enqueue_style ( 'media' ); |
| 2647 |
wp_enqueue_style( 'wp-color-picker' ); |
| 2648 |
wp_enqueue_script( 'wp-color-picker' ); |
| 2649 |
} |
| 2650 |
} |
| 2651 |
|
| 2652 |
function prvg_remove_extra_p_tags($content){ |
| 2653 |
|
| 2654 |
if(strpos($content, 'print_responsive_video_grid_func')!==false){ |
| 2655 |
|
| 2656 |
|
| 2657 |
$pattern = "/<!-- print_responsive_video_grid_func -->(.*)<!-- end print_responsive_video_grid_func -->/Uis"; |
| 2658 |
$content = preg_replace_callback($pattern, function($matches) { |
| 2659 |
|
| 2660 |
|
| 2661 |
$altered = str_replace("<p>","",$matches[1]); |
| 2662 |
$altered = str_replace("</p>","",$altered); |
| 2663 |
|
| 2664 |
$altered=str_replace("&","&",$altered); |
| 2665 |
$altered=str_replace("”",'"',$altered); |
| 2666 |
|
| 2667 |
|
| 2668 |
return @str_replace($matches[1], $altered, $matches[0]); |
| 2669 |
}, $content); |
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
} |
| 2674 |
|
| 2675 |
$content = str_replace("<p><!-- print_responsive_video_grid_func -->","<!-- print_responsive_video_grid_func -->",$content); |
| 2676 |
$content = str_replace("<!-- end print_responsive_video_grid_func --></p>","<!-- end print_responsive_video_grid_func -->",$content); |
| 2677 |
|
| 2678 |
|
| 2679 |
return $content; |
| 2680 |
} |
| 2681 |
|
| 2682 |
add_filter('widget_text_content', 'prvg_remove_extra_p_tags', 999); |
| 2683 |
add_filter('the_content', 'prvg_remove_extra_p_tags', 999); |
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
?> |