Completed
Branch Gutenberg/event-attendees-bloc... (dcb43c)
by
unknown
21:24 queued 19:24
created
caffeinated/admin/new/pricing/Price_Types_List_Table.class.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -16,188 +16,188 @@
 block discarded – undo
16 16
 class Price_Types_List_Table extends EE_Admin_List_Table
17 17
 {
18 18
 
19
-    public function __construct($admin_page)
20
-    {
21
-        parent::__construct($admin_page);
22
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
23
-        $this->_PRT = EEM_Price_Type::instance();
24
-    }
25
-
26
-
27
-    protected function _setup_data()
28
-    {
29
-        $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
30
-        $this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
31
-        $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
32
-        $this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
33
-    }
34
-
35
-
36
-    protected function _set_properties()
37
-    {
38
-        $this->_wp_list_args = array(
39
-            'singular' => __('price type', 'event_espresso'),
40
-            'plural'   => __('price types', 'event_espresso'),
41
-            'ajax'     => true,
42
-            'screen'   => $this->_admin_page->get_current_screen()->id,
43
-        );
44
-
45
-        $this->_columns = array(
46
-            'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47
-            'name'      => __('Name', 'event_espresso'),
48
-            'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
49
-            'percent'   => '<div class="jst-cntr">' . __('Applied', 'event_espresso') . '<br/>'
50
-                           . __('as ', 'event_espresso') . '<span class="big-text">'
51
-                           . __('%', 'event_espresso') . '</span>'
52
-                           . __(' or ', 'event_espresso') . '<span class="big-text">'
53
-                           . __('$', 'event_espresso') . '</span></div>',
54
-            'order'     => '<div class="jst-cntr">' . __('Order of', 'event_espresso') . '<br/>'
55
-                           . __('Application', 'event_espresso') . '</div>',
56
-        );
57
-
58
-        $this->_sortable_columns = array(
59
-            // TRUE means its already sorted
60
-            'name' => array('name' => false),
61
-        );
62
-
63
-        $this->_hidden_columns = array();
64
-    }
65
-
66
-
67
-    protected function _get_table_filters()
68
-    {
69
-    }
70
-
71
-
72
-    protected function _add_view_counts()
73
-    {
74
-        $this->_views['all']['count'] = $this->_all_data_count;
75
-        if (EE_Registry::instance()->CAP->current_user_can(
76
-            'ee_delete_default_price_types',
77
-            'pricing_trash_price_type'
78
-        )) {
79
-            $this->_views['trashed']['count'] = $this->_trashed_count;
80
-        }
81
-    }
82
-
83
-
84
-    public function column_cb($item)
85
-    {
86
-        if ($item->base_type() !== 1) {
87
-            return sprintf(
88
-                '<input type="checkbox" name="checkbox[%1$s]" />',
89
-                $item->ID()
90
-            );
91
-        }
92
-        return '';
93
-    }
94
-
95
-
96
-    public function column_name($item)
97
-    {
98
-
99
-        // Build row actions
100
-        $actions = array();
101
-        // edit price link
102
-        if (EE_Registry::instance()->CAP->current_user_can(
103
-            'ee_edit_default_price_type',
104
-            'pricing_edit_price_type',
105
-            $item->ID()
106
-        )) {
107
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
108
-                'action' => 'edit_price_type',
109
-                'id'     => $item->ID(),
110
-            ), PRICING_ADMIN_URL);
111
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
112
-                               . esc_attr__('Edit Price Type', 'event_espresso') . '">'
113
-                               . __('Edit', 'event_espresso') . '</a>';
114
-        }
115
-
116
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
117
-            'ee_edit_default_price_type',
118
-            'pricing_edit_price_type',
119
-            $item->ID()
120
-        )
121
-            ? '<a href="' . $edit_lnk_url . '" title="'
122
-              . esc_attr__('Edit Price Type', 'event_espresso') . '">'
123
-              . stripslashes($item->name()) . '</a>'
124
-            : $item->name();
125
-
126
-        if ($item->base_type() !== 1) {
127
-            if ($this->_view == 'all') {
128
-                // trash price link
129
-                if (EE_Registry::instance()->CAP->current_user_can(
130
-                    'ee_delete_default_price_type',
131
-                    'pricing_trash_price_type',
132
-                    $item->ID()
133
-                )) {
134
-                    $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
135
-                        'action'   => 'trash_price_type',
136
-                        'id'       => $item->ID(),
137
-                        'noheader' => true,
138
-                    ), PRICING_ADMIN_URL);
139
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
140
-                                        . esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
141
-                                        . __('Move to Trash', 'event_espresso') . '</a>';
142
-                }
143
-            } else {
144
-                // restore price link
145
-                if (EE_Registry::instance()->CAP->current_user_can(
146
-                    'ee_delete_default_price_type',
147
-                    'pricing_restore_price_type',
148
-                    $item->ID()
149
-                )) {
150
-                    $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
151
-                        'action'   => 'restore_price_type',
152
-                        'id'       => $item->ID(),
153
-                        'noheader' => true,
154
-                    ), PRICING_ADMIN_URL);
155
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
156
-                                          . esc_attr__('Restore Price Type', 'event_espresso') . '">'
157
-                                          . __('Restore', 'event_espresso') . '</a>';
158
-                }
159
-                // delete price link
160
-                if (EE_Registry::instance()->CAP->current_user_can(
161
-                    'ee_delete_default_price_type',
162
-                    'pricing_delete_price_type',
163
-                    $item->ID()
164
-                )) {
165
-                    $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
166
-                        'action'   => 'delete_price_type',
167
-                        'id'       => $item->ID(),
168
-                        'noheader' => true,
169
-                    ), PRICING_ADMIN_URL);
170
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
171
-                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
172
-                                         . __('Delete Permanently', 'event_espresso') . '</a>';
173
-                }
174
-            }
175
-        }
176
-
177
-        // Return the name contents
178
-        return sprintf(
179
-            '%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
180
-            $name_link,
181
-            $item->ID(),
182
-            $this->row_actions($actions)
183
-        );
184
-    }
185
-
186
-
187
-    public function column_base_type($item)
188
-    {
189
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
190
-    }
191
-
192
-
193
-    public function column_percent($item)
194
-    {
195
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
196
-    }
197
-
198
-
199
-    public function column_order($item)
200
-    {
201
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
202
-    }
19
+	public function __construct($admin_page)
20
+	{
21
+		parent::__construct($admin_page);
22
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
23
+		$this->_PRT = EEM_Price_Type::instance();
24
+	}
25
+
26
+
27
+	protected function _setup_data()
28
+	{
29
+		$trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
30
+		$this->_data = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
31
+		$this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, false);
32
+		$this->_trashed_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
33
+	}
34
+
35
+
36
+	protected function _set_properties()
37
+	{
38
+		$this->_wp_list_args = array(
39
+			'singular' => __('price type', 'event_espresso'),
40
+			'plural'   => __('price types', 'event_espresso'),
41
+			'ajax'     => true,
42
+			'screen'   => $this->_admin_page->get_current_screen()->id,
43
+		);
44
+
45
+		$this->_columns = array(
46
+			'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47
+			'name'      => __('Name', 'event_espresso'),
48
+			'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
49
+			'percent'   => '<div class="jst-cntr">' . __('Applied', 'event_espresso') . '<br/>'
50
+						   . __('as ', 'event_espresso') . '<span class="big-text">'
51
+						   . __('%', 'event_espresso') . '</span>'
52
+						   . __(' or ', 'event_espresso') . '<span class="big-text">'
53
+						   . __('$', 'event_espresso') . '</span></div>',
54
+			'order'     => '<div class="jst-cntr">' . __('Order of', 'event_espresso') . '<br/>'
55
+						   . __('Application', 'event_espresso') . '</div>',
56
+		);
57
+
58
+		$this->_sortable_columns = array(
59
+			// TRUE means its already sorted
60
+			'name' => array('name' => false),
61
+		);
62
+
63
+		$this->_hidden_columns = array();
64
+	}
65
+
66
+
67
+	protected function _get_table_filters()
68
+	{
69
+	}
70
+
71
+
72
+	protected function _add_view_counts()
73
+	{
74
+		$this->_views['all']['count'] = $this->_all_data_count;
75
+		if (EE_Registry::instance()->CAP->current_user_can(
76
+			'ee_delete_default_price_types',
77
+			'pricing_trash_price_type'
78
+		)) {
79
+			$this->_views['trashed']['count'] = $this->_trashed_count;
80
+		}
81
+	}
82
+
83
+
84
+	public function column_cb($item)
85
+	{
86
+		if ($item->base_type() !== 1) {
87
+			return sprintf(
88
+				'<input type="checkbox" name="checkbox[%1$s]" />',
89
+				$item->ID()
90
+			);
91
+		}
92
+		return '';
93
+	}
94
+
95
+
96
+	public function column_name($item)
97
+	{
98
+
99
+		// Build row actions
100
+		$actions = array();
101
+		// edit price link
102
+		if (EE_Registry::instance()->CAP->current_user_can(
103
+			'ee_edit_default_price_type',
104
+			'pricing_edit_price_type',
105
+			$item->ID()
106
+		)) {
107
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
108
+				'action' => 'edit_price_type',
109
+				'id'     => $item->ID(),
110
+			), PRICING_ADMIN_URL);
111
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
112
+							   . esc_attr__('Edit Price Type', 'event_espresso') . '">'
113
+							   . __('Edit', 'event_espresso') . '</a>';
114
+		}
115
+
116
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
117
+			'ee_edit_default_price_type',
118
+			'pricing_edit_price_type',
119
+			$item->ID()
120
+		)
121
+			? '<a href="' . $edit_lnk_url . '" title="'
122
+			  . esc_attr__('Edit Price Type', 'event_espresso') . '">'
123
+			  . stripslashes($item->name()) . '</a>'
124
+			: $item->name();
125
+
126
+		if ($item->base_type() !== 1) {
127
+			if ($this->_view == 'all') {
128
+				// trash price link
129
+				if (EE_Registry::instance()->CAP->current_user_can(
130
+					'ee_delete_default_price_type',
131
+					'pricing_trash_price_type',
132
+					$item->ID()
133
+				)) {
134
+					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
135
+						'action'   => 'trash_price_type',
136
+						'id'       => $item->ID(),
137
+						'noheader' => true,
138
+					), PRICING_ADMIN_URL);
139
+					$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
140
+										. esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
141
+										. __('Move to Trash', 'event_espresso') . '</a>';
142
+				}
143
+			} else {
144
+				// restore price link
145
+				if (EE_Registry::instance()->CAP->current_user_can(
146
+					'ee_delete_default_price_type',
147
+					'pricing_restore_price_type',
148
+					$item->ID()
149
+				)) {
150
+					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
151
+						'action'   => 'restore_price_type',
152
+						'id'       => $item->ID(),
153
+						'noheader' => true,
154
+					), PRICING_ADMIN_URL);
155
+					$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
156
+										  . esc_attr__('Restore Price Type', 'event_espresso') . '">'
157
+										  . __('Restore', 'event_espresso') . '</a>';
158
+				}
159
+				// delete price link
160
+				if (EE_Registry::instance()->CAP->current_user_can(
161
+					'ee_delete_default_price_type',
162
+					'pricing_delete_price_type',
163
+					$item->ID()
164
+				)) {
165
+					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
166
+						'action'   => 'delete_price_type',
167
+						'id'       => $item->ID(),
168
+						'noheader' => true,
169
+					), PRICING_ADMIN_URL);
170
+					$actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
171
+										 . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
172
+										 . __('Delete Permanently', 'event_espresso') . '</a>';
173
+				}
174
+			}
175
+		}
176
+
177
+		// Return the name contents
178
+		return sprintf(
179
+			'%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
180
+			$name_link,
181
+			$item->ID(),
182
+			$this->row_actions($actions)
183
+		);
184
+	}
185
+
186
+
187
+	public function column_base_type($item)
188
+	{
189
+		return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
190
+	}
191
+
192
+
193
+	public function column_percent($item)
194
+	{
195
+		return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
196
+	}
197
+
198
+
199
+	public function column_order($item)
200
+	{
201
+		return '<div class="jst-cntr">' . $item->order() . '</div>';
202
+	}
203 203
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function __construct($admin_page)
20 20
     {
21 21
         parent::__construct($admin_page);
22
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
22
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
23 23
         $this->_PRT = EEM_Price_Type::instance();
24 24
     }
25 25
 
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
         $this->_columns = array(
46 46
             'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
47 47
             'name'      => __('Name', 'event_espresso'),
48
-            'base_type' => '<div class="jst-cntr">' . __('Base Type', 'event_espresso') . '</div>',
49
-            'percent'   => '<div class="jst-cntr">' . __('Applied', 'event_espresso') . '<br/>'
50
-                           . __('as ', 'event_espresso') . '<span class="big-text">'
51
-                           . __('%', 'event_espresso') . '</span>'
52
-                           . __(' or ', 'event_espresso') . '<span class="big-text">'
53
-                           . __('$', 'event_espresso') . '</span></div>',
54
-            'order'     => '<div class="jst-cntr">' . __('Order of', 'event_espresso') . '<br/>'
55
-                           . __('Application', 'event_espresso') . '</div>',
48
+            'base_type' => '<div class="jst-cntr">'.__('Base Type', 'event_espresso').'</div>',
49
+            'percent'   => '<div class="jst-cntr">'.__('Applied', 'event_espresso').'<br/>'
50
+                           . __('as ', 'event_espresso').'<span class="big-text">'
51
+                           . __('%', 'event_espresso').'</span>'
52
+                           . __(' or ', 'event_espresso').'<span class="big-text">'
53
+                           . __('$', 'event_espresso').'</span></div>',
54
+            'order'     => '<div class="jst-cntr">'.__('Order of', 'event_espresso').'<br/>'
55
+                           . __('Application', 'event_espresso').'</div>',
56 56
         );
57 57
 
58 58
         $this->_sortable_columns = array(
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
                 'action' => 'edit_price_type',
109 109
                 'id'     => $item->ID(),
110 110
             ), PRICING_ADMIN_URL);
111
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
112
-                               . esc_attr__('Edit Price Type', 'event_espresso') . '">'
113
-                               . __('Edit', 'event_espresso') . '</a>';
111
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
112
+                               . esc_attr__('Edit Price Type', 'event_espresso').'">'
113
+                               . __('Edit', 'event_espresso').'</a>';
114 114
         }
115 115
 
116 116
         $name_link = EE_Registry::instance()->CAP->current_user_can(
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
             'pricing_edit_price_type',
119 119
             $item->ID()
120 120
         )
121
-            ? '<a href="' . $edit_lnk_url . '" title="'
122
-              . esc_attr__('Edit Price Type', 'event_espresso') . '">'
123
-              . stripslashes($item->name()) . '</a>'
121
+            ? '<a href="'.$edit_lnk_url.'" title="'
122
+              . esc_attr__('Edit Price Type', 'event_espresso').'">'
123
+              . stripslashes($item->name()).'</a>'
124 124
             : $item->name();
125 125
 
126 126
         if ($item->base_type() !== 1) {
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
                         'id'       => $item->ID(),
137 137
                         'noheader' => true,
138 138
                     ), PRICING_ADMIN_URL);
139
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
140
-                                        . esc_attr__('Move Price Type to Trash', 'event_espresso') . '">'
141
-                                        . __('Move to Trash', 'event_espresso') . '</a>';
139
+                    $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
140
+                                        . esc_attr__('Move Price Type to Trash', 'event_espresso').'">'
141
+                                        . __('Move to Trash', 'event_espresso').'</a>';
142 142
                 }
143 143
             } else {
144 144
                 // restore price link
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
                         'id'       => $item->ID(),
153 153
                         'noheader' => true,
154 154
                     ), PRICING_ADMIN_URL);
155
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
156
-                                          . esc_attr__('Restore Price Type', 'event_espresso') . '">'
157
-                                          . __('Restore', 'event_espresso') . '</a>';
155
+                    $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
156
+                                          . esc_attr__('Restore Price Type', 'event_espresso').'">'
157
+                                          . __('Restore', 'event_espresso').'</a>';
158 158
                 }
159 159
                 // delete price link
160 160
                 if (EE_Registry::instance()->CAP->current_user_can(
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
                         'id'       => $item->ID(),
168 168
                         'noheader' => true,
169 169
                     ), PRICING_ADMIN_URL);
170
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
171
-                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso') . '">'
172
-                                         . __('Delete Permanently', 'event_espresso') . '</a>';
170
+                    $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'
171
+                                         . esc_attr__('Delete Price Type Permanently', 'event_espresso').'">'
172
+                                         . __('Delete Permanently', 'event_espresso').'</a>';
173 173
                 }
174 174
             }
175 175
         }
@@ -186,18 +186,18 @@  discard block
 block discarded – undo
186 186
 
187 187
     public function column_base_type($item)
188 188
     {
189
-        return '<div class="jst-cntr">' . $item->base_type_name() . '</div>';
189
+        return '<div class="jst-cntr">'.$item->base_type_name().'</div>';
190 190
     }
191 191
 
192 192
 
193 193
     public function column_percent($item)
194 194
     {
195
-        return '<div class="jst-cntr">' . ($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign) . '</div>';
195
+        return '<div class="jst-cntr">'.($item->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign).'</div>';
196 196
     }
197 197
 
198 198
 
199 199
     public function column_order($item)
200 200
     {
201
-        return '<div class="jst-cntr">' . $item->order() . '</div>';
201
+        return '<div class="jst-cntr">'.$item->order().'</div>';
202 202
     }
203 203
 }
Please login to merge, or discard this patch.
caffeinated/admin/hooks/Global_EE_Caf_Hooks.class.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -15,42 +15,42 @@
 block discarded – undo
15 15
 class Global_EE_Caf_Hooks
