PluginProbe
Slider Ultimate / 2.1.1
Slider Ultimate v2.1.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
404 lines 13.2 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.1.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.1.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/Blocks.class.php' );
63 require_once( EWD_US_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
64 require_once( EWD_US_PLUGIN_DIR . '/includes/Dashboard.class.php' );
65 require_once( EWD_US_PLUGIN_DIR . '/includes/DeactivationSurvey.class.php' );
66 require_once( EWD_US_PLUGIN_DIR . '/includes/Helper.class.php' );
67 require_once( EWD_US_PLUGIN_DIR . '/includes/InstallationWalkthrough.class.php' );
68 require_once( EWD_US_PLUGIN_DIR . '/includes/Permissions.class.php' );
69 require_once( EWD_US_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
70 require_once( EWD_US_PLUGIN_DIR . '/includes/Settings.class.php' );
71 require_once( EWD_US_PLUGIN_DIR . '/includes/template-functions.php' );
72 require_once( EWD_US_PLUGIN_DIR . '/includes/Widgets.class.php' );
73 require_once( EWD_US_PLUGIN_DIR . '/includes/WooCommerceIntegration.class.php' );
74 }
75
76 /**
77 * Spin up instances of our plugin classes.
78 *
79 * @since 2.0.0
80 * @access protected
81 * @return void
82 */
83 protected function instantiate() {
84
85 new ewdusDashboard();
86 new ewdusDeactivationSurvey();
87 new ewdusInstallationWalkthrough();
88 new ewdusReviewAsk();
89
90 $this->cpts = new ewdusCustomPostTypes();
91 $this->permissions = new ewdusPermissions();
92 $this->settings = new ewdusSettings();
93
94 new ewdusBlocks();
95 new ewdusWidgetManager();
96
97 if ( $this->settings->get_setting( 'wc-product-image-slider' ) ) {
98 new ewdusWooCommerceIntegration();
99 }
100 }
101
102 /**
103 * Run walk-through, load assets, add links to plugin listing, etc.
104 *
105 * @since 2.0.0
106 * @access protected
107 * @return void
108 */
109 protected function wp_hooks() {
110
111 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
112 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
113
114 add_action( 'init', array( $this, 'load_view_files' ) );
115
116 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
117
118 add_action( 'admin_notices', array( $this, 'display_header_area' ) );
119 add_action( 'admin_notices', array( $this, 'maybe_display_helper_notice' ) );
120
121 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
122 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
123 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
124 add_action( 'wp_footer', array( $this, 'assets_footer' ), 2 );
125
126 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
127
128 add_action( 'wp_ajax_ewd_us_hide_helper_notice', array( $this, 'hide_helper_notice' ) );
129 }
130
131 /**
132 * Run the options conversion function on update if necessary
133 *
134 * @since 2.0.0
135 * @access protected
136 * @return void
137 */
138 public function convert_options() {
139
140 require_once( EWD_US_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
141 new ewdusBackwardsCompatibility();
142 }
143
144 /**
145 * Load files needed for views
146 * @since 2.0.0
147 * @note Can be filtered to add new classes as needed
148 */
149 public function load_view_files() {
150
151 $files = array(
152 EWD_US_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
153 );
154
155 $files = apply_filters( 'ewd_us_load_view_files', $files );
156
157 foreach( $files as $file ) {
158 require_once( $file );
159 }
160
161 }
162
163 /**
164 * Load the plugin textdomain for localisation
165 * @since 2.0.0
166 */
167 public function load_textdomain() {
168
169 load_plugin_textdomain( 'ultimate-slider', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
170 }
171
172 /**
173 * Set a transient so that the walk-through gets run
174 * @since 2.0.0
175 */
176 public function run_walkthrough() {
177
178 set_transient( 'ewd-us-getting-started', true, 30 );
179 }
180
181 /**
182 * Enqueue the admin-only CSS and Javascript
183 * @since 2.0.0
184 */
185 public function enqueue_admin_assets( $hook ) {
186 global $post;
187
188 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 );
189 wp_localize_script(
190 'ewd-us-helper-notice',
191 'ewd_us_helper_notice',
192 array( 'nonce' => wp_create_nonce( 'ewd-us-helper-notice' ) )
193 );
194
195 wp_enqueue_style( 'ewd-us-helper-notice', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-helper-install-notice.css', array(), EWD_US_VERSION );
196
197 $screen = get_current_screen();
198
199 $candidates = array(
200 EWD_US_SLIDER_POST_TYPE,
201
202 'ultimate_slider_page_ewd-us-settings',
203
204 'widgets.php',
205 );
206
207 // 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
208 if ( ! in_array( $hook, $candidates )
209 and ( empty( $screen->post_type ) or ! in_array ( $screen->post_type, $candidates ) )
210 and ! in_array( $screen->id, $candidates )
211 ) {
212 return;
213 }
214
215 wp_enqueue_script( 'jquery-ui-core' );
216 wp_enqueue_script( 'jquery-ui-sortable' );
217 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 );
218
219 wp_enqueue_style( 'ewd-us-admin-css', EWD_US_PLUGIN_URL . '/assets/css/ewd-us-admin.css', EWD_US_VERSION );
220
221 $settings = array(
222 'nonce' => wp_create_nonce( 'ewd-us-admin-js' ),
223 );
224
225 wp_localize_script( 'ewd-us-admin-js', 'ewd_us_admin_php_data', $settings );
226 }
227
228 /**
229 * Register the front-end CSS and Javascript for the slider
230 * @since 2.0.0
231 */
232 function register_assets() {
233 global $ewd_us_controller;
234
235 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 );
236 wp_register_script( 'iframe-clicks', EWD_US_PLUGIN_URL . '/assets/js/jquery.iframetracker.js' , array( 'jquery' ), EWD_US_VERSION, true );
237
238 wp_register_style( 'ewd-us-css', EWD_US_PLUGIN_URL . '/assets/css/ewd-us.css', EWD_US_VERSION );
239
240 if ( $ewd_us_controller->settings->get_setting( 'lightbox' ) ) {
241
242 wp_register_script( 'ultimate-lightbox', EWD_US_PLUGIN_URL . '/assets/js/ultimate-lightbox.js', array( 'jquery' ), EWD_US_VERSION, true );
243
244 wp_register_style( 'ewd-ulb-main', EWD_US_PLUGIN_URL . '/assets/css/ewd-ulb-main.css', EWD_US_VERSION );
245 }
246 }
247
248 /**
249 * Print out any PHP data needed for our JS to work correctly
250 * @since 2.1.0
251 */
252 public function assets_footer() {
253
254 if ( empty( $this->front_end_php_js_data ) ) { return; }
255
256 $print_variables = array();
257
258 foreach ( (array) $this->front_end_php_js_data as $variable => $values ) {
259
260 if ( empty( $values ) ) { continue; }
261
262 $print_variables[ $variable ] = ewdusHelper::escape_js_recursive( $values );
263 }
264
265 foreach ( $print_variables as $variable => $values ) {
266
267 echo "<script type='text/javascript'>\n";
268 echo "/* <![CDATA[ */\n";
269 echo 'var ' . esc_attr( $variable ) . ' = ' . wp_json_encode( $values ) . "\n";
270 echo "/* ]]> */\n";
271 echo "</script>\n";
272 }
273 }
274
275 /**
276 * Adds a variable to be passed to our front-end JS
277 * @since 2.1.0
278 */
279 public function add_front_end_php_data( $handle, $variable, $data ) {
280
281 $this->front_end_php_js_data[ $variable ] = $data;
282 }
283
284 /**
285 * Returns the corresponding front-end JS variable if it exists, otherwise an empty array
286 * @since 2.1.0
287 */
288 public function get_front_end_php_data( $handle, $variable ) {
289
290 return ! empty( $this->front_end_php_js_data[ $variable ] ) ? $this->front_end_php_js_data[ $variable ] : array();
291 }
292
293 /**
294 * Add links to the plugin listing on the installed plugins page
295 * @since 2.0.0
296 */
297 public function plugin_action_links( $links, $plugin ) {
298
299 if ( $plugin == EWD_US_PLUGIN_FNAME ) {
300
301 $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>';
302 }
303
304 return $links;
305
306 }
307
308 /**
309 * Adds in a menu bar for the plugin
310 * @since 2.0.0
311 */
312 public function display_header_area() {
313 global $ewd_us_controller;
314
315 $screen = get_current_screen();
316
317 if ( empty( $screen->parent_file ) or $screen->parent_file != 'edit.php?post_type=ultimate_slider' ) { return; }
318
319 if ( ! $ewd_us_controller->permissions->check_permission( 'styling' ) or get_option( 'EWD_US_Trial_Happening' ) == 'Yes' ) {
320 ?>
321 <div class="ewd-us-dashboard-new-upgrade-banner">
322 <div class="ewd-us-dashboard-banner-icon"></div>
323 <div class="ewd-us-dashboard-banner-buttons">
324 <a class="ewd-us-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=US&Quantity=1" target="_blank">UPGRADE NOW</a>
325 </div>
326 <div class="ewd-us-dashboard-banner-text">
327 <div class="ewd-us-dashboard-banner-title">
328 GET FULL ACCESS WITH OUR PREMIUM VERSION
329 </div>
330 <div class="ewd-us-dashboard-banner-brief">
331 Slide and title animations/effects, modify the controls, WooCommerce integration, advanced styling options and more!
332 </div>
333 </div>
334 </div>
335 <?php
336 }
337
338 ?>
339 <div class="ewd-us-admin-header-menu">
340 <h2 class="nav-tab-wrapper">
341 <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>
342 <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>
343 <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>
344 <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>
345 </h2>
346 </div>
347 <?php
348 }
349
350 public function maybe_display_helper_notice() {
351 global $ewd_us_controller;
352
353 if ( empty( $ewd_us_controller->permissions->check_permission( 'premium' ) ) ) { return; }
354
355 if ( is_plugin_active( 'ewd-premium-helper/ewd-premium-helper.php' ) ) { return; }
356
357 if ( get_transient( 'ewd-helper-notice-dismissed' ) ) { return; }
358
359 ?>
360
361 <div class='notice notice-error is-dismissible ewd-us-helper-install-notice'>
362
363 <div class='ewd-us-helper-install-notice-img'>
364 <img src='<?php echo EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/img/options-asset-exclamation.png' ; ?>' />
365 </div>
366
367 <div class='ewd-us-helper-install-notice-txt'>
368 <?php _e( 'You\'re using the Ultimate Slider premium version, but the premium helper plugin is not active.', 'ultimate-slider' ); ?>
369 <br />
370 <?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/' ); ?>
371 </div>
372
373 <div class='ewd-us-clear'></div>
374
375 </div>
376
377 <?php
378 }
379
380 public function hide_helper_notice() {
381
382 // Authenticate request
383 if ( ! check_ajax_referer( 'ewd-us-helper-notice', 'nonce' ) or ! current_user_can( 'manage_options' ) ) {
384
385 wp_send_json_error(
386 array(
387 'error' => 'loggedout',
388 '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>' ),
389 )
390 );
391 }
392
393 set_transient( 'ewd-helper-notice-dismissed', true, 3600*24*7 );
394
395 die();
396 }
397
398 }
399 } // endif;
400
401 global $ewd_us_controller;
402 $ewd_us_controller = new ewdusInit();
403
404 do_action( 'ewd_us_initialized' );