Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
public/Espresso_Arabica_2014/functions.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  * @ link			http://www.eventespresso.com
10 10
  * @ version		4+
11 11
  */
12
-define( 'EE_THEME_FUNCTIONS_LOADED', TRUE );
12
+define('EE_THEME_FUNCTIONS_LOADED', TRUE);
13 13
 
14
-if ( ! function_exists( 'espresso_pagination' ) ) {
14
+if ( ! function_exists('espresso_pagination')) {
15 15
 	/**
16 16
 	 *    espresso_pagination
17 17
 	 *
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 		$big = 999999999; // need an unlikely integer
24 24
 		$pagination = paginate_links(
25 25
 			array(
26
-				'base'         => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
26
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
27 27
 				'format'       => '?paged=%#%',
28
-				'current'      => max( 1, get_query_var( 'paged' ) ),
28
+				'current'      => max(1, get_query_var('paged')),
29 29
 				'total'        => $wp_query->max_num_pages,
30 30
 				'show_all'     => true,
31 31
 				'end_size'     => 10,
32 32
 				'mid_size'     => 6,
33 33
 				'prev_next'    => true,
34
-				'prev_text'    => esc_html__( '‹ PREV', 'event_espresso' ),
35
-				'next_text'    => esc_html__( 'NEXT ›', 'event_espresso' ),
34
+				'prev_text'    => esc_html__('‹ PREV', 'event_espresso'),
35
+				'next_text'    => esc_html__('NEXT ›', 'event_espresso'),
36 36
 				'type'         => 'plain',
37 37
 				'add_args'     => false,
38 38
 				'add_fragment' => ''
39 39
 			)
40 40
 		);
41
-		echo ! empty( $pagination ) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
41
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
42 42
 	}
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/messages/data_class/EE_Messages_REG_incoming_data.class.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $filtered_reg_status = null;
33 33
 
34
-        if (! is_array($data) && $data instanceof EE_Registration) {
34
+        if ( ! is_array($data) && $data instanceof EE_Registration) {
35 35
             $this->reg_obj = $data;
36 36
         } else {
37 37
             $this->reg_obj = is_array($data) && isset($data[0]) && $data[0] instanceof EE_Registration ? $data[0] : null;
38 38
             $filtered_reg_status = is_array($data) && ! empty($data[1]) ? $data[1] : null;
39 39
         }
40 40
 
41
-        if (! $this->reg_obj instanceof EE_Registration) {
41
+        if ( ! $this->reg_obj instanceof EE_Registration) {
42 42
             throw new EE_Error(
43 43
                 sprintf(
44 44
                     esc_html__('%1$s requires the incoming data argument to be an instance of %2$s or an array where the first value is an instance of %2$s', 'event_espresso'),
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     public static function convert_data_for_persistent_storage($data)
67 67
     {
68 68
         $prepped_data = array();
69
-        if (! is_array($data) && $data instanceof EE_Registration) {
69
+        if ( ! is_array($data) && $data instanceof EE_Registration) {
70 70
             $prepped_data['Registration'] = $data->ID();
71 71
             return $prepped_data;
72
-        } elseif (! is_array($data)) {
72
+        } elseif ( ! is_array($data)) {
73 73
             return array();
74 74
         } else {
75 75
             if ($data[0] instanceof EE_Registration) {
76 76
                 $prepped_data['Registration'] = $data[0];
77 77
             }
78
-            if (! empty($data[1])) {
78
+            if ( ! empty($data[1])) {
79 79
                 $prepped_data['filter'] = $data[1];
80 80
             }
81 81
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $this->txn = $this->reg_obj->transaction();
122 122
         // possible session stuff?
123 123
         $session = $this->txn->session_data();
124
-        $session_data =  $session instanceof EE_Session ? $session->get_session_data() : array();
124
+        $session_data = $session instanceof EE_Session ? $session->get_session_data() : array();
125 125
 
126 126
         // other data from the session (if possible)
127 127
         $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -15,137 +15,137 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Messages_REG_incoming_data extends EE_Messages_incoming_data
17 17
 {
18
-    /**
19
-     * For the constructor of this special preview class.
20
-     *
21
-     * The data is expected to be an array that came from the request data
22
-     * and should have at least one property from the list looked for.
23
-     *
24
-     * @param EE_Registration|array $data
25
-     * @throws \EE_Error
26
-     */
27
-    public function __construct($data)
28
-    {
29
-        $filtered_reg_status = null;
30
-
31
-        if (! is_array($data) && $data instanceof EE_Registration) {
32
-            $this->reg_obj = $data;
33
-        } else {
34
-            $this->reg_obj = is_array($data) && isset($data[0]) && $data[0] instanceof EE_Registration ? $data[0] : null;
35
-            $filtered_reg_status = is_array($data) && ! empty($data[1]) ? $data[1] : null;
36
-        }
37
-
38
-        if (! $this->reg_obj instanceof EE_Registration) {
39
-            throw new EE_Error(
40
-                sprintf(
41
-                    esc_html__('%1$s requires the incoming data argument to be an instance of %2$s or an array where the first value is an instance of %2$s', 'event_espresso'),
42
-                    'EE_Messages_REG_incoming_data',
43
-                    'EE_Registration'
44
-                )
45
-            );
46
-        }
47
-
48
-        $data = array(
49
-            'reg_obj' => $this->reg_obj,
50
-            'filtered_reg_status' => $filtered_reg_status
51
-            );
52
-
53
-        parent::__construct($data);
54
-    }
55
-
56
-    /**
57
-     * Returns database safe representation of the data later used to when instantiating this object.
58
-     *
59
-     * @param mixed $data The incoming data to be prepped.
60
-     *
61
-     * @return array   The prepped data for db
62
-     */
63
-    public static function convert_data_for_persistent_storage($data)
64
-    {
65
-        $prepped_data = array();
66
-        if (! is_array($data) && $data instanceof EE_Registration) {
67
-            $prepped_data['Registration'] = $data->ID();
68
-            return $prepped_data;
69
-        } elseif (! is_array($data)) {
70
-            return array();
71
-        } else {
72
-            if ($data[0] instanceof EE_Registration) {
73
-                $prepped_data['Registration'] = $data[0];
74
-            }
75
-            if (! empty($data[1])) {
76
-                $prepped_data['filter'] = $data[1];
77
-            }
78
-        }
79
-
80
-        return $prepped_data;
81
-    }
82
-
83
-    /**
84
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
85
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
86
-     *
87
-     * @param $data
88
-     *
89
-     * @return mixed
90
-     */
91
-    public static function convert_data_from_persistent_storage($data)
92
-    {
93
-        $registration = null;
94
-        // $data['Registration'] could be either an ID (back compat) or a registration object (prepped using old system).
95
-        if (isset($data['Registration'])) {
96
-            $registration = $data['Registration'] instanceof EE_Registration
97
-                ? $data['Registration']
98
-                : EEM_Registration::instance()->get_one_by_ID($data['Registration']);
99
-        }
100
-        $prepped_data = array(
101
-            0 => $registration,
102
-            1 => isset($data['filter']) ? $data['filter'] : null
103
-        );
104
-        return $prepped_data;
105
-    }
106
-
107
-
108
-    /**
109
-     * This will just setup the _events property in the expected format.
110
-     * @return void
111
-     */
112
-    protected function _setup_data()
113
-    {
114
-
115
-        // now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
116
-        $this->filtered_reg_status = $this->_data['filtered_reg_status'];
117
-        // get txn
118
-        $this->txn = $this->reg_obj->transaction();
119
-        // possible session stuff?
120
-        $session = $this->txn->session_data();
121
-        $session_data =  $session instanceof EE_Session ? $session->get_session_data() : array();
122
-
123
-        // other data from the session (if possible)
124
-        $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
125
-        $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
126
-        $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
127
-        $this->init_access = $this->last_access = '';
128
-
129
-        $this->payment = $this->txn->get_first_related('Payment');
130
-        // if there is no payments associated with the transaction
131
-        // then we just create a default payment object for potential parsing.
132
-        $this->payment = empty($this->payment)
133
-            ? EE_Payment::new_instance(
134
-                array(
135
-                    'STS_ID'               => EEM_Payment::status_id_pending,
136
-                    'PAY_timestamp'        => time(),
137
-                    'PMD_ID'               => $this->txn->payment_method_ID(),
138
-                    'PAY_gateway_response' => $this->txn->gateway_response_on_transaction(),
139
-                )
140
-            )
141
-            : $this->payment;
142
-
143
-
144
-        // get reg_objs for txn
145
-        $this->reg_objs = $this->txn->registrations();
146
-
147
-        // now we can set things up like we do for other handlers
148
-
149
-        $this->_assemble_data();
150
-    }
18
+	/**
19
+	 * For the constructor of this special preview class.
20
+	 *
21
+	 * The data is expected to be an array that came from the request data
22
+	 * and should have at least one property from the list looked for.
23
+	 *
24
+	 * @param EE_Registration|array $data
25
+	 * @throws \EE_Error
26
+	 */
27
+	public function __construct($data)
28
+	{
29
+		$filtered_reg_status = null;
30
+
31
+		if (! is_array($data) && $data instanceof EE_Registration) {
32
+			$this->reg_obj = $data;
33
+		} else {
34
+			$this->reg_obj = is_array($data) && isset($data[0]) && $data[0] instanceof EE_Registration ? $data[0] : null;
35
+			$filtered_reg_status = is_array($data) && ! empty($data[1]) ? $data[1] : null;
36
+		}
37
+
38
+		if (! $this->reg_obj instanceof EE_Registration) {
39
+			throw new EE_Error(
40
+				sprintf(
41
+					esc_html__('%1$s requires the incoming data argument to be an instance of %2$s or an array where the first value is an instance of %2$s', 'event_espresso'),
42
+					'EE_Messages_REG_incoming_data',
43
+					'EE_Registration'
44
+				)
45
+			);
46
+		}
47
+
48
+		$data = array(
49
+			'reg_obj' => $this->reg_obj,
50
+			'filtered_reg_status' => $filtered_reg_status
51
+			);
52
+
53
+		parent::__construct($data);
54
+	}
55
+
56
+	/**
57
+	 * Returns database safe representation of the data later used to when instantiating this object.
58
+	 *
59
+	 * @param mixed $data The incoming data to be prepped.
60
+	 *
61
+	 * @return array   The prepped data for db
62
+	 */
63
+	public static function convert_data_for_persistent_storage($data)
64
+	{
65
+		$prepped_data = array();
66
+		if (! is_array($data) && $data instanceof EE_Registration) {
67
+			$prepped_data['Registration'] = $data->ID();
68
+			return $prepped_data;
69
+		} elseif (! is_array($data)) {
70
+			return array();
71
+		} else {
72
+			if ($data[0] instanceof EE_Registration) {
73
+				$prepped_data['Registration'] = $data[0];
74
+			}
75
+			if (! empty($data[1])) {
76
+				$prepped_data['filter'] = $data[1];
77
+			}
78
+		}
79
+
80
+		return $prepped_data;
81
+	}
82
+
83
+	/**
84
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
85
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
86
+	 *
87
+	 * @param $data
88
+	 *
89
+	 * @return mixed
90
+	 */
91
+	public static function convert_data_from_persistent_storage($data)
92
+	{
93
+		$registration = null;
94
+		// $data['Registration'] could be either an ID (back compat) or a registration object (prepped using old system).
95
+		if (isset($data['Registration'])) {
96
+			$registration = $data['Registration'] instanceof EE_Registration
97
+				? $data['Registration']
98
+				: EEM_Registration::instance()->get_one_by_ID($data['Registration']);
99
+		}
100
+		$prepped_data = array(
101
+			0 => $registration,
102
+			1 => isset($data['filter']) ? $data['filter'] : null
103
+		);
104
+		return $prepped_data;
105
+	}
106
+
107
+
108
+	/**
109
+	 * This will just setup the _events property in the expected format.
110
+	 * @return void
111
+	 */
112
+	protected function _setup_data()
113
+	{
114
+
115
+		// now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
116
+		$this->filtered_reg_status = $this->_data['filtered_reg_status'];
117
+		// get txn
118
+		$this->txn = $this->reg_obj->transaction();
119
+		// possible session stuff?
120
+		$session = $this->txn->session_data();
121
+		$session_data =  $session instanceof EE_Session ? $session->get_session_data() : array();
122
+
123
+		// other data from the session (if possible)
124
+		$this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
125
+		$this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
126
+		$this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
127
+		$this->init_access = $this->last_access = '';
128
+
129
+		$this->payment = $this->txn->get_first_related('Payment');
130
+		// if there is no payments associated with the transaction
131
+		// then we just create a default payment object for potential parsing.
132
+		$this->payment = empty($this->payment)
133
+			? EE_Payment::new_instance(
134
+				array(
135
+					'STS_ID'               => EEM_Payment::status_id_pending,
136
+					'PAY_timestamp'        => time(),
137
+					'PMD_ID'               => $this->txn->payment_method_ID(),
138
+					'PAY_gateway_response' => $this->txn->gateway_response_on_transaction(),
139
+				)
140
+			)
141
+			: $this->payment;
142
+
143
+
144
+		// get reg_objs for txn
145
+		$this->reg_objs = $this->txn->registrations();
146
+
147
+		// now we can set things up like we do for other handlers
148
+
149
+		$this->_assemble_data();
150
+	}
151 151
 }
Please login to merge, or discard this patch.
libraries/messages/data_class/EE_Messages_Gateways_incoming_data.class.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     {
33 33
 
34 34
         // test for valid params
35
-        if (! ( $data[0] instanceof EE_Transaction )) {
35
+        if ( ! ($data[0] instanceof EE_Transaction)) {
36 36
             throw new EE_Error(esc_html__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso'));
37 37
         }
38 38
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $pmt_obj = $this->_get_empty_payment_obj($data[0]);
41 41
         }
42 42
 
43
-        if (! empty($data[2])) {
43
+        if ( ! empty($data[2])) {
44 44
             $filtered_reg_status = $data[2];
45 45
         }
46 46
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $prepped_data['Payment'] = $data[1]->ID();
76 76
         }
77 77
 
78
-        if (! empty($data[2])) {
78
+        if ( ! empty($data[2])) {
79 79
             $prepped_data['filter'] = $data[2];
80 80
         }
81 81
 
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -13,141 +13,141 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messages_Gateways_incoming_data extends EE_Messages_incoming_data
15 15
 {
16
-    /**
17
-     * This holds the incoming payment object
18
-     * @var EE_Payment
19
-     */
20
-    public $payment;
21
-
22
-
23
-
24
-    /**
25
-     * incoming data is expected to be a EE_Transaction object and (possibly) EE_Payment object in an array.
26
-     *
27
-     * @param array $data
28
-     * @throws EE_Error
29
-     */
30
-    public function __construct($data)
31
-    {
32
-
33
-        // test for valid params
34
-        if (! ( $data[0] instanceof EE_Transaction )) {
35
-            throw new EE_Error(esc_html__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso'));
36
-        }
37
-
38
-        if (empty($data[1]) || ! $data[1] instanceof  EE_Payment) {
39
-            $pmt_obj = $this->_get_empty_payment_obj($data[0]);
40
-        }
41
-
42
-        if (! empty($data[2])) {
43
-            $filtered_reg_status = $data[2];
44
-        }
16
+	/**
17
+	 * This holds the incoming payment object
18
+	 * @var EE_Payment
19
+	 */
20
+	public $payment;
21
+
22
+
23
+
24
+	/**
25
+	 * incoming data is expected to be a EE_Transaction object and (possibly) EE_Payment object in an array.
26
+	 *
27
+	 * @param array $data
28
+	 * @throws EE_Error
29
+	 */
30
+	public function __construct($data)
31
+	{
32
+
33
+		// test for valid params
34
+		if (! ( $data[0] instanceof EE_Transaction )) {
35
+			throw new EE_Error(esc_html__('Incoming data for the Gateways data handler must have an EE_Transaction object as the value for the first array index.', 'event_espresso'));
36
+		}
37
+
38
+		if (empty($data[1]) || ! $data[1] instanceof  EE_Payment) {
39
+			$pmt_obj = $this->_get_empty_payment_obj($data[0]);
40
+		}
41
+
42
+		if (! empty($data[2])) {
43
+			$filtered_reg_status = $data[2];
44
+		}
45 45
 
46
-        $data = array(
47
-            'txn_obj' => $data[0],
48
-            'pmt_obj' => isset($pmt_obj) ? $pmt_obj : $data[1],
49
-            'filtered_reg_status' => isset($filtered_reg_status) ? $filtered_reg_status : null
50
-            );
51
-        parent::__construct($data);
52
-    }
53
-
54
-
55
-
56
-
57
-
58
-    /**
59
-     * Returns database safe representation of the data later used to when instantiating this object.
60
-     *
61
-     * @param array $data The incoming data to be prepped.
62
-     *
63
-     * @return array   The prepped data for db
64
-     */
65
-    public static function convert_data_for_persistent_storage($data)
66
-    {
67
-        $prepped_data = array();
68
-
69
-        if ($data[0] instanceof EE_Transaction) {
70
-            $prepped_data['Transaction'] = $data[0]->ID();
71
-        }
72
-
73
-        if (isset($data[1]) && $data[1] instanceof EE_Payment) {
74
-            $prepped_data['Payment'] = $data[1]->ID();
75
-        }
76
-
77
-        if (! empty($data[2])) {
78
-            $prepped_data['filter'] = $data[2];
79
-        }
80
-
81
-        return $prepped_data;
82
-    }
83
-
84
-
85
-
86
-
87
-
88
-
89
-    /**
90
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
91
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
92
-     *
93
-     * @param array  $data
94
-     *
95
-     * @return array
96
-     */
97
-    public static function convert_data_from_persistent_storage($data)
98
-    {
99
-        $prepped_data = array(
100
-            0 => isset($data['Transaction']) ? EEM_Transaction::instance()->get_one_by_ID($data['Transaction']) : null,
101
-            1 => isset($data['Payment']) ? EEM_Payment::instance()->get_one_by_ID($data['Payment']) : null,
102
-            2 => isset($data['filter']) ? $data['filter'] : null
103
-        );
104
-        return $prepped_data;
105
-    }
106
-
107
-
108
-    /**
109
-     * This sets up an empty EE_Payment object for the purpose of shortcode parsing.  Note that this doesn't actually get saved to the db.
110
-     * @param \EE_Transaction $txn
111
-     * @return \EE_Payment
112
-     */
113
-    private function _get_empty_payment_obj(EE_Transaction $txn)
114
-    {
115
-        $PMT = EE_Payment::new_instance(array(
116
-            'STS_ID' => EEM_Payment::status_id_pending,
117
-            'PAY_timestamp' => time(),
118
-            'PMD_ID' => $txn->payment_method_ID(),
119
-            'PAY_gateway_response' => $txn->gateway_response_on_transaction(),
120
-            ));
121
-        return $PMT;
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * _setup_data
128
-     *
129
-     * @throws EE_Error
130
-     */
131
-    protected function _setup_data()
132
-    {
133
-
134
-        $this->reg_info = array();
135
-
136
-        $this->txn = $this->_data['txn_obj'];
137
-        $this->payment = $this->_data['pmt_obj'];
138
-        $this->filtered_reg_status = $this->_data['filtered_reg_status'];
139
-        $this->incoming_data = $this->_data;
140
-
141
-        $session_data = $this->txn->session_data();
142
-
143
-
144
-        // other data from the session (if possible)
145
-        $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
146
-        $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
147
-        $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
148
-        $this->init_access = $this->last_access = '';
149
-        // get all non-trashed registrations
150
-        $this->reg_objs = $this->txn->registrations(array(array('REG_deleted' => false)));
151
-        $this->_assemble_data();
152
-    }
46
+		$data = array(
47
+			'txn_obj' => $data[0],
48
+			'pmt_obj' => isset($pmt_obj) ? $pmt_obj : $data[1],
49
+			'filtered_reg_status' => isset($filtered_reg_status) ? $filtered_reg_status : null
50
+			);
51
+		parent::__construct($data);
52
+	}
53
+
54
+
55
+
56
+
57
+
58
+	/**
59
+	 * Returns database safe representation of the data later used to when instantiating this object.
60
+	 *
61
+	 * @param array $data The incoming data to be prepped.
62
+	 *
63
+	 * @return array   The prepped data for db
64
+	 */
65
+	public static function convert_data_for_persistent_storage($data)
66
+	{
67
+		$prepped_data = array();
68
+
69
+		if ($data[0] instanceof EE_Transaction) {
70
+			$prepped_data['Transaction'] = $data[0]->ID();
71
+		}
72
+
73
+		if (isset($data[1]) && $data[1] instanceof EE_Payment) {
74
+			$prepped_data['Payment'] = $data[1]->ID();
75
+		}
76
+
77
+		if (! empty($data[2])) {
78
+			$prepped_data['filter'] = $data[2];
79
+		}
80
+
81
+		return $prepped_data;
82
+	}
83
+
84
+
85
+
86
+
87
+
88
+
89
+	/**
90
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
91
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
92
+	 *
93
+	 * @param array  $data
94
+	 *
95
+	 * @return array
96
+	 */
97
+	public static function convert_data_from_persistent_storage($data)
98
+	{
99
+		$prepped_data = array(
100
+			0 => isset($data['Transaction']) ? EEM_Transaction::instance()->get_one_by_ID($data['Transaction']) : null,
101
+			1 => isset($data['Payment']) ? EEM_Payment::instance()->get_one_by_ID($data['Payment']) : null,
102
+			2 => isset($data['filter']) ? $data['filter'] : null
103
+		);
104
+		return $prepped_data;
105
+	}
106
+
107
+
108
+	/**
109
+	 * This sets up an empty EE_Payment object for the purpose of shortcode parsing.  Note that this doesn't actually get saved to the db.
110
+	 * @param \EE_Transaction $txn
111
+	 * @return \EE_Payment
112
+	 */
113
+	private function _get_empty_payment_obj(EE_Transaction $txn)
114
+	{
115
+		$PMT = EE_Payment::new_instance(array(
116
+			'STS_ID' => EEM_Payment::status_id_pending,
117
+			'PAY_timestamp' => time(),
118
+			'PMD_ID' => $txn->payment_method_ID(),
119
+			'PAY_gateway_response' => $txn->gateway_response_on_transaction(),
120
+			));
121
+		return $PMT;
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * _setup_data
128
+	 *
129
+	 * @throws EE_Error
130
+	 */
131
+	protected function _setup_data()
132
+	{
133
+
134
+		$this->reg_info = array();
135
+
136
+		$this->txn = $this->_data['txn_obj'];
137
+		$this->payment = $this->_data['pmt_obj'];
138
+		$this->filtered_reg_status = $this->_data['filtered_reg_status'];
139
+		$this->incoming_data = $this->_data;
140
+
141
+		$session_data = $this->txn->session_data();
142
+
143
+
144
+		// other data from the session (if possible)
145
+		$this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
146
+		$this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
147
+		$this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
148
+		$this->init_access = $this->last_access = '';
149
+		// get all non-trashed registrations
150
+		$this->reg_objs = $this->txn->registrations(array(array('REG_deleted' => false)));
151
+		$this->_assemble_data();
152
+	}
153 153
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_To_Generate_From_Request.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             [],
53 53
             $request->getRequestParam('context')
54 54
         );
55
-        if (! $this->valid()) {
55
+        if ( ! $this->valid()) {
56 56
             return;
57 57
         }
58 58
         $this->token              = $request->getRequestParam('token');
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         /** @type EE_Registration $registration */
109 109
         $registration = EEM_Registration::instance()->get_one([['REG_url_link' => $this->token]]);
110 110
         // if no registration then bail early.
111
-        if (! $registration instanceof EE_Registration) {
111
+        if ( ! $registration instanceof EE_Registration) {
112 112
             throw new EE_Error(esc_html__('Unable to complete the request because the token is invalid.', 'event_espresso'));
113 113
         }
114 114
 
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -18,113 +18,113 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Message_To_Generate_From_Request extends EE_Message_To_Generate implements EEI_Has_Sending_Messenger
20 20
 {
21
-    /**
22
-     * This messenger is used to send the generated message.
23
-     *
24
-     * @type EE_messenger
25
-     */
26
-    protected $_sending_messenger = '';
21
+	/**
22
+	 * This messenger is used to send the generated message.
23
+	 *
24
+	 * @type EE_messenger
25
+	 */
26
+	protected $_sending_messenger = '';
27 27
 
28 28
 
29
-    /**
30
-     * Holds the token from the request.
31
-     *
32
-     * @type string
33
-     */
34
-    public $token = '';
29
+	/**
30
+	 * Holds the token from the request.
31
+	 *
32
+	 * @type string
33
+	 */
34
+	public $token = '';
35 35
 
36 36
 
37
-    /**
38
-     * Constructor
39
-     * This instantiates the object using arguments from the given request and calling the parent constructor.
40
-     *
41
-     * @param EE_Message_Resource_Manager $message_resource_manager
42
-     * @param RequestInterface            $request
43
-     * @throws EE_Error
44
-     */
45
-    public function __construct(EE_Message_Resource_Manager $message_resource_manager, RequestInterface $request)
46
-    {
47
-        parent::__construct(
48
-            $request->getRequestParam('gen_msgr'),
49
-            $request->getRequestParam('message_type'),
50
-            [],
51
-            $request->getRequestParam('context')
52
-        );
53
-        if (! $this->valid()) {
54
-            return;
55
-        }
56
-        $this->token              = $request->getRequestParam('token');
57
-        $this->_sending_messenger = $message_resource_manager->get_active_messenger(
58
-            $request->getRequestParam('snd_msgr')
59
-        );
60
-        $this->_validate_request();
61
-        $this->_data = $this->_get_data_from_request($request->getRequestParam('id'));
62
-    }
37
+	/**
38
+	 * Constructor
39
+	 * This instantiates the object using arguments from the given request and calling the parent constructor.
40
+	 *
41
+	 * @param EE_Message_Resource_Manager $message_resource_manager
42
+	 * @param RequestInterface            $request
43
+	 * @throws EE_Error
44
+	 */
45
+	public function __construct(EE_Message_Resource_Manager $message_resource_manager, RequestInterface $request)
46
+	{
47
+		parent::__construct(
48
+			$request->getRequestParam('gen_msgr'),
49
+			$request->getRequestParam('message_type'),
50
+			[],
51
+			$request->getRequestParam('context')
52
+		);
53
+		if (! $this->valid()) {
54
+			return;
55
+		}
56
+		$this->token              = $request->getRequestParam('token');
57
+		$this->_sending_messenger = $message_resource_manager->get_active_messenger(
58
+			$request->getRequestParam('snd_msgr')
59
+		);
60
+		$this->_validate_request();
61
+		$this->_data = $this->_get_data_from_request($request->getRequestParam('id'));
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @return EE_messenger
67
-     */
68
-    public function sending_messenger()
69
-    {
70
-        return $this->_sending_messenger;
71
-    }
65
+	/**
66
+	 * @return EE_messenger
67
+	 */
68
+	public function sending_messenger()
69
+	{
70
+		return $this->_sending_messenger;
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * This validates set properties from the incoming request.
76
-     *
77
-     * @throws EE_Error
78
-     */
79
-    protected function _validate_request()
80
-    {
81
-        if (
82
-            ! $this->_sending_messenger instanceof EE_messenger
83
-            || ! $this->_messenger instanceof EE_messenger
84
-            || ! $this->_message_type instanceof EE_message_type
85
-            || empty($this->_context)
86
-            || empty($this->token)
87
-        ) {
88
-            throw new EE_Error(esc_html__(
89
-                'The request for the "msg_url_trigger" route has a malformed url.',
90
-                'event_espresso'
91
-            ));
92
-        }
93
-    }
74
+	/**
75
+	 * This validates set properties from the incoming request.
76
+	 *
77
+	 * @throws EE_Error
78
+	 */
79
+	protected function _validate_request()
80
+	{
81
+		if (
82
+			! $this->_sending_messenger instanceof EE_messenger
83
+			|| ! $this->_messenger instanceof EE_messenger
84
+			|| ! $this->_message_type instanceof EE_message_type
85
+			|| empty($this->_context)
86
+			|| empty($this->token)
87
+		) {
88
+			throw new EE_Error(esc_html__(
89
+				'The request for the "msg_url_trigger" route has a malformed url.',
90
+				'event_espresso'
91
+			));
92
+		}
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * This returns the data property according to what is expected from the request.
98
-     *
99
-     * @param $id
100
-     * @return mixed (whatever the data is returned from the message type).
101
-     * @throws EE_Error
102
-     */
103
-    protected function _get_data_from_request($id)
104
-    {
105
-        // get the EE_Registration from the token
106
-        /** @type EE_Registration $registration */
107
-        $registration = EEM_Registration::instance()->get_one([['REG_url_link' => $this->token]]);
108
-        // if no registration then bail early.
109
-        if (! $registration instanceof EE_Registration) {
110
-            throw new EE_Error(esc_html__('Unable to complete the request because the token is invalid.', 'event_espresso'));
111
-        }
96
+	/**
97
+	 * This returns the data property according to what is expected from the request.
98
+	 *
99
+	 * @param $id
100
+	 * @return mixed (whatever the data is returned from the message type).
101
+	 * @throws EE_Error
102
+	 */
103
+	protected function _get_data_from_request($id)
104
+	{
105
+		// get the EE_Registration from the token
106
+		/** @type EE_Registration $registration */
107
+		$registration = EEM_Registration::instance()->get_one([['REG_url_link' => $this->token]]);
108
+		// if no registration then bail early.
109
+		if (! $registration instanceof EE_Registration) {
110
+			throw new EE_Error(esc_html__('Unable to complete the request because the token is invalid.', 'event_espresso'));
111
+		}
112 112
 
113
-        return $this->_get_data_to_use($registration, $id);
114
-    }
113
+		return $this->_get_data_to_use($registration, $id);
114
+	}
115 115
 
116 116
 
117
-    /**
118
-     * This uses the set message type to retrieve the data in the correct format as it came from the url.
119
-     *
120
-     * @param EE_Registration $registration
121
-     * @param int             $data_id This is sometimes used for secondary data a message type requires.
122
-     * @return mixed   Data prepared as needed for generating this message.
123
-     * @throws EE_Error
124
-     */
125
-    protected function _get_data_to_use($registration, $data_id)
126
-    {
127
-        // use incoming data from url to setup data for the message type requirements
128
-        return $this->_message_type->get_data_for_context($this->_context, $registration, $data_id);
129
-    }
117
+	/**
118
+	 * This uses the set message type to retrieve the data in the correct format as it came from the url.
119
+	 *
120
+	 * @param EE_Registration $registration
121
+	 * @param int             $data_id This is sometimes used for secondary data a message type requires.
122
+	 * @return mixed   Data prepared as needed for generating this message.
123
+	 * @throws EE_Error
124
+	 */
125
+	protected function _get_data_to_use($registration, $data_id)
126
+	{
127
+		// use incoming data from url to setup data for the message type requirements
128
+		return $this->_message_type->get_data_for_context($this->_context, $registration, $data_id);
129
+	}
130 130
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_message_type.lib.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     {
409 409
         // validate context
410 410
         // valid context?
411
-        if (! isset($this->_contexts[ $context ])) {
411
+        if ( ! isset($this->_contexts[$context])) {
412 412
             throw new EE_Error(
413 413
                 sprintf(
414 414
                     esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     public function get_data_for_context($context, EE_Registration $registration, $id = 0)
465 465
     {
466 466
         // valid context?
467
-        if (! isset($this->_contexts[ $context ])) {
467
+        if ( ! isset($this->_contexts[$context])) {
468 468
             throw new EE_Error(
469 469
                 sprintf(
470 470
                     esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
             $this->_get_data_for_context($context, $registration, $id),
480 480
             $this
481 481
         );
482
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
482
+        $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
483 483
         // if empty then something went wrong!
484 484
         if (empty($data)) {
485 485
             throw new EE_Error(
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
     public function with_messengers()
540 540
     {
541 541
         return apply_filters(
542
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
542
+            'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this),
543 543
             $this->_with_messengers
544 544
         );
545 545
     }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     {
601 601
         // first class specific filter then filter that by the global filter.
602 602
         $master_templates = apply_filters(
603
-            'FHEE__' . get_class($this) . '__get_master_templates',
603
+            'FHEE__'.get_class($this).'__get_master_templates',
604 604
             $this->_master_templates
605 605
         );
606 606
         return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
@@ -624,11 +624,11 @@  discard block
 block discarded – undo
624 624
         $addressees        = array();
625 625
         $original_contexts = $this->_contexts;
626 626
         // if incoming context then limit to that context
627
-        if (! empty($context)) {
628
-            $cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : '';
629
-            if (! empty($cntxt)) {
630
-                $this->_contexts           = array();
631
-                $this->_contexts[ $context ] = $cntxt;
627
+        if ( ! empty($context)) {
628
+            $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
+            if ( ! empty($cntxt)) {
630
+                $this->_contexts = array();
631
+                $this->_contexts[$context] = $cntxt;
632 632
             }
633 633
         }
634 634
         $this->_set_default_addressee_data();
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
     {
654 654
         // at a minimum, we NEED EE_Attendee objects.
655 655
         if (empty($this->_data->attendees)) {
656
-            return false;  // there's no data to process!
656
+            return false; // there's no data to process!
657 657
         }
658 658
         // process addressees for each context.  Child classes will have to have methods for
659 659
         // each context defined to handle the processing of the data object within them
660 660
         foreach ($this->_contexts as $context => $details) {
661
-            $xpctd_method = '_' . $context . '_addressees';
662
-            if (! method_exists($this, $xpctd_method)) {
661
+            $xpctd_method = '_'.$context.'_addressees';
662
+            if ( ! method_exists($this, $xpctd_method)) {
663 663
                 throw new EE_Error(
664 664
                     sprintf(
665 665
                         esc_html__(
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                     )
672 672
                 );
673 673
             }
674
-            $this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method));
674
+            $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
675 675
         }
676 676
         return true; // data was processed successfully.
677 677
     }
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
             'total_ticket_count'       => $this->_data->total_ticket_count,
708 708
         );
709 709
         if (is_array($this->_data->primary_attendee_data)) {
710
-            $this->_default_addressee_data                    = array_merge(
710
+            $this->_default_addressee_data = array_merge(
711 711
                 $this->_default_addressee_data,
712 712
                 $this->_data->primary_attendee_data
713 713
             );
@@ -750,25 +750,25 @@  discard block
 block discarded – undo
750 750
             'email',
751 751
             'messenger',
752 752
         );
753
-        $contexts       = $this->get_contexts();
753
+        $contexts = $this->get_contexts();
754 754
         foreach ($contexts as $context => $details) {
755
-            $this->_valid_shortcodes[ $context ] = $all_shortcodes;
755
+            $this->_valid_shortcodes[$context] = $all_shortcodes;
756 756
             // make sure non admin context does not include the event_author shortcodes
757 757
             if ($context != 'admin') {
758
-                if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) {
759
-                    unset($this->_valid_shortcodes[ $context ][ $key ]);
758
+                if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
759
+                    unset($this->_valid_shortcodes[$context][$key]);
760 760
                 }
761 761
             }
762 762
         }
763 763
         // make sure admin context does not include the recipient_details shortcodes
764 764
         // IF we have admin context hooked in message types might not have that context.
765
-        if (! empty($this->_valid_shortcodes['admin'])) {
765
+        if ( ! empty($this->_valid_shortcodes['admin'])) {
766 766
             if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767
-                unset($this->_valid_shortcodes['admin'][ $key ]);
767
+                unset($this->_valid_shortcodes['admin'][$key]);
768 768
             }
769 769
             // make sure admin context does not include the recipient_details shortcodes
770 770
             if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
771
-                unset($this->_valid_shortcodes['admin'][ $key ]);
771
+                unset($this->_valid_shortcodes['admin'][$key]);
772 772
             }
773 773
         }
774 774
     }
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
     public function reset_valid_shortcodes_config($new_config)
784 784
     {
785 785
         foreach ($new_config as $context => $shortcodes) {
786
-            $this->_valid_shortcodes[ $context ] = $shortcodes;
786
+            $this->_valid_shortcodes[$context] = $shortcodes;
787 787
         }
788 788
     }
789 789
 
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
         foreach ($this->_data->events as $line_ref => $event) {
808 808
             $admin_id = $this->_get_event_admin_id($event['ID']);
809 809
             // make sure we are just including the events that belong to this admin!
810
-            $admin_events[ $admin_id ][ $line_ref ] = $event;
810
+            $admin_events[$admin_id][$line_ref] = $event;
811 811
         }
812 812
         // k now we can loop through the event_admins and setup the addressee data.
813 813
         foreach ($admin_events as $admin_id => $event_details) {
814
-            $aee          = array(
814
+            $aee = array(
815 815
                 'user_id'        => $admin_id,
816 816
                 'events'         => $event_details,
817 817
                 'attendees'      => $this->_data->attendees,
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
             }
870 870
             // is $this->_regs_for_sending present?
871 871
             // If so, let's make sure we ONLY generate addressee for registrations in that array.
872
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
872
+            if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
873 873
                 $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
874 874
                 if (empty($regs_allowed)) {
875 875
                     continue;
@@ -888,10 +888,10 @@  discard block
 block discarded – undo
888 888
             }
889 889
             $already_processed[] = $att_id;
890 890
             foreach ($details as $item => $value) {
891
-                $aee[ $item ] = $value;
891
+                $aee[$item] = $value;
892 892
                 if ($item === 'line_ref') {
893 893
                     foreach ($value as $event_id) {
894
-                        $aee['events'][ $event_id ] = $this->_data->events[ $event_id ];
894
+                        $aee['events'][$event_id] = $this->_data->events[$event_id];
895 895
                     }
896 896
                 }
897 897
                 if ($item === 'attendee_email') {
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
             }
904 904
             // note the FIRST reg object in this array is the one
905 905
             // we'll use for this attendee as the primary registration for this attendee.
906
-            $aee['reg_obj']        = reset($this->_data->attendees[ $att_id ]['reg_objs']);
906
+            $aee['reg_obj']        = reset($this->_data->attendees[$att_id]['reg_objs']);
907 907
             $aee['attendees']      = $this->_data->attendees;
908 908
             $aee['recipient_id']   = $att_id;
909 909
             $aee['recipient_type'] = 'Attendee';
Please login to merge, or discard this patch.
Indentation   +905 added lines, -905 removed lines patch added patch discarded remove patch
@@ -15,915 +15,915 @@
 block discarded – undo
15 15
  */
16 16
 abstract class EE_message_type extends EE_Messages_Base
17 17
 {
18
-    /**
19
-     * message type child classes will set what contexts are associated with the message type via this array.
20
-     * format:
21
-     * array(
22
-     * 'context' => array(
23
-     *        'label' => esc_html__('Context Label', 'event_espresso'),
24
-     *        'description' => esc_html__('Context description (for help popups)', 'event_espresso')
25
-     *    ));
26
-     *
27
-     * @var array
28
-     */
29
-    protected $_contexts = array();
30
-
31
-
32
-    /**
33
-     * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
34
-     * Format:
35
-     * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_context_label;
40
-
41
-
42
-    /** MESSAGE ASSEMBLING PROPERTIES **/
43
-    /**
44
-     * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
45
-     *
46
-     * @var array of message objects.
47
-     */
48
-    public $messages = array();
49
-
50
-    /**
51
-     * The following holds the templates that will be used to assemble the message object for the messenger.
52
-     *
53
-     * @var array
54
-     */
55
-    protected $_templates;
56
-
57
-
58
-    /**
59
-     * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
60
-     *
61
-     * @var int.
62
-     */
63
-    protected $_GRP_ID;
64
-
65
-
66
-    /** OTHER INFO PROPERTIES **/
67
-    /**
68
-     * This will hold the count of the message objects in the messages array. This could be used for determining if
69
-     * batching/queueing is needed.
70
-     *
71
-     * @var int
72
-     */
73
-    public $count = 0;
74
-
75
-
76
-    /**
77
-     * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
78
-     * this message type at time of sending.
79
-     *
80
-     * @var EE_messenger
81
-     */
82
-    protected $_active_messenger;
83
-
84
-
85
-    /**
86
-     * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
87
-     *
88
-     * @var object
89
-     */
90
-    protected $_shortcode_replace;
91
-
92
-
93
-    /**
94
-     * The purpose for this property is to simply allow message types to indicate if the message generated is intended
95
-     * for only single context.  Child message types should redefine this variable (if necessary) in the
96
-     * _set_data_Handler() method.
97
-     *
98
-     * @var boolean
99
-     */
100
-    protected $_single_message = false;
101
-
102
-
103
-    /**
104
-     * This will hold an array of specific reg_ids that are receiving messages.
105
-     *
106
-     * @since 4.7.x
107
-     * @var array
108
-     */
109
-    protected $_regs_for_sending = array();
110
-
111
-
112
-    /**
113
-     * This holds the data passed to this class from the controller and also the final processed data.
114
-     *
115
-     * @var object
116
-     */
117
-    protected $_data;
118
-
119
-
120
-    /**
121
-     * this is just a flag indicating whether we're in preview mode or not.
122
-     *
123
-     * @var bool
124
-     */
125
-    protected $_preview = false;
126
-
127
-
128
-    /**
129
-     * This just holds defaults for addressee data that children merge with their data array setup
130
-     *
131
-     * @var array
132
-     */
133
-    protected $_default_addressee_data;
134
-
135
-
136
-    /**
137
-     * Child classes declare through this property what handler they want to use for the incoming data and this string
138
-     * is used to instantiate the EE_Messages_incoming_data child class for that handler.
139
-     *
140
-     * @var string
141
-     */
142
-    protected $_data_handler;
143
-
144
-
145
-    /**
146
-     * This holds any specific fields for holding any settings related to a message type (if any needed)
147
-     *
148
-     * @var array
149
-     */
150
-    protected $_admin_settings_fields = array();
151
-
152
-    /**
153
-     * this property will hold any existing setting that may have been set in the admin.
154
-     *
155
-     * @var array
156
-     */
157
-    protected $_existing_admin_settings = array();
158
-
159
-
160
-    /**
161
-     * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
162
-     * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
163
-     * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
164
-     * in this format:
165
-     * {
166
-     *
167
-     * @type string $generating_messenger the name of the generating messenger.  Generating
168
-     *                                          messengers are used for generating templates,
169
-     *                                          doing validation and defining valid shortcodes.
170
-     *      {
171
-     * @type string $sending_messenger    values are the name(s) for the sending
172
-     *                                              messengers.  sending messengers are
173
-     *                                              just valid delivery vehicles that will utilize
174
-     *                                              the templates (and generated EE_message
175
-     *                                              objects from the generating messengers).
176
-     *      }
177
-     * }
178
-     * @since                             4.5.0
179
-     * @var array
180
-     */
181
-    protected $_with_messengers = array();
182
-
183
-
184
-    /**
185
-     * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
186
-     *
187
-     * @access protected
188
-     * @var array
189
-     */
190
-    protected $_addressees = array();
191
-
192
-
193
-    /**
194
-     * This allows each message type to set what alternate messenger&message type combination can be used for fallback
195
-     * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
196
-     * format:
197
-     * array(
198
-     *      'messenger' => 'message_type',
199
-     *      'another_messenger' => another_message_type
200
-     * );
201
-     * This is set in the message type constructor.
202
-     *
203
-     * @var array
204
-     */
205
-    protected $_master_templates = array();
206
-
207
-
208
-    /**
209
-     * This holds whatever the set template pack is for a message template group when generating messages.
210
-     *
211
-     * @since 4.5.0
212
-     * @var EE_Messages_Template_Pack
213
-     */
214
-    protected $_template_pack;
215
-
216
-
217
-    /**
218
-     * This holds whatever the set variation is for a message template group when generating messages.
219
-     *
220
-     * @since 4.5.0
221
-     * @var string
222
-     */
223
-    protected $_variation;
224
-
225
-
226
-    /**
227
-     * EE_message_type constructor.
228
-     */
229
-    public function __construct()
230
-    {
231
-        $this->_messages_item_type = 'message_type';
232
-        $this->_set_contexts();
233
-        $this->_set_with_messengers();
234
-        parent::__construct();
235
-    }
236
-
237
-
238
-    /**
239
-     * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
240
-     * called when messages are setup.
241
-     *
242
-     * @abstract
243
-     * @access protected
244
-     * @return void
245
-     */
246
-    abstract protected function _set_data_handler();
247
-
248
-
249
-    /**
250
-     * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
251
-     * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
252
-     * type's data handler is.
253
-     *
254
-     * @since 4.5.0
255
-     * @param string          $context      This should be a string matching a valid context for the message type.
256
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
257
-     *                                      guessing a url).
258
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
259
-     *                                      EE_Base_Class_Object
260
-     * @return mixed ( EE_Base_Class||EE_Base_Class[] )
261
-     */
262
-    abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
263
-
264
-
265
-    /**
266
-     * _set_contexts
267
-     * This sets up the contexts associated with the message_type
268
-     *
269
-     * @abstract
270
-     * @access  protected
271
-     * @return  void
272
-     */
273
-    abstract protected function _set_contexts();
274
-
275
-
276
-    /**
277
-     * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
278
-     * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
279
-     * EE_Base_Class that is required in generating a message for a message type recipient then the message
280
-     * type should override this method and use the given params to generate the correct ID.
281
-     *
282
-     * @param string          $context      The message type context.
283
-     * @param EE_Registration $registration Registration object
284
-     * @deprecated 4.9.0
285
-     * @return int
286
-     */
287
-    protected function _get_id_for_msg_url($context, EE_Registration $registration)
288
-    {
289
-        return 0;
290
-    }
291
-
292
-
293
-    /**
294
-     * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
295
-     * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
296
-     * messenger.
297
-     *
298
-     * @since 1.0.0
299
-     * @return void
300
-     */
301
-    protected function _do_messenger_hooks()
302
-    {
303
-        return;
304
-    }
305
-
306
-
307
-    /**
308
-     * This is a public wrapper for the protected _do_messenger_hooks() method.
309
-     * For backward compat reasons, this was done rather than making the protected method public.
310
-     *
311
-     * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
312
-     *                                  to know what messenger is being used to send the message at the time of
313
-     *                                  sending.
314
-     * @since 4.9.0
315
-     */
316
-    public function do_messenger_hooks($messenger = null)
317
-    {
318
-        $this->_active_messenger = $messenger;
319
-        $this->_do_messenger_hooks();
320
-    }
321
-
322
-
323
-    /**
324
-     * This method returns whether this message type should always generate a new copy
325
-     * when requested, or if links can be to the already generated copy.
326
-     * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
327
-     * Child classes should override this if different from the default of false.
328
-     *
329
-     * @return bool     false means can link to generated EE_Message.  true must regenerate.
330
-     */
331
-    public function always_generate()
332
-    {
333
-        return false;
334
-    }
335
-
336
-
337
-    /**
338
-     * Returns the priority for the message type.
339
-     * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
340
-     * - EEM_Message::priority_high
341
-     * - EEM_Message::priority_medium
342
-     * - EEM_Message::priority_low
343
-     * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
344
-     *
345
-     * @see    EEM_Message for more phpdocs on priority.
346
-     *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
347
-     *         a higher priority must override this method. Also note, messengers are able to override priorities
348
-     *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
349
-     *         which displays things in the browser.
350
-     * @since  4.9.0
351
-     * @return int
352
-     */
353
-    public function get_priority()
354
-    {
355
-        return EEM_Message::priority_low;
356
-    }
357
-
358
-
359
-    /**
360
-     * This runs the _set_data_handler() method for message types and then returns what got set.
361
-     *
362
-     * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
363
-     * @return string (the reference for the data handler) (will be an empty string if could not be determined).
364
-     */
365
-    public function get_data_handler($data)
366
-    {
367
-        $this->_data = $data;
368
-        $this->_set_data_handler();
369
-        return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
370
-    }
371
-
372
-
373
-    /**
374
-     * This is called externally to reset the value of the $_data property for the message type.
375
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
376
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
377
-     * (and for back compat reasons). This particular method is used in
378
-     * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
379
-     * cleaned before subsequent EE_Message generation in the same request.
380
-     *
381
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
382
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
383
-     *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
384
-     *            at all.
385
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
386
-     * @since     4.9
387
-     */
388
-    public function reset_data()
389
-    {
390
-        $this->_data = null;
391
-    }
392
-
393
-
394
-    /**
395
-     * This does some validation of incoming params gets the url trigger from the defined method in the specific child
396
-     * class and then filters the results.
397
-     *
398
-     * @param string          $context           The message type context
399
-     * @param string          $sending_messenger The sending messenger
400
-     * @param EE_Registration $registration      Registration object
401
-     * @throws EE_Error
402
-     * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
403
-     * @return string          generated url
404
-     */
405
-    public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
406
-    {
407
-        // validate context
408
-        // valid context?
409
-        if (! isset($this->_contexts[ $context ])) {
410
-            throw new EE_Error(
411
-                sprintf(
412
-                    esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
413
-                    $context,
414
-                    get_class($this)
415
-                )
416
-            );
417
-        }
418
-        // valid sending_messenger?
419
-        $not_valid_msgr = false;
420
-        foreach ($this->_with_messengers as $generating => $sendings) {
421
-            if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
422
-                $not_valid_msgr = true;
423
-            }
424
-        }
425
-        if ($not_valid_msgr) {
426
-            throw new EE_Error(
427
-                sprintf(
428
-                    esc_html__(
429
-                        'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
430
-                        'event_espresso'
431
-                    ),
432
-                    $sending_messenger,
433
-                    get_class($this)
434
-                )
435
-            );
436
-        }
437
-        return EEH_MSG_Template::generate_url_trigger(
438
-            $sending_messenger,
439
-            $this->_active_messenger->name,
440
-            $context,
441
-            $this->name,
442
-            $registration,
443
-            $this->_GRP_ID,
444
-            $this->_get_id_for_msg_url($context, $registration)
445
-        );
446
-    }
447
-
448
-
449
-    /**
450
-     * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
451
-     * for filtering. This is (currently) called by the EED_Messages module.
452
-     *
453
-     * @since 4.5.0
454
-     * @throws EE_Error
455
-     * @param string          $context      This should be a string matching a valid context for the message type.
456
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
457
-     *                                      guessing a url).
458
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
459
-     *                                      EE_Base_Class_Object
460
-     * @return mixed (EE_Base_Class||EE_Base_Class[])
461
-     */
462
-    public function get_data_for_context($context, EE_Registration $registration, $id = 0)
463
-    {
464
-        // valid context?
465
-        if (! isset($this->_contexts[ $context ])) {
466
-            throw new EE_Error(
467
-                sprintf(
468
-                    esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
469
-                    $context,
470
-                    get_class($this)
471
-                )
472
-            );
473
-        }
474
-        // get data and apply global and class specific filters on it.
475
-        $data = apply_filters(
476
-            'FHEE__EE_message_type__get_data_for_context__data',
477
-            $this->_get_data_for_context($context, $registration, $id),
478
-            $this
479
-        );
480
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
481
-        // if empty then something went wrong!
482
-        if (empty($data)) {
483
-            throw new EE_Error(
484
-                sprintf(
485
-                    esc_html__(
486
-                        'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
487
-                        'event_espresso'
488
-                    ),
489
-                    $id,
490
-                    $this->name
491
-                )
492
-            );
493
-        }
494
-        return $data;
495
-    }
496
-
497
-
498
-    /**
499
-     * This returns the contents of the _data property.
500
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
501
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
502
-     *
503
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
504
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
505
-     *            expectation of what it is.
506
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
507
-     * @return mixed
508
-     */
509
-    public function get_data()
510
-    {
511
-        return $this->_data;
512
-    }
513
-
514
-
515
-    /**
516
-     * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
517
-     *
518
-     * @see   property definition for description of setup.
519
-     * @since 4.5.0
520
-     * @abstract
521
-     * @return void
522
-     */
523
-    protected function _set_with_messengers()
524
-    {
525
-        $this->_with_messengers = array(
526
-            'email' => array('html'),
527
-        );
528
-    }
529
-
530
-
531
-    /**
532
-     * Return the value of the _with_messengers property
533
-     *
534
-     * @since 4.5.0
535
-     * @return array
536
-     */
537
-    public function with_messengers()
538
-    {
539
-        return apply_filters(
540
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
541
-            $this->_with_messengers
542
-        );
543
-    }
544
-
545
-
546
-    /**
547
-     * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
548
-     * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
549
-     * *
550
-     *
551
-     * @param string $page       the slug of the EE admin page
552
-     * @param array  $messengers an array of active messenger objects
553
-     * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
554
-     * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
555
-     *                           page content.
556
-     * @access public
557
-     * @return string
558
-     */
559
-    public function get_message_type_admin_page_content(
560
-        $page,
561
-        $action = null,
562
-        $extra = array(),
563
-        $messengers = array()
564
-    ) {
565
-        // we can also further refine the context by action (if present).
566
-        return $this->_get_admin_page_content($page, $action, $extra, $messengers);
567
-    }
568
-
569
-
570
-    /**
571
-     * @return array
572
-     */
573
-    public function get_contexts()
574
-    {
575
-        return $this->_contexts;
576
-    }
577
-
578
-
579
-    /**
580
-     * This just returns the context label for a given context (as set in $_context_label property)
581
-     *
582
-     * @access public
583
-     * @return array
584
-     */
585
-    public function get_context_label()
586
-    {
587
-        return $this->_context_label;
588
-    }
589
-
590
-
591
-    /**
592
-     * This just returns the (filtered) _master_templates property.
593
-     *
594
-     * @see property definition for documentation.
595
-     * @return array
596
-     */
597
-    public function get_master_templates()
598
-    {
599
-        // first class specific filter then filter that by the global filter.
600
-        $master_templates = apply_filters(
601
-            'FHEE__' . get_class($this) . '__get_master_templates',
602
-            $this->_master_templates
603
-        );
604
-        return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
605
-    }
606
-
607
-
608
-    /**
609
-     * Accepts an incoming data handler which contains data for processing, and returns an array of
610
-     * EE_Messages_Addressee objects.
611
-     *
612
-     * @param EE_Messages_incoming_data $data
613
-     * @param string                    $context Limit addressees to specific context.
614
-     * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for
615
-     *                                           that context
616
-     * @throws EE_Error
617
-     */
618
-    public function get_addressees(EE_Messages_incoming_data $data, $context = '')
619
-    {
620
-        // override _data
621
-        $this->_data       = $data;
622
-        $addressees        = array();
623
-        $original_contexts = $this->_contexts;
624
-        // if incoming context then limit to that context
625
-        if (! empty($context)) {
626
-            $cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : '';
627
-            if (! empty($cntxt)) {
628
-                $this->_contexts           = array();
629
-                $this->_contexts[ $context ] = $cntxt;
630
-            }
631
-        }
632
-        $this->_set_default_addressee_data();
633
-        if ($this->_process_data()) {
634
-            $addressees = $this->_addressees;
635
-        }
636
-
637
-        // reset contexts and addressees
638
-        $this->_contexts   = $original_contexts;
639
-        $this->_addressees = array();
640
-        return $addressees;
641
-    }
642
-
643
-
644
-    /**
645
-     * processes the data object so we get
646
-     *
647
-     * @throws EE_Error
648
-     * @return bool  true means data was processed successfully, false means not.
649
-     */
650
-    protected function _process_data()
651
-    {
652
-        // at a minimum, we NEED EE_Attendee objects.
653
-        if (empty($this->_data->attendees)) {
654
-            return false;  // there's no data to process!
655
-        }
656
-        // process addressees for each context.  Child classes will have to have methods for
657
-        // each context defined to handle the processing of the data object within them
658
-        foreach ($this->_contexts as $context => $details) {
659
-            $xpctd_method = '_' . $context . '_addressees';
660
-            if (! method_exists($this, $xpctd_method)) {
661
-                throw new EE_Error(
662
-                    sprintf(
663
-                        esc_html__(
664
-                            'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
665
-                            'event_espresso'
666
-                        ),
667
-                        $this->label['singular'],
668
-                        $xpctd_method
669
-                    )
670
-                );
671
-            }
672
-            $this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method));
673
-        }
674
-        return true; // data was processed successfully.
675
-    }
676
-
677
-
678
-    /**
679
-     * sets the default_addressee_data property,
680
-     *
681
-     * @access private
682
-     * @return void
683
-     */
684
-    private function _set_default_addressee_data()
685
-    {
686
-        $this->_default_addressee_data = array(
687
-            'billing'                  => $this->_data->billing,
688
-            'taxes'                    => $this->_data->taxes,
689
-            'tax_line_items'           => $this->_data->tax_line_items,
690
-            'additional_line_items'    => $this->_data->additional_line_items,
691
-            'grand_total_line_item'    => $this->_data->grand_total_line_item,
692
-            'txn'                      => $this->_data->txn,
693
-            'payments'                 => $this->_data->payments,
694
-            'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
695
-                ? $this->_data->payment
696
-                : null,
697
-            'reg_objs'                 => $this->_data->reg_objs,
698
-            'registrations'            => $this->_data->registrations,
699
-            'datetimes'                => $this->_data->datetimes,
700
-            'tickets'                  => $this->_data->tickets,
701
-            'line_items_with_children' => $this->_data->line_items_with_children,
702
-            'questions'                => $this->_data->questions,
703
-            'answers'                  => $this->_data->answers,
704
-            'txn_status'               => $this->_data->txn_status,
705
-            'total_ticket_count'       => $this->_data->total_ticket_count,
706
-        );
707
-        if (is_array($this->_data->primary_attendee_data)) {
708
-            $this->_default_addressee_data                    = array_merge(
709
-                $this->_default_addressee_data,
710
-                $this->_data->primary_attendee_data
711
-            );
712
-            $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
713
-            $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
714
-        }
715
-    }
716
-
717
-
718
-
719
-    /********************
18
+	/**
19
+	 * message type child classes will set what contexts are associated with the message type via this array.
20
+	 * format:
21
+	 * array(
22
+	 * 'context' => array(
23
+	 *        'label' => esc_html__('Context Label', 'event_espresso'),
24
+	 *        'description' => esc_html__('Context description (for help popups)', 'event_espresso')
25
+	 *    ));
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $_contexts = array();
30
+
31
+
32
+	/**
33
+	 * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
34
+	 * Format:
35
+	 * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_context_label;
40
+
41
+
42
+	/** MESSAGE ASSEMBLING PROPERTIES **/
43
+	/**
44
+	 * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
45
+	 *
46
+	 * @var array of message objects.
47
+	 */
48
+	public $messages = array();
49
+
50
+	/**
51
+	 * The following holds the templates that will be used to assemble the message object for the messenger.
52
+	 *
53
+	 * @var array
54
+	 */
55
+	protected $_templates;
56
+
57
+
58
+	/**
59
+	 * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
60
+	 *
61
+	 * @var int.
62
+	 */
63
+	protected $_GRP_ID;
64
+
65
+
66
+	/** OTHER INFO PROPERTIES **/
67
+	/**
68
+	 * This will hold the count of the message objects in the messages array. This could be used for determining if
69
+	 * batching/queueing is needed.
70
+	 *
71
+	 * @var int
72
+	 */
73
+	public $count = 0;
74
+
75
+
76
+	/**
77
+	 * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
78
+	 * this message type at time of sending.
79
+	 *
80
+	 * @var EE_messenger
81
+	 */
82
+	protected $_active_messenger;
83
+
84
+
85
+	/**
86
+	 * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
87
+	 *
88
+	 * @var object
89
+	 */
90
+	protected $_shortcode_replace;
91
+
92
+
93
+	/**
94
+	 * The purpose for this property is to simply allow message types to indicate if the message generated is intended
95
+	 * for only single context.  Child message types should redefine this variable (if necessary) in the
96
+	 * _set_data_Handler() method.
97
+	 *
98
+	 * @var boolean
99
+	 */
100
+	protected $_single_message = false;
101
+
102
+
103
+	/**
104
+	 * This will hold an array of specific reg_ids that are receiving messages.
105
+	 *
106
+	 * @since 4.7.x
107
+	 * @var array
108
+	 */
109
+	protected $_regs_for_sending = array();
110
+
111
+
112
+	/**
113
+	 * This holds the data passed to this class from the controller and also the final processed data.
114
+	 *
115
+	 * @var object
116
+	 */
117
+	protected $_data;
118
+
119
+
120
+	/**
121
+	 * this is just a flag indicating whether we're in preview mode or not.
122
+	 *
123
+	 * @var bool
124
+	 */
125
+	protected $_preview = false;
126
+
127
+
128
+	/**
129
+	 * This just holds defaults for addressee data that children merge with their data array setup
130
+	 *
131
+	 * @var array
132
+	 */
133
+	protected $_default_addressee_data;
134
+
135
+
136
+	/**
137
+	 * Child classes declare through this property what handler they want to use for the incoming data and this string
138
+	 * is used to instantiate the EE_Messages_incoming_data child class for that handler.
139
+	 *
140
+	 * @var string
141
+	 */
142
+	protected $_data_handler;
143
+
144
+
145
+	/**
146
+	 * This holds any specific fields for holding any settings related to a message type (if any needed)
147
+	 *
148
+	 * @var array
149
+	 */
150
+	protected $_admin_settings_fields = array();
151
+
152
+	/**
153
+	 * this property will hold any existing setting that may have been set in the admin.
154
+	 *
155
+	 * @var array
156
+	 */
157
+	protected $_existing_admin_settings = array();
158
+
159
+
160
+	/**
161
+	 * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
162
+	 * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
163
+	 * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
164
+	 * in this format:
165
+	 * {
166
+	 *
167
+	 * @type string $generating_messenger the name of the generating messenger.  Generating
168
+	 *                                          messengers are used for generating templates,
169
+	 *                                          doing validation and defining valid shortcodes.
170
+	 *      {
171
+	 * @type string $sending_messenger    values are the name(s) for the sending
172
+	 *                                              messengers.  sending messengers are
173
+	 *                                              just valid delivery vehicles that will utilize
174
+	 *                                              the templates (and generated EE_message
175
+	 *                                              objects from the generating messengers).
176
+	 *      }
177
+	 * }
178
+	 * @since                             4.5.0
179
+	 * @var array
180
+	 */
181
+	protected $_with_messengers = array();
182
+
183
+
184
+	/**
185
+	 * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
186
+	 *
187
+	 * @access protected
188
+	 * @var array
189
+	 */
190
+	protected $_addressees = array();
191
+
192
+
193
+	/**
194
+	 * This allows each message type to set what alternate messenger&message type combination can be used for fallback
195
+	 * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
196
+	 * format:
197
+	 * array(
198
+	 *      'messenger' => 'message_type',
199
+	 *      'another_messenger' => another_message_type
200
+	 * );
201
+	 * This is set in the message type constructor.
202
+	 *
203
+	 * @var array
204
+	 */
205
+	protected $_master_templates = array();
206
+
207
+
208
+	/**
209
+	 * This holds whatever the set template pack is for a message template group when generating messages.
210
+	 *
211
+	 * @since 4.5.0
212
+	 * @var EE_Messages_Template_Pack
213
+	 */
214
+	protected $_template_pack;
215
+
216
+
217
+	/**
218
+	 * This holds whatever the set variation is for a message template group when generating messages.
219
+	 *
220
+	 * @since 4.5.0
221
+	 * @var string
222
+	 */
223
+	protected $_variation;
224
+
225
+
226
+	/**
227
+	 * EE_message_type constructor.
228
+	 */
229
+	public function __construct()
230
+	{
231
+		$this->_messages_item_type = 'message_type';
232
+		$this->_set_contexts();
233
+		$this->_set_with_messengers();
234
+		parent::__construct();
235
+	}
236
+
237
+
238
+	/**
239
+	 * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
240
+	 * called when messages are setup.
241
+	 *
242
+	 * @abstract
243
+	 * @access protected
244
+	 * @return void
245
+	 */
246
+	abstract protected function _set_data_handler();
247
+
248
+
249
+	/**
250
+	 * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
251
+	 * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
252
+	 * type's data handler is.
253
+	 *
254
+	 * @since 4.5.0
255
+	 * @param string          $context      This should be a string matching a valid context for the message type.
256
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
257
+	 *                                      guessing a url).
258
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
259
+	 *                                      EE_Base_Class_Object
260
+	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
261
+	 */
262
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
263
+
264
+
265
+	/**
266
+	 * _set_contexts
267
+	 * This sets up the contexts associated with the message_type
268
+	 *
269
+	 * @abstract
270
+	 * @access  protected
271
+	 * @return  void
272
+	 */
273
+	abstract protected function _set_contexts();
274
+
275
+
276
+	/**
277
+	 * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
278
+	 * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
279
+	 * EE_Base_Class that is required in generating a message for a message type recipient then the message
280
+	 * type should override this method and use the given params to generate the correct ID.
281
+	 *
282
+	 * @param string          $context      The message type context.
283
+	 * @param EE_Registration $registration Registration object
284
+	 * @deprecated 4.9.0
285
+	 * @return int
286
+	 */
287
+	protected function _get_id_for_msg_url($context, EE_Registration $registration)
288
+	{
289
+		return 0;
290
+	}
291
+
292
+
293
+	/**
294
+	 * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
295
+	 * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
296
+	 * messenger.
297
+	 *
298
+	 * @since 1.0.0
299
+	 * @return void
300
+	 */
301
+	protected function _do_messenger_hooks()
302
+	{
303
+		return;
304
+	}
305
+
306
+
307
+	/**
308
+	 * This is a public wrapper for the protected _do_messenger_hooks() method.
309
+	 * For backward compat reasons, this was done rather than making the protected method public.
310
+	 *
311
+	 * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
312
+	 *                                  to know what messenger is being used to send the message at the time of
313
+	 *                                  sending.
314
+	 * @since 4.9.0
315
+	 */
316
+	public function do_messenger_hooks($messenger = null)
317
+	{
318
+		$this->_active_messenger = $messenger;
319
+		$this->_do_messenger_hooks();
320
+	}
321
+
322
+
323
+	/**
324
+	 * This method returns whether this message type should always generate a new copy
325
+	 * when requested, or if links can be to the already generated copy.
326
+	 * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
327
+	 * Child classes should override this if different from the default of false.
328
+	 *
329
+	 * @return bool     false means can link to generated EE_Message.  true must regenerate.
330
+	 */
331
+	public function always_generate()
332
+	{
333
+		return false;
334
+	}
335
+
336
+
337
+	/**
338
+	 * Returns the priority for the message type.
339
+	 * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
340
+	 * - EEM_Message::priority_high
341
+	 * - EEM_Message::priority_medium
342
+	 * - EEM_Message::priority_low
343
+	 * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
344
+	 *
345
+	 * @see    EEM_Message for more phpdocs on priority.
346
+	 *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
347
+	 *         a higher priority must override this method. Also note, messengers are able to override priorities
348
+	 *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
349
+	 *         which displays things in the browser.
350
+	 * @since  4.9.0
351
+	 * @return int
352
+	 */
353
+	public function get_priority()
354
+	{
355
+		return EEM_Message::priority_low;
356
+	}
357
+
358
+
359
+	/**
360
+	 * This runs the _set_data_handler() method for message types and then returns what got set.
361
+	 *
362
+	 * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
363
+	 * @return string (the reference for the data handler) (will be an empty string if could not be determined).
364
+	 */
365
+	public function get_data_handler($data)
366
+	{
367
+		$this->_data = $data;
368
+		$this->_set_data_handler();
369
+		return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
370
+	}
371
+
372
+
373
+	/**
374
+	 * This is called externally to reset the value of the $_data property for the message type.
375
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
376
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
377
+	 * (and for back compat reasons). This particular method is used in
378
+	 * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
379
+	 * cleaned before subsequent EE_Message generation in the same request.
380
+	 *
381
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
382
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
383
+	 *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
384
+	 *            at all.
385
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
386
+	 * @since     4.9
387
+	 */
388
+	public function reset_data()
389
+	{
390
+		$this->_data = null;
391
+	}
392
+
393
+
394
+	/**
395
+	 * This does some validation of incoming params gets the url trigger from the defined method in the specific child
396
+	 * class and then filters the results.
397
+	 *
398
+	 * @param string          $context           The message type context
399
+	 * @param string          $sending_messenger The sending messenger
400
+	 * @param EE_Registration $registration      Registration object
401
+	 * @throws EE_Error
402
+	 * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
403
+	 * @return string          generated url
404
+	 */
405
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
406
+	{
407
+		// validate context
408
+		// valid context?
409
+		if (! isset($this->_contexts[ $context ])) {
410
+			throw new EE_Error(
411
+				sprintf(
412
+					esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
413
+					$context,
414
+					get_class($this)
415
+				)
416
+			);
417
+		}
418
+		// valid sending_messenger?
419
+		$not_valid_msgr = false;
420
+		foreach ($this->_with_messengers as $generating => $sendings) {
421
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
422
+				$not_valid_msgr = true;
423
+			}
424
+		}
425
+		if ($not_valid_msgr) {
426
+			throw new EE_Error(
427
+				sprintf(
428
+					esc_html__(
429
+						'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
430
+						'event_espresso'
431
+					),
432
+					$sending_messenger,
433
+					get_class($this)
434
+				)
435
+			);
436
+		}
437
+		return EEH_MSG_Template::generate_url_trigger(
438
+			$sending_messenger,
439
+			$this->_active_messenger->name,
440
+			$context,
441
+			$this->name,
442
+			$registration,
443
+			$this->_GRP_ID,
444
+			$this->_get_id_for_msg_url($context, $registration)
445
+		);
446
+	}
447
+
448
+
449
+	/**
450
+	 * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
451
+	 * for filtering. This is (currently) called by the EED_Messages module.
452
+	 *
453
+	 * @since 4.5.0
454
+	 * @throws EE_Error
455
+	 * @param string          $context      This should be a string matching a valid context for the message type.
456
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
457
+	 *                                      guessing a url).
458
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
459
+	 *                                      EE_Base_Class_Object
460
+	 * @return mixed (EE_Base_Class||EE_Base_Class[])
461
+	 */
462
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0)
463
+	{
464
+		// valid context?
465
+		if (! isset($this->_contexts[ $context ])) {
466
+			throw new EE_Error(
467
+				sprintf(
468
+					esc_html__('The context %s is not a valid context for %s.', 'event_espresso'),
469
+					$context,
470
+					get_class($this)
471
+				)
472
+			);
473
+		}
474
+		// get data and apply global and class specific filters on it.
475
+		$data = apply_filters(
476
+			'FHEE__EE_message_type__get_data_for_context__data',
477
+			$this->_get_data_for_context($context, $registration, $id),
478
+			$this
479
+		);
480
+		$data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
481
+		// if empty then something went wrong!
482
+		if (empty($data)) {
483
+			throw new EE_Error(
484
+				sprintf(
485
+					esc_html__(
486
+						'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
487
+						'event_espresso'
488
+					),
489
+					$id,
490
+					$this->name
491
+				)
492
+			);
493
+		}
494
+		return $data;
495
+	}
496
+
497
+
498
+	/**
499
+	 * This returns the contents of the _data property.
500
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
501
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
502
+	 *
503
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
504
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
505
+	 *            expectation of what it is.
506
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
507
+	 * @return mixed
508
+	 */
509
+	public function get_data()
510
+	{
511
+		return $this->_data;
512
+	}
513
+
514
+
515
+	/**
516
+	 * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
517
+	 *
518
+	 * @see   property definition for description of setup.
519
+	 * @since 4.5.0
520
+	 * @abstract
521
+	 * @return void
522
+	 */
523
+	protected function _set_with_messengers()
524
+	{
525
+		$this->_with_messengers = array(
526
+			'email' => array('html'),
527
+		);
528
+	}
529
+
530
+
531
+	/**
532
+	 * Return the value of the _with_messengers property
533
+	 *
534
+	 * @since 4.5.0
535
+	 * @return array
536
+	 */
537
+	public function with_messengers()
538
+	{
539
+		return apply_filters(
540
+			'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
541
+			$this->_with_messengers
542
+		);
543
+	}
544
+
545
+
546
+	/**
547
+	 * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
548
+	 * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
549
+	 * *
550
+	 *
551
+	 * @param string $page       the slug of the EE admin page
552
+	 * @param array  $messengers an array of active messenger objects
553
+	 * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
554
+	 * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
555
+	 *                           page content.
556
+	 * @access public
557
+	 * @return string
558
+	 */
559
+	public function get_message_type_admin_page_content(
560
+		$page,
561
+		$action = null,
562
+		$extra = array(),
563
+		$messengers = array()
564
+	) {
565
+		// we can also further refine the context by action (if present).
566
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
567
+	}
568
+
569
+
570
+	/**
571
+	 * @return array
572
+	 */
573
+	public function get_contexts()
574
+	{
575
+		return $this->_contexts;
576
+	}
577
+
578
+
579
+	/**
580
+	 * This just returns the context label for a given context (as set in $_context_label property)
581
+	 *
582
+	 * @access public
583
+	 * @return array
584
+	 */
585
+	public function get_context_label()
586
+	{
587
+		return $this->_context_label;
588
+	}
589
+
590
+
591
+	/**
592
+	 * This just returns the (filtered) _master_templates property.
593
+	 *
594
+	 * @see property definition for documentation.
595
+	 * @return array
596
+	 */
597
+	public function get_master_templates()
598
+	{
599
+		// first class specific filter then filter that by the global filter.
600
+		$master_templates = apply_filters(
601
+			'FHEE__' . get_class($this) . '__get_master_templates',
602
+			$this->_master_templates
603
+		);
604
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
605
+	}
606
+
607
+
608
+	/**
609
+	 * Accepts an incoming data handler which contains data for processing, and returns an array of
610
+	 * EE_Messages_Addressee objects.
611
+	 *
612
+	 * @param EE_Messages_incoming_data $data
613
+	 * @param string                    $context Limit addressees to specific context.
614
+	 * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for
615
+	 *                                           that context
616
+	 * @throws EE_Error
617
+	 */
618
+	public function get_addressees(EE_Messages_incoming_data $data, $context = '')
619
+	{
620
+		// override _data
621
+		$this->_data       = $data;
622
+		$addressees        = array();
623
+		$original_contexts = $this->_contexts;
624
+		// if incoming context then limit to that context
625
+		if (! empty($context)) {
626
+			$cntxt = ! empty($this->_contexts[ $context ]) ? $this->_contexts[ $context ] : '';
627
+			if (! empty($cntxt)) {
628
+				$this->_contexts           = array();
629
+				$this->_contexts[ $context ] = $cntxt;
630
+			}
631
+		}
632
+		$this->_set_default_addressee_data();
633
+		if ($this->_process_data()) {
634
+			$addressees = $this->_addressees;
635
+		}
636
+
637
+		// reset contexts and addressees
638
+		$this->_contexts   = $original_contexts;
639
+		$this->_addressees = array();
640
+		return $addressees;
641
+	}
642
+
643
+
644
+	/**
645
+	 * processes the data object so we get
646
+	 *
647
+	 * @throws EE_Error
648
+	 * @return bool  true means data was processed successfully, false means not.
649
+	 */
650
+	protected function _process_data()
651
+	{
652
+		// at a minimum, we NEED EE_Attendee objects.
653
+		if (empty($this->_data->attendees)) {
654
+			return false;  // there's no data to process!
655
+		}
656
+		// process addressees for each context.  Child classes will have to have methods for
657
+		// each context defined to handle the processing of the data object within them
658
+		foreach ($this->_contexts as $context => $details) {
659
+			$xpctd_method = '_' . $context . '_addressees';
660
+			if (! method_exists($this, $xpctd_method)) {
661
+				throw new EE_Error(
662
+					sprintf(
663
+						esc_html__(
664
+							'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
665
+							'event_espresso'
666
+						),
667
+						$this->label['singular'],
668
+						$xpctd_method
669
+					)
670
+				);
671
+			}
672
+			$this->_addressees[ $context ] = call_user_func(array($this, $xpctd_method));
673
+		}
674
+		return true; // data was processed successfully.
675
+	}
676
+
677
+
678
+	/**
679
+	 * sets the default_addressee_data property,
680
+	 *
681
+	 * @access private
682
+	 * @return void
683
+	 */
684
+	private function _set_default_addressee_data()
685
+	{
686
+		$this->_default_addressee_data = array(
687
+			'billing'                  => $this->_data->billing,
688
+			'taxes'                    => $this->_data->taxes,
689
+			'tax_line_items'           => $this->_data->tax_line_items,
690
+			'additional_line_items'    => $this->_data->additional_line_items,
691
+			'grand_total_line_item'    => $this->_data->grand_total_line_item,
692
+			'txn'                      => $this->_data->txn,
693
+			'payments'                 => $this->_data->payments,
694
+			'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
695
+				? $this->_data->payment
696
+				: null,
697
+			'reg_objs'                 => $this->_data->reg_objs,
698
+			'registrations'            => $this->_data->registrations,
699
+			'datetimes'                => $this->_data->datetimes,
700
+			'tickets'                  => $this->_data->tickets,
701
+			'line_items_with_children' => $this->_data->line_items_with_children,
702
+			'questions'                => $this->_data->questions,
703
+			'answers'                  => $this->_data->answers,
704
+			'txn_status'               => $this->_data->txn_status,
705
+			'total_ticket_count'       => $this->_data->total_ticket_count,
706
+		);
707
+		if (is_array($this->_data->primary_attendee_data)) {
708
+			$this->_default_addressee_data                    = array_merge(
709
+				$this->_default_addressee_data,
710
+				$this->_data->primary_attendee_data
711
+			);
712
+			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
713
+			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
714
+		}
715
+	}
716
+
717
+
718
+
719
+	/********************
720 720
      * setup default shared addressee object/contexts
721 721
      * These can be utilized simply by defining the context in the child message type.
722 722
      * They can also be overridden if a specific message type needs to do something different for that context.
723 723
      ****************/
724
-    /**
725
-     * see abstract declaration in parent class for details, children message types can
726
-     * override these valid shortcodes if desired (we include all for all contexts by default).
727
-     */
728
-    protected function _set_valid_shortcodes()
729
-    {
730
-        $all_shortcodes = array(
731
-            'attendee_list',
732
-            'attendee',
733
-            'datetime_list',
734
-            'datetime',
735
-            'event_list',
736
-            'event_meta',
737
-            'event',
738
-            'organization',
739
-            'recipient_details',
740
-            'recipient_list',
741
-            'ticket_list',
742
-            'ticket',
743
-            'transaction',
744
-            'venue',
745
-            'primary_registration_details',
746
-            'primary_registration_list',
747
-            'event_author',
748
-            'email',
749
-            'messenger',
750
-        );
751
-        $contexts       = $this->get_contexts();
752
-        foreach ($contexts as $context => $details) {
753
-            $this->_valid_shortcodes[ $context ] = $all_shortcodes;
754
-            // make sure non admin context does not include the event_author shortcodes
755
-            if ($context != 'admin') {
756
-                if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) {
757
-                    unset($this->_valid_shortcodes[ $context ][ $key ]);
758
-                }
759
-            }
760
-        }
761
-        // make sure admin context does not include the recipient_details shortcodes
762
-        // IF we have admin context hooked in message types might not have that context.
763
-        if (! empty($this->_valid_shortcodes['admin'])) {
764
-            if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
765
-                unset($this->_valid_shortcodes['admin'][ $key ]);
766
-            }
767
-            // make sure admin context does not include the recipient_details shortcodes
768
-            if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
769
-                unset($this->_valid_shortcodes['admin'][ $key ]);
770
-            }
771
-        }
772
-    }
773
-
774
-
775
-    /**
776
-     * Used by Validators to modify the valid shortcodes.
777
-     *
778
-     * @param  array $new_config array of valid shortcodes (by context)
779
-     * @return void               sets valid_shortcodes property
780
-     */
781
-    public function reset_valid_shortcodes_config($new_config)
782
-    {
783
-        foreach ($new_config as $context => $shortcodes) {
784
-            $this->_valid_shortcodes[ $context ] = $shortcodes;
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     * returns an array of addressee objects for event_admins
791
-     *
792
-     * @access protected
793
-     * @return array array of EE_Messages_Addressee objects
794
-     * @throws EE_Error
795
-     * @throws InvalidArgumentException
796
-     * @throws InvalidDataTypeException
797
-     * @throws InvalidInterfaceException
798
-     */
799
-    protected function _admin_addressees()
800
-    {
801
-        $admin_events = array();
802
-        $addressees   = array();
803
-        // first we need to get the event admin user id for all the events
804
-        // and setup an addressee object for each unique admin user.
805
-        foreach ($this->_data->events as $line_ref => $event) {
806
-            $admin_id = $this->_get_event_admin_id($event['ID']);
807
-            // make sure we are just including the events that belong to this admin!
808
-            $admin_events[ $admin_id ][ $line_ref ] = $event;
809
-        }
810
-        // k now we can loop through the event_admins and setup the addressee data.
811
-        foreach ($admin_events as $admin_id => $event_details) {
812
-            $aee          = array(
813
-                'user_id'        => $admin_id,
814
-                'events'         => $event_details,
815
-                'attendees'      => $this->_data->attendees,
816
-                'recipient_id'   => $admin_id,
817
-                'recipient_type' => 'WP_User',
818
-            );
819
-            $aee          = array_merge($this->_default_addressee_data, $aee);
820
-            $addressees[] = new EE_Messages_Addressee($aee);
821
-        }
822
-        return $addressees;
823
-    }
824
-
825
-
826
-    /**
827
-     * Takes care of setting up the addressee object(s) for the primary attendee.
828
-     *
829
-     * @access protected
830
-     * @return array of EE_Addressee objects
831
-     * @throws EE_Error
832
-     */
833
-    protected function _primary_attendee_addressees()
834
-    {
835
-        $aee                   = $this->_default_addressee_data;
836
-        $aee['events']         = $this->_data->events;
837
-        $aee['attendees']      = $this->_data->attendees;
838
-        $aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
839
-        $aee['recipient_type'] = 'Attendee';
840
-        // great now we can instantiate the $addressee object and return (as an array);
841
-        $add[] = new EE_Messages_Addressee($aee);
842
-        return $add;
843
-    }
844
-
845
-
846
-    /**
847
-     * Takes care of setting up the addressee object(s) for the registered attendees
848
-     *
849
-     * @access protected
850
-     * @return array of EE_Addressee objects
851
-     */
852
-    protected function _attendee_addressees()
853
-    {
854
-        $add = array();
855
-        // we just have to loop through the attendees.  We'll also set the attached events for each attendee.
856
-        // use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
857
-        $already_processed = array();
858
-        foreach ($this->_data->attendees as $att_id => $details) {
859
-            // set the attendee array to blank on each loop;
860
-            $aee = array();
861
-            if (
862
-                isset($this->_data->reg_obj)
863
-                && ($this->_data->reg_obj->attendee_ID() != $att_id)
864
-                && $this->_single_message
865
-            ) {
866
-                continue;
867
-            }
868
-            // is $this->_regs_for_sending present?
869
-            // If so, let's make sure we ONLY generate addressee for registrations in that array.
870
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
871
-                $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
872
-                if (empty($regs_allowed)) {
873
-                    continue;
874
-                }
875
-            }
876
-            if (
877
-                apply_filters(
878
-                    'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
879
-                    true,
880
-                    $this->_data,
881
-                    $this
882
-                )
883
-                && in_array($att_id, $already_processed, true)
884
-            ) {
885
-                continue;
886
-            }
887
-            $already_processed[] = $att_id;
888
-            foreach ($details as $item => $value) {
889
-                $aee[ $item ] = $value;
890
-                if ($item === 'line_ref') {
891
-                    foreach ($value as $event_id) {
892
-                        $aee['events'][ $event_id ] = $this->_data->events[ $event_id ];
893
-                    }
894
-                }
895
-                if ($item === 'attendee_email') {
896
-                    $aee['attendee_email'] = $value;
897
-                }
898
-                /*if ( $item == 'registration_id' ) {
724
+	/**
725
+	 * see abstract declaration in parent class for details, children message types can
726
+	 * override these valid shortcodes if desired (we include all for all contexts by default).
727
+	 */
728
+	protected function _set_valid_shortcodes()
729
+	{
730
+		$all_shortcodes = array(
731
+			'attendee_list',
732
+			'attendee',
733
+			'datetime_list',
734
+			'datetime',
735
+			'event_list',
736
+			'event_meta',
737
+			'event',
738
+			'organization',
739
+			'recipient_details',
740
+			'recipient_list',
741
+			'ticket_list',
742
+			'ticket',
743
+			'transaction',
744
+			'venue',
745
+			'primary_registration_details',
746
+			'primary_registration_list',
747
+			'event_author',
748
+			'email',
749
+			'messenger',
750
+		);
751
+		$contexts       = $this->get_contexts();
752
+		foreach ($contexts as $context => $details) {
753
+			$this->_valid_shortcodes[ $context ] = $all_shortcodes;
754
+			// make sure non admin context does not include the event_author shortcodes
755
+			if ($context != 'admin') {
756
+				if (($key = array_search('event_author', $this->_valid_shortcodes[ $context ])) !== false) {
757
+					unset($this->_valid_shortcodes[ $context ][ $key ]);
758
+				}
759
+			}
760
+		}
761
+		// make sure admin context does not include the recipient_details shortcodes
762
+		// IF we have admin context hooked in message types might not have that context.
763
+		if (! empty($this->_valid_shortcodes['admin'])) {
764
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
765
+				unset($this->_valid_shortcodes['admin'][ $key ]);
766
+			}
767
+			// make sure admin context does not include the recipient_details shortcodes
768
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
769
+				unset($this->_valid_shortcodes['admin'][ $key ]);
770
+			}
771
+		}
772
+	}
773
+
774
+
775
+	/**
776
+	 * Used by Validators to modify the valid shortcodes.
777
+	 *
778
+	 * @param  array $new_config array of valid shortcodes (by context)
779
+	 * @return void               sets valid_shortcodes property
780
+	 */
781
+	public function reset_valid_shortcodes_config($new_config)
782
+	{
783
+		foreach ($new_config as $context => $shortcodes) {
784
+			$this->_valid_shortcodes[ $context ] = $shortcodes;
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 * returns an array of addressee objects for event_admins
791
+	 *
792
+	 * @access protected
793
+	 * @return array array of EE_Messages_Addressee objects
794
+	 * @throws EE_Error
795
+	 * @throws InvalidArgumentException
796
+	 * @throws InvalidDataTypeException
797
+	 * @throws InvalidInterfaceException
798
+	 */
799
+	protected function _admin_addressees()
800
+	{
801
+		$admin_events = array();
802
+		$addressees   = array();
803
+		// first we need to get the event admin user id for all the events
804
+		// and setup an addressee object for each unique admin user.
805
+		foreach ($this->_data->events as $line_ref => $event) {
806
+			$admin_id = $this->_get_event_admin_id($event['ID']);
807
+			// make sure we are just including the events that belong to this admin!
808
+			$admin_events[ $admin_id ][ $line_ref ] = $event;
809
+		}
810
+		// k now we can loop through the event_admins and setup the addressee data.
811
+		foreach ($admin_events as $admin_id => $event_details) {
812
+			$aee          = array(
813
+				'user_id'        => $admin_id,
814
+				'events'         => $event_details,
815
+				'attendees'      => $this->_data->attendees,
816
+				'recipient_id'   => $admin_id,
817
+				'recipient_type' => 'WP_User',
818
+			);
819
+			$aee          = array_merge($this->_default_addressee_data, $aee);
820
+			$addressees[] = new EE_Messages_Addressee($aee);
821
+		}
822
+		return $addressees;
823
+	}
824
+
825
+
826
+	/**
827
+	 * Takes care of setting up the addressee object(s) for the primary attendee.
828
+	 *
829
+	 * @access protected
830
+	 * @return array of EE_Addressee objects
831
+	 * @throws EE_Error
832
+	 */
833
+	protected function _primary_attendee_addressees()
834
+	{
835
+		$aee                   = $this->_default_addressee_data;
836
+		$aee['events']         = $this->_data->events;
837
+		$aee['attendees']      = $this->_data->attendees;
838
+		$aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
839
+		$aee['recipient_type'] = 'Attendee';
840
+		// great now we can instantiate the $addressee object and return (as an array);
841
+		$add[] = new EE_Messages_Addressee($aee);
842
+		return $add;
843
+	}
844
+
845
+
846
+	/**
847
+	 * Takes care of setting up the addressee object(s) for the registered attendees
848
+	 *
849
+	 * @access protected
850
+	 * @return array of EE_Addressee objects
851
+	 */
852
+	protected function _attendee_addressees()
853
+	{
854
+		$add = array();
855
+		// we just have to loop through the attendees.  We'll also set the attached events for each attendee.
856
+		// use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
857
+		$already_processed = array();
858
+		foreach ($this->_data->attendees as $att_id => $details) {
859
+			// set the attendee array to blank on each loop;
860
+			$aee = array();
861
+			if (
862
+				isset($this->_data->reg_obj)
863
+				&& ($this->_data->reg_obj->attendee_ID() != $att_id)
864
+				&& $this->_single_message
865
+			) {
866
+				continue;
867
+			}
868
+			// is $this->_regs_for_sending present?
869
+			// If so, let's make sure we ONLY generate addressee for registrations in that array.
870
+			if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
871
+				$regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
872
+				if (empty($regs_allowed)) {
873
+					continue;
874
+				}
875
+			}
876
+			if (
877
+				apply_filters(
878
+					'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
879
+					true,
880
+					$this->_data,
881
+					$this
882
+				)
883
+				&& in_array($att_id, $already_processed, true)
884
+			) {
885
+				continue;
886
+			}
887
+			$already_processed[] = $att_id;
888
+			foreach ($details as $item => $value) {
889
+				$aee[ $item ] = $value;
890
+				if ($item === 'line_ref') {
891
+					foreach ($value as $event_id) {
892
+						$aee['events'][ $event_id ] = $this->_data->events[ $event_id ];
893
+					}
894
+				}
895
+				if ($item === 'attendee_email') {
896
+					$aee['attendee_email'] = $value;
897
+				}
898
+				/*if ( $item == 'registration_id' ) {
899 899
                     $aee['attendee_registration_id'] = $value;
900 900
                 }/**/
901
-            }
902
-            // note the FIRST reg object in this array is the one
903
-            // we'll use for this attendee as the primary registration for this attendee.
904
-            $aee['reg_obj']        = reset($this->_data->attendees[ $att_id ]['reg_objs']);
905
-            $aee['attendees']      = $this->_data->attendees;
906
-            $aee['recipient_id']   = $att_id;
907
-            $aee['recipient_type'] = 'Attendee';
908
-            // merge in the primary attendee data
909
-            $aee   = array_merge($this->_default_addressee_data, $aee);
910
-            $add[] = new EE_Messages_Addressee($aee);
911
-        }
912
-        return $add;
913
-    }
914
-
915
-
916
-    /**
917
-     * @param $event_id
918
-     * @return int
919
-     * @throws EE_Error
920
-     * @throws InvalidArgumentException
921
-     * @throws InvalidDataTypeException
922
-     * @throws InvalidInterfaceException
923
-     */
924
-    protected function _get_event_admin_id($event_id)
925
-    {
926
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
927
-        return $event instanceof EE_Event ? $event->wp_user() : 0;
928
-    }
901
+			}
902
+			// note the FIRST reg object in this array is the one
903
+			// we'll use for this attendee as the primary registration for this attendee.
904
+			$aee['reg_obj']        = reset($this->_data->attendees[ $att_id ]['reg_objs']);
905
+			$aee['attendees']      = $this->_data->attendees;
906
+			$aee['recipient_id']   = $att_id;
907
+			$aee['recipient_type'] = 'Attendee';
908
+			// merge in the primary attendee data
909
+			$aee   = array_merge($this->_default_addressee_data, $aee);
910
+			$add[] = new EE_Messages_Addressee($aee);
911
+		}
912
+		return $add;
913
+	}
914
+
915
+
916
+	/**
917
+	 * @param $event_id
918
+	 * @return int
919
+	 * @throws EE_Error
920
+	 * @throws InvalidArgumentException
921
+	 * @throws InvalidDataTypeException
922
+	 * @throws InvalidInterfaceException
923
+	 */
924
+	protected function _get_event_admin_id($event_id)
925
+	{
926
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
927
+		return $event instanceof EE_Event ? $event->wp_user() : 0;
928
+	}
929 929
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Type_Collection_Loader.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
     {
66 66
         // make sure autoloaders are set (fail-safe)
67 67
         EED_Messages::set_autoloaders();
68
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type';
69
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
+        $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages/message_type';
69
+        $folder .= $folder[strlen($folder) - 1] != '/' ? '/' : '';
70 70
         // get all the files in that folder that end in ".class.php
71 71
         $filepaths = apply_filters(
72 72
             'FHEE__EE_messages__get_installed__messagetype_files',
73
-            glob($folder . '*.class.php')
73
+            glob($folder.'*.class.php')
74 74
         );
75 75
         if (empty($filepaths)) {
76 76
             return;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                 continue;
87 87
             }
88 88
 
89
-            if (! class_exists($message_type_class_name)) {
89
+            if ( ! class_exists($message_type_class_name)) {
90 90
                 throw new EE_Error(
91 91
                     sprintf(
92 92
                         esc_html__('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -13,105 +13,105 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Message_Type_Collection_Loader
15 15
 {
16
-    /**
17
-     * @type EE_Message_Type_Collection $_message_type_collection
18
-     */
19
-    protected $_message_type_collection = null;
20
-
21
-
22
-
23
-    /**
24
-     * EE_Message_Type_Collection_Loader constructor.
25
-     *
26
-     * @param EE_Message_Type_Collection $message_types
27
-     */
28
-    public function __construct(EE_Message_Type_Collection $message_types)
29
-    {
30
-        $this->set_message_type_collection($message_types);
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * @return EE_Message_Type_Collection
37
-     */
38
-    public function message_type_collection()
39
-    {
40
-        return $this->_message_type_collection;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @param mixed $message_types
47
-     */
48
-    public function set_message_type_collection(EE_Message_Type_Collection $message_types)
49
-    {
50
-        $this->_message_type_collection = $message_types;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * load_message_types
57
-     * globs the supplied filepath and adds any found
58
-     *
59
-     * @param  string $folder
60
-     * @throws \EE_Error
61
-     */
62
-    public function load_message_types_from_folder($folder = '')
63
-    {
64
-        // make sure autoloaders are set (fail-safe)
65
-        EED_Messages::set_autoloaders();
66
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type';
67
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
-        // get all the files in that folder that end in ".class.php
69
-        $filepaths = apply_filters(
70
-            'FHEE__EE_messages__get_installed__messagetype_files',
71
-            glob($folder . '*.class.php')
72
-        );
73
-        if (empty($filepaths)) {
74
-            return;
75
-        }
76
-        foreach ((array) $filepaths as $file_path) {
77
-            // extract filename from path
78
-            $file_path = basename($file_path);
79
-            // now remove any file extensions
80
-            $message_type_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
-
82
-            // if this class name doesn't represent a message type class, then we just skip.
83
-            if (strpos(strtolower($message_type_class_name), 'message_type') === false) {
84
-                continue;
85
-            }
86
-
87
-            if (! class_exists($message_type_class_name)) {
88
-                throw new EE_Error(
89
-                    sprintf(
90
-                        esc_html__('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
-                        $message_type_class_name,
92
-                        $file_path
93
-                    )
94
-                );
95
-            }
96
-
97
-            $this->_load_message_type(new $message_type_class_name());
98
-        }
99
-    }
100
-
101
-
102
-    /**
103
-     * Loads the given message type into the message type collection if it doesn't already exist.
104
-     * @param EE_message_type $message_type
105
-     * @return bool
106
-     */
107
-    protected function _load_message_type(EE_message_type $message_type)
108
-    {
109
-        if ($this->message_type_collection()->has_by_name($message_type->name)) {
110
-            return true;
111
-        }
112
-        return $this->message_type_collection()->add(
113
-            $message_type,
114
-            $message_type->name
115
-        );
116
-    }
16
+	/**
17
+	 * @type EE_Message_Type_Collection $_message_type_collection
18
+	 */
19
+	protected $_message_type_collection = null;
20
+
21
+
22
+
23
+	/**
24
+	 * EE_Message_Type_Collection_Loader constructor.
25
+	 *
26
+	 * @param EE_Message_Type_Collection $message_types
27
+	 */
28
+	public function __construct(EE_Message_Type_Collection $message_types)
29
+	{
30
+		$this->set_message_type_collection($message_types);
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * @return EE_Message_Type_Collection
37
+	 */
38
+	public function message_type_collection()
39
+	{
40
+		return $this->_message_type_collection;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @param mixed $message_types
47
+	 */
48
+	public function set_message_type_collection(EE_Message_Type_Collection $message_types)
49
+	{
50
+		$this->_message_type_collection = $message_types;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * load_message_types
57
+	 * globs the supplied filepath and adds any found
58
+	 *
59
+	 * @param  string $folder
60
+	 * @throws \EE_Error
61
+	 */
62
+	public function load_message_types_from_folder($folder = '')
63
+	{
64
+		// make sure autoloaders are set (fail-safe)
65
+		EED_Messages::set_autoloaders();
66
+		$folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type';
67
+		$folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
+		// get all the files in that folder that end in ".class.php
69
+		$filepaths = apply_filters(
70
+			'FHEE__EE_messages__get_installed__messagetype_files',
71
+			glob($folder . '*.class.php')
72
+		);
73
+		if (empty($filepaths)) {
74
+			return;
75
+		}
76
+		foreach ((array) $filepaths as $file_path) {
77
+			// extract filename from path
78
+			$file_path = basename($file_path);
79
+			// now remove any file extensions
80
+			$message_type_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
+
82
+			// if this class name doesn't represent a message type class, then we just skip.
83
+			if (strpos(strtolower($message_type_class_name), 'message_type') === false) {
84
+				continue;
85
+			}
86
+
87
+			if (! class_exists($message_type_class_name)) {
88
+				throw new EE_Error(
89
+					sprintf(
90
+						esc_html__('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
+						$message_type_class_name,
92
+						$file_path
93
+					)
94
+				);
95
+			}
96
+
97
+			$this->_load_message_type(new $message_type_class_name());
98
+		}
99
+	}
100
+
101
+
102
+	/**
103
+	 * Loads the given message type into the message type collection if it doesn't already exist.
104
+	 * @param EE_message_type $message_type
105
+	 * @return bool
106
+	 */
107
+	protected function _load_message_type(EE_message_type $message_type)
108
+	{
109
+		if ($this->message_type_collection()->has_by_name($message_type->name)) {
110
+			return true;
111
+		}
112
+		return $this->message_type_collection()->add(
113
+			$message_type,
114
+			$message_type->name
115
+		);
116
+	}
117 117
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messenger_Collection_Loader.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     {
67 67
         // make sure autoloaders are set (fail-safe)
68 68
         EED_Messages::set_autoloaders();
69
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
70
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
69
+        $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages/messenger';
70
+        $folder .= $folder[strlen($folder) - 1] != '/' ? '/' : '';
71 71
         // get all the files in that folder that end in ".class.php
72 72
         $filepaths = apply_filters(
73 73
             'FHEE__EE_messages__get_installed__messenger_files',
74
-            glob($folder . '*.class.php')
74
+            glob($folder.'*.class.php')
75 75
         );
76 76
         if (empty($filepaths)) {
77 77
             return;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 continue;
88 88
             }
89 89
 
90
-            if (! class_exists($messenger_class_name)) {
90
+            if ( ! class_exists($messenger_class_name)) {
91 91
                 throw new EE_Error(
92 92
                     sprintf(
93 93
                         esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,127 +13,127 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messenger_Collection_Loader
15 15
 {
16
-    /**
17
-     * @type EE_Messenger_Collection $_messenger_collection
18
-     */
19
-    protected $_messenger_collection = null;
20
-
21
-
22
-
23
-    /**
24
-     * EE_Messenger_Collection_Loader constructor.
25
-     *
26
-     * @param EE_Messenger_Collection $messengers
27
-     */
28
-    public function __construct(EE_Messenger_Collection $messengers)
29
-    {
30
-        $this->set_messenger_collection($messengers);
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * @return EE_Messenger_Collection
37
-     */
38
-    public function messenger_collection()
39
-    {
40
-        return $this->_messenger_collection;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @param mixed $messengers
47
-     */
48
-    public function set_messenger_collection(EE_Messenger_Collection $messengers)
49
-    {
50
-        $this->_messenger_collection = $messengers;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * load_messengers
57
-     * globs the supplied filepath and adds any found
58
-     *
59
-     * @param  string $folder
60
-     * @throws \EE_Error
61
-     */
62
-    public function load_messengers_from_folder($folder = '')
63
-    {
64
-        // make sure autoloaders are set (fail-safe)
65
-        EED_Messages::set_autoloaders();
66
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
67
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
-        // get all the files in that folder that end in ".class.php
69
-        $filepaths = apply_filters(
70
-            'FHEE__EE_messages__get_installed__messenger_files',
71
-            glob($folder . '*.class.php')
72
-        );
73
-        if (empty($filepaths)) {
74
-            return;
75
-        }
76
-        foreach ((array) $filepaths as $file_path) {
77
-            // extract filename from path
78
-            $file_path = basename($file_path);
79
-            // now remove any file extensions
80
-            $messenger_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
-
82
-            // first check to see if the class name represents an actual messenger class.
83
-            if (strpos(strtolower($messenger_class_name), 'messenger') === false) {
84
-                continue;
85
-            }
86
-
87
-            if (! class_exists($messenger_class_name)) {
88
-                throw new EE_Error(
89
-                    sprintf(
90
-                        esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
-                        $messenger_class_name,
92
-                        $file_path
93
-                    )
94
-                );
95
-            }
96
-
97
-            $this->_load_messenger(new $messenger_class_name());
98
-        }
99
-    }
100
-
101
-
102
-    /**
103
-     * load_messengers
104
-     * globs the supplied filepath and adds any found
105
-     *
106
-     * @return array
107
-     */
108
-    public function load_active_messengers_from_db()
109
-    {
110
-        // make sure autoloaders are set (fail-safe)
111
-        EED_Messages::set_autoloaders();
112
-        $active_messengers = apply_filters(
113
-            'FHEE__EEH_MSG_Template__get_active_messengers_in_db',
114
-            get_option('ee_active_messengers', array())
115
-        );
116
-        foreach ((array) $active_messengers as $active_messenger_classname => $active_messenger) {
117
-            $this->_load_messenger($active_messenger);
118
-        }
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * load_messenger
125
-     *
126
-     * @param \EE_messenger $messenger
127
-     * @return bool
128
-     */
129
-    protected function _load_messenger(EE_messenger $messenger)
130
-    {
131
-        if ($this->messenger_collection()->has_by_name($messenger->name)) {
132
-            return true;
133
-        }
134
-        return $this->messenger_collection()->add(
135
-            $messenger,
136
-            $messenger->name
137
-        );
138
-    }
16
+	/**
17
+	 * @type EE_Messenger_Collection $_messenger_collection
18
+	 */
19
+	protected $_messenger_collection = null;
20
+
21
+
22
+
23
+	/**
24
+	 * EE_Messenger_Collection_Loader constructor.
25
+	 *
26
+	 * @param EE_Messenger_Collection $messengers
27
+	 */
28
+	public function __construct(EE_Messenger_Collection $messengers)
29
+	{
30
+		$this->set_messenger_collection($messengers);
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * @return EE_Messenger_Collection
37
+	 */
38
+	public function messenger_collection()
39
+	{
40
+		return $this->_messenger_collection;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @param mixed $messengers
47
+	 */
48
+	public function set_messenger_collection(EE_Messenger_Collection $messengers)
49
+	{
50
+		$this->_messenger_collection = $messengers;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * load_messengers
57
+	 * globs the supplied filepath and adds any found
58
+	 *
59
+	 * @param  string $folder
60
+	 * @throws \EE_Error
61
+	 */
62
+	public function load_messengers_from_folder($folder = '')
63
+	{
64
+		// make sure autoloaders are set (fail-safe)
65
+		EED_Messages::set_autoloaders();
66
+		$folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
67
+		$folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
+		// get all the files in that folder that end in ".class.php
69
+		$filepaths = apply_filters(
70
+			'FHEE__EE_messages__get_installed__messenger_files',
71
+			glob($folder . '*.class.php')
72
+		);
73
+		if (empty($filepaths)) {
74
+			return;
75
+		}
76
+		foreach ((array) $filepaths as $file_path) {
77
+			// extract filename from path
78
+			$file_path = basename($file_path);
79
+			// now remove any file extensions
80
+			$messenger_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
+
82
+			// first check to see if the class name represents an actual messenger class.
83
+			if (strpos(strtolower($messenger_class_name), 'messenger') === false) {
84
+				continue;
85
+			}
86
+
87
+			if (! class_exists($messenger_class_name)) {
88
+				throw new EE_Error(
89
+					sprintf(
90
+						esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
+						$messenger_class_name,
92
+						$file_path
93
+					)
94
+				);
95
+			}
96
+
97
+			$this->_load_messenger(new $messenger_class_name());
98
+		}
99
+	}
100
+
101
+
102
+	/**
103
+	 * load_messengers
104
+	 * globs the supplied filepath and adds any found
105
+	 *
106
+	 * @return array
107
+	 */
108
+	public function load_active_messengers_from_db()
109
+	{
110
+		// make sure autoloaders are set (fail-safe)
111
+		EED_Messages::set_autoloaders();
112
+		$active_messengers = apply_filters(
113
+			'FHEE__EEH_MSG_Template__get_active_messengers_in_db',
114
+			get_option('ee_active_messengers', array())
115
+		);
116
+		foreach ((array) $active_messengers as $active_messenger_classname => $active_messenger) {
117
+			$this->_load_messenger($active_messenger);
118
+		}
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * load_messenger
125
+	 *
126
+	 * @param \EE_messenger $messenger
127
+	 * @return bool
128
+	 */
129
+	protected function _load_messenger(EE_messenger $messenger)
130
+	{
131
+		if ($this->messenger_collection()->has_by_name($messenger->name)) {
132
+			return true;
133
+		}
134
+		return $this->messenger_collection()->add(
135
+			$messenger,
136
+			$messenger->name
137
+		);
138
+	}
139 139
 }
Please login to merge, or discard this patch.
messages/defaults/default/html_receipt_ticket_line_item_pms.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 <tr class="item">
9 9
     <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td>
10 10
     <td colspan="2">[LINE_ITEM_DESCRIPTION]
11
-        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p>
11
+        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p>
12 12
     </td>
13 13
     <td class="item_c">[LINE_ITEM_QUANTITY]</td>
14 14
     <td class="item_c">[LINE_ITEM_AMOUNT]</td>
Please login to merge, or discard this patch.
core/libraries/messages/defaults/EE_Messages_Template_Pack.core.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
         // make sure required props have been set
167 167
 
168 168
         // if label is empty then throw an error because we should have it defined by now.
169
-        if (! isset($this->label)) {
169
+        if ( ! isset($this->label)) {
170 170
             throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
171 171
         }
172 172
 
173 173
 
174 174
         // the reference for this template pack
175
-        if (! isset($this->dbref)) {
175
+        if ( ! isset($this->dbref)) {
176 176
             throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
177 177
         }
178 178
 
179 179
         // make sure dbref is safe
180 180
         $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
181 181
 
182
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
182
+        $should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
183 183
 
184 184
         if ($should_be !== $classname) {
185 185
             throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
238 238
     {
239
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
239
+        return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type);
240 240
     }
241 241
 
242 242
 
@@ -286,18 +286,18 @@  discard block
 block discarded – undo
286 286
                         foreach ($sub_fields as $sub_field => $sub_field_details) {
287 287
                             // make sure that the template_field_ref matches what the main template field is for this template group.
288 288
                             $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
289
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
289
+                            $templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
290 290
                         }
291 291
                     }
292 292
                 } else {
293
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
293
+                    $templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
294 294
                 }
295 295
             }
296 296
         }
297 297
 
298 298
         $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
299 299
 
300
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
300
+        $this->_templates[$messenger->name][$message_type->name] = $templates;
301 301
          return $templates;
302 302
     }
303 303
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
         $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
324 324
 
325 325
         $master_templates = $message_type->get_master_templates();
326
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
327
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
328
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
329
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
332
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
326
+        $master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name;
327
+        $full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php';
328
+        $fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php';
329
+        $mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
330
+        $mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
331
+        $base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
332
+        $base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
333 333
 
334 334
         /**
335 335
          * Template checks are done hierarchically in the following order:
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             $actual_path = '';
360 360
         }
361 361
         if (empty($actual_path)) {
362
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
362
+            $contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : '';
363 363
         } else {
364 364
             $contents = EEH_Template::display_template($actual_path, array(), true);
365 365
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function get_supports()
382 382
     {
383
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
383
+        $supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports);
384 384
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
385 385
     }
386 386
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     public function get_default_variation_labels($messenger = '')
400 400
     {
401 401
         $label = empty($messenger) ? $this->_default_variation_labels : array();
402
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
402
+        $label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : esc_html__('Default', 'event_espresso');
403 403
 
404 404
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
405 405
     }
@@ -419,24 +419,24 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function get_variations($messenger = '', $message_type = '')
421 421
     {
422
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
422
+        $messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array();
423 423
 
424 424
         // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
425
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
425
+        $variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array();
426 426
 
427 427
         // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
428
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
428
+        $variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
429 429
 
430 430
         // filter per template pack and globally.
431
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
431
+        $variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type);
432 432
         $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
433 433
 
434 434
         // prepend the _default_variation, but ONLY if we're returning the fully validated array.
435
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
436
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
+        if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) {
436
+            $variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations;
437 437
         }
438 438
 
439
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
439
+        return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations;
440 440
     }
441 441
 
442 442
 
@@ -463,23 +463,23 @@  discard block
 block discarded – undo
463 463
         $base = $url ? $this->_base_url : $this->_base_path;
464 464
         $base_path = $this->_base_path;
465 465
 
466
-        if (! $skip_filters) {
467
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
+        if ( ! $skip_filters) {
467
+            $base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
468 468
             $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
469 469
         }
470 470
 
471 471
         $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472 472
 
473 473
         // possible variation paths considering whether message type is present or not in the file name.
474
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
475
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension;
475
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension;
476 476
 
477 477
         // first see if fully validated file exists.
478
-        if (is_readable($base_path . $path_string)) {
479
-            $variation_path = $base . $path_string;
478
+        if (is_readable($base_path.$path_string)) {
479
+            $variation_path = $base.$path_string;
480 480
         // otherwise see if default exists.
481
-        } elseif (is_readable($base_path . $default_path_string)) {
482
-            $variation_path = $base . $default_path_string;
481
+        } elseif (is_readable($base_path.$default_path_string)) {
482
+            $variation_path = $base.$default_path_string;
483 483
         } else {
484 484
             $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
485 485
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         }
490 490
 
491 491
         // filter result
492
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
492
+        $variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
493 493
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
494 494
     }
495 495
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     {
510 510
         $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
511 511
 
512
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
512
+        $path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php';
513 513
 
514 514
         if (is_readable($path_string)) {
515 515
             $template = $path_string;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         }
519 519
 
520 520
         // filter
521
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
521
+        $template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type);
522 522
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523 523
     }
524 524
 }
Please login to merge, or discard this patch.
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -12,511 +12,511 @@
 block discarded – undo
12 12
  */
13 13
 abstract class EE_Messages_Template_Pack
14 14
 {
15
-    /**
16
-     * This defines the base_path where the templates are located.
17
-     *
18
-     * @since            4.5.0
19
-     *
20
-     * @var string
21
-     */
22
-    protected $_base_path;
15
+	/**
16
+	 * This defines the base_path where the templates are located.
17
+	 *
18
+	 * @since            4.5.0
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $_base_path;
23 23
 
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * This defines the base_url where things are found for this template pack (possibly variations).
29
-     *
30
-     * @since 4.5.0
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_base_url;
27
+	/**
28
+	 * This defines the base_url where things are found for this template pack (possibly variations).
29
+	 *
30
+	 * @since 4.5.0
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_base_url;
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * localized label for this template pack
40
-     *
41
-     * @since            4.5.0
42
-     *
43
-     * @var string
44
-     */
45
-    public $label;
38
+	/**
39
+	 * localized label for this template pack
40
+	 *
41
+	 * @since            4.5.0
42
+	 *
43
+	 * @var string
44
+	 */
45
+	public $label;
46 46
 
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * used to contain a description for the template pack.
52
-     *
53
-     * @since 4.5.0
54
-     *
55
-     * @var string
56
-     */
57
-    public $description;
50
+	/**
51
+	 * used to contain a description for the template pack.
52
+	 *
53
+	 * @since 4.5.0
54
+	 *
55
+	 * @var string
56
+	 */
57
+	public $description;
58 58
 
59 59
 
60 60
 
61 61
 
62
-    /**
63
-     * How this template is referenced in the db
64
-     *
65
-     * @since 4.5.0
66
-     *
67
-     * @var string
68
-     */
69
-    public $dbref;
62
+	/**
63
+	 * How this template is referenced in the db
64
+	 *
65
+	 * @since 4.5.0
66
+	 *
67
+	 * @var string
68
+	 */
69
+	public $dbref;
70 70
 
71 71
 
72 72
 
73 73
 
74
-    /**
75
-     * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
76
-     *
77
-     * @since 4.5.0
78
-     *
79
-     * @var array.
80
-     */
81
-    protected $_supports = array();
74
+	/**
75
+	 * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
76
+	 *
77
+	 * @since 4.5.0
78
+	 *
79
+	 * @var array.
80
+	 */
81
+	protected $_supports = array();
82 82
 
83 83
 
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
89
-     *
90
-     * $templates = array(
91
-     *  'email' => array(
92
-     *      'registration' => array(
93
-     *          'admin' => array(
94
-     *              'to' => 'contents',
95
-     *              'from' => 'contents',
96
-     *              'subject' => 'contents',
97
-     *              'content' => 'contents',
98
-     *              'event_list' => 'contents',
99
-     *              'attendee_list' => 'contents'
100
-     *          ),
101
-     *          'attendee' => array(
102
-     *              'to' => 'contents',
103
-     *              'from' => 'contents',
104
-     *              'subject' => 'contents',
105
-     *              'content' => 'contents',
106
-     *              'event_list' => 'contents',
107
-     *              'attendee_list' => 'contents',
108
-     *          ),
109
-     *      )
110
-     *  )
111
-     * )
112
-     *
113
-     * @since 4.5.0
114
-     *
115
-     * @var array
116
-     */
117
-    protected $_templates = array();
87
+	/**
88
+	 * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
89
+	 *
90
+	 * $templates = array(
91
+	 *  'email' => array(
92
+	 *      'registration' => array(
93
+	 *          'admin' => array(
94
+	 *              'to' => 'contents',
95
+	 *              'from' => 'contents',
96
+	 *              'subject' => 'contents',
97
+	 *              'content' => 'contents',
98
+	 *              'event_list' => 'contents',
99
+	 *              'attendee_list' => 'contents'
100
+	 *          ),
101
+	 *          'attendee' => array(
102
+	 *              'to' => 'contents',
103
+	 *              'from' => 'contents',
104
+	 *              'subject' => 'contents',
105
+	 *              'content' => 'contents',
106
+	 *              'event_list' => 'contents',
107
+	 *              'attendee_list' => 'contents',
108
+	 *          ),
109
+	 *      )
110
+	 *  )
111
+	 * )
112
+	 *
113
+	 * @since 4.5.0
114
+	 *
115
+	 * @var array
116
+	 */
117
+	protected $_templates = array();
118 118
 
119 119
 
120 120
 
121 121
 
122 122
 
123 123
 
124
-    /**
125
-     * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
126
-     * example:
127
-     * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
128
-     *
129
-     * @var array
130
-     */
131
-    protected $_default_variation_labels = array();
124
+	/**
125
+	 * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
126
+	 * example:
127
+	 * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
128
+	 *
129
+	 * @var array
130
+	 */
131
+	protected $_default_variation_labels = array();
132 132
 
133 133
 
134 134
 
135 135
 
136
-    /**
137
-     * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
138
-     * array(
139
-     *  'email' => array(
140
-     *  )
141
-     * )
142
-     *
143
-     * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
144
-     *
145
-     * @since 4.5.0
146
-     *
147
-     * @var array
148
-     */
149
-    public $_variations = array();
150
-
151
-
152
-
153
-
154
-    /**
155
-     * Template pack constructor
156
-     *
157
-     * @since 4.5.0
158
-     */
159
-    public function __construct()
160
-    {
161
-        $this->_set_props();
162
-        // make sure classname is correct
163
-        $classname = get_class($this);
164
-        // make sure required props have been set
165
-
166
-        // if label is empty then throw an error because we should have it defined by now.
167
-        if (! isset($this->label)) {
168
-            throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
169
-        }
170
-
171
-
172
-        // the reference for this template pack
173
-        if (! isset($this->dbref)) {
174
-            throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
175
-        }
176
-
177
-        // make sure dbref is safe
178
-        $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
179
-
180
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
181
-
182
-        if ($should_be !== $classname) {
183
-            throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
184
-        }
185
-
186
-        // if _base_path is not set then throw an error because a base path string is needed.
187
-        if (empty($this->_base_path)) {
188
-            throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
189
-        }
190
-
191
-
192
-        // if _base_url is not set then throw an error because a  string is needed for variations.
193
-        if (empty($this->_base_url)) {
194
-            throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
195
-        }
196
-
197
-
198
-        // if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
199
-        if (empty($this->_supports)) {
200
-            throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
201
-        }
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * This method should be used to define the following properties:
208
-     * - label
209
-     * - dbref
210
-     * - description
211
-     * - _base_path
212
-     * - _base_url
213
-     * - supports
214
-     * - variations
215
-     *
216
-     * @since 4.5.0
217
-     * @return void.
218
-     * @abstract
219
-     */
220
-    abstract protected function _set_props();
221
-
222
-
223
-
224
-
225
-    /**
226
-     * Wrapper for get_templates() ( @see get_templates() for documentation)
227
-     *
228
-     * @since 4.5.0
229
-     *
230
-     * @param EE_messenger    $messenger
231
-     * @param EE_message_type $message_type
232
-     *
233
-     * @return array
234
-     */
235
-    public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
236
-    {
237
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
238
-    }
239
-
240
-
241
-
242
-
243
-    /**
244
-     * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
245
-     *
246
-     * @since 4.5.0
247
-     *
248
-     * @param EE_messenger    $messenger
249
-     * @param EE_message_type $message_type
250
-     *
251
-     * @return array          Returns an multi-level associative array indexed by template context and field in the format:
252
-     *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
253
-     */
254
-    protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
255
-    {
256
-        $templates = array();
257
-
258
-        /**
259
-         * Retrieving the default pack for later usage of default templates for template packs that
260
-         * are NOT the default pack ( or an extension of the default pack ).
261
-         * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
262
-         * pack.  This prevents recursion in _get_specific_template().  The intention is that for
263
-         * template packs that are NOT default packs, we use the default template pack to provide
264
-         * the final fallback templates if there aren't any defined for the called template pack.
265
-         *
266
-         * @type EE_Messages_Template_Pack_Default | null $default_pack
267
-         */
268
-        $default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
269
-
270
-        $fields = $messenger->get_template_fields();
271
-        $contexts = $message_type->get_contexts();
272
-
273
-
274
-        foreach ($contexts as $context => $details) {
275
-            foreach ($fields as $field => $field_details) {
276
-                if (empty($field_details)) {
277
-                    continue;
278
-                }
279
-                /**
280
-                 * is this a field array (linked to a main field)?
281
-                 */
282
-                if ($field == 'extra') {
283
-                    foreach ($field_details as $main_field => $sub_fields) {
284
-                        foreach ($sub_fields as $sub_field => $sub_field_details) {
285
-                            // make sure that the template_field_ref matches what the main template field is for this template group.
286
-                            $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
287
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
288
-                        }
289
-                    }
290
-                } else {
291
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
292
-                }
293
-            }
294
-        }
295
-
296
-        $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
297
-
298
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
299
-         return $templates;
300
-    }
301
-
302
-
303
-    /**
304
-     * Utility method for retrieving a specific template matching the given parameters
305
-     *
306
-     * @param null | EE_Messages_Template_Pack_Default $default_pack
307
-     * @param EE_messenger                             $messenger
308
-     * @param EE_message_type                          $message_type
309
-     * @param string                                   $field          The field reference for the specific template being looked up.
310
-     * @param string                                   $context      The context reference for the specific template being looked up
311
-     *
312
-     * @return string          The template contents.
313
-     */
314
-    protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
315
-    {
316
-
317
-        // default templates
318
-        $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
319
-
320
-        // first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
321
-        $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
322
-
323
-        $master_templates = $message_type->get_master_templates();
324
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
325
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
326
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
327
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
328
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
329
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-
332
-        /**
333
-         * Template checks are done hierarchically in the following order:
334
-         *
335
-         * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
336
-         * - a match for the full messenger name, message type, field in the full path for the given template pack.
337
-         * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
338
-         * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
339
-         * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
340
-         * - empty string.
341
-         */
342
-
343
-
344
-        if (is_readable($full_path)) {
345
-            $actual_path = $full_path;
346
-        } elseif (is_readable($fallback_path)) {
347
-            $actual_path = $fallback_path;
348
-        } elseif (is_readable($mt_defined_full_path)) {
349
-            $actual_path = $mt_defined_full_path;
350
-        } elseif (is_readable($mt_defined_fallback_path)) {
351
-            $actual_path = $mt_defined_fallback_path;
352
-        } elseif (is_readable($base_defined_full_path)) {
353
-            $actual_path = $base_defined_full_path;
354
-        } elseif (is_readable($base_defined_fallback_path)) {
355
-            $actual_path = $base_defined_fallback_path;
356
-        } else {
357
-            $actual_path = '';
358
-        }
359
-        if (empty($actual_path)) {
360
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
361
-        } else {
362
-            $contents = EEH_Template::display_template($actual_path, array(), true);
363
-        }
364
-
365
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
366
-    }
367
-
368
-
369
-
370
-
371
-
372
-    /**
373
-     * Return filtered _supports property.
374
-     *
375
-     * @since 4.5.0
376
-     *
377
-     * @return array
378
-     */
379
-    public function get_supports()
380
-    {
381
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
382
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
383
-    }
384
-
385
-
386
-
387
-
388
-    /**
389
-     * This simply returns the $_default_variation_labels property value.
390
-     *
391
-     * @since 4.5.0
392
-     *
393
-     * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
394
-     *
395
-     * @return array|string
396
-     */
397
-    public function get_default_variation_labels($messenger = '')
398
-    {
399
-        $label = empty($messenger) ? $this->_default_variation_labels : array();
400
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
401
-
402
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
403
-    }
404
-
405
-
406
-
407
-
408
-
409
-    /**
410
-     * This simply returns the _variations property.
411
-     *
412
-     * @since 4.5.0
413
-     *
414
-     * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
415
-     * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
416
-     * @return array
417
-     */
418
-    public function get_variations($messenger = '', $message_type = '')
419
-    {
420
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
421
-
422
-        // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
423
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
424
-
425
-        // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
426
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
427
-
428
-        // filter per template pack and globally.
429
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
430
-        $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
431
-
432
-        // prepend the _default_variation, but ONLY if we're returning the fully validated array.
433
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
434
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
-        }
436
-
437
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
438
-    }
439
-
440
-
441
-
442
-
443
-    /**
444
-     * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
445
-     *
446
-     * @since 4.5.0
447
-     *
448
-     * @param string $messenger messenger slug
449
-     * @param string $message_type message_type slug
450
-     * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
451
-     * @param string $variation    this should match one of the defined variations in the _variations property on this class.
452
-     * @param string $file_extension  What type of file the variation file is (defaults to css)
453
-     * @param bool   $url          if true then return the url otherwise path.
454
-     * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
455
-     *
456
-     * @return string The variation path or url (typically css reference)
457
-     */
458
-    public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
459
-    {
136
+	/**
137
+	 * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
138
+	 * array(
139
+	 *  'email' => array(
140
+	 *  )
141
+	 * )
142
+	 *
143
+	 * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
144
+	 *
145
+	 * @since 4.5.0
146
+	 *
147
+	 * @var array
148
+	 */
149
+	public $_variations = array();
150
+
151
+
152
+
153
+
154
+	/**
155
+	 * Template pack constructor
156
+	 *
157
+	 * @since 4.5.0
158
+	 */
159
+	public function __construct()
160
+	{
161
+		$this->_set_props();
162
+		// make sure classname is correct
163
+		$classname = get_class($this);
164
+		// make sure required props have been set
165
+
166
+		// if label is empty then throw an error because we should have it defined by now.
167
+		if (! isset($this->label)) {
168
+			throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
169
+		}
170
+
171
+
172
+		// the reference for this template pack
173
+		if (! isset($this->dbref)) {
174
+			throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
175
+		}
176
+
177
+		// make sure dbref is safe
178
+		$this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
179
+
180
+		$should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
181
+
182
+		if ($should_be !== $classname) {
183
+			throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
184
+		}
185
+
186
+		// if _base_path is not set then throw an error because a base path string is needed.
187
+		if (empty($this->_base_path)) {
188
+			throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
189
+		}
190
+
191
+
192
+		// if _base_url is not set then throw an error because a  string is needed for variations.
193
+		if (empty($this->_base_url)) {
194
+			throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
195
+		}
196
+
197
+
198
+		// if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
199
+		if (empty($this->_supports)) {
200
+			throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
201
+		}
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * This method should be used to define the following properties:
208
+	 * - label
209
+	 * - dbref
210
+	 * - description
211
+	 * - _base_path
212
+	 * - _base_url
213
+	 * - supports
214
+	 * - variations
215
+	 *
216
+	 * @since 4.5.0
217
+	 * @return void.
218
+	 * @abstract
219
+	 */
220
+	abstract protected function _set_props();
221
+
222
+
223
+
224
+
225
+	/**
226
+	 * Wrapper for get_templates() ( @see get_templates() for documentation)
227
+	 *
228
+	 * @since 4.5.0
229
+	 *
230
+	 * @param EE_messenger    $messenger
231
+	 * @param EE_message_type $message_type
232
+	 *
233
+	 * @return array
234
+	 */
235
+	public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
236
+	{
237
+		return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
238
+	}
239
+
240
+
241
+
242
+
243
+	/**
244
+	 * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
245
+	 *
246
+	 * @since 4.5.0
247
+	 *
248
+	 * @param EE_messenger    $messenger
249
+	 * @param EE_message_type $message_type
250
+	 *
251
+	 * @return array          Returns an multi-level associative array indexed by template context and field in the format:
252
+	 *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
253
+	 */
254
+	protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
255
+	{
256
+		$templates = array();
257
+
258
+		/**
259
+		 * Retrieving the default pack for later usage of default templates for template packs that
260
+		 * are NOT the default pack ( or an extension of the default pack ).
261
+		 * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
262
+		 * pack.  This prevents recursion in _get_specific_template().  The intention is that for
263
+		 * template packs that are NOT default packs, we use the default template pack to provide
264
+		 * the final fallback templates if there aren't any defined for the called template pack.
265
+		 *
266
+		 * @type EE_Messages_Template_Pack_Default | null $default_pack
267
+		 */
268
+		$default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
269
+
270
+		$fields = $messenger->get_template_fields();
271
+		$contexts = $message_type->get_contexts();
272
+
273
+
274
+		foreach ($contexts as $context => $details) {
275
+			foreach ($fields as $field => $field_details) {
276
+				if (empty($field_details)) {
277
+					continue;
278
+				}
279
+				/**
280
+				 * is this a field array (linked to a main field)?
281
+				 */
282
+				if ($field == 'extra') {
283
+					foreach ($field_details as $main_field => $sub_fields) {
284
+						foreach ($sub_fields as $sub_field => $sub_field_details) {
285
+							// make sure that the template_field_ref matches what the main template field is for this template group.
286
+							$template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
287
+							$templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
288
+						}
289
+					}
290
+				} else {
291
+					$templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
292
+				}
293
+			}
294
+		}
295
+
296
+		$templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
297
+
298
+		$this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
299
+		 return $templates;
300
+	}
301
+
302
+
303
+	/**
304
+	 * Utility method for retrieving a specific template matching the given parameters
305
+	 *
306
+	 * @param null | EE_Messages_Template_Pack_Default $default_pack
307
+	 * @param EE_messenger                             $messenger
308
+	 * @param EE_message_type                          $message_type
309
+	 * @param string                                   $field          The field reference for the specific template being looked up.
310
+	 * @param string                                   $context      The context reference for the specific template being looked up
311
+	 *
312
+	 * @return string          The template contents.
313
+	 */
314
+	protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
315
+	{
316
+
317
+		// default templates
318
+		$default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
319
+
320
+		// first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
321
+		$filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
322
+
323
+		$master_templates = $message_type->get_master_templates();
324
+		$master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
325
+		$full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
326
+		$fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
327
+		$mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
328
+		$mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
329
+		$base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
+		$base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
+
332
+		/**
333
+		 * Template checks are done hierarchically in the following order:
334
+		 *
335
+		 * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
336
+		 * - a match for the full messenger name, message type, field in the full path for the given template pack.
337
+		 * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
338
+		 * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
339
+		 * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
340
+		 * - empty string.
341
+		 */
342
+
343
+
344
+		if (is_readable($full_path)) {
345
+			$actual_path = $full_path;
346
+		} elseif (is_readable($fallback_path)) {
347
+			$actual_path = $fallback_path;
348
+		} elseif (is_readable($mt_defined_full_path)) {
349
+			$actual_path = $mt_defined_full_path;
350
+		} elseif (is_readable($mt_defined_fallback_path)) {
351
+			$actual_path = $mt_defined_fallback_path;
352
+		} elseif (is_readable($base_defined_full_path)) {
353
+			$actual_path = $base_defined_full_path;
354
+		} elseif (is_readable($base_defined_fallback_path)) {
355
+			$actual_path = $base_defined_fallback_path;
356
+		} else {
357
+			$actual_path = '';
358
+		}
359
+		if (empty($actual_path)) {
360
+			$contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
361
+		} else {
362
+			$contents = EEH_Template::display_template($actual_path, array(), true);
363
+		}
364
+
365
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
366
+	}
367
+
368
+
369
+
370
+
371
+
372
+	/**
373
+	 * Return filtered _supports property.
374
+	 *
375
+	 * @since 4.5.0
376
+	 *
377
+	 * @return array
378
+	 */
379
+	public function get_supports()
380
+	{
381
+		$supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
382
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
383
+	}
384
+
385
+
386
+
387
+
388
+	/**
389
+	 * This simply returns the $_default_variation_labels property value.
390
+	 *
391
+	 * @since 4.5.0
392
+	 *
393
+	 * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
394
+	 *
395
+	 * @return array|string
396
+	 */
397
+	public function get_default_variation_labels($messenger = '')
398
+	{
399
+		$label = empty($messenger) ? $this->_default_variation_labels : array();
400
+		$label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
401
+
402
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
403
+	}
404
+
405
+
406
+
407
+
408
+
409
+	/**
410
+	 * This simply returns the _variations property.
411
+	 *
412
+	 * @since 4.5.0
413
+	 *
414
+	 * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
415
+	 * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
416
+	 * @return array
417
+	 */
418
+	public function get_variations($messenger = '', $message_type = '')
419
+	{
420
+		$messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
421
+
422
+		// message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
423
+		$variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
424
+
425
+		// now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
426
+		$variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
427
+
428
+		// filter per template pack and globally.
429
+		$variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
430
+		$variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
431
+
432
+		// prepend the _default_variation, but ONLY if we're returning the fully validated array.
433
+		if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
434
+			$variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
+		}
436
+
437
+		return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
438
+	}
439
+
440
+
441
+
442
+
443
+	/**
444
+	 * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
445
+	 *
446
+	 * @since 4.5.0
447
+	 *
448
+	 * @param string $messenger messenger slug
449
+	 * @param string $message_type message_type slug
450
+	 * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
451
+	 * @param string $variation    this should match one of the defined variations in the _variations property on this class.
452
+	 * @param string $file_extension  What type of file the variation file is (defaults to css)
453
+	 * @param bool   $url          if true then return the url otherwise path.
454
+	 * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
455
+	 *
456
+	 * @return string The variation path or url (typically css reference)
457
+	 */
458
+	public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
459
+	{
460 460
 
461
-        $base = $url ? $this->_base_url : $this->_base_path;
462
-        $base_path = $this->_base_path;
461
+		$base = $url ? $this->_base_url : $this->_base_path;
462
+		$base_path = $this->_base_path;
463 463
 
464
-        if (! $skip_filters) {
465
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
-            $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
467
-        }
464
+		if (! $skip_filters) {
465
+			$base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
+			$base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
467
+		}
468 468
 
469
-        $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
470
-
471
-        // possible variation paths considering whether message type is present or not in the file name.
472
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
473
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
-
475
-        // first see if fully validated file exists.
476
-        if (is_readable($base_path . $path_string)) {
477
-            $variation_path = $base . $path_string;
478
-        // otherwise see if default exists.
479
-        } elseif (is_readable($base_path . $default_path_string)) {
480
-            $variation_path = $base . $default_path_string;
481
-        } else {
482
-            $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
483
-        }
469
+		$default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
470
+
471
+		// possible variation paths considering whether message type is present or not in the file name.
472
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
473
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
+
475
+		// first see if fully validated file exists.
476
+		if (is_readable($base_path . $path_string)) {
477
+			$variation_path = $base . $path_string;
478
+		// otherwise see if default exists.
479
+		} elseif (is_readable($base_path . $default_path_string)) {
480
+			$variation_path = $base . $default_path_string;
481
+		} else {
482
+			$variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
483
+		}
484 484
 
485
-        if ($skip_filters) {
486
-            return $variation_path;
487
-        }
488
-
489
-        // filter result
490
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
491
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
492
-    }
493
-
494
-
495
-
496
-
497
-
498
-    /**
499
-     * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
500
-     *
501
-     * @param string $messenger What messenger the wrapper is for.
502
-     * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
503
-     *
504
-     * @return string returns the path for the requested wrapper template.
505
-     */
506
-    public function get_wrapper($messenger, $type = 'main')
507
-    {
508
-        $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
509
-
510
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
511
-
512
-        if (is_readable($path_string)) {
513
-            $template = $path_string;
514
-        } else {
515
-            $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
516
-        }
517
-
518
-        // filter
519
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
520
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
521
-    }
485
+		if ($skip_filters) {
486
+			return $variation_path;
487
+		}
488
+
489
+		// filter result
490
+		$variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
491
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
492
+	}
493
+
494
+
495
+
496
+
497
+
498
+	/**
499
+	 * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
500
+	 *
501
+	 * @param string $messenger What messenger the wrapper is for.
502
+	 * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
503
+	 *
504
+	 * @return string returns the path for the requested wrapper template.
505
+	 */
506
+	public function get_wrapper($messenger, $type = 'main')
507
+	{
508
+		$default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
509
+
510
+		$path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
511
+
512
+		if (is_readable($path_string)) {
513
+			$template = $path_string;
514
+		} else {
515
+			$template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
516
+		}
517
+
518
+		// filter
519
+		$template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
520
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
521
+	}
522 522
 }
Please login to merge, or discard this patch.