Ejemplo n.º 1
0
    /**
     * wp_enqueue_scripts action
     *
     * @internal action: wp_enqueue_scripts
     * @since 1.0
     */
    public function actionWPEnqueueScripts()
    {
        // Debug
        $this->beginMarker(__METHOD__);
        $min_sufix = !$this->debug_mode ? '.min' : '';
        $ver = $this->base_theme->version;
        // 3rd party styles
        wp_enqueue_style('everything-3rd-party', $this->template_uri . '/data/css/3rd-party.min.css', array(), $ver);
        // Main style
        wp_enqueue_style('everything-style', $this->template_uri . "/data/css/style{$min_sufix}.css", array(), $ver);
        // Color scheme
        wp_enqueue_style('everything-scheme', $this->template_uri . '/data/css/' . Everything::to('general/scheme') . $min_sufix . '.css', array(), $ver);
        // Responsive design
        if (Everything::to('general/responsive')) {
            wp_enqueue_style('everything-mobile', $this->template_uri . "/data/css/mobile{$min_sufix}.css", array(), $ver, 'only screen and (max-width: 767px)');
        }
        // Stylesheet
        wp_enqueue_style('everything-stylesheet', get_stylesheet_uri());
        // Leading color
        $this->addDocumentStyle(sprintf(<<<'EOS'
			a,
			a.alt:hover,
			.alt a:hover,
			h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
			.color,
			.toggles > div > h3:hover > i,
			.nav-menu a:hover,
			.nav-menu .current > a, .nav-menu .current > a:hover,
			.mobile-nav-menu a:hover,
			.mobile-nav-menu .current > a, .mobile-nav-menu .current > a:hover,
			.aside-nav-menu a:hover,
			.aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a, .aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a:hover {
				color: %1$s;
			}

			mark,
			.background-color,
			.sy-pager li.sy-active a {
				background-color: %1$s;
			}

			.zoom-hover > .zoom-hover-overlay {
				background-color: rgba(%2$s, 0.75);
			}

			blockquote.bar,
			.sticky:before {
				border-color: %1$s;
			}
EOS
, Everything::to('general/color'), implode(', ', array_map('hexdec', str_split(substr(Everything::to('general/color'), 1), 2)))));
        // Comment reply
        if (is_singular() && comments_open() && get_option('thread_comments')) {
            wp_enqueue_script('comment-reply');
        }
        // 3rd party scripts
        wp_enqueue_script('everything-3rd-party', $this->template_uri . '/data/js/3rd-party.min.js', array('jquery'), $ver, true);
        // Main script
        wp_enqueue_script('everything-script', $this->template_uri . "/data/js/everything{$min_sufix}.js", array('jquery'), $ver, true);
        // WooCommerce
        if (Everything::isPluginActive('woocommerce')) {
            wp_deregister_script('wc-single-product');
            wp_register_script('wc-single-product', $this->template_uri . "/data/js/woocommerce/single-product{$min_sufix}.js", array('jquery'), $ver, true);
        }
        // Configuration
        $this->addDocumentScript(sprintf('everythingConfig = %s;', json_encode(array('retinaSupport' => Everything::to('general/retina'), 'fancyboxOptions' => Everything::to('site/image/fancybox_horizontal_fit_only') ? array('maxWidth' => '100%', 'fitToView' => false) : array(), 'zoomHoverIcons' => array_map(function ($s) {
            return 'icon-' . $s;
        }, Everything::to_('site/hover_icons')->toArray()), 'captions' => array('bricksAllButton' => __('all', 'everything'))))));
        // Max. width style
        if (!Everything::to_('general/max_width')->isDefault()) {
            Everything::$max_width = Everything::to_('general/max_width')->value();
            $this->addDocumentStyle(sprintf(<<<'EOS'
				.layout-boxed .outer-container, .container {
					max-width: %dpx;
				}
EOS
, Everything::$max_width));
        }
        // Colors styles
        foreach (Everything::to_('color')->childs() as $name => $group) {
            if ($group->child('enabled')->value) {
                $color = $group->child($name);
                $hsl = \Drone\Func::colorRGBToHSL(\Drone\Func::cssColorToDec($color->value));
                $hsl[2] = max($hsl[2] - 0.12, 0);
                $darken = \Drone\Func::cssDecToColor(\Drone\Func::colorHSLToRGB($hsl));
                $this->addDocumentStyle(sprintf($color->tag, $color->value, $darken));
            }
        }
        // Header style
        if (Everything::to_('header/style/settings')->value('floated')) {
            if (Everything::to('header/style/opacity')) {
                $this->addDocumentStyle(sprintf('#header:before { opacity: %.2f; }', Everything::to('header/style/opacity') / 100));
            } else {
                $this->addDocumentStyle('#header:before { display: none; }');
            }
        }
        // Content
        if (!is_null($background = Everything::io_('layout/background/background', 'general/background/background', '__hidden_ns', '__hidden'))) {
            if ($background instanceof \Drone\Options\Option\ConditionalTags) {
                $background = $background->option();
            }
            if (!$background->option('opacity')->isDefault()) {
                $this->addDocumentStyle(sprintf(<<<'EOS'
					.layout-boxed #content aside.aside .aside-nav-menu .current:not(.current-menu-parent):not(.current-menu-ancestor) > a:before {
						display: none;
					}
					#content:before {
						opacity: %.2f;
					}
EOS
, $background->property('opacity') / 100));
            }
        }
        // Fonts styles
        foreach (\Drone\Options\Option\Font::getInstances() as $font) {
            if ($font->isVisible() && !is_null($font->tag)) {
                foreach ((array) $font->tag as $selector) {
                    $this->addDocumentStyle($font->css($selector));
                }
            }
        }
        // MediaElement.js progress bar color
        if (version_compare($this->wp_version, '4.0') >= 0) {
            $this->addDocumentStyle(sprintf(<<<'EOS'
				.mejs-container .mejs-controls .mejs-time-rail .mejs-time-current {
					background-color: %s;
				}
EOS
, Everything::to('general/color')));
        }
        // Google Chrome fonts fix
        if (Everything::to('advanced/chrome_fonts_fix')) {
            $this->addDocumentStyle(<<<'EOS'
				@media screen and (-webkit-min-device-pixel-ratio: 0) {
					* {
						-webkit-font-smoothing: antialiased;
						-webkit-text-stroke: 0.1pt;
					}
					h1, h2, h3, .button.big *, .button.huge *, #header * {
						-webkit-text-stroke: 0.2pt;
					}
				}
EOS
);
        }
        // List widgets script
        if (is_active_widget(false, false, 'pages') || is_active_widget(false, false, 'archives') || is_active_widget(false, false, 'categories') || is_active_widget(false, false, 'recent-posts') || is_active_widget(false, false, 'recent-comments') || is_active_widget(false, false, 'bbp_forums_widget') || is_active_widget(false, false, 'bbp_replies_widget') || is_active_widget(false, false, 'bbp_topics_widget') || is_active_widget(false, false, 'bbp_views_widget')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('.widget_pages, .widget_archive, .widget_categories, .widget_recent_entries, .widget_recent_comments, .widget_display_forums, .widget_display_replies, .widget_display_topics, .widget_display_views').each(function() {
					$('ul', this).addClass('fancy alt');
					$('li', this).prepend($('<i />', {'class': 'icon-right-open'}));
					if ($(this).closest('#content').length > 0) {
						$('li > .icon-right-open', this).addClass('color');
					}
				});
EOS
);
        }
        // Menu widgets script
        if (is_active_widget(false, false, 'meta') || is_active_widget(false, false, 'nav_menu')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('.widget_meta, .widget_nav_menu').each(function() {
					if ($(this).is('#content .widget')) {
						$('> div:has(> ul)', this).replaceWith(function() { return $(this).contents(); });
						$('ul:first', this).wrap('<nav class="aside-nav-menu"></nav>');
					} else {
						$('ul', this).addClass('fancy alt');
						$('li', this).prepend($('<i />', {'class': 'icon-right-open'}));
					}
				});
EOS
);
        }
        // Calendar widget
        if (is_active_widget(false, false, 'calendar')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('.widget_calendar #calendar_wrap > table').unwrap();
EOS
);
        }
        // Tag cloud widget
        if (is_active_widget(false, false, 'tag_cloud')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('.widget_tag_cloud .tagcloud').wrapInner('<div />').find('a').addClass('button small').css('font-size', '');
EOS
);
        }
        // bbPress
        if (Everything::isPluginActive('bbpress') && is_active_widget(false, false, 'bbp_replies_widget')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('.widget_display_replies li > div').addClass('small');
EOS
);
        }
        // Disqus Comment System
        if (Everything::isPluginActive('disqus')) {
            $this->addDocumentJQueryScript(<<<'EOS'
				$('#disqus_thread').addClass('section');
EOS
);
        }
        // WooCommerce
        if (Everything::isPluginActive('woocommerce')) {
            if (!is_null($color = Everything::to('woocommerce/cart/color', '__default'))) {
                $this->addDocumentStyle(sprintf(<<<'EOS'
					i.icon-woocommerce-cart {
						color: %s;
					}
EOS
, $color));
            }
            $this->addDocumentStyle(sprintf(<<<'EOS'
				.widget_price_filter .ui-slider .ui-slider-range,
				.widget_price_filter .ui-slider .ui-slider-handle {
					background-color: %s;
				}
EOS
, Everything::to('general/color')));
            if (Everything::to('woocommerce/onsale/custom')) {
                $this->addDocumentStyle(sprintf(<<<'EOS'
					.woocommerce .onsale,
					.woocommerce-page .onsale {
						background: %s;
						color: %s;
					}
EOS
, Everything::to('woocommerce/onsale/background'), Everything::to('woocommerce/onsale/color')));
            }
            if (Everything::to('woocommerce/rating/custom')) {
                $this->addDocumentStyle(sprintf(<<<'EOS'
					.woocommerce .rating i:not(.pad),
					.woocommerce-page .rating i:not(.pad) {
						color: %s;
					}
EOS
, Everything::to('woocommerce/rating/color')));
            }
            if (\Drone\Options\Option\ConditionalTags::is('account_page')) {
                $this->addDocumentJQueryScript(<<<'EOS'
					$('.woocommerce .my_account_orders .order-actions .button').addClass('small');
EOS
);
            }
        }
        // WooCommerce Brands
        if (Everything::isPluginActive('woocommerce-brands')) {
            wp_dequeue_style('brands-styles');
        }
        // WPML
        if (Everything::isPluginActive('wpml')) {
            if (is_active_widget(false, false, 'icl_lang_sel_widget')) {
                $this->addDocumentJQueryScript(<<<'EOS'
					$('.widget_icl_lang_sel_widget').each(function() {
						$('ul', this).unwrap().addClass('simple alt');
						$('img', this).addClass('icon');
					});
EOS
);
            }
        }
        // Debug
        $this->endMarker(__METHOD__);
    }
Ejemplo n.º 2
0
 public function __construct($name, $default, $properties = array())
 {
     parent::__construct($name, $default, $properties);
     $this->id->required = true;
     $this->id->on_html = function ($option, &$html) {
         $html->style('width: 140px;');
     };
     $this->size->max = 1000;
 }