. * * @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' ) ) { /** * Main ReduxFramework_slides class * * @since 1.0.0 */ class ReduxFramework_slides { /** * 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 * @return void */ function __construct ( $field = array(), $value = '', $parent ) { $this->parent = $parent; $this->field = $field; $this->value = $value; } /** * Field Render Function. * Takes the vars and outputs the HTML for the field in the settings * * @since 1.0.0 * @access public * @return void */ public function render () { $defaults = array( 'show' => array( 'title' => true, 'description' => true, 'url' => true, ), 'content_title' => __ ( 'Slide', 'redux-framework' ) ); $this->field = wp_parse_args ( $this->field, $defaults ); echo '
'; $x = 0; $multi = ( isset ( $this->field[ 'multi' ] ) && $this->field[ 'multi' ] ) ? ' multiple="multiple"' : ""; if ( isset ( $this->value ) && is_array ( $this->value ) && !empty ( $this->value ) ) { $slides = $this->value; foreach ( $slides as $slide ) { if ( empty ( $slide ) ) { continue; } $defaults = array( 'title' => '', 'description' => '', 'sort' => '', 'url' => '', 'image' => '', 'thumb' => '', 'attachment_id' => '', 'height' => '', 'width' => '', 'select' => array(), ); $slide = wp_parse_args ( $slide, $defaults ); if ( empty ( $slide[ 'thumb' ] ) && !empty ( $slide[ 'attachment_id' ] ) ) { $img = wp_get_attachment_image_src ( $slide[ 'attachment_id' ], 'full' ); $slide[ 'image' ] = $img[ 0 ]; $slide[ 'width' ] = $img[ 1 ]; $slide[ 'height' ] = $img[ 2 ]; } echo '

' . $slide[ 'title' ] . '

'; $hide = ''; if ( empty ( $slide[ 'image' ] ) ) { $hide = ' hide'; } echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo '' . __ ( 'Upload', 'redux-framework' ) . ''; $hide = ''; if ( empty ( $slide[ 'image' ] ) || $slide[ 'image' ] == '' ) { $hide = ' hide'; } echo '' . __ ( 'Remove', 'redux-framework' ) . ''; echo '
' . "\n"; echo '
    '; if ( $this->field[ 'show' ][ 'title' ] ) { $title_type = "text"; } else { $title_type = "hidden"; } $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'title' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'title' ] ) : __ ( 'Title', 'redux-framework' ); echo '
  • '; if ( $this->field[ 'show' ][ 'description' ] ) { $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' ); echo '
  • '; } $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'url' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'url' ] ) : __ ( 'URL', 'redux-framework' ); if ( $this->field[ 'show' ][ 'url' ] ) { $url_type = "text"; } else { $url_type = "hidden"; } echo '
  • '; echo '
  • '; echo '
  • '; echo ''; echo ''; echo ''; echo '
  • '; echo '
  • ' . sprintf ( __ ( 'Delete %s', 'redux-framework' ), $this->field[ 'content_title' ] ) . '
  • '; echo '
'; $x ++; } } if ( $x == 0 ) { echo '

New ' . $this->field[ 'content_title' ] . '

'; $hide = ' hide'; echo '
'; echo ''; echo ''; echo ''; echo '
'; //Upload controls DIV echo '
'; //If the user has WP3.5+ show upload/remove button echo '' . __ ( 'Upload', 'redux-framework' ) . ''; echo '' . __ ( 'Remove', 'redux-framework' ) . ''; echo '
' . "\n"; echo '
    '; if ( $this->field[ 'show' ][ 'title' ] ) { $title_type = "text"; } else { $title_type = "hidden"; } $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'title' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'title' ] ) : __ ( 'Title', 'redux-framework' ); echo '
  • '; if ( $this->field[ 'show' ][ 'description' ] ) { $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' ); echo '
  • '; } $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'url' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'url' ] ) : __ ( 'URL', 'redux-framework' ); if ( $this->field[ 'show' ][ 'url' ] ) { $url_type = "text"; } else { $url_type = "hidden"; } echo '
  • '; echo '
  • '; echo '
  • '; echo ''; echo ''; echo '
  • '; echo ''; echo '
  • ' . sprintf ( __ ( 'Delete %s', 'redux-framework' ), $this->field[ 'content_title' ] ) . '
  • '; echo '
'; } echo '
' . sprintf ( __ ( 'Add %s', 'redux-framework' ), $this->field[ 'content_title' ] ) . '
'; } /** * 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 . 'assets/js/media/media' . Redux_Functions::isMin() . '.js', array( 'jquery', 'redux-js' ), time(), true ); wp_enqueue_style ( 'redux-field-media-css', ReduxFramework::$_url . 'inc/fields/media/field_media.css', time (), true ); wp_enqueue_script ( 'redux-field-slides-js', ReduxFramework::$_url . 'inc/fields/slides/field_slides' . Redux_Functions::isMin () . '.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'wp-color-picker', 'redux-field-media-js' ), time (), true ); wp_enqueue_style ( 'redux-field-slides-css', ReduxFramework::$_url . 'inc/fields/slides/field_slides.css', time (), true ); } } }