fields = require( ITALYSTRAP_PLUGIN_PATH . 'config/carousel.php' ); $this->carousel_options = array( 'orderby' => array( 'menu_order' => __( 'Menu order (Default)', 'italystrap' ), 'title' => __( 'Order by the image\'s title', 'italystrap' ), 'post_date' => __( 'Sort by date/time', 'italystrap' ), 'rand' => __( 'Order randomly', 'italystrap' ), 'ID' => __( 'Order by the image\'s ID', 'italystrap' ), ), 'indicators' => array( 'before-inner' => __( 'before-inner', 'italystrap' ), 'after-inner' => __( 'after-inner', 'italystrap' ), 'after-control' => __( 'after-control', 'italystrap' ), 'false' => __( 'false', 'italystrap' ), ), 'control' => true, 'pause' => array( 'false' => __( 'none', 'italystrap' ), 'hover' => __( 'hover', 'italystrap' ), ), 'image_title' => true, 'text' => true, 'wpautop' => true, 'responsive' => false, ); $widget_ops = array( 'classname' => 'widget_italystrap_media_carousel', 'description' => __( 'Use this widget to add a Bootstrap Media Carousel', 'italystrap' ), ); /** * The width and eight of the widget in admin * @var array */ $control_ops = array( // 'width' => 350, // 'height' => 350 ); parent::__construct( 'widget_italystrap_media_carousel', __( 'ItalyStrap: Bootstrap Media Carousel', 'italystrap' ), $widget_ops, $control_ops ); add_action( 'save_post', array( &$this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'upload_scripts' ) ); } /** * Outputs the content for the current Bootstrap carousel widget instance. * * @since 1.4.0 * @access public * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Bootstrap carousel widget instance. */ public function widget( $args, $instance ) { $cache = wp_cache_get( 'widget_italystrap_media_carousel', 'widget' ); if ( ! is_array( $cache ) ) $cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = null; if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); $title = apply_filters( 'italystrap_media_carousel_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); // foreach ( $this->fields as $name => $label ) // $instance[ $name ] = ! empty( $instance[ $name ] ) ? esc_attr( $instance[ $name ] ) : $this->fields[ $name ]; echo $args['before_widget']; /** * Print the optional widget title */ if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } $instance['type'] = $instance['ids'] ? 'carousel' : ''; $mediacarousel = new ItalyStrapCarousel( $instance ); echo $mediacarousel->__get( 'output' ); echo $args['after_widget']; $cache[ $args['widget_id'] ] = ob_get_flush(); wp_cache_set( 'widget_italystrap_media_carousel', $cache, 'widget' ); } /** * Handles updating settings for the current Bootstrap carousel widget instance. * * @since 1.4.0 * @access public * * @param array $new_instance New settings for this instance as input by the user via * WP_Widget::form(). * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */ public function update( $new_instance, $old_instance ) { /** * Sanitizzo l'array */ foreach ( $this->fields as $key => $value ) { $new_instance[ $key ] = ( isset( $new_instance[ $key ] ) ) ? sanitize_text_field( $new_instance[ $key ] ) : ''; } $instance = $new_instance; $this->flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_italystrap_media_carousel'] ) ) delete_option( 'widget_italystrap_media_carousel' ); return $instance; } /** * Outputs the Bootstrap carousel widget settings form. * * @since 1.4.0 * @access public * * @param array $instance Current settings. */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, (array) $this->fields ); $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : '' ; $instance['type'] = 'carousel'; $instance['name'] = $this->id; /** * Instance of list of image sizes * @var ItalyStrapAdminMediaSettings */ $image_size_media = new ItalyStrapAdminMediaSettings; $image_size_media_array = $image_size_media->get_image_sizes( array( 'full' => __( 'Real size', 'italystrap' ) ) ); ?>

create_field_label( 'Title', 'Id' ) . '
'; ?>

fields as $key => $label ) { $instance[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; /** * Save select in widget * @link https://wordpress.org/support/topic/wordpress-custom-widget-select-options-not-saving * Display select only if is schema */ if ( 'ids' === $key ) { ?>


carousel_options[ $key ] ) && is_array( $this->carousel_options[ $key ] ) ) : ?> carousel_options[ $key ] ) ) : if ( 'true' === $instance[ $key ] ) { $instance[ $key ] = true; } ?> />