/** * Returns the given donation. * * This will first attempt to retrieve it from the object cache to prevent duplicate objects. * * @param int $donation_id * @param boolean $force * @return Charitable_Donation * @since 1.0.0 */ function charitable_get_donation($donation_id, $force = false) { if (!did_action('charitable_start') && false === (defined('DOING_AJAX') && DOING_AJAX)) { charitable_get_deprecated()->doing_it_wrong(__FUNCTION__, __('charitable_get_donation should not be called before the charitable_start action.', 'charitable'), '1.0.0'); return false; } $donation = wp_cache_get($donation_id, 'charitable_donation', $force); if (!$donation) { $donation = charitable()->donation_factory->get_donation($donation_id); wp_cache_set($donation_id, $donation, 'charitable_donation'); } return $donation; }
/** * Flush the donations cache for every campaign receiving a donation. * * @param int $donation_id * @return void * @access public * @since 1.0.0 * @deprecated 1.4.0 */ public function flush_campaigns_donation_cache($donation_id) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', 'charitable_sanitize_donation_meta()'); return charitable_flush_campaigns_donation_cache($donation_id); }
/** * Returns whether a credit card form is required for this gateway. * * @return boolean * @access public * @since 1.0.0 * * @deprecated */ public function requires_credit_card_form() { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.3.0', 'Charitable_Gateway::supports( \'credit-card\' )'); return $this->supports('credit-card'); }
/** * Add a new donor. This may also create a user account for them. * * @param array $submitted * @return int $donor_id * @access public * @since 1.0.0 */ public function add_donor($submitted = array()) { $email = false; if (isset($submitted['email'])) { $email = $submitted['email']; } if (!$email && $this->is_logged_in()) { $email = $this->user_email; } /** * Still no email? We're going to have to call an end * to this party right now then. */ if (!$email) { charitable_get_deprecated()->doing_it_wrong(__METHOD__, __('Unable to add donor. Email not set for logged out user.', 'charitable'), '1.0.0'); return 0; } $donor_values = apply_filters('charitable_donor_values', array('user_id' => $this->ID, 'email' => $email, 'first_name' => isset($submitted['first_name']) ? $submitted['first_name'] : $this->first_name, 'last_name' => isset($submitted['last_name']) ? $submitted['last_name'] : $this->last_name), $this, $submitted); $donor_id = charitable_get_table('donors')->insert($donor_values); do_action('charitable_after_insert_donor', $donor_id, $this); return $donor_id; }
/** * @deprecated 1.3.0 */ public function email_template($template) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.3.0', 'Charitable_Templates::template_loader() or Charitable_Templates::get_email_template()'); return $this->get_email_template($template); }
/** * Receives unfiltered monetary amount and sanitizes it, returning it as a float. * * $50.00 -> 50.00 * * @param string $amount * @return float|WP_Error * @access public * @since 1.0.0 */ public function sanitize_monetary_amount($amount) { /* Sending anything other than a string can cause unexpected returns, so we require strings. */ if (!is_string($amount)) { charitable_get_deprecated()->doing_it_wrong(__METHOD__, __('Amount must be passed as a string.', 'charitable'), '1.0.0'); return new WP_Error('invalid_parameter_type', 'Amount must be passed as a string.'); } /** If we're using commas for decimals, we need to turn any commas into points, and we need to replace existing points with blank spaces. Example: 12.500,50 -> 12500.50 */ if ($this->is_comma_decimal()) { $amount = str_replace(',', '_', $amount); $amount = str_replace('.', '', $amount); $amount = str_replace('_', '.', $amount); } $amount = str_replace($this->get_currency_symbol(), '', $amount); return floatval(filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)); }
/** * Add the charitable_user_profile_after_fields hook but fire off a deprecated notice. * * @deprecated 1.4.0 * @return void * @access public * @static * @since 1.4.0 */ public static function add_deprecated_charitable_user_profile_after_fields_hook($form) { if (!has_action('charitable_user_profile_after_fields')) { return; } charitable_get_deprecated()->doing_it_wrong(__METHOD__, __('charitable_user_profile_after_fields hook has been removed. Use charitable_form_after_fields instead.', 'charitable'), '1.4.0'); if ('Charitable_Profile_Form' == get_class($form)) { do_action('charitable_user_profile_after_fields', $form); } }
/** * @deprecated */ public function get_location_helper() { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.2.0', 'charitable_get_location_helper'); return charitable_get_location_helper(); }
/** * Return the reset link. * * @return string|WP_Error|false If the reset key could not be generated, an error is returned. * @access public * @since 1.4.0 */ public function get_reset_link() { if (!isset($this->reset_link)) { if (!is_a($this->user, 'WP_User')) { charitable_get_deprecated()->doing_it_wrong(__METHOD__, __('Password reset link cannot be generated without a WP_User object.', 'charitable'), '1.4.0'); return ''; } $base_url = charitable_get_permalink('reset_password_page'); $key = get_password_reset_key($this->user); if (is_wp_error($key)) { return $key; } $this->reset_link = esc_url_raw(add_query_arg(array('key' => $key, 'login' => rawurlencode($this->user->user_login)), $base_url)); } return $this->reset_link; }
/** * Return the IPN url. * * IPNs in Charitable are structured in this way: charitable-listener=gateway * * @deprecated * * @param string $gateway * @return string * @access public * @since 1.0.0 */ public function get_ipn_url($gateway) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', 'charitable_get_ipn_url()'); return charitable_get_ipn_url($gateway); }
/** * @deprecated 1.3.6 * * @param mixed $return * @param mixed $fallback * @return mixed $return * @access protected * @since 1.0.0 */ protected function return_value_if_has_valid_donation($return, $fallback = '') { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.3.6', __('This function was buggy and has been deprecated.', 'charitable')); if (!$this->has_valid_donation()) { return $fallback; } return $return; }
/** * Return a value from the donor meta. * * @deprecated * * @param string $key * @return mixed * @access public * @since 1.2.4 */ public function get_value($key) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', 'Charitable_Donor::get_donor_meta()'); return $this->get_donor_meta($key); }
/** * Verifies whether the current user can access the donation receipt. * * @param Charitable_Donation $donation * @return boolean * @since 1.1.2 */ function charitable_user_can_access_receipt(Charitable_Donation $donation) { charitable_get_deprecated()->deprecated_function(__FUNCTION__, '1.4.0', 'Charitable_Donation::is_from_current_user()'); return $donation->is_from_current_user(); }
function test_charitable_get_deprecated() { $this->assertInstanceOf('Charitable_Deprecated', charitable_get_deprecated()); }
/** * Respond to changes in donation status. * * @param string $new_status * @param string $old_status * @param WP_Post $post * @return void * @access public * @since 1.2.0 * * @deprecated 1.4.0 */ public function handle_donation_status_change($new_status, $old_status, $post) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', __('Handled automatically when $donation->update_status() is called.', 'reach')); if (Charitable::DONATION_POST_TYPE != $post->post_type) { return; } $valid_statuses = charitable_get_valid_donation_statuses(); if ('new' == $old_status) { $message = sprintf(__('Donation status set to %s.', 'charitable'), $valid_statuses[$new_status]); } else { $message = sprintf(__('Donation status updated from %s to %s.', 'charitable'), $valid_statuses[$old_status], $valid_statuses[$new_status]); } charitable_get_donation($post->ID)->update_donation_log($message); }
/** * Returns the campaign ID clause. * * @param int|int[] $campaigns * @return array * @access private * @since 1.0.0 * * @deprecated 1.4.0 */ private function get_campaigns_clause($campaigns) { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', 'Charitable_Campaign_Donations_DB::get_in_clause_params()'); return $this->get_in_clause_params($campaigns); }
/** * Display the Charitable donations page. * * @return void * @access public * @since 1.0.0 * * @deprecated 1.4.0 */ public function render_donations_page() { charitable_get_deprecated()->deprecated_function(__METHOD__, '1.4.0', __('Donations page now rendered by WordPress default manage_edit-donation_columns', 'charitable')); charitable_admin_view('donations-page/page'); }