/** * Add a new campaign donation. * * @param array $data * @return int The ID of the inserted donor. * @access public * @since 1.0.0 */ public function insert($data, $type = 'donors') { return parent::insert($data, $type); }
/** * Add a new campaign donation. * * @param array $data * @return int The ID of the inserted campaign donation * @access public * @since 1.0.0 */ public function insert($data, $type = 'campaign_donation') { if (!isset($data['campaign_name'])) { $data['campaign_name'] = get_the_title($data['campaign_id']); } Charitable_Campaign::flush_donations_cache($data['campaign_id']); return parent::insert($data, $type); }
/** * Add a new benefactor object. * * @param array $data * @return int Positive ID if successful. 0 if failed. * @access public * @since 1.0.0 */ public function insert($data, $type = 'campaign_benefactor') { /* Allow plugins to filter the data before inserting to database */ $data = apply_filters('charitable_benefactor_data', $data); /* An array detailing the benefactor must be provided. */ if (!isset($data['benefactor']) || !is_array($data['benefactor']) || empty($data['benefactor'])) { _doing_it_wrong(__METHOD__, 'Campaign benefactors cannot be created without benefactor details.', '1.0.0'); return 0; } /* A contribution amount must be set */ if (empty($data['contribution_amount']) || !is_numeric($data['contribution_amount'])) { _doing_it_wrong(__METHOD__, 'Campaign benefactors cannot be created without a contribution amount.', '1.0.0'); return 0; } /* Pull out the benefactor details. These are passed to the 3rd party plugins */ $benefactor_details = $data['benefactor']; unset($data['benefactor']); /* Create the record */ $campaign_benefactor_id = parent::insert($data, $type); /* Allow plugins to hook into this event */ do_action('charitable_benefactor_added', $campaign_benefactor_id, $benefactor_details, $data); return $campaign_benefactor_id; }