array( 'title' => true, 'description' => true, 'url' => true, ), 'content_title' => esc_html__( 'Slide', 'redux-framework' ), ); $this->field = wp_parse_args( $this->field, $defaults ); } /** * 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() { // translators: New accordion title. echo '
'; $x = 0; if ( 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 '

' . esc_html( $slide['title'] ) . '

'; $hide = ''; if ( empty( $slide['image'] ) ) { $hide = ' hide'; } $alt = wp_prepare_attachment_for_js( $slide['attachment_id'] ); $alt = $alt['alt'] ?? ''; echo '
'; echo ''; echo '' . esc_attr( $alt ) . ''; echo ''; echo '
'; echo '
'; echo '' . esc_html__( 'Upload', 'redux-framework' ) . ''; $hide = ''; if ( empty( $slide['image'] ) ) { $hide = ' hide'; } echo '' . esc_html__( '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 '
  • '; echo ''; echo '
  • '; if ( $this->field['show']['description'] ) { $placeholder = ( isset( $this->field['placeholder']['description'] ) ) ? esc_attr( $this->field['placeholder']['description'] ) : __( 'Description', 'redux-framework' ); echo '
  • '; echo ''; 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 ''; echo ''; echo ''; echo '
  • '; echo ''; echo ''; echo '
  • '; echo '' . esc_html__( 'Delete', 'redux-framework' ) . ''; echo '
  • '; echo '
'; echo '
'; echo '
'; echo '
'; ++$x; } } if ( 0 === $x ) { echo '
'; echo '
'; echo '

'; // translators: Content title for new accordion. echo '' . esc_html( sprintf( __( 'New %s', 'redux-framework' ), esc_attr( $this->field['content_title'] ) ) ) . ''; echo '

'; echo '
'; $hide = ' hide'; echo '
'; echo ''; echo 'placeholder'; echo ''; echo '
'; // Upload controls DIV. echo '
'; // If the user has WP3.5+ show upload/remove button. echo '' . esc_html__( 'Upload', 'redux-framework' ) . ''; echo '' . esc_html__( '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 '
  • '; echo ''; echo '
  • '; if ( $this->field['show']['description'] ) { $placeholder = ( isset( $this->field['placeholder']['description'] ) ) ? esc_attr( $this->field['placeholder']['description'] ) : __( 'Description', 'redux-framework' ); echo '
  • '; echo ''; 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 ''; echo ''; echo ''; echo '
  • '; echo ''; echo ''; echo '
  • '; echo '' . esc_html__( 'Delete', 'redux-framework' ) . ''; echo '
  • '; echo '
'; echo '
'; echo '
'; echo '
'; } echo '
'; // translators: Content title for accordion. echo '' . esc_html( sprintf( __( 'Add %s', 'redux-framework' ), esc_html( $this->field['content_title'] ) ) ) . ''; echo '
'; } /** * 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' ); wp_enqueue_style( 'redux-field-slides', Redux_Core::$url . 'inc/fields/slides/redux-slides.css', array(), $this->timestamp ); } wp_enqueue_script( 'redux-field-media', Redux_Core::$url . 'assets/js/media/media' . Redux_Functions::is_min() . '.js', array( 'jquery', 'redux-js' ), $this->timestamp, true ); wp_enqueue_script( 'redux-field-slides', Redux_Core::$url . 'inc/fields/slides/redux-slides' . Redux_Functions::is_min() . '.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-sortable', 'redux-field-media' ), $this->timestamp, true ); } } } class_alias( 'Redux_Slides', 'ReduxFramework_Slides' );