get_valid_date_string( $charitable_report_data_args['start_date'] ) : false; $charitable_end_date = ( false === $charitable_end_date && ! empty( $charitable_report_data_args['end_date'] ) ) ? $charitable_reports->get_valid_date_string( $charitable_report_data_args['end_date'] ) : false; $charitable_filter = ( false === $charitable_filter && ! empty( $charitable_report_data_args['filter'] ) ) ? intval( $charitable_report_data_args['filter'] ) : 'test'; $charitable_campaign_id = ( false === $charitable_campaign_id && ! empty( $charitable_report_data_args['campaign_id'] ) ) ? intval( $charitable_report_data_args['campaign_id'] ) : false; $charitable_category_id = ( false === $charitable_category_id && ! empty( $charitable_report_data_args['category_id'] ) ) ? intval( $charitable_report_data_args['category_id'] ) : false; } if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_filter ) { // so nothing from the transient, so check the $_GET. $charitable_start_date = isset( $_GET['start_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['start_date'] ) ) : false; // phpcs:ignore $charitable_end_date = isset( $_GET['end_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['end_date'] ) ) : false; // phpcs:ignore $charitable_filter = isset( $_GET['filter'] ) ? intval( $_GET['filter'] ) : false; // phpcs:ignore $charitable_campaign_id = isset( $_GET['campaign_id'] ) ? intval( $_GET['campaign_id'] ) : false; // phpcs:ignore $charitable_category_id = isset( $_GET['category_id'] ) ? intval( $_GET['category_id'] ) : false; // phpcs:ignore } if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_filter ) { // If still nothing assign defaults. /* * Site-local, not UTC: post_date is stored in site-local time, so a bound * built from bare UTC excludes part of today's donations on any site whose * timezone is ahead of UTC. * * @since 1.8.13 */ $charitable_start_date = gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) - ( 7 * DAY_IN_SECONDS ) ); $charitable_end_date = gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) ); $charitable_filter = 7; $charitable_campaign_id = -1; // cannot be zero because that would be false. $charitable_category_id = 0; } $charitable_report_overview_args = apply_filters( 'charitable_report_overview_args', array( 'start_date' => $charitable_start_date, 'end_date' => $charitable_end_date, 'filter' => $charitable_filter, 'campaign_id' => $charitable_campaign_id, 'category_id' => $charitable_category_id, ) ); $charitable_reports->init_with_array( 'overview', $charitable_report_overview_args ); // main activity. $charitable_report_activity = $charitable_reports->get_activity(); // donations. $charitable_donations = $charitable_reports->get_donations(); $charitable_total_count_donations = count( $charitable_donations ); $charitable_total_amount_donations = $charitable_reports->get_donations_total(); $charitable_donation_breakdown = $charitable_reports->get_donations_by_day(); $charitable_payment_breakdown = $charitable_reports->get_donations_by_payment(); $charitable_donation_average = ( $charitable_total_amount_donations > 0 && $charitable_total_amount_donations > 0 ) ? ( charitable_format_money( $charitable_total_amount_donations / $charitable_total_count_donations, 2, true ) ) : charitable_format_money( 0 ); $charitable_donation_total = charitable_format_money( $charitable_total_amount_donations ); // donors. $charitable_top_donors = $charitable_reports->get_top_donors_overview(); $charitable_total_count_donors = $charitable_reports->get_donors_count(); $charitable_total_donors_label = ( 1 === $charitable_total_count_donors ) ? esc_html__( 'Donor', 'charitable' ) : esc_html__( 'Donors', 'charitable' ); // refunds. $charitable_refunds_data = $charitable_reports->get_refunds(); $charitable_total_amount_refunds = $charitable_refunds_data['total_amount']; $charitable_total_count_refunds = $charitable_refunds_data['total_count']; // campaigns. $charitable_args = array( 'posts_per_page' => apply_filters( 'charitable_overview_top_campaigns_amount', 20 ) ); $charitable_top_campaigns = Charitable_Campaigns::ordered_by_amount( $charitable_args ); $charitable_campaign_dropdown = array(); if ( ! empty( $charitable_top_campaigns->posts ) ) : $charitable_campaign_dropdown = wp_list_pluck( $charitable_top_campaigns->posts, 'post_title', 'ID' ); $charitable_campaign_dropdown = array_map( 'esc_html', $charitable_campaign_dropdown ); // sort by title. asort( $charitable_campaign_dropdown ); endif; $charitable_campaign_categories = $charitable_reports->get_campaign_categories(); $charitable_campaign_category_id = 0; ?>