| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The public-facing functionality of the plugin. |
| 5 |
* |
| 6 |
* @link http://rextheme.com/ |
| 7 |
* @since 8.0.0 |
| 8 |
* |
| 9 |
* @package Wpvr |
| 10 |
* @subpackage Wpvr/public |
| 11 |
*/ |
| 12 |
|
| 13 |
use WPVR\Builder\DIVI\WPVR_Divi_modules; |
| 14 |
|
| 15 |
/** |
| 16 |
* The public-facing functionality of the plugin. |
| 17 |
* |
| 18 |
* Defines the plugin name, version, and two examples hooks for how to |
| 19 |
* enqueue the public-facing stylesheet and JavaScript. |
| 20 |
* |
| 21 |
* @package Wpvr |
| 22 |
* @subpackage Wpvr/public |
| 23 |
* @author Rextheme <support@rextheme.com> |
| 24 |
*/ |
| 25 |
class Wpvr_Public { |
| 26 |
|
| 27 |
/** |
| 28 |
* The ID of this plugin. |
| 29 |
* |
| 30 |
* @since 8.0.0 |
| 31 |
* @access private |
| 32 |
* @var string $plugin_name The ID of this plugin. |
| 33 |
*/ |
| 34 |
private $plugin_name; |
| 35 |
|
| 36 |
/** |
| 37 |
* The version of this plugin. |
| 38 |
* |
| 39 |
* @since 8.0.0 |
| 40 |
* @access private |
| 41 |
* @var string $version The current version of this plugin. |
| 42 |
*/ |
| 43 |
private $version; |
| 44 |
|
| 45 |
|
| 46 |
/** |
| 47 |
* Instance of WPVR_Shortcode class |
| 48 |
* |
| 49 |
* @var object |
| 50 |
* @since 8.0.0 |
| 51 |
*/ |
| 52 |
private $shortcode; |
| 53 |
|
| 54 |
/** |
| 55 |
* Initialize the class and set its properties. |
| 56 |
* |
| 57 |
* @since 8.0.0 |
| 58 |
* @param string $plugin_name The name of the plugin. |
| 59 |
* @param string $version The version of this plugin. |
| 60 |
*/ |
| 61 |
public function __construct( $plugin_name, $version ) { |
| 62 |
|
| 63 |
$this->plugin_name = $plugin_name; |
| 64 |
$this->version = $version; |
| 65 |
$this->shortcode = new WPVR_Shortcode($this->plugin_name); |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Register the stylesheets for the public-facing side of the site. |
| 71 |
* |
| 72 |
* @since 8.0.0 |
| 73 |
*/ |
| 74 |
public function enqueue_styles() { |
| 75 |
|
| 76 |
/** |
| 77 |
* This function is provided for demonstration purposes only. |
| 78 |
* |
| 79 |
* An instance of this class should be passed to the run() function |
| 80 |
* defined in Wpvr_Loader as all of the hooks are defined |
| 81 |
* in that particular class. |
| 82 |
* |
| 83 |
* The Wpvr_Loader will then create the relationship |
| 84 |
* between the defined hooks and the functions defined in this |
| 85 |
* class. |
| 86 |
*/ |
| 87 |
|
| 88 |
global $wp; |
| 89 |
$wpvr_script_control = get_option('wpvr_script_control'); |
| 90 |
$wpvr_script_list = get_option('wpvr_script_list'); |
| 91 |
$allowed_pages_modified = array(); |
| 92 |
$allowed_pages = explode(",", $wpvr_script_list); |
| 93 |
foreach ($allowed_pages as $value) { |
| 94 |
$allowed_pages_modified[] = untrailingslashit($value); |
| 95 |
} |
| 96 |
$current_url = home_url(add_query_arg(array($_GET), $wp->request)); |
| 97 |
if ($wpvr_script_control == 'true') { |
| 98 |
foreach ($allowed_pages_modified as $value) { |
| 99 |
if ($value) { |
| 100 |
if (strpos($current_url, $value) !== false) { |
| 101 |
$fontawesome_disable = get_option('wpvr_fontawesome_disable'); |
| 102 |
if ($fontawesome_disable == 'true') { |
| 103 |
} else { |
| 104 |
wp_enqueue_style($this->plugin_name . 'fontawesome', 'https://use.fontawesome.com/releases/v6.5.1/css/all.css', array(), $this->version, 'all'); |
| 105 |
} |
| 106 |
wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); |
| 107 |
wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); |
| 108 |
wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); |
| 109 |
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all'); |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
} else { |
| 114 |
$fontawesome_disable = get_option('wpvr_fontawesome_disable'); |
| 115 |
if ($fontawesome_disable == 'true') { |
| 116 |
} else { |
| 117 |
wp_enqueue_style($this->plugin_name . 'fontawesome', 'https://use.fontawesome.com/releases/v6.5.1/css/all.css', array(), $this->version, 'all'); |
| 118 |
} |
| 119 |
wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); |
| 120 |
wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); // commented for video js vr |
| 121 |
// wp_enqueue_style('videojs-css', 'https://vjs.zencdn.net/7.18.1/video-js.css', array(), true); // commented for video js vr |
| 122 |
wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true); //video js VR |
| 123 |
wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); |
| 124 |
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all'); |
| 125 |
} |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* Register the JavaScript for the public-facing side of the site. |
| 131 |
* |
| 132 |
* @since 8.0.0 |
| 133 |
*/ |
| 134 |
public function enqueue_scripts() { |
| 135 |
|
| 136 |
$notice = ''; |
| 137 |
$wpvr_frontend_notice = get_option('wpvr_frontend_notice'); |
| 138 |
if ($wpvr_frontend_notice) { |
| 139 |
$notice = get_option('wpvr_frontend_notice_area'); |
| 140 |
} |
| 141 |
global $wp; |
| 142 |
$wpvr_script_control = get_option('wpvr_script_control'); |
| 143 |
$wpvr_script_list = get_option('wpvr_script_list'); |
| 144 |
$allowed_pages_modified = array(); |
| 145 |
$allowed_pages = explode(",", $wpvr_script_list); |
| 146 |
foreach ($allowed_pages as $value) { |
| 147 |
$allowed_pages_modified[] = untrailingslashit($value); |
| 148 |
} |
| 149 |
|
| 150 |
$wpvr_video_script_control = get_option('wpvr_video_script_control'); |
| 151 |
$wpvr_video_script_list = get_option('wpvr_video_script_list'); |
| 152 |
$allowed_video_pages_modified = array(); |
| 153 |
$allowed_video_pages = explode(",", $wpvr_video_script_list); |
| 154 |
foreach ($allowed_video_pages as $value) { |
| 155 |
$allowed_video_pages_modified[] = untrailingslashit($value); |
| 156 |
} |
| 157 |
|
| 158 |
$current_url = home_url(add_query_arg(array($_GET), $wp->request)); |
| 159 |
|
| 160 |
if ($wpvr_script_control == 'true') { |
| 161 |
foreach ($allowed_pages_modified as $value) { |
| 162 |
if (strpos($current_url, $value) !== false) { |
| 163 |
wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); |
| 164 |
wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array(), true); |
| 165 |
wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); //commented for video js vr |
| 166 |
// wp_enqueue_script('videojs-js', 'https://vjs.zencdn.net/7.18.1/video.min.js', array(), true); |
| 167 |
wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array(), true); //video js vr |
| 168 |
wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true); |
| 169 |
wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); |
| 170 |
wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true); |
| 171 |
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, false); |
| 172 |
wp_localize_script('wpvr', 'wpvr_public', array( |
| 173 |
'notice_active' => $wpvr_frontend_notice, |
| 174 |
'notice' => $notice, |
| 175 |
'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), |
| 176 |
)); |
| 177 |
} |
| 178 |
} |
| 179 |
} else { |
| 180 |
wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); |
| 181 |
wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array(), true); |
| 182 |
wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); // commented for video js vr |
| 183 |
wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array(), true); //video js vr |
| 184 |
wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true); |
| 185 |
wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); |
| 186 |
wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true); |
| 187 |
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, true); |
| 188 |
wp_localize_script('wpvr', 'wpvr_public', array( |
| 189 |
'notice_active' => $wpvr_frontend_notice, |
| 190 |
'notice' => $notice, |
| 191 |
'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), |
| 192 |
)); |
| 193 |
} |
| 194 |
|
| 195 |
$match_found = false; |
| 196 |
if ($wpvr_video_script_control == 'true') { |
| 197 |
foreach ($allowed_video_pages_modified as $value) { |
| 198 |
if (strpos($current_url, $value) !== false) { |
| 199 |
$match_found = true; |
| 200 |
wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); // commented for video js vr |
| 201 |
wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array(), true); //video js vr |
| 202 |
wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true); |
| 203 |
} |
| 204 |
} |
| 205 |
if (!$match_found) { |
| 206 |
wp_dequeue_script('videojs-js'); |
| 207 |
wp_dequeue_script('videojsvr-js'); |
| 208 |
wp_dequeue_script('panelliumvid-js'); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
} |
| 213 |
|
| 214 |
/** |
| 215 |
* Init the edit screen of the plugin post type item |
| 216 |
* |
| 217 |
* @since 8.0.0 |
| 218 |
*/ |
| 219 |
public function public_init() |
| 220 |
{ |
| 221 |
add_shortcode($this->plugin_name, array( $this->shortcode , 'wpvr_shortcode')); |
| 222 |
|
| 223 |
} |
| 224 |
|
| 225 |
} |
| 226 |
|