PluginProbe
Slider Ultimate / 2.2.1
Slider Ultimate v2.2.1
2.2.10 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 All 54 releases
ultimate-slider / ultimate-slider.php
ultimate-slider.php
413 lines 13.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Slider Ultimate
4 Plugin URI: http://www.EtoileWebDesign.com/plugins/
5 Description: A plugin that lets you create a slider, using posts, WooCommerce or Ultimate Product Catalog products
6 Author: Etoile Web Design
7 Author URI: http://www.EtoileWebDesign.com/plugins/
8 Terms and Conditions: http://www.etoilewebdesign.com/plugin-terms-and-conditions/
9 Text Domain: ultimate-slider
10 Version: 2.2.1
11 */
12
13 if ( ! defined( 'ABSPATH' ) )
14 exit;
15
16 if ( ! class_exists( 'ewdusInit' ) ) {
17 class ewdusInit {
18
19 // Any data that needs to be passed from PHP to our JS files
20 public $front_end_php_js_data = array();
21
22 /**
23 * Initialize the plugin and register hooks
24 */
25 public function __construct() {
26
27 self::constants();
28 self::includes();
29 self::instantiate();
30 self::wp_hooks();
31 }
32
33 /**
34 * Define plugin constants.
35 *
36 * @since 2.0.0
37 * @access protected
38 * @return void
39 */
40 protected function constants() {
41
42 define( 'EWD_US_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
43 define( 'EWD_US_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
44 define( 'EWD_US_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
45 define( 'EWD_US_TEMPLATE_DIR', 'ewd-us-templates' );
46 define( 'EWD_US_VERSION', '2.2.1' );
47
48 define( 'EWD_US_SLIDER_POST_TYPE', 'ultimate_slider' );
49 define( 'EWD_US_SLIDER_CATEGORY_TAXONOMY', 'ultimate_slider_categories' );
50 define( 'EWD_US_SLIDER_TAG_TAXONOMY', 'ultimate_slider_tags' );
51 }
52
53 /**
54 * Include necessary classes.
55 *
56 * @since 2.0.0
57 * @access protected
58 * @return void
59 */
60 protected function includes() {
61
62 require_once( EWD_US_PLUGIN_DIR . '/includes/AboutUs.class.php' );
63 require_once( EWD_US_PLUGIN_DIR . '/includes/Blocks.class.php' );
64 require_once( EWD_US_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
65 require_once( EWD_US_PLUGIN_DIR . '/includes/Dashboard.class.php' );
66 require_once( EWD_US_PLUGIN_DIR . '/includes/DeactivationSurvey.class.php' );
67 require_once( EWD_US_PLUGIN_DIR . '/includes/Helper.class.php' );
68 require_once( EWD_US_PLUGIN_DIR . '/includes/InstallationWalkthrough.class.php' );
69 require_once( EWD_US_PLUGIN_DIR . '/includes/Permissions.class.php' );
70 require_once( EWD_US_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
71 require_once( EWD_US_PLUGIN_DIR . '/includes/Settings.class.php' );
72 require_once( EWD_US_PLUGIN_DIR . '/includes/template-functions.php' );
73 require_once( EWD_US_PLUGIN_DIR . '/includes/Widgets.class.php' );
74 require_once( EWD_US_PLUGIN_DIR . '/includes/WooCommerceIntegration.class.php' );
75 }
76
77 /**
78 * Spin up instances of our plugin classes.
79 *
80 * @since 2.0.0
81 * @access protected
82 * @return void
83 */
84 protected function instantiate() {
85
86 new ewdusDashboard();
87 new ewdusDeactivationSurvey();
88 new ewdusInstallationWalkthrough();
89 new ewdusReviewAsk();
90
91 $this->cpts = new ewdusCustomPostTypes();
92 $this->permissions = new ewdusPermissions();
93 $this->settings = new ewdusSettings();
94
95 new ewdusBlocks();
96 new ewdusWidgetManager();
97
98 if ( $this->settings->get_setting( 'wc-product-image-slider' ) ) {
99 new ewdusWooCommerceIntegration();
100 }
101
102 new ewdusAboutUs();
103 }
104
105 /**
106 * Run walk-through, load assets, add links to plugin listing, etc.
107 *
108 * @since 2.0.0
109 * @access protected
110 * @return void
111 */
112 protected function wp_hooks() {
113
114 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
115 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
116
117 add_action( 'init', array( $this, 'load_view_files' ) );
118
119 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
120
121 add_action( 'admin_notices', array( $this, 'display_header_area' ) );
122 add_action( 'admin_notices', array( $this, 'maybe_display_helper_notice' ) );
123
124 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
125 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
126 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
127 add_action( 'wp_footer', array( $this, 'assets_footer' ), 2 );
128
129 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
130
131 add_action( 'wp_ajax_ewd_us_hide_helper_notice', array( $this, 'hide_helper_notice' ) );
132 }
133
134 /**
135 * Run the options conversion function on update if necessary
136 *
137 * @since 2.0.0
138 * @access protected
139 * @return void
140 */
141 public function convert_options() {
142
143 require_once( EWD_US_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
144 new ewdusBackwardsCompatibility();
145 }
146
147 /**
148 * Load files needed for views
149 * @since 2.0.0
150 * @note Can be filtered to add new classes as needed
151 */
152 public function load_view_files() {
153
154 $files = array(
155 EWD_US_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
156 );
157
158 $files = apply_filters( 'ewd_us_load_view_files', $files );
159
160 foreach( $files as $file ) {
161 require_once( $file );
162 }
163
164 }
165
166 /**
167 * Load the plugin textdomain for localisation
168 * @since 2.0.0
169 */
170 public function load_textdomain() {
171
172 load_plugin_textdomain( 'ultimate-slider', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
173 }
174
175 /**
176 * Set a transient so that the walk-through gets run
177 * @since 2.0.0
178 */
179 public function run_walkthrough() {
180
181 set_transient( 'ewd-us-getting-started', true, 30 );
182 }
183
184 /**
185 * Enqueue the admin-only CSS and Javascript
186 * @since 2.0.0
187 */
188 public function enqueue_admin_assets( $hook ) {
189 global $post;
190
191 wp_enqueue_script( 'ewd-us-helper-notice', EWD_US_PLUGIN_URL . '/assets/js/ewd-us-helper-install-notice.js', array( 'jquery' ), EWD_US_VERSION, true );
192 wp_localize_script(
193 'ewd-us-helper-notice',
194 'ewd_us_helper_notice',
195 array( 'nonce' => wp_create_nonce( 'ewd-us-helper-notice' ) )
196 );
197
198 wp_enqueue_style( 'ewd-us-helper-notice', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-helper-install-notice.css', array(), EWD_US_VERSION );
199
200 $screen = get_current_screen();
201
202 $candidates = array(
203 EWD_US_SLIDER_POST_TYPE,
204
205 'ultimate_slider_page_ewd-us-settings',
206
207 'widgets.php',
208 );
209
210 // Return if not ultimate_slider post_type, we're not on a post-type page, or we're not on the settings or widget pages
211 if ( ! in_array( $hook, $candidates )
212 and ( empty( $screen->post_type ) or ! in_array ( $screen->post_type, $candidates ) )
213 and ! in_array( $screen->id, $candidates )
214 ) {
215 return;
216 }
217
218 wp_enqueue_script( 'jquery-ui-core' );
219 wp_enqueue_script( 'jquery-ui-sortable' );
220 wp_enqueue_script( 'ewd-us-admin-js', EWD_US_PLUGIN_URL . '/assets/js/ewd-us-admin.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable' ), EWD_US_VERSION, true );
221
222 wp_enqueue_style( 'ewd-us-admin-css', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-admin.css', EWD_US_VERSION );
223
224 $settings = array(
225 'nonce' => wp_create_nonce( 'ewd-us-admin-js' ),
226 );
227
228 wp_localize_script( 'ewd-us-admin-js', 'ewd_us_admin_php_data', $settings );
229 }
230
231 /**
232 * Register the front-end CSS and Javascript for the slider
233 * @since 2.0.0
234 */
235 function register_assets() {
236 global $ewd_us_controller;
237
238 wp_register_script( 'ewd-us-js', EWD_US_PLUGIN_URL . '/assets/js/ewd-us.js', array( 'jquery', 'jquery-ui-core', 'jquery-effects-slide' ), EWD_US_VERSION, true );
239 wp_register_script( 'iframe-clicks', EWD_US_PLUGIN_URL . '/assets/js/jquery.iframetracker.js' , array( 'jquery' ), EWD_US_VERSION, true );
240
241 wp_register_style( 'ewd-us-css', EWD_US_PLUGIN_URL . '/assets/css/ewd-us.css', EWD_US_VERSION );
242
243 if ( $ewd_us_controller->settings->get_setting( 'lightbox' ) ) {
244
245 wp_register_script( 'ultimate-lightbox', EWD_US_PLUGIN_URL . '/assets/js/ultimate-lightbox.js', array( 'jquery' ), EWD_US_VERSION, true );
246
247 wp_register_style( 'ewd-ulb-main', EWD_US_PLUGIN_URL . '/assets/css/ewd-ulb-main.css', EWD_US_VERSION );
248 }
249 }
250
251 /**
252 * Print out any PHP data needed for our JS to work correctly
253 * @since 2.1.0
254 */
255 public function assets_footer() {
256
257 if ( empty( $this->front_end_php_js_data ) ) { return; }
258
259 $print_variables = array();
260
261 foreach ( (array) $this->front_end_php_js_data as $variable => $values ) {
262
263 if ( empty( $values ) ) { continue; }
264
265 $print_variables[ $variable ] = ewdusHelper::escape_js_recursive( $values );
266 }
267
268 foreach ( $print_variables as $variable => $values ) {
269
270 echo "<script type='text/javascript'>\n";
271 echo "/* <![CDATA[ */\n";
272 echo 'var ' . esc_attr( $variable ) . ' = ' . wp_json_encode( $values ) . "\n";
273 echo "/* ]]> */\n";
274 echo "</script>\n";
275 }
276 }
277
278 /**
279 * Adds a variable to be passed to our front-end JS
280 * @since 2.1.0
281 */
282 public function add_front_end_php_data( $handle, $variable, $data ) {
283
284 $this->front_end_php_js_data[ $variable ] = $data;
285 }
286
287 /**
288 * Returns the corresponding front-end JS variable if it exists, otherwise an empty array
289 * @since 2.1.0
290 */
291 public function get_front_end_php_data( $handle, $variable ) {
292
293 return ! empty( $this->front_end_php_js_data[ $variable ] ) ? $this->front_end_php_js_data[ $variable ] : array();
294 }
295
296 /**
297 * Add links to the plugin listing on the installed plugins page
298 * @since 2.0.0
299 */
300 public function plugin_action_links( $links, $plugin ) {
301 global $ewd_us_controller;
302
303 if ( $plugin == EWD_US_PLUGIN_FNAME ) {
304
305 if ( ! $ewd_us_controller->permissions->check_permission( 'premium' ) ) {
306
307 array_unshift( $links, '<a class="ewd-us-plugin-page-upgrade-link" href="https://www.etoilewebdesign.com/license-payment/?Selected=US&Quantity=1&utm_source=wp_admin_plugins_page" title="' . __( 'Try Premium', 'ultimate-slider' ) . '" target="_blank">' . __( 'Try Premium', 'ultimate-slider' ) . '</a>' );
308 }
309
310 $links['settings'] = '<a href="admin.php?page=ewd-us-settings" title="' . __( 'Head to the settings page for Ultimate Slider', 'ultimate-slider' ) . '">' . __( 'Settings', 'ultimate-slider' ) . '</a>';
311 }
312
313 return $links;
314
315 }
316
317 /**
318 * Adds in a menu bar for the plugin
319 * @since 2.0.0
320 */
321 public function display_header_area() {
322 global $ewd_us_controller;
323
324 $screen = get_current_screen();
325
326 if ( empty( $screen->parent_file ) or $screen->parent_file != 'edit.php?post_type=ultimate_slider' ) { return; }
327
328 if ( ! $ewd_us_controller->permissions->check_permission( 'styling' ) or get_option( 'EWD_US_Trial_Happening' ) == 'Yes' ) {
329 ?>
330 <div class="ewd-us-dashboard-new-upgrade-banner">
331 <div class="ewd-us-dashboard-banner-icon"></div>
332 <div class="ewd-us-dashboard-banner-buttons">
333 <a class="ewd-us-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=US&Quantity=1&utm_source=us_admin&utm_content=banner" target="_blank">UPGRADE NOW</a>
334 </div>
335 <div class="ewd-us-dashboard-banner-text">
336 <div class="ewd-us-dashboard-banner-title">
337 GET FULL ACCESS WITH OUR PREMIUM VERSION
338 </div>
339 <div class="ewd-us-dashboard-banner-brief">
340 Slide and title animations/effects, modify the controls, WooCommerce integration, advanced styling options and more!
341 </div>
342 </div>
343 </div>
344 <?php
345 }
346
347 ?>
348 <div class="ewd-us-admin-header-menu">
349 <h2 class="nav-tab-wrapper">
350 <a id="ewd-us-dash-mobile-menu-open" href="#" class="menu-tab nav-tab"><?php _e("MENU", 'ultimate-slider'); ?><span id="ewd-us-dash-mobile-menu-down-caret">&nbsp;&nbsp;&#9660;</span><span id="ewd-us-dash-mobile-menu-up-caret">&nbsp;&nbsp;&#9650;</span></a>
351 <a id="dashboard-menu" href='admin.php?page=ewd-us-dashboard' class="menu-tab nav-tab <?php if ( $screen->id == 'ultimate_slider_ewd-us-dashboard' ) {echo 'nav-tab-active';}?>"><?php _e("Dashboard", 'ultimate-slider'); ?></a>
352 <a id="slides-menu" href='edit.php?post_type=ultimate_slider' class="menu-tab nav-tab <?php if ( $screen->id == 'edit-ultimate_slider' ) {echo 'nav-tab-active';}?>"><?php _e("Slides", 'ultimate-slider'); ?></a>
353 <a id="options-menu" href='edit.php?post_type=ultimate_slider&page=ewd-us-settings' class="menu-tab nav-tab <?php if ( $screen->id == ' ultimate_slider_page_ewd-us-settings' ) {echo 'nav-tab-active';}?>"><?php _e("Settings", 'ultimate-slider'); ?></a>
354 </h2>
355 </div>
356 <?php
357 }
358
359 public function maybe_display_helper_notice() {
360 global $ewd_us_controller;
361
362 if ( empty( $ewd_us_controller->permissions->check_permission( 'premium' ) ) ) { return; }
363
364 if ( is_plugin_active( 'ewd-premium-helper/ewd-premium-helper.php' ) ) { return; }
365
366 if ( get_transient( 'ewd-helper-notice-dismissed' ) ) { return; }
367
368 ?>
369
370 <div class='notice notice-error is-dismissible ewd-us-helper-install-notice'>
371
372 <div class='ewd-us-helper-install-notice-img'>
373 <img src='<?php echo EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/img/options-asset-exclamation.png' ; ?>' />
374 </div>
375
376 <div class='ewd-us-helper-install-notice-txt'>
377 <?php _e( 'You\'re using the Ultimate Slider premium version, but the premium helper plugin is not active.', 'ultimate-slider' ); ?>
378 <br />
379 <?php echo sprintf( __( 'Please re-activate the helper plugin, or <a target=\'_blank\' href=\'%s\'>download and install it</a> if the plugin is no longer installed to ensure continued access to the premium features of the plugin.', 'ultimate-slider' ), 'https://www.etoilewebdesign.com/2021/12/11/requiring-premium-helper-plugin/' ); ?>
380 </div>
381
382 <div class='ewd-us-clear'></div>
383
384 </div>
385
386 <?php
387 }
388
389 public function hide_helper_notice() {
390
391 // Authenticate request
392 if ( ! check_ajax_referer( 'ewd-us-helper-notice', 'nonce' ) or ! current_user_can( 'manage_options' ) ) {
393
394 wp_send_json_error(
395 array(
396 'error' => 'loggedout',
397 'msg' => sprintf( __( 'You have been logged out. Please %slogin again%s.', 'ultimate-slider' ), '<a href="' . wp_login_url( admin_url( 'admin.php?page=ewd-us-dashboard' ) ) . '">', '</a>' ),
398 )
399 );
400 }
401
402 set_transient( 'ewd-helper-notice-dismissed', true, 3600*24*7 );
403
404 die();
405 }
406
407 }
408 } // endif;
409
410 global $ewd_us_controller;
411 $ewd_us_controller = new ewdusInit();
412
413 do_action( 'ewd_us_initialized' );