/** * On the Donation page, customize the title shown in the banner. * * @param string $title * @return string */ function ed_set_donation_page_banner_title($title) { if (charitable_is_page('campaign_donation_page')) { $title = 'Donation to ' . $title; } return $title; }
/** * Check whether we have clicked on a password reset link. * * If so, redirect to the password reset page without the query string. * * @return false|void False if no redirect takes place. * @access public * @since 1.4.0 */ public function maybe_redirect_to_password_reset() { if (!charitable_is_page('reset_password_page')) { return false; } if (!isset($_GET['key']) || !isset($_GET['login'])) { return false; } $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key'])); $this->set_reset_cookie($value); wp_safe_redirect(esc_url_raw(charitable_get_permalink('reset_password_page'))); exit; }
/** * Load the email template if we're looking at the email page. * * @param string $template * @return string * @access public * @since 1.0.0 */ public function email_template($template) { if (charitable_is_page('email_preview')) { do_action('charitable_email_preview'); $template = charitable_get_template_path('emails/preview.php'); } return $template; }
/** * Render the content of the reset password page. * * @param string $content * @return string * @since 1.4.0 */ function charitable_template_reset_password_content($content = '') { if (!charitable_is_page('reset_password_page')) { return $content; } ob_start(); charitable_template('account/reset-password.php', array('form' => new Charitable_Reset_Password_Form())); $content = ob_get_clean(); return $content; }
/** * Load the correct template based on the current request. * * @return string $template * @access public * @since 1.3.0 */ public function template_loader($template) { if (charitable_is_page('donation_receipt_page')) { return $this->get_donation_receipt_template($template); } if (charitable_is_page('donation_processing_page')) { return $this->get_donation_processing_template($template); } if (charitable_is_page('campaign_donation_page', array('strict' => true))) { return $this->get_donate_template($template); } if (charitable_is_page('campaign_widget_page')) { return $this->get_widget_template($template); } if (charitable_is_page('email_preview')) { return $this->get_email_template($template); } if (charitable_is_page('forgot_password_page')) { return $this->get_forgot_password_template($template); } if (charitable_is_page('reset_password_page')) { return $this->get_reset_password_template($template); } return $template; }
/** * Cancel a donation. * * @global WP_Query $wp_query * * @return boolean True if the donation was cancelled. False otherwise. * @since 1.4.0 */ function charitable_cancel_donation() { global $wp_query; if (!charitable_is_page('donation_cancel_page')) { return false; } if (!isset($wp_query->query_vars['donation_id'])) { return false; } $donation = charitable_get_donation($wp_query->query_vars['donation_id']); if (!$donation) { return false; } /* Donations can only be cancelled if they are currently pending. */ if ('charitable-pending' != $donation->get_status()) { return false; } if (!$donation->is_from_current_user()) { return false; } $donation->update_status('charitable-cancelled'); return true; }
/** * Disable comments on application pages like the donation page. * * @param boolean $open * @param int $post_id * @return boolean * @access public * @since 1.3.0 */ public function disable_comments_on_application_pages($open, $post_id) { /* If open is already false, just hit return. */ if (!$open) { return $open; } if (charitable_is_page('campaign_donation_page', array('strict' => true)) || charitable_is_page('campaign_widget_page') || charitable_is_page('donation_receipt_page') || charitable_is_page('donation_processing_page')) { $open = false; } return $open; }
/** * Checks whether the current request is for the donation cancel page. * * This is used when you call charitable_is_page( 'donation_cancel_page' ). * In general, you should use charitable_is_page() instead since it will * take into account any filtering by plugins/themes. * * @global WP_Query $wp_query * * @return boolean * @since 1.4.0 */ function charitable_is_donation_cancel_page() { global $wp_query; return charitable_is_page('campaign_donation_page') && isset($wp_query->query_vars['donation_id']) && isset($wp_query->query_vars['cancel']) && $wp_query->query_vars['cancel']; }
/** * Render the content of the donation processing page. * * @param string $content * @return string * @since 1.2.0 */ function charitable_template_donation_processing_content($content) { if (!charitable_is_page('donation_processing_page')) { return $content; } $donation = charitable_get_current_donation(); if (!$donation) { return $content; } $content = apply_filters('charitable_processing_donation_' . $donation->get_gateway(), $content, $donation); return $content; }
/** * Load the donation receipt inside the user dashboard. * * @param boolean $ret * @return boolean * @access public * @since 1.0.0 */ public function load_donation_receipt_in_user_dashboard($ret) { if (is_front_page() || is_home()) { return false; } if (charitable_is_page('donation_receipt_page')) { $ret = true; } return $ret; }