__( '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', '
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" />