__( 'Display a list of donors.', 'charitable' ), 'customize_selective_refresh' => true, ) ); } /** * Display the widget contents on the front-end. * * @since 1.0.0 * * @param array $args Display arguments including 'before_title', 'after_title', 'before_widget' and 'after_widget'. * @param array $instance The settings for the particular instance of the widget. * @return void */ public function widget( $args, $instance ) { $instance = $this->get_parsed_args( $instance ); $view_args = array_merge( $args, $instance ); $instance['campaign'] = $view_args['campaign_id']; $view_args['campaign'] = $view_args['campaign_id']; $view_args['orderby'] = $view_args['order']; $view_args['order'] = 'DESC'; $view_args['donors'] = $this->get_widget_donors( $instance ); charitable_template( 'widgets/donors.php', $view_args ); } /** * Display the widget form in the admin. * * @since 1.0.0 * * @param array $instance The current settings for the widget options. * @return void */ public function form( $instance ) { $args = $this->get_parsed_args( $instance ); $campaigns = Charitable_Campaigns::query( array( 'posts_per_page' => -1 ) ); ?>
>
>
>
>
>
>
'', 'number' => 10, 'order' => 'recent', 'campaign_id' => 'all', 'show_distinct' => 1, 'show_avatar' => 1, 'show_location' => 0, 'show_amount' => 0, 'show_name' => 0, 'hide_if_no_donors' => 0, ), $instance ); return wp_parse_args( $instance, $defaults ); } /** * Return the donors to display in the widget. * * @since 1.0.0 * * @param mixed[] $instance The widget instance. * @return Charitable_Donor_Query */ protected function get_widget_donors( $instance ) { $query_args = charitable_array_subset( $instance, array( 'number', 'campaign' ) ); if ( 'amount' == $instance['order'] ) { $query_args['orderby'] = 'amount'; } $query_args['distinct_donors'] = $instance['show_distinct']; /** * Filter the arguments passed to Charitable_Donor_Query. * * @since 1.0.0 * * @param array $query_args The arguments to be passed to Charitable_Donor_Query::__construct. * @param array $args All the parsed arguments. */ $query_args = apply_filters( 'charitable_donors_widget_donor_query_args', $query_args, $instance ); return new Charitable_Donor_Query( $query_args ); } } endif;