__( 'Display the downloads shopping cart', 'easy-digital-downloads' ) ) ); add_filter( 'dynamic_sidebar_params', array( $this, 'cart_widget_class' ), 10, 1 ); } /** @see WP_Widget::widget */ function widget( $args, $instance ) { if ( ! empty( $instance['hide_on_checkout'] ) && edd_is_checkout() ) { return; } $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'edd_cart_widget'; $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; $title = apply_filters( 'widget_title', $instance['title'], $instance, $args['id'] ); echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } do_action( 'edd_before_cart_widget' ); edd_shopping_cart( true ); do_action( 'edd_after_cart_widget' ); echo $args['after_widget']; } /** @see WP_Widget::update */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['hide_on_checkout'] = ! empty( $new_instance['hide_on_checkout'] ); $instance['hide_on_empty'] = ! empty( $new_instance['hide_on_empty'] ); return $instance; } /** @see WP_Widget::form */ function form( $instance ) { $defaults = array( 'title' => '', 'hide_on_checkout' => false, 'hide_on_empty' => false, ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

id="get_field_id( 'hide_on_checkout' ) ); ?>" name="get_field_name( 'hide_on_checkout' ) ); ?>" type="checkbox" />

id="get_field_id( 'hide_on_empty' ) ); ?>" name="get_field_name( 'hide_on_empty' ) ); ?>" type="checkbox" />

get_settings(); $instance_settings = $all_settings[ $instance_id ]; if ( ! empty( $instance_settings['hide_on_empty'] ) ) { $cart_quantity = edd_get_cart_quantity(); $class = empty( $cart_quantity ) ? 'cart-empty' : 'cart-not-empty'; $params[0]['before_widget'] = preg_replace( '/class="(.*?)"/', 'class="$1 edd-hide-on-empty ' . $class . '"', $params[0]['before_widget'] ); } } return $params; } } /** * Categories / Tags Widget. * * Downloads categories / tags widget class. * * @since 1.0 * @return void */ class edd_categories_tags_widget extends WP_Widget { /** Constructor */ function __construct() { parent::__construct( 'edd_categories_tags_widget', __( 'Downloads Categories / Tags', 'easy-digital-downloads' ), array( 'description' => __( 'Display the downloads categories or tags', 'easy-digital-downloads' ) ) ); } /** @see WP_Widget::widget */ function widget( $args, $instance ) { // Set defaults. $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'edd_categories_tags_widget'; $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; $instance['taxonomy'] = ( isset( $instance['taxonomy'] ) ) ? $instance['taxonomy'] : 'download_category'; $title = apply_filters( 'widget_title', $instance['title'], $instance, $args['id'] ); $tax = $instance['taxonomy']; $count = isset( $instance['count'] ) && $instance['count'] == 'on' ? 1 : 0; $hide_empty = isset( $instance['hide_empty'] ) && $instance['hide_empty'] == 'on' ? 1 : 0; echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } do_action( 'edd_before_taxonomy_widget' ); echo "\n"; do_action( 'edd_after_taxonomy_widget' ); echo $args['after_widget']; } /** @see WP_Widget::update */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['taxonomy'] = strip_tags( $new_instance['taxonomy'] ); $instance['count'] = isset( $new_instance['count'] ) ? $new_instance['count'] : ''; $instance['hide_empty'] = isset( $new_instance['hide_empty'] ) ? $new_instance['hide_empty'] : ''; return $instance; } /** @see WP_Widget::form */ function form( $instance ) { // Set up some default widget settings. $defaults = array( 'title' => '', 'taxonomy' => 'download_category', 'count' => 'off', 'hide_empty' => 'off', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

id="get_field_id( 'count' ) ); ?>" name="get_field_name( 'count' ) ); ?>" type="checkbox" />

id="get_field_id( 'hide_empty' ) ); ?>" name="get_field_name( 'hide_empty' ) ); ?>" type="checkbox" />

sprintf( __( 'Display the details of a specific %s', 'easy-digital-downloads' ), edd_get_label_singular() ), ) ); } /** @see WP_Widget::widget */ public function widget( $args, $instance ) { $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'edd_download_details_widget'; if ( ! empty( $instance['download_id'] ) ) { if ( 'current' === ( $instance['download_id'] ) ) { $instance['display_type'] = 'current'; unset( $instance['download_id'] ); } elseif ( is_numeric( $instance['download_id'] ) ) { $instance['display_type'] = 'specific'; } } if ( ! isset( $instance['display_type'] ) || ( 'specific' === $instance['display_type'] && ! isset( $instance['download_id'] ) ) || ( 'current' == $instance['display_type'] && ! is_singular( 'download' ) ) ) { return; } // set correct download ID. if ( 'current' == $instance['display_type'] && is_singular( 'download' ) ) { $download_id = get_the_ID(); } else { $download_id = absint( $instance['download_id'] ); } // Since we can take a typed in value, make sure it's a download we're looking for $download = get_post( $download_id ); if ( ! is_object( $download ) || 'download' !== $download->post_type ) { return; } // Variables from widget settings. $title = apply_filters( 'widget_title', $instance['title'], $instance, $args['id'] ); $download_title = $instance['download_title'] ? apply_filters( 'edd_product_details_widget_download_title', '

' . get_the_title( $download_id ) . '

', $download_id ) : ''; $purchase_button = $instance['purchase_button'] ? apply_filters( 'edd_product_details_widget_purchase_button', edd_get_purchase_link( array( 'download_id' => $download_id ) ), $download_id ) : ''; $categories = $instance['categories'] ? $instance['categories'] : ''; $tags = $instance['tags'] ? $instance['tags'] : ''; // Used by themes. Opens the widget. echo $args['before_widget']; // Display the widget title. if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } do_action( 'edd_product_details_widget_before_title' , $instance , $download_id ); // Download title. echo $download_title; do_action( 'edd_product_details_widget_before_purchase_button' , $instance , $download_id ); // Purchase button. echo $purchase_button; // Categories. $category_list = false; $category_label = ''; if ( $categories ) { $category_terms = (array) get_the_terms( $download_id, 'download_category' ); if ( $category_terms && ! is_wp_error( $category_terms ) ) { $category_list = get_the_term_list( $download_id, 'download_category', '', ', ' ); $category_count = count( $category_terms ); $category_labels = edd_get_taxonomy_labels( 'download_category' ); $category_label = $category_count > 1 ? $category_labels['name'] : $category_labels['singular_name']; } } // Tags. $tag_list = false; $tag_label = ''; if ( $tags ) { $tag_terms = (array) get_the_terms( $download_id, 'download_tag' ); if ( $tag_terms && ! is_wp_error( $tag_terms ) ) { $tag_list = get_the_term_list( $download_id, 'download_tag', '', ', ' ); $tag_count = count( $tag_terms ); $tag_taxonomy = edd_get_taxonomy_labels( 'download_tag' ); $tag_label = $tag_count > 1 ? $tag_taxonomy['name'] : $tag_taxonomy['singular_name']; } } $text = ''; if ( $category_list || $tag_list ) { $text .= '

'; if ( $category_list ) { $text .= '%1$s: %2$s
'; } if ( $tag_list ) { $text .= '%3$s: %4$s'; } $text .= '

'; } do_action( 'edd_product_details_widget_before_categories_and_tags', $instance, $download_id ); printf( $text, $category_label, $category_list, $tag_label, $tag_list ); do_action( 'edd_product_details_widget_before_end', $instance, $download_id ); // Used by themes. Closes the widget. echo $args['after_widget']; } /** @see WP_Widget::form */ public function form( $instance ) { // Set up some default widget settings. $defaults = array( 'title' => sprintf( __( '%s Details', 'easy-digital-downloads' ), edd_get_label_singular() ), 'display_type' => 'current', 'download_id' => false, 'download_title' => 'on', 'purchase_button' => 'on', 'categories' => 'on', 'tags' => 'on', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>


value="current" name="get_field_name( 'display_type' ) ); ?>" id="get_field_id( 'display_type' ) ); ?>-current"> value="specific" name="get_field_name( 'display_type' ) ); ?>" id="get_field_id( 'display_type' ) ); ?>-specific">

> publish < 1000 ) : ?> 'download', 'posts_per_page' => -1, 'post_status' => 'publish', ); $downloads = get_posts( $args ); ?>

id="get_field_id( 'download_title' ) ); ?>" name="get_field_name( 'download_title' ) ); ?>" type="checkbox" />

id="get_field_id( 'purchase_button' ) ); ?>" name="get_field_name( 'purchase_button' ) ); ?>" type="checkbox" />

id="get_field_id( 'categories' ) ); ?>" name="get_field_name( 'categories' ) ); ?>" type="checkbox" />

id="get_field_id( 'tags' ) ); ?>" name="get_field_name( 'tags' ) ); ?>" type="checkbox" />