/**
  * Get things started
  *
  * @see     WP_List_Table::__construct()
  * @uses    Charitable_Donations_Table::prepare_donation_counts()
  *
  * @access  public
  * @since   1.0.0     
  */
 public function __construct()
 {
     global $status, $page;
     $donation_post_type = get_post_type_object('donation');
     // Set parent defaults
     parent::__construct(array('singular' => $donation_post_type->labels->singular_name, 'plural' => $donation_post_type->labels->name, 'ajax' => false));
     $this->base_url = admin_url('edit.php?page=charitable-donations-table');
     $this->donation_statuses = Charitable_Donation::get_valid_donation_statuses();
     $this->prepare_donation_counts();
     $this->process_bulk_action();
 }
示例#2
0
<?php

/**
 * Display the donations widget on the dashboard. 
 *
 * @author  Studio 164a
 * @package Charitable/Admin View/Dashboard Widgets
 * @since   1.2.0
 */
$statuses = Charitable_Donation::get_valid_donation_statuses();
$donations = get_posts(array('post_type' => Charitable::DONATION_POST_TYPE, 'posts_per_page' => 5, 'post_status' => array_keys($statuses), 'fields' => 'ids'));
$table = charitable_get_table('campaign_donations');
$today = $table->get_donations_summary_by_period(date('Y-m-d%'));
$this_month = $table->get_donations_summary_by_period(date('Y-m%'));
$last_month = $table->get_donations_summary_by_period(date('Y-m%', strtotime('-1 month')));
$this_year = $table->get_donations_summary_by_period(date('Y-%'));
?>
<div class="charitable-donation-statistics">
    <div class="cell">
        <h3 class="amount"><?php 
echo charitable_format_money($today->amount);
?>
</h3>
        <p class="summary"><?php 
printf(_n('%d donation %stoday%s', '%d donations %stoday%s', $today->count, 'charitable'), $today->count, '<span class="time-period">', '</span>');
?>
</p>
    </div>
    <div class="cell">
        <h3 class="amount"><?php 
echo charitable_format_money($this_month->amount);
示例#3
0
?>
</th>
                <td><?php 
echo $donation->get_gateway_label();
?>
</td>
            </tr>
            <tr>
                <th><?php 
_e('Change Status', 'charitable');
?>
</th>
                <td>
                    <select id="change-donation-status" name="post_status">
                    <?php 
foreach (Charitable_Donation::get_valid_donation_statuses() as $status => $label) {
    ?>
                        <option value="<?php 
    echo $status;
    ?>
" <?php 
    selected($status, $donation->get_status());
    ?>
><?php 
    echo $label;
    ?>
</option>
                    <?php 
}
?>
                    </select>
 /**
  * Returns the array of view options for this campaign. 
  *
  * @param   array       $views
  * @return  array
  * @access  public
  * @since   1.0.0
  */
 public function view_options($views)
 {
     $current = isset($_GET['post-status']) ? $_GET['post-status'] : '';
     $statuses = Charitable_Donation::get_valid_donation_statuses();
     $donations = new Charitable_Donations();
     $status_count = $donations->count_by_status();
     $views = array();
     $views['all'] = sprintf('<a href="%s"%s>%s <span class="count">(%s)</span></a>', esc_url(remove_query_arg(array('post_status', 'paged'))), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'charitable'), $donations->count_all());
     foreach ($statuses as $status => $label) {
         $views[$status] = sprintf('<a href="%s"%s>%s <span class="count">(%s)</span></a>', esc_url(add_query_arg(array('post_status' => $status, 'paged' => false))), $current === $status ? ' class="current"' : '', $label, isset($status_count[$status]) ? $status_count[$status]->num_donations : 0);
     }
     return $views;
 }
 /**
  * Fix the donation dates.
  *
  * This upgrade routine was added in 1.3.0
  *
  * @see 	https://github.com/Charitable/Charitable/issues/58
  *
  * @return  void
  * @access  public
  * @since   1.3.0
  */
 public function fix_donation_dates()
 {
     if (!current_user_can('manage_charitable_settings')) {
         wp_die(__('You do not have permission to do Charitable upgrades', 'charitable'), __('Error', 'charitable'), array('response' => 403));
     }
     ignore_user_abort(true);
     if (!charitable_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
         @set_time_limit(0);
     }
     $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
     $number = 20;
     $total = Charitable_Donations::count_all();
     /**
      * If there are no donations to update, go ahead and wrap it up right now.
      */
     if (!$total) {
         $this->finish_upgrade('fix_donation_dates');
     }
     $donations = get_posts(array('post_type' => Charitable::DONATION_POST_TYPE, 'posts_per_page' => $number, 'paged' => $step, 'post_status' => array_keys(Charitable_Donation::get_valid_donation_statuses())));
     if (count($donations)) {
         /**
          * Prevent donation receipt & admin notifications from getting resent.
          */
         remove_action('save_post_' . Charitable::DONATION_POST_TYPE, array('Charitable_Email_Donation_Receipt', 'send_with_donation_id'));
         remove_action('save_post_' . Charitable::DONATION_POST_TYPE, array('Charitable_Email_New_Donation', 'send_with_donation_id'));
         foreach ($donations as $donation) {
             /**
              * Thankfully, we store the timestamp of the donation in the log,
              * so we can use that to correct any incorrect post_date/post_date_gmt
              * values.
              */
             $donation_log = get_post_meta($donation->ID, '_donation_log', true);
             if (empty($donation_log)) {
                 continue;
             }
             $time = $donation_log[0]['time'];
             $date_gmt = gmdate('Y-m-d H:i:s', $time);
             if ($date_gmt == $donation->post_date_gmt) {
                 continue;
             }
             $date = get_date_from_gmt($date_gmt);
             wp_update_post(array('ID' => $donation->ID, 'post_date' => $date, 'post_date_gmt' => $date_gmt));
         }
         $step++;
         $redirect = add_query_arg(array('page' => 'charitable-upgrades', 'charitable-upgrade' => 'fix_donation_dates', 'step' => $step, 'number' => $number, 'total' => $total), admin_url('index.php'));
         wp_redirect($redirect);
         exit;
     }
     $this->upgrade_logs();
     $this->finish_upgrade('fix_donation_dates');
 }
示例#6
0
 public function test_get_valid_donation_statuses()
 {
     $this->assertCount(5, Charitable_Donation::get_valid_donation_statuses());
 }