16 16
 {
17 17
 
18
-    public function __construct()
19
-    {
20
-        $this->_do_hooks();
21
-    }
22
-
23
-
24
-    private function _do_hooks()
25
-    {
26
-        add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10);
27
-        add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10);
28
-        add_filter(
29
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
30
-            array($this, 'forums_lazy_loading'),
31
-            10
32
-        );
33
-        add_action(
34
-            'AHEE__EE_Admin_Page__espresso_news_post_box__after_content',
35
-            array($this, 'extra_news_box_content'),
36
-            10
37
-        );
38
-    }
39
-
40
-
41
-    public function extra_news_box_content($content)
42
-    {
43
-        echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>';
44
-        echo '<div id="ee_forum_posts_content">';
45
-        $url = 'http://eventespresso.com/forum/event-espresso-support/feed/';
46
-        EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url);
47
-        echo '</div>';
48
-    }
49
-
50
-
51
-    public function forums_lazy_loading($ids)
52
-    {
53
-        $ids[] = 'ee_forum_posts_content';
54
-        return $ids;
55
-    }
18
+	public function __construct()
19
+	{
20
+		$this->_do_hooks();
21
+	}
22
+
23
+
24
+	private function _do_hooks()
25
+	{
26
+		add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10);
27
+		add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10);
28
+		add_filter(
29
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
30
+			array($this, 'forums_lazy_loading'),
31
+			10
32
+		);
33
+		add_action(
34
+			'AHEE__EE_Admin_Page__espresso_news_post_box__after_content',
35
+			array($this, 'extra_news_box_content'),
36
+			10
37
+		);
38
+	}
39
+
40
+
41
+	public function extra_news_box_content($content)
42
+	{
43
+		echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>';
44
+		echo '<div id="ee_forum_posts_content">';
45
+		$url = 'http://eventespresso.com/forum/event-espresso-support/feed/';
46
+		EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url);
47
+		echo '</div>';
48
+	}
49
+
50
+
51
+	public function forums_lazy_loading($ids)
52
+	{
53
+		$ids[] = 'ee_forum_posts_content';
54
+		return $ids;
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
     public function extra_news_box_content($content)
42 42
     {
43
-        echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>';
43
+        echo '<h3 style="margin:0">'.__('From the Forums', 'event_espresso').'</h3>';
44 44
         echo '<div id="ee_forum_posts_content">';
45 45
         $url = 'http://eventespresso.com/forum/event-espresso-support/feed/';
46 46
         EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url);
Please login to merge, or discard this patch.
espresso.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
+    if ( ! function_exists('espresso_duplicate_plugin_error')) {
42 42
         /**
43 43
          *    espresso_duplicate_plugin_error
44 44
          *    displays if more than one version of EE is activated at the same time
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64 64
     define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66 66
         /**
67 67
          * espresso_minimum_php_version_error
68 68
          *
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 
117 117
         register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
119
+        require_once __DIR__.'/core/bootstrap_espresso.php';
120 120
         bootstrap_espresso();
121 121
     }
122 122
 }
123
-if (! function_exists('espresso_deactivate_plugin')) {
123
+if ( ! function_exists('espresso_deactivate_plugin')) {
124 124
     /**
125 125
      *    deactivate_plugin
126 126
      * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      */
132 132
     function espresso_deactivate_plugin($plugin_basename = '')
133 133
     {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
134
+        if ( ! function_exists('deactivate_plugins')) {
135
+            require_once ABSPATH.'wp-admin/includes/plugin.php';
136 136
         }
137 137
         unset($_GET['activate'], $_REQUEST['activate']);
138 138
         deactivate_plugins($plugin_basename);
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.037');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.66.rc.037');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
caffeinated/EE_Caf_Messages.class.php 2 patches
Indentation   +799 added lines, -799 removed lines patch added patch discarded remove patch
@@ -13,803 +13,803 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * constructor.
18
-     */
19
-    public function __construct()
20
-    {
21
-        $this->_caf_hooks();
22
-    }
23
-
24
-
25
-    /**
26
-     * Contains all the hooks filters for setting up caffeinated messages functionality.
27
-     *
28
-     * @since 4.3.2
29
-     *
30
-     * @return void
31
-     */
32
-    private function _caf_hooks()
33
-    {
34
-        add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
35
-        add_filter(
36
-            'FHEE__EE_Email_messenger__get_validator_config',
37
-            array($this, 'email_messenger_validator_config'),
38
-            5,
39
-            2
40
-        );
41
-        add_filter(
42
-            'FHEE__EE_Email_messenger__get_template_fields',
43
-            array($this, 'email_messenger_template_fields'),
44
-            5,
45
-            2
46
-        );
47
-        add_filter(
48
-            'FHEE__EE_Html_messenger__get_template_fields',
49
-            array($this, 'html_messenger_template_fields'),
50
-            5,
51
-            2
52
-        );
53
-        add_filter(
54
-            'FHEE__EE_Html_messenger__get_validator_config',
55
-            array($this, 'html_messenger_validator_config'),
56
-            5,
57
-            2
58
-        );
59
-        add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
60
-        add_filter(
61
-            'FHEE__EE_Pdf_messenger__get_validator_config',
62
-            array($this, 'pdf_messenger_validator_config'),
63
-            5,
64
-            2
65
-        );
66
-        add_filter(
67
-            'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
68
-            array($this, 'new_default_templates'),
69
-            5,
70
-            7
71
-        );
72
-        add_filter(
73
-            'FHEE__EE_Messages_Base__get_valid_shortcodes',
74
-            array($this, 'message_types_valid_shortcodes'),
75
-            5,
76
-            2
77
-        );
78
-
79
-        // shortcode parsers
80
-        add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
81
-        add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
82
-        add_filter(
83
-            'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
84
-            array($this, 'additional_recipient_details_shortcodes'),
85
-            5,
86
-            2
87
-        );
88
-        add_filter(
89
-            'FHEE__EE_Recipient_List_Shortcodes__parser_after',
90
-            array($this, 'additional_recipient_details_parser'),
91
-            5,
92
-            5
93
-        );
94
-        add_filter(
95
-            'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
96
-            array($this, 'additional_primary_registration_details_shortcodes'),
97
-            5,
98
-            2
99
-        );
100
-        add_filter(
101
-            'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
102
-            array($this, 'additional_primary_registration_details_parser'),
103
-            5,
104
-            5
105
-        );
106
-
107
-        /**
108
-         * @since 4.2.0
109
-         */
110
-        add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
111
-        add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
112
-
113
-        /**
114
-         * @since 4.3.0
115
-         */
116
-        // eat our own dog food!
117
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
118
-        add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
119
-        do_action('EE_Brewing_Regular___messages_caf');
120
-    }
121
-
122
-
123
-    /**
124
-     * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
125
-     * messages system.
126
-     *
127
-     * @param  array $dir_ref original array of paths
128
-     *
129
-     * @return array           appended paths
130
-     */
131
-    public function messages_autoload_paths($dir_ref)
132
-    {
133
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
134
-
135
-        return $dir_ref;
136
-    }
137
-
138
-
139
-    public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
140
-    {
141
-        $validator_config['attendee_list'] = array(
142
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
143
-            'required'   => array('[ATTENDEE_LIST]'),
144
-        );
145
-        $validator_config['question_list'] = array(
146
-            'shortcodes' => array('question'),
147
-            'required'   => array('[QUESTION_LIST]'),
148
-        );
149
-
150
-        return $validator_config;
151
-    }
152
-
153
-
154
-    public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
155
-    {
156
-        $validator_config['attendee_list'] = array(
157
-            'shortcodes' => array('attendee', 'question_list'),
158
-            'required'   => array('[ATTENDEE_LIST]'),
159
-        );
160
-        $validator_config['question_list'] = array(
161
-            'shortcodes' => array('question'),
162
-            'required'   => array('[QUESTION_LIST]'),
163
-        );
164
-
165
-        return $validator_config;
166
-    }
167
-
168
-
169
-    public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
170
-    {
171
-        $validator_config['attendee_list'] = array(
172
-            'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
173
-            'required'   => array('[ATTENDEE_LIST]'),
174
-        );
175
-        $validator_config['question_list'] = array(
176
-            'shortcodes' => array('question'),
177
-            'required'   => array('[QUESTION_LIST]'),
178
-        );
179
-
180
-        return $validator_config;
181
-    }
182
-
183
-
184
-    public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
185
-    {
186
-        $template_fields['extra']['content']['question_list'] = array(
187
-            'input'               => 'textarea',
188
-            'label'               => '[QUESTION_LIST]',
189
-            'type'                => 'string',
190
-            'required'            => true,
191
-            'validation'          => true,
192
-            'format'              => '%s',
193
-            'css_class'           => 'large-text',
194
-            'rows'                => '5',
195
-            'shortcodes_required' => array('[QUESTION_LIST]'),
196
-        );
197
-
198
-        return $template_fields;
199
-    }
200
-
201
-
202
-    public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
203
-    {
204
-        $template_fields['extra']['content']['question_list'] = array(
205
-            'input'               => 'textarea',
206
-            'label'               => '[QUESTION_LIST]',
207
-            'type'                => 'string',
208
-            'required'            => true,
209
-            'validation'          => true,
210
-            'format'              => '%s',
211
-            'css_class'           => 'large-text',
212
-            'rows'                => '5',
213
-            'shortcodes_required' => array('[QUESTION_LIST]'),
214
-        );
215
-
216
-        return $template_fields;
217
-    }
218
-
219
-
220
-    public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
221
-    {
222
-        $template_fields['extra']['content']['question_list'] = array(
223
-            'input'               => 'textarea',
224
-            'label'               => '[QUESTION_LIST]',
225
-            'type'                => 'string',
226
-            'required'            => true,
227
-            'validation'          => true,
228
-            'format'              => '%s',
229
-            'css_class'           => 'large-text',
230
-            'rows'                => '5',
231
-            'shortcodes_required' => array('[QUESTION_LIST]'),
232
-        );
233
-
234
-        return $template_fields;
235
-    }
236
-
237
-
238
-    public function new_default_templates(
239
-        $contents,
240
-        $actual_path,
241
-        EE_messenger $messenger,
242
-        EE_message_type $message_type,
243
-        $field,
244
-        $context,
245
-        EE_Messages_Template_Pack $template_pack
246
-    ) {
247
-
248
-        // we're only modifying templates for the default template pack
249
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250
-            return $contents;
251
-        }
252
-
253
-        // the template file name we're replacing contents for.
254
-        $template_file_prefix = $field . '_' . $context;
255
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
256
-
257
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
258
-
259
-        if ($messenger->name == 'email' && $message_type->name == 'registration') {
260
-            switch ($template_file_prefix) {
261
-                case 'question_list_admin':
262
-                case 'question_list_attendee':
263
-                case 'question_list_primary_attendee':
264
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
265
-                    $contents = EEH_Template::display_template($path, array(), true);
266
-                    break;
267
-
268
-                case 'attendee_list_primary_attendee':
269
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
270
-                    $contents = EEH_Template::display_template($path, array(), true);
271
-                    break;
272
-
273
-                case 'attendee_list_admin':
274
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
275
-                    $contents = EEH_Template::display_template(
276
-                        $path,
277
-                        array(),
278
-                        true
279
-                    );
280
-                    break;
281
-
282
-                case 'attendee_list_attendee':
283
-                    $contents = '';
284
-                    break;
285
-
286
-                case 'event_list_attendee':
287
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
288
-                    $contents = EEH_Template::display_template($path, array(), true);
289
-                    break;
290
-            }
291
-        } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292
-            switch ($template_file_prefix) {
293
-                case 'content_attendee':
294
-                    $path = $base_path . $msg_prefix . 'content.template.php';
295
-                    $contents = EEH_Template::display_template($path, array(), true);
296
-                    break;
297
-
298
-                case 'newsletter_content_attendee':
299
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
300
-                    $contents = EEH_Template::display_template($path, array(), true);
301
-                    break;
302
-
303
-                case 'newsletter_subject_attendee':
304
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
305
-                    $contents = EEH_Template::display_template($path, array(), true);
306
-                    break;
307
-            }
308
-        } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309
-            switch ($template_file_prefix) {
310
-                case 'attendee_list_purchaser':
311
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
312
-                    $contents = EEH_Template::display_template($path, array(), true);
313
-                    break;
314
-            }
315
-        }
316
-
317
-        return $contents;
318
-    }
319
-
320
-
321
-    public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
322
-    {
323
-        // make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
324
-        $include_with = array(
325
-            'registration',
326
-            'cancelled_registration',
327
-            'declined_registration',
328
-            'not_approved_registration',
329
-            'payment_declined',
330
-            'payment_failed',
331
-            'payment_cancelled',
332
-            'payment',
333
-            'payment_reminder',
334
-            'pending_approval',
335
-            'registration_summary',
336
-            'invoice',
337
-            'receipt',
338
-        );
339
-        if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340
-            $contexts = array_keys($msg->get_contexts());
341
-            foreach ($contexts as $context) {
342
-                $valid_shortcodes[ $context ][] = 'question_list';
343
-                $valid_shortcodes[ $context ][] = 'question';
344
-            }
345
-        }
346
-
347
-        return $valid_shortcodes;
348
-    }
349
-
350
-
351
-    public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
352
-    {
353
-        $shortcodes['[ANSWER_*]'] = __(
354
-            'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
355
-            'event_espresso'
356
-        );
357
-
358
-        return $shortcodes;
359
-    }
360
-
361
-
362
-    public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
363
-    {
364
-
365
-        if (strpos($shortcode, '[ANSWER_*') === false
366
-            || ! isset($extra_data['data']->questions)
367
-            || ! isset($extra_data['data']->registrations)
368
-        ) {
369
-            return $parsed;
370
-        }
371
-
372
-        // let's get the question from the code.
373
-        $shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
-        $shortcode = trim(str_replace(']', '', $shortcode));
375
-
376
-        $registration = $data instanceof EE_Registration ? $data : null;
377
-        $registration = ! $registration instanceof EE_Registration && is_array(
378
-            $extra_data
379
-        ) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
-
381
-        $aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
-            $extra_data
384
-        ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
-
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
-            return $parsed;
388
-        }
389
-
390
-        // now let's figure out which question has this text.
391
-        foreach ($aee->questions as $ansid => $question) {
392
-            if ($question instanceof EE_Question
393
-                && trim($question->display_text()) == trim($shortcode)
394
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
395
-            ) {
396
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
397
-                    'ANS_value',
398
-                    'no_wpautop'
399
-                );
400
-            }
401
-        }
402
-
403
-        // nothing!
404
-        return $parsed;
405
-    }
406
-
407
-
408
-    /**
409
-     * Callback for additional shortcodes filter for adding additional datetime shortcodes.
410
-     *
411
-     * @since  4.2
412
-     *
413
-     * @param  array                  $shortcodes         array of shortcodes and
414
-     *                                                    descriptions
415
-     * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
416
-     *
417
-     * @return array                                        array of shortcodes and
418
-     *                                                        descriptions
419
-     */
420
-    public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
421
-    {
422
-        $shortcodes['[DTT_NAME]'] = __(
423
-            'This will be parsed to the Title given for a Datetime',
424
-            'event_espresso'
425
-        );
426
-        $shortcodes['[DTT_DESCRIPTION]'] = __(
427
-            'This will be parsed to the description for a Datetime',
428
-            'event_espresso'
429
-        );
430
-        $shortcodes['[DTT_NAME_OR_DATES]'] = __(
431
-            'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
432
-            'event_espresso'
433
-        );
434
-
435
-        return $shortcodes;
436
-    }
437
-
438
-
439
-    /**
440
-     * Callback for additional shortcodes parser filter used for adding parser for new
441
-     * Datetime shortcodes
442
-     *
443
-     * @since  4.2
444
-     *
445
-     * @param  string                 $parsed     The finished parsed string for the given shortcode.
446
-     * @param  string                 $shortcode  The shortcode being parsed.
447
-     * @param  object                 $data       The incoming data object for the Shortcode Parser.
448
-     * @param  object                 $extra_data The incoming extra date object for the Shortcode
449
-     *                                            Parser.
450
-     * @param  EE_Datetime_Shortcodes $shortcode_parser
451
-     *
452
-     * @return string                   The new parsed string.
453
-     */
454
-    public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455
-    {
456
-
457
-        if (! $data instanceof EE_Datetime) {
458
-            return ''; // get out because we can only parse with the datetime object.
459
-        }
460
-
461
-        switch ($shortcode) {
462
-            case '[DTT_NAME]':
463
-                return $data->name();
464
-                break;
465
-            case '[DTT_DESCRIPTION]':
466
-                return $data->description();
467
-                break;
468
-            case '[DTT_NAME_OR_DATES]':
469
-                return $data->get_dtt_display_name(true);
470
-                break;
471
-            default:
472
-                return $parsed;
473
-                break;
474
-        }
475
-    }
476
-
477
-
478
-    public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
479
-    {
480
-        $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __(
481
-            'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
482
-            'event_espresso'
483
-        );
484
-
485
-        return $shortcodes;
486
-    }
487
-
488
-
489
-    /**
490
-     * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
491
-     *
492
-     * @param string         $parsed           The original parsed content for the shortcode
493
-     * @param string         $shortcode        The shortcode being parsed
494
-     * @param array          $data             The shortcode parser data array
495
-     * @param array          $extra_data       The shortcode parser extra data array
496
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
497
-     *
498
-     * @return string
499
-     */
500
-    public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
501
-    {
502
-
503
-        if (array($data) && ! isset($data['data'])) {
504
-            return $parsed;
505
-        }
506
-
507
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509
-
510
-        if (! $recipient instanceof EE_Messages_Addressee) {
511
-            return $parsed;
512
-        }
513
-
514
-        switch ($shortcode) {
515
-            case '[RECIPIENT_QUESTION_LIST]':
516
-                $att = $recipient->att_obj;
517
-                $registrations_on_attendee = $att instanceof EE_Attendee
518
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
519
-                    : array();
520
-                $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521
-                $answers = array();
522
-
523
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
524
-                    ? $data['template']['question_list']
525
-                    : $extra_data['template']['question_list'];
526
-                $valid_shortcodes = array('question');
527
-
528
-                // if the context is main_content then get all answers for all registrations on this attendee
529
-                if ($data['data'] instanceof EE_Messages_Addressee) {
530
-                    foreach ($registrations_on_attendee as $reg) {
531
-                        if ($reg instanceof EE_Registration) {
532
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
534
-                                : array();
535
-                            foreach ($anss as $ans) {
536
-                                if ($ans instanceof EE_Answer) {
537
-                                    $answers[ $ans->ID() ] = $ans;
538
-                                }
539
-                            }
540
-                        }
541
-                    }
542
-                }
543
-
544
-                // if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
545
-                if ($data['data'] instanceof EE_Event) {
546
-                    $event = $data['data'];
547
-                    foreach ($registrations_on_attendee as $reg) {
548
-                        if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
551
-                                : array();
552
-                            foreach ($anss as $ans) {
553
-                                if ($ans instanceof EE_Answer) {
554
-                                    $answers[ $ans->ID() ] = $ans;
555
-                                }
556
-                            }
557
-                        }
558
-                    }
559
-                }
560
-
561
-                $questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
562
-
563
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564
-                // object on it.
565
-                if (! isset($extra_data['data'])) {
566
-                    $extra_data['data'] = $recipient;
567
-                }
568
-
569
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
570
-                    $shortcode_parser,
571
-                    $questions,
572
-                    $answers,
573
-                    $template,
574
-                    $valid_shortcodes,
575
-                    $extra_data
576
-                );
577
-                break;
578
-
579
-            default:
580
-                return $parsed;
581
-                break;
582
-        }
583
-    }
584
-
585
-
586
-    public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
587
-    {
588
-        $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __(
589
-            'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
590
-            'event_espresso'
591
-        );
592
-
593
-        return $shortcodes;
594
-    }
595
-
596
-
597
-    /**
598
-     * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
599
-     *
600
-     * @param string         $parsed           The original parsed content for the shortcode
601
-     * @param string         $shortcode        The shortcode being parsed
602
-     * @param array          $data             The shortcode parser data array
603
-     * @param array          $extra_data       The shortcode parser extra data array
604
-     * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
605
-     *
606
-     * @return string
607
-     */
608
-    public function additional_primary_registration_details_parser(
609
-        $parsed,
610
-        $shortcode,
611
-        $data,
612
-        $extra_data,
613
-        $shortcode_parser
614
-    ) {
615
-        if (array($data) && ! isset($data['data'])) {
616
-            return $parsed;
617
-        }
618
-
619
-        $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621
-
622
-        if (! $recipient instanceof EE_Messages_Addressee) {
623
-            return $parsed;
624
-        }
625
-
626
-        switch ($shortcode) {
627
-            case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629
-                    return '';
630
-                }
631
-                $registration = $recipient->primary_reg_obj;
632
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
634
-                    : array();
635
-                if (empty($answers)) {
636
-                    return '';
637
-                }
638
-                $template = is_array($data['template']) && isset($data['template']['question_list'])
639
-                    ? $data['template']['question_list']
640
-                    : $extra_data['template']['question_list'];
641
-                $valid_shortcodes = array('question');
642
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
643
-                $questions = isset($recipient->questions) ? $recipient->questions : array();
644
-                // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645
-                // object on it.
646
-                if (! isset($extra_data['data'])) {
647
-                    $extra_data['data'] = $recipient;
648
-                }
649
-                return $this->_parse_question_list_for_primary_or_recipient_registration(
650
-                    $shortcode_parser,
651
-                    $questions,
652
-                    $answers,
653
-                    $template,
654
-                    $valid_shortcodes,
655
-                    $extra_data
656
-                );
657
-                break;
658
-
659
-            default:
660
-                return $parsed;
661
-                break;
662
-        }
663
-    }
664
-
665
-
666
-    /**
667
-     * Takes care of registering the  message types that are only available in caffeinated EE.
668
-     *
669
-     * @since   4.3.2
670
-     *
671
-     * @return  void
672
-     */
673
-    public function register_caf_message_types()
674
-    {
675
-        // register newsletter message type
676
-        $setup_args = array(
677
-            'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678
-            'autoloadpaths'                                    => array(
679
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
680
-            ),
681
-            'messengers_to_activate_with'                      => array('email'),
682
-            'messengers_to_validate_with'                      => array('email'),
683
-            'messengers_supporting_default_template_pack_with' => array('email'),
684
-        );
685
-        EE_Register_Message_Type::register('newsletter', $setup_args);
686
-
687
-        // register payment reminder message type
688
-        $setup_args = array(
689
-            'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
691
-            'messengers_to_activate_with'                      => array('email'),
692
-            'messengers_to_validate_with'                      => array('email'),
693
-            'messengers_supporting_default_template_pack_with' => array('email'),
694
-        );
695
-        EE_Register_Message_Type::register('payment_reminder', $setup_args);
696
-
697
-        // register payment declined message type
698
-        $setup_args = array(
699
-            'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
701
-            'messengers_to_activate_with'                      => array('email'),
702
-            'messengers_to_validate_with'                      => array('email'),
703
-            'messengers_supporting_default_template_pack_with' => array('email'),
704
-        );
705
-        EE_Register_Message_Type::register('payment_declined', $setup_args);
706
-
707
-        // register registration declined message type
708
-        $setup_args = array(
709
-            'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
711
-            'messengers_to_activate_with'                      => array('email'),
712
-            'messengers_to_validate_with'                      => array('email'),
713
-            'messengers_supporting_default_template_pack_with' => array('email'),
714
-        );
715
-        EE_Register_Message_Type::register('declined_registration', $setup_args);
716
-
717
-        // register registration cancelled message type
718
-        $setup_args = array(
719
-            'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
721
-            'messengers_to_activate_with'                      => array('email'),
722
-            'messengers_to_validate_with'                      => array('email'),
723
-            'messengers_supporting_default_template_pack_with' => array('email'),
724
-        );
725
-        EE_Register_Message_Type::register('cancelled_registration', $setup_args);
726
-
727
-
728
-        // register payment failed message type
729
-        $setup_args = array(
730
-            'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
732
-            'messengers_to_activate_with'                      => array('email'),
733
-            'messengers_to_validate_with'                      => array('email'),
734
-            'messengers_supporting_default_template_pack_with' => array('email'),
735
-        );
736
-        EE_Register_Message_Type::register('payment_failed', $setup_args);
737
-
738
-        // register payment declined message type
739
-        $setup_args = array(
740
-            'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
742
-            'messengers_to_activate_with'                      => array('email'),
743
-            'messengers_to_validate_with'                      => array('email'),
744
-            'messengers_supporting_default_template_pack_with' => array('email'),
745
-        );
746
-        EE_Register_Message_Type::register('payment_cancelled', $setup_args);
747
-    }
748
-
749
-
750
-    /**
751
-     * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
752
-     *
753
-     * @since   4.3.2
754
-     *
755
-     * @return void
756
-     */
757
-    public function register_caf_shortcodes()
758
-    {
759
-        $setup_args = array(
760
-            'autoloadpaths'                 => array(
761
-                EE_CAF_LIBRARIES . 'shortcodes/',
762
-            ),
763
-            'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764
-            'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
765
-            'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
766
-        );
767
-        EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
768
-    }
769
-
770
-
771
-    /**
772
-     * Parses a question list shortcode using given data and template
773
-     *
774
-     * @param \EE_Shortcodes $shortcode_parser
775
-     * @param EE_Question[]  $questions        An array of questions indexed by answer id.
776
-     * @param EE_Answer[]    $answers          An array of answer objects
777
-     * @param string         $template         Template content to be parsed.
778
-     * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
779
-     * @param array          $extra_data       Extra data that might be used when parsing the template.
780
-     */
781
-    protected function _parse_question_list_for_primary_or_recipient_registration(
782
-        $shortcode_parser,
783
-        $questions,
784
-        $answers,
785
-        $template,
786
-        $valid_shortcodes,
787
-        $extra_data
788
-    ) {
789
-        $question_list = '';
790
-        /** @var EEH_Parse_Shortcodes $shortcode_helper */
791
-        $shortcode_helper = $shortcode_parser->get_shortcode_helper();
792
-        foreach ($answers as $answer) {
793
-            if ($answer instanceof EE_Answer) {
794
-                // first see if the question is in our $questions array. If not then try to get from answer object.
795
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
796
-                $question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
-                if (! $question instanceof EE_Question
798
-                    || (
799
-                        $question instanceof EE_Question
800
-                        && $question->admin_only()
801
-                    )
802
-                ) {
803
-                    continue;
804
-                }
805
-                $question_list .= $shortcode_helper->parse_question_list_template(
806
-                    $template,
807
-                    $answer,
808
-                    $valid_shortcodes,
809
-                    $extra_data
810
-                );
811
-            }
812
-        }
813
-        return $question_list;
814
-    }
16
+	/**
17
+	 * constructor.
18
+	 */
19
+	public function __construct()
20
+	{
21
+		$this->_caf_hooks();
22
+	}
23
+
24
+
25
+	/**
26
+	 * Contains all the hooks filters for setting up caffeinated messages functionality.
27
+	 *
28
+	 * @since 4.3.2
29
+	 *
30
+	 * @return void
31
+	 */
32
+	private function _caf_hooks()
33
+	{
34
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5);
35
+		add_filter(
36
+			'FHEE__EE_Email_messenger__get_validator_config',
37
+			array($this, 'email_messenger_validator_config'),
38
+			5,
39
+			2
40
+		);
41
+		add_filter(
42
+			'FHEE__EE_Email_messenger__get_template_fields',
43
+			array($this, 'email_messenger_template_fields'),
44
+			5,
45
+			2
46
+		);
47
+		add_filter(
48
+			'FHEE__EE_Html_messenger__get_template_fields',
49
+			array($this, 'html_messenger_template_fields'),
50
+			5,
51
+			2
52
+		);
53
+		add_filter(
54
+			'FHEE__EE_Html_messenger__get_validator_config',
55
+			array($this, 'html_messenger_validator_config'),
56
+			5,
57
+			2
58
+		);
59
+		add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2);
60
+		add_filter(
61
+			'FHEE__EE_Pdf_messenger__get_validator_config',
62
+			array($this, 'pdf_messenger_validator_config'),
63
+			5,
64
+			2
65
+		);
66
+		add_filter(
67
+			'FHEE__EE_Messages_Template_Pack__get_specific_template__contents',
68
+			array($this, 'new_default_templates'),
69
+			5,
70
+			7
71
+		);
72
+		add_filter(
73
+			'FHEE__EE_Messages_Base__get_valid_shortcodes',
74
+			array($this, 'message_types_valid_shortcodes'),
75
+			5,
76
+			2
77
+		);
78
+
79
+		// shortcode parsers
80
+		add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2);
81
+		add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5);
82
+		add_filter(
83
+			'FHEE__EE_Recipient_List_Shortcodes__shortcodes',
84
+			array($this, 'additional_recipient_details_shortcodes'),
85
+			5,
86
+			2
87
+		);
88
+		add_filter(
89
+			'FHEE__EE_Recipient_List_Shortcodes__parser_after',
90
+			array($this, 'additional_recipient_details_parser'),
91
+			5,
92
+			5
93
+		);
94
+		add_filter(
95
+			'FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes',
96
+			array($this, 'additional_primary_registration_details_shortcodes'),
97
+			5,
98
+			2
99
+		);
100
+		add_filter(
101
+			'FHEE__EE_Primary_Registration_List_Shortcodes__parser_after',
102
+			array($this, 'additional_primary_registration_details_parser'),
103
+			5,
104
+			5
105
+		);
106
+
107
+		/**
108
+		 * @since 4.2.0
109
+		 */
110
+		add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2);
111
+		add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5);
112
+
113
+		/**
114
+		 * @since 4.3.0
115
+		 */
116
+		// eat our own dog food!
117
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types'));
118
+		add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes'));
119
+		do_action('EE_Brewing_Regular___messages_caf');
120
+	}
121
+
122
+
123
+	/**
124
+	 * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the
125
+	 * messages system.
126
+	 *
127
+	 * @param  array $dir_ref original array of paths
128
+	 *
129
+	 * @return array           appended paths
130
+	 */
131
+	public function messages_autoload_paths($dir_ref)
132
+	{
133
+		$dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
134
+
135
+		return $dir_ref;
136
+	}
137
+
138
+
139
+	public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger)
140
+	{
141
+		$validator_config['attendee_list'] = array(
142
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
143
+			'required'   => array('[ATTENDEE_LIST]'),
144
+		);
145
+		$validator_config['question_list'] = array(
146
+			'shortcodes' => array('question'),
147
+			'required'   => array('[QUESTION_LIST]'),
148
+		);
149
+
150
+		return $validator_config;
151
+	}
152
+
153
+
154
+	public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger)
155
+	{
156
+		$validator_config['attendee_list'] = array(
157
+			'shortcodes' => array('attendee', 'question_list'),
158
+			'required'   => array('[ATTENDEE_LIST]'),
159
+		);
160
+		$validator_config['question_list'] = array(
161
+			'shortcodes' => array('question'),
162
+			'required'   => array('[QUESTION_LIST]'),
163
+		);
164
+
165
+		return $validator_config;
166
+	}
167
+
168
+
169
+	public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger)
170
+	{
171
+		$validator_config['attendee_list'] = array(
172
+			'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'),
173
+			'required'   => array('[ATTENDEE_LIST]'),
174
+		);
175
+		$validator_config['question_list'] = array(
176
+			'shortcodes' => array('question'),
177
+			'required'   => array('[QUESTION_LIST]'),
178
+		);
179
+
180
+		return $validator_config;
181
+	}
182
+
183
+
184
+	public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger)
185
+	{
186
+		$template_fields['extra']['content']['question_list'] = array(
187
+			'input'               => 'textarea',
188
+			'label'               => '[QUESTION_LIST]',
189
+			'type'                => 'string',
190
+			'required'            => true,
191
+			'validation'          => true,
192
+			'format'              => '%s',
193
+			'css_class'           => 'large-text',
194
+			'rows'                => '5',
195
+			'shortcodes_required' => array('[QUESTION_LIST]'),
196
+		);
197
+
198
+		return $template_fields;
199
+	}
200
+
201
+
202
+	public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger)
203
+	{
204
+		$template_fields['extra']['content']['question_list'] = array(
205
+			'input'               => 'textarea',
206
+			'label'               => '[QUESTION_LIST]',
207
+			'type'                => 'string',
208
+			'required'            => true,
209
+			'validation'          => true,
210
+			'format'              => '%s',
211
+			'css_class'           => 'large-text',
212
+			'rows'                => '5',
213
+			'shortcodes_required' => array('[QUESTION_LIST]'),
214
+		);
215
+
216
+		return $template_fields;
217
+	}
218
+
219
+
220
+	public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger)
221
+	{
222
+		$template_fields['extra']['content']['question_list'] = array(
223
+			'input'               => 'textarea',
224
+			'label'               => '[QUESTION_LIST]',
225
+			'type'                => 'string',
226
+			'required'            => true,
227
+			'validation'          => true,
228
+			'format'              => '%s',
229
+			'css_class'           => 'large-text',
230
+			'rows'                => '5',
231
+			'shortcodes_required' => array('[QUESTION_LIST]'),
232
+		);
233
+
234
+		return $template_fields;
235
+	}
236
+
237
+
238
+	public function new_default_templates(
239
+		$contents,
240
+		$actual_path,
241
+		EE_messenger $messenger,
242
+		EE_message_type $message_type,
243
+		$field,
244
+		$context,
245
+		EE_Messages_Template_Pack $template_pack
246
+	) {
247
+
248
+		// we're only modifying templates for the default template pack
249
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250
+			return $contents;
251
+		}
252
+
253
+		// the template file name we're replacing contents for.
254
+		$template_file_prefix = $field . '_' . $context;
255
+		$msg_prefix = $messenger->name . '_' . $message_type->name . '_';
256
+
257
+		$base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
258
+
259
+		if ($messenger->name == 'email' && $message_type->name == 'registration') {
260
+			switch ($template_file_prefix) {
261
+				case 'question_list_admin':
262
+				case 'question_list_attendee':
263
+				case 'question_list_primary_attendee':
264
+					$path = $base_path . $msg_prefix . 'question_list.template.php';
265
+					$contents = EEH_Template::display_template($path, array(), true);
266
+					break;
267
+
268
+				case 'attendee_list_primary_attendee':
269
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
270
+					$contents = EEH_Template::display_template($path, array(), true);
271
+					break;
272
+
273
+				case 'attendee_list_admin':
274
+					$path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
275
+					$contents = EEH_Template::display_template(
276
+						$path,
277
+						array(),
278
+						true
279
+					);
280
+					break;
281
+
282
+				case 'attendee_list_attendee':
283
+					$contents = '';
284
+					break;
285
+
286
+				case 'event_list_attendee':
287
+					$path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
288
+					$contents = EEH_Template::display_template($path, array(), true);
289
+					break;
290
+			}
291
+		} elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292
+			switch ($template_file_prefix) {
293
+				case 'content_attendee':
294
+					$path = $base_path . $msg_prefix . 'content.template.php';
295
+					$contents = EEH_Template::display_template($path, array(), true);
296
+					break;
297
+
298
+				case 'newsletter_content_attendee':
299
+					$path = $base_path . $msg_prefix . 'newsletter_content.template.php';
300
+					$contents = EEH_Template::display_template($path, array(), true);
301
+					break;
302
+
303
+				case 'newsletter_subject_attendee':
304
+					$path = $base_path . $msg_prefix . 'subject.template.php';
305
+					$contents = EEH_Template::display_template($path, array(), true);
306
+					break;
307
+			}
308
+		} elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309
+			switch ($template_file_prefix) {
310
+				case 'attendee_list_purchaser':
311
+					$path = $base_path . $msg_prefix . 'attendee_list.template.php';
312
+					$contents = EEH_Template::display_template($path, array(), true);
313
+					break;
314
+			}
315
+		}
316
+
317
+		return $contents;
318
+	}
319
+
320
+
321
+	public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg)
322
+	{
323
+		// make sure question_list and question are ONLY added for the core message types.  Any other message types will have to explicitly set question_list as a valid shortcode.
324
+		$include_with = array(
325
+			'registration',
326
+			'cancelled_registration',
327
+			'declined_registration',
328
+			'not_approved_registration',
329
+			'payment_declined',
330
+			'payment_failed',
331
+			'payment_cancelled',
332
+			'payment',
333
+			'payment_reminder',
334
+			'pending_approval',
335
+			'registration_summary',
336
+			'invoice',
337
+			'receipt',
338
+		);
339
+		if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340
+			$contexts = array_keys($msg->get_contexts());
341
+			foreach ($contexts as $context) {
342
+				$valid_shortcodes[ $context ][] = 'question_list';
343
+				$valid_shortcodes[ $context ][] = 'question';
344
+			}
345
+		}
346
+
347
+		return $valid_shortcodes;
348
+	}
349
+
350
+
351
+	public function additional_attendee_shortcodes($shortcodes, $shortcode_parser)
352
+	{
353
+		$shortcodes['[ANSWER_*]'] = __(
354
+			'This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.',
355
+			'event_espresso'
356
+		);
357
+
358
+		return $shortcodes;
359
+	}
360
+
361
+
362
+	public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
363
+	{
364
+
365
+		if (strpos($shortcode, '[ANSWER_*') === false
366
+			|| ! isset($extra_data['data']->questions)
367
+			|| ! isset($extra_data['data']->registrations)
368
+		) {
369
+			return $parsed;
370
+		}
371
+
372
+		// let's get the question from the code.
373
+		$shortcode = str_replace('[ANSWER_*', '', $shortcode);
374
+		$shortcode = trim(str_replace(']', '', $shortcode));
375
+
376
+		$registration = $data instanceof EE_Registration ? $data : null;
377
+		$registration = ! $registration instanceof EE_Registration && is_array(
378
+			$extra_data
379
+		) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration;
380
+
381
+		$aee = $data instanceof EE_Messages_Addressee ? $data : null;
382
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array(
383
+			$extra_data
384
+		) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385
+
386
+		if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387
+			return $parsed;
388
+		}
389
+
390
+		// now let's figure out which question has this text.
391
+		foreach ($aee->questions as $ansid => $question) {
392
+			if ($question instanceof EE_Question
393
+				&& trim($question->display_text()) == trim($shortcode)
394
+				&& isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
395
+			) {
396
+				return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
397
+					'ANS_value',
398
+					'no_wpautop'
399
+				);
400
+			}
401
+		}
402
+
403
+		// nothing!
404
+		return $parsed;
405
+	}
406
+
407
+
408
+	/**
409
+	 * Callback for additional shortcodes filter for adding additional datetime shortcodes.
410
+	 *
411
+	 * @since  4.2
412
+	 *
413
+	 * @param  array                  $shortcodes         array of shortcodes and
414
+	 *                                                    descriptions
415
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser   EE_Shortcodes object
416
+	 *
417
+	 * @return array                                        array of shortcodes and
418
+	 *                                                        descriptions
419
+	 */
420
+	public function additional_datetime_shortcodes($shortcodes, $shortcode_parser)
421
+	{
422
+		$shortcodes['[DTT_NAME]'] = __(
423
+			'This will be parsed to the Title given for a Datetime',
424
+			'event_espresso'
425
+		);
426
+		$shortcodes['[DTT_DESCRIPTION]'] = __(
427
+			'This will be parsed to the description for a Datetime',
428
+			'event_espresso'
429
+		);
430
+		$shortcodes['[DTT_NAME_OR_DATES]'] = __(
431
+			'When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.',
432
+			'event_espresso'
433
+		);
434
+
435
+		return $shortcodes;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Callback for additional shortcodes parser filter used for adding parser for new
441
+	 * Datetime shortcodes
442
+	 *
443
+	 * @since  4.2
444
+	 *
445
+	 * @param  string                 $parsed     The finished parsed string for the given shortcode.
446
+	 * @param  string                 $shortcode  The shortcode being parsed.
447
+	 * @param  object                 $data       The incoming data object for the Shortcode Parser.
448
+	 * @param  object                 $extra_data The incoming extra date object for the Shortcode
449
+	 *                                            Parser.
450
+	 * @param  EE_Datetime_Shortcodes $shortcode_parser
451
+	 *
452
+	 * @return string                   The new parsed string.
453
+	 */
454
+	public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455
+	{
456
+
457
+		if (! $data instanceof EE_Datetime) {
458
+			return ''; // get out because we can only parse with the datetime object.
459
+		}
460
+
461
+		switch ($shortcode) {
462
+			case '[DTT_NAME]':
463
+				return $data->name();
464
+				break;
465
+			case '[DTT_DESCRIPTION]':
466
+				return $data->description();
467
+				break;
468
+			case '[DTT_NAME_OR_DATES]':
469
+				return $data->get_dtt_display_name(true);
470
+				break;
471
+			default:
472
+				return $parsed;
473
+				break;
474
+		}
475
+	}
476
+
477
+
478
+	public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser)
479
+	{
480
+		$shortcodes['[RECIPIENT_QUESTION_LIST]'] = __(
481
+			'This is used to indicate where you want the list of questions and answers to show for the person receiving the message.',
482
+			'event_espresso'
483
+		);
484
+
485
+		return $shortcodes;
486
+	}
487
+
488
+
489
+	/**
490
+	 * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter).
491
+	 *
492
+	 * @param string         $parsed           The original parsed content for the shortcode
493
+	 * @param string         $shortcode        The shortcode being parsed
494
+	 * @param array          $data             The shortcode parser data array
495
+	 * @param array          $extra_data       The shortcode parser extra data array
496
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
501
+	{
502
+
503
+		if (array($data) && ! isset($data['data'])) {
504
+			return $parsed;
505
+		}
506
+
507
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509
+
510
+		if (! $recipient instanceof EE_Messages_Addressee) {
511
+			return $parsed;
512
+		}
513
+
514
+		switch ($shortcode) {
515
+			case '[RECIPIENT_QUESTION_LIST]':
516
+				$att = $recipient->att_obj;
517
+				$registrations_on_attendee = $att instanceof EE_Attendee
518
+					? $recipient->attendees[ $att->ID() ]['reg_objs']
519
+					: array();
520
+				$registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521
+				$answers = array();
522
+
523
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
524
+					? $data['template']['question_list']
525
+					: $extra_data['template']['question_list'];
526
+				$valid_shortcodes = array('question');
527
+
528
+				// if the context is main_content then get all answers for all registrations on this attendee
529
+				if ($data['data'] instanceof EE_Messages_Addressee) {
530
+					foreach ($registrations_on_attendee as $reg) {
531
+						if ($reg instanceof EE_Registration) {
532
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
534
+								: array();
535
+							foreach ($anss as $ans) {
536
+								if ($ans instanceof EE_Answer) {
537
+									$answers[ $ans->ID() ] = $ans;
538
+								}
539
+							}
540
+						}
541
+					}
542
+				}
543
+
544
+				// if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event.
545
+				if ($data['data'] instanceof EE_Event) {
546
+					$event = $data['data'];
547
+					foreach ($registrations_on_attendee as $reg) {
548
+						if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
+							$anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
+								? $recipient->registrations[ $reg->ID() ]['ans_objs']
551
+								: array();
552
+							foreach ($anss as $ans) {
553
+								if ($ans instanceof EE_Answer) {
554
+									$answers[ $ans->ID() ] = $ans;
555
+								}
556
+							}
557
+						}
558
+					}
559
+				}
560
+
561
+				$questions = $questions = isset($recipient->questions) ? $recipient->questions : array();
562
+
563
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564
+				// object on it.
565
+				if (! isset($extra_data['data'])) {
566
+					$extra_data['data'] = $recipient;
567
+				}
568
+
569
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
570
+					$shortcode_parser,
571
+					$questions,
572
+					$answers,
573
+					$template,
574
+					$valid_shortcodes,
575
+					$extra_data
576
+				);
577
+				break;
578
+
579
+			default:
580
+				return $parsed;
581
+				break;
582
+		}
583
+	}
584
+
585
+
586
+	public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser)
587
+	{
588
+		$shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __(
589
+			'This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field',
590
+			'event_espresso'
591
+		);
592
+
593
+		return $shortcodes;
594
+	}
595
+
596
+
597
+	/**
598
+	 * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter).
599
+	 *
600
+	 * @param string         $parsed           The original parsed content for the shortcode
601
+	 * @param string         $shortcode        The shortcode being parsed
602
+	 * @param array          $data             The shortcode parser data array
603
+	 * @param array          $extra_data       The shortcode parser extra data array
604
+	 * @param \EE_Shortcodes $shortcode_parser Shortcode parser.
605
+	 *
606
+	 * @return string
607
+	 */
608
+	public function additional_primary_registration_details_parser(
609
+		$parsed,
610
+		$shortcode,
611
+		$data,
612
+		$extra_data,
613
+		$shortcode_parser
614
+	) {
615
+		if (array($data) && ! isset($data['data'])) {
616
+			return $parsed;
617
+		}
618
+
619
+		$recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621
+
622
+		if (! $recipient instanceof EE_Messages_Addressee) {
623
+			return $parsed;
624
+		}
625
+
626
+		switch ($shortcode) {
627
+			case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
+				if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629
+					return '';
630
+				}
631
+				$registration = $recipient->primary_reg_obj;
632
+				$answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
+					? $recipient->registrations[ $registration->ID() ]['ans_objs']
634
+					: array();
635
+				if (empty($answers)) {
636
+					return '';
637
+				}
638
+				$template = is_array($data['template']) && isset($data['template']['question_list'])
639
+					? $data['template']['question_list']
640
+					: $extra_data['template']['question_list'];
641
+				$valid_shortcodes = array('question');
642
+				$answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
643
+				$questions = isset($recipient->questions) ? $recipient->questions : array();
644
+				// if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645
+				// object on it.
646
+				if (! isset($extra_data['data'])) {
647
+					$extra_data['data'] = $recipient;
648
+				}
649
+				return $this->_parse_question_list_for_primary_or_recipient_registration(
650
+					$shortcode_parser,
651
+					$questions,
652
+					$answers,
653
+					$template,
654
+					$valid_shortcodes,
655
+					$extra_data
656
+				);
657
+				break;
658
+
659
+			default:
660
+				return $parsed;
661
+				break;
662
+		}
663
+	}
664
+
665
+
666
+	/**
667
+	 * Takes care of registering the  message types that are only available in caffeinated EE.
668
+	 *
669
+	 * @since   4.3.2
670
+	 *
671
+	 * @return  void
672
+	 */
673
+	public function register_caf_message_types()
674
+	{
675
+		// register newsletter message type
676
+		$setup_args = array(
677
+			'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678
+			'autoloadpaths'                                    => array(
679
+				EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
680
+			),
681
+			'messengers_to_activate_with'                      => array('email'),
682
+			'messengers_to_validate_with'                      => array('email'),
683
+			'messengers_supporting_default_template_pack_with' => array('email'),
684
+		);
685
+		EE_Register_Message_Type::register('newsletter', $setup_args);
686
+
687
+		// register payment reminder message type
688
+		$setup_args = array(
689
+			'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
691
+			'messengers_to_activate_with'                      => array('email'),
692
+			'messengers_to_validate_with'                      => array('email'),
693
+			'messengers_supporting_default_template_pack_with' => array('email'),
694
+		);
695
+		EE_Register_Message_Type::register('payment_reminder', $setup_args);
696
+
697
+		// register payment declined message type
698
+		$setup_args = array(
699
+			'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
701
+			'messengers_to_activate_with'                      => array('email'),
702
+			'messengers_to_validate_with'                      => array('email'),
703
+			'messengers_supporting_default_template_pack_with' => array('email'),
704
+		);
705
+		EE_Register_Message_Type::register('payment_declined', $setup_args);
706
+
707
+		// register registration declined message type
708
+		$setup_args = array(
709
+			'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
711
+			'messengers_to_activate_with'                      => array('email'),
712
+			'messengers_to_validate_with'                      => array('email'),
713
+			'messengers_supporting_default_template_pack_with' => array('email'),
714
+		);
715
+		EE_Register_Message_Type::register('declined_registration', $setup_args);
716
+
717
+		// register registration cancelled message type
718
+		$setup_args = array(
719
+			'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
721
+			'messengers_to_activate_with'                      => array('email'),
722
+			'messengers_to_validate_with'                      => array('email'),
723
+			'messengers_supporting_default_template_pack_with' => array('email'),
724
+		);
725
+		EE_Register_Message_Type::register('cancelled_registration', $setup_args);
726
+
727
+
728
+		// register payment failed message type
729
+		$setup_args = array(
730
+			'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
732
+			'messengers_to_activate_with'                      => array('email'),
733
+			'messengers_to_validate_with'                      => array('email'),
734
+			'messengers_supporting_default_template_pack_with' => array('email'),
735
+		);
736
+		EE_Register_Message_Type::register('payment_failed', $setup_args);
737
+
738
+		// register payment declined message type
739
+		$setup_args = array(
740
+			'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
+			'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
742
+			'messengers_to_activate_with'                      => array('email'),
743
+			'messengers_to_validate_with'                      => array('email'),
744
+			'messengers_supporting_default_template_pack_with' => array('email'),
745
+		);
746
+		EE_Register_Message_Type::register('payment_cancelled', $setup_args);
747
+	}
748
+
749
+
750
+	/**
751
+	 * Takes care of registering the  shortcode libraries implemented with caffeinated EE and set up related items.
752
+	 *
753
+	 * @since   4.3.2
754
+	 *
755
+	 * @return void
756
+	 */
757
+	public function register_caf_shortcodes()
758
+	{
759
+		$setup_args = array(
760
+			'autoloadpaths'                 => array(
761
+				EE_CAF_LIBRARIES . 'shortcodes/',
762
+			),
763
+			'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764
+			'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
765
+			'list_type_shortcodes'          => array('[NEWSLETTER_CONTENT]'),
766
+		);
767
+		EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args);
768
+	}
769
+
770
+
771
+	/**
772
+	 * Parses a question list shortcode using given data and template
773
+	 *
774
+	 * @param \EE_Shortcodes $shortcode_parser
775
+	 * @param EE_Question[]  $questions        An array of questions indexed by answer id.
776
+	 * @param EE_Answer[]    $answers          An array of answer objects
777
+	 * @param string         $template         Template content to be parsed.
778
+	 * @param array          $valid_shortcodes Valid shortcodes for the template being parsed.
779
+	 * @param array          $extra_data       Extra data that might be used when parsing the template.
780
+	 */
781
+	protected function _parse_question_list_for_primary_or_recipient_registration(
782
+		$shortcode_parser,
783
+		$questions,
784
+		$answers,
785
+		$template,
786
+		$valid_shortcodes,
787
+		$extra_data
788
+	) {
789
+		$question_list = '';
790
+		/** @var EEH_Parse_Shortcodes $shortcode_helper */
791
+		$shortcode_helper = $shortcode_parser->get_shortcode_helper();
792
+		foreach ($answers as $answer) {
793
+			if ($answer instanceof EE_Answer) {
794
+				// first see if the question is in our $questions array. If not then try to get from answer object.
795
+				$question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
796
+				$question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
+				if (! $question instanceof EE_Question
798
+					|| (
799
+						$question instanceof EE_Question
800
+						&& $question->admin_only()
801
+					)
802
+				) {
803
+					continue;
804
+				}
805
+				$question_list .= $shortcode_helper->parse_question_list_template(
806
+					$template,
807
+					$answer,
808
+					$valid_shortcodes,
809
+					$extra_data
810
+				);
811
+			}
812
+		}
813
+		return $question_list;
814
+	}
815 815
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function messages_autoload_paths($dir_ref)
132 132
     {
133
-        $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/';
133
+        $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/';
134 134
 
135 135
         return $dir_ref;
136 136
     }
