AboutUs.class.php
3 years ago
BackwardsCompatibility.class.php
4 years ago
Blocks.class.php
4 years ago
CustomPostTypes.class.php
2 years ago
Dashboard.class.php
3 years ago
DeactivationSurvey.class.php
1 month ago
Helper.class.php
4 years ago
InstallationWalkthrough.class.php
4 years ago
Permissions.class.php
4 years ago
ReviewAsk.class.php
4 years ago
Settings.class.php
2 years ago
Widgets.class.php
4 years ago
WooCommerceIntegration.class.php
4 years ago
template-functions.php
2 years ago
Settings.class.php
496 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | if ( ! class_exists( 'ewdusSettings' ) ) { |
| 5 | /** |
| 6 | * Class to handle configurable settings for Ultimate Slider |
| 7 | * @since 1.0.0 |
| 8 | */ |
| 9 | class ewdusSettings { |
| 10 | |
| 11 | /** |
| 12 | * Default values for settings |
| 13 | * @since 1.0.0 |
| 14 | */ |
| 15 | public $defaults = array(); |
| 16 | |
| 17 | /** |
| 18 | * Stored values for settings |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | public $settings = array(); |
| 22 | |
| 23 | public function __construct() { |
| 24 | |
| 25 | add_action( 'init', array( $this, 'set_defaults' ) ); |
| 26 | |
| 27 | add_action( 'init', array( $this, 'load_settings_panel' ) ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Load the plugin's default settings |
| 32 | * @since 1.0.0 |
| 33 | */ |
| 34 | public function set_defaults() { |
| 35 | |
| 36 | $this->defaults = array( |
| 37 | |
| 38 | 'timer-bar' => 'bottom', |
| 39 | 'autoplay-delay' => 6, |
| 40 | 'autoplay-interval' => 6, |
| 41 | 'transition-time' => 1, |
| 42 | 'aspect-ratio' => '16_7', |
| 43 | 'mobile-aspect-ratio' => '16_7', |
| 44 | 'arrow' => 'a', |
| 45 | 'hide-from-slider' => array(), |
| 46 | 'hide-on-mobile' => array(), |
| 47 | ); |
| 48 | |
| 49 | $this->defaults = apply_filters( 'ewd_us_defaults', $this->defaults, $this ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get a setting's value or fallback to a default if one exists |
| 54 | * @since 1.0.0 |
| 55 | */ |
| 56 | public function get_setting( $setting ) { |
| 57 | |
| 58 | if ( empty( $this->settings ) ) { |
| 59 | $this->settings = get_option( 'ewd-us-settings' ); |
| 60 | } |
| 61 | |
| 62 | if ( ! empty( $this->settings[ $setting ] ) or isset( $this->settings[ $setting ] ) ) { |
| 63 | return apply_filters( 'ewd-us-settings-' . $setting, $this->settings[ $setting ] ); |
| 64 | } |
| 65 | |
| 66 | if ( ! empty( $this->defaults[ $setting ] ) or isset( $this->defaults[ $setting ] ) ) { |
| 67 | return apply_filters( 'ewd-us-settings-' . $setting, $this->defaults[ $setting ] ); |
| 68 | } |
| 69 | |
| 70 | return apply_filters( 'ewd-us-settings-' . $setting, null ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Set a setting to a particular value |
| 75 | * @since 1.0.0 |
| 76 | */ |
| 77 | public function set_setting( $setting, $value ) { |
| 78 | |
| 79 | $this->settings[ $setting ] = $value; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Save all settings, to be used with set_setting |
| 84 | * @since 1.0.0 |
| 85 | */ |
| 86 | public function save_settings() { |
| 87 | |
| 88 | update_option( 'ewd-us-settings', $this->settings ); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Load the admin settings page |
| 93 | * @since 1.0.0 |
| 94 | * @sa https://github.com/NateWr/simple-admin-pages |
| 95 | */ |
| 96 | public function load_settings_panel() { |
| 97 | global $ewd_us_controller; |
| 98 | |
| 99 | require_once( EWD_US_PLUGIN_DIR . '/lib/simple-admin-pages/simple-admin-pages.php' ); |
| 100 | $sap = sap_initialize_library( |
| 101 | $args = array( |
| 102 | 'version' => '2.6.19', |
| 103 | 'lib_url' => EWD_US_PLUGIN_URL . '/lib/simple-admin-pages/', |
| 104 | 'theme' => 'purple', |
| 105 | ) |
| 106 | ); |
| 107 | |
| 108 | $sap->add_page( |
| 109 | 'submenu', |
| 110 | array( |
| 111 | 'id' => 'ewd-us-settings', |
| 112 | 'title' => __( 'Settings', 'ultimate-slider' ), |
| 113 | 'menu_title' => __( 'Settings', 'ultimate-slider' ), |
| 114 | 'parent_menu' => 'edit.php?post_type=ultimate_slider', |
| 115 | 'description' => '', |
| 116 | 'capability' => 'manage_options', |
| 117 | 'default_tab' => 'ewd-us-basic-tab', |
| 118 | ) |
| 119 | ); |
| 120 | |
| 121 | $sap->add_section( |
| 122 | 'ewd-us-settings', |
| 123 | array( |
| 124 | 'id' => 'ewd-us-basic-tab', |
| 125 | 'title' => __( 'Basic', 'ultimate-slider' ), |
| 126 | 'is_tab' => true, |
| 127 | ) |
| 128 | ); |
| 129 | |
| 130 | $sap->add_section( |
| 131 | 'ewd-us-settings', |
| 132 | array( |
| 133 | 'id' => 'ewd-us-basic-options', |
| 134 | 'title' => __( 'Basic Options', 'ultimate-slider' ), |
| 135 | 'tab' => 'ewd-us-basic-tab', |
| 136 | ) |
| 137 | ); |
| 138 | |
| 139 | $sap->add_setting( |
| 140 | 'ewd-us-settings', |
| 141 | 'ewd-us-basic-options', |
| 142 | 'warningtip', |
| 143 | array( |
| 144 | 'id' => 'shortcodes-reminder', |
| 145 | 'title' => __( 'REMINDER:', 'ultimate-slider' ), |
| 146 | 'placeholder' => __( 'To display the slider, place the [ultimate-slider] shortcode on a page' ) |
| 147 | ) |
| 148 | ); |
| 149 | |
| 150 | $sap->add_setting( |
| 151 | 'ewd-us-settings', |
| 152 | 'ewd-us-basic-options', |
| 153 | 'textarea', |
| 154 | array( |
| 155 | 'id' => 'custom-css', |
| 156 | 'title' => __( 'Custom CSS', 'ultimate-slider' ), |
| 157 | 'description' => __( 'You can add custom CSS styles to your slider in the box above.', 'ultimate-slider' ), ) |
| 158 | ); |
| 159 | |
| 160 | $sap->add_setting( |
| 161 | 'ewd-us-settings', |
| 162 | 'ewd-us-basic-options', |
| 163 | 'toggle', |
| 164 | array( |
| 165 | 'id' => 'autoplay-slideshow', |
| 166 | 'title' => __( 'Autoplay Slideshow', 'ultimate-slider' ), |
| 167 | 'description' => __( 'Should the slider automatically toggle through slides?', 'ultimate-slider' ) |
| 168 | ) |
| 169 | ); |
| 170 | |
| 171 | $sap->add_setting( |
| 172 | 'ewd-us-settings', |
| 173 | 'ewd-us-basic-options', |
| 174 | 'count', |
| 175 | array( |
| 176 | 'id' => 'autoplay-delay', |
| 177 | 'title' => __( 'Autoplay Delay', 'ultimate-slider' ), |
| 178 | 'description' => __( 'If autoplay is on, how many seconds should the timer wait before starting the slideshow?', 'ultimate-slider' ), |
| 179 | 'default' => $this->defaults['autoplay-delay'], |
| 180 | 'blank_option' => false, |
| 181 | 'min_value' => 1, |
| 182 | 'max_value' => 60, |
| 183 | 'increment' => 1, |
| 184 | 'conditional_on' => 'autoplay-slideshow', |
| 185 | 'conditional_on_value' => true |
| 186 | ) |
| 187 | ); |
| 188 | |
| 189 | $sap->add_setting( |
| 190 | 'ewd-us-settings', |
| 191 | 'ewd-us-basic-options', |
| 192 | 'count', |
| 193 | array( |
| 194 | 'id' => 'autoplay-interval', |
| 195 | 'title' => __( 'Autoplay Interval', 'ultimate-slider' ), |
| 196 | 'description' => __( 'If autoplay is on, how many seconds should the slideshow wait between each slide?', 'ultimate-slider' ), |
| 197 | 'default' => $this->defaults['autoplay-interval'], |
| 198 | 'blank_option' => false, |
| 199 | 'min_value' => 1, |
| 200 | 'max_value' => 60, |
| 201 | 'increment' => 1, |
| 202 | 'conditional_on' => 'autoplay-slideshow', |
| 203 | 'conditional_on_value' => true |
| 204 | ) |
| 205 | ); |
| 206 | |
| 207 | $sap->add_setting( |
| 208 | 'ewd-us-settings', |
| 209 | 'ewd-us-basic-options', |
| 210 | 'toggle', |
| 211 | array( |
| 212 | 'id' => 'autoplay-pause-hover', |
| 213 | 'title' => __( 'Pause Autoplay on Hover', 'ultimate-slider' ), |
| 214 | 'description' => __( 'Should the slider autoplay automatically pause when you hover over it?', 'ultimate-slider' ), |
| 215 | 'conditional_on' => 'autoplay-slideshow', |
| 216 | 'conditional_on_value' => true |
| 217 | ) |
| 218 | ); |
| 219 | |
| 220 | $sap->add_setting( |
| 221 | 'ewd-us-settings', |
| 222 | 'ewd-us-basic-options', |
| 223 | 'count', |
| 224 | array( |
| 225 | 'id' => 'transition-time', |
| 226 | 'title' => __( 'Slide Transition Time', 'ultimate-slider' ), |
| 227 | 'description' => __( 'How many seconds should each transition take to complete?', 'ultimate-slider' ), |
| 228 | 'default' => $this->defaults['transition-time'], |
| 229 | 'blank_option' => false, |
| 230 | 'min_value' => 1, |
| 231 | 'max_value' => 10, |
| 232 | 'increment' => 1 |
| 233 | ) |
| 234 | ); |
| 235 | |
| 236 | $sap->add_setting( |
| 237 | 'ewd-us-settings', |
| 238 | 'ewd-us-basic-options', |
| 239 | 'select', |
| 240 | array( |
| 241 | 'id' => 'aspect-ratio', |
| 242 | 'title' => __( 'Aspect Ratio', 'ultimate-slider' ), |
| 243 | 'description' => '', |
| 244 | 'blank_option' => false, |
| 245 | 'default' => $this->defaults['aspect-ratio'], |
| 246 | 'options' => array( |
| 247 | '3_1' => '3:1', |
| 248 | '16_7' => '16:7' . __( '(default)', 'ultimate-slider' ), |
| 249 | '2_1' => '2:1', |
| 250 | '16_9' => '16:9', |
| 251 | '3_2' => '3:2', |
| 252 | '4_3' => '4:3', |
| 253 | '1_1' => '1:1', |
| 254 | ) |
| 255 | ) |
| 256 | ); |
| 257 | |
| 258 | $sap->add_setting( |
| 259 | 'ewd-us-settings', |
| 260 | 'ewd-us-basic-options', |
| 261 | 'toggle', |
| 262 | array( |
| 263 | 'id' => 'carousel', |
| 264 | 'title' => __( 'Carousel', 'ultimate-slider' ), |
| 265 | 'description' => __( 'Display a carousel slider instead of the default. The "Slide Transition Effect" setting has to be set to "Default".', 'ultimate-slider' ) |
| 266 | ) |
| 267 | ); |
| 268 | |
| 269 | $sap->add_setting( |
| 270 | 'ewd-us-settings', |
| 271 | 'ewd-us-basic-options', |
| 272 | 'radio', |
| 273 | array( |
| 274 | 'id' => 'carousel-columns', |
| 275 | 'title' => __( 'Carousel Columns', 'ultimate-slider' ), |
| 276 | 'description' => __( 'Set the number of slides that should be displayed at once in carousel mode', 'ultimate-slider' ), |
| 277 | 'options' => array( |
| 278 | 2 => 2, |
| 279 | 3 => 3, |
| 280 | 4 => 4 |
| 281 | ), |
| 282 | 'conditional_on' => 'carousel', |
| 283 | 'conditional_on_value' => true |
| 284 | ) |
| 285 | ); |
| 286 | |
| 287 | $sap->add_setting( |
| 288 | 'ewd-us-settings', |
| 289 | 'ewd-us-basic-options', |
| 290 | 'radio', |
| 291 | array( |
| 292 | 'id' => 'timer-bar', |
| 293 | 'title' => __( 'Timer Bar', 'ultimate-slider' ), |
| 294 | 'description' => __( 'Display a timer bar at the top or bottom of your slider.', 'ultimate-slider' ), |
| 295 | 'options' => array( |
| 296 | 'top' => __( 'Top', 'ultimate-slider' ), |
| 297 | 'bottom' => __( 'Bottom', 'ultimate-slider' ), |
| 298 | 'off' => __( 'Off', 'ultimate-slider' ) |
| 299 | ) |
| 300 | ) |
| 301 | ); |
| 302 | |
| 303 | $sap->add_setting( |
| 304 | 'ewd-us-settings', |
| 305 | 'ewd-us-basic-options', |
| 306 | 'radio', |
| 307 | array( |
| 308 | 'id' => 'slide-indicators', |
| 309 | 'title' => __( 'Slide Indicators', 'ultimate-slider' ), |
| 310 | 'description' => __( 'Display navigation controls to jump between slides.', 'ultimate-slider' ), |
| 311 | 'options' => array( |
| 312 | 'none' => __( 'None', 'ultimate-slider' ), |
| 313 | 'dots' => __( 'Dots', 'ultimate-slider' ), |
| 314 | 'thumbnails' => __( 'Thumbnails', 'ultimate-slider' ), |
| 315 | 'sidethumbnails' => __( 'Side Thumbnails', 'ultimate-slider' ) |
| 316 | ) |
| 317 | ) |
| 318 | ); |
| 319 | |
| 320 | $sap->add_setting( |
| 321 | 'ewd-us-settings', |
| 322 | 'ewd-us-basic-options', |
| 323 | 'radio', |
| 324 | array( |
| 325 | 'id' => 'link-action', |
| 326 | 'title' => __( 'Button Link Action', 'ultimate-slider' ), |
| 327 | 'description' => __( 'Should button links open in the same or new windows? "Smart" opens external links in new windows and links on your site in the same window.', 'ultimate-slider' ), |
| 328 | 'options' => array( |
| 329 | 'same' => __( 'Same Window', 'ultimate-slider' ), |
| 330 | 'new' => __( 'New Window', 'ultimate-slider' ), |
| 331 | 'smart' => __( 'Smart', 'ultimate-slider' ) |
| 332 | ) |
| 333 | ) |
| 334 | ); |
| 335 | |
| 336 | /** |
| 337 | * Premium options preview only |
| 338 | */ |
| 339 | // "Premium" Tab |
| 340 | $sap->add_section( |
| 341 | 'ewd-us-settings', |
| 342 | array( |
| 343 | 'id' => 'ewd-us-premium-tab', |
| 344 | 'title' => __( 'Premium', 'ultimate-slider' ), |
| 345 | 'is_tab' => true, |
| 346 | 'show_submit_button' => $this->show_submit_button( 'premium' ) |
| 347 | ) |
| 348 | ); |
| 349 | $sap->add_section( |
| 350 | 'ewd-us-settings', |
| 351 | array( |
| 352 | 'id' => 'ewd-us-premium-tab-body', |
| 353 | 'tab' => 'ewd-us-premium-tab', |
| 354 | 'callback' => $this->premium_info( 'premium' ) |
| 355 | ) |
| 356 | ); |
| 357 | |
| 358 | // "Styling" Tab |
| 359 | $sap->add_section( |
| 360 | 'ewd-us-settings', |
| 361 | array( |
| 362 | 'id' => 'ewd-us-styling-tab', |
| 363 | 'title' => __( 'Styling', 'ultimate-slider' ), |
| 364 | 'is_tab' => true, |
| 365 | 'show_submit_button' => $this->show_submit_button( 'styling' ) |
| 366 | ) |
| 367 | ); |
| 368 | $sap->add_section( |
| 369 | 'ewd-us-settings', |
| 370 | array( |
| 371 | 'id' => 'ewd-us-styling-tab-body', |
| 372 | 'tab' => 'ewd-us-styling-tab', |
| 373 | 'callback' => $this->premium_info( 'styling' ) |
| 374 | ) |
| 375 | ); |
| 376 | |
| 377 | // "Controls" Tab |
| 378 | $sap->add_section( |
| 379 | 'ewd-us-settings', |
| 380 | array( |
| 381 | 'id' => 'ewd-us-controls-tab', |
| 382 | 'title' => __( 'Controls', 'ultimate-slider' ), |
| 383 | 'is_tab' => true, |
| 384 | 'show_submit_button' => $this->show_submit_button( 'controls' ) |
| 385 | ) |
| 386 | ); |
| 387 | $sap->add_section( |
| 388 | 'ewd-us-settings', |
| 389 | array( |
| 390 | 'id' => 'ewd-us-controls-tab-body', |
| 391 | 'tab' => 'ewd-us-controls-tab', |
| 392 | 'callback' => $this->premium_info( 'controls' ) |
| 393 | ) |
| 394 | ); |
| 395 | |
| 396 | $sap = apply_filters( 'ewd_us_settings_page', $sap, $this ); |
| 397 | |
| 398 | $sap->add_admin_menus(); |
| 399 | |
| 400 | } |
| 401 | |
| 402 | public function show_submit_button( $permission_type = '' ) { |
| 403 | global $ewd_us_controller; |
| 404 | |
| 405 | if ( $ewd_us_controller->permissions->check_permission( $permission_type ) ) { |
| 406 | return true; |
| 407 | } |
| 408 | |
| 409 | return false; |
| 410 | } |
| 411 | |
| 412 | public function premium_info( $section_and_perm_type ) { |
| 413 | global $ewd_us_controller; |
| 414 | |
| 415 | $is_premium_user = $ewd_us_controller->permissions->check_permission( $section_and_perm_type ); |
| 416 | $is_helper_installed = defined( 'EWDPH_PLUGIN_FNAME' ) && is_plugin_active( EWDPH_PLUGIN_FNAME ); |
| 417 | |
| 418 | if ( $is_premium_user || $is_helper_installed ) { |
| 419 | return false; |
| 420 | } |
| 421 | |
| 422 | $content = ''; |
| 423 | |
| 424 | $premium_features = ' |
| 425 | <p><strong>' . __( 'The premium version also gives you access to the following features:', 'ultimate-slider' ) . '</strong></p> |
| 426 | <ul class="ewd-us-dashboard-new-footer-one-benefits"> |
| 427 | <li>' . __( 'Integrated Lightbox Effect', 'ultimate-slider' ) . '</li> |
| 428 | <li>' . __( 'Advanced Styling Options', 'ultimate-slider' ) . '</li> |
| 429 | <li>' . __( 'Advanced Control Options', 'ultimate-slider' ) . '</li> |
| 430 | <li>' . __( 'WooCommerce integration', 'ultimate-slider' ) . '</li> |
| 431 | <li>' . __( 'Add Watermarks', 'ultimate-slider' ) . '</li> |
| 432 | <li>' . __( 'Email Support', 'ultimate-slider' ) . '</li> |
| 433 | </ul> |
| 434 | <div class="ewd-us-dashboard-new-footer-one-buttons"> |
| 435 | <a class="ewd-us-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=US&Quantity=1&utm_source=us_settings&utm_content=' . $section_and_perm_type . '" target="_blank">' . __( 'UPGRADE NOW', 'ultimate-slider' ) . '</a> |
| 436 | </div> |
| 437 | '; |
| 438 | |
| 439 | switch ( $section_and_perm_type ) { |
| 440 | |
| 441 | case 'premium': |
| 442 | |
| 443 | $content = ' |
| 444 | <div class="ewd-us-settings-preview"> |
| 445 | <h2>' . __( 'Premium', 'ultimate-slider' ) . '<span>' . __( 'Premium', 'ultimate-slider' ) . '</span></h2> |
| 446 | <p>' . __( 'The premium options let you change the slide transition and title effects, set the aspect ratio, hide specific slider elements (overall or just on mobile), enable a lightbox and video autoplay, and more.', 'ultimate-slider' ) . '</p> |
| 447 | <div class="ewd-us-settings-preview-images"> |
| 448 | <img src="' . EWD_US_PLUGIN_URL . '/assets/img/premium-screenshots/premium1.png" alt="US premium screenshot one"> |
| 449 | <img src="' . EWD_US_PLUGIN_URL . '/assets/img/premium-screenshots/premium2.png" alt="US premium screenshot two"> |
| 450 | </div> |
| 451 | ' . $premium_features . ' |
| 452 | </div> |
| 453 | '; |
| 454 | |
| 455 | break; |
| 456 | |
| 457 | case 'styling': |
| 458 | |
| 459 | $content = ' |
| 460 | <div class="ewd-us-settings-preview"> |
| 461 | <h2>' . __( 'Styling', 'ultimate-slider' ) . '<span>' . __( 'Premium', 'ultimate-slider' ) . '</span></h2> |
| 462 | <p>' . __( 'The styling options let you modify the color, font size and font family of the various elements found in the slider.', 'ultimate-slider' ) . '</p> |
| 463 | <div class="ewd-us-settings-preview-images"> |
| 464 | <img src="' . EWD_US_PLUGIN_URL . '/assets/img/premium-screenshots/styling.png" alt="US styling screenshot"> |
| 465 | </div> |
| 466 | ' . $premium_features . ' |
| 467 | </div> |
| 468 | '; |
| 469 | |
| 470 | break; |
| 471 | |
| 472 | case 'controls': |
| 473 | |
| 474 | $content = ' |
| 475 | <div class="ewd-us-settings-preview"> |
| 476 | <h2>' . __( 'Controls', 'ultimate-slider' ) . '<span>' . __( 'Premium', 'ultimate-slider' ) . '</span></h2> |
| 477 | <p>' . __( 'The control options let you choose and customize the icon set you want to use for the slider controls. ', 'ultimate-slider' ) . '</p> |
| 478 | <div class="ewd-us-settings-preview-images"> |
| 479 | <img src="' . EWD_US_PLUGIN_URL . '/assets/img/premium-screenshots/controls.png" alt="US controls screenshot"> |
| 480 | </div> |
| 481 | ' . $premium_features . ' |
| 482 | </div> |
| 483 | '; |
| 484 | |
| 485 | break; |
| 486 | } |
| 487 | |
| 488 | return function() use ( $content ) { |
| 489 | |
| 490 | echo wp_kses_post( $content ); |
| 491 | }; |
| 492 | } |
| 493 | |
| 494 | } |
| 495 | } // endif; |
| 496 |