You appear to be a bot. Output may be restricted
Description
Usage
EDD_Product_Details_Widget::form( $instance );
Parameters
- $instance
- ( mixed ) required –
Returns
void
Source
File name: easy-digital-downloads/includes/widgets.php
Lines:
1 to 89 of 89
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 ); ?> <?php if ( 'current' === ( $instance['download_id'] ) ) { $instance['display_type'] = 'current'; $instance['download_id'] = false; } elseif ( is_numeric( $instance['download_id'] ) ) { $instance['display_type'] = 'specific'; } ?> <!-- Title --> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'easy-digital-downloads' ) ?></label> <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> </p> <p> <?php _e( 'Display Type:', 'easy-digital-downloads' ); ?><br /> <input type="radio" onchange="jQuery(this).parent().next('.download-details-selector').hide();" <?php checked( 'current', $instance['display_type'], true ); ?> value="current" name="<?php echo esc_attr( $this->get_field_name( 'display_type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>-current"><label for="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>-current"><?php _e( 'Current', 'easy-digital-downloads' ); ?></label> <input type="radio" onchange="jQuery(this).parent().next('.download-details-selector').show();" <?php checked( 'specific', $instance['display_type'], true ); ?> value="specific" name="<?php echo esc_attr( $this->get_field_name( 'display_type' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>-specific"><label for="<?php echo esc_attr( $this->get_field_id( 'display_type' ) ); ?>-specific"><?php _e( 'Specific', 'easy-digital-downloads' ); ?></label> </p> <!-- Download --> <?php $display = 'current' === $instance['display_type'] ? ' style="display: none;"' : ''; ?> <p class="download-details-selector" <?php echo $display; ?>> <label for="<?php echo esc_attr( $this->get_field_id( 'download_id' ) ); ?>"><?php printf( __( '%s:', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></label> <?php $download_count = wp_count_posts( 'download' ); ?> <?php if ( $download_count->publish < 1000 ) : ?> <?php $args = array( 'post_type' => 'download', 'posts_per_page' => -1, 'post_status' => 'publish', ); $downloads = get_posts( $args ); ?> <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'download_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'download_id' ) ); ?>"> <?php foreach ( $downloads as $download ) { ?> <option <?php selected( absint( $instance['download_id'] ), $download->ID ); ?> value="<?php echo esc_attr( $download->ID ); ?>"><?php echo $download->post_title; ?></option> <?php } ?> </select> <?php else: ?> <br /> <input type="text" value="<?php echo esc_attr( $instance['download_id'] ); ?>" placeholder="<?php printf( __( '%s ID', 'easy-digital-downloads' ), edd_get_label_singular() ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'download_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'download_id' ) ); ?>"> <?php endif; ?> </p> <!-- Download title --> <p> <input <?php checked( $instance['download_title'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'download_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'download_title' ) ); ?>" type="checkbox" /> <label for="<?php echo esc_attr( $this->get_field_id( 'download_title' ) ); ?>"><?php printf( __( 'Show %s Title', 'easy-digital-downloads' ), edd_get_label_singular() ); ?></label> </p> <!-- Show purchase button --> <p> <input <?php checked( $instance['purchase_button'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'purchase_button' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'purchase_button' ) ); ?>" type="checkbox" /> <label for="<?php echo esc_attr( $this->get_field_id( 'purchase_button' ) ); ?>"><?php _e( 'Show Purchase Button', 'easy-digital-downloads' ); ?></label> </p> <!-- Show download categories --> <p> <?php $category_labels = edd_get_taxonomy_labels( 'download_category' ); ?> <input <?php checked( $instance['categories'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'categories' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'categories' ) ); ?>" type="checkbox" /> <label for="<?php echo esc_attr( $this->get_field_id( 'categories' ) ); ?>"><?php printf( __( 'Show %s', 'easy-digital-downloads' ), $category_labels['name'] ); ?></label> </p> <!-- Show download tags --> <p> <?php $tag_labels = edd_get_taxonomy_labels( 'download_tag' ); ?> <input <?php checked( $instance['tags'], 'on' ); ?> id="<?php echo esc_attr( $this->get_field_id( 'tags' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'tags' ) ); ?>" type="checkbox" /> <label for="<?php echo esc_attr( $this->get_field_id( 'tags' ) ); ?>"><?php printf( __( 'Show %s', 'easy-digital-downloads' ), $tag_labels['name'] ); ?></label> </p> <?php do_action( 'edd_product_details_widget_form' , $instance ); ?> <?php }