| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: WP Video Lightbox |
| 4 |
Version: 1.9.12 |
| 5 |
Plugin URI: https://www.tipsandtricks-hq.com/?p=2700 |
| 6 |
Author: Tips and Tricks HQ, Ruhul Amin |
| 7 |
Author URI: https://www.tipsandtricks-hq.com/ |
| 8 |
Description: Simple video lightbox plugin to display videos in a nice overlay popup. It also supports images, flash, YouTube, iFrame. |
| 9 |
Text Domain: wp-video-lightbox |
| 10 |
Domain Path: /languages |
| 11 |
*/ |
| 12 |
if (!defined('ABSPATH')) exit; |
| 13 |
|
| 14 |
if (!class_exists('WP_Video_Lightbox')) |
| 15 |
{ |
| 16 |
class WP_Video_Lightbox |
| 17 |
{ |
| 18 |
var $version = '1.9.12'; |
| 19 |
var $db_version = '1.0'; |
| 20 |
var $plugin_url; |
| 21 |
var $plugin_path; |
| 22 |
var $settings_obj; |
| 23 |
|
| 24 |
function __construct() |
| 25 |
{ |
| 26 |
$this->define_constants(); |
| 27 |
$this->includes(); |
| 28 |
$this->loader_operations(); |
| 29 |
//Handle any db install and upgrade task |
| 30 |
|
| 31 |
add_action( 'init', array( $this, 'plugin_init' ), 0 ); |
| 32 |
add_action( 'wp_enqueue_scripts', array( $this, 'plugin_scripts' ), 0 ); |
| 33 |
add_action( 'wp_head', array( $this, 'plugin_header' )); |
| 34 |
add_action( 'wp_footer', array( $this, 'plugin_footer' ), 0 ); |
| 35 |
} |
| 36 |
|
| 37 |
function define_constants(){ |
| 38 |
define('WP_VIDEO_LIGHTBOX_VERSION', $this->version); |
| 39 |
define('WP_VID_LIGHTBOX_URL', $this->plugin_url()); |
| 40 |
define('WP_VIDEO_LIGHTBOX_PATH', $this->plugin_path()); |
| 41 |
define('WP_VIDEO_LIGHTBOX_DB_VERSION', $this->db_version); |
| 42 |
define('WPVL_PRETTYPHOTO_REL', 'wp-video-lightbox'); |
| 43 |
define('WPVL_PRETTYPHOTO_VERSION', '3.1.6'); |
| 44 |
define('WPVL_FANCYBOX_VERSION', '3.0.47'); |
| 45 |
} |
| 46 |
|
| 47 |
function includes() { |
| 48 |
include_once('class-prettyphoto.php'); |
| 49 |
include_once('wpvl-settings.php'); |
| 50 |
include_once('misc_functions.php'); |
| 51 |
} |
| 52 |
|
| 53 |
function loader_operations(){ |
| 54 |
register_activation_hook( __FILE__, array(&$this, 'activate_handler') ); //activation hook |
| 55 |
add_action('plugins_loaded',array(&$this, 'plugins_loaded_handler')); //plugins loaded hook |
| 56 |
if (!is_admin()) |
| 57 |
{ |
| 58 |
add_filter('widget_text', 'do_shortcode'); |
| 59 |
add_filter('the_excerpt', 'do_shortcode',11); |
| 60 |
add_filter('the_content', 'do_shortcode',11); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
function plugins_loaded_handler() //Runs when plugins_loaded action gets fired |
| 65 |
{ |
| 66 |
load_plugin_textdomain('wp-video-lightbox', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); |
| 67 |
$this->do_db_upgrade_check(); |
| 68 |
$this->settings_obj = new Video_Lightbox_Settings_Page(); //Initialize settins menus |
| 69 |
} |
| 70 |
|
| 71 |
function activate_handler(){//Will run when the plugin activates only |
| 72 |
//initialize settings |
| 73 |
add_option('wpvl_plugin_version', $this->version); |
| 74 |
add_option('wpvl_enable_jquery', '1'); |
| 75 |
add_option('wpvl_enable_prettyPhoto', '1'); |
| 76 |
$wpvl_prettyPhoto = WP_Video_Lightbox_prettyPhoto::get_instance(); |
| 77 |
WP_Video_Lightbox_prettyPhoto::save_object($wpvl_prettyPhoto); |
| 78 |
} |
| 79 |
|
| 80 |
function do_db_upgrade_check(){ |
| 81 |
//NOP |
| 82 |
if(is_admin()) |
| 83 |
{ |
| 84 |
$wpvl_version = get_option('wpvl_plugin_version'); |
| 85 |
if(!isset($wpvl_version) || $wpvl_version != $this->version) |
| 86 |
{ |
| 87 |
$this->activate_handler(); |
| 88 |
update_option('wpvl_plugin_version', $this->version); |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
function plugin_init(){ |
| 94 |
//add_filter('ngg_render_template',array(&$this, 'ngg_render_template_handler'),10,2); |
| 95 |
if(!is_admin()) |
| 96 |
{ |
| 97 |
|
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
function plugin_scripts() |
| 102 |
{ |
| 103 |
if (!is_admin()) |
| 104 |
{ |
| 105 |
wp_vid_lightbox_enqueue_script(); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
function plugin_header() |
| 110 |
{ |
| 111 |
$custom_function = <<<EOT |
| 112 |
function wpvl_paramReplace(name, string, value) { |
| 113 |
// Find the param with regex |
| 114 |
// Grab the first character in the returned string (should be ? or &) |
| 115 |
// Replace our href string with our new value, passing on the name and delimeter |
| 116 |
|
| 117 |
var re = new RegExp("[\\?&]" + name + "=([^&#]*)"); |
| 118 |
var matches = re.exec(string); |
| 119 |
var newString; |
| 120 |
|
| 121 |
if (matches === null) { |
| 122 |
// if there are no params, append the parameter |
| 123 |
newString = string + '?' + name + '=' + value; |
| 124 |
} else { |
| 125 |
var delimeter = matches[0].charAt(0); |
| 126 |
newString = string.replace(re, delimeter + name + "=" + value); |
| 127 |
} |
| 128 |
return newString; |
| 129 |
} |
| 130 |
EOT; |
| 131 |
echo '<script> |
| 132 |
WP_VIDEO_LIGHTBOX_VERSION="'.WP_VIDEO_LIGHTBOX_VERSION.'"; |
| 133 |
WP_VID_LIGHTBOX_URL="'.WP_VID_LIGHTBOX_URL.'"; |
| 134 |
'.$custom_function.' |
| 135 |
</script>'; |
| 136 |
} |
| 137 |
|
| 138 |
function plugin_footer() |
| 139 |
{ |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
function plugin_url(){ |
| 144 |
if ( $this->plugin_url ) return $this->plugin_url; |
| 145 |
return $this->plugin_url = plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) ); |
| 146 |
} |
| 147 |
|
| 148 |
function plugin_path(){ |
| 149 |
if ( $this->plugin_path ) return $this->plugin_path; |
| 150 |
return $this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ); |
| 151 |
} |
| 152 |
|
| 153 |
} |
| 154 |
|
| 155 |
}//End of class not exists check |
| 156 |
|
| 157 |
$GLOBALS['wp_video_lightbox'] = new WP_Video_Lightbox(); |
| 158 |
|