Example #1
0
/*  for PRO users! -  @var array $families */
/*  for PRO users! - *
 * Overwrite families with those served by redux ... they can give us fonts with all-styles included
 */
if (class_exists('ReduxFramework_customizer_typography')) {
    global $redux;
    $typography = new ReduxFramework_customizer_typography(null, null, $redux);
    // on customizer overwrite options
    // @TODO Refactor this somewhere else
    if (isset($_POST['customized'])) {
        $typography2 = false;
        foreach ($fonts_array as $font) {
            if (wpgrade::customizer_option_exists($font)) {
                $this_font = wpgrade::get_customizer_option($font);
                // Regenerate the font-list on customizer page
                $typography2 = new ReduxFramework_customizer_typography(array('google' => 1), $this_font, $redux);
                ob_start();
                $typography2->output();
                $to_be_deleted = ob_get_clean();
                unset($to_be_deleted);
                // we actually don't need this variable
            }
        }
    }
    if (!empty($typography->parent->typography)) {
        $families = $typography->makeGoogleWebfontString($typography->parent->typography);
        if (!empty($families)) {
            ?>
			<script type="text/javascript">
				WebFont.load({google: {families: [<?php 
            echo $families;
Example #2
0
        public function _enqueue_output()
        {
            if ($this->args['output'] == false && $this->args['compiler'] == false) {
                return;
            }
            /*  for PRO users! - * @noinspection PhpUnusedLocalVariableInspection */
            foreach ($this->sections as $k => $section) {
                if (isset($section['type']) && $section['type'] == 'divide') {
                    continue;
                }
                if (isset($section['fields'])) {
                    /*  for PRO users! - * @noinspection PhpUnusedLocalVariableInspection */
                    foreach ($section['fields'] as $fieldk => $field) {
                        if (isset($field['type']) && $field['type'] != "callback") {
                            $field_class = "ReduxFramework_{$field['type']}";
                            if (!class_exists($field_class)) {
                                if (!isset($field['compiler'])) {
                                    $field['compiler'] = "";
                                }
                                /*  for PRO users! - *
                                 * Field class file
                                 * filter 'redux/{opt_name}/field/class/{field.type}
                                 *
                                 * @param       string        field class file
                                 * @param array $field        field config data
                                 */
                                $class_file = apply_filters("redux/{$this->args['opt_name']}/field/class/{$field['type']}", self::$_dir . "inc/fields/{$field['type']}/field_{$field['type']}.php", $field);
                                if ($class_file && file_exists($class_file) && !class_exists($field_class)) {
                                    /*  for PRO users! - * @noinspection PhpIncludeInspection */
                                    require_once $class_file;
                                }
                            }
                            if (!empty($this->options[$field['id']]) && class_exists($field_class) && method_exists($field_class, 'output') && $this->_can_output_css($field)) {
                                $field = apply_filters("redux/field/{$this->args['opt_name']}/output_css", $field);
                                if (!empty($field['output']) && !is_array($field['output'])) {
                                    $field['output'] = array($field['output']);
                                }
                                $value = isset($this->options[$field['id']]) ? $this->options[$field['id']] : '';
                                $enqueue = new $field_class($field, $value, $this);
                                if (isset($field['output']) && !empty($field['output']) || isset($field['compiler']) && !empty($field['compiler']) || $field['type'] == "typography" || $field['type'] == "icon_select") {
                                    $enqueue->output();
                                }
                            }
                        }
                    }
                }
            }
            // For use like in the customizer. Stops the output, but passes the CSS in the variable for the compiler
            if (isset($this->no_output)) {
                return;
            }
            if (!empty($this->typography) && !empty($this->typography) && filter_var($this->args['output'], FILTER_VALIDATE_BOOLEAN)) {
                $version = !empty($this->transients['last_save']) ? $this->transients['last_save'] : '';
                $typography = new ReduxFramework_customizer_typography(null, null, $this);
                if ($this->args['async_typography'] && !empty($this->typography)) {
                    $families = array();
                    foreach ($this->typography as $key => $value) {
                        $families[] = $key;
                    }
                    ?>
                        <script>
                            /*  for PRO users! -  You can add more configuration options to webfontloader by previously defining the WebFontConfig with your options */
                            if ( typeof WebFontConfig === "undefined" ) {
                                WebFontConfig = new Object();
                            }
                            WebFontConfig['google'] = {families: [<?php 
                    echo $typography->makeGoogleWebfontString($this->typography);
                    ?>
]};

                            (function() {
                                var wf = document.createElement( 'script' );
                                wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.5.3/webfont.js';
                                wf.type = 'text/javascript';
                                wf.async = 'true';
                                var s = document.getElementsByTagName( 'script' )[0];
                                s.parentNode.insertBefore( wf, s );
                            })();
                        </script>
                    <?php 
                } elseif ($this->args['google_fonts_link']) {
                    $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https:" : "http:";
                    //echo '<link rel="stylesheet" id="options-google-fonts" title="" href="'.$protocol.$typography->makeGoogleWebfontLink( $this->typography ).'&amp;v='.$version.'" type="text/css" media="all" />';
                    wp_register_style('redux-google-fonts', $protocol . $typography->makeGoogleWebfontLink($this->typography), '', $version);
                    wp_enqueue_style('redux-google-fonts');
                }
            }
        }