/**
  * Class Constructor. Defines the args for the extions class
  *
  * @since       1.0.0
  * @access      public
  *
  * @param       array $sections Panel sections.
  * @param       array $args Class constructor arguments.
  * @param       array $extra_tabs Extra panel tabs.
  *
  * @return      void
  */
 public function __construct($parent)
 {
     $this->parent = $parent;
     if (empty($this->extension_dir)) {
         //$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
     }
     $this->field_name = 'options_object';
     self::$theInstance = $this;
     $this->is_field = Redux_Helpers::isFieldInUse($parent, 'options_object');
     if (!$this->is_field && $this->parent->args['dev_mode'] && $this->parent->args['show_options_object']) {
         $this->add_section();
     }
     add_filter('redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(&$this, 'overload_field_path'));
     // Adds the local field
 }
 /**
  * Class Constructor. Defines the args for the extions class
  *
  * @since       1.0.0
  * @access      public
  *
  * @param       array $sections   Panel sections.
  * @param       array $args       Class constructor arguments.
  * @param       array $extra_tabs Extra panel tabs.
  *
  * @return      void
  */
 public function __construct($parent)
 {
     $this->parent = $parent;
     if (empty($this->extension_dir)) {
         //$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
     }
     $this->field_name = 'import_export';
     self::$theInstance = $this;
     add_action("wp_ajax_redux_link_options-" . $this->parent->args['opt_name'], array($this, "link_options"));
     add_action("wp_ajax_nopriv_redux_link_options-" . $this->parent->args['opt_name'], array($this, "link_options"));
     add_action("wp_ajax_redux_download_options-" . $this->parent->args['opt_name'], array($this, "download_options"));
     add_action("wp_ajax_nopriv_redux_download_options-" . $this->parent->args['opt_name'], array($this, "download_options"));
     do_action("redux/options/{$this->parent->args['opt_name']}/import", array($this, 'remove_cookie'));
     $this->is_field = Redux_Helpers::isFieldInUse($parent, 'import_export');
     if (!$this->is_field && $this->parent->args['show_import_export']) {
         $this->add_section();
     }
     add_filter('redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(&$this, 'overload_field_path'));
     // Adds the local field
     add_filter('upload_mimes', array($this, 'custom_upload_mimes'));
 }
Exemple #3
0
 public function in_field()
 {
     $this->is_field = Redux_Helpers::isFieldInUse($this->parent, 'import_export');
 }
Exemple #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;
     wp_register_style('redux-css', self::$_url . 'assets/css/redux.css', array('farbtastic'), filemtime(self::$_dir . 'assets/css/redux.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('select2-css', self::$_url . 'assets/js/vendor/select2/select2.css', array(), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.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_register_style('nouislider-css', self::$_url . 'assets/css/vendor/nouislider/jquery.nouislider.css', array(), filemtime(self::$_dir . 'assets/css/vendor/nouislider/jquery.nouislider.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('redux-css');
     wp_enqueue_style('select2-css');
     wp_enqueue_style('nouislider-css');
     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', '', 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-sortable');
     wp_enqueue_style('jquery-ui-sortable');
     wp_enqueue_script('jquery-ui-datepicker');
     wp_enqueue_script('jquery-ui-dialog');
     wp_enqueue_script('jquery-ui-slider');
     wp_enqueue_script('wp-color-picker');
     wp_enqueue_script('jquery-ui-accordion');
     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('select2-js', self::$_url . 'assets/js/vendor/select2/select2.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor/select2/select2.min.js'), true);
     wp_register_script('qtip-js', self::$_url . 'assets/js/vendor/qtip/jquery.qtip.js', array('jquery'), '2.2.0', true);
     wp_register_script('nouislider-js', self::$_url . 'assets/js/vendor/nouislider/jquery.nouislider.min.js', array('jquery'), '5.0.0', true);
     wp_register_script('serializeForm-js', self::$_url . 'assets/js/vendor/jquery.serializeForm.js', array('jquery'), '1.0.0', true);
     // Register ACE if it's being used
     $ace_prereq = null;
     if (Redux_Helpers::isFieldInUse($this, 'ace_editor')) {
         $ace_prereq = 'ace-editor-js';
         wp_enqueue_script($ace_prereq, self::$_url . 'assets/js/vendor/ace_editor/ace.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor/ace_editor/ace.js'), true);
     }
     // default JS dependency aarray
     $arrEnq = array('jquery', 'select2-js', 'qtip-js', 'nouislider-js', 'serializeForm-js');
     // Embed the compress version unless in dev mode
     // dev_mode = true
     if (isset($this->args['dev_mode']) && $this->args['dev_mode'] === true) {
         wp_register_script('redux-vendor', self::$_url . 'assets/js/vendor.min.js', array('jquery'), filemtime(self::$_dir . 'assets/js/vendor.min.js'), true);
         // push redux-cendor into dep array
         $arrDev = $arrEnq;
         array_push($arrDev, 'redux-vendor');
         // If ACE is loaded, push in into the dep array
         if ('' != $ace_prereq) {
             array_push($arrDev, $ace_prereq);
         }
         wp_register_script('redux-js', self::$_url . 'assets/js/redux.js', $arrDev, filemtime(self::$_dir . 'assets/js/redux.js'), true);
         // dev_mode - false
     } else {
         // If ACE loaded, push into the dep array
         $arrProd = $arrEnq;
         if ('' != $ace_prereq) {
             array_push($arrProd, $ace_prereq);
         }
         if (file_exists(self::$_dir . 'assets/js/redux.min.js')) {
             wp_register_script('redux-js', self::$_url . 'assets/js/redux.min.js', $arrProd, 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['type'] != 'group') {
                     //if ('typography' == $field['type']) {
                     //continue;
                     //}
                     $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)) {
                             /** @noinspection PhpIncludeInspection */
                             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) {
                                     /** @noinspection PhpUndefinedMethodInspection */
                                     $theField->enqueue();
                                 }
                             }
                             if (method_exists($field_class, 'localize')) {
                                 /** @noinspection PhpUndefinedMethodInspection */
                                 $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);
                         }
                     }
                 }
             }
         }
     }
     $this->localize_data['required'] = $this->required;
     $this->localize_data['required_child'] = $this->required_child;
     $this->localize_data['fields'] = $this->fields;
     $this->localize_data['fonts'] = $this->fonts;
     $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";
                 }
             }
         }
     }
     $this->localize_data['fieldsHidden'] = $this->fieldsHidden;
     $this->localize_data['options'] = $this->options;
     $this->localize_data['defaults'] = $this->options_defaults;
     $this->localize_data['args'] = array('save_pending' => __('You have changes that are not saved. Would you like to save them now?', 'redux-framework'), 'reset_confirm' => __('Are you sure? Resetting will lose all custom values.', 'redux-framework'), 'reset_section_confirm' => __('Are you sure? Resetting will lose all custom values in this section.', 'redux-framework'), 'preset_confirm' => __('Your current options will be replaced with the values of this preset. Would you like to proceed?', 'redux-framework'), 'please_wait' => __('Please Wait', 'redux-framework'), 'opt_name' => $this->args['opt_name'], 'slug' => $this->args['page_slug'], 'hints' => $this->args['hints']);
     $notices = array();
     if (isset($_COOKIE['redux-notices-' . $this->args['opt_name']])) {
         $notices = get_transient('redux-notices-' . $this->args['opt_name']);
         setcookie('redux-notices-' . $this->args['opt_name'], 1, time() - 3600, "/");
     }
     // Construct the errors array.
     if ($this->saved && !empty($notices['errors'])) {
         $theTotal = 0;
         $theErrors = array();
         foreach ($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);
     }
     // Construct the warnings array.
     if ($this->saved && !empty($notices['warnings'])) {
         $theTotal = 0;
         $theWarnings = array();
         foreach ($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++;
         }
         $this->localize_data['warnings'] = array('total' => $theTotal, 'warnings' => $theWarnings);
     }
     // 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");
 }
 /**
  * Class Constructor. Defines the args for the extions class
  *
  * @since       1.0.0
  * @access      public
  *
  * @param       array $sections   Panel sections.
  * @param       array $args       Class constructor arguments.
  * @param       array $extra_tabs Extra panel tabs.
  *
  * @return      void
  */
 public function __construct($parent)
 {
     $this->parent = $parent;
     $this->filesystem = $this->parent->filesystem->execute('object');
     $this->upload_dir = ReduxFramework::$_upload_dir . 'custom-fonts/';
     // $upload['basedir'] . '/redux_custom_fonts/';
     $this->upload_url = ReduxFramework::$_upload_url . 'custom-fonts/';
     // $upload['baseurl'] . '/redux_custom_fonts/';
     //echo substr(sprintf('%o', fileperms($this->upload_dir )), -4);
     $this->getFonts();
     if (file_exists($this->upload_dir . 'fonts.css')) {
         if (filemtime($this->upload_dir . 'custom') > filemtime($this->upload_dir . 'fonts.css') + 10) {
             //echo "regen existing file";
             $this->generateCSS();
         }
     } else {
         //echo "create non existing file";
         $this->generateCSS();
     }
     if (empty($this->extension_dir)) {
         $this->extension_dir = trailingslashit(str_replace('\\', '/', dirname(__FILE__)));
     }
     $this->field_name = 'custom_fonts';
     self::$theInstance = $this;
     // Adds the local field
     add_filter('redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(&$this, 'overload_field_path'));
     add_action('wp_ajax_redux_custom_fonts', array($this, 'ajax'));
     //$this->ajax();
     //add_action( 'wp_ajax_nopriv_redux_custom_fonts', array(
     //    $this,
     //    'ajax'
     //) );
     add_filter("redux/{$this->parent->args['opt_name']}/field/typography/custom_fonts", array($this, 'addCustomFonts'));
     $this->is_field = Redux_Helpers::isFieldInUse($parent, 'custom_fonts');
     if (!$this->is_field) {
         $this->add_section();
     }
     //require_once 'System.php'; // Wordpress core file
     //if ( class_exists('System') === true ) {
     add_filter('upload_mimes', array($this, 'custom_upload_mimes'));
     //}
     add_action('wp_head', array($this, '_enqueue_output'), 150);
     add_filter('tiny_mce_before_init', array($this, 'extend_tinymce_dropdown'));
 }
 /**
  * Class Constructor. Defines the args for the extions class
  *
  * @since       1.0.0
  * @access      public
  *
  * @param       array $sections   Panel sections.
  * @param       array $args       Class constructor arguments.
  * @param       array $extra_tabs Extra panel tabs.
  *
  * @return      void
  */
 public function __construct($parent)
 {
     $this->parent = $parent;
     $this->upload_dir = ReduxFramework::$_upload_dir . 'custom-fonts/';
     $this->upload_url = ReduxFramework::$_upload_url . 'custom-fonts/';
     if (!is_dir($this->upload_dir)) {
         $this->parent->filesystem->execute('mkdir', $this->upload_dir);
     }
     if (!is_dir($this->upload_dir . '/custom')) {
         $this->parent->filesystem->execute('mkdir', $this->upload_dir . '/custom');
     }
     $this->getFonts();
     if (file_exists($this->upload_dir . 'fonts.css')) {
         if (filemtime($this->upload_dir . 'custom') > filemtime($this->upload_dir . 'fonts.css') + 10) {
             $this->generateCSS();
         }
     } else {
         $this->generateCSS();
     }
     if (empty($this->extension_dir)) {
         $this->extension_dir = trailingslashit(str_replace('\\', '/', dirname(__FILE__)));
     }
     $this->field_name = 'custom_fonts';
     self::$theInstance = $this;
     // Adds the local field
     add_filter('redux/' . $this->parent->args['opt_name'] . '/field/class/' . $this->field_name, array(&$this, 'overload_field_path'));
     add_action('wp_ajax_redux_custom_fonts', array($this, 'ajax'));
     add_action('wp_ajax_redux_custom_font_timer', array($this, 'timer'));
     add_filter("redux/{$this->parent->args['opt_name']}/field/typography/custom_fonts", array($this, 'addCustomFonts'));
     $this->is_field = Redux_Helpers::isFieldInUse($parent, 'custom_fonts');
     if (!$this->is_field) {
         $this->add_section();
     }
     //$this->dynamic_section();
     add_filter("redux/options/{$this->parent->args['opt_name']}/section/redux_dynamic_font_control", array($this, 'remove_dynamic_section'));
     add_filter('upload_mimes', array($this, 'custom_upload_mimes'));
     add_action('wp_head', array($this, '_enqueue_output'), 150);
     add_filter('tiny_mce_before_init', array($this, 'extend_tinymce_dropdown'));
 }