Ejemplo n.º 1
0
 /**
  * Enqueues style for SASS comnpile or WP enqueue, depending on 'use_sass' arg.
  *
  * @since       3.3.9
  * @access      public
  * @param       string  $handle     Name of the stylesheet.
  * @param       string  $css_src    Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
  * @param       string  $scss_dir   Directory path to SCSS file.
  * @param       array   $deps       An array of registered style handles this stylesheet depends on. Default empty array.
  * @param       string  $ver        String specifying the stylesheet version number, if it has one. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the stylesheet.
  * @param       string  $media      Optional. The media for which this stylesheet has been defined. Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print', 'screen', 'tty', or 'tv'.
  * @return      void
  */
 function redux_enqueue_style($parent, $handle, $css_src, $scss_dir, $deps = array(), $ver = '', $media = false)
 {
     if ($parent->args['sass']['enabled']) {
         $path_parts = pathinfo($css_src);
         $filename = $path_parts['filename'];
         reduxSassCompiler::add_path($scss_dir);
         reduxSassCompiler::add_import('@import "' . $filename . '.scss"');
     } else {
         wp_enqueue_style($handle, $css_src, $deps, $ver, $media);
     }
 }
 /**
  * Enqueues style for SASS comnpile or WP enqueue, depending on 'use_sass' arg.
  *
  * @since       3.3.9
  * @access      public
  * @param       string  $handle     Name of the stylesheet.
  * @param       string  $css_src    Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
  * @param       string  $scss_dir   Directory path to SCSS file.
  * @param       array   $deps       An array of registered style handles this stylesheet depends on. Default empty array.
  * @param       string  $ver        String specifying the stylesheet version number, if it has one. This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the stylesheet.
  * @param       string  $media      Optional. The media for which this stylesheet has been defined. Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print', 'screen', 'tty', or 'tv'.
  * @return      void
  */
 function redux_enqueue_style($parent, $handle, $css_src, $scss_dir, $deps = array(), $ver = '', $media = false)
 {
     if ($parent->args['sass']['enabled']) {
         //if ($parent->args['dev_mode'] || $parent->args['sass']['page_output']) {
         $path_parts = pathinfo($css_src);
         $filename = $path_parts['filename'];
         $scss_dir = Redux_Helpers::cleanFilePath($scss_dir);
         $scss_dir = untrailingslashit($scss_dir);
         //$css_src = Redux_Helpers::cleanFilePath($css_src);
         //$css_src = untrailingslashit($css_src) . '/';
         //$is_diff = reduxSassCompiler::is_scss_newer($scss_dir, $filename);
         reduxSassCompiler::add_path($scss_dir);
         reduxSassCompiler::add_import('@import "' . $filename . '.scss"');
         //}
     } else {
         wp_enqueue_style($handle, $css_src, $deps, $ver, $media);
     }
 }
Ejemplo n.º 3
0
 public static function compile_sass($parent)
 {
     if (!empty(self::$path)) {
         $do_compile = false;
         $as_output = false;
         if (!self::is_sass_dir(ReduxFramework::$_upload_dir . 'sass')) {
             $as_output = true;
         }
         if ($parent->args['sass']['page_output']) {
             $as_output = true;
         }
         $mb = $parent->extensions['metaboxes'];
         if (!empty($mb->boxes)) {
             $as_output = true;
         }
         $opt_name = $parent->args['opt_name'];
         self::$matrix_file = ReduxFramework::$_upload_dir . 'sass/' . $opt_name . '-id-matrix';
         self::$matrix_key = 'redux-sass-' . $opt_name . '-id-matrix';
         if (!$as_output) {
             $current_ids = self::get_current_id_matrix($parent);
             $saved_ids = self::get_id_matrix();
             if ($saved_ids == '' || empty($saved_ids)) {
                 $ret = self::set_id_matrix($current_ids);
                 $do_compile = true;
             } else {
                 if ($current_ids != $saved_ids) {
                     logconsole('not the same');
                     self::set_id_matrix($current_ids);
                     $do_compile = true;
                 } else {
                     logconsole('the same');
                 }
             }
         } else {
             $do_compile = true;
         }
         if ($do_compile || self::$_do_compile) {
             logconsole('compiler run');
             if (!class_exists('scssc') && !isset($GLOBALS['redux_scss_compiler'])) {
                 $GLOBALS['redux_scss_compiler'] = true;
                 require "scssphp/scss.inc.php";
             }
             $scss = new scssc();
             $scss->setImportPaths(self::$path);
             if (!$parent->args['dev_mode']) {
                 $scss->setFormatter("scss_formatter_compressed");
             }
             $new_css = '';
             foreach (self::$import as $import) {
                 $new_css .= $scss->compile($import);
             }
             unset($scss);
             if ($new_css != '') {
                 if ($as_output) {
                     self::css_to_page($opt_name, $new_css);
                     return self::SASS_PAGE_OUTPUT;
                 } else {
                     $css_file = Redux_Helpers::cleanFilePath(ReduxFramework::$_upload_dir . $parent->args['opt_name'] . '-redux.css');
                     $ret = @file_put_contents($css_file, $new_css);
                     if ($ret == false) {
                         self::css_to_page($opt_name, $new_css);
                         return self::SASS_PAGE_OUTPUT;
                     }
                     return self::SASS_FILE_COMPILE;
                 }
             }
         }
         // do_compile
     }
     return self::SASS_NO_COMPILE;
 }
