__( 'Displays the products entered into Artistography', $i18n_domain ), ) // Args ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { GLOBAL $i18n_domain; extract( $args ); $albums = new Music; // outputs the content of the widget echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; } if ( ! empty( $instance['number'] ) ) { $number = $instance['number']; } else { $number = 2; } // load albums and shuffle them if ( $instance['free'] == '' ) { $albums->loadAllNotFree(); } else { $albums->loadAllLinked(); } for($i = 0; $i < $albums->getTotalRows(); $i++) { $albums_preload[] = $albums->id; $albums->getNodeNext(); } if( $albums->getTotalRows() > 0) { shuffle($albums_preload); } else { echo "Nothing to show yet."; } for($i = 0; $i < $number and $i < $albums->getTotalRows(); $i++) { echo do_shortcode("[artistography_display_album id=" .$albums_preload[$i]. "]"); } echo $args['after_widget']; } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form( $instance ) { GLOBAL $i18n_domain; // outputs the options form on admin $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Products', $i18n_domain ); $number = ! empty( $instance['number'] ) ? $instance['number'] : '2'; $free = ! empty( $instance['free'] ) ? $instance['free'] : ''; ?>
>