function dgx_donate_send_donation_notification($donationID) { $fromEmail = get_option('dgx_donate_reply_email'); $subject = "[Seamless Donations] " . __('A donation has been received', 'dgx-donate'); $body = __('A donation has been received. Here are some details about the donation.', 'dgx-donate') . "\n"; $body .= "\n"; $body .= "Donor:\n"; $firstName = get_post_meta($donationID, '_dgx_donate_donor_first_name', true); $lastName = get_post_meta($donationID, '_dgx_donate_donor_last_name', true); $city = get_post_meta($donationID, '_dgx_donate_donor_city', true); $state = get_post_meta($donationID, '_dgx_donate_donor_state', true); $zip = get_post_meta($donationID, '_dgx_donate_donor_zip', true); $donorEmail = get_post_meta($donationID, '_dgx_donate_donor_email', true); $body .= "{$firstName} {$lastName}\n"; $body .= "{$city} {$state} {$zip}\n"; $body .= "{$donorEmail}\n"; $body .= "\n"; $tributeGift = get_post_meta($donationID, '_dgx_donate_tribute_gift', true); if (!empty($tributeGift)) { $body .= __('NOTE: The donor is making this donation in honor of / in memory of someone.', 'dgx-donate') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'dgx-donate') . "\n"; $body .= "\n"; } $employer_match = get_post_meta($donationID, '_dgx_donate_employer_match', true); if (!empty($employer_match)) { $body .= __('NOTE: The donor is making this donation with an employer match.', 'dgx-donate') . " "; $body .= __('Please see the donation details (using the link below) for more information.', 'dgx-donate') . "\n"; $body .= "\n"; } $amount = get_post_meta($donationID, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donationID); $formattedDonationAmount = dgx_donate_get_plain_formatted_amount($amount, 2, $currency_code, true); $body .= __('Donation:', 'dgx-donate') . "\n"; $body .= __('Amount:', 'dgx-donate') . " {$formattedDonationAmount}\n"; $body .= "\n"; $body .= __('Click on the following link to view all details for this donation:', 'dgx-donate') . "\n"; $secureDonateLink = dgx_donate_get_donation_detail_link($donationID); $donateLink = str_replace("https:", "http:", $secureDonateLink); $body .= $donateLink; $body .= "\n"; // Loop on addresses $notifyEmails = get_option('dgx_donate_notify_emails'); $notifyEmailAr = explode(',', $notifyEmails); foreach ($notifyEmailAr as $notifyEmail) { $notifyEmail = trim($notifyEmail); if (!empty($notifyEmail)) { $headers = "From: {$fromEmail}\r\n"; $mail_sent = wp_mail($notifyEmail, $subject, $body, $headers); if (!$mail_sent) { dgx_donate_debug_log("Error: Could NOT send mail."); dgx_donate_debug_log("Subject: {$subject}"); dgx_donate_debug_log("To Email: {$notifyEmail}"); } } } }
function menu_page() { echo "<div class='wrap'>\n"; echo "<div id='icon-edit-pages' class='icon32'></div>\n"; echo "<h2>" . esc_html__('Donations', 'seamless-donations') . "</h2>\n"; // Validate User if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } // Get form arguments $start_date = isset($_POST['startdate']) ? $_POST['startdate'] : ''; $end_date = isset($_POST['enddate']) ? $_POST['enddate'] : ''; // If we have form arguments, we must validate the nonce if (count($_POST)) { $nonce = $_POST['dgx_donate_donation_report_nonce']; if (!wp_verify_nonce($nonce, 'dgx_donate_donation_report_nonce')) { wp_die(__('You do not have sufficient permissions to access this page.', 'seamless-donations')); } } // Sanitize and adjust $start_date = dgx_donate_sanitize_date($start_date, 1, 1, date('Y')); $start_timestamp = strtotime($start_date); $end_date = dgx_donate_sanitize_date($end_date, 12, 31, date('Y')); $end_timestamp = strtotime($end_date); do_action('dgx_donate_donations_page_load'); echo "<div id='col-container'>\n"; echo "<div id='col-right'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html(sprintf(__('Donation Report for %1$s to %2$s', 'seamless-donations'), $start_date, $end_date)) . "</h3>\n"; $args = array('numberposts' => '-1', 'post_type' => 'dgx-donation', 'order' => 'ASC'); $my_donations = get_posts($args); // Scan all the donations for that date range // Build a hashmap of funds (don't forget to handle undesignated) to an array of donationIDs // Sort by fund name, put undesignated last? // Loop through the hashmap, printing the fund, its donations, total for that fund // Finally, print a total for the entire timeperiod if (count($my_donations)) { $my_funds = array(); foreach ((array) $my_donations as $my_donation) { $donation_id = $my_donation->ID; $ok_to_add = true; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $donation_date = $month . "/" . $day . "/" . $year; $donation_timestamp = strtotime($donation_date); if ($donation_timestamp < $start_timestamp) { $ok_to_add = false; } if ($donation_timestamp > $end_timestamp) { $ok_to_add = false; } if ($ok_to_add) { $designated_fund = __('Undesignated', 'seamless-donations'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $designated_fund = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } if (array_key_exists($designated_fund, $my_funds)) { $temp_array = $my_funds[$designated_fund]; $temp_array[] = $donation_id; $my_funds[$designated_fund] = $temp_array; } else { $my_funds[$designated_fund] = array($donation_id); } } } ksort($my_funds); // Start the table echo "<table class='widefat'><tbody>\n"; echo "<tr>"; echo "<th>" . esc_html__('Fund/Date', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Donor', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; echo "</tr>\n"; // Now, loop on the funds and then the donation IDs inside them $grand_total = 0; $all_currency_codes_found = array(); foreach ((array) $my_funds as $my_fund => $fund_donation_ids) { $fund_total = 0; $fund_count = count($fund_donation_ids); $fund_currency_codes_found = array(); echo "<tr>"; echo "<th colspan='3'>" . esc_html($my_fund . " (" . $fund_count . ")") . "</th>"; echo "</tr>\n"; foreach ((array) $fund_donation_ids as $donation_id) { $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); $first_name = get_post_meta($donation_id, '_dgx_donate_donor_first_name', true); $last_name = get_post_meta($donation_id, '_dgx_donate_donor_last_name', true); $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $fund_total = $fund_total + floatval($amount); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $all_currency_codes_found[$currency_code] = true; $fund_currency_codes_found[$currency_code] = true; $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); $donation_detail = dgx_donate_get_donation_detail_link($donation_id); $donor_email = get_post_meta($donation_id, '_dgx_donate_donor_email', true); $donor_detail = dgx_donate_get_donor_detail_link($donor_email); echo "<tr>"; echo "<td><a href='" . esc_url($donation_detail) . "'>" . esc_html($year . "-" . $month . "-" . $day . " " . $time) . "</a></td>"; echo "<td><a href='" . esc_url($donor_detail) . "'>" . esc_html($first_name . " " . $last_name) . "</a></td>"; echo "<td>" . $formatted_amount . "</td>"; echo "</tr>\n"; } if (count($fund_currency_codes_found) > 1) { $formatted_fund_total = "-"; } else { $formatted_fund_total = dgx_donate_get_escaped_formatted_amount($fund_total, 2, $currency_code); } echo "<tr>"; echo "<th> </th>"; echo "<th>" . esc_html__('Fund Subtotal', 'seamless-donations') . "</th>"; echo "<td>" . $formatted_fund_total . "</td>"; echo "</tr>\n"; $grand_total = $grand_total + $fund_total; } if (count($all_currency_codes_found) > 1) { $formatted_grand_total = "-"; } else { $formatted_grand_total = dgx_donate_get_escaped_formatted_amount($grand_total, 2, $currency_code); } echo "<tr>"; echo "<th> </th>"; echo "<th>" . esc_html__('Grand Total', 'seamless-donations') . "</th>"; echo "<td>" . $formatted_grand_total . "</td>"; echo "</tr>\n"; echo "</tbody></table>\n"; } else { echo "<p>" . esc_html__('No donations found.', 'seamless-donations') . "</p>\n"; } do_action('dgx_donate_donations_page_right'); do_action('dgx_donate_admin_footer'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-right -->\n"; echo "<div id='col-left'>\n"; echo "<div class='col-wrap'>\n"; if (count($my_donations)) { $export_url = plugins_url('/export.php', __FILE__); echo "<h3>" . esc_html__('Export Report as Spreadsheet (CSV)', 'seamless-donations') . "</h3>\n"; echo "<p>" . esc_html__('Click the following button to export detailed information for each donation in this report to a comma-separated-value (CSV) file compatible with most spreadsheet software.', 'seamless-donations') . "</p>"; echo "<form method='POST' action='" . esc_url($export_url) . "'>\n"; echo "<input type='hidden' name='startdate' value='" . esc_attr($start_date) . "' size='12'/>"; echo "<input type='hidden' name='enddate' value='" . esc_attr($end_date) . "' size='12'/>"; echo "</p><p>"; echo "<input id='submit' class='button' type='submit' value='" . esc_attr__('Export Report', 'seamless-donations') . "' name='submit'></p>\n"; echo "</form>"; echo "<hr/>"; } echo "<h3>" . esc_html__('Date Range', 'seamless-donations') . "</h3>\n"; echo "<form method='POST' action=''>\n"; $nonce = wp_create_nonce('dgx_donate_donation_report_nonce'); echo "<input type='hidden' name='dgx_donate_donation_report_nonce' value='" . esc_attr($nonce) . "' />\n"; echo "<p>"; echo esc_html__('Start Date', 'seamless-donations') . ": "; echo "<input type='text' name='startdate' value='" . esc_attr($start_date) . "' size='12'/>"; echo "<br/>"; echo esc_html__('End Date', 'seamless-donations') . ": "; echo "<input type='text' name='enddate' value='" . esc_attr($end_date) . "' size='12'/>"; echo "</p>"; echo "<p>"; echo "<input id='submit' class='button' type='submit' value='" . esc_attr__('Update', 'seamless-donations') . "' name='submit'>"; echo "</p>\n"; echo "</form>"; do_action('dgx_donate_donations_page_left'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-left -->\n"; echo "</div> <!-- col-container -->\n"; echo "</div> <!-- wrap -->\n"; }
static function show($donation_id) { // Validate User if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.', 'seamless-donations')); } // Get form arguments $delete_donation = ""; if (isset($_POST['delete_donation'])) { $delete_donation = $_POST['delete_donation']; } // If we have form arguments, we must validate the nonce if (count($_POST)) { $nonce = $_POST['dgx_donate_donation_detail_nonce']; if (!wp_verify_nonce($nonce, 'dgx_donate_donation_detail_nonce')) { wp_die(__('You do not have sufficient permissions to access this page.', 'seamless-donations')); } } echo "<div class='wrap'>\n"; echo "<div id='icon-edit-pages' class='icon32'></div>\n"; echo "<h2>" . esc_html__('Donation Detail', 'seamless-donations') . "</h2>\n"; $donation_deleted = false; if ("true" == $delete_donation) { dgx_donate_debug_log("Donation (ID: {$donation_id}) deleted"); wp_delete_post($donation_id, true); /* true = force delete / bypass trash */ $donation_deleted = true; $message = __('Donation deleted', 'seamless-donations'); } // Display any message if (!empty($message)) { echo "<div id='message' class='updated below-h2'>\n"; echo "<p>" . esc_html($message) . "</p>\n"; echo "</div>\n"; } if (!$donation_deleted) { echo "<div id='col-container'>\n"; echo "<div id='col-right'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html__('Donation Details', 'seamless-donations') . "</h3>\n"; echo "<table class='widefat'><tbody>\n"; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); echo "<tr>"; echo "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($month . "/" . $day . "/" . $year . " " . $time) . "</td></tr>\n"; $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); echo "<tr>"; echo "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; echo "<td>" . $formatted_amount . "</td></tr>\n"; $add_to_mailing_list = get_post_meta($donation_id, '_dgx_donate_add_to_mailing_list', true); if (!empty($add_to_mailing_list)) { $add_to_mailing_list = __('Yes', 'seamless-donations'); } else { $add_to_mailing_list = __('No', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Add to Mailing List?', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($add_to_mailing_list) . "</td></tr>\n"; $anonymous = get_post_meta($donation_id, '_dgx_donate_anonymous', true); if (empty($anonymous)) { $anonymous = __('No', 'seamless-donations'); } else { $anonymous = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Would like to remain anonymous?', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($anonymous) . "</td></tr>\n"; $fund_name = __('Undesignated', 'seamless-donations'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $fund_name = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } echo "<tr><th>" . esc_html__('Designated Fund', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($fund_name) . "</td></tr>\n"; $employer_match = get_post_meta($donation_id, '_dgx_donate_employer_match', true); if (empty($employer_match)) { $employer_match_message = __('No', 'seamless-donations'); } else { $employer_match_message = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Employer Match', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($employer_match_message) . "</td></tr>\n"; $employer_name = get_post_meta($donation_id, '_dgx_donate_employer_name', true); if (empty($employer_name)) { $employer_name_message = '-'; } else { $employer_name_message = $employer_name; } echo "<tr><th>" . esc_html__('Employer', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($employer_name_message) . "</td></tr>\n"; $occupation = get_post_meta($donation_id, '_dgx_donate_occupation', true); if (empty($occupation)) { $occupation_message = '-'; } else { $occupation_message = $occupation; } echo "<tr><th>" . esc_html__('Occupation', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($occupation_message) . "</td></tr>\n"; $donor_country = get_post_meta($donation_id, '_dgx_donate_donor_country', true); if ('GB' == $donor_country) { $uk_gift_aid = get_post_meta($donation_id, '_dgx_donate_uk_gift_aid', true); if (empty($uk_gift_aid)) { $uk_gift_aid_message = __('No', 'seamless-donations'); } else { $uk_gift_aid_message = __('Yes', 'seamless-donations'); } echo "<tr><th>" . esc_html__('UK Gift Aid', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($uk_gift_aid_message) . "</td></tr>\n"; } $tribute_gift_message = __('No', 'seamless-donations'); $tribute_gift = get_post_meta($donation_id, '_dgx_donate_tribute_gift', true); if (!empty($tribute_gift)) { $tribute_gift_message = __('Yes', 'seamless-donations') . " - "; $honoree_name = get_post_meta($donation_id, '_dgx_donate_honoree_name', true); $honor_by_email = get_post_meta($donation_id, '_dgx_donate_honor_by_email', true); $honoree_email_name = get_post_meta($donation_id, '_dgx_donate_honoree_email_name', true); $honoree_post_name = get_post_meta($donation_id, '_dgx_donate_honoree_post_name', true); $honoree_email = get_post_meta($donation_id, '_dgx_donate_honoree_email', true); $honoree_address = get_post_meta($donation_id, '_dgx_donate_honoree_address', true); $honoree_city = get_post_meta($donation_id, '_dgx_donate_honoree_city', true); $honoree_state = get_post_meta($donation_id, '_dgx_donate_honoree_state', true); $honoree_province = get_post_meta($donation_id, '_dgx_donate_honoree_province', true); $honoree_zip = get_post_meta($donation_id, '_dgx_donate_honoree_zip', true); $honoree_country = get_post_meta($donation_id, '_dgx_donate_honoree_country', true); $memorial_gift = get_post_meta($donation_id, '_dgx_donate_memorial_gift', true); if (empty($memorial_gift)) { $tribute_gift_message .= __('in honor of', 'seamless-donations') . ' '; } else { $tribute_gift_message .= __('in memory of', 'seamless-donations') . ' '; } $tribute_gift_message .= $honoree_name . "<br/><br/>"; if ('TRUE' == $honor_by_email) { $tribute_gift_message .= __('Send acknowledgement via email to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_email_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_email) . "<br/>"; } else { $tribute_gift_message .= __('Send acknowledgement via postal mail to', 'seamless-donations') . '<br/>'; $tribute_gift_message .= esc_html($honoree_post_name) . "<br/>"; $tribute_gift_message .= esc_html($honoree_address) . "<br/>"; if (!empty($honoree_city)) { $tribute_gift_message .= esc_html($honoree_city . " "); } if ('US' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_state . " "); } else { if ('CA' == $honoree_country) { $tribute_gift_message .= esc_html($honoree_province . " "); } } if (dgx_donate_country_requires_postal_code($honoree_country)) { $tribute_gift_message .= esc_html(" " . $honoree_zip); } $tribute_gift_message .= "<br/>"; $countries = dgx_donate_get_countries(); $honoree_country_name = $countries[$honoree_country]; $tribute_gift_message .= esc_html($honoree_country_name) . "<br/><br/>"; } } echo "<tr>"; echo "<th>" . esc_html__('Tribute Gift', 'seamless-donations') . "</th>"; echo "<td>" . $tribute_gift_message . "</td></tr>\n"; $payment_method = get_post_meta($donation_id, '_dgx_donate_payment_method', true); echo "<tr><th>" . esc_html__('Payment Method', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($payment_method) . "</td></tr>\n"; $repeating = get_post_meta($donation_id, '_dgx_donate_repeating', true); $is_repeating_donation = !empty($repeating); if ($is_repeating_donation) { $repeatingText = __('Yes', 'seamless-donations'); } else { $repeatingText = __('No', 'seamless-donations'); } echo "<tr><th>" . esc_html__('Repeating', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($repeatingText) . "</td></tr>\n"; $session_id = get_post_meta($donation_id, '_dgx_donate_session_id', true); echo "<tr><th>" . esc_html__('Session ID', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($session_id) . "</td></tr>\n"; $transaction_id = get_post_meta($donation_id, '_dgx_donate_transaction_id', true); echo "<tr><th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th>"; echo "<td>" . esc_html($transaction_id) . "</td></tr>\n"; echo "</tbody></table>\n"; if ($is_repeating_donation) { // Display links to related (same session ID) donations $related_donation_ids = get_donations_by_meta('_dgx_donate_session_id', $session_id, -1); // Unset this donation if present (it probably will be) if (($index = array_search($donation_id, $related_donation_ids)) !== false) { unset($related_donation_ids[$index]); } echo "<h3>" . esc_html__('Related Donations', 'seamless-donations') . "</h3>\n"; echo "<p class='description'>"; echo esc_html__('For repeating donations, displays a list of other donations in the series (subscription)', 'seamless-donations'); echo "</p>\n"; // Show the array echo "<table class='widefat'><tbody>\n"; if (count($related_donation_ids)) { echo "<tr>"; echo "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Transaction ID', 'seamless-donations') . "</th></tr>"; foreach ((array) $related_donation_ids as $related_donation_id) { $year = get_post_meta($related_donation_id, '_dgx_donate_year', true); $month = get_post_meta($related_donation_id, '_dgx_donate_month', true); $day = get_post_meta($related_donation_id, '_dgx_donate_day', true); $time = get_post_meta($related_donation_id, '_dgx_donate_time', true); $donation_date = $month . "/" . $day . "/" . $year; $transaction_id = get_post_meta($related_donation_id, '_dgx_donate_transaction_id', true); $donation_detail = dgx_donate_get_donation_detail_link($related_donation_id); echo "<tr>"; echo "<td><a href='" . esc_url($donation_detail) . "'>" . esc_html($donation_date . " " . $time) . "</a></td>"; echo "<td>" . esc_html($transaction_id) . "</td></tr>\n"; } } else { echo "<tr>"; echo "<th>" . esc_html__('No related donations found', 'seamless-donations') . "</th>"; echo "</tr>\n"; } echo "</tbody></table>\n"; } do_action('dgx_donate_donation_detail_right', $donation_id); do_action('dgx_donate_admin_footer'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-right -->\n"; echo "<div id=\"col-left\">\n"; echo "<div class=\"col-wrap\">\n"; Dgx_Donate_Admin_Donor_Detail_View::echo_donor_information($donation_id); echo "<h3>" . esc_html__('Delete this Donation', 'seamless-donations') . "</h3>"; echo "<p>" . esc_html__('Click the following button to delete this donation. This will also remove this donation from all reports. This operation cannot be undone.', 'seamless-donations') . "</p>"; if ($is_repeating_donation) { echo "<p><strong>" . esc_html__('This is a repeating donation (subscription). Deleting this donation does NOT end the subscription. The donor will need to log into PayPal to end the subscription.', 'seamless-donations') . "</strong></p>"; } echo "<form method='POST' action=''>\n"; $nonce = wp_create_nonce('dgx_donate_donation_detail_nonce'); echo "<input type='hidden' name='dgx_donate_donation_detail_nonce' value='" . esc_attr($nonce) . "' />\n"; echo "<input type='hidden' name='delete_donation' value='true' />"; echo "<p><input class='button' type='submit' value='" . esc_attr__('Delete Donation', 'seamless-donations') . "'"; echo " onclick=\"return confirm('" . esc_attr('Are you sure you want to delete this donation?', 'seamless-donations') . "');\"></p>\n"; echo "</form>"; do_action('dgx_donate_donation_detail_left', $donation_id); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-left -->\n"; echo "</div> <!-- col-container -->\n"; } echo "</div> <!-- wrap -->\n"; }
static function show($donor_id) { echo "<div class='wrap'>\n"; echo "<div id='icon-edit-pages' class='icon32'></div>\n"; echo "<h2>" . esc_html__('Donor Detail', 'dgx-donate') . "</h2>\n"; $donor_email = strtolower($donor_id); $args = array('numberposts' => '-1', 'post_type' => 'dgx-donation', 'meta_key' => '_dgx_donate_donor_email', 'meta_value' => $donor_email, 'order' => 'ASC'); $my_donations = get_posts($args); $args = array('numberposts' => '1', 'post_type' => 'dgx-donation', 'meta_key' => '_dgx_donate_donor_email', 'meta_value' => $donor_email, 'order' => 'DESC'); $last_donation = get_posts($args); if (count($my_donations) < 1) { echo "<p>" . esc_html__('No donations found.', 'dgx-donate') . "</p>"; } else { echo "<div id='col-container'>\n"; echo "<div id='col-right'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html__('Donations by This Donor', 'dgx-donate') . "</h3>\n"; echo "<table class='widefat'><tbody>\n"; echo "<tr>"; echo "<th>" . esc_html__('Date', 'dgx-donate') . "</th>"; echo "<th>" . esc_html__('Fund', 'dgx-donate') . "</th>"; echo "<th>" . esc_html__('Amount', 'dgx-donate') . "</th>"; echo "</tr>\n"; $donor_total = 0; $donor_currency_codes = array(); foreach ((array) $my_donations as $my_donation) { $donation_id = $my_donation->ID; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); $fund_name = __('Undesignated', 'dgx-donate'); $designated = get_post_meta($donation_id, '_dgx_donate_designated', true); if (!empty($designated)) { $fund_name = get_post_meta($donation_id, '_dgx_donate_designated_fund', true); } $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $donor_total = $donor_total + floatval($amount); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $donor_currency_codes[$currency_code] = true; $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); $donation_detail = dgx_donate_get_donation_detail_link($donation_id); echo "<tr><td><a href='" . esc_url($donation_detail) . "'>" . esc_html($year . "-" . $month . "- " . $day . " " . $time) . "</a></td>"; echo "<td>" . esc_html($fund_name) . "</td>"; echo "<td>" . $formatted_amount . "</td>"; echo "</tr>\n"; } if (count($donor_currency_codes) > 1) { $formatted_donor_total = "-"; } else { $formatted_donor_total = dgx_donate_get_escaped_formatted_amount($donor_total, 2, $currency_code); } echo "<tr>"; echo "<th> </th><th>" . esc_html__('Donor Total', 'dgx-donate') . "</th>"; echo "<td>" . $formatted_donor_total . "</td></tr>\n"; echo "</tbody></table>\n"; do_action('dgx_donate_donor_detail_right', $donor_id); do_action('dgx_donate_admin_footer'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-right -->\n"; echo "<div id=\"col-left\">\n"; echo "<div class=\"col-wrap\">\n"; $donation_id = $last_donation[0]->ID; self::echo_donor_information($donation_id); do_action('dgx_donate_donor_detail_left', $donor_id); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-left -->\n"; echo "</div> <!-- col-container -->\n"; } echo "</div> <!-- wrap -->\n"; }
static function show() { echo "<div class='wrap'>\n"; echo "<div id='icon-edit-pages' class='icon32'></div>\n"; echo "<h2>" . esc_html__('Seamless Donations for WordPress', 'seamless-donations') . "</h2>\n"; // Quick Links $quick_links = array(array('title' => __('Donations', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_donation_report_page"), array('title' => __('Donors', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_donor_report_page"), array('title' => __('Funds', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_funds_page"), array('title' => __('Thank You Emails', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_template_page"), array('title' => __('Thank You Page', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_thank_you_page"), array('title' => __('Form Options', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_form_options_page"), array('title' => __('Settings', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_settings_page"), array('title' => __('Log', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_debug_log_page"), array('title' => __('Help/FAQ', 'seamless-donations'), 'url' => get_admin_url() . "admin.php?page=dgx_donate_help_page")); echo "<p><strong>" . __('Quick Links', 'seamless-donations') . ": "; $count = 0; foreach ((array) $quick_links as $quick_link) { echo "<a href='" . esc_url($quick_link['url']) . "'><strong>" . esc_html($quick_link['title']) . "</strong></a>"; $count++; if ($count != count($quick_links)) { echo " | "; } } echo "</p>"; // Seamless Donations 4.0 upgrade form seamless_donations_sd40_upgrade_form(); // Recent Donations echo "<div id='col-container'>\n"; echo "<div id='col-right'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html__('Recent Donations', 'seamless-donations') . "</h3>\n"; $args = array('numberposts' => '10', 'post_type' => 'dgx-donation'); $my_donations = get_posts($args); if (count($my_donations)) { echo "<table class='widefat'><tbody>\n"; echo "<tr>"; echo "<th>" . esc_html__('Date', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Donor', 'seamless-donations') . "</th>"; echo "<th>" . esc_html__('Amount', 'seamless-donations') . "</th>"; echo "</tr>\n"; foreach ((array) $my_donations as $my_donation) { $donation_id = $my_donation->ID; $year = get_post_meta($donation_id, '_dgx_donate_year', true); $month = get_post_meta($donation_id, '_dgx_donate_month', true); $day = get_post_meta($donation_id, '_dgx_donate_day', true); $time = get_post_meta($donation_id, '_dgx_donate_time', true); $donation_date = $month . "/" . $day . "/" . $year; $first_name = get_post_meta($donation_id, '_dgx_donate_donor_first_name', true); $last_name = get_post_meta($donation_id, '_dgx_donate_donor_last_name', true); $donor_email = get_post_meta($donation_id, '_dgx_donate_donor_email', true); $donor_detail = dgx_donate_get_donor_detail_link($donor_email); $amount = get_post_meta($donation_id, '_dgx_donate_amount', true); $currency_code = dgx_donate_get_donation_currency_code($donation_id); $formatted_amount = dgx_donate_get_escaped_formatted_amount($amount, 2, $currency_code); $donation_detail = dgx_donate_get_donation_detail_link($donation_id); echo "<tr>"; echo "<td>"; echo "<a href='" . esc_url($donation_detail) . "'>"; echo esc_html($donation_date . ' ' . $time) . "</a>"; echo "</td>"; echo "<td>"; echo "<a href='" . esc_url($donor_detail) . "'>"; echo esc_html($first_name . ' ' . $last_name) . "</a>"; echo "</td>"; echo "<td>" . $formatted_amount . "</td>"; echo "</tr>\n"; } echo "</tbody></table>\n"; } else { echo "<p>" . esc_html__('No donations found.', 'seamless-donations') . "</p>\n"; } do_action('dgx_donate_main_page_right'); do_action('dgx_donate_admin_footer'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-right -->\n"; echo "<div id='col-left'>\n"; echo "<div class='col-wrap'>\n"; echo "<h3>" . esc_html__("Latest News", 'seamless-donations') . "</h3>"; // regular news feed echo "<div class='rss-widget'>"; wp_widget_rss_output(array('url' => 'http://zatzlabs.com/feed/', 'title' => __("What's up with Seamless Donations", 'seamless-donations'), 'items' => 3, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1)); echo "</div>"; do_action('dgx_donate_main_page_left'); echo "</div> <!-- col-wrap -->\n"; echo "</div> <!-- col-left -->\n"; echo "</div> <!-- col-container -->\n"; echo "</div> <!-- wrap -->\n"; }