Ejemplo n.º 4
0
 /**
  * Enqueue CSS/JS for options page
  *
  * @since       1.0.0
  * @access      public
  * @global      $wp_styles
  * @return      void
  */
 public function _enqueue()
 {
     global $wp_styles;
     Redux_Functions::$_parent = $this;
     $min = Redux_Functions::isMin();
     // Select2 business.  Fields:  Background, Border, Dimensions, Select, Slider, Typography
     $field_arr = array('background', 'border', 'dimensions', 'select', 'select_image', 'slider', 'spacing', 'typography', 'color_scheme', 'css_layout');
     if (Redux_Helpers::isFieldInUseByType($this->fields, $field_arr)) {
         // select2 CSS
         wp_register_style('select2-css', self::$_url . 'assets/js/vendor/select2/select2.css', array(), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.css'), 'all');
         wp_enqueue_style('select2-css');
         // JS
         wp_register_script('redux-select2-sortable-js', self::$_url . 'assets/js/vendor/redux.select2.sortable' . $min . '.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor/redux.select2.sortable' . $min . '.js'), true);
         wp_register_script('select2-js', self::$_url . 'assets/js/vendor/select2/select2.min.js', array('jquery', 'redux-select2-sortable-js'), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.min.js'), true);
         wp_enqueue_script('select2-js');
     }
     redux_enqueue_style($this, 'redux-admin-css', self::$_url . 'assets/css/redux-admin.css', self::$_dir . 'assets/css/', array('farbtastic'), time(), 'all');
     //                wp_enqueue_style(
     //                    'redux-css',
     //                    self::$_url . 'assets/css/redux.css',
     //                    array( 'farbtastic' ),
     //                    filemtime( self::$_dir . 'assets/css/redux.css' ),
     //                    'all'
     //                );
     //
     //                wp_register_style(
     //                    'admin-css',
     //                    self::$_url . 'assets/css/admin.css',
     //                    array( 'farbtastic' ),
     //                    filemtime( self::$_dir . 'assets/css/admin.css' ),
     //                    'all'
     //                );
     wp_register_style('redux-elusive-icon', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont.css'), 'all');
     wp_register_style('redux-elusive-icon-ie7', self::$_url . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css', array(), filemtime(self::$_dir . 'assets/css/vendor/elusive-icons/elusive-webfont-ie7.css'), 'all');
     wp_register_style('qtip-css', self::$_url . 'assets/css/vendor/qtip/jquery.qtip.css', array(), filemtime(self::$_dir . 'assets/css/vendor/qtip/jquery.qtip.css'), 'all');
     $wp_styles->add_data('redux-elusive-icon-ie7', 'conditional', 'lte IE 7');
     /**
      * jQuery UI stylesheet src
      * filter 'redux/page/{opt_name}/enqueue/jquery-ui-css'
      *
      * @param string  bundled stylesheet src
      */
     wp_register_style('jquery-ui-css', apply_filters("redux/page/{$this->args['opt_name']}/enqueue/jquery-ui-css", self::$_url . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), '', filemtime(self::$_dir . 'assets/css/vendor/jquery-ui-bootstrap/jquery-ui-1.10.0.custom.css'), 'all');
     wp_enqueue_style('jquery-ui-css');
     wp_enqueue_style('redux-lte-ie8');
     wp_enqueue_style('qtip-css');
     wp_enqueue_style('redux-elusive-icon');
     wp_enqueue_style('redux-elusive-icon-ie7');
     if (is_rtl()) {
         wp_register_style('redux-rtl-css', self::$_url . 'assets/css/rtl.css', array('redux-css'), filemtime(self::$_dir . 'assets/css/rtl.css'), 'all');
         wp_enqueue_style('redux-rtl-css');
     }
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-dialog');
     // Load jQuery sortable for slides, sorter, sortable and group
     if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'sorter', 'sortable', 'group'))) {
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_style('jquery-ui-sortable');
     }
     // Load jQuery UI Datepicker for date
     if (Redux_Helpers::isFieldInUseByType($this->fields, array('date', 'datetime'))) {
         wp_enqueue_script('jquery-ui-datepicker');
     }
     // Load jQuery UI Accordion for slides and group
     if (Redux_Helpers::isFieldInUseByType($this->fields, array('slides', 'group'))) {
         wp_enqueue_script('jquery-ui-accordion');
     }
     // Load wp-color-picker for color, color_gradient, link_color, border, background and typography
     if (Redux_Helpers::isFieldInUseByType($this->fields, array('background', 'color', 'color_gradient', 'link_color', 'border', 'typography', 'css_layout'))) {
         redux_enqueue_style($this, 'redux-color-picker-css', ReduxFramework::$_url . 'assets/css/color-picker/color-picker.css', ReduxFramework::$_dir . 'assets/css/color-picker', array(), time(), false);
         //                    wp_enqueue_style(
         //                        'redux-color-picker-css',
         //                        self::$_url . 'assets/css/color-picker/color-picker.css',
         //                        array( 'wp-color-picker' ),
         //                        filemtime( self::$_dir . 'assets/css/color-picker/color-picker.css' ),
         //                        'all'
         //                    );
         wp_enqueue_style('color-picker-css');
         wp_enqueue_script('wp-color-picker');
         wp_enqueue_style('wp-color-picker');
     }
     if (function_exists('wp_enqueue_media')) {
         wp_enqueue_media();
     } else {
         wp_enqueue_script('media-upload');
     }
     add_thickbox();
     wp_register_script('qtip-js', self::$_url . 'assets/js/vendor/qtip/jquery.qtip.js', array('jquery'), '2.2.0', true);
     wp_register_script('serializeForm-js', self::$_url . 'assets/js/vendor/jquery.serializeForm.js', array('jquery'), '1.0.0', true);
     // Embed the compress version unless in dev mode
     // dev_mode = true
     if (isset($this->args['dev_mode']) && $this->args['dev_mode'] == true) {
         //wp_enqueue_style( 'admin-css' );
         wp_register_script('redux-vendor', self::$_url . 'assets/js/vendor.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor.min.js'), true);
         // dev_mode - false
     } else {
         //wp_enqueue_style( 'redux-css' );
     }
     $depArray = array('jquery', 'qtip-js', 'serializeForm-js');
     if (true == $this->args['dev_mode']) {
         array_push($depArray, 'redux-vendor');
     }
     wp_register_script('redux-js', self::$_url . 'assets/js/redux' . $min . '.js', $depArray, filemtime(self::$_dir . 'assets/js/redux' . $min . '.js'), true);
     foreach ($this->sections as $section) {
         if (isset($section['fields'])) {
             foreach ($section['fields'] as $field) {
                 // TODO AFTER GROUP WORKS - Revert IF below
                 // if( isset( $field['type'] ) && $field['type'] != 'callback' ) {
                 if (isset($field['type']) && $field['type'] != 'callback') {
                     $field_class = 'ReduxFramework_' . $field['type'];
                     /**
                      * Field class file
                      * filter 'redux/{opt_name}/field/class/{field.type}
                      *
                      * @param       string        field class file path
                      * @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) {
                         if (!class_exists($field_class)) {
                             if (file_exists($class_file)) {
                                 require_once $class_file;
                             }
                         }
                         if (method_exists($field_class, 'enqueue') || method_exists($field_class, 'localize')) {
                             if (!isset($this->options[$field['id']])) {
                                 $this->options[$field['id']] = "";
                             }
                             $theField = new $field_class($field, $this->options[$field['id']], $this);
                             // Move dev_mode check to a new if/then block
                             if (!wp_script_is('redux-field-' . $field['type'] . '-js', 'enqueued') && class_exists($field_class) && method_exists($field_class, 'enqueue')) {
                                 // Checking for extension field AND dev_mode = false OR dev_mode = true
                                 // Since extension fields use 'extension_dir' exclusively, we can detect them here.
                                 // Also checking for dev_mode = true doesn't mess up the JS combinine.
                                 //if ( /*$this->args['dev_mode'] === false && */ isset($theField->extension_dir) && (!'' == $theField->extension_dir) /* || ($this->args['dev_mode'] === true) */) {
                                 $theField->enqueue();
                                 //print_r($field['type']);
                                 //}
                             }
                             if (method_exists($field_class, 'localize')) {
                                 $params = $theField->localize($field);
                                 if (!isset($this->localize_data[$field['type']])) {
                                     $this->localize_data[$field['type']] = array();
                                 }
                                 $this->localize_data[$field['type']][$field['id']] = $theField->localize($field);
                             }
                             unset($theField);
                         }
                     }
                 }
             }
         }
     }
     if ($this->args['sass']['enabled']) {
         reduxSassCompiler::compile_sass($this);
         if (!$this->args['sass']['page_output']) {
             wp_enqueue_style('redux-css', ReduxFramework::$_upload_url . $this->args['opt_name'] . '-redux.css', array(), time(), 'all');
         }
     }
     $this->localize_data['required'] = $this->required;
     $this->localize_data['fonts'] = $this->fonts;
     $this->localize_data['required_child'] = $this->required_child;
     $this->localize_data['fields'] = $this->fields;
     if (isset($this->font_groups['google'])) {
         $this->localize_data['googlefonts'] = $this->font_groups['google'];
     }
     if (isset($this->font_groups['std'])) {
         $this->localize_data['stdfonts'] = $this->font_groups['std'];
     }
     if (isset($this->font_groups['customfonts'])) {
         $this->localize_data['customfonts'] = $this->font_groups['customfonts'];
     }
     $this->localize_data['folds'] = $this->folds;
     // Make sure the children are all hidden properly.
     foreach ($this->fields as $key => $value) {
         if (in_array($key, $this->fieldsHidden)) {
             foreach ($value as $k => $v) {
                 if (!in_array($k, $this->fieldsHidden)) {
                     $this->fieldsHidden[] = $k;
                     $this->folds[$k] = "hide";
                 }
             }
         }
     }
     if (isset($this->args['dev_mode']) && $this->args['dev_mode'] == true) {
         $base = admin_url('admin-ajax.php') . '?action=redux_p&url=';
         $url = $base . urlencode('http://ads.reduxframework.com/api/index.php?js&g&1&v=2') . '&proxy=' . urlencode($base);
         $this->localize_data['rAds'] = '<span data-id="1" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $url . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>';
     }
     $this->localize_data['fieldsHidden'] = $this->fieldsHidden;
     $this->localize_data['options'] = $this->options;
     $this->localize_data['defaults'] = $this->options_defaults;
     /**
      * Save pending string
      * filter 'redux/{opt_name}/localize/save_pending
      *
      * @param       string        save_pending string
      */
     $save_pending = apply_filters("redux/{$this->args['opt_name']}/localize/save_pending", __('You have changes that are not saved. Would you like to save them now?', 'redux-framework'));
     /**
      * Reset all string
      * filter 'redux/{opt_name}/localize/reset
      *
      * @param       string        reset all string
      */
     $reset_all = apply_filters("redux/{$this->args['opt_name']}/localize/reset", __('Are you sure? Resetting will lose all custom values.', 'redux-framework'));
     /**
      * Reset section string
      * filter 'redux/{opt_name}/localize/reset_section
      *
      * @param       string        reset section string
      */
     $reset_section = apply_filters("redux/{$this->args['opt_name']}/localize/reset_section", __('Are you sure? Resetting will lose all custom values in this section.', 'redux-framework'));
     /**
      * Preset confirm string
      * filter 'redux/{opt_name}/localize/preset
      *
      * @param       string        preset confirm string
      */
     $preset_confirm = apply_filters("redux/{$this->args['opt_name']}/localize/preset", __('Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework'));
     global $pagenow;
     $this->localize_data['args'] = array('save_pending' => $save_pending, 'reset_confirm' => $reset_all, 'reset_section_confirm' => $reset_section, 'preset_confirm' => $preset_confirm, 'please_wait' => __('Please Wait', 'redux-framework'), 'opt_name' => $this->args['opt_name'], 'slug' => $this->args['page_slug'], 'hints' => $this->args['hints'], 'disable_save_warn' => $this->args['disable_save_warn'], 'class' => $this->args['class'], 'menu_search' => $pagenow . '?page=' . $this->args['page_slug'] . "&tab=");
     // Construct the errors array.
     if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['errors'])) {
         $theTotal = 0;
         $theErrors = array();
         foreach ($this->transients['notices']['errors'] as $error) {
             $theErrors[$error['section_id']]['errors'][] = $error;
             if (!isset($theErrors[$error['section_id']]['total'])) {
                 $theErrors[$error['section_id']]['total'] = 0;
             }
             $theErrors[$error['section_id']]['total']++;
             $theTotal++;
         }
         $this->localize_data['errors'] = array('total' => $theTotal, 'errors' => $theErrors);
         unset($this->transients['notices']['errors']);
     }
     // Construct the warnings array.
     if (isset($this->transients['last_save_mode']) && !empty($this->transients['notices']['warnings'])) {
         $theTotal = 0;
         $theWarnings = array();
         foreach ($this->transients['notices']['warnings'] as $warning) {
             $theWarnings[$warning['section_id']]['warnings'][] = $warning;
             if (!isset($theWarnings[$warning['section_id']]['total'])) {
                 $theWarnings[$warning['section_id']]['total'] = 0;
             }
             $theWarnings[$warning['section_id']]['total']++;
             $theTotal++;
         }
         unset($this->transients['notices']['warnings']);
         $this->localize_data['warnings'] = array('total' => $theTotal, 'warnings' => $theWarnings);
     }
     if (empty($this->transients['notices'])) {
         unset($this->transients['notices']);
     }
     // Values used by the javascript
     wp_localize_script('redux-js', 'redux', $this->localize_data);
     wp_enqueue_script('redux-js');
     // Enque the JS now
     wp_enqueue_script('webfontloader', 'https://ajax.googleapis.com/ajax/libs/webfont/1.5.0/webfont.js', array('jquery'), '1.5.0', true);
     /**
      * action 'redux-enqueue-{opt_name}'
      *
      * @deprecated
      *
      * @param  object $this ReduxFramework
      */
     do_action("redux-enqueue-{$this->args['opt_name']}", $this);
     // REMOVE
     /**
      * action 'redux/page/{opt_name}/enqueue'
      */
     do_action("redux/page/{$this->args['opt_name']}/enqueue");
 }
Ejemplo n.º 5
0
 public static function compile_single_field($parent, $scss_path, $filename)
 {
     self::$parent = $parent;
     echo 'single field compile: ' . $scss_path . ' ' . $filename;
     if (!class_exists('scssc') && !isset($GLOBALS['redux_scss_compiler'])) {
         $GLOBALS['redux_scss_compiler'] = true;
         require_once "scssphp/scss.inc.php";
     }
     $scss = new scssc();
     $scss->setImportPaths($scss_path);
     if (!$parent->args['dev_mode']) {
         $scss->setFormatter("scss_formatter_compressed");
     }
     $new_css = $scss->compile('@import "' . $filename . '.scss"');
     unset($scss);
     self::$parent->filesystem->execute('put_contents', $scss_path . '/' . $filename . '.css', array('content' => $new_css));
 }