@@ -246,32 +246,32 @@  discard block
 block discarded – undo
246 246
     ) {
247 247
 
248 248
         // we're only modifying templates for the default template pack
249
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
249
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
250 250
             return $contents;
251 251
         }
252 252
 
253 253
         // the template file name we're replacing contents for.
254
-        $template_file_prefix = $field . '_' . $context;
255
-        $msg_prefix = $messenger->name . '_' . $message_type->name . '_';
254
+        $template_file_prefix = $field.'_'.$context;
255
+        $msg_prefix = $messenger->name.'_'.$message_type->name.'_';
256 256
 
257
-        $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/';
257
+        $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/';
258 258
 
259 259
         if ($messenger->name == 'email' && $message_type->name == 'registration') {
260 260
             switch ($template_file_prefix) {
261 261
                 case 'question_list_admin':
262 262
                 case 'question_list_attendee':
263 263
                 case 'question_list_primary_attendee':
264
-                    $path = $base_path . $msg_prefix . 'question_list.template.php';
264
+                    $path = $base_path.$msg_prefix.'question_list.template.php';
265 265
                     $contents = EEH_Template::display_template($path, array(), true);
266 266
                     break;
267 267
 
268 268
                 case 'attendee_list_primary_attendee':
269
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
269
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
270 270
                     $contents = EEH_Template::display_template($path, array(), true);
271 271
                     break;
272 272
 
273 273
                 case 'attendee_list_admin':
274
-                    $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php';
274
+                    $path = $base_path.$msg_prefix.'attendee_list_admin.template.php';
275 275
                     $contents = EEH_Template::display_template(
276 276
                         $path,
277 277
                         array(),
@@ -284,31 +284,31 @@  discard block
 block discarded – undo
284 284
                     break;
285 285
 
286 286
                 case 'event_list_attendee':
287
-                    $path = $base_path . $msg_prefix . 'event_list_attendee.template.php';
287
+                    $path = $base_path.$msg_prefix.'event_list_attendee.template.php';
288 288
                     $contents = EEH_Template::display_template($path, array(), true);
289 289
                     break;
290 290
             }
291 291
         } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') {
292 292
             switch ($template_file_prefix) {
293 293
                 case 'content_attendee':
294
-                    $path = $base_path . $msg_prefix . 'content.template.php';
294
+                    $path = $base_path.$msg_prefix.'content.template.php';
295 295
                     $contents = EEH_Template::display_template($path, array(), true);
296 296
                     break;
297 297
 
298 298
                 case 'newsletter_content_attendee':
299
-                    $path = $base_path . $msg_prefix . 'newsletter_content.template.php';
299
+                    $path = $base_path.$msg_prefix.'newsletter_content.template.php';
300 300
                     $contents = EEH_Template::display_template($path, array(), true);
301 301
                     break;
302 302
 
303 303
                 case 'newsletter_subject_attendee':
304
-                    $path = $base_path . $msg_prefix . 'subject.template.php';
304
+                    $path = $base_path.$msg_prefix.'subject.template.php';
305 305
                     $contents = EEH_Template::display_template($path, array(), true);
306 306
                     break;
307 307
             }
308 308
         } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') {
