public function dispatch() { $listing_id = intval(isset($_REQUEST['listing_id']) ? $_REQUEST['listing_id'] : 0); if (!$listing_id) { return ''; } if (!$this->can_submit($listing_id, $error_msg)) { return wpbdp_render_msg($error_msg, 'error'); } $this->listing_id = $listing_id; $this->prepare_input(); if (!$this->validate()) { return $this->render_form($listing_id, $this->errors); } // Compose e-mail message. $replacements = array('listing-url' => get_permalink($listing_id), 'listing' => get_the_title($listing_id), 'name' => $this->name, 'email' => $this->email, 'message' => $this->message, 'date' => date_i18n(__('l F j, Y \\a\\t g:i a'), current_time('timestamp'))); $email = wpbdp_email_from_template('email-templates-contact', $replacements); $email->from = "{$this->name} <{$this->email}>"; $email->to = wpbusdirman_get_the_business_email($listing_id); $email->reply_to = $this->email; $email->template = 'businessdirectory-email'; if (in_array('listing-contact', wpbdp_get_option('admin-notifications'), true)) { $email->cc[] = get_bloginfo('admin_email'); if (wpbdp_get_option('admin-notifications-cc')) { $email->cc[] = wpbdp_get_option('admin-notifications-cc'); } } $html = ''; if ($email->send()) { $html .= wpbdp_render_msg('Your message has been sent.', 'contact-message', 'WPBDM'); $this->update_contacts($listing_id); } else { $html .= wpbdp_render_msg(_x("There was a problem encountered. Your message has not been sent", 'contact-message', "WPBDM"), 'error'); } $html .= sprintf('<p><a href="%s">%s</a></p>', get_permalink($listing_id), _x('Return to listing.', 'contact-message', "WPBDM")); return $html; }
/** * @since 3.5.8 */ public function notify_abandoned_payments() { global $wpdb; $threshold = max(1, absint(wpbdp_get_option('payment-abandonment-threshold'))); $time_for_pending = wpbdp_format_time(strtotime("-{$threshold} hours", current_time('timestamp')), 'mysql'); $notified = get_option('wpbdp-payment-abandonment-notified', array()); if (!is_array($notified)) { $notified = array(); } // For now, we only notify listings with pending INITIAL payments. $to_notify = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}wpbdp_payments WHERE status = %s AND tag = %s AND processed_on IS NULL AND created_on < %s ORDER BY created_on", 'pending', 'initial', $time_for_pending)); foreach ($to_notify as &$data) { if (in_array($data->id, $notified)) { continue; } $payment = WPBDP_Payment::get($data->id); // Send e-mail. $replacements = array('listing' => get_the_title($payment->get_listing_id()), 'link' => sprintf('<a href="%1$s">%1$s</a>', esc_url($payment->get_checkout_url()))); $email = wpbdp_email_from_template('email-templates-payment-abandoned', $replacements); $email->to[] = wpbusdirman_get_the_business_email($payment->get_listing_id()); $email->template = 'businessdirectory-email'; $email->send(); $notified[] = $data->id; } update_option('wpbdp-payment-abandonment-notified', $notified); }