. * * @package ReduxFramework * @subpackage Field_slides * @author Luciano "WebCaos" Ubertini * @author Daniel J Griffiths (Ghost1227) * @author Dovy Paukstys * @version 3.0.0 */ // Exit if accessed directly if (!defined('ABSPATH')) exit; // Don't duplicate me! if (!class_exists('ReduxFramework_slides_html')) { /** * Main ReduxFramework_slides_html class * * @since 1.0.0 */ class ReduxFramework_slides_html extends widget_handler{ var $titles = array(); var $field_id = ""; /** * Field Constructor. * * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function * * @since 1.0.0 * @access public * @param array $field * @param string $value * @param $parent * @return \ReduxFramework_slides_html */ function __construct( $field = array(), $value ='', $parent ) { parent::__construct($field,$value,$parent); $this->field_id = $this->field['id']; $default_titles = array( "add_slider" => "Add Slider", "add_slide" => "Add Slide", "remove_slider" => "Delete Slider", "remove_slide" => "Delete Slide", "new_slide" => "New item", ); if(!isset($this->field['titles']) || !is_array($this->field['titles'])) $this->field['titles'] = array(); $this->titles = wp_parse_args($this->field['titles'],$default_titles); include_once(ReduxFramework::$_dir. "inc/fields/editor/field_editor.php"); $this->editor_args = array( 'id' => $this->field['id'], 'name' => $this->field['id'], 'name_suffix' => '', 'class' => '', 'type' => 'editor', 'title' => __('HTML', 'redux-framework-demo'), 'subtitle' => __('', 'redux-framework-demo'), 'default' => 'Enter html code here', 'args' => array( 'teeny' => true, 'textarea_rows' => 10 ) ); $this->enqueue(); } public function blank_slider(){ } /** * Field Render Function. * * Takes the vars and outputs the HTML for the field in the settings * * @since 1.0.0 * @access public * @param bool $hidden * @return void */ public function render($hidden = false) { $this->blank_slider(); $x = 0; if(!isset($this->value['items']) || empty($this->value['items'])){ $this->value['items'] = array('1'=>array()); }else if(isset($this->value['items']['_blank'])) unset($this->value['items']['_blank']); $filed_name = $this->field['name']; echo '
'; $this->field['name']=$filed_name.'[slides]'; if (isset($this->value['slides']) && is_array($this->value['slides']) && !$hidden) { $slides = $this->value['slides']; foreach ($slides as $slide) { if ( empty( $slide ) ) { continue; } $defaults = array( 'title' => '', 'click_action' => '', 'sort' => '', 'products'=>'', 'click_action_value' => '', 'image' => '', 'thumb' => '', 'attachment_id' => '', 'height' => '', 'width' => '', 'select' => array(), ); $slide = wp_parse_args( $slide, $defaults ); echo '

' . $slide['title'] . '

'; echo '
    '; $placeholder = (isset($this->field['placeholder']['title'])) ? esc_attr($this->field['placeholder']['title']) : __( 'Title', 'redux-framework' ); echo '
  • '; echo '
  • '; $args = array("id"=>$this->field['id']."-content-".$x,"name"=>$this->field['name'] . '[' . $x . '][content]'); $args = wp_parse_args($args,$this->editor_args); $slide['content'] = isset($slide['content'])?$slide['content']:''; $editor = new ReduxFramework_editor($args,$slide['content'],$this->parent); $editor->render(); echo '
  • '; echo '
  • '; echo '
  • ' . __($this->titles['remove_slider'], 'redux-framework') . '
  • '; echo '
'; $x++; } } if ($x == 0) { echo '

'. __($this->titles['new_slide'], 'redux-framework').'

'; echo '
    '; $placeholder = (isset($this->field['placeholder']['title'])) ? esc_attr($this->field['placeholder']['title']) : __( 'Title', 'redux-framework' ); echo '
  • '; echo '
  • '; $args = array("id"=>$this->field['id']."-content-".$x,"name"=>$this->field['name'] . '[' . $x . '][content]'); $args = wp_parse_args($args,$this->editor_args); $editor = new ReduxFramework_editor($args,'',$this->parent); $editor->render(); echo '
  • '; echo '
  • '; echo '
  • '. __($this->titles['remove_slider'], 'redux-framework').'
  • '; echo '
'; } echo '
' . __($this->titles['add_slider'], 'redux-framework') . '
'; } /** * 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-field-media-js', ReduxFramework::$_url . 'inc/fields/media/field_media.js', array( 'jquery' ), time(), true ); wp_enqueue_style( 'redux-field-media-css', ReduxFramework::$_url . 'inc/fields/media/field_media.css', time(), true ); wp_enqueue_script( 'redux-field-slideshow-js', plugins_url('field_slides.js',__FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'wp-color-picker'), time(), true ); wp_enqueue_style( 'redux-field-slideshow-css', plugins_url('field_slides.css',__FILE__), time(), true ); Redux_CDN::enqueue_script( 'select2-js', '//cdn.jsdelivr.net/select2/3.5.2/select2.min.js', array( 'jquery', 'redux-select2-sortable-js' ), '3.5.2', true ); /* wp_enqueue_script( 'select2-js', ReduxFramework::$_url . 'assets/js/vendor/select2/select2.js', array( ), time(), true ); wp_enqueue_script( 'select2-sortable-js', ReduxFramework::$_url . 'assets/js/vendor/select2.sortable.js', array( ), time(), true ); */ wp_enqueue_script( 'field-select-js', ReduxFramework::$_url . 'inc/fields/select/field_select.js', array( ), time(), true ); parent::enqueue(); } } }