309 309
             switch ($template_file_prefix) {
310 310
                 case 'attendee_list_purchaser':
311
-                    $path = $base_path . $msg_prefix . 'attendee_list.template.php';
311
+                    $path = $base_path.$msg_prefix.'attendee_list.template.php';
312 312
                     $contents = EEH_Template::display_template($path, array(), true);
313 313
                     break;
314 314
             }
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
         if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) {
340 340
             $contexts = array_keys($msg->get_contexts());
341 341
             foreach ($contexts as $context) {
342
-                $valid_shortcodes[ $context ][] = 'question_list';
343
-                $valid_shortcodes[ $context ][] = 'question';
342
+                $valid_shortcodes[$context][] = 'question_list';
343
+                $valid_shortcodes[$context][] = 'question';
344 344
             }
345 345
         }
346 346
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $extra_data
384 384
         ) && isset($extra_data['data']) ? $extra_data['data'] : $aee;
385 385
 
386
-        if (! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
386
+        if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) {
387 387
             return $parsed;
388 388
         }
389 389
 
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
         foreach ($aee->questions as $ansid => $question) {
392 392
             if ($question instanceof EE_Question
393 393
                 && trim($question->display_text()) == trim($shortcode)
394
-                && isset($aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ])
394
+                && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid])
395 395
             ) {
396
-                return $aee->registrations[ $registration->ID() ]['ans_objs'][ $ansid ]->get_pretty(
396
+                return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty(
397 397
                     'ANS_value',
398 398
                     'no_wpautop'
399 399
                 );
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser)
455 455
     {
456 456
 
457
-        if (! $data instanceof EE_Datetime) {
457
+        if ( ! $data instanceof EE_Datetime) {
458 458
             return ''; // get out because we can only parse with the datetime object.
459 459
         }
460 460
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
508 508
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
509 509
 
510
-        if (! $recipient instanceof EE_Messages_Addressee) {
510
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
511 511
             return $parsed;
512 512
         }
513 513
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
             case '[RECIPIENT_QUESTION_LIST]':
516 516
                 $att = $recipient->att_obj;
517 517
                 $registrations_on_attendee = $att instanceof EE_Attendee
518
-                    ? $recipient->attendees[ $att->ID() ]['reg_objs']
518
+                    ? $recipient->attendees[$att->ID()]['reg_objs']
519 519
                     : array();
520 520
                 $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee;
521 521
                 $answers = array();
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
                 if ($data['data'] instanceof EE_Messages_Addressee) {
530 530
                     foreach ($registrations_on_attendee as $reg) {
531 531
                         if ($reg instanceof EE_Registration) {
532
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
533
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
532
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
533
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
534 534
                                 : array();
535 535
                             foreach ($anss as $ans) {
536 536
                                 if ($ans instanceof EE_Answer) {
537
-                                    $answers[ $ans->ID() ] = $ans;
537
+                                    $answers[$ans->ID()] = $ans;
538 538
                                 }
539 539
                             }
540 540
                         }
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
                     $event = $data['data'];
547 547
                     foreach ($registrations_on_attendee as $reg) {
548 548
                         if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) {
549
-                            $anss = ! empty($recipient->registrations[ $reg->ID() ]['ans_objs'])
550
-                                ? $recipient->registrations[ $reg->ID() ]['ans_objs']
549
+                            $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs'])
550
+                                ? $recipient->registrations[$reg->ID()]['ans_objs']
551 551
                                 : array();
552 552
                             foreach ($anss as $ans) {
553 553
                                 if ($ans instanceof EE_Answer) {
554
-                                    $answers[ $ans->ID() ] = $ans;
554
+                                    $answers[$ans->ID()] = $ans;
555 555
                                 }
556 556
                             }
557 557
                         }
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
564 564
                 // object on it.
565
-                if (! isset($extra_data['data'])) {
565
+                if ( ! isset($extra_data['data'])) {
566 566
                     $extra_data['data'] = $recipient;
567 567
                 }
568 568
 
@@ -619,18 +619,18 @@  discard block
 block discarded – undo
619 619
         $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null;
620 620
         $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient;
621 621
 
622
-        if (! $recipient instanceof EE_Messages_Addressee) {
622
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
623 623
             return $parsed;
624 624
         }
625 625
 
626 626
         switch ($shortcode) {
627 627
             case '[PRIMARY_REGISTRANT_QUESTION_LIST]':
628
-                if (! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
628
+                if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) {
629 629
                     return '';
630 630
                 }
631 631
                 $registration = $recipient->primary_reg_obj;
632
-                $answers = isset($recipient->registrations[ $registration->ID() ]['ans_objs'])
633
-                    ? $recipient->registrations[ $registration->ID() ]['ans_objs']
632
+                $answers = isset($recipient->registrations[$registration->ID()]['ans_objs'])
633
+                    ? $recipient->registrations[$registration->ID()]['ans_objs']
634 634
                     : array();
635 635
                 if (empty($answers)) {
636 636
                     return '';
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
                     ? $data['template']['question_list']
640 640
                     : $extra_data['template']['question_list'];
641 641
                 $valid_shortcodes = array('question');
642
-                $answers = $recipient->registrations[ $registration->ID() ]['ans_objs'];
642
+                $answers = $recipient->registrations[$registration->ID()]['ans_objs'];
643 643
                 $questions = isset($recipient->questions) ? $recipient->questions : array();
644 644
                 // if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee
645 645
                 // object on it.
646
-                if (! isset($extra_data['data'])) {
646
+                if ( ! isset($extra_data['data'])) {
647 647
                     $extra_data['data'] = $recipient;
648 648
                 }
649 649
                 return $this->_parse_question_list_for_primary_or_recipient_registration(
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         $setup_args = array(
677 677
             'mtfilename'                                       => 'EE_Newsletter_message_type.class.php',
678 678
             'autoloadpaths'                                    => array(
679
-                EE_CAF_LIBRARIES . 'messages/message_type/newsletter/',
679
+                EE_CAF_LIBRARIES.'messages/message_type/newsletter/',
680 680
             ),
681 681
             'messengers_to_activate_with'                      => array('email'),
682 682
             'messengers_to_validate_with'                      => array('email'),
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
         // register payment reminder message type
688 688
         $setup_args = array(
689 689
             'mtfilename'                                       => 'EE_Payment_Reminder_message_type.class.php',
690
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'),
690
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'),
691 691
             'messengers_to_activate_with'                      => array('email'),
692 692
             'messengers_to_validate_with'                      => array('email'),
693 693
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
         // register payment declined message type
698 698
         $setup_args = array(
699 699
             'mtfilename'                                       => 'EE_Payment_Declined_message_type.class.php',
700
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'),
700
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'),
701 701
             'messengers_to_activate_with'                      => array('email'),
702 702
             'messengers_to_validate_with'                      => array('email'),
703 703
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
         // register registration declined message type
708 708
         $setup_args = array(
709 709
             'mtfilename'                                       => 'EE_Declined_Registration_message_type.class.php',
710
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'),
710
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'),
711 711
             'messengers_to_activate_with'                      => array('email'),
712 712
             'messengers_to_validate_with'                      => array('email'),
713 713
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         // register registration cancelled message type
718 718
         $setup_args = array(
719 719
             'mtfilename'                                       => 'EE_Cancelled_Registration_message_type.class.php',
720
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'),
720
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'),
721 721
             'messengers_to_activate_with'                      => array('email'),
722 722
             'messengers_to_validate_with'                      => array('email'),
723 723
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
         // register payment failed message type
729 729
         $setup_args = array(
730 730
             'mtfilename'                                       => 'EE_Payment_Failed_message_type.class.php',
731
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'),
731
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'),
732 732
             'messengers_to_activate_with'                      => array('email'),
733 733
             'messengers_to_validate_with'                      => array('email'),
734 734
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
         // register payment declined message type
739 739
         $setup_args = array(
740 740
             'mtfilename'                                       => 'EE_Payment_Cancelled_message_type.class.php',
741
-            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'),
741
+            'autoloadpaths'                                    => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'),
742 742
             'messengers_to_activate_with'                      => array('email'),
743 743
             'messengers_to_validate_with'                      => array('email'),
744 744
             'messengers_supporting_default_template_pack_with' => array('email'),
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     {
759 759
         $setup_args = array(
760 760
             'autoloadpaths'                 => array(
761
-                EE_CAF_LIBRARIES . 'shortcodes/',
761
+                EE_CAF_LIBRARIES.'shortcodes/',
762 762
             ),
763 763
             'msgr_validator_callback'       => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'),
764 764
             'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'),
@@ -792,9 +792,9 @@  discard block
 block discarded – undo
792 792
         foreach ($answers as $answer) {
793 793
             if ($answer instanceof EE_Answer) {
794 794
                 // first see if the question is in our $questions array. If not then try to get from answer object.
795
-                $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null;
795
+                $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null;
796 796
                 $question = ! $question instanceof EE_Question ? $answer->question() : $question;
797
-                if (! $question instanceof EE_Question
797
+                if ( ! $question instanceof EE_Question
798 798
                     || (
799 799
                         $question instanceof EE_Question
800 800
                         && $question->admin_only()
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Prices_List_Table.class.php 2 patches
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -16,220 +16,220 @@
 block discarded – undo
16 16
 class Prices_List_Table extends EE_Admin_List_Table
17 17
 {
18 18
 
19
-    private $_PRT;
20
-
21
-    /**
22
-     * Array of price types.
23
-     *
24
-     * @var EE_Price_Type[]
25
-     */
26
-    protected $_price_types = array();
27
-
28
-    public function __construct($admin_page)
29
-    {
30
-        parent::__construct($admin_page);
31
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
32
-        $this->_PRT = EEM_Price_Type::instance();
33
-        $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted();
34
-    }
35
-
36
-
37
-    protected function _setup_data()
38
-    {
39
-        $trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
40
-        $this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed);
41
-        $this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false);
42
-        $this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true);
43
-    }
44
-
45
-
46
-    protected function _set_properties()
47
-    {
48
-        $this->_wp_list_args = array(
49
-            'singular' => __('price', 'event_espresso'),
50
-            'plural'   => __('prices', 'event_espresso'),
51
-            'ajax'     => true,
52
-            'screen'   => $this->_admin_page->get_current_screen()->id,
53
-        );
54
-
55
-        $this->_columns = array(
56
-            'cb'          => '<input type="checkbox" />', // Render a checkbox instead of text
57
-            'name'        => __('Name', 'event_espresso'),
58
-            'type'        => __('Price Type', 'event_espresso'),
59
-            'description' => __('Description', 'event_espresso'),
60
-            'amount'      => __('Amount', 'event_espresso'),
61
-        );
62
-
63
-        $this->_sortable_columns = array(
64
-            // true means its already sorted
65
-            'name'   => array('name' => false),
66
-            'type'   => array('type' => false),
67
-            'amount' => array('amount' => false),
68
-        );
69
-
70
-        $this->_hidden_columns = array();
71
-
72
-        $this->_ajax_sorting_callback = 'update_prices_order';
73
-    }
74
-
75
-
76
-    protected function _get_table_filters()
77
-    {
78
-    }
79
-
80
-
81
-    protected function _add_view_counts()
82
-    {
83
-        $this->_views['all']['count'] = $this->_all_data_count;
84
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
85
-            $this->_views['trashed']['count'] = $this->_trashed_count;
86
-        }
87
-    }
88
-
89
-
90
-    /**
91
-     * overriding parent method so that we can make sure the row isn't sortable for certain items
92
-     *
93
-     * @param  object $item the current item
94
-     * @return string
95
-     */
96
-    protected function _get_row_class($item)
97
-    {
98
-        static $row_class = '';
99
-        $row_class = ($row_class == '' ? 'alternate' : '');
100
-
101
-        $new_row = $row_class;
102
-
103
-        if ($item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4) {
104
-            $new_row .= ' rowsortable';
105
-        }
106
-
107
-        return ' class="' . $new_row . '"';
108
-    }
109
-
110
-
111
-    public function column_cb($item)
112
-    {
113
-        if ($item->type_obj()->base_type() !== 1) {
114
-            return sprintf(
115
-                '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
116
-                $item->ID()
117
-            );
118
-        }
119
-        return '';
120
-    }
121
-
122
-
123
-    public function column_name($item)
124
-    {
125
-
126
-        // Build row actions
127
-        $actions = array();
128
-        // edit price link
129
-        if (EE_Registry::instance()->CAP->current_user_can(
130
-            'ee_edit_default_price',
131
-            'pricing_edit_price',
132
-            $item->ID()
133
-        )) {
134
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
135
-                'action' => 'edit_price',
136
-                'id'     => $item->ID(),
137
-            ), PRICING_ADMIN_URL);
138
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
139
-                               . esc_attr__('Edit Price', 'event_espresso') . '">'
140
-                               . __('Edit', 'event_espresso') . '</a>';
141
-        }
142
-
143
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
144
-            'ee_edit_default_price',
145
-            'edit_price',
146
-            $item->ID()
147
-        )
148
-            ? '<a href="' . $edit_lnk_url . '" title="'
149
-              . esc_attr__('Edit Price', 'event_espresso') . '">'
150
-              . stripslashes($item->name()) . '</a>'
151
-            : $item->name();
152
-
153
-        if ($item->type_obj()->base_type() !== 1) {
154
-            if ($this->_view == 'all') {
155
-                // trash price link
156
-                if (EE_Registry::instance()->CAP->current_user_can(
157
-                    'ee_delete_default_price',
158
-                    'pricing_trash_price',
159
-                    $item->ID()
160
-                )) {
161
-                    $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
162
-                        'action'   => 'trash_price',
163
-                        'id'       => $item->ID(),
164
-                        'noheader' => true,
165
-                    ), PRICING_ADMIN_URL);
166
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
167
-                                        . esc_attr__('Move Price to Trash', 'event_espresso') . '">'
168
-                                        . __('Move to Trash', 'event_espresso') . '</a>';
169
-                }
170
-            } else {
171
-                if (EE_Registry::instance()->CAP->current_user_can(
172
-                    'ee_delete_default_price',
173
-                    'pricing_restore_price',
174
-                    $item->ID()
175
-                )) {
176
-                    // restore price link
177
-                    $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
178
-                        'action'   => 'restore_price',
179
-                        'id'       => $item->ID(),
180
-                        'noheader' => true,
181
-                    ), PRICING_ADMIN_URL);
182
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
183
-                                          . esc_attr__('Restore Price', 'event_espresso') . '">'
184
-                                          . __('Restore', 'event_espresso') . '</a>';
185
-                }
186
-
187
-                // delete price link
188
-                if (EE_Registry::instance()->CAP->current_user_can(
189
-                    'ee_delete_default_price',
190
-                    'pricing_delete_price',
191
-                    $item->ID()
192
-                )) {
193
-                    $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
194
-                        'action'   => 'delete_price',
195
-                        'id'       => $item->ID(),
196
-                        'noheader' => true,
197
-                    ), PRICING_ADMIN_URL);
198
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
199
-                                         . esc_attr__('Delete Price Permanently', 'event_espresso') . '">'
200
-                                         . __('Delete Permanently', 'event_espresso') . '</a>';
201
-                }
202
-            }
203
-        }
204
-
205
-        // Return the name contents
206
-        return sprintf(
207
-            '%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
208
-            $name_link,
209
-            $item->ID(),
210
-            $this->row_actions($actions)
211
-        );
212
-    }
213
-
214
-
215
-    public function column_type($item)
216
-    {
217
-        return $this->_price_types[ $item->type() ]->name();
218
-    }
219
-
220
-
221
-    public function column_description($item)
222
-    {
223
-        return stripslashes($item->desc());
224
-    }
225
-
226
-
227
-    public function column_amount($item)
228
-    {
229
-        if ($this->_price_types[ $item->type() ]->is_percent()) {
230
-            return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>';
231
-        } else {
232
-            return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>';
233
-        }
234
-    }
19
+	private $_PRT;
20
+
21
+	/**
22
+	 * Array of price types.
23
+	 *
24
+	 * @var EE_Price_Type[]
25
+	 */
26
+	protected $_price_types = array();
27
+
28
+	public function __construct($admin_page)
29
+	{
30
+		parent::__construct($admin_page);
31
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
32
+		$this->_PRT = EEM_Price_Type::instance();
33
+		$this->_price_types = $this->_PRT->get_all_deleted_and_undeleted();
34
+	}
35
+
36
+
37
+	protected function _setup_data()
38
+	{
39
+		$trashed = $this->_admin_page->get_view() == 'trashed' ? true : false;
40
+		$this->_data = $this->_admin_page->get_prices_overview_data($this->_per_page, false, $trashed);
41
+		$this->_all_data_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, false);
42
+		$this->_trashed_count = $this->_admin_page->get_prices_overview_data($this->_per_page, true, true);
43
+	}
44
+
45
+
46
+	protected function _set_properties()
47
+	{
48
+		$this->_wp_list_args = array(
49
+			'singular' => __('price', 'event_espresso'),
50
+			'plural'   => __('prices', 'event_espresso'),
51
+			'ajax'     => true,
52
+			'screen'   => $this->_admin_page->get_current_screen()->id,
53
+		);
54
+
55
+		$this->_columns = array(
56
+			'cb'          => '<input type="checkbox" />', // Render a checkbox instead of text
57
+			'name'        => __('Name', 'event_espresso'),
58
+			'type'        => __('Price Type', 'event_espresso'),
59
+			'description' => __('Description', 'event_espresso'),
60
+			'amount'      => __('Amount', 'event_espresso'),
61
+		);
62
+
63
+		$this->_sortable_columns = array(
64
+			// true means its already sorted
65
+			'name'   => array('name' => false),
66
+			'type'   => array('type' => false),
67
+			'amount' => array('amount' => false),
68
+		);
69
+
70
+		$this->_hidden_columns = array();
71
+
72
+		$this->_ajax_sorting_callback = 'update_prices_order';
73
+	}
74
+
75
+
76
+	protected function _get_table_filters()
77
+	{
78
+	}
79
+
80
+
81
+	protected function _add_view_counts()
82
+	{
83
+		$this->_views['all']['count'] = $this->_all_data_count;
84
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
85
+			$this->_views['trashed']['count'] = $this->_trashed_count;
86
+		}
87
+	}
88
+
89
+
90
+	/**
91
+	 * overriding parent method so that we can make sure the row isn't sortable for certain items
92
+	 *
93
+	 * @param  object $item the current item
94
+	 * @return string
95
+	 */
96
+	protected function _get_row_class($item)
97
+	{
98
+		static $row_class = '';
99
+		$row_class = ($row_class == '' ? 'alternate' : '');
100
+
101
+		$new_row = $row_class;
102
+
103
+		if ($item->type_obj()->base_type() !== 1 && $item->type_obj()->base_type() !== 4) {
104
+			$new_row .= ' rowsortable';
105
+		}
106
+
107
+		return ' class="' . $new_row . '"';
108
+	}
109
+
110
+
111
+	public function column_cb($item)
112
+	{
113
+		if ($item->type_obj()->base_type() !== 1) {
114
+			return sprintf(
115
+				'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
116
+				$item->ID()
117
+			);
118
+		}
119
+		return '';
120
+	}
121
+
122
+
123
+	public function column_name($item)
124
+	{
125
+
126
+		// Build row actions
127
+		$actions = array();
128
+		// edit price link
129
+		if (EE_Registry::instance()->CAP->current_user_can(
130
+			'ee_edit_default_price',
131
+			'pricing_edit_price',
132
+			$item->ID()
133
+		)) {
134
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
135
+				'action' => 'edit_price',
136
+				'id'     => $item->ID(),
137
+			), PRICING_ADMIN_URL);
138
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
139
+							   . esc_attr__('Edit Price', 'event_espresso') . '">'
140
+							   . __('Edit', 'event_espresso') . '</a>';
141
+		}
142
+
143
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
144
+			'ee_edit_default_price',
145
+			'edit_price',
146
+			$item->ID()
147
+		)
148
+			? '<a href="' . $edit_lnk_url . '" title="'
149
+			  . esc_attr__('Edit Price', 'event_espresso') . '">'
150
+			  . stripslashes($item->name()) . '</a>'
151
+			: $item->name();
152
+
153
+		if ($item->type_obj()->base_type() !== 1) {
154
+			if ($this->_view == 'all') {
155
+				// trash price link
156
+				if (EE_Registry::instance()->CAP->current_user_can(
157
+					'ee_delete_default_price',
158
+					'pricing_trash_price',
159
+					$item->ID()
160
+				)) {
161
+					$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
162
+						'action'   => 'trash_price',
163
+						'id'       => $item->ID(),
164
+						'noheader' => true,
165
+					), PRICING_ADMIN_URL);
166
+					$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
167
+										. esc_attr__('Move Price to Trash', 'event_espresso') . '">'
168
+										. __('Move to Trash', 'event_espresso') . '</a>';
169
+				}
170
+			} else {
171
+				if (EE_Registry::instance()->CAP->current_user_can(
172
+					'ee_delete_default_price',
173
+					'pricing_restore_price',
174
+					$item->ID()
175
+				)) {
176
+					// restore price link
177
+					$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
178
+						'action'   => 'restore_price',
179
+						'id'       => $item->ID(),
180
+						'noheader' => true,
181
+					), PRICING_ADMIN_URL);
182
+					$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
183
+										  . esc_attr__('Restore Price', 'event_espresso') . '">'
184
+										  . __('Restore', 'event_espresso') . '</a>';
185
+				}
186
+
187
+				// delete price link
188
+				if (EE_Registry::instance()->CAP->current_user_can(
189
+					'ee_delete_default_price',
190
+					'pricing_delete_price',
191
+					$item->ID()
192
+				)) {
193
+					$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
194
+						'action'   => 'delete_price',
195
+						'id'       => $item->ID(),
196
+						'noheader' => true,
197
+					), PRICING_ADMIN_URL);
198
+					$actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
199
+										 . esc_attr__('Delete Price Permanently', 'event_espresso') . '">'
200
+										 . __('Delete Permanently', 'event_espresso') . '</a>';
201
+				}
202
+			}
203
+		}
204
+
205
+		// Return the name contents
206
+		return sprintf(
207
+			'%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
208
+			$name_link,
209
+			$item->ID(),
210
+			$this->row_actions($actions)
211
+		);
212
+	}
213
+
214
+
215
+	public function column_type($item)
216
+	{
217
+		return $this->_price_types[ $item->type() ]->name();
218
+	}
219
+
220
+
221
+	public function column_description($item)
222
+	{
223
+		return stripslashes($item->desc());
224
+	}
225
+
226
+
227
+	public function column_amount($item)
228
+	{
229
+		if ($this->_price_types[ $item->type() ]->is_percent()) {
230
+			return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>';
231
+		} else {
232
+			return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>';
233
+		}
234
+	}
235 235
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public function __construct($admin_page)
29 29
     {
30 30
         parent::__construct($admin_page);
31
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
31
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
32 32
         $this->_PRT = EEM_Price_Type::instance();
33 33
         $this->_price_types = $this->_PRT->get_all_deleted_and_undeleted();
34 34
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $new_row .= ' rowsortable';
105 105
         }
