PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / endpoints / class-charitable-email-preview-endpoint.php

class-charitable-email-preview-endpoint.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.3, at includes/endpoints/class-charitable-email-preview-endpoint.php

111 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Email preview endpoint.
4 *
5 * @package Charitable/Classes/Charitable_Email_Preview_Endpoint
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.5.0
10 * @version 1.6.55
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Email_Preview_Endpoint' ) ) :
18
19 /**
20 * Charitable_Email_Preview_Endpoint
21 *
22 * @since 1.5.0
23 */
24 class Charitable_Email_Preview_Endpoint extends Charitable_Endpoint {
25
26 /** Endpoint ID. */
27 const ID = 'email_preview';
28
29 /**
30 * Return the endpoint ID.
31 *
32 * @since 1.5.0
33 *
34 * @return string
35 */
36 public static function get_endpoint_id() {
37 return self::ID;
38 }
39
40 /**
41 * Return the endpoint URL.
42 *
43 * @since 1.5.0
44 *
45 * @param array $args Mixed arguments.
46 * @return string
47 */
48 public function get_page_url( $args = array() ) {
49 if ( ! array_key_exists( 'email_id', $args ) ) {
50 charitable_get_deprecated()->doing_it_wrong(
51 __METHOD__,
52 __( 'Missing email_id in args for email preview endpoint URL.', 'charitable' ),
53 '1.5.0'
54 );
55
56 return '';
57 }
58
59 return esc_url_raw(
60 add_query_arg(
61 array(
62 'charitable_action' => 'preview_email',
63 'email_id' => $args['email_id'],
64 ),
65 home_url()
66 )
67 );
68 }
69
70 /**
71 * Return whether we are currently viewing the endpoint.
72 *
73 * @since 1.5.0
74 *
75 * @param array $args Mixed arguments.
76 * @return boolean
77 */
78 public function is_page( $args = array() ) {
79 return array_key_exists( 'charitable_action', $_GET ) && 'preview_email' === $_GET['charitable_action']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
80 }
81
82 /**
83 * Whether the endpoint uses a custom template.
84 *
85 * @since 1.8.1.6
86 *
87 * @return boolean
88 */
89 public function uses_custom_template() {
90 return true;
91 }
92
93 /**
94 * Return the template to display for this endpoint.
95 *
96 * @since 1.5.0
97 * @since 1.6.55 Now returns an array.
98 *
99 * @param string $template The default template.
100 * @return array
101 */
102 public function get_template( $template ) {
103
104 do_action( 'charitable_email_preview' );
105
106 return array( 'emails/preview.php' );
107 }
108 }
109
110 endif;
111