/** * 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_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'))), 'all' === $current || '' == $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'); }