106 106
 
107
-        return ' class="' . $new_row . '"';
107
+        return ' class="'.$new_row.'"';
108 108
     }
109 109
 
110 110
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
                 'action' => 'edit_price',
136 136
                 'id'     => $item->ID(),
137 137
             ), PRICING_ADMIN_URL);
138
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
139
-                               . esc_attr__('Edit Price', 'event_espresso') . '">'
140
-                               . __('Edit', 'event_espresso') . '</a>';
138
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
139
+                               . esc_attr__('Edit Price', 'event_espresso').'">'
140
+                               . __('Edit', 'event_espresso').'</a>';
141 141
         }
142 142
 
143 143
         $name_link = EE_Registry::instance()->CAP->current_user_can(
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
             'edit_price',
146 146
             $item->ID()
147 147
         )
148
-            ? '<a href="' . $edit_lnk_url . '" title="'
149
-              . esc_attr__('Edit Price', 'event_espresso') . '">'
150
-              . stripslashes($item->name()) . '</a>'
148
+            ? '<a href="'.$edit_lnk_url.'" title="'
149
+              . esc_attr__('Edit Price', 'event_espresso').'">'
150
+              . stripslashes($item->name()).'</a>'
151 151
             : $item->name();
152 152
 
153 153
         if ($item->type_obj()->base_type() !== 1) {
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
                         'id'       => $item->ID(),
164 164
                         'noheader' => true,
165 165
                     ), PRICING_ADMIN_URL);
