/**
  * 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'));
 }
 /**
  * Enqueue Function.
  *
  * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  *
  * @since       1.0.0
  * @access      public
  * @return      void
  */
 public function enqueue()
 {
     wp_enqueue_script('redux-blockUI', $this->extension_url . '/jquery.blockUI.js', array('jquery'), time(), true);
     wp_enqueue_script('redux-field-custom_fonts-js', $this->extension_url . '/field_custom_fonts.js', array('jquery', 'redux-blockUI'), time(), true);
     wp_enqueue_style('redux-field-custom_fonts-css', $this->extension_url . 'field_custom_fonts.css', time(), true);
     $class = ReduxFramework_extension_custom_fonts::get_instance();
     if (!empty($class->custom_fonts)) {
         wp_enqueue_style('redux-custom_fonts-css', $class->upload_url . "fonts.css", time(), true);
     }
 }
Example #3
0
 /**
  * Enqueue Function.
  * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  *
  * @since       1.0.0
  * @access      public
  * @return      void
  */
 public function enqueue()
 {
     $min = Redux_Functions::isMin();
     wp_enqueue_script('redux-blockUI', $this->extension_url . '/jquery.blockUI' . $min . '.js', array('jquery'), time(), true);
     wp_enqueue_script('redux-field-custom_fonts-js', $this->extension_url . '/field_custom_fonts' . $min . '.js', array('jquery', 'redux-blockUI'), time(), true);
     if (function_exists('redux_enqueue_style')) {
         redux_enqueue_style($this->parent, 'redux-field-custom_fonts-css', $this->extension_url . 'field_custom_fonts.css', $this->extension_dir, array(), time());
     } else {
         wp_enqueue_style('redux-field-custom_fonts-css', $this->extension_url . 'field_custom_fonts.css', time(), true);
     }
     $class = ReduxFramework_extension_custom_fonts::get_instance();
     if (!empty($class->custom_fonts)) {
         wp_enqueue_style('redux-custom_fonts-css', $class->upload_url . "fonts.css", time(), true);
     }
 }
 /**
  * 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)
 {
     global $wp_filesystem;
     // Initialize the Wordpress filesystem, no more using file_put_contents function
     if (empty($wp_filesystem)) {
         require_once ABSPATH . '/wp-admin/includes/file.php';
         WP_Filesystem();
     }
     $upload = wp_upload_dir();
     $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/';
     $this->getFonts();
     if (file_exists($this->upload_dir . '/fonts.css')) {
         if (filemtime($this->upload_dir) > filemtime($this->upload_dir . '/fonts.css') + 20) {
             //echo "regen existing file";
             $this->generateCSS();
         }
     } else {
         //echo "create non existing file";
         $this->generateCSS();
     }
     $this->parent = $parent;
     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_filter("redux/{$this->parent->args['opt_name']}/field/typography/custom_fonts", array($this, 'addCustomFonts'));
     $this->dynamic_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->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'));
 }
 /**
  * Enqueue Function.
  * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
  *
  * @since       1.0.0
  * @access      public
  * @return      void
  */
 public function enqueue()
 {
     $min = Redux_Functions::isMin();
     wp_enqueue_script('redux-blockUI', $this->extension_url . '/jquery.blockUI' . $min . '.js', array('jquery'), time(), true);
     wp_enqueue_script('redux-field-custom_fonts-js', $this->extension_url . '/field_custom_fonts' . $min . '.js', array('jquery', 'redux-blockUI'), time(), true);
     wp_localize_script('redux-field-custom_fonts-js', 'redux_custom_fonts_l10', apply_filters('redux_custom_fonts_localized_data', array('delete_error' => __('There was an error deleting your font:', 'redux-framework'), 'unzip' => __('Unzipping archive and generating any missing font files.', 'redux-framework'), 'convert' => __('Converting font file(s)...', 'redux-framework'), 'partial' => __('The only file(s) imported were those uploaded.  Please refresh the page to continue (making note of any errors before doing so, please).', 'redux-framework'), 'unknown' => __('An unknown error occurred. Please try again.', 'redux-framework'), 'complete' => __('Conversion complete.  Refreshing page...', 'redux-framework'), 'media_title' => __('Choose font file or ZIP of font files.', 'redux-framework'), 'media_button' => __('Update', 'redux-framework'))));
     wp_enqueue_style('redux-field-custom_fonts-css', $this->extension_url . 'field_custom_fonts.css', array(), time(), 'all');
     $class = ReduxFramework_extension_custom_fonts::get_instance();
     if (!empty($class->custom_fonts)) {
         wp_enqueue_style('redux-custom_fonts-css', $class->upload_url . "fonts.css", array(), time(), 'all');
     }
 }