| Total Complexity | 162 |
| Total Lines | 2883 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like AyeCode_UI_Settings often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AyeCode_UI_Settings, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 31 | class AyeCode_UI_Settings { |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Class version version. |
||
| 35 | * |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | public $version = '0.1.63'; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Class textdomain. |
||
| 42 | * |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public $textdomain = 'aui'; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Latest version of Bootstrap at time of publish published. |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | public $latest = "4.5.3"; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Current version of select2 being used. |
||
| 56 | * |
||
| 57 | * @var string |
||
| 58 | */ |
||
| 59 | public $select2_version = "4.0.11"; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * The title. |
||
| 63 | * |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | public $name = 'AyeCode UI'; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * The relative url to the assets. |
||
| 70 | * |
||
| 71 | * @var string |
||
| 72 | */ |
||
| 73 | public $url = ''; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Holds the settings values. |
||
| 77 | * |
||
| 78 | * @var array |
||
| 79 | */ |
||
| 80 | private $settings; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * AyeCode_UI_Settings instance. |
||
| 84 | * |
||
| 85 | * @access private |
||
| 86 | * @since 1.0.0 |
||
| 87 | * @var AyeCode_UI_Settings There can be only one! |
||
| 88 | */ |
||
| 89 | private static $instance = null; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Main AyeCode_UI_Settings Instance. |
||
| 93 | * |
||
| 94 | * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
||
| 95 | * |
||
| 96 | * @since 1.0.0 |
||
| 97 | * @static |
||
| 98 | * @return AyeCode_UI_Settings - Main instance. |
||
| 99 | */ |
||
| 100 | public static function instance() { |
||
| 101 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
||
| 102 | |||
| 103 | self::$instance = new AyeCode_UI_Settings; |
||
| 104 | |||
| 105 | add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
||
| 106 | |||
| 107 | if ( is_admin() ) { |
||
| 108 | add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
||
| 109 | add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
||
| 110 | |||
| 111 | // Maybe show example page |
||
| 112 | add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
||
| 113 | } |
||
| 114 | |||
| 115 | add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
||
| 116 | |||
| 117 | do_action( 'ayecode_ui_settings_loaded' ); |
||
| 118 | } |
||
| 119 | |||
| 120 | return self::$instance; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Setup some constants. |
||
| 125 | */ |
||
| 126 | public function constants(){ |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * Initiate the settings and add the required action hooks. |
||
| 135 | */ |
||
| 136 | public function init() { |
||
| 137 | |||
| 138 | // Maybe fix settings |
||
| 139 | if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
||
| 140 | $db_settings = get_option( 'ayecode-ui-settings' ); |
||
| 141 | if ( ! empty( $db_settings ) ) { |
||
| 142 | $db_settings['css_backend'] = 'compatibility'; |
||
| 143 | $db_settings['js_backend'] = 'core-popper'; |
||
| 144 | update_option( 'ayecode-ui-settings', $db_settings ); |
||
| 145 | wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | $this->constants(); |
||
| 150 | $this->settings = $this->get_settings(); |
||
| 151 | $this->url = $this->get_url(); |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Maybe load CSS |
||
| 155 | * |
||
| 156 | * We load super early in case there is a theme version that might change the colors |
||
| 157 | */ |
||
| 158 | if ( $this->settings['css'] ) { |
||
| 159 | $priority = $this->is_bs3_compat() ? 100 : 1; |
||
| 160 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
||
| 161 | } |
||
| 162 | if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
||
| 163 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
||
| 164 | } |
||
| 165 | |||
| 166 | // maybe load JS |
||
| 167 | if ( $this->settings['js'] ) { |
||
| 168 | $priority = $this->is_bs3_compat() ? 100 : 1; |
||
| 169 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
||
| 170 | } |
||
| 171 | if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
||
| 172 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
||
| 173 | } |
||
| 174 | |||
| 175 | // Maybe set the HTML font size |
||
| 176 | if ( $this->settings['html_font_size'] ) { |
||
| 177 | add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
||
| 178 | } |
||
| 179 | |||
| 180 | // Maybe show backend style error |
||
| 181 | if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
||
| 182 | add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
||
| 183 | } |
||
| 184 | |||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Show admin notice if backend scripts not loaded. |
||
| 189 | */ |
||
| 190 | public function show_admin_style_notice(){ |
||
| 191 | $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
||
| 192 | $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
||
| 193 | $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
||
| 194 | echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Check if we should load the admin scripts or not. |
||
| 199 | * |
||
| 200 | * @return bool |
||
| 201 | */ |
||
| 202 | public function load_admin_scripts(){ |
||
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * Add a html font size to the footer. |
||
| 220 | */ |
||
| 221 | public function html_font_size(){ |
||
| 222 | $this->settings = $this->get_settings(); |
||
| 223 | echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Check if the current admin screen should load scripts. |
||
| 228 | * |
||
| 229 | * @return bool |
||
| 230 | */ |
||
| 231 | public function is_aui_screen(){ |
||
| 232 | // echo '###';exit; |
||
| 233 | $load = false; |
||
| 234 | // check if we should load or not |
||
| 235 | if ( is_admin() ) { |
||
| 236 | // Only enable on set pages |
||
| 237 | $aui_screens = array( |
||
| 238 | 'page', |
||
| 239 | 'post', |
||
| 240 | 'settings_page_ayecode-ui-settings', |
||
| 241 | 'appearance_page_gutenberg-widgets', |
||
| 242 | 'widgets', |
||
| 243 | 'ayecode-ui-settings', |
||
| 244 | ); |
||
| 245 | $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
||
| 246 | |||
| 247 | $screen = get_current_screen(); |
||
|
|
|||
| 248 | |||
| 249 | // echo '###'.$screen->id; |
||
| 250 | |||
| 251 | // check if we are on a AUI screen |
||
| 252 | if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
||
| 253 | $load = true; |
||
| 254 | } |
||
| 255 | |||
| 256 | //load for widget previews in WP 5.8 |
||
| 257 | if( !empty($_REQUEST['legacy-widget-preview'])){ |
||
| 258 | $load = true; |
||
| 259 | } |
||
| 260 | } |
||
| 261 | |||
| 262 | return apply_filters( 'aui_load_on_admin' , $load ); |
||
| 263 | } |
||
| 264 | |||
| 265 | /** |
||
| 266 | * Adds the styles. |
||
| 267 | */ |
||
| 268 | public function enqueue_style() { |
||
| 269 | |||
| 270 | |||
| 271 | if( is_admin() && !$this->is_aui_screen()){ |
||
| 272 | // don't add wp-admin scripts if not requested to |
||
| 273 | }else{ |
||
| 274 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
||
| 275 | |||
| 276 | $rtl = is_rtl() ? '-rtl' : ''; |
||
| 277 | |||
| 278 | if($this->settings[$css_setting]){ |
||
| 279 | $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
||
| 280 | $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
||
| 281 | wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
||
| 282 | wp_enqueue_style( 'ayecode-ui' ); |
||
| 283 | |||
| 284 | // flatpickr |
||
| 285 | wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
||
| 286 | |||
| 287 | // fontawesome-iconpicker |
||
| 288 | //wp_register_style( 'fontawesome-iconpicker', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
||
| 289 | |||
| 290 | // fix some wp-admin issues |
||
| 291 | if(is_admin()){ |
||
| 292 | $custom_css = " |
||
| 293 | body{ |
||
| 294 | background-color: #f1f1f1; |
||
| 295 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
||
| 296 | font-size:13px; |
||
| 297 | } |
||
| 298 | a { |
||
| 299 | color: #0073aa; |
||
| 300 | text-decoration: underline; |
||
| 301 | } |
||
| 302 | label { |
||
| 303 | display: initial; |
||
| 304 | margin-bottom: 0; |
||
| 305 | } |
||
| 306 | input, select { |
||
| 307 | margin: 1px; |
||
| 308 | line-height: initial; |
||
| 309 | } |
||
| 310 | th, td, div, h2 { |
||
| 311 | box-sizing: content-box; |
||
| 312 | } |
||
| 313 | p { |
||
| 314 | font-size: 13px; |
||
| 315 | line-height: 1.5; |
||
| 316 | margin: 1em 0; |
||
| 317 | } |
||
| 318 | h1, h2, h3, h4, h5, h6 { |
||
| 319 | display: block; |
||
| 320 | font-weight: 600; |
||
| 321 | } |
||
| 322 | h2,h3 { |
||
| 323 | font-size: 1.3em; |
||
| 324 | margin: 1em 0 |
||
| 325 | } |
||
| 326 | .blocks-widgets-container .bsui *{ |
||
| 327 | box-sizing: border-box; |
||
| 328 | } |
||
| 329 | .bs-tooltip-top .arrow{ |
||
| 330 | margin-left:0px; |
||
| 331 | } |
||
| 332 | |||
| 333 | .custom-switch input[type=checkbox]{ |
||
| 334 | display:none; |
||
| 335 | } |
||
| 336 | "; |
||
| 337 | |||
| 338 | // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
||
| 339 | $custom_css .= " |
||
| 340 | .edit-post-sidebar input[type=color].components-text-control__input{ |
||
| 341 | padding: 0; |
||
| 342 | } |
||
| 343 | "; |
||
| 344 | wp_add_inline_style( 'ayecode-ui', $custom_css ); |
||
| 345 | } |
||
| 346 | |||
| 347 | // custom changes |
||
| 348 | wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
||
| 349 | |||
| 350 | } |
||
| 351 | } |
||
| 352 | |||
| 353 | |||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Get inline script used if bootstrap enqueued |
||
| 358 | * |
||
| 359 | * If this remains small then its best to use this than to add another JS file. |
||
| 360 | */ |
||
| 361 | public function inline_script() { |
||
| 362 | // Flatpickr calendar locale |
||
| 363 | $flatpickr_locale = self::flatpickr_locale(); |
||
| 364 | |||
| 365 | ob_start(); |
||
| 366 | ?> |
||
| 367 | <script> |
||
| 368 | /** |
||
| 369 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
||
| 370 | * |
||
| 371 | * Simply add the class `greedy` to any <nav> menu and it will do the rest. |
||
| 372 | * Licensed under the MIT license - http://opensource.org/licenses/MIT |
||
| 373 | * @ver 0.0.1 |
||
| 374 | */ |
||
| 375 | function aui_init_greedy_nav(){ |
||
| 376 | jQuery('nav.greedy').each(function(i, obj) { |
||
| 377 | |||
| 378 | // Check if already initialized, if so continue. |
||
| 379 | if(jQuery(this).hasClass("being-greedy")){return true;} |
||
| 380 | |||
| 381 | // Make sure its always expanded |
||
| 382 | jQuery(this).addClass('navbar-expand'); |
||
| 383 | |||
| 384 | // vars |
||
| 385 | var $vlinks = ''; |
||
| 386 | var $dDownClass = ''; |
||
| 387 | if(jQuery(this).find('.navbar-nav').length){ |
||
| 388 | if(jQuery(this).find('.navbar-nav').hasClass("being-greedy")){return true;} |
||
| 389 | $vlinks = jQuery(this).find('.navbar-nav').addClass("being-greedy w-100").removeClass('overflow-hidden'); |
||
| 390 | }else if(jQuery(this).find('.nav').length){ |
||
| 391 | if(jQuery(this).find('.nav').hasClass("being-greedy")){return true;} |
||
| 392 | $vlinks = jQuery(this).find('.nav').addClass("being-greedy w-100").removeClass('overflow-hidden'); |
||
| 393 | $dDownClass = ' mt-2 '; |
||
| 394 | }else{ |
||
| 395 | return false; |
||
| 396 | } |
||
| 397 | |||
| 398 | jQuery($vlinks).append('<li class="nav-item list-unstyled ml-auto greedy-btn d-none dropdown ">' + |
||
| 399 | '<a href="javascript:void(0)" data-toggle="dropdown" class="nav-link"><i class="fas fa-ellipsis-h"></i> <span class="greedy-count badge badge-dark badge-pill"></span></a>' + |
||
| 400 | '<ul class="greedy-links dropdown-menu dropdown-menu-right '+$dDownClass+'"></ul>' + |
||
| 401 | '</li>'); |
||
| 402 | |||
| 403 | var $hlinks = jQuery(this).find('.greedy-links'); |
||
| 404 | var $btn = jQuery(this).find('.greedy-btn'); |
||
| 405 | |||
| 406 | var numOfItems = 0; |
||
| 407 | var totalSpace = 0; |
||
| 408 | var closingTime = 1000; |
||
| 409 | var breakWidths = []; |
||
| 410 | |||
| 411 | // Get initial state |
||
| 412 | $vlinks.children().outerWidth(function(i, w) { |
||
| 413 | totalSpace += w; |
||
| 414 | numOfItems += 1; |
||
| 415 | breakWidths.push(totalSpace); |
||
| 416 | }); |
||
| 417 | |||
| 418 | var availableSpace, numOfVisibleItems, requiredSpace, buttonSpace ,timer; |
||
| 419 | |||
| 420 | /* |
||
| 421 | The check function. |
||
| 422 | */ |
||
| 423 | function check() { |
||
| 424 | |||
| 425 | // Get instant state |
||
| 426 | buttonSpace = $btn.width(); |
||
| 427 | availableSpace = $vlinks.width() - 10; |
||
| 428 | numOfVisibleItems = $vlinks.children().length; |
||
| 429 | requiredSpace = breakWidths[numOfVisibleItems - 1]; |
||
| 430 | |||
| 431 | // There is not enough space |
||
| 432 | if (numOfVisibleItems > 1 && requiredSpace > availableSpace) { |
||
| 433 | $vlinks.children().last().prev().prependTo($hlinks); |
||
| 434 | numOfVisibleItems -= 1; |
||
| 435 | check(); |
||
| 436 | // There is more than enough space |
||
| 437 | } else if (availableSpace > breakWidths[numOfVisibleItems]) { |
||
| 438 | $hlinks.children().first().insertBefore($btn); |
||
| 439 | numOfVisibleItems += 1; |
||
| 440 | check(); |
||
| 441 | } |
||
| 442 | // Update the button accordingly |
||
| 443 | jQuery($btn).find(".greedy-count").html( numOfItems - numOfVisibleItems); |
||
| 444 | if (numOfVisibleItems === numOfItems) { |
||
| 445 | $btn.addClass('d-none'); |
||
| 446 | } else $btn.removeClass('d-none'); |
||
| 447 | } |
||
| 448 | |||
| 449 | // Window listeners |
||
| 450 | jQuery(window).on("resize",function() { |
||
| 451 | check(); |
||
| 452 | }); |
||
| 453 | |||
| 454 | // do initial check |
||
| 455 | check(); |
||
| 456 | }); |
||
| 457 | } |
||
| 458 | |||
| 459 | function aui_select2_locale() { |
||
| 460 | var aui_select2_params = <?php echo self::select2_locale(); ?>; |
||
| 461 | |||
| 462 | return { |
||
| 463 | 'language': { |
||
| 464 | errorLoading: function() { |
||
| 465 | // Workaround for https://github.com/select2/select2/issues/4355 instead of i18n_ajax_error. |
||
| 466 | return aui_select2_params.i18n_searching; |
||
| 467 | }, |
||
| 468 | inputTooLong: function(args) { |
||
| 469 | var overChars = args.input.length - args.maximum; |
||
| 470 | if (1 === overChars) { |
||
| 471 | return aui_select2_params.i18n_input_too_long_1; |
||
| 472 | } |
||
| 473 | return aui_select2_params.i18n_input_too_long_n.replace('%item%', overChars); |
||
| 474 | }, |
||
| 475 | inputTooShort: function(args) { |
||
| 476 | var remainingChars = args.minimum - args.input.length; |
||
| 477 | if (1 === remainingChars) { |
||
| 478 | return aui_select2_params.i18n_input_too_short_1; |
||
| 479 | } |
||
| 480 | return aui_select2_params.i18n_input_too_short_n.replace('%item%', remainingChars); |
||
| 481 | }, |
||
| 482 | loadingMore: function() { |
||
| 483 | return aui_select2_params.i18n_load_more; |
||
| 484 | }, |
||
| 485 | maximumSelected: function(args) { |
||
| 486 | if (args.maximum === 1) { |
||
| 487 | return aui_select2_params.i18n_selection_too_long_1; |
||
| 488 | } |
||
| 489 | return aui_select2_params.i18n_selection_too_long_n.replace('%item%', args.maximum); |
||
| 490 | }, |
||
| 491 | noResults: function() { |
||
| 492 | return aui_select2_params.i18n_no_matches; |
||
| 493 | }, |
||
| 494 | searching: function() { |
||
| 495 | return aui_select2_params.i18n_searching; |
||
| 496 | } |
||
| 497 | } |
||
| 498 | }; |
||
| 499 | } |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Initiate Select2 items. |
||
| 503 | */ |
||
| 504 | function aui_init_select2(){ |
||
| 505 | var select2_args = jQuery.extend({}, aui_select2_locale()); |
||
| 506 | |||
| 507 | jQuery("select.aui-select2").select2(select2_args); |
||
| 508 | } |
||
| 509 | |||
| 510 | /** |
||
| 511 | * A function to convert a time value to a "ago" time text. |
||
| 512 | * |
||
| 513 | * @param selector string The .class selector |
||
| 514 | */ |
||
| 515 | function aui_time_ago(selector) { |
||
| 516 | var aui_timeago_params = <?php echo self::timeago_locale(); ?>; |
||
| 517 | |||
| 518 | var templates = { |
||
| 519 | prefix: aui_timeago_params.prefix_ago, |
||
| 520 | suffix: aui_timeago_params.suffix_ago, |
||
| 521 | seconds: aui_timeago_params.seconds, |
||
| 522 | minute: aui_timeago_params.minute, |
||
| 523 | minutes: aui_timeago_params.minutes, |
||
| 524 | hour: aui_timeago_params.hour, |
||
| 525 | hours: aui_timeago_params.hours, |
||
| 526 | day: aui_timeago_params.day, |
||
| 527 | days: aui_timeago_params.days, |
||
| 528 | month: aui_timeago_params.month, |
||
| 529 | months: aui_timeago_params.months, |
||
| 530 | year: aui_timeago_params.year, |
||
| 531 | years: aui_timeago_params.years |
||
| 532 | }; |
||
| 533 | var template = function (t, n) { |
||
| 534 | return templates[t] && templates[t].replace(/%d/i, Math.abs(Math.round(n))); |
||
| 535 | }; |
||
| 536 | |||
| 537 | var timer = function (time) { |
||
| 538 | if (!time) |
||
| 539 | return; |
||
| 540 | time = time.replace(/\.\d+/, ""); // remove milliseconds |
||
| 541 | time = time.replace(/-/, "/").replace(/-/, "/"); |
||
| 542 | time = time.replace(/T/, " ").replace(/Z/, " UTC"); |
||
| 543 | time = time.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"); // -04:00 -> -0400 |
||
| 544 | time = new Date(time * 1000 || time); |
||
| 545 | |||
| 546 | var now = new Date(); |
||
| 547 | var seconds = ((now.getTime() - time) * .001) >> 0; |
||
| 548 | var minutes = seconds / 60; |
||
| 549 | var hours = minutes / 60; |
||
| 550 | var days = hours / 24; |
||
| 551 | var years = days / 365; |
||
| 552 | |||
| 553 | return templates.prefix + ( |
||
| 554 | seconds < 45 && template('seconds', seconds) || |
||
| 555 | seconds < 90 && template('minute', 1) || |
||
| 556 | minutes < 45 && template('minutes', minutes) || |
||
| 557 | minutes < 90 && template('hour', 1) || |
||
| 558 | hours < 24 && template('hours', hours) || |
||
| 559 | hours < 42 && template('day', 1) || |
||
| 560 | days < 30 && template('days', days) || |
||
| 561 | days < 45 && template('month', 1) || |
||
| 562 | days < 365 && template('months', days / 30) || |
||
| 563 | years < 1.5 && template('year', 1) || |
||
| 564 | template('years', years) |
||
| 565 | ) + templates.suffix; |
||
| 566 | }; |
||
| 567 | |||
| 568 | var elements = document.getElementsByClassName(selector); |
||
| 569 | if (selector && elements && elements.length) { |
||
| 570 | for (var i in elements) { |
||
| 571 | var $el = elements[i]; |
||
| 572 | if (typeof $el === 'object') { |
||
| 573 | $el.innerHTML = '<i class="far fa-clock"></i> ' + timer($el.getAttribute('title') || $el.getAttribute('datetime')); |
||
| 574 | } |
||
| 575 | } |
||
| 576 | } |
||
| 577 | |||
| 578 | // update time every minute |
||
| 579 | setTimeout(function() { |
||
| 580 | aui_time_ago(selector); |
||
| 581 | }, 60000); |
||
| 582 | |||
| 583 | } |
||
| 584 | |||
| 585 | /** |
||
| 586 | * Initiate tooltips on the page. |
||
| 587 | */ |
||
| 588 | function aui_init_tooltips(){ |
||
| 589 | jQuery('[data-toggle="tooltip"]').tooltip(); |
||
| 590 | jQuery('[data-toggle="popover"]').popover(); |
||
| 591 | jQuery('[data-toggle="popover-html"]').popover({ |
||
| 592 | html: true |
||
| 593 | }); |
||
| 594 | |||
| 595 | // fix popover container compatibility |
||
| 596 | jQuery('[data-toggle="popover"],[data-toggle="popover-html"]').on('inserted.bs.popover', function () { |
||
| 597 | jQuery('body > .popover').wrapAll("<div class='bsui' />"); |
||
| 598 | }); |
||
| 599 | } |
||
| 600 | |||
| 601 | /** |
||
| 602 | * Initiate flatpickrs on the page. |
||
| 603 | */ |
||
| 604 | $aui_doing_init_flatpickr = false; |
||
| 605 | function aui_init_flatpickr(){ |
||
| 606 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
||
| 607 | $aui_doing_init_flatpickr = true; |
||
| 608 | <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
||
| 609 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
||
| 610 | } |
||
| 611 | $aui_doing_init_flatpickr = false; |
||
| 612 | } |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Initiate iconpicker on the page. |
||
| 616 | */ |
||
| 617 | $aui_doing_init_iconpicker = false; |
||
| 618 | function aui_init_iconpicker(){ |
||
| 619 | if ( typeof jQuery.fn.iconpicker === "function" && !$aui_doing_init_iconpicker) { |
||
| 620 | $aui_doing_init_iconpicker = true; |
||
| 621 | jQuery('input[data-aui-init="iconpicker"]:not(.iconpicker-input)').iconpicker(); |
||
| 622 | } |
||
| 623 | $aui_doing_init_iconpicker= false; |
||
| 624 | } |
||
| 625 | |||
| 626 | function aui_modal_iframe($title,$url,$footer,$dismissible,$class,$dialog_class,$body_class){ |
||
| 627 | if(!$body_class){$body_class = 'p-0';} |
||
| 628 | var $body = '<div class="ac-preview-loading text-center position-absolute w-100 text-dark vh-100 overlay overlay-white p-0 m-0 d-none d-flex justify-content-center align-items-center"><div class="spinner-border" role="status"></div></div>'; |
||
| 629 | $body += '<iframe id="embedModal-iframe" class="w-100 vh-100 p-0 m-0" src="" width="100%" height="100%" frameborder="0" allowtransparency="true"></iframe>'; |
||
| 630 | |||
| 631 | $m = aui_modal($title,$body,$footer,$dismissible,$class,$dialog_class,$body_class); |
||
| 632 | jQuery( $m ).on( 'shown.bs.modal', function ( e ) { |
||
| 633 | iFrame = jQuery( '#embedModal-iframe') ; |
||
| 634 | |||
| 635 | jQuery('.ac-preview-loading').addClass('d-flex'); |
||
| 636 | iFrame.attr({ |
||
| 637 | src: $url |
||
| 638 | }); |
||
| 639 | |||
| 640 | //resize the iframe once loaded. |
||
| 641 | iFrame.load(function() { |
||
| 642 | jQuery('.ac-preview-loading').removeClass('d-flex'); |
||
| 643 | }); |
||
| 644 | }); |
||
| 645 | |||
| 646 | return $m; |
||
| 647 | |||
| 648 | } |
||
| 649 | |||
| 650 | function aui_modal($title,$body,$footer,$dismissible,$class,$dialog_class,$body_class) { |
||
| 651 | if(!$class){$class = '';} |
||
| 652 | if(!$dialog_class){$dialog_class = '';} |
||
| 653 | if(!$body){$body = '<div class="text-center"><div class="spinner-border" role="status"></div></div>';} |
||
| 654 | // remove it first |
||
| 655 | jQuery('.aui-modal').modal('hide').modal('dispose').remove(); |
||
| 656 | jQuery('.modal-backdrop').remove(); |
||
| 657 | |||
| 658 | var $modal = ''; |
||
| 659 | |||
| 660 | $modal += '<div class="modal aui-modal fade shadow bsui '+$class+'" tabindex="-1">'+ |
||
| 661 | '<div class="modal-dialog modal-dialog-centered '+$dialog_class+'">'+ |
||
| 662 | '<div class="modal-content border-0 shadow">'; |
||
| 663 | |||
| 664 | if($title) { |
||
| 665 | $modal += '<div class="modal-header">' + |
||
| 666 | '<h5 class="modal-title">' + $title + '</h5>'; |
||
| 667 | |||
| 668 | if ($dismissible) { |
||
| 669 | $modal += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' + |
||
| 670 | '<span aria-hidden="true">×</span>' + |
||
| 671 | '</button>'; |
||
| 672 | } |
||
| 673 | |||
| 674 | $modal += '</div>'; |
||
| 675 | } |
||
| 676 | $modal += '<div class="modal-body '+$body_class+'">'+ |
||
| 677 | $body+ |
||
| 678 | '</div>'; |
||
| 679 | |||
| 680 | if($footer){ |
||
| 681 | $modal += '<div class="modal-footer">'+ |
||
| 682 | $footer + |
||
| 683 | '</div>'; |
||
| 684 | } |
||
| 685 | |||
| 686 | $modal +='</div>'+ |
||
| 687 | '</div>'+ |
||
| 688 | '</div>'; |
||
| 689 | |||
| 690 | jQuery('body').append($modal); |
||
| 691 | |||
| 692 | return jQuery('.aui-modal').modal('hide').modal({ |
||
| 693 | //backdrop: 'static' |
||
| 694 | }); |
||
| 695 | } |
||
| 696 | |||
| 697 | /** |
||
| 698 | * Show / hide fields depending on conditions. |
||
| 699 | */ |
||
| 700 | function aui_conditional_fields(form){ |
||
| 701 | jQuery(form).find(".aui-conditional-field").each(function () { |
||
| 702 | |||
| 703 | var $element_require = jQuery(this).data('element-require'); |
||
| 704 | |||
| 705 | if ($element_require) { |
||
| 706 | |||
| 707 | $element_require = $element_require.replace("'", "'"); // replace single quotes |
||
| 708 | $element_require = $element_require.replace(""", '"'); // replace double quotes |
||
| 709 | if (aui_check_form_condition($element_require,form)) { |
||
| 710 | jQuery(this).removeClass('d-none'); |
||
| 711 | } else { |
||
| 712 | jQuery(this).addClass('d-none'); |
||
| 713 | } |
||
| 714 | } |
||
| 715 | }); |
||
| 716 | } |
||
| 717 | |||
| 718 | /** |
||
| 719 | * Check form condition |
||
| 720 | */ |
||
| 721 | function aui_check_form_condition(condition,form) { |
||
| 722 | if (form) { |
||
| 723 | condition = condition.replace(/\(form\)/g, "('"+form+"')"); |
||
| 724 | } |
||
| 725 | return new Function("return " + condition+";")(); |
||
| 726 | } |
||
| 727 | |||
| 728 | /** |
||
| 729 | * A function to determine if a element is on screen. |
||
| 730 | */ |
||
| 731 | jQuery.fn.aui_isOnScreen = function(){ |
||
| 732 | |||
| 733 | var win = jQuery(window); |
||
| 734 | |||
| 735 | var viewport = { |
||
| 736 | top : win.scrollTop(), |
||
| 737 | left : win.scrollLeft() |
||
| 738 | }; |
||
| 739 | viewport.right = viewport.left + win.width(); |
||
| 740 | viewport.bottom = viewport.top + win.height(); |
||
| 741 | |||
| 742 | var bounds = this.offset(); |
||
| 743 | bounds.right = bounds.left + this.outerWidth(); |
||
| 744 | bounds.bottom = bounds.top + this.outerHeight(); |
||
| 745 | |||
| 746 | return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); |
||
| 747 | |||
| 748 | }; |
||
| 749 | |||
| 750 | /** |
||
| 751 | * Maybe show multiple carousel items if set to do so. |
||
| 752 | */ |
||
| 753 | function aui_carousel_maybe_show_multiple_items($carousel){ |
||
| 754 | var $items = {}; |
||
| 755 | var $item_count = 0; |
||
| 756 | |||
| 757 | // maybe backup |
||
| 758 | if(!jQuery($carousel).find('.carousel-inner-original').length){ |
||
| 759 | jQuery($carousel).append('<div class="carousel-inner-original d-none">'+jQuery($carousel).find('.carousel-inner').html()+'</div>'); |
||
| 760 | } |
||
| 761 | |||
| 762 | // Get the original items html |
||
| 763 | jQuery($carousel).find('.carousel-inner-original .carousel-item').each(function () { |
||
| 764 | $items[$item_count] = jQuery(this).html(); |
||
| 765 | $item_count++; |
||
| 766 | }); |
||
| 767 | |||
| 768 | // bail if no items |
||
| 769 | if(!$item_count){return;} |
||
| 770 | |||
| 771 | if(jQuery(window).width() <= 576){ |
||
| 772 | // maybe restore original |
||
| 773 | if(jQuery($carousel).find('.carousel-inner').hasClass('aui-multiple-items') && jQuery($carousel).find('.carousel-inner-original').length){ |
||
| 774 | jQuery($carousel).find('.carousel-inner').removeClass('aui-multiple-items').html(jQuery($carousel).find('.carousel-inner-original').html()); |
||
| 775 | jQuery($carousel).find(".carousel-indicators li").removeClass("d-none"); |
||
| 776 | } |
||
| 777 | |||
| 778 | }else{ |
||
| 779 | // new items |
||
| 780 | var $md_count = jQuery($carousel).data('limit_show'); |
||
| 781 | var $new_items = ''; |
||
| 782 | var $new_items_count = 0; |
||
| 783 | var $new_item_count = 0; |
||
| 784 | var $closed = true; |
||
| 785 | Object.keys($items).forEach(function(key,index) { |
||
| 786 | |||
| 787 | // close |
||
| 788 | if(index != 0 && Number.isInteger(index/$md_count) ){ |
||
| 789 | $new_items += '</div></div>'; |
||
| 790 | $closed = true; |
||
| 791 | } |
||
| 792 | |||
| 793 | // open |
||
| 794 | if(index == 0 || Number.isInteger(index/$md_count) ){ |
||
| 795 | $active = index == 0 ? 'active' : ''; |
||
| 796 | $new_items += '<div class="carousel-item '+$active+'"><div class="row m-0">'; |
||
| 797 | $closed = false; |
||
| 798 | $new_items_count++; |
||
| 799 | $new_item_count = 0; |
||
| 800 | } |
||
| 801 | |||
| 802 | // content |
||
| 803 | $new_items += '<div class="col pr-1 pl-0">'+$items[index]+'</div>'; |
||
| 804 | $new_item_count++; |
||
| 805 | |||
| 806 | |||
| 807 | }); |
||
| 808 | |||
| 809 | // close if not closed in the loop |
||
| 810 | if(!$closed){ |
||
| 811 | // check for spares |
||
| 812 | if($md_count-$new_item_count > 0){ |
||
| 813 | $placeholder_count = $md_count-$new_item_count; |
||
| 814 | while($placeholder_count > 0){ |
||
| 815 | $new_items += '<div class="col pr-1 pl-0"></div>'; |
||
| 816 | $placeholder_count--; |
||
| 817 | } |
||
| 818 | |||
| 819 | } |
||
| 820 | |||
| 821 | $new_items += '</div></div>'; |
||
| 822 | } |
||
| 823 | |||
| 824 | // insert the new items |
||
| 825 | jQuery($carousel).find('.carousel-inner').addClass('aui-multiple-items').html($new_items); |
||
| 826 | |||
| 827 | // fix any lazyload images in the active slider |
||
| 828 | jQuery($carousel).find('.carousel-item.active img').each(function () { |
||
| 829 | // fix the srcset |
||
| 830 | if(real_srcset = jQuery(this).attr("data-srcset")){ |
||
| 831 | if(!jQuery(this).attr("srcset")) jQuery(this).attr("srcset",real_srcset); |
||
| 832 | } |
||
| 833 | // fix the src |
||
| 834 | if(real_src = jQuery(this).attr("data-src")){ |
||
| 835 | if(!jQuery(this).attr("srcset")) jQuery(this).attr("src",real_src); |
||
| 836 | } |
||
| 837 | }); |
||
| 838 | |||
| 839 | // maybe fix carousel indicators |
||
| 840 | $hide_count = $new_items_count-1; |
||
| 841 | jQuery($carousel).find(".carousel-indicators li:gt("+$hide_count+")").addClass("d-none"); |
||
| 842 | } |
||
| 843 | |||
| 844 | // trigger a global action to say we have |
||
| 845 | jQuery( window ).trigger( "aui_carousel_multiple" ); |
||
| 846 | } |
||
| 847 | |||
| 848 | /** |
||
| 849 | * Init Multiple item carousels. |
||
| 850 | */ |
||
| 851 | function aui_init_carousel_multiple_items(){ |
||
| 852 | jQuery(window).on("resize",function(){ |
||
| 853 | jQuery('.carousel-multiple-items').each(function () { |
||
| 854 | aui_carousel_maybe_show_multiple_items(this); |
||
| 855 | }); |
||
| 856 | }); |
||
| 857 | |||
| 858 | // run now |
||
| 859 | jQuery('.carousel-multiple-items').each(function () { |
||
| 860 | aui_carousel_maybe_show_multiple_items(this); |
||
| 861 | }); |
||
| 862 | } |
||
| 863 | |||
| 864 | /** |
||
| 865 | * Allow navs to use multiple sub menus. |
||
| 866 | */ |
||
| 867 | function init_nav_sub_menus(){ |
||
| 868 | |||
| 869 | jQuery('.navbar-multi-sub-menus').each(function(i, obj) { |
||
| 870 | // Check if already initialized, if so continue. |
||
| 871 | if(jQuery(this).hasClass("has-sub-sub-menus")){return true;} |
||
| 872 | |||
| 873 | // Make sure its always expanded |
||
| 874 | jQuery(this).addClass('has-sub-sub-menus'); |
||
| 875 | |||
| 876 | jQuery(this).find( '.dropdown-menu a.dropdown-toggle' ).on( 'click', function ( e ) { |
||
| 877 | var $el = jQuery( this ); |
||
| 878 | $el.toggleClass('active-dropdown'); |
||
| 879 | var $parent = jQuery( this ).offsetParent( ".dropdown-menu" ); |
||
| 880 | if ( !jQuery( this ).next().hasClass( 'show' ) ) { |
||
| 881 | jQuery( this ).parents( '.dropdown-menu' ).first().find( '.show' ).removeClass( "show" ); |
||
| 882 | } |
||
| 883 | var $subMenu = jQuery( this ).next( ".dropdown-menu" ); |
||
| 884 | $subMenu.toggleClass( 'show' ); |
||
| 885 | |||
| 886 | jQuery( this ).parent( "li" ).toggleClass( 'show' ); |
||
| 887 | |||
| 888 | jQuery( this ).parents( 'li.nav-item.dropdown.show' ).on( 'hidden.bs.dropdown', function ( e ) { |
||
| 889 | jQuery( '.dropdown-menu .show' ).removeClass( "show" ); |
||
| 890 | $el.removeClass('active-dropdown'); |
||
| 891 | } ); |
||
| 892 | |||
| 893 | if ( !$parent.parent().hasClass( 'navbar-nav' ) ) { |
||
| 894 | $el.next().addClass('position-relative border-top border-bottom'); |
||
| 895 | } |
||
| 896 | |||
| 897 | return false; |
||
| 898 | } ); |
||
| 899 | |||
| 900 | }); |
||
| 901 | |||
| 902 | } |
||
| 903 | |||
| 904 | |||
| 905 | /** |
||
| 906 | * Open a lightbox when an embed item is clicked. |
||
| 907 | */ |
||
| 908 | function aui_lightbox_embed($link,ele){ |
||
| 909 | ele.preventDefault(); |
||
| 910 | |||
| 911 | // remove it first |
||
| 912 | jQuery('.aui-carousel-modal').remove(); |
||
| 913 | |||
| 914 | var $modal = '<div class="modal fade aui-carousel-modal bsui" tabindex="-1" role="dialog" aria-labelledby="aui-modal-title" aria-hidden="true"><div class="modal-dialog modal-dialog-centered modal-xl mw-100"><div class="modal-content bg-transparent border-0"><div class="modal-header"><h5 class="modal-title" id="aui-modal-title"></h5></div><div class="modal-body text-center"><i class="fas fa-circle-notch fa-spin fa-3x"></i></div></div></div></div>'; |
||
| 915 | jQuery('body').append($modal); |
||
| 916 | |||
| 917 | jQuery('.aui-carousel-modal').modal({ |
||
| 918 | //backdrop: 'static' |
||
| 919 | }); |
||
| 920 | jQuery('.aui-carousel-modal').on('hidden.bs.modal', function (e) { |
||
| 921 | jQuery("iframe").attr('src', ''); |
||
| 922 | }); |
||
| 923 | |||
| 924 | $container = jQuery($link).closest('.aui-gallery'); |
||
| 925 | |||
| 926 | $clicked_href = jQuery($link).attr('href'); |
||
| 927 | $images = []; |
||
| 928 | $container.find('.aui-lightbox-image').each(function() { |
||
| 929 | var a = this; |
||
| 930 | var href = jQuery(a).attr('href'); |
||
| 931 | if (href) { |
||
| 932 | $images.push(href); |
||
| 933 | } |
||
| 934 | }); |
||
| 935 | |||
| 936 | if( $images.length ){ |
||
| 937 | var $carousel = '<div id="aui-embed-slider-modal" class="carousel slide" >'; |
||
| 938 | |||
| 939 | // indicators |
||
| 940 | if($images.length > 1){ |
||
| 941 | $i = 0; |
||
| 942 | $carousel += '<ol class="carousel-indicators position-fixed">'; |
||
| 943 | $container.find('.aui-lightbox-image').each(function() { |
||
| 944 | $active = $clicked_href == jQuery(this).attr('href') ? 'active' : ''; |
||
| 945 | $carousel += '<li data-target="#aui-embed-slider-modal" data-slide-to="'+$i+'" class="'+$active+'"></li>'; |
||
| 946 | $i++; |
||
| 947 | |||
| 948 | }); |
||
| 949 | $carousel += '</ol>'; |
||
| 950 | } |
||
| 951 | |||
| 952 | |||
| 953 | |||
| 954 | // items |
||
| 955 | $i = 0; |
||
| 956 | $carousel += '<div class="carousel-inner">'; |
||
| 957 | $container.find('.aui-lightbox-image').each(function() { |
||
| 958 | var a = this; |
||
| 959 | |||
| 960 | $active = $clicked_href == jQuery(this).attr('href') ? 'active' : ''; |
||
| 961 | $carousel += '<div class="carousel-item '+ $active+'"><div>'; |
||
| 962 | |||
| 963 | |||
| 964 | // image |
||
| 965 | var css_height = window.innerWidth > window.innerHeight ? '90vh' : 'auto'; |
||
| 966 | var img = jQuery(a).find('img').clone().removeClass().addClass('mx-auto d-block w-auto mw-100 rounded').css('height',css_height).get(0).outerHTML; |
||
| 967 | $carousel += img; |
||
| 968 | // captions |
||
| 969 | if(jQuery(a).parent().find('.carousel-caption').length ){ |
||
| 970 | $carousel += jQuery(a).parent().find('.carousel-caption').clone().removeClass('sr-only').get(0).outerHTML; |
||
| 971 | } |
||
| 972 | $carousel += '</div></div>'; |
||
| 973 | $i++; |
||
| 974 | |||
| 975 | }); |
||
| 976 | $container.find('.aui-lightbox-iframe').each(function() { |
||
| 977 | var a = this; |
||
| 978 | |||
| 979 | $active = $clicked_href == jQuery(this).attr('href') ? 'active' : ''; |
||
| 980 | $carousel += '<div class="carousel-item '+ $active+'"><div class="modal-xl mx-auto embed-responsive embed-responsive-16by9">'; |
||
| 981 | |||
| 982 | |||
| 983 | // iframe |
||
| 984 | var css_height = window.innerWidth > window.innerHeight ? '95vh' : 'auto'; |
||
| 985 | var url = jQuery(a).attr('href'); |
||
| 986 | var iframe = '<iframe class="embed-responsive-item" style="height:'+css_height +'" src="'+url+'?rel=0&showinfo=0&modestbranding=1&autoplay=1" id="video" allow="autoplay"></iframe>'; |
||
| 987 | var img = iframe ;//.css('height',css_height).get(0).outerHTML; |
||
| 988 | $carousel += img; |
||
| 989 | |||
| 990 | $carousel += '</div></div>'; |
||
| 991 | $i++; |
||
| 992 | |||
| 993 | }); |
||
| 994 | $carousel += '</div>'; |
||
| 995 | |||
| 996 | |||
| 997 | // next/prev indicators |
||
| 998 | if($images.length > 1) { |
||
| 999 | $carousel += '<a class="carousel-control-prev" href="#aui-embed-slider-modal" role="button" data-slide="prev">'; |
||
| 1000 | $carousel += '<span class="carousel-control-prev-icon" aria-hidden="true"></span>'; |
||
| 1001 | $carousel += ' <a class="carousel-control-next" href="#aui-embed-slider-modal" role="button" data-slide="next">'; |
||
| 1002 | $carousel += '<span class="carousel-control-next-icon" aria-hidden="true"></span>'; |
||
| 1003 | $carousel += '</a>'; |
||
| 1004 | } |
||
| 1005 | |||
| 1006 | |||
| 1007 | $carousel += '</div>'; |
||
| 1008 | |||
| 1009 | var $close = '<button type="button" class="close text-white text-right position-fixed" style="font-size: 2.5em;right: 20px;top: 10px; z-index: 1055;" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'; |
||
| 1010 | |||
| 1011 | jQuery('.aui-carousel-modal .modal-content').html($carousel).prepend($close); |
||
| 1012 | |||
| 1013 | // enable ajax load |
||
| 1014 | //gd_init_carousel_ajax(); |
||
| 1015 | } |
||
| 1016 | |||
| 1017 | } |
||
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Init lightbox embed. |
||
| 1021 | */ |
||
| 1022 | function aui_init_lightbox_embed(){ |
||
| 1023 | // Open a lightbox for embeded items |
||
| 1024 | jQuery('.aui-lightbox-image, .aui-lightbox-iframe').off('click').on("click",function(ele) { |
||
| 1025 | aui_lightbox_embed(this,ele); |
||
| 1026 | }); |
||
| 1027 | } |
||
| 1028 | |||
| 1029 | /** |
||
| 1030 | * Show a toast. |
||
| 1031 | */ |
||
| 1032 | $aui_doing_toast = false; |
||
| 1033 | function aui_toast($id,$type,$title,$title_small,$body,$time,$can_close){ |
||
| 1034 | |||
| 1035 | if($aui_doing_toast){setTimeout(function(){ |
||
| 1036 | aui_toast($id,$type,$title,$title_small,$body,$time,$can_close); |
||
| 1037 | }, 500); return;} |
||
| 1038 | |||
| 1039 | $aui_doing_toast = true; |
||
| 1040 | |||
| 1041 | if($can_close == null){$can_close = false;} |
||
| 1042 | if($time == '' || $time == null ){$time = 3000;} |
||
| 1043 | |||
| 1044 | // if already setup then just show |
||
| 1045 | if(document.getElementById($id)){ |
||
| 1046 | jQuery('#'+$id).toast('show'); |
||
| 1047 | setTimeout(function(){ $aui_doing_toast = false; }, 500); |
||
| 1048 | return; |
||
| 1049 | } |
||
| 1050 | |||
| 1051 | var uniqid = Date.now(); |
||
| 1052 | if($id){ |
||
| 1053 | uniqid = $id; |
||
| 1054 | } |
||
| 1055 | |||
| 1056 | $op = ""; |
||
| 1057 | $tClass = ''; |
||
| 1058 | $thClass = ''; |
||
| 1059 | $icon = ""; |
||
| 1060 | |||
| 1061 | if ($type == 'success') { |
||
| 1062 | $op = "opacity:.92;"; |
||
| 1063 | $tClass = 'alert alert-success'; |
||
| 1064 | $thClass = 'bg-transparent border-0 alert-success'; |
||
| 1065 | $icon = "<div class='h5 m-0 p-0'><i class='fas fa-check-circle mr-2'></i></div>"; |
||
| 1066 | } else if ($type == 'error' || $type == 'danger') { |
||
| 1067 | $op = "opacity:.92;"; |
||
| 1068 | $tClass = 'alert alert-danger'; |
||
| 1069 | $thClass = 'bg-transparent border-0 alert-danger'; |
||
| 1070 | $icon = "<div class='h5 m-0 p-0'><i class='far fa-times-circle mr-2'></i></div>"; |
||
| 1071 | } else if ($type == 'info') { |
||
| 1072 | $op = "opacity:.92;"; |
||
| 1073 | $tClass = 'alert alert-info'; |
||
| 1074 | $thClass = 'bg-transparent border-0 alert-info'; |
||
| 1075 | $icon = "<div class='h5 m-0 p-0'><i class='fas fa-info-circle mr-2'></i></div>"; |
||
| 1076 | } else if ($type == 'warning') { |
||
| 1077 | $op = "opacity:.92;"; |
||
| 1078 | $tClass = 'alert alert-warning'; |
||
| 1079 | $thClass = 'bg-transparent border-0 alert-warning'; |
||
| 1080 | $icon = "<div class='h5 m-0 p-0'><i class='fas fa-exclamation-triangle mr-2'></i></div>"; |
||
| 1081 | } |
||
| 1082 | |||
| 1083 | |||
| 1084 | // add container if not exist |
||
| 1085 | if(!document.getElementById("aui-toasts")){ |
||
| 1086 | jQuery('body').append('<div class="bsui" id="aui-toasts"><div class="position-fixed aui-toast-bottom-right pr-3 mb-1" style="z-index: 50000;right: 0;bottom: 0;'+$op+'"></div></div>'); |
||
| 1087 | } |
||
| 1088 | |||
| 1089 | $toast = '<div id="'+uniqid+'" class="toast fade hide shadow hover-shadow '+$tClass+'" style="" role="alert" aria-live="assertive" aria-atomic="true" data-delay="'+$time+'">'; |
||
| 1090 | if($type || $title || $title_small){ |
||
| 1091 | $toast += '<div class="toast-header '+$thClass+'">'; |
||
| 1092 | if($icon ){$toast += $icon;} |
||
| 1093 | if($title){$toast += '<strong class="mr-auto">'+$title+'</strong>';} |
||
| 1094 | if($title_small){$toast += '<small>'+$title_small+'</small>';} |
||
| 1095 | if($can_close){$toast += '<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close"><span aria-hidden="true">×</span></button>';} |
||
| 1096 | $toast += '</div>'; |
||
| 1097 | } |
||
| 1098 | |||
| 1099 | if($body){ |
||
| 1100 | $toast += '<div class="toast-body">'+$body+'</div>'; |
||
| 1101 | } |
||
| 1102 | |||
| 1103 | $toast += '</div>'; |
||
| 1104 | |||
| 1105 | jQuery('.aui-toast-bottom-right').prepend($toast); |
||
| 1106 | jQuery('#'+uniqid).toast('show'); |
||
| 1107 | setTimeout(function(){ $aui_doing_toast = false; }, 500); |
||
| 1108 | } |
||
| 1109 | |||
| 1110 | |||
| 1111 | /** |
||
| 1112 | * Initiate all AUI JS. |
||
| 1113 | */ |
||
| 1114 | function aui_init(){ |
||
| 1115 | // nav menu submenus |
||
| 1116 | init_nav_sub_menus(); |
||
| 1117 | |||
| 1118 | // init tooltips |
||
| 1119 | aui_init_tooltips(); |
||
| 1120 | |||
| 1121 | // init select2 |
||
| 1122 | aui_init_select2(); |
||
| 1123 | |||
| 1124 | // init flatpickr |
||
| 1125 | aui_init_flatpickr(); |
||
| 1126 | |||
| 1127 | // init iconpicker |
||
| 1128 | aui_init_iconpicker(); |
||
| 1129 | |||
| 1130 | // init Greedy nav |
||
| 1131 | aui_init_greedy_nav(); |
||
| 1132 | |||
| 1133 | // Set times to time ago |
||
| 1134 | aui_time_ago('timeago'); |
||
| 1135 | |||
| 1136 | // init multiple item carousels |
||
| 1137 | aui_init_carousel_multiple_items(); |
||
| 1138 | |||
| 1139 | // init lightbox embeds |
||
| 1140 | aui_init_lightbox_embed(); |
||
| 1141 | } |
||
| 1142 | |||
| 1143 | // run on window loaded |
||
| 1144 | jQuery(window).on("load",function() { |
||
| 1145 | aui_init(); |
||
| 1146 | }); |
||
| 1147 | |||
| 1148 | /* Fix modal background scroll on iOS mobile device */ |
||
| 1149 | jQuery(function($) { |
||
| 1150 | var ua = navigator.userAgent.toLowerCase(); |
||
| 1151 | var isiOS = ua.match(/(iphone|ipod|ipad)/); |
||
| 1152 | if (isiOS) { |
||
| 1153 | var pS = 0; pM = parseFloat($('body').css('marginTop')); |
||
| 1154 | |||
| 1155 | $(document).on('show.bs.modal', function() { |
||
| 1156 | pS = window.scrollY; |
||
| 1157 | $('body').css({ |
||
| 1158 | marginTop: -pS, |
||
| 1159 | overflow: 'hidden', |
||
| 1160 | position: 'fixed', |
||
| 1161 | }); |
||
| 1162 | }).on('hidden.bs.modal', function() { |
||
| 1163 | $('body').css({ |
||
| 1164 | marginTop: pM, |
||
| 1165 | overflow: 'visible', |
||
| 1166 | position: 'inherit', |
||
| 1167 | }); |
||
| 1168 | window.scrollTo(0, pS); |
||
| 1169 | }); |
||
| 1170 | } |
||
| 1171 | }); |
||
| 1172 | |||
| 1173 | /** |
||
| 1174 | * Show a "confirm" dialog to the user (using jQuery UI's dialog) |
||
| 1175 | * |
||
| 1176 | * @param {string} message The message to display to the user |
||
| 1177 | * @param {string} okButtonText OPTIONAL - The OK button text, defaults to "Yes" |
||
| 1178 | * @param {string} cancelButtonText OPTIONAL - The Cancel button text, defaults to "No" |
||
| 1179 | * @returns {Q.Promise<boolean>} A promise of a boolean value |
||
| 1180 | */ |
||
| 1181 | var aui_confirm = function (message, okButtonText, cancelButtonText, isDelete, large ) { |
||
| 1182 | okButtonText = okButtonText || 'Yes'; |
||
| 1183 | cancelButtonText = cancelButtonText || 'Cancel'; |
||
| 1184 | message = message || 'Are you sure?'; |
||
| 1185 | sizeClass = large ? '' : 'modal-sm'; |
||
| 1186 | btnClass = isDelete ? 'btn-danger' : 'btn-primary'; |
||
| 1187 | |||
| 1188 | deferred = jQuery.Deferred(); |
||
| 1189 | var $body = ""; |
||
| 1190 | $body += "<h3 class='h4 py-3 text-center text-dark'>"+message+"</h3>"; |
||
| 1191 | $body += "<div class='d-flex'>"; |
||
| 1192 | $body += "<button class='btn btn-outline-secondary w-50 btn-round' data-dismiss='modal' onclick='deferred.resolve(false);'>"+cancelButtonText+"</button>"; |
||
| 1193 | $body += "<button class='btn "+btnClass+" ml-2 w-50 btn-round' data-dismiss='modal' onclick='deferred.resolve(true);'>"+okButtonText+"</button>"; |
||
| 1194 | $body += "</div>"; |
||
| 1195 | $modal = aui_modal('',$body,'',false,'',sizeClass); |
||
| 1196 | |||
| 1197 | return deferred.promise(); |
||
| 1198 | } |
||
| 1199 | </script> |
||
| 1200 | <?php |
||
| 1201 | $output = ob_get_clean(); |
||
| 1202 | |||
| 1203 | |||
| 1204 | |||
| 1205 | /* |
||
| 1206 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
||
| 1207 | */ |
||
| 1208 | return str_replace( array( |
||
| 1209 | '<script>', |
||
| 1210 | '</script>' |
||
| 1211 | ), '', self::minify_js($output) ); |
||
| 1212 | } |
||
| 1213 | |||
| 1214 | |||
| 1215 | /** |
||
| 1216 | * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
||
| 1217 | * |
||
| 1218 | * @TODO we may need this when other conflicts arrise. |
||
| 1219 | * @return mixed |
||
| 1220 | */ |
||
| 1221 | public static function bs3_compat_js() { |
||
| 1222 | ob_start(); |
||
| 1223 | ?> |
||
| 1224 | <script> |
||
| 1225 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
||
| 1226 | /* With Avada builder */ |
||
| 1227 | |||
| 1228 | <?php } ?> |
||
| 1229 | </script> |
||
| 1230 | <?php |
||
| 1231 | return str_replace( array( |
||
| 1232 | '<script>', |
||
| 1233 | '</script>' |
||
| 1234 | ), '', ob_get_clean()); |
||
| 1235 | } |
||
| 1236 | |||
| 1237 | /** |
||
| 1238 | * Get inline script used if bootstrap file browser enqueued. |
||
| 1239 | * |
||
| 1240 | * If this remains small then its best to use this than to add another JS file. |
||
| 1241 | */ |
||
| 1242 | public function inline_script_file_browser(){ |
||
| 1243 | ob_start(); |
||
| 1244 | ?> |
||
| 1245 | <script> |
||
| 1246 | // run on doc ready |
||
| 1247 | jQuery(document).ready(function () { |
||
| 1248 | bsCustomFileInput.init(); |
||
| 1249 | }); |
||
| 1250 | </script> |
||
| 1251 | <?php |
||
| 1252 | $output = ob_get_clean(); |
||
| 1253 | |||
| 1254 | /* |
||
| 1255 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
||
| 1256 | */ |
||
| 1257 | return str_replace( array( |
||
| 1258 | '<script>', |
||
| 1259 | '</script>' |
||
| 1260 | ), '', $output ); |
||
| 1261 | } |
||
| 1262 | |||
| 1263 | /** |
||
| 1264 | * Adds the Font Awesome JS. |
||
| 1265 | */ |
||
| 1266 | public function enqueue_scripts() { |
||
| 1267 | |||
| 1268 | if( is_admin() && !$this->is_aui_screen()){ |
||
| 1269 | // don't add wp-admin scripts if not requested to |
||
| 1270 | }else { |
||
| 1271 | |||
| 1272 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
||
| 1273 | |||
| 1274 | // select2 |
||
| 1275 | wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
||
| 1276 | |||
| 1277 | // flatpickr |
||
| 1278 | wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
||
| 1279 | |||
| 1280 | // flatpickr |
||
| 1281 | wp_register_script( 'iconpicker', $this->url . 'assets/js/fontawesome-iconpicker.min.js', array(), $this->latest ); |
||
| 1282 | |||
| 1283 | // Bootstrap file browser |
||
| 1284 | wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
||
| 1285 | wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
||
| 1286 | |||
| 1287 | $load_inline = false; |
||
| 1288 | |||
| 1289 | if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
||
| 1290 | // Bootstrap bundle |
||
| 1291 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
||
| 1292 | wp_register_script( 'bootstrap-js-bundle', $url, array( |
||
| 1293 | 'select2', |
||
| 1294 | 'jquery' |
||
| 1295 | ), $this->latest, $this->is_bs3_compat() ); |
||
| 1296 | // if in admin then add to footer for compatibility. |
||
| 1297 | is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
||
| 1298 | $script = $this->inline_script(); |
||
| 1299 | wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
||
| 1300 | } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
||
| 1301 | $url = $this->url . 'assets/js/popper.min.js'; |
||
| 1302 | wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
||
| 1303 | wp_enqueue_script( 'bootstrap-js-popper' ); |
||
| 1304 | $load_inline = true; |
||
| 1305 | } else { |
||
| 1306 | $load_inline = true; |
||
| 1307 | } |
||
| 1308 | |||
| 1309 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
||
| 1310 | if ( $load_inline ) { |
||
| 1311 | wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
||
| 1312 | wp_enqueue_script( 'bootstrap-dummy' ); |
||
| 1313 | $script = $this->inline_script(); |
||
| 1314 | wp_add_inline_script( 'bootstrap-dummy', $script ); |
||
| 1315 | } |
||
| 1316 | } |
||
| 1317 | |||
| 1318 | } |
||
| 1319 | |||
| 1320 | /** |
||
| 1321 | * Enqueue flatpickr if called. |
||
| 1322 | */ |
||
| 1323 | public function enqueue_flatpickr(){ |
||
| 1324 | wp_enqueue_style( 'flatpickr' ); |
||
| 1325 | wp_enqueue_script( 'flatpickr' ); |
||
| 1326 | } |
||
| 1327 | |||
| 1328 | /** |
||
| 1329 | * Enqueue iconpicker if called. |
||
| 1330 | */ |
||
| 1331 | public function enqueue_iconpicker(){ |
||
| 1332 | wp_enqueue_style( 'iconpicker' ); |
||
| 1333 | wp_enqueue_script( 'iconpicker' ); |
||
| 1334 | } |
||
| 1335 | |||
| 1336 | /** |
||
| 1337 | * Get the url path to the current folder. |
||
| 1338 | * |
||
| 1339 | * @return string |
||
| 1340 | */ |
||
| 1341 | public function get_url() { |
||
| 1342 | |||
| 1343 | $url = ''; |
||
| 1344 | // check if we are inside a plugin |
||
| 1345 | $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
||
| 1346 | |||
| 1347 | // add check in-case user has changed wp-content dir name. |
||
| 1348 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
||
| 1349 | $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
||
| 1350 | $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
||
| 1351 | |||
| 1352 | if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
||
| 1353 | $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
||
| 1354 | } |
||
| 1355 | |||
| 1356 | return $url; |
||
| 1357 | } |
||
| 1358 | |||
| 1359 | /** |
||
| 1360 | * Register the database settings with WordPress. |
||
| 1361 | */ |
||
| 1362 | public function register_settings() { |
||
| 1363 | register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
||
| 1364 | } |
||
| 1365 | |||
| 1366 | /** |
||
| 1367 | * Add the WordPress settings menu item. |
||
| 1368 | * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
||
| 1369 | */ |
||
| 1370 | public function menu_item() { |
||
| 1371 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
||
| 1372 | call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
||
| 1373 | $this, |
||
| 1374 | 'settings_page' |
||
| 1375 | ) ); |
||
| 1376 | } |
||
| 1377 | |||
| 1378 | /** |
||
| 1379 | * Get a list of themes and their default JS settings. |
||
| 1380 | * |
||
| 1381 | * @return array |
||
| 1382 | */ |
||
| 1383 | public function theme_js_settings(){ |
||
| 1384 | return array( |
||
| 1385 | 'ayetheme' => 'popper', |
||
| 1386 | 'listimia' => 'required', |
||
| 1387 | 'listimia_backend' => 'core-popper', |
||
| 1388 | //'avada' => 'required', // removed as we now add compatibility |
||
| 1389 | ); |
||
| 1390 | } |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Get the current Font Awesome output settings. |
||
| 1394 | * |
||
| 1395 | * @return array The array of settings. |
||
| 1396 | */ |
||
| 1397 | public function get_settings() { |
||
| 1398 | |||
| 1399 | $db_settings = get_option( 'ayecode-ui-settings' ); |
||
| 1400 | $js_default = 'core-popper'; |
||
| 1401 | $js_default_backend = $js_default; |
||
| 1402 | |||
| 1403 | // maybe set defaults (if no settings set) |
||
| 1404 | if(empty($db_settings)){ |
||
| 1405 | $active_theme = strtolower( get_template() ); // active parent theme. |
||
| 1406 | $theme_js_settings = self::theme_js_settings(); |
||
| 1407 | if(isset($theme_js_settings[$active_theme])){ |
||
| 1408 | $js_default = $theme_js_settings[$active_theme]; |
||
| 1409 | $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
||
| 1410 | } |
||
| 1411 | } |
||
| 1412 | |||
| 1413 | $defaults = array( |
||
| 1414 | 'css' => 'compatibility', // core, compatibility |
||
| 1415 | 'js' => $js_default, // js to load, core-popper, popper |
||
| 1416 | 'html_font_size' => '16', // js to load, core-popper, popper |
||
| 1417 | 'css_backend' => 'compatibility', // core, compatibility |
||
| 1418 | 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
||
| 1419 | 'disable_admin' => '', // URL snippets to disable loading on admin |
||
| 1420 | ); |
||
| 1421 | |||
| 1422 | $settings = wp_parse_args( $db_settings, $defaults ); |
||
| 1423 | |||
| 1424 | /** |
||
| 1425 | * Filter the Bootstrap settings. |
||
| 1426 | * |
||
| 1427 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
||
| 1428 | */ |
||
| 1429 | return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
||
| 1430 | } |
||
| 1431 | |||
| 1432 | |||
| 1433 | /** |
||
| 1434 | * The settings page html output. |
||
| 1435 | */ |
||
| 1436 | public function settings_page() { |
||
| 1437 | if ( ! current_user_can( 'manage_options' ) ) { |
||
| 1438 | wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
||
| 1439 | } |
||
| 1440 | ?> |
||
| 1441 | <div class="wrap"> |
||
| 1442 | <h1><?php echo $this->name; ?></h1> |
||
| 1443 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
||
| 1444 | <form method="post" action="options.php"> |
||
| 1445 | <?php |
||
| 1446 | settings_fields( 'ayecode-ui-settings' ); |
||
| 1447 | do_settings_sections( 'ayecode-ui-settings' ); |
||
| 1448 | ?> |
||
| 1449 | |||
| 1450 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
||
| 1451 | <table class="form-table wpbs-table-settings"> |
||
| 1452 | <tr valign="top"> |
||
| 1453 | <th scope="row"><label |
||
| 1454 | for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
||
| 1455 | <td> |
||
| 1456 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
||
| 1457 | <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
||
| 1458 | <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
||
| 1459 | <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
||
| 1460 | </select> |
||
| 1461 | </td> |
||
| 1462 | </tr> |
||
| 1463 | |||
| 1464 | <tr valign="top"> |
||
| 1465 | <th scope="row"><label |
||
| 1466 | for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
||
| 1467 | <td> |
||
| 1468 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
||
| 1469 | <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
||
| 1470 | <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
||
| 1471 | <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
||
| 1472 | <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
||
| 1473 | </select> |
||
| 1474 | </td> |
||
| 1475 | </tr> |
||
| 1476 | |||
| 1477 | <tr valign="top"> |
||
| 1478 | <th scope="row"><label |
||
| 1479 | for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
||
| 1480 | <td> |
||
| 1481 | <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
||
| 1482 | <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
||
| 1483 | </td> |
||
| 1484 | </tr> |
||
| 1485 | |||
| 1486 | </table> |
||
| 1487 | |||
| 1488 | <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
||
| 1489 | <table class="form-table wpbs-table-settings"> |
||
| 1490 | <tr valign="top"> |
||
| 1491 | <th scope="row"><label |
||
| 1492 | for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
||
| 1493 | <td> |
||
| 1494 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
||
| 1495 | <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
||
| 1496 | <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
||
| 1497 | <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
||
| 1498 | </select> |
||
| 1499 | </td> |
||
| 1500 | </tr> |
||
| 1501 | |||
| 1502 | <tr valign="top"> |
||
| 1503 | <th scope="row"><label |
||
| 1504 | for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
||
| 1505 | <td> |
||
| 1506 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
||
| 1507 | <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
||
| 1508 | <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
||
| 1509 | <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
||
| 1510 | <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
||
| 1511 | </select> |
||
| 1512 | </td> |
||
| 1513 | </tr> |
||
| 1514 | |||
| 1515 | <tr valign="top"> |
||
| 1516 | <th scope="row"><label |
||
| 1517 | for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
||
| 1518 | <td> |
||
| 1519 | <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
||
| 1520 | <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
||
| 1521 | |||
| 1522 | </td> |
||
| 1523 | </tr> |
||
| 1524 | |||
| 1525 | </table> |
||
| 1526 | |||
| 1527 | <?php |
||
| 1528 | submit_button(); |
||
| 1529 | ?> |
||
| 1530 | </form> |
||
| 1531 | |||
| 1532 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
||
| 1533 | </div> |
||
| 1534 | |||
| 1535 | <?php |
||
| 1536 | } |
||
| 1537 | |||
| 1538 | public function customizer_settings($wp_customize){ |
||
| 1539 | $wp_customize->add_section('aui_settings', array( |
||
| 1540 | 'title' => __('AyeCode UI','aui'), |
||
| 1541 | 'priority' => 120, |
||
| 1542 | )); |
||
| 1543 | |||
| 1544 | // ============================= |
||
| 1545 | // = Color Picker = |
||
| 1546 | // ============================= |
||
| 1547 | $wp_customize->add_setting('aui_options[color_primary]', array( |
||
| 1548 | 'default' => AUI_PRIMARY_COLOR, |
||
| 1549 | 'sanitize_callback' => 'sanitize_hex_color', |
||
| 1550 | 'capability' => 'edit_theme_options', |
||
| 1551 | 'type' => 'option', |
||
| 1552 | 'transport' => 'refresh', |
||
| 1553 | )); |
||
| 1554 | $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
||
| 1555 | 'label' => __('Primary Color','aui'), |
||
| 1556 | 'section' => 'aui_settings', |
||
| 1557 | 'settings' => 'aui_options[color_primary]', |
||
| 1558 | ))); |
||
| 1559 | |||
| 1560 | $wp_customize->add_setting('aui_options[color_secondary]', array( |
||
| 1561 | 'default' => '#6c757d', |
||
| 1562 | 'sanitize_callback' => 'sanitize_hex_color', |
||
| 1563 | 'capability' => 'edit_theme_options', |
||
| 1564 | 'type' => 'option', |
||
| 1565 | 'transport' => 'refresh', |
||
| 1566 | )); |
||
| 1567 | $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
||
| 1568 | 'label' => __('Secondary Color','aui'), |
||
| 1569 | 'section' => 'aui_settings', |
||
| 1570 | 'settings' => 'aui_options[color_secondary]', |
||
| 1571 | ))); |
||
| 1572 | } |
||
| 1573 | |||
| 1574 | /** |
||
| 1575 | * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
||
| 1576 | * |
||
| 1577 | * @return mixed |
||
| 1578 | */ |
||
| 1579 | public static function bs3_compat_css() { |
||
| 1611 | } |
||
| 1612 | |||
| 1613 | |||
| 1614 | public static function custom_css($compatibility = true) { |
||
| 1615 | $settings = get_option('aui_options'); |
||
| 1616 | |||
| 1617 | ob_start(); |
||
| 1618 | |||
| 1619 | $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
||
| 1620 | $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
||
| 1621 | //AUI_PRIMARY_COLOR_ORIGINAL |
||
| 1622 | ?> |
||
| 1623 | <style> |
||
| 1624 | <?php |
||
| 1625 | |||
| 1626 | // BS v3 compat |
||
| 1627 | if( self::is_bs3_compat() ){ |
||
| 1628 | echo self::bs3_compat_css(); |
||
| 1629 | } |
||
| 1630 | |||
| 1631 | if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
||
| 1632 | echo self::css_primary($primary_color,$compatibility); |
||
| 1633 | } |
||
| 1634 | |||
| 1635 | if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
||
| 1636 | echo self::css_secondary($settings['color_secondary'],$compatibility); |
||
| 1637 | } |
||
| 1638 | |||
| 1639 | // Set admin bar z-index lower when modal is open. |
||
| 1640 | echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
||
| 1641 | |||
| 1642 | if(is_admin()){ |
||
| 1643 | echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
||
| 1644 | } |
||
| 1645 | ?> |
||
| 1646 | </style> |
||
| 1647 | <?php |
||
| 1648 | |||
| 1649 | |||
| 1650 | /* |
||
| 1651 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
||
| 1652 | */ |
||
| 1653 | return str_replace( array( |
||
| 1654 | '<style>', |
||
| 1655 | '</style>' |
||
| 1656 | ), '', self::minify_css( ob_get_clean() ) ); |
||
| 1657 | } |
||
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Check if we should add booststrap 3 compatibility changes. |
||
| 1661 | * |
||
| 1662 | * @return bool |
||
| 1663 | */ |
||
| 1664 | public static function is_bs3_compat(){ |
||
| 1665 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
||
| 1666 | } |
||
| 1667 | |||
| 1668 | public static function css_primary($color_code,$compatibility){; |
||
| 1669 | $color_code = sanitize_hex_color($color_code); |
||
| 1670 | if(!$color_code){return '';} |
||
| 1671 | /** |
||
| 1672 | * c = color, b = background color, o = border-color, f = fill |
||
| 1673 | */ |
||
| 1674 | $selectors = array( |
||
| 1675 | 'a' => array('c'), |
||
| 1676 | '.btn-primary' => array('b','o'), |
||
| 1677 | '.btn-primary.disabled' => array('b','o'), |
||
| 1678 | '.btn-primary:disabled' => array('b','o'), |
||
| 1679 | '.btn-outline-primary' => array('c','o'), |
||
| 1680 | '.btn-outline-primary:hover' => array('b','o'), |
||
| 1681 | '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
||
| 1682 | '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
||
| 1683 | '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
||
| 1684 | '.btn-link' => array('c'), |
||
| 1685 | '.dropdown-item.active' => array('b'), |
||
| 1686 | '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
||
| 1687 | '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
||
| 1688 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
||
| 1689 | // '.custom-range::-moz-range-thumb' => array('b'), |
||
| 1690 | // '.custom-range::-ms-thumb' => array('b'), |
||
| 1691 | '.nav-pills .nav-link.active' => array('b'), |
||
| 1692 | '.nav-pills .show>.nav-link' => array('b'), |
||
| 1693 | '.page-link' => array('c'), |
||
| 1694 | '.page-item.active .page-link' => array('b','o'), |
||
| 1695 | '.badge-primary' => array('b'), |
||
| 1696 | '.alert-primary' => array('b','o'), |
||
| 1697 | '.progress-bar' => array('b'), |
||
| 1698 | '.list-group-item.active' => array('b','o'), |
||
| 1699 | '.bg-primary' => array('b','f'), |
||
| 1700 | '.btn-link.btn-primary' => array('c'), |
||
| 1701 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
||
| 1702 | ); |
||
| 1703 | |||
| 1704 | $important_selectors = array( |
||
| 1705 | '.bg-primary' => array('b','f'), |
||
| 1706 | '.border-primary' => array('o'), |
||
| 1707 | '.text-primary' => array('c'), |
||
| 1708 | ); |
||
| 1709 | |||
| 1710 | $color = array(); |
||
| 1711 | $color_i = array(); |
||
| 1712 | $background = array(); |
||
| 1713 | $background_i = array(); |
||
| 1714 | $border = array(); |
||
| 1715 | $border_i = array(); |
||
| 1716 | $fill = array(); |
||
| 1717 | $fill_i = array(); |
||
| 1718 | |||
| 1719 | $output = ''; |
||
| 1720 | |||
| 1721 | // build rules into each type |
||
| 1722 | foreach($selectors as $selector => $types){ |
||
| 1723 | $selector = $compatibility ? ".bsui ".$selector : $selector; |
||
| 1724 | $types = array_combine($types,$types); |
||
| 1725 | if(isset($types['c'])){$color[] = $selector;} |
||
| 1726 | if(isset($types['b'])){$background[] = $selector;} |
||
| 1727 | if(isset($types['o'])){$border[] = $selector;} |
||
| 1728 | if(isset($types['f'])){$fill[] = $selector;} |
||
| 1729 | } |
||
| 1730 | |||
| 1731 | // build rules into each type |
||
| 1732 | foreach($important_selectors as $selector => $types){ |
||
| 1733 | $selector = $compatibility ? ".bsui ".$selector : $selector; |
||
| 1734 | $types = array_combine($types,$types); |
||
| 1735 | if(isset($types['c'])){$color_i[] = $selector;} |
||
| 1736 | if(isset($types['b'])){$background_i[] = $selector;} |
||
| 1737 | if(isset($types['o'])){$border_i[] = $selector;} |
||
| 1738 | if(isset($types['f'])){$fill_i[] = $selector;} |
||
| 1739 | } |
||
| 1740 | |||
| 1741 | // add any color rules |
||
| 1742 | if(!empty($color)){ |
||
| 1743 | $output .= implode(",",$color) . "{color: $color_code;} "; |
||
| 1744 | } |
||
| 1745 | if(!empty($color_i)){ |
||
| 1746 | $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
||
| 1747 | } |
||
| 1748 | |||
| 1749 | // add any background color rules |
||
| 1750 | if(!empty($background)){ |
||
| 1751 | $output .= implode(",",$background) . "{background-color: $color_code;} "; |
||
| 1752 | } |
||
| 1753 | if(!empty($background_i)){ |
||
| 1754 | $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
||
| 1755 | } |
||
| 1756 | |||
| 1757 | // add any border color rules |
||
| 1758 | if(!empty($border)){ |
||
| 1759 | $output .= implode(",",$border) . "{border-color: $color_code;} "; |
||
| 1760 | } |
||
| 1761 | if(!empty($border_i)){ |
||
| 1762 | $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
||
| 1763 | } |
||
| 1764 | |||
| 1765 | // add any fill color rules |
||
| 1766 | if(!empty($fill)){ |
||
| 1767 | $output .= implode(",",$fill) . "{fill: $color_code;} "; |
||
| 1768 | } |
||
| 1769 | if(!empty($fill_i)){ |
||
| 1770 | $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
||
| 1771 | } |
||
| 1772 | |||
| 1773 | |||
| 1774 | $prefix = $compatibility ? ".bsui " : ""; |
||
| 1775 | |||
| 1776 | // darken |
||
| 1777 | $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
||
| 1778 | $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
||
| 1779 | $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
||
| 1780 | |||
| 1781 | // lighten |
||
| 1782 | $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
||
| 1783 | |||
| 1784 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
||
| 1785 | $op_25 = $color_code."40"; // 25% opacity |
||
| 1786 | |||
| 1787 | |||
| 1788 | // button states |
||
| 1789 | $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
||
| 1790 | $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1791 | $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
||
| 1792 | $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1793 | |||
| 1794 | |||
| 1795 | // dropdown's |
||
| 1796 | $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
||
| 1797 | |||
| 1798 | |||
| 1799 | // input states |
||
| 1800 | $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1801 | |||
| 1802 | // page link |
||
| 1803 | $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1804 | |||
| 1805 | return $output; |
||
| 1806 | } |
||
| 1807 | |||
| 1808 | public static function css_secondary($color_code,$compatibility){; |
||
| 1809 | $color_code = sanitize_hex_color($color_code); |
||
| 1810 | if(!$color_code){return '';} |
||
| 1811 | /** |
||
| 1812 | * c = color, b = background color, o = border-color, f = fill |
||
| 1813 | */ |
||
| 1814 | $selectors = array( |
||
| 1815 | '.btn-secondary' => array('b','o'), |
||
| 1816 | '.btn-secondary.disabled' => array('b','o'), |
||
| 1817 | '.btn-secondary:disabled' => array('b','o'), |
||
| 1818 | '.btn-outline-secondary' => array('c','o'), |
||
| 1819 | '.btn-outline-secondary:hover' => array('b','o'), |
||
| 1820 | '.btn-outline-secondary.disabled' => array('c'), |
||
| 1821 | '.btn-outline-secondary:disabled' => array('c'), |
||
| 1822 | '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
||
| 1823 | '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
||
| 1824 | '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
||
| 1825 | '.badge-secondary' => array('b'), |
||
| 1826 | '.alert-secondary' => array('b','o'), |
||
| 1827 | '.btn-link.btn-secondary' => array('c'), |
||
| 1828 | ); |
||
| 1829 | |||
| 1830 | $important_selectors = array( |
||
| 1831 | '.bg-secondary' => array('b','f'), |
||
| 1832 | '.border-secondary' => array('o'), |
||
| 1833 | '.text-secondary' => array('c'), |
||
| 1834 | ); |
||
| 1835 | |||
| 1836 | $color = array(); |
||
| 1837 | $color_i = array(); |
||
| 1838 | $background = array(); |
||
| 1839 | $background_i = array(); |
||
| 1840 | $border = array(); |
||
| 1841 | $border_i = array(); |
||
| 1842 | $fill = array(); |
||
| 1843 | $fill_i = array(); |
||
| 1844 | |||
| 1845 | $output = ''; |
||
| 1846 | |||
| 1847 | // build rules into each type |
||
| 1848 | foreach($selectors as $selector => $types){ |
||
| 1849 | $selector = $compatibility ? ".bsui ".$selector : $selector; |
||
| 1850 | $types = array_combine($types,$types); |
||
| 1851 | if(isset($types['c'])){$color[] = $selector;} |
||
| 1852 | if(isset($types['b'])){$background[] = $selector;} |
||
| 1853 | if(isset($types['o'])){$border[] = $selector;} |
||
| 1854 | if(isset($types['f'])){$fill[] = $selector;} |
||
| 1855 | } |
||
| 1856 | |||
| 1857 | // build rules into each type |
||
| 1858 | foreach($important_selectors as $selector => $types){ |
||
| 1859 | $selector = $compatibility ? ".bsui ".$selector : $selector; |
||
| 1860 | $types = array_combine($types,$types); |
||
| 1861 | if(isset($types['c'])){$color_i[] = $selector;} |
||
| 1862 | if(isset($types['b'])){$background_i[] = $selector;} |
||
| 1863 | if(isset($types['o'])){$border_i[] = $selector;} |
||
| 1864 | if(isset($types['f'])){$fill_i[] = $selector;} |
||
| 1865 | } |
||
| 1866 | |||
| 1867 | // add any color rules |
||
| 1868 | if(!empty($color)){ |
||
| 1869 | $output .= implode(",",$color) . "{color: $color_code;} "; |
||
| 1870 | } |
||
| 1871 | if(!empty($color_i)){ |
||
| 1872 | $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
||
| 1873 | } |
||
| 1874 | |||
| 1875 | // add any background color rules |
||
| 1876 | if(!empty($background)){ |
||
| 1877 | $output .= implode(",",$background) . "{background-color: $color_code;} "; |
||
| 1878 | } |
||
| 1879 | if(!empty($background_i)){ |
||
| 1880 | $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
||
| 1881 | } |
||
| 1882 | |||
| 1883 | // add any border color rules |
||
| 1884 | if(!empty($border)){ |
||
| 1885 | $output .= implode(",",$border) . "{border-color: $color_code;} "; |
||
| 1886 | } |
||
| 1887 | if(!empty($border_i)){ |
||
| 1888 | $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
||
| 1889 | } |
||
| 1890 | |||
| 1891 | // add any fill color rules |
||
| 1892 | if(!empty($fill)){ |
||
| 1893 | $output .= implode(",",$fill) . "{fill: $color_code;} "; |
||
| 1894 | } |
||
| 1895 | if(!empty($fill_i)){ |
||
| 1896 | $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
||
| 1897 | } |
||
| 1898 | |||
| 1899 | |||
| 1900 | $prefix = $compatibility ? ".bsui " : ""; |
||
| 1901 | |||
| 1902 | // darken |
||
| 1903 | $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
||
| 1904 | $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
||
| 1905 | $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
||
| 1906 | |||
| 1907 | // lighten |
||
| 1908 | $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
||
| 1909 | |||
| 1910 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
||
| 1911 | $op_25 = $color_code."40"; // 25% opacity |
||
| 1912 | |||
| 1913 | |||
| 1914 | // button states |
||
| 1915 | $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
||
| 1916 | $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1917 | $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
||
| 1918 | $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
||
| 1919 | |||
| 1920 | |||
| 1921 | return $output; |
||
| 1922 | } |
||
| 1923 | |||
| 1924 | /** |
||
| 1925 | * Increases or decreases the brightness of a color by a percentage of the current brightness. |
||
| 1926 | * |
||
| 1927 | * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
||
| 1928 | * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
||
| 1929 | * |
||
| 1930 | * @return string |
||
| 1931 | */ |
||
| 1932 | public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
||
| 1933 | $hexCode = ltrim($hexCode, '#'); |
||
| 1934 | |||
| 1935 | if (strlen($hexCode) == 3) { |
||
| 1936 | $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
||
| 1937 | } |
||
| 1938 | |||
| 1939 | $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
||
| 1940 | |||
| 1941 | foreach ($hexCode as & $color) { |
||
| 1942 | $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
||
| 1943 | $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
||
| 1944 | |||
| 1945 | $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
||
| 1946 | } |
||
| 1947 | |||
| 1948 | return '#' . implode($hexCode); |
||
| 1949 | } |
||
| 1950 | |||
| 1951 | /** |
||
| 1952 | * Check if we should display examples. |
||
| 1953 | */ |
||
| 1954 | public function maybe_show_examples(){ |
||
| 1955 | if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
||
| 1956 | echo "<head>"; |
||
| 1957 | wp_head(); |
||
| 1958 | echo "</head>"; |
||
| 1959 | echo "<body>"; |
||
| 1960 | echo $this->get_examples(); |
||
| 1961 | echo "</body>"; |
||
| 1962 | exit; |
||
| 1963 | } |
||
| 1964 | } |
||
| 1965 | |||
| 1966 | /** |
||
| 1967 | * Get developer examples. |
||
| 1968 | * |
||
| 1969 | * @return string |
||
| 1970 | */ |
||
| 1971 | public function get_examples(){ |
||
| 1972 | $output = ''; |
||
| 1973 | |||
| 1974 | |||
| 1975 | // open form |
||
| 1976 | $output .= "<form class='p-5 m-5 border rounded'>"; |
||
| 1977 | |||
| 1978 | // input example |
||
| 1979 | $output .= aui()->input(array( |
||
| 1980 | 'type' => 'text', |
||
| 1981 | 'id' => 'text-example', |
||
| 1982 | 'name' => 'text-example', |
||
| 1983 | 'placeholder' => 'text placeholder', |
||
| 1984 | 'title' => 'Text input example', |
||
| 1985 | 'value' => '', |
||
| 1986 | 'required' => false, |
||
| 1987 | 'help_text' => 'help text', |
||
| 1988 | 'label' => 'Text input example label' |
||
| 1989 | )); |
||
| 1990 | |||
| 1991 | // input example |
||
| 1992 | $output .= aui()->input(array( |
||
| 1993 | 'type' => 'url', |
||
| 1994 | 'id' => 'text-example2', |
||
| 1995 | 'name' => 'text-example', |
||
| 1996 | 'placeholder' => 'url placeholder', |
||
| 1997 | 'title' => 'Text input example', |
||
| 1998 | 'value' => '', |
||
| 1999 | 'required' => false, |
||
| 2000 | 'help_text' => 'help text', |
||
| 2001 | 'label' => 'Text input example label' |
||
| 2002 | )); |
||
| 2003 | |||
| 2004 | // checkbox example |
||
| 2005 | $output .= aui()->input(array( |
||
| 2006 | 'type' => 'checkbox', |
||
| 2007 | 'id' => 'checkbox-example', |
||
| 2008 | 'name' => 'checkbox-example', |
||
| 2009 | 'placeholder' => 'checkbox-example', |
||
| 2010 | 'title' => 'Checkbox example', |
||
| 2011 | 'value' => '1', |
||
| 2012 | 'checked' => true, |
||
| 2013 | 'required' => false, |
||
| 2014 | 'help_text' => 'help text', |
||
| 2015 | 'label' => 'Checkbox checked' |
||
| 2016 | )); |
||
| 2017 | |||
| 2018 | // checkbox example |
||
| 2019 | $output .= aui()->input(array( |
||
| 2020 | 'type' => 'checkbox', |
||
| 2021 | 'id' => 'checkbox-example2', |
||
| 2022 | 'name' => 'checkbox-example2', |
||
| 2023 | 'placeholder' => 'checkbox-example', |
||
| 2024 | 'title' => 'Checkbox example', |
||
| 2025 | 'value' => '1', |
||
| 2026 | 'checked' => false, |
||
| 2027 | 'required' => false, |
||
| 2028 | 'help_text' => 'help text', |
||
| 2029 | 'label' => 'Checkbox un-checked' |
||
| 2030 | )); |
||
| 2031 | |||
| 2032 | // switch example |
||
| 2033 | $output .= aui()->input(array( |
||
| 2034 | 'type' => 'checkbox', |
||
| 2035 | 'id' => 'switch-example', |
||
| 2036 | 'name' => 'switch-example', |
||
| 2037 | 'placeholder' => 'checkbox-example', |
||
| 2038 | 'title' => 'Switch example', |
||
| 2039 | 'value' => '1', |
||
| 2040 | 'checked' => true, |
||
| 2041 | 'switch' => true, |
||
| 2042 | 'required' => false, |
||
| 2043 | 'help_text' => 'help text', |
||
| 2044 | 'label' => 'Switch on' |
||
| 2045 | )); |
||
| 2046 | |||
| 2047 | // switch example |
||
| 2048 | $output .= aui()->input(array( |
||
| 2049 | 'type' => 'checkbox', |
||
| 2050 | 'id' => 'switch-example2', |
||
| 2051 | 'name' => 'switch-example2', |
||
| 2052 | 'placeholder' => 'checkbox-example', |
||
| 2053 | 'title' => 'Switch example', |
||
| 2054 | 'value' => '1', |
||
| 2055 | 'checked' => false, |
||
| 2056 | 'switch' => true, |
||
| 2057 | 'required' => false, |
||
| 2058 | 'help_text' => 'help text', |
||
| 2059 | 'label' => 'Switch off' |
||
| 2060 | )); |
||
| 2061 | |||
| 2062 | // close form |
||
| 2063 | $output .= "</form>"; |
||
| 2064 | |||
| 2065 | return $output; |
||
| 2066 | } |
||
| 2067 | |||
| 2068 | /** |
||
| 2069 | * Calendar params. |
||
| 2070 | * |
||
| 2071 | * @since 0.1.44 |
||
| 2072 | * |
||
| 2073 | * @return array Calendar params. |
||
| 2074 | */ |
||
| 2075 | public static function calendar_params() { |
||
| 2076 | $params = array( |
||
| 2077 | 'month_long_1' => __( 'January', 'aui' ), |
||
| 2078 | 'month_long_2' => __( 'February', 'aui' ), |
||
| 2079 | 'month_long_3' => __( 'March', 'aui' ), |
||
| 2080 | 'month_long_4' => __( 'April', 'aui' ), |
||
| 2081 | 'month_long_5' => __( 'May', 'aui' ), |
||
| 2082 | 'month_long_6' => __( 'June', 'aui' ), |
||
| 2083 | 'month_long_7' => __( 'July', 'aui' ), |
||
| 2084 | 'month_long_8' => __( 'August', 'aui' ), |
||
| 2085 | 'month_long_9' => __( 'September', 'aui' ), |
||
| 2086 | 'month_long_10' => __( 'October', 'aui' ), |
||
| 2087 | 'month_long_11' => __( 'November', 'aui' ), |
||
| 2088 | 'month_long_12' => __( 'December', 'aui' ), |
||
| 2089 | 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
||
| 2090 | 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
||
| 2091 | 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
||
| 2092 | 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
||
| 2093 | 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
||
| 2094 | 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
||
| 2095 | 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
||
| 2096 | 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
||
| 2097 | 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
||
| 2098 | 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
||
| 2099 | 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
||
| 2100 | 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
||
| 2101 | 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
||
| 2102 | 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
||
| 2103 | 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
||
| 2104 | 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
||
| 2105 | 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
||
| 2106 | 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
||
| 2107 | 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
||
| 2108 | 'day_s2_1' => __( 'Su', 'aui' ), |
||
| 2109 | 'day_s2_2' => __( 'Mo', 'aui' ), |
||
| 2110 | 'day_s2_3' => __( 'Tu', 'aui' ), |
||
| 2111 | 'day_s2_4' => __( 'We', 'aui' ), |
||
| 2112 | 'day_s2_5' => __( 'Th', 'aui' ), |
||
| 2113 | 'day_s2_6' => __( 'Fr', 'aui' ), |
||
| 2114 | 'day_s2_7' => __( 'Sa', 'aui' ), |
||
| 2115 | 'day_s3_1' => __( 'Sun', 'aui' ), |
||
| 2116 | 'day_s3_2' => __( 'Mon', 'aui' ), |
||
| 2117 | 'day_s3_3' => __( 'Tue', 'aui' ), |
||
| 2118 | 'day_s3_4' => __( 'Wed', 'aui' ), |
||
| 2119 | 'day_s3_5' => __( 'Thu', 'aui' ), |
||
| 2120 | 'day_s3_6' => __( 'Fri', 'aui' ), |
||
| 2121 | 'day_s3_7' => __( 'Sat', 'aui' ), |
||
| 2122 | 'day_s5_1' => __( 'Sunday', 'aui' ), |
||
| 2123 | 'day_s5_2' => __( 'Monday', 'aui' ), |
||
| 2124 | 'day_s5_3' => __( 'Tuesday', 'aui' ), |
||
| 2125 | 'day_s5_4' => __( 'Wednesday', 'aui' ), |
||
| 2126 | 'day_s5_5' => __( 'Thursday', 'aui' ), |
||
| 2127 | 'day_s5_6' => __( 'Friday', 'aui' ), |
||
| 2128 | 'day_s5_7' => __( 'Saturday', 'aui' ), |
||
| 2129 | 'am_lower' => __( 'am', 'aui' ), |
||
| 2130 | 'pm_lower' => __( 'pm', 'aui' ), |
||
| 2131 | 'am_upper' => __( 'AM', 'aui' ), |
||
| 2132 | 'pm_upper' => __( 'PM', 'aui' ), |
||
| 2133 | 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
||
| 2134 | 'time_24hr' => false, |
||
| 2135 | 'year' => __( 'Year', 'aui' ), |
||
| 2136 | 'hour' => __( 'Hour', 'aui' ), |
||
| 2137 | 'minute' => __( 'Minute', 'aui' ), |
||
| 2138 | 'weekAbbreviation' => __( 'Wk', 'aui' ), |
||
| 2139 | 'rangeSeparator' => __( ' to ', 'aui' ), |
||
| 2140 | 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
||
| 2141 | 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
||
| 2142 | ); |
||
| 2143 | |||
| 2144 | return apply_filters( 'ayecode_ui_calendar_params', $params ); |
||
| 2145 | } |
||
| 2146 | |||
| 2147 | /** |
||
| 2148 | * Flatpickr calendar localize. |
||
| 2149 | * |
||
| 2150 | * @since 0.1.44 |
||
| 2151 | * |
||
| 2152 | * @return string Calendar locale. |
||
| 2153 | */ |
||
| 2154 | public static function flatpickr_locale() { |
||
| 2155 | $params = self::calendar_params(); |
||
| 2156 | |||
| 2157 | if ( is_string( $params ) ) { |
||
| 2158 | $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
||
| 2159 | } else { |
||
| 2160 | foreach ( (array) $params as $key => $value ) { |
||
| 2161 | if ( ! is_scalar( $value ) ) { |
||
| 2162 | continue; |
||
| 2163 | } |
||
| 2164 | |||
| 2165 | $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
||
| 2166 | } |
||
| 2167 | } |
||
| 2168 | |||
| 2169 | $day_s3 = array(); |
||
| 2170 | $day_s5 = array(); |
||
| 2171 | |||
| 2172 | for ( $i = 1; $i <= 7; $i ++ ) { |
||
| 2173 | $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
||
| 2174 | $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
||
| 2175 | } |
||
| 2176 | |||
| 2177 | $month_s = array(); |
||
| 2178 | $month_long = array(); |
||
| 2179 | |||
| 2180 | for ( $i = 1; $i <= 12; $i ++ ) { |
||
| 2181 | $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
||
| 2182 | $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
||
| 2183 | } |
||
| 2184 | |||
| 2185 | ob_start(); |
||
| 2186 | if ( 0 ) { ?><script><?php } ?> |
||
| 2187 | { |
||
| 2188 | weekdays: { |
||
| 2189 | shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
||
| 2190 | longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
||
| 2191 | }, |
||
| 2192 | months: { |
||
| 2193 | shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
||
| 2194 | longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
||
| 2195 | }, |
||
| 2196 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
||
| 2197 | firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
||
| 2198 | ordinal: function (nth) { |
||
| 2199 | var s = nth % 100; |
||
| 2200 | if (s > 3 && s < 21) |
||
| 2201 | return "th"; |
||
| 2202 | switch (s % 10) { |
||
| 2203 | case 1: |
||
| 2204 | return "st"; |
||
| 2205 | case 2: |
||
| 2206 | return "nd"; |
||
| 2207 | case 3: |
||
| 2208 | return "rd"; |
||
| 2209 | default: |
||
| 2210 | return "th"; |
||
| 2211 | } |
||
| 2212 | }, |
||
| 2213 | rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
||
| 2214 | weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
||
| 2215 | scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
||
| 2216 | toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
||
| 2217 | amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
||
| 2218 | yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
||
| 2219 | hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
||
| 2220 | minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
||
| 2221 | time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
||
| 2222 | } |
||
| 2223 | <?php if ( 0 ) { ?></script><?php } ?> |
||
| 2224 | <?php |
||
| 2225 | $locale = ob_get_clean(); |
||
| 2226 | |||
| 2227 | return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
||
| 2228 | } |
||
| 2229 | |||
| 2230 | /** |
||
| 2231 | * Select2 JS params. |
||
| 2232 | * |
||
| 2233 | * @since 0.1.44 |
||
| 2234 | * |
||
| 2235 | * @return array Select2 JS params. |
||
| 2236 | */ |
||
| 2237 | public static function select2_params() { |
||
| 2253 | } |
||
| 2254 | |||
| 2255 | /** |
||
| 2256 | * Select2 JS localize. |
||
| 2257 | * |
||
| 2258 | * @since 0.1.44 |
||
| 2259 | * |
||
| 2260 | * @return string Select2 JS locale. |
||
| 2261 | */ |
||
| 2262 | public static function select2_locale() { |
||
| 2263 | $params = self::select2_params(); |
||
| 2264 | |||
| 2265 | foreach ( (array) $params as $key => $value ) { |
||
| 2266 | if ( ! is_scalar( $value ) ) { |
||
| 2267 | continue; |
||
| 2268 | } |
||
| 2269 | |||
| 2270 | $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
||
| 2271 | } |
||
| 2272 | |||
| 2273 | $locale = json_encode( $params ); |
||
| 2274 | |||
| 2275 | return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
||
| 2276 | } |
||
| 2277 | |||
| 2278 | /** |
||
| 2279 | * Time ago JS localize. |
||
| 2280 | * |
||
| 2281 | * @since 0.1.47 |
||
| 2282 | * |
||
| 2283 | * @return string Time ago JS locale. |
||
| 2284 | */ |
||
| 2285 | public static function timeago_locale() { |
||
| 2286 | $params = array( |
||
| 2287 | 'prefix_ago' => '', |
||
| 2288 | 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
||
| 2289 | 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
||
| 2290 | 'suffix_after' => '', |
||
| 2291 | 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
||
| 2292 | 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
||
| 2293 | 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
||
| 2294 | 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
||
| 2295 | 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
||
| 2296 | 'day' => _x( 'a day', 'time ago', 'aui' ), |
||
| 2297 | 'days' => _x( '%d days', 'time ago', 'aui' ), |
||
| 2298 | 'month' => _x( 'about a month', 'time ago', 'aui' ), |
||
| 2299 | 'months' => _x( '%d months', 'time ago', 'aui' ), |
||
| 2300 | 'year' => _x( 'about a year', 'time ago', 'aui' ), |
||
| 2301 | 'years' => _x( '%d years', 'time ago', 'aui' ), |
||
| 2302 | ); |
||
| 2303 | |||
| 2304 | $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
||
| 2305 | |||
| 2306 | foreach ( (array) $params as $key => $value ) { |
||
| 2307 | if ( ! is_scalar( $value ) ) { |
||
| 2308 | continue; |
||
| 2309 | } |
||
| 2310 | |||
| 2311 | $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
||
| 2312 | } |
||
| 2313 | |||
| 2314 | $locale = json_encode( $params ); |
||
| 2315 | |||
| 2316 | return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
||
| 2317 | } |
||
| 2318 | |||
| 2319 | /** |
||
| 2320 | * JavaScript Minifier |
||
| 2321 | * |
||
| 2322 | * @param $input |
||
| 2323 | * |
||
| 2324 | * @return mixed |
||
| 2325 | */ |
||
| 2326 | public static function minify_js($input) { |
||
| 2327 | if(trim($input) === "") return $input; |
||
| 2328 | return preg_replace( |
||
| 2329 | array( |
||
| 2330 | // Remove comment(s) |
||
| 2331 | '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
||
| 2332 | // Remove white-space(s) outside the string and regex |
||
| 2333 | '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
||
| 2334 | // Remove the last semicolon |
||
| 2335 | '#;+\}#', |
||
| 2336 | // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
||
| 2337 | '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
||
| 2338 | // --ibid. From `foo['bar']` to `foo.bar` |
||
| 2339 | '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
||
| 2340 | ), |
||
| 2341 | array( |
||
| 2342 | '$1', |
||
| 2343 | '$1$2', |
||
| 2344 | '}', |
||
| 2345 | '$1$3', |
||
| 2346 | '$1.$3' |
||
| 2347 | ), |
||
| 2348 | $input); |
||
| 2349 | } |
||
| 2350 | |||
| 2351 | /** |
||
| 2352 | * Minify CSS |
||
| 2353 | * |
||
| 2354 | * @param $input |
||
| 2355 | * |
||
| 2356 | * @return mixed |
||
| 2357 | */ |
||
| 2358 | public static function minify_css($input) { |
||
| 2398 | } |
||
| 2399 | |||
| 2400 | /** |
||
| 2401 | * Get the conditional fields JavaScript. |
||
| 2402 | * |
||
| 2403 | * @return mixed |
||
| 2404 | */ |
||
| 2405 | public function conditional_fields_js() { |
||
| 2406 | ob_start(); |
||
| 2914 | } |
||
| 2915 | } |
||
| 2916 | |||
| 2917 | /** |
||
| 2918 | * Run the class if found. |
||
| 2919 | */ |
||
| 2920 | AyeCode_UI_Settings::instance(); |
||
| 2921 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.