166
-                    $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
167
-                                        . esc_attr__('Move Price to Trash', 'event_espresso') . '">'
168
-                                        . __('Move to Trash', 'event_espresso') . '</a>';
166
+                    $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
167
+                                        . esc_attr__('Move Price to Trash', 'event_espresso').'">'
168
+                                        . __('Move to Trash', 'event_espresso').'</a>';
169 169
                 }
170 170
             } else {
171 171
                 if (EE_Registry::instance()->CAP->current_user_can(
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
                         'id'       => $item->ID(),
180 180
                         'noheader' => true,
181 181
                     ), PRICING_ADMIN_URL);
182
-                    $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
183
-                                          . esc_attr__('Restore Price', 'event_espresso') . '">'
184
-                                          . __('Restore', 'event_espresso') . '</a>';
182
+                    $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
183
+                                          . esc_attr__('Restore Price', 'event_espresso').'">'
184
+                                          . __('Restore', 'event_espresso').'</a>';
185 185
                 }
186 186
 
187 187
                 // delete price link
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
                         'id'       => $item->ID(),
196 196
                         'noheader' => true,
197 197
                     ), PRICING_ADMIN_URL);
198
-                    $actions['delete'] = '<a href="' . $delete_lnk_url . '" title="'
199
-                                         . esc_attr__('Delete Price Permanently', 'event_espresso') . '">'
200
-                                         . __('Delete Permanently', 'event_espresso') . '</a>';
198
+                    $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'
199
+                                         . esc_attr__('Delete Price Permanently', 'event_espresso').'">'
200
+                                         . __('Delete Permanently', 'event_espresso').'</a>';
201 201
                 }
202 202
             }
203 203
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
     public function column_type($item)
216 216
     {
217
-        return $this->_price_types[ $item->type() ]->name();
217
+        return $this->_price_types[$item->type()]->name();
218 218
     }
219 219
 
220 220
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 
227 227
     public function column_amount($item)
