.
*
* @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 '
';
$x ++;
}
}
if ( $x == 0 ) {
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 () {
if ( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
} else {
wp_enqueue_script( 'media-upload' );
}
if ($this->parent->args['dev_mode']){
wp_enqueue_style ('redux-field-media-css');
wp_enqueue_style (
'redux-field-slides-css',
ReduxFramework::$_url . 'inc/fields/slides/field_slides.css',
array(),
time (),
'all'
);
}
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_script (
'redux-field-slides-js',
ReduxFramework::$_url . 'inc/fields/slides/field_slides' . Redux_Functions::isMin () . '.js',
array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-sortable', 'redux-field-media-js' ),
time (),
true
);
}
}
}