BackwardsCompatibility.class.php
5 years ago
Blocks.class.php
5 years ago
CustomPostTypes.class.php
5 years ago
Dashboard.class.php
5 years ago
DeactivationSurvey.class.php
5 years ago
InstallationWalkthrough.class.php
5 years ago
Permissions.class.php
5 years ago
ReviewAsk.class.php
5 years ago
Settings.class.php
5 years ago
Widgets.class.php
5 years ago
WooCommerceIntegration.class.php
5 years ago
template-functions.php
5 years ago
Widgets.class.php
126 lines
| 1 | <?php |
| 2 | |
| 3 | class ewdusWidgetManager { |
| 4 | |
| 5 | public function __construct() { |
| 6 | |
| 7 | add_action( 'widgets_init', array( $this, 'register_display_slider_widget' ) ); |
| 8 | } |
| 9 | |
| 10 | public function register_display_slider_widget() { |
| 11 | |
| 12 | return register_widget( 'ewdusDisplaySliderWidget' ); |
| 13 | } |
| 14 | |
| 15 | } |
| 16 | |
| 17 | class ewdusDisplaySliderWidget extends WP_Widget { |
| 18 | |
| 19 | /** |
| 20 | * Sets up the widgets name etc |
| 21 | */ |
| 22 | public function __construct() { |
| 23 | |
| 24 | parent::__construct( |
| 25 | 'ewd_us_display_slider', // Base ID |
| 26 | __( 'Ultimate Slider', 'ultimate-slider' ), // Name |
| 27 | array( 'description' => __( 'Add a slider to any widgetized area.', 'ultimate-slider' ), ) // Args |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Outputs the content of the widget |
| 33 | * |
| 34 | * @param array $args |
| 35 | * @param array $instance |
| 36 | */ |
| 37 | public function widget( $args, $instance ) { |
| 38 | |
| 39 | echo $args['before_widget']; |
| 40 | echo do_shortcode( "[ultimate-slider posts='". $instance['post_count'] . "' slider_type='". $instance['slider_type'] . "' category='". $instance['category'] . "' carousel_mode='". $instance['carousel_mode'] . "' slide_indicators='". $instance['slide_indicators'] . "']" ); |
| 41 | echo $args['after_widget']; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Outputs the options form on admin |
| 46 | * |
| 47 | * @param array $instance The widget options |
| 48 | */ |
| 49 | public function form( $instance ) { |
| 50 | |
| 51 | $post_count = ! empty( $instance['post_count'] ) ? $instance['post_count'] : __( 'Number of Slides', 'ultimate-slider' ); |
| 52 | $slider_type = ! empty( $instance['slider_type'] ) ? $instance['slider_type'] : __( 'Slider Type', 'ultimate-slider' ); |
| 53 | $category = ! empty( $instance['category'] ) ? $instance['category'] : __( 'Category', 'ultimate-slider' ); |
| 54 | $carousel_mode = ! empty( $instance['carousel_mode'] ) ? $instance['carousel_mode'] : __( 'Carousel Mode', 'ultimate-slider' ); |
| 55 | $slide_indicators = ! empty( $instance['slide_indicators'] ) ? $instance['slide_indicators'] : __( 'Slide Indicators', 'ultimate-slider' ); |
| 56 | ?> |
| 57 | |
| 58 | <p> |
| 59 | <label for="<?php echo $this->get_field_id( 'post_count' ); ?>"><?php _e( 'Number of Slides:', 'ultimate-slider' ); ?></label> |
| 60 | <select class="widefat" id="<?php echo $this->get_field_id( 'post_count' ); ?>" name="<?php echo $this->get_field_name( 'post_count' ); ?>" > |
| 61 | <option value="-1" <?php if ( $post_count == "-1" ) { echo "selected='selected'"; } ?> >All</option> |
| 62 | <?php for ($i=1; $i<=10; $i++) { ?> |
| 63 | <option value='<?php echo $i;?>' <?php if ( $post_count == $i ) { echo "selected='selected'"; } ?> ><?php echo $i; ?></option> |
| 64 | <?php } ?> |
| 65 | </select> |
| 66 | </p> |
| 67 | |
| 68 | <p> |
| 69 | <label for="<?php echo $this->get_field_id( 'slider_type' ); ?>"><?php _e( 'Slider Type:', 'ultimate-slider' ); ?></label> |
| 70 | <select class="widefat ewd-us-widget-slider-type" id="<?php echo $this->get_field_id( 'slider_type' ); ?>" name="<?php echo $this->get_field_name( 'slider_type' ); ?>" > |
| 71 | <option value="" <?php if ( $slider_type == "" ) { echo "selected='selected'"; } ?> >Standard (Uses Slides You Create)</option> |
| 72 | <option value="woocommerce" <?php if ( $slider_type == "woocommerce" ) { echo "selected='selected'"; } ?> >WooCommerce (Product Slides)</option> |
| 73 | </select> |
| 74 | </p> |
| 75 | |
| 76 | <p> |
| 77 | <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Category:', 'ultimate-slider' ); ?></label> |
| 78 | <select class="widefat ewd-us-widget-category" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>" > |
| 79 | <option value="" <?php if ( $category == "" ) { echo "selected='selected'"; } ?> >All</option> |
| 80 | </select> |
| 81 | </p> |
| 82 | |
| 83 | <p> |
| 84 | <label for="<?php echo $this->get_field_id( 'carousel_mode' ); ?>"><?php _e( 'Carousel Mode:', 'ultimate-slider' ); ?></label> |
| 85 | <select class="widefat ewd-us-widget-carousel" id="<?php echo $this->get_field_id( 'carousel_mode' ); ?>" name="<?php echo $this->get_field_name( 'carousel_mode' ); ?>" > |
| 86 | <option value="No" <?php if ( $carousel_mode == "No" ) { echo "selected='selected'"; } ?> >No</option> |
| 87 | <option value="Yes" <?php if ( $carousel_mode == "Yes" ) { echo "selected='selected'"; } ?> >Yes</option> |
| 88 | </select> |
| 89 | </p> |
| 90 | |
| 91 | <p> |
| 92 | <label for="<?php echo $this->get_field_id( 'slide_indicators' ); ?>"><?php _e( 'Slide Indicators:', 'ultimate-slider' ); ?></label> |
| 93 | <select class="widefat ewd-us-widget-slide-indicators" id="<?php echo $this->get_field_id( 'slide_indicators' ); ?>" name="<?php echo $this->get_field_name( 'slide_indicators' ); ?>" > |
| 94 | <option value="Dots" <?php if ( $slide_indicators == "No" ) { echo "selected='selected'"; } ?> >Dots</option> |
| 95 | <option value="Thumbnails" <?php if ( $slide_indicators == "Yes" ) { echo "selected='selected'"; } ?> >Thumbnails</option> |
| 96 | <option value="Side Thumbnails" <?php if ( $slide_indicators == "Side Thumbnails" ) { echo "selected='selected'"; } ?> >Side Thumbnails</option> |
| 97 | <option value="None" <?php if ( $slide_indicators == "None" ) { echo "selected='selected'"; } ?> >None</option> |
| 98 | </select> |
| 99 | </p> |
| 100 | |
| 101 | <?php |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Processing widget options on save |
| 106 | * |
| 107 | * @param array $new_instance The new options |
| 108 | * @param array $old_instance The previous options |
| 109 | */ |
| 110 | public function update( $new_instance, $old_instance ) { |
| 111 | |
| 112 | $instance = array(); |
| 113 | $instance['post_count'] = ( ! empty( $new_instance['post_count'] ) ) ? strip_tags( $new_instance['post_count'] ) : ''; |
| 114 | $instance['slider_type'] = ( ! empty( $new_instance['slider_type'] ) ) ? strip_tags( $new_instance['slider_type'] ) : ''; |
| 115 | $instance['category'] = ( ! empty( $new_instance['category'] ) ) ? strip_tags( $new_instance['category'] ) : ''; |
| 116 | $instance['carousel_mode'] = ( ! empty( $new_instance['carousel_mode'] ) ) ? strip_tags( $new_instance['carousel_mode'] ) : ''; |
| 117 | $instance['slide_indicators'] = ( ! empty( $new_instance['slide_indicators'] ) ) ? strip_tags( $new_instance['slide_indicators'] ) : ''; |
| 118 | |
| 119 | return $instance; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 |