228 228
     {
229
-        if ($this->_price_types[ $item->type() ]->is_percent()) {
230
-            return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>';
229
+        if ($this->_price_types[$item->type()]->is_percent()) {
230
+            return '<div class="pad-amnt-rght">'.number_format($item->amount(), 1).'%</div>';
231 231
         } else {
232
-            return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>';
232
+            return '<div class="pad-amnt-rght">'.EEH_Template::format_currency($item->amount()).'</div>';
233 233
         }
234 234
     }
235 235
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Taxes.class.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -10,138 +10,138 @@
 block discarded – undo
10 10
 class EE_Taxes extends EE_Base
11 11
 {
12 12
 
13
-    /**
14
-     * This is used for when EE_Taxes is used statically by the admin
15
-     *
16
-     * @var array
17
-     */
18
-    private static $_subtotal = array();
13
+	/**
14
+	 * This is used for when EE_Taxes is used statically by the admin
15
+	 *
16
+	 * @var array
17
+	 */
18
+	private static $_subtotal = array();
19 19
 
20
-    /**
21
-     * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types)
22
-     *
23
-     * @var EE_Price[]
24
-     */
25
-    private static $_default_taxes = array();
20
+	/**
21
+	 * This holds an array of EE_Price objects that are of PRT_ID == 4 (tax price types)
22
+	 *
23
+	 * @var EE_Price[]
24
+	 */
25
+	private static $_default_taxes = array();
26 26
 
27 27
 
28
-    /**
29
-     * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket
30
-     * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick
31
-     * calc of taxes for tickets listed in the event editor.
32
-     *
33
-     * @param  EE_Ticket $ticket incoming EE_Ticket
34
-     * @return float             total taxes to apply to ticket.
35
-     * @throws \EE_Error
36
-     */
37
-    public static function get_total_taxes_for_admin(EE_Ticket $ticket)
38
-    {
39
-        $tax = 0;
40
-        $total_tax = 0;
41
-        // This first checks to see if the given ticket is taxable.
42
-        if (! $ticket->get('TKT_taxable')) {
43
-            return $tax;
44
-        }
45
-        // get subtotal (notice we're only retrieving a subtotal if there isn't one given)
46
-        $subtotal = self::get_subtotal_for_admin($ticket);
47
-        // get taxes
48
-        $taxes = self::get_taxes_for_admin();
49
-        // apply taxes to subtotal
50
-        foreach ($taxes as $tax) {
51
-            // assuming taxes are not cumulative
52
-            $total_tax += $subtotal * $tax->get('PRC_amount') / 100;
53
-        }
54
-        return $total_tax;
55
-    }
28
+	/**
29
+	 * This method simply calculates the total taxes for a given ticket (by pulling the prices attached to the ticket
30
+	 * and applying default taxes to it). Note: this is just an intermediary helper method added to facilitate quick
31
+	 * calc of taxes for tickets listed in the event editor.
32
+	 *
33
+	 * @param  EE_Ticket $ticket incoming EE_Ticket
34
+	 * @return float             total taxes to apply to ticket.
35
+	 * @throws \EE_Error
36
+	 */
37
+	public static function get_total_taxes_for_admin(EE_Ticket $ticket)
38
+	{
39
+		$tax = 0;
40
+		$total_tax = 0;
41
+		// This first checks to see if the given ticket is taxable.
42
+		if (! $ticket->get('TKT_taxable')) {
43
+			return $tax;
44
+		}
45
+		// get subtotal (notice we're only retrieving a subtotal if there isn't one given)
46
+		$subtotal = self::get_subtotal_for_admin($ticket);
47
+		// get taxes
48
+		$taxes = self::get_taxes_for_admin();
49
+		// apply taxes to subtotal
50
+		foreach ($taxes as $tax) {
51
+			// assuming taxes are not cumulative
52
+			$total_tax += $subtotal * $tax->get('PRC_amount') / 100;
53
+		}
54
+		return $total_tax;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Gets the total percentage of tax that should be applied to taxable line items
60
-     *
61
-     * @return float the percentage of tax that should be added to taxable items
62
-     * @throws \EE_Error
63
-     * eg 20 for %20 tax (NOT 0.20, which
64
-     */
65
-    public static function get_total_taxes_percentage()
66
-    {
67
-        $total_tax_percent = 0;
68
-        foreach (self::get_taxes_for_admin() as $tax_price) {
69
-            $total_tax_percent += $tax_price->get('PRC_amount');
70
-        }
71
-        return $total_tax_percent;
72
-    }
58
+	/**
59
+	 * Gets the total percentage of tax that should be applied to taxable line items
60
+	 *
61
+	 * @return float the percentage of tax that should be added to taxable items
62
+	 * @throws \EE_Error
63
+	 * eg 20 for %20 tax (NOT 0.20, which
64
+	 */
65
+	public static function get_total_taxes_percentage()
66
+	{
67
+		$total_tax_percent = 0;
68
+		foreach (self::get_taxes_for_admin() as $tax_price) {
69
+			$total_tax_percent += $tax_price->get('PRC_amount');
70
+		}
71
+		return $total_tax_percent;
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @param EE_Ticket $ticket
77
-     * @return float
78
-     * @throws \EE_Error
79
-     */
80
-    public static function get_subtotal_for_admin(EE_Ticket $ticket)
81
-    {
82
-        $TKT_ID = $ticket->ID();
83
-        return isset(self::$_subtotal[ $TKT_ID ])
84
-            ? self::$_subtotal[ $TKT_ID ]
85
-            : self::_get_subtotal_for_admin($ticket);
86
-    }
75
+	/**
76
+	 * @param EE_Ticket $ticket
77
+	 * @return float
78
+	 * @throws \EE_Error
79
+	 */
80
+	public static function get_subtotal_for_admin(EE_Ticket $ticket)
81
+	{
82
+		$TKT_ID = $ticket->ID();
83
+		return isset(self::$_subtotal[ $TKT_ID ])
84
+			? self::$_subtotal[ $TKT_ID ]
85
+			: self::_get_subtotal_for_admin($ticket);
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * simply take an incoming ticket and calculate the subtotal for the ticket
91
-     *
92
-     * @param  EE_Ticket $ticket
93
-     * @return float     subtotal calculated from all EE_Price[] on Ticket.
94
-     * @throws \EE_Error
95
-     */
96
-    private static function _get_subtotal_for_admin(EE_Ticket $ticket)
97
-    {
98
-        $subtotal = 0;
99
-        // get all prices
100
-        $prices = $ticket->get_many_related(
101
-            'Price',
102
-            array(
103
-                'default_where_conditions' => 'none',
104
-                'order_by'                 => array('PRC_order' => 'ASC'),
105
-            )
106
-        );
107
-        // let's loop through them (base price is always the first item)
108
-        foreach ($prices as $price) {
109
-            if ($price instanceof EE_Price) {
110
-                $price_type = $price->type_obj();
111
-                if ($price_type instanceof EE_Price_Type) {
112
-                    switch ($price->type_obj()->base_type()) {
113
-                        case 1: // base price
114
-                        case 3: // surcharges
115
-                            $subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
116
-                                : $price->get('PRC_amount');
117
-                            break;
118
-                        case 2: // discounts
119
-                            $subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
120
-                                : $price->get('PRC_amount');
121
-                            break;
122
-                    }
123
-                }
124
-            }
125
-        }
126
-        $TKT_ID = $ticket->ID();
127
-        self::$_subtotal = array($TKT_ID => $subtotal);
128
-        return $subtotal;
129
-    }
89
+	/**
90
+	 * simply take an incoming ticket and calculate the subtotal for the ticket
91
+	 *
92
+	 * @param  EE_Ticket $ticket
93
+	 * @return float     subtotal calculated from all EE_Price[] on Ticket.
94
+	 * @throws \EE_Error
95
+	 */
96
+	private static function _get_subtotal_for_admin(EE_Ticket $ticket)
97
+	{
98
+		$subtotal = 0;
99
+		// get all prices
100
+		$prices = $ticket->get_many_related(
101
+			'Price',
102
+			array(
103
+				'default_where_conditions' => 'none',
104
+				'order_by'                 => array('PRC_order' => 'ASC'),
105
+			)
106
+		);
107
+		// let's loop through them (base price is always the first item)
108
+		foreach ($prices as $price) {
109
+			if ($price instanceof EE_Price) {
110
+				$price_type = $price->type_obj();
111
+				if ($price_type instanceof EE_Price_Type) {
112
+					switch ($price->type_obj()->base_type()) {
113
+						case 1: // base price
114
+						case 3: // surcharges
115
+							$subtotal += $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
116
+								: $price->get('PRC_amount');
117
+							break;
118
+						case 2: // discounts
119
+							$subtotal -= $price->is_percent() ? $subtotal * $price->get('PRC_amount') / 100
120
+								: $price->get('PRC_amount');
121
+							break;
122
+					}
123
+				}
124
+			}
125
+		}
126
+		$TKT_ID = $ticket->ID();
127
+		self::$_subtotal = array($TKT_ID => $subtotal);
128
+		return $subtotal;
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * get all default prices that are a Tax price type (PRT_ID = 4) and return
134
-     *
135
-     * @return EE_Price[] EE_Price objects that have PRT_ID == 4
136
-     * @throws \EE_Error
137
-     */
138
-    public static function get_taxes_for_admin()
139
-    {
140
-        if (empty(self::$_default_taxes)) {
141
-            self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all(
142
-                array(array('Price_Type.PBT_ID' => 4))
143
-            );
144
-        }
145
-        return self::$_default_taxes;
146
-    }
132
+	/**
133
+	 * get all default prices that are a Tax price type (PRT_ID = 4) and return
134
+	 *
135
+	 * @return EE_Price[] EE_Price objects that have PRT_ID == 4
136
+	 * @throws \EE_Error
137
+	 */
138
+	public static function get_taxes_for_admin()
139
+	{
140
+		if (empty(self::$_default_taxes)) {
141
+			self::$_default_taxes = EE_Registry::instance()->load_model('Price')->get_all(
142
+				array(array('Price_Type.PBT_ID' => 4))
143
+			);
144
+		}
145
+		return self::$_default_taxes;
146
+	}
147 147
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $tax = 0;
40 40
         $total_tax = 0;
41 41
         // This first checks to see if the given ticket is taxable.
42
-        if (! $ticket->get('TKT_taxable')) {
42
+        if ( ! $ticket->get('TKT_taxable')) {
43 43
             return $tax;
44 44
         }
45 45
         // get subtotal (notice we're only retrieving a subtotal if there isn't one given)
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     public static function get_subtotal_for_admin(EE_Ticket $ticket)
81 81
     {
82 82
         $TKT_ID = $ticket->ID();
83
-        return isset(self::$_subtotal[ $TKT_ID ])
84
-            ? self::$_subtotal[ $TKT_ID ]
83
+        return isset(self::$_subtotal[$TKT_ID])
84
+            ? self::$_subtotal[$TKT_ID]
85 85
             : self::_get_subtotal_for_admin($ticket);
86 86
     }
87 87
 
Please login to merge, or discard this patch.
core/db_classes/EE_Term_Taxonomy.class.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,80 +11,80 @@
 block discarded – undo
11 11
 class EE_Term_Taxonomy extends EE_Base_Class
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $props_n_values
16
-     * @return EE_Term_Taxonomy
17
-     */
18
-    public static function new_instance($props_n_values = array())
19
-    {
20
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
-        return $has_object ? $has_object : new self($props_n_values);
22
-    }
14
+	/**
15
+	 * @param array $props_n_values
16
+	 * @return EE_Term_Taxonomy
17
+	 */
18
+	public static function new_instance($props_n_values = array())
19
+	{
20
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
21
+		return $has_object ? $has_object : new self($props_n_values);
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * @param array $props_n_values
27
-     * @return EE_Term_Taxonomy
28
-     */
29
-    public static function new_instance_from_db($props_n_values = array())
30
-    {
31
-        return new self($props_n_values, true);
32
-    }
25
+	/**
26
+	 * @param array $props_n_values
27
+	 * @return EE_Term_Taxonomy
28
+	 */
29
+	public static function new_instance_from_db($props_n_values = array())
30
+	{
31
+		return new self($props_n_values, true);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Gets taxonomy
37
-     *
38
-     * @return string
39
-     */
40
-    public function taxonomy()
41
-    {
42
-        return $this->get('taxonomy');
43
-    }
35
+	/**
36
+	 * Gets taxonomy
37
+	 *
38
+	 * @return string
39
+	 */
40
+	public function taxonomy()
41
+	{
42
+		return $this->get('taxonomy');
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Sets taxonomy
48
-     *
49
-     * @param string $taxonomy
50
-     * @return boolean
51
-     */
52
-    public function set_taxonomy($taxonomy)
53
-    {
54
-        $this->set('taxonomy', $taxonomy);
55
-    }
46
+	/**
47
+	 * Sets taxonomy
48
+	 *
49
+	 * @param string $taxonomy
50
+	 * @return boolean
51
+	 */
52
+	public function set_taxonomy($taxonomy)
53
+	{
54
+		$this->set('taxonomy', $taxonomy);
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Gets term_count
60
-     *
61
-     * @return int
62
-     */
63
-    public function count()
64
-    {
65
-        return $this->get('term_count');
66
-    }
58
+	/**
59
+	 * Gets term_count
60
+	 *
61
+	 * @return int
62
+	 */
63
+	public function count()
64
+	{
65
+		return $this->get('term_count');
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Sets term_count
71
-     *
72
-     * @param int $term_count
73
-     * @return boolean
74
-     */
75
-    public function set_count($term_count)
76
-    {
77
-        $this->set('term_count', $term_count);
78
-    }
69
+	/**
70
+	 * Sets term_count
71
+	 *
72
+	 * @param int $term_count
73
+	 * @return boolean
74
+	 */
75
+	public function set_count($term_count)
76
+	{
77
+		$this->set('term_count', $term_count);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * Gets the term for this term taxonomy
83
-     *
84
-     * @return EE_Term
85
-     */
86
-    public function term()
87
-    {
88
-        return $this->get_first_related('Term');
89
-    }
81
+	/**
82
+	 * Gets the term for this term taxonomy
83
+	 *
84
+	 * @return EE_Term
85
+	 */
86
+	public function term()
87
+	{
88
+		return $this->get_first_related('Term');
89
+	}
90 90
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template_Group.class.php 2 patches
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -13,487 +13,487 @@
 block discarded – undo
13 13
 class EE_Message_Template_Group extends EE_Soft_Delete_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
18
-     */
19
-    const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
20
-
21
-    /**
22
-     * @param array  $props_n_values
23
-     * @param string $timezone
24
-     * @return EE_Message_Template_Group|mixed
25
-     * @throws EE_Error
26
-     */
27
-    public static function new_instance($props_n_values = array(), $timezone = '')
28
-    {
29
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
30
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
31
-    }
32
-
33
-
34
-    /**
35
-     * @param array  $props_n_values
36
-     * @param string $timezone
37
-     * @return EE_Message_Template_Group
38
-     */
39
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
40
-    {
41
-        return new self($props_n_values, true, $timezone);
42
-    }
43
-
44
-
45
-    /**
46
-     * @param bool $message_type
47
-     * @throws EE_Error
48
-     */
49
-    public function set_message_type($message_type = false)
50
-    {
51
-        if (! $message_type) {
52
-            throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53
-        }
54
-        $this->set('MTP_message_type', $message_type);
55
-    }
56
-
57
-
58
-    /**
59
-     * @param bool $messenger
60
-     * @throws EE_Error
61
-     */
62
-    public function set_messenger($messenger = false)
63
-    {
64
-        if (! $messenger) {
65
-            throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66
-        }
67
-        $this->set('MTP_messenger', $messenger);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param bool $GRP_ID
73
-     * @throws EE_Error
74
-     */
75
-    public function set_group_template_id($GRP_ID = false)
76
-    {
77
-        if (! $GRP_ID) {
78
-            throw new EE_Error(
79
-                esc_html__(
80
-                    'Missing required value for the message template group id',
81
-                    'event_espresso'
82
-                )
83
-            );
84
-        }
85
-        $this->set('GRP_ID', $GRP_ID);
86
-    }
87
-
88
-
89
-    /**
90
-     * get Group ID
91
-     *
92
-     * @access public
93
-     * @return int
94
-     * @throws EE_Error
95
-     */
96
-    public function GRP_ID()
97
-    {
98
-        return $this->get('GRP_ID');
99
-    }
100
-
101
-
102
-    /**
103
-     * get User ID
104
-     *
105
-     * @access public
106
-     * @return int
107
-     * @throws EE_Error
108
-     */
109
-    public function user()
110
-    {
111
-        $user_id = $this->get('MTP_user_id');
112
-        return empty($user_id) ? get_current_user_id() : $user_id;
113
-    }
114
-
115
-
116
-    /**
117
-     * Wrapper for the user function() (preserve backward compat)
118
-     *
119
-     * @since  4.5.0
120
-     * @return int
121
-     * @throws EE_Error
122
-     */
123
-    public function wp_user()
124
-    {
125
-        return $this->user();
126
-    }
127
-
128
-
129
-    /**
130
-     * This simply returns a count of all related events to this message template group
131
-     *
132
-     * @return int
133
-     */
134
-    public function count_events()
135
-    {
136
-        return $this->count_related('Event');
137
-    }
138
-
139
-
140
-    /**
141
-     * returns the name saved in the db for this template
142
-     *
143
-     * @return string
144
-     * @throws EE_Error
145
-     */
146
-    public function name()
147
-    {
148
-        return $this->get('MTP_name');
149
-    }
150
-
151
-
152
-    /**
153
-     * Returns the description saved in the db for this template group
154
-     *
155
-     * @return string
156
-     * @throws EE_Error
157
-     */
158
-    public function description()
159
-    {
160
-        return $this->get('MTP_description');
161
-    }
162
-
163
-
164
-    /**
165
-     * returns all related EE_Message_Template objects
166
-     *
167
-     * @param  array $query_params like EEM_Base::get_all()
168
-     * @return EE_Message_Template[]
169
-     * @throws EE_Error
170
-     */
171
-    public function message_templates($query_params = array())
172
-    {
173
-        return $this->get_many_related('Message_Template', $query_params);
174
-    }
175
-
176
-
177
-    /**
178
-     * get Message Messenger
179
-     *
180
-     * @access public
181
-     * @return string
182
-     * @throws EE_Error
183
-     */
184
-    public function messenger()
185
-    {
186
-        return $this->get('MTP_messenger');
187
-    }
188
-
189
-
190
-    /**
191
-     * get Message Messenger OBJECT
192
-     * If an attempt to get the corresponding messenger object fails, then we set this message
193
-     * template group to inactive, and save to db.  Then return null so client code can handle
194
-     * appropriately.
195
-     *
196
-     * @return EE_messenger
197
-     * @throws EE_Error
198
-     */
199
-    public function messenger_obj()
200
-    {
201
-        $messenger = $this->messenger();
202
-        try {
203
-            $messenger = EEH_MSG_Template::messenger_obj($messenger);
204
-        } catch (EE_Error $e) {
205
-            // if an exception was thrown then let's deactivate this message template group because it means there is no
206
-            // class for this messenger in this group.
207
-            $this->set('MTP_is_active', false);
208
-            $this->save();
209
-            return null;
210
-        }
211
-        return $messenger;
212
-    }
213
-
214
-
215
-    /**
216
-     * get Message Type
217
-     *
218
-     * @access public
219
-     * @return string
220
-     * @throws EE_Error
221
-     */
222
-    public function message_type()
223
-    {
224
-        return $this->get('MTP_message_type');
225
-    }
226
-
227
-
228
-    /**
229
-     * get Message type OBJECT
230
-     * If an attempt to get the corresponding message type object fails, then we set this message
231
-     * template group to inactive, and save to db.  Then return null so client code can handle
232
-     * appropriately.
233
-     *
234
-     * @throws EE_Error
235
-     * @return EE_message_type|false if exception thrown.
236
-     */
237
-    public function message_type_obj()
238
-    {
239
-        $message_type = $this->message_type();
240
-        try {
241
-            $message_type = EEH_MSG_Template::message_type_obj($message_type);
242
-        } catch (EE_Error $e) {
243
-            // if an exception was thrown then let's deactivate this message template group because it means there is no
244
-            // class for the message type in this group.
245
-            $this->set('MTP_is_active', false);
246
-            $this->save();
247
-            return null;
248
-        }
249
-        return $message_type;
250
-    }
251
-
252
-
253
-    /**
254
-     * @return array
255
-     * @throws EE_Error
256
-     */
257
-    public function contexts_config()
258
-    {
259
-        return $this->message_type_obj()->get_contexts();
260
-    }
261
-
262
-
263
-    /**
264
-     * This returns the context_label for contexts as set in the message type object
265
-     * Note this is an array with singular and plural keys
266
-     *
267
-     * @access public
268
-     * @return array labels for "context"
269
-     * @throws EE_Error
270
-     */
271
-    public function context_label()
272
-    {
273
-        $obj = $this->message_type_obj();
274
-        return $obj->get_context_label();
275
-    }
276
-
277
-
278
-    /**
279
-     * This returns an array of EE_Message_Template objects indexed by context and field.
280
-     *
281
-     * @return array ()
282
-     * @throws EE_Error
283
-     */
284
-    public function context_templates()
285
-    {
286
-        $mtps_arr = array();
287
-        $mtps = $this->get_many_related('Message_Template');
288
-        if (empty($mtps)) {
289
-            return array();
290
-        }
291
-        // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292
-        foreach ($mtps as $mtp) {
293
-            $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
294
-        }
295
-        return $mtps_arr;
296
-    }
297
-
298
-
299
-    /**
300
-     * this returns if the template group this template belongs to is global
301
-     *
302
-     * @return bool true if it is, false if it isn't
303
-     * @throws EE_Error
304
-     */
305
-    public function is_global()
306
-    {
307
-        return $this->get('MTP_is_global');
308
-    }
309
-
310
-
311
-    /**
312
-     * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
313
-     *
314
-     * @return bool true if it is, false if it isn't
315
-     * @throws EE_Error
316
-     */
317
-    public function is_active()
318
-    {
319
-        return $this->get('MTP_is_active');
320
-    }
321
-
322
-
323
-    /**
324
-     * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
325
-     * this template.
326
-     *
327
-     * @since 4.3.0
328
-     * @uses  EEH_MSG_Template::get_shortcodes()
329
-     * @param string $context what context we're going to return shortcodes for
330
-     * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
331
-     *                        to be returned.
332
-     * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
333
-     *                        unique shortcodes for all the given (or all) fields.
334
-     * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
335
-     *                        shortcodes found.
336
-     * @throws EE_Error
337
-     */
338
-    public function get_shortcodes($context, $fields = array(), $merged = false)
339
-    {
340
-        $messenger = $this->messenger();
341
-        $message_type = $this->message_type();
342
-        return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
343
-    }
344
-
345
-
346
-    /**
347
-     * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
348
-     * use the default template pack.
349
-     *
350
-     * @since 4.5.0
351
-     * @return string
352
-     * @throws EE_Error
353
-     */
354
-    public function get_template_pack_name()
355
-    {
356
-        return $this->get_extra_meta('MTP_template_pack', true, 'default');
357
-    }
358
-
359
-
360
-    /**
361
-     * This returns the specific template pack object referenced by the template pack name attached to this message
362
-     * template group.  If no template pack is assigned then the default template pack is retrieved.
363
-     *
364
-     * @since 4.5.0
365
-     * @return EE_Messages_Template_Pack
366
-     * @throws EE_Error
367
-     * @throws InvalidArgumentException
368
-     * @throws ReflectionException
369
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
370
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
371
-     */
372
-    public function get_template_pack()
373
-    {
374
-        $pack_name = $this->get_template_pack_name();
375
-        EE_Registry::instance()->load_helper('MSG_Template');
376
-        return EEH_MSG_Template::get_template_pack($pack_name);
377
-    }
378
-
379
-
380
-    /**
381
-     * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
382
-     * use the default template variation.
383
-     *
384
-     * @since 4.5.0
385
-     * @return string
386
-     * @throws EE_Error
387
-     */
388
-    public function get_template_pack_variation()
389
-    {
390
-        return $this->get_extra_meta('MTP_variation', true, 'default');
391
-    }
392
-
393
-
394
-    /**
395
-     * This just sets the template pack name attached to this message template group.
396
-     *
397
-     * @since 4.5.0
398
-     * @param string $template_pack_name What message template pack is assigned.
399
-     * @return int
400
-     * @throws EE_Error
401
-     */
402
-    public function set_template_pack_name($template_pack_name)
403
-    {
404
-        return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
405
-    }
406
-
407
-
408
-    /**
409
-     * This just sets the template pack variation attached to this message template group.
410
-     *
411
-     * @since 4.5.0
412
-     * @param string $variation What variation is being set on the message template group.
413
-     * @return int
414
-     * @throws EE_Error
415
-     */
416
-    public function set_template_pack_variation($variation)
417
-    {
418
-        return $this->update_extra_meta('MTP_variation', $variation);
419
-    }
420
-
421
-
422
-    /**
423
-     * Deactivates the given context.
424
-     *
425
-     * @param $context
426
-     * @return bool|int
427
-     * @throws EE_Error
428
-     * @throws InvalidIdentifierException
429
-     */
430
-    public function deactivate_context($context)
431
-    {
432
-        $this->validate_context($context);
433
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
434
-    }
435
-
436
-
437
-    /**
438
-     * Activates the given context.
439
-     *
440
-     * @param $context
441
-     * @return bool|int
442
-     * @throws EE_Error
443
-     * @throws InvalidIdentifierException
444
-     */
445
-    public function activate_context($context)
446
-    {
447
-        $this->validate_context($context);
448
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
449
-    }
450
-
451
-
452
-    /**
453
-     * Returns whether the context is active or not.
454
-     * Note, this will default to true if the extra meta record doesn't exist.
455
-     * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
456
-     * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
457
-     * whether a context is "active" or not.
458
-     *
459
-     * @param $context
460
-     * @return bool
461
-     * @throws EE_Error
462
-     * @throws InvalidIdentifierException
463
-     */
464
-    public function is_context_active($context)
465
-    {
466
-        $this->validate_context($context);
467
-        return filter_var(
468
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
469
-            FILTER_VALIDATE_BOOLEAN
470
-        );
471
-    }
472
-
473
-
474
-    /**
475
-     * Validates the incoming context to verify it matches a registered context for the related message type.
476
-     *
477
-     * @param string $context
478
-     * @throws EE_Error
479
-     * @throws InvalidIdentifierException
480
-     */
481
-    public function validate_context($context)
482
-    {
483
-        $contexts = $this->contexts_config();
484
-        if (! isset($contexts[ $context ])) {
485
-            throw new InvalidIdentifierException(
486
-                '',
487
-                '',
488
-                sprintf(
489
-                    esc_html__(
490
-                        'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
491
-                        'event_espresso'
492
-                    ),
493
-                    $context,
494
-                    implode(',', array_keys($contexts))
495
-                )
496
-            );
497
-        }
498
-    }
16
+	/**
17
+	 * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
18
+	 */
19
+	const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
20
+
21
+	/**
22
+	 * @param array  $props_n_values
23
+	 * @param string $timezone
24
+	 * @return EE_Message_Template_Group|mixed
25
+	 * @throws EE_Error
26
+	 */
27
+	public static function new_instance($props_n_values = array(), $timezone = '')
28
+	{
29
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
30
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
31
+	}
32
+
33
+
34
+	/**
35
+	 * @param array  $props_n_values
36
+	 * @param string $timezone
37
+	 * @return EE_Message_Template_Group
38
+	 */
39
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
40
+	{
41
+		return new self($props_n_values, true, $timezone);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @param bool $message_type
47
+	 * @throws EE_Error
48
+	 */
49
+	public function set_message_type($message_type = false)
50
+	{
51
+		if (! $message_type) {
52
+			throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53
+		}
54
+		$this->set('MTP_message_type', $message_type);
55
+	}
56
+
57
+
58
+	/**
59
+	 * @param bool $messenger
60
+	 * @throws EE_Error
61
+	 */
62
+	public function set_messenger($messenger = false)
63
+	{
64
+		if (! $messenger) {
65
+			throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66
+		}
67
+		$this->set('MTP_messenger', $messenger);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param bool $GRP_ID
73
+	 * @throws EE_Error
74
+	 */
75
+	public function set_group_template_id($GRP_ID = false)
76
+	{
77
+		if (! $GRP_ID) {
78
+			throw new EE_Error(
79
+				esc_html__(
80
+					'Missing required value for the message template group id',
81
+					'event_espresso'
82
+				)
83
+			);
84
+		}
85
+		$this->set('GRP_ID', $GRP_ID);
86
+	}
87
+
88
+
89
+	/**
90
+	 * get Group ID
91
+	 *
92
+	 * @access public
93
+	 * @return int
94
+	 * @throws EE_Error
95
+	 */
96
+	public function GRP_ID()
97
+	{
98
+		return $this->get('GRP_ID');
99
+	}
100
+
101
+
102
+	/**
103
+	 * get User ID
104
+	 *
105
+	 * @access public
106
+	 * @return int
107
+	 * @throws EE_Error
108
+	 */
109
+	public function user()
110
+	{
111
+		$user_id = $this->get('MTP_user_id');
112
+		return empty($user_id) ? get_current_user_id() : $user_id;
113
+	}
114
+
115
+
116
+	/**
117
+	 * Wrapper for the user function() (preserve backward compat)
118
+	 *
119
+	 * @since  4.5.0
120
+	 * @return int
121
+	 * @throws EE_Error
122
+	 */
123
+	public function wp_user()
124
+	{
125
+		return $this->user();
126
+	}
127
+
128
+
129
+	/**
130
+	 * This simply returns a count of all related events to this message template group
131
+	 *
132
+	 * @return int
133
+	 */
134
+	public function count_events()
135
+	{
136
+		return $this->count_related('Event');
137
+	}
138
+
139
+
140
+	/**
141
+	 * returns the name saved in the db for this template
142
+	 *
143
+	 * @return string
144
+	 * @throws EE_Error
145
+	 */
146
+	public function name()
147
+	{
148
+		return $this->get('MTP_name');
149
+	}
150
+
151
+
152
+	/**
153
+	 * Returns the description saved in the db for this template group
154
+	 *
155
+	 * @return string
156
+	 * @throws EE_Error
157
+	 */
158
+	public function description()
159
+	{
160
+		return $this->get('MTP_description');
161
+	}
162
+
163
+
164
+	/**
165
+	 * returns all related EE_Message_Template objects
166
+	 *
167
+	 * @param  array $query_params like EEM_Base::get_all()
168
+	 * @return EE_Message_Template[]
169
+	 * @throws EE_Error
170
+	 */
171
+	public function message_templates($query_params = array())
172
+	{
173
+		return $this->get_many_related('Message_Template', $query_params);
174
+	}
175
+
176
+
177
+	/**
178
+	 * get Message Messenger
179
+	 *
180
+	 * @access public
181
+	 * @return string
182
+	 * @throws EE_Error
183
+	 */
184
+	public function messenger()
185
+	{
186
+		return $this->get('MTP_messenger');
187
+	}
188
+
189
+
190
+	/**
191
+	 * get Message Messenger OBJECT
192
+	 * If an attempt to get the corresponding messenger object fails, then we set this message
193
+	 * template group to inactive, and save to db.  Then return null so client code can handle
194
+	 * appropriately.
195
+	 *
196
+	 * @return EE_messenger
197
+	 * @throws EE_Error
198
+	 */
199
+	public function messenger_obj()
200
+	{
201
+		$messenger = $this->messenger();
202
+		try {
203
+			$messenger = EEH_MSG_Template::messenger_obj($messenger);
204
+		} catch (EE_Error $e) {
205
+			// if an exception was thrown then let's deactivate this message template group because it means there is no
206
+			// class for this messenger in this group.
207
+			$this->set('MTP_is_active', false);
208
+			$this->save();
209
+			return null;
210
+		}
211
+		return $messenger;
212
+	}
213
+
214
+
215
+	/**
216
+	 * get Message Type
217
+	 *
218
+	 * @access public
219
+	 * @return string
220
+	 * @throws EE_Error
221
+	 */
222
+	public function message_type()
223
+	{
224
+		return $this->get('MTP_message_type');
225
+	}
226
+
227
+
228
+	/**
229
+	 * get Message type OBJECT
230
+	 * If an attempt to get the corresponding message type object fails, then we set this message
231
+	 * template group to inactive, and save to db.  Then return null so client code can handle
232
+	 * appropriately.
233
+	 *
234
+	 * @throws EE_Error
235
+	 * @return EE_message_type|false if exception thrown.
236
+	 */
237
+	public function message_type_obj()
238
+	{
239
+		$message_type = $this->message_type();
240
+		try {
241
+			$message_type = EEH_MSG_Template::message_type_obj($message_type);
242
+		} catch (EE_Error $e) {
243
+			// if an exception was thrown then let's deactivate this message template group because it means there is no
244
+			// class for the message type in this group.
245
+			$this->set('MTP_is_active', false);
246
+			$this->save();
247
+			return null;
248
+		}
249
+		return $message_type;
250
+	}
251
+
252
+
253
+	/**
254
+	 * @return array
255
+	 * @throws EE_Error
256
+	 */
257
+	public function contexts_config()
258
+	{
259
+		return $this->message_type_obj()->get_contexts();
260
+	}
261
+
262
+
263
+	/**
264
+	 * This returns the context_label for contexts as set in the message type object
265
+	 * Note this is an array with singular and plural keys
266
+	 *
267
+	 * @access public
268
+	 * @return array labels for "context"
269
+	 * @throws EE_Error
270
+	 */
271
+	public function context_label()
272
+	{
273
+		$obj = $this->message_type_obj();
274
+		return $obj->get_context_label();
275
+	}
276
+
277
+
278
+	/**
279
+	 * This returns an array of EE_Message_Template objects indexed by context and field.
280
+	 *
281
+	 * @return array ()
282
+	 * @throws EE_Error
283
+	 */
284
+	public function context_templates()
285
+	{
286
+		$mtps_arr = array();
287
+		$mtps = $this->get_many_related('Message_Template');
288
+		if (empty($mtps)) {
289
+			return array();
290
+		}
291
+		// note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292
+		foreach ($mtps as $mtp) {
293
+			$mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
294
+		}
295
+		return $mtps_arr;
296
+	}
297
+
298
+
299
+	/**
300
+	 * this returns if the template group this template belongs to is global
301
+	 *
302
+	 * @return bool true if it is, false if it isn't
303
+	 * @throws EE_Error
304
+	 */
305
+	public function is_global()
306
+	{
307
+		return $this->get('MTP_is_global');
308
+	}
309
+
310
+
311
+	/**
312
+	 * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
313
+	 *
314
+	 * @return bool true if it is, false if it isn't
315
+	 * @throws EE_Error
316
+	 */
317
+	public function is_active()
318
+	{
319
+		return $this->get('MTP_is_active');
320
+	}
321
+
322
+
323
+	/**
324
+	 * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
325
+	 * this template.
326
+	 *
327
+	 * @since 4.3.0
328
+	 * @uses  EEH_MSG_Template::get_shortcodes()
329
+	 * @param string $context what context we're going to return shortcodes for
330
+	 * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
331
+	 *                        to be returned.
332
+	 * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
333
+	 *                        unique shortcodes for all the given (or all) fields.
334
+	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
335
+	 *                        shortcodes found.
336
+	 * @throws EE_Error
337
+	 */
338
+	public function get_shortcodes($context, $fields = array(), $merged = false)
339
+	{
340
+		$messenger = $this->messenger();
341
+		$message_type = $this->message_type();
342
+		return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
343
+	}
344
+
345
+
346
+	/**
347
+	 * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
348
+	 * use the default template pack.
349
+	 *
350
+	 * @since 4.5.0
351
+	 * @return string
352
+	 * @throws EE_Error
353
+	 */
354
+	public function get_template_pack_name()
355
+	{
356
+		return $this->get_extra_meta('MTP_template_pack', true, 'default');
357
+	}
358
+
359
+
360
+	/**
361
+	 * This returns the specific template pack object referenced by the template pack name attached to this message
362
+	 * template group.  If no template pack is assigned then the default template pack is retrieved.
363
+	 *
364
+	 * @since 4.5.0
365
+	 * @return EE_Messages_Template_Pack
366
+	 * @throws EE_Error
367
+	 * @throws InvalidArgumentException
368
+	 * @throws ReflectionException
369
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
370
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
371
+	 */
372
+	public function get_template_pack()
373
+	{
374
+		$pack_name = $this->get_template_pack_name();
375
+		EE_Registry::instance()->load_helper('MSG_Template');
376
+		return EEH_MSG_Template::get_template_pack($pack_name);
377
+	}
378
+
379
+
380
+	/**
381
+	 * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
382
+	 * use the default template variation.
383
+	 *
384
+	 * @since 4.5.0
385
+	 * @return string
386
+	 * @throws EE_Error
387
+	 */
388
+	public function get_template_pack_variation()
389
+	{
390
+		return $this->get_extra_meta('MTP_variation', true, 'default');
391
+	}
392
+
393
+
394
+	/**
395
+	 * This just sets the template pack name attached to this message template group.
396
+	 *
397
+	 * @since 4.5.0
398
+	 * @param string $template_pack_name What message template pack is assigned.
399
+	 * @return int
400
+	 * @throws EE_Error
401
+	 */
402
+	public function set_template_pack_name($template_pack_name)
403
+	{
404
+		return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
405
+	}
406
+
407
+
408
+	/**
409
+	 * This just sets the template pack variation attached to this message template group.
410
+	 *
411
+	 * @since 4.5.0
412
+	 * @param string $variation What variation is being set on the message template group.
413
+	 * @return int
414
+	 * @throws EE_Error
415
+	 */
416
+	public function set_template_pack_variation($variation)
417
+	{
418
+		return $this->update_extra_meta('MTP_variation', $variation);
419
+	}
420
+
421
+
422
+	/**
423
+	 * Deactivates the given context.
424
+	 *
425
+	 * @param $context
426
+	 * @return bool|int
427
+	 * @throws EE_Error
428
+	 * @throws InvalidIdentifierException
429
+	 */
430
+	public function deactivate_context($context)
431
+	{
432
+		$this->validate_context($context);
433
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
434
+	}
435
+
436
+
437
+	/**
438
+	 * Activates the given context.
439
+	 *
440
+	 * @param $context
441
+	 * @return bool|int
442
+	 * @throws EE_Error
443
+	 * @throws InvalidIdentifierException
444
+	 */
445
+	public function activate_context($context)
446
+	{
447
+		$this->validate_context($context);
448
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
449
+	}
450
+
451
+
452
+	/**
453
+	 * Returns whether the context is active or not.
454
+	 * Note, this will default to true if the extra meta record doesn't exist.
455
+	 * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
456
+	 * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
457
+	 * whether a context is "active" or not.
458
+	 *
459
+	 * @param $context
460
+	 * @return bool
461
+	 * @throws EE_Error
462
+	 * @throws InvalidIdentifierException
463
+	 */
464
+	public function is_context_active($context)
465
+	{
466
+		$this->validate_context($context);
467
+		return filter_var(
468
+			$this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
469
+			FILTER_VALIDATE_BOOLEAN
470
+		);
471
+	}
472
+
473
+
474
+	/**
475
+	 * Validates the incoming context to verify it matches a registered context for the related message type.
476
+	 *
477
+	 * @param string $context
478
+	 * @throws EE_Error
479
+	 * @throws InvalidIdentifierException
480
+	 */
481
+	public function validate_context($context)
482
+	{
483
+		$contexts = $this->contexts_config();
484
+		if (! isset($contexts[ $context ])) {
485
+			throw new InvalidIdentifierException(
486
+				'',
487
+				'',
488
+				sprintf(
489
+					esc_html__(
490
+						'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
491
+						'event_espresso'
492
+					),
493
+					$context,
494
+					implode(',', array_keys($contexts))
495
+				)
496
+			);
497
+		}
498
+	}
499 499
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function set_message_type($message_type = false)
50 50
     {
51
-        if (! $message_type) {
51
+        if ( ! $message_type) {
52 52
             throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
53 53
         }
54 54
         $this->set('MTP_message_type', $message_type);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function set_messenger($messenger = false)
63 63
     {
64
-        if (! $messenger) {
64
+        if ( ! $messenger) {
65 65
             throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
66 66
         }
67 67
         $this->set('MTP_messenger', $messenger);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function set_group_template_id($GRP_ID = false)
76 76
     {
77
-        if (! $GRP_ID) {
77
+        if ( ! $GRP_ID) {
78 78
             throw new EE_Error(
79 79
                 esc_html__(
80 80
                     'Missing required value for the message template group id',
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         }
291 291
         // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
292 292
         foreach ($mtps as $mtp) {
293
-            $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp;
293
+            $mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
294 294
         }
295 295
         return $mtps_arr;
296 296
     }
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     public function deactivate_context($context)
431 431
     {
432 432
         $this->validate_context($context);
433
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
433
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, false);
434 434
     }
435 435
 
436 436
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     public function activate_context($context)
446 446
     {
447 447
         $this->validate_context($context);
448
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
448
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true);
449 449
     }
450 450
 
451 451
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     {
466 466
         $this->validate_context($context);
467 467
         return filter_var(
468
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
468
+            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true, true),
469 469
             FILTER_VALIDATE_BOOLEAN
470 470
         );
471 471
     }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     public function validate_context($context)
482 482
     {
483 483
         $contexts = $this->contexts_config();
484
-        if (! isset($contexts[ $context ])) {
484
+        if ( ! isset($contexts[$context])) {
485 485
             throw new InvalidIdentifierException(
486 486
                 '',
487 487
                 '',
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template.class.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -13,173 +13,173 @@
 block discarded – undo
13 13
 class EE_Message_Template extends EE_Base_Class
14 14
 {
15 15
 
16
-    /**
17
-     * @param array  $props_n_values
18
-     * @param string $timezone
19
-     * @return EE_Message_Template|mixed
20
-     */
21
-    public static function new_instance($props_n_values = array(), $timezone = '')
22
-    {
23
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
24
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
25
-    }
26
-
27
-
28
-    /**
29
-     * @param array  $props_n_values
30
-     * @param string $timezone
31
-     * @return EE_Message_Template
32
-     */
33
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
34
-    {
35
-        return new self($props_n_values, true, $timezone);
36
-    }
37
-
38
-
39
-    /**
40
-     * @param bool $GRP_ID
41
-     * @throws EE_Error
42
-     */
43
-    public function set_group_template_id($GRP_ID = false)
44
-    {
45
-        if (! $GRP_ID) {
46
-            throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso'));
47
-        }
48
-        $this->set('GRP_ID', $GRP_ID);
49
-    }
50
-
51
-
52
-    /**
53
-     * get Group ID
54
-     *
55
-     * @access public
56
-     * @return int
57
-     */
58
-    public function GRP_ID()
59
-    {
60
-        return $this->get('GRP_ID');
61
-    }
62
-
63
-
64
-    /**
65
-     * get User ID
66
-     *
67
-     * @access public
68
-     * @return int
69
-     */
70
-    public function user()
71
-    {
72
-        return $this->get_first_related('Message_Template_Group')->get('MTP_user_id');
73
-    }
74
-
75
-
76
-    /**
77
-     * get Message Messenger
78
-     *
79
-     * @access public
80
-     * @return string
81
-     */
82
-    public function messenger()
83
-    {
84
-        return $this->get_first_related('Message_Template_Group')->messenger();
85
-    }
86
-
87
-
88
-    /**
89
-     * get Message Messenger OBJECT
90
-     *
91
-     * @access public
92
-     * @return object Messenger Object for the given messenger
93
-     */
94
-    public function messenger_obj()
95
-    {
96
-        return $this->get_first_related('Message_Template_Group')->messenger_obj();
97
-    }
98
-
99
-
100
-    /**
101
-     * get Message Type
102
-     *
103
-     * @access public
104
-     * @return string
105
-     */
106
-    public function message_type()
107
-    {
108
-        return $this->get_first_related('Message_Template_Group')->message_type();
109
-    }
110
-
111
-
112
-    /**
113
-     * get Message type OBJECT
114
-     *
115
-     * @access public
116
-     * @return object  Message Type object for the given message type
117
-     */
118
-    public function message_type_obj()
119
-    {
120
-        return $this->get_first_related('Message_Template_Group')->message_type_obj();
121
-    }
122
-
123
-
124
-    /**
125
-     * This returns the set context array configured in the message type object
126
-     *
127
-     * @access public
128
-     * @return array array of contexts and their configuration.
129
-     */
130
-    public function contexts_config()
131
-    {
132
-        return $this->get_first_related('Message_Template_Group')->contexts_config();
133
-    }
134
-
135
-
136
-    /**
137
-     * This returns the context_label for contexts as set in the message type object
138
-     *
139
-     * @access public
140
-     * @return string label for "context"
141
-     */
142
-    public function context_label()
143
-    {
144
-        return $this->get_first_related('Message_Template_Group')->context_label();
145
-    }
146
-
147
-
148
-    /**
149
-     * this returns if the template group this template belongs to is global
150
-     *
151
-     * @return boolean true if it is, false if it isn't
152
-     */
153
-    public function is_global()
154
-    {
155
-        return $this->get_first_related('Message_Template_Group')->is_global();
156
-    }
157
-
158
-
159
-    /**
160
-     * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
161
-     *
162
-     * @return boolean true if it is, false if it isn't
163
-     */
164
-    public function is_active()
165
-    {
166
-        return $this->get_first_related('Message_Template_Group')->is_active();
167
-    }
168
-
169
-
170
-    /**
171
-     * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
172
-     * this template.
173
-     *
174
-     * @access public
175
-     * @param string $context what context we're going to return shortcodes for
176
-     * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
177
-     *                        to be merged and returned.
178
-     * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
179
-     *               shortcodes found.
180
-     */
181
-    public function get_shortcodes($context, $fields = array())
182
-    {
183
-        return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields);
184
-    }
16
+	/**
17
+	 * @param array  $props_n_values
18
+	 * @param string $timezone
19
+	 * @return EE_Message_Template|mixed
20
+	 */
21
+	public static function new_instance($props_n_values = array(), $timezone = '')
22
+	{
23
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
24
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
25
+	}
26
+
27
+
28
+	/**
29
+	 * @param array  $props_n_values
30
+	 * @param string $timezone
31
+	 * @return EE_Message_Template
32
+	 */
33
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
34
+	{
35
+		return new self($props_n_values, true, $timezone);
36
+	}
37
+
38
+
39
+	/**
40
+	 * @param bool $GRP_ID
41
+	 * @throws EE_Error
42
+	 */
43
+	public function set_group_template_id($GRP_ID = false)
44
+	{
45
+		if (! $GRP_ID) {
46
+			throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso'));
47
+		}
48
+		$this->set('GRP_ID', $GRP_ID);
49
+	}
50
+
51
+
52
+	/**
53
+	 * get Group ID
54
+	 *
55
+	 * @access public
56
+	 * @return int
57
+	 */
58
+	public function GRP_ID()
59
+	{
60
+		return $this->get('GRP_ID');
61
+	}
62
+
63
+
64
+	/**
65
+	 * get User ID
66
+	 *
67
+	 * @access public
68
+	 * @return int
69
+	 */
70
+	public function user()
71
+	{
72
+		return $this->get_first_related('Message_Template_Group')->get('MTP_user_id');
73
+	}
74
+
75
+
76
+	/**
77
+	 * get Message Messenger
78
+	 *
79
+	 * @access public
80
+	 * @return string
81
+	 */
82
+	public function messenger()
83
+	{
84
+		return $this->get_first_related('Message_Template_Group')->messenger();
85
+	}
86
+
87
+
88
+	/**
89
+	 * get Message Messenger OBJECT
90
+	 *
91
+	 * @access public
92
+	 * @return object Messenger Object for the given messenger
93
+	 */
94
+	public function messenger_obj()
95
+	{
96
+		return $this->get_first_related('Message_Template_Group')->messenger_obj();
97
+	}
98
+
99
+
100
+	/**
101
+	 * get Message Type
102
+	 *
103
+	 * @access public
104
+	 * @return string
105
+	 */
106
+	public function message_type()
107
+	{
108
+		return $this->get_first_related('Message_Template_Group')->message_type();
109
+	}
110
+
111
+
112
+	/**
113
+	 * get Message type OBJECT
114
+	 *
115
+	 * @access public
116
+	 * @return object  Message Type object for the given message type
117
+	 */
118
+	public function message_type_obj()
119
+	{
120
+		return $this->get_first_related('Message_Template_Group')->message_type_obj();
121
+	}
122
+
123
+
124
+	/**
125
+	 * This returns the set context array configured in the message type object
126
+	 *
127
+	 * @access public
128
+	 * @return array array of contexts and their configuration.
129
+	 */
130
+	public function contexts_config()
131
+	{
132
+		return $this->get_first_related('Message_Template_Group')->contexts_config();
133
+	}
134
+
135
+
136
+	/**
137
+	 * This returns the context_label for contexts as set in the message type object
138
+	 *
139
+	 * @access public
140
+	 * @return string label for "context"
141
+	 */
142
+	public function context_label()
143
+	{
144
+		return $this->get_first_related('Message_Template_Group')->context_label();
145
+	}
146
+
147
+
148
+	/**
149
+	 * this returns if the template group this template belongs to is global
150
+	 *
151
+	 * @return boolean true if it is, false if it isn't
152
+	 */
153
+	public function is_global()
154
+	{
155
+		return $this->get_first_related('Message_Template_Group')->is_global();
156
+	}
157
+
158
+
159
+	/**
160
+	 * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
161
+	 *
162
+	 * @return boolean true if it is, false if it isn't
163
+	 */
164
+	public function is_active()
165
+	{
166
+		return $this->get_first_related('Message_Template_Group')->is_active();
167
+	}
168
+
169
+
170
+	/**
171
+	 * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
172
+	 * this template.
173
+	 *
174
+	 * @access public
175
+	 * @param string $context what context we're going to return shortcodes for
176
+	 * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
177
+	 *                        to be merged and returned.
178
+	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
179
+	 *               shortcodes found.
180
+	 */
181
+	public function get_shortcodes($context, $fields = array())
182
+	{
183
+		return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields);
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
      */
43 43
     public function set_group_template_id($GRP_ID = false)
44 44
     {
45
-        if (! $GRP_ID) {
45
+        if ( ! $GRP_ID) {
46 46
             throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso'));
47 47
         }
48 48
         $this->set('GRP_ID', $GRP_ID);
Please login to merge, or discard this patch.