コード例 #1
0
        /**
         * Enqueue CSS/JS for options page
         *
         * @since       1.0.0
         * @access      public
         * @global      $wp_styles
         * @return      void
         */
        public function _enqueue_output()
        {
            if ($this->args['output'] == false && $this->args['compiler'] == false) {
                return;
            }
            /** @noinspection PhpUnusedLocalVariableInspection */
            foreach ($this->sections as $k => $section) {
                if (isset($section['type']) && $section['type'] == 'divide') {
                    continue;
                }
                if (isset($section['fields'])) {
                    /** @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'] = "";
                                }
                                /**
                                 * 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)) {
                                    /** @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)) {
                                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);
                                /** @noinspection PhpUndefinedMethodInspection */
                                if (isset($field['output']) && !empty($field['output']) || isset($field['compiler']) && !empty($field['compiler']) || $field['type'] == "typography") {
                                    $enqueue->output();
                                }
                            }
                        }
                    }
                }
            }
            if (!empty($this->outputCSS) && $this->args['output_tag'] == true) {
                echo '<style type="text/css" title="dynamic-css" class="options-output">' . $this->outputCSS . '</style>';
            }
            if (!empty($this->typography) && !empty($this->typography) && filter_var($this->args['output'], FILTER_VALIDATE_BOOLEAN)) {
                $version = !empty($this->options['REDUX_last_saved']) ? $this->options['REDUX_last_saved'] : '';
                $typography = new ReduxFramework_typography(null, null, $this);
                if ($this->args['async_typography'] && !empty($this->typography)) {
                    $families = array();
                    foreach ($this->typography as $key => $value) {
                        $families[] = $key;
                    }
                    ?>
                    <script>

                      /* 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.0/webfont.js';
                        wf.type = 'text/javascript';
                        wf.async = 'true';
                        var s = document.getElementsByTagName('script')[0];
                        s.parentNode.insertBefore(wf, s);
                      })();
                    </script><style>.wf-loading{visibility:hidden;}</style>
                    <?php 
                } else {
                    echo '<link rel="stylesheet" id="options-google-fonts"  href="' . $typography->makeGoogleWebfontLink($this->typography) . '&amp;v=' . $version . '" type="text/css" media="all" />';
                    //wp_register_style( 'redux-google-fonts', $typography->makeGoogleWebfontLink( $this->typography ), '', $version );
                    //wp_enqueue_style( 'redux-google-fonts' );
                }
            }
        }
コード例 #2
0
 /**
  * Enqueue CSS/JS for options page
  *
  * @since       1.0.0
  * @access      public
  * @global      $wp_styles
  * @return      void
  */
 public function _enqueue_output()
 {
     if ($this->args['output'] == false && $this->args['compiler'] == false) {
         return;
     }
     /** @noinspection PhpUnusedLocalVariableInspection */
     foreach ($this->sections as $k => $section) {
         if (isset($section['type']) && $section['type'] == 'divide') {
             continue;
         }
         if (isset($section['fields'])) {
             /** @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'] = "";
                         }
                         /**
                          * 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)) {
                             /** @noinspection PhpIncludeInspection */
                             require_once $class_file;
                         }
                     }
                     if (!empty($this->options[$field['id']]) && class_exists($field_class) && method_exists($field_class, 'output')) {
                         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);
                         /** @noinspection PhpUndefinedMethodInspection */
                         if (isset($field['output']) && !empty($field['output']) || isset($field['compiler']) && !empty($field['compiler']) || $field['type'] == "typography") {
                             $enqueue->output();
                         }
                     }
                 }
             }
         }
     }
     if (!empty($this->outputCSS) && $this->args['output_tag'] == true) {
         echo '<style type="text/css" class="options-output">' . $this->outputCSS . '</style>';
     }
     if (!empty($this->typography) && !empty($this->typography) && filter_var($this->args['output'], FILTER_VALIDATE_BOOLEAN)) {
         $version = !empty($this->options['REDUX_last_saved']) ? $this->options['REDUX_last_saved'] : '';
         $typography = new ReduxFramework_typography(null, null, $this);
         echo '<link rel="stylesheet" id="options-google-fonts"  href="' . $typography->makeGoogleWebfontLink($this->typography) . '&amp;v=' . $version . '" type="text/css" media="all" />';
         //wp_register_style( 'redux-google-fonts', $typography->makeGoogleWebfontLink( $this->typography ), '', $version );
         //wp_enqueue_style( 'redux-google-fonts' );
     }
 }
コード例 #3
0
        /**
         * Enqueue CSS and Google fonts for front end
         *
         * @since       1.0.0
         * @access      public
         * @return      void
         */
        public function _enqueue_output()
        {
            if ($this->args['output'] == false && $this->args['compiler'] == false) {
                return;
            }
            /** @noinspection PhpUnusedLocalVariableInspection */
            foreach ($this->sections as $k => $section) {
                if (isset($section['type']) && $section['type'] == 'divide') {
                    continue;
                }
                if (isset($section['fields'])) {
                    /** @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'] = "";
                                }
                                /**
                                 * 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)) {
                                    /** @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_typography(null, null, $this);
                if ($this->args['async_typography'] && !empty($this->typography)) {
                    $families = array();
                    foreach ($this->typography as $key => $value) {
                        $families[] = $key;
                    }
                    ?>
                        <script>
                            /* 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['disable_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-' . $this->args['opt_name'], $protocol . $typography->makeGoogleWebfontLink($this->typography), '', $version);
                    wp_enqueue_style('redux-google-fonts-' . $this->args['opt_name']);
                }
            }
        }
コード例 #4
0
ファイル: framework.php プロジェクト: xygcxy/iunmcf
 /**
  * Enqueue CSS and Google fonts for front end
  *
  * @since       1.0.0
  * @access      public
  * @return      void
  */
 public function _enqueue_output()
 {
     if ($this->args['output'] == false && $this->args['compiler'] == false) {
         return;
     }
     /** @noinspection PhpUnusedLocalVariableInspection */
     foreach ($this->sections as $k => $section) {
         if (isset($section['type']) && $section['type'] == 'divide') {
             continue;
         }
         if (isset($section['fields'])) {
             /** @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'] = "";
                         }
                         /**
                          * 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)) {
                             /** @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_typography(null, null, $this);
         if ($this->args['async_typography'] && !empty($this->typography)) {
             $families = array();
             foreach ($this->typography as $key => $value) {
                 $families[] = $key;
             }
         } elseif (!$this->args['disable_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-' . $this->args['opt_name'], $protocol . $typography->makeGoogleWebfontLink($this->typography), '', $version);
             wp_enqueue_style('redux-google-fonts-' . $this->args['opt_name']);
         }
     }
 }