Completed
Branch BUG/fix-ee-rest-debug-headers (1355bc)
by
unknown
03:29 queued 18s
created
payment_methods/Check/EE_PMT_Check.pm.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         $this->_pretty_name = esc_html__("Check", 'event_espresso');
23 23
         $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
24 24
         parent::__construct($pm_instance);
25
-        $this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
25
+        $this->_default_button_url = $this->file_url().'lib/check-logo.png';
26 26
     }
27 27
 
28 28
 
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
49 49
             $organization = EE_Registry::instance()->CFG->organization;
50 50
             $organization_name = $organization->get_pretty('name');
51
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
52
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
+            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : '';
52
+            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : '';
53 53
             $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
54
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
54
+            $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
55 55
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
56
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
57
-            $default_address .=  $state ? $state->name() . '<br />' : '';
58
-            $default_address .= $country ? $country->name() . '<br />' : '';
56
+            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO);
57
+            $default_address .= $state ? $state->name().'<br />' : '';
58
+            $default_address .= $country ? $country->name().'<br />' : '';
59 59
             $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
60 60
         } else {
61 61
             $default_address = 'unknown';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 'payment_instructions' => new EE_Text_Area_Input(array(
71 71
                     'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
72 72
                     'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
73
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
73
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
74 74
                 )),
75 75
                 'payable_to' => new EE_Text_Input(array(
76 76
                     'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 'address_to_send_payment' => new EE_Text_Area_Input(array(
80 80
                     'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
81 81
                     'default' => $default_address,
82
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
82
+                    'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
83 83
                 )),
84 84
             ),
85 85
             'exclude' => array('PMD_debug_mode')
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -11,121 +11,121 @@
 block discarded – undo
11 11
  */
12 12
 class EE_PMT_Check extends EE_PMT_Base
13 13
 {
14
-    /**
15
-     * @param null $pm_instance
16
-     * @return EE_PMT_Check
17
-     */
18
-    public function __construct($pm_instance = null)
19
-    {
20
-        $this->_pretty_name = esc_html__("Check", 'event_espresso');
21
-        $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
22
-        parent::__construct($pm_instance);
23
-        $this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
24
-    }
14
+	/**
15
+	 * @param null $pm_instance
16
+	 * @return EE_PMT_Check
17
+	 */
18
+	public function __construct($pm_instance = null)
19
+	{
20
+		$this->_pretty_name = esc_html__("Check", 'event_espresso');
21
+		$this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso');
22
+		parent::__construct($pm_instance);
23
+		$this->_default_button_url = $this->file_url() . 'lib/check-logo.png';
24
+	}
25 25
 
26 26
 
27 27
 
28
-    /**
29
-     * Creates the billing form for this payment method type
30
-     * @param \EE_Transaction $transaction
31
-     * @return NULL
32
-     */
33
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
34
-    {
35
-        return null;
36
-    }
28
+	/**
29
+	 * Creates the billing form for this payment method type
30
+	 * @param \EE_Transaction $transaction
31
+	 * @return NULL
32
+	 */
33
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
34
+	{
35
+		return null;
36
+	}
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * Overrides parent to dynamically set some defaults, but only when the form is requested
42
-     * @return EE_Form_Section_Proper
43
-     */
44
-    public function generate_new_settings_form()
45
-    {
46
-        if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
47
-            $organization = EE_Registry::instance()->CFG->organization;
48
-            $organization_name = $organization->get_pretty('name');
49
-            $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
50
-            $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
-            $default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
52
-            $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
53
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
54
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
55
-            $default_address .=  $state ? $state->name() . '<br />' : '';
56
-            $default_address .= $country ? $country->name() . '<br />' : '';
57
-            $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
58
-        } else {
59
-            $default_address = 'unknown';
60
-            $organization_name = 'unknown';
61
-        }
62
-            return new EE_Payment_Method_Form(array(
63
-            'extra_meta_inputs' => array(
64
-                'check_title' => new EE_Text_Input(array(
65
-                    'html_label_text' =>  sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()),
66
-                    'default' =>  esc_html__("Check/Money Order Payments", 'event_espresso'),
67
-                )),
68
-                'payment_instructions' => new EE_Text_Area_Input(array(
69
-                    'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
70
-                    'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
71
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
72
-                )),
73
-                'payable_to' => new EE_Text_Input(array(
74
-                    'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
75
-                    'default' => $organization_name
76
-                )),
77
-                'address_to_send_payment' => new EE_Text_Area_Input(array(
78
-                    'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
79
-                    'default' => $default_address,
80
-                    'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
81
-                )),
82
-            ),
83
-            'exclude' => array('PMD_debug_mode')
84
-            ));
85
-    }
40
+	/**
41
+	 * Overrides parent to dynamically set some defaults, but only when the form is requested
42
+	 * @return EE_Form_Section_Proper
43
+	 */
44
+	public function generate_new_settings_form()
45
+	{
46
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
47
+			$organization = EE_Registry::instance()->CFG->organization;
48
+			$organization_name = $organization->get_pretty('name');
49
+			$default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : '';
50
+			$default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : '';
51
+			$default_address .= $organization->city != '' ? $organization->get_pretty('city') : '';
52
+			$default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />';
53
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
54
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ;
55
+			$default_address .=  $state ? $state->name() . '<br />' : '';
56
+			$default_address .= $country ? $country->name() . '<br />' : '';
57
+			$default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : '';
58
+		} else {
59
+			$default_address = 'unknown';
60
+			$organization_name = 'unknown';
61
+		}
62
+			return new EE_Payment_Method_Form(array(
63
+			'extra_meta_inputs' => array(
64
+				'check_title' => new EE_Text_Input(array(
65
+					'html_label_text' =>  sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()),
66
+					'default' =>  esc_html__("Check/Money Order Payments", 'event_espresso'),
67
+				)),
68
+				'payment_instructions' => new EE_Text_Area_Input(array(
69
+					'html_label_text' =>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
70
+					'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'),
71
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
72
+				)),
73
+				'payable_to' => new EE_Text_Input(array(
74
+					'html_label_text' =>  sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()),
75
+					'default' => $organization_name
76
+				)),
77
+				'address_to_send_payment' => new EE_Text_Area_Input(array(
78
+					'html_label_text' =>  sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()),
79
+					'default' => $default_address,
80
+					'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
81
+				)),
82
+			),
83
+			'exclude' => array('PMD_debug_mode')
84
+			));
85
+	}
86 86
 
87 87
 
88 88
 
89
-    /**
90
-     * Adds the help tab
91
-     * @see EE_PMT_Base::help_tabs_config()
92
-     * @return array
93
-     */
94
-    public function help_tabs_config()
95
-    {
96
-        return array(
97
-            $this->get_help_tab_name() => array(
98
-                        'title' => esc_html__('Check Settings', 'event_espresso'),
99
-                        'filename' => 'payment_methods_overview_check'
100
-                        ),
101
-        );
102
-    }
89
+	/**
90
+	 * Adds the help tab
91
+	 * @see EE_PMT_Base::help_tabs_config()
92
+	 * @return array
93
+	 */
94
+	public function help_tabs_config()
95
+	{
96
+		return array(
97
+			$this->get_help_tab_name() => array(
98
+						'title' => esc_html__('Check Settings', 'event_espresso'),
99
+						'filename' => 'payment_methods_overview_check'
100
+						),
101
+		);
102
+	}
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * For adding any html output ab ove the payment overview.
108
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
109
-     * Other gateways may want to override this, such as offline gateways.
110
-     * @return string
111
-     */
112
-    public function payment_overview_content(EE_Payment $payment)
113
-    {
114
-        $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
115
-        $template_vars = array_merge(
116
-            array(
117
-                            'payment_method' => $this->_pm_instance,
118
-                            'payment' => $payment,
119
-                            'check_title' => '',
120
-                            'payment_instructions' => '',
121
-                            'payable_to' => '',
122
-                            'address_to_send_payment' => '',
123
-                            ),
124
-            $extra_meta_for_payment_method
125
-        );
126
-        return EEH_Template::locate_template(
127
-            'payment_methods/Check/templates/check_payment_details_content.template.php',
128
-            $template_vars
129
-        );
130
-    }
106
+	/**
107
+	 * For adding any html output ab ove the payment overview.
108
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
109
+	 * Other gateways may want to override this, such as offline gateways.
110
+	 * @return string
111
+	 */
112
+	public function payment_overview_content(EE_Payment $payment)
113
+	{
114
+		$extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array();
115
+		$template_vars = array_merge(
116
+			array(
117
+							'payment_method' => $this->_pm_instance,
118
+							'payment' => $payment,
119
+							'check_title' => '',
120
+							'payment_instructions' => '',
121
+							'payable_to' => '',
122
+							'address_to_send_payment' => '',
123
+							),
124
+			$extra_meta_for_payment_method
125
+		);
126
+		return EEH_Template::locate_template(
127
+			'payment_methods/Check/templates/check_payment_details_content.template.php',
128
+			$template_vars
129
+		);
130
+	}
131 131
 }
Please login to merge, or discard this patch.
admin_pages/messages/EE_Message_List_Table.class.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $class = parent::_get_row_class($item);
80 80
         // add status class
81
-        $class .= ' ee-status-strip msg-status-' . $item->STS_ID();
81
+        $class .= ' ee-status-strip msg-status-'.$item->STS_ID();
82 82
         if ($this->_has_checkbox_column) {
83 83
             $class .= ' has-checkbox-column';
84 84
         }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     protected function _add_view_counts()
121 121
     {
122 122
         foreach ($this->_views as $view => $args) {
123
-            $this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
123
+            $this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
124 124
         }
125 125
     }
126 126
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
                                  ),
166 166
                                  admin_url('admin.php')
167 167
                              )
168
-                             . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
169
-        return esc_html($message->to()) . $this->row_actions($actions);
168
+                             . '">'.esc_html__('Delete', 'event_espresso').'</a>';
169
+        return esc_html($message->to()).$this->row_actions($actions);
170 170
     }
171 171
 
172 172
 
@@ -238,23 +238,23 @@  discard block
 block discarded – undo
238 238
         $content = '';
239 239
         switch ($message->STS_ID()) {
240 240
             case EEM_Message::status_sent:
241
-                $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
241
+                $content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction'];
242 242
                 break;
243 243
             case EEM_Message::status_resend:
244
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
244
+                $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
245 245
                 break;
246 246
             case EEM_Message::status_retry:
247
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
247
+                $content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction'];
248 248
                 break;
249 249
             case EEM_Message::status_failed:
250 250
             case EEM_Message::status_debug_only:
251
-                $content = $action_links['error'] . $action_links['view_transaction'];
251
+                $content = $action_links['error'].$action_links['view_transaction'];
252 252
                 break;
253 253
             case EEM_Message::status_idle:
254
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
254
+                $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
255 255
                 break;
256 256
             case EEM_Message::status_incomplete:
257
-                $content = $action_links['generate_now'] . $action_links['view_transaction'];
257
+                $content = $action_links['generate_now'].$action_links['view_transaction'];
258 258
                 break;
259 259
         }
260 260
         return $content;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
          */
296 296
         if (isset($this->_req_data['filterby'])) {
297 297
             $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
298
-            if (! $count) {
298
+            if ( ! $count) {
299 299
                 $query_params['group_by'] = 'MSG_ID';
300 300
             }
301 301
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             );
308 308
         }
309 309
 
310
-        if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
310
+        if ( ! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
311 311
             $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
312 312
                 ? array(
313 313
                     'STS_ID' => array(
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
                 : array('STS_ID' => strtoupper($this->_req_data['status']));
319 319
         }
320 320
 
321
-        if (! $all && ! empty($this->_req_data['s'])) {
322
-            $search_string = '%' . $this->_req_data['s'] . '%';
321
+        if ( ! $all && ! empty($this->_req_data['s'])) {
322
+            $search_string = '%'.$this->_req_data['s'].'%';
323 323
             $query_params[0]['OR'] = array(
324 324
                 'MSG_to'      => array('LIKE', $search_string),
325 325
                 'MSG_from'    => array('LIKE', $search_string),
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         // the messages system is in debug mode.
333 333
         // Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
334 334
         // messages in the database.
335
-        if (! EEM_Message::debug()) {
335
+        if ( ! EEM_Message::debug()) {
336 336
             $query_params[0]['AND*debug_only_conditional'] = array(
337 337
                 'STS_ID' => array('!=', EEM_Message::status_debug_only),
338 338
             );
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         // setup array of messenger options
390 390
         foreach ($active_messages_grouped_by_messenger as $active_message) {
391 391
             if ($active_message instanceof EE_Message) {
392
-                $messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label());
392
+                $messenger_options[$active_message->messenger()] = ucwords($active_message->messenger_label());
393 393
             }
394 394
         }
395 395
         return $this->get_admin_page()->get_messengers_select_input($messenger_options);
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
         // setup array of message type options
412 412
         foreach ($active_messages_grouped_by_message_type as $active_message) {
413 413
             if ($active_message instanceof EE_Message) {
414
-                $message_type_options[ $active_message->message_type() ] = ucwords(
414
+                $message_type_options[$active_message->message_type()] = ucwords(
415 415
                     $active_message->message_type_label()
416 416
                 );
417 417
             }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
                 if ($message_type instanceof EE_message_type) {
438 438
                     foreach ($message_type->get_contexts() as $context => $context_details) {
439 439
                         if (isset($context_details['label'])) {
440
-                            $context_options[ $context ] = $context_details['label'];
440
+                            $context_options[$context] = $context_details['label'];
441 441
                         }
442 442
                     }
443 443
                 }
Please login to merge, or discard this patch.
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -10,437 +10,437 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Message_List_Table extends EE_Admin_List_Table
12 12
 {
13
-    /**
14
-     * @return Messages_Admin_Page
15
-     */
16
-    public function get_admin_page()
17
-    {
18
-        return $this->_admin_page;
19
-    }
20
-
21
-
22
-    protected function _setup_data()
23
-    {
24
-        $this->_data = $this->_get_messages($this->_per_page, $this->_view);
25
-        $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
26
-    }
27
-
28
-
29
-    protected function _set_properties()
30
-    {
31
-        $this->_wp_list_args = array(
32
-            'singular' => esc_html__('Message', 'event_espresso'),
33
-            'plural'   => esc_html__('Messages', 'event_espresso'),
34
-            'ajax'     => true,
35
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
36
-        );
37
-
38
-        $this->_columns = array(
39
-            'cb'           => '<input type="checkbox" />',
40
-            'to'           => esc_html__('To', 'event_espresso'),
41
-            'from'         => esc_html__('From', 'event_espresso'),
42
-            'messenger'    => esc_html__('Messenger', 'event_espresso'),
43
-            'message_type' => esc_html__('Message Type', 'event_espresso'),
44
-            'context'      => esc_html__('Context', 'event_espresso'),
45
-            'modified'     => esc_html__('Modified', 'event_espresso'),
46
-            'action'       => esc_html__('Actions', 'event_espresso'),
47
-            'msg_id'       => esc_html__('ID', 'event_espresso'),
48
-        );
49
-
50
-        $this->_sortable_columns = array(
51
-            'modified'     => array('MSG_modified' => true),
52
-            'message_type' => array('MSG_message_type' => false),
53
-            'messenger'    => array('MSG_messenger' => false),
54
-            'to'           => array('MSG_to' => false),
55
-            'from'         => array('MSG_from' => false),
56
-            'context'      => array('MSG_context' => false),
57
-            'msg_id'       => array('MSG_ID', false),
58
-        );
59
-
60
-        $this->_primary_column = 'to';
61
-
62
-        $this->_hidden_columns = array(
63
-            'msg_id',
64
-        );
65
-    }
66
-
67
-
68
-    /**
69
-     * This simply sets up the row class for the table rows.
70
-     * Allows for easier overriding of child methods for setting up sorting.
71
-     *
72
-     * @param  object $item the current item
73
-     * @return string
74
-     */
75
-    protected function _get_row_class($item)
76
-    {
77
-        $class = parent::_get_row_class($item);
78
-        // add status class
79
-        $class .= ' ee-status-strip msg-status-' . $item->STS_ID();
80
-        if ($this->_has_checkbox_column) {
81
-            $class .= ' has-checkbox-column';
82
-        }
83
-        return $class;
84
-    }
85
-
86
-
87
-    /**
88
-     * _get_table_filters
89
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
90
-     * get's shown in the table.
91
-     *
92
-     * @abstract
93
-     * @access protected
94
-     * @return string
95
-     * @throws \EE_Error
96
-     */
97
-    protected function _get_table_filters()
98
-    {
99
-        $filters = array();
100
-
101
-        // get select_inputs
102
-        $select_inputs = array(
103
-            $this->_get_messengers_dropdown_filter(),
104
-            $this->_get_message_types_dropdown_filter(),
105
-            $this->_get_contexts_for_message_types_dropdown_filter(),
106
-        );
107
-
108
-        // set filters to select inputs if they aren't empty
109
-        foreach ($select_inputs as $select_input) {
110
-            if ($select_input) {
111
-                $filters[] = $select_input;
112
-            }
113
-        }
114
-        return $filters;
115
-    }
116
-
117
-
118
-    protected function _add_view_counts()
119
-    {
120
-        foreach ($this->_views as $view => $args) {
121
-            $this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
122
-        }
123
-    }
124
-
125
-
126
-    /**
127
-     * @param EE_Message $message
128
-     * @return string   checkbox
129
-     * @throws \EE_Error
130
-     */
131
-    public function column_cb($message)
132
-    {
133
-        return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
134
-    }
135
-
136
-
137
-    /**
138
-     * @param EE_Message $message
139
-     * @return string
140
-     * @throws \EE_Error
141
-     */
142
-    public function column_msg_id(EE_Message $message)
143
-    {
144
-        return $message->ID();
145
-    }
146
-
147
-
148
-    /**
149
-     * @param EE_Message $message
150
-     * @return string    The recipient of the message
151
-     * @throws \EE_Error
152
-     */
153
-    public function column_to(EE_Message $message)
154
-    {
155
-        EE_Registry::instance()->load_helper('URL');
156
-        $actions = array();
157
-        $actions['delete'] = '<a href="'
158
-                             . EEH_URL::add_query_args_and_nonce(
159
-                                 array(
160
-                                    'page'   => 'espresso_messages',
161
-                                    'action' => 'delete_ee_message',
162
-                                    'MSG_ID' => $message->ID(),
163
-                                 ),
164
-                                 admin_url('admin.php')
165
-                             )
166
-                             . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
167
-        return esc_html($message->to()) . $this->row_actions($actions);
168
-    }
169
-
170
-
171
-    /**
172
-     * @param EE_Message $message
173
-     * @return string   The sender of the message
174
-     */
175
-    public function column_from(EE_Message $message)
176
-    {
177
-        return esc_html($message->from());
178
-    }
179
-
180
-
181
-    /**
182
-     * @param EE_Message $message
183
-     * @return string  The messenger used to send the message.
184
-     */
185
-    public function column_messenger(EE_Message $message)
186
-    {
187
-        return ucwords($message->messenger_label());
188
-    }
189
-
190
-
191
-    /**
192
-     * @param EE_Message $message
193
-     * @return string  The message type used to generate the message.
194
-     */
195
-    public function column_message_type(EE_Message $message)
196
-    {
197
-        return ucwords($message->message_type_label());
198
-    }
199
-
200
-
201
-    /**
202
-     * @param EE_Message $message
203
-     * @return string  The context the message was generated for.
204
-     */
205
-    public function column_context(EE_Message $message)
206
-    {
207
-        return $message->context_label();
208
-    }
209
-
210
-
211
-    /**
212
-     * @param EE_Message $message
213
-     * @return string    The timestamp when this message was last modified.
214
-     */
215
-    public function column_modified(EE_Message $message)
216
-    {
217
-        return $message->modified();
218
-    }
219
-
220
-
221
-    /**
222
-     * @param EE_Message $message
223
-     * @return string   Actions that can be done on the current message.
224
-     */
225
-    public function column_action(EE_Message $message)
226
-    {
227
-        EE_Registry::instance()->load_helper('MSG_Template');
228
-        $action_links = array(
229
-            'view'                => EEH_MSG_Template::get_message_action_link('view', $message),
230
-            'error'               => EEH_MSG_Template::get_message_action_link('error', $message),
231
-            'generate_now'        => EEH_MSG_Template::get_message_action_link('generate_now', $message),
232
-            'send_now'            => EEH_MSG_Template::get_message_action_link('send_now', $message),
233
-            'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
234
-            'view_transaction'    => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
235
-        );
236
-        $content = '';
237
-        switch ($message->STS_ID()) {
238
-            case EEM_Message::status_sent:
239
-                $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
240
-                break;
241
-            case EEM_Message::status_resend:
242
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
243
-                break;
244
-            case EEM_Message::status_retry:
245
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
246
-                break;
247
-            case EEM_Message::status_failed:
248
-            case EEM_Message::status_debug_only:
249
-                $content = $action_links['error'] . $action_links['view_transaction'];
250
-                break;
251
-            case EEM_Message::status_idle:
252
-                $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
253
-                break;
254
-            case EEM_Message::status_incomplete:
255
-                $content = $action_links['generate_now'] . $action_links['view_transaction'];
256
-                break;
257
-        }
258
-        return $content;
259
-    }
260
-
261
-
262
-    /**
263
-     * Retrieve the EE_Message objects for the list table.
264
-     *
265
-     * @param int    $perpage The number of items per page
266
-     * @param string $view    The view items are being retrieved for
267
-     * @param bool   $count   Whether to just return a count or not.
268
-     * @param bool   $all     Disregard any paging info (no limit on data returned).
269
-     * @return int|EE_Message[]
270
-     * @throws \EE_Error
271
-     */
272
-    protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false)
273
-    {
274
-
275
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
276
-            ? $this->_req_data['paged']
277
-            : 1;
278
-
279
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
280
-            ? $this->_req_data['perpage']
281
-            : $perpage;
282
-
283
-        $offset = ($current_page - 1) * $per_page;
284
-        $limit = $all || $count ? null : array($offset, $per_page);
285
-        $query_params = array(
286
-            'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
287
-            'order'    => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
288
-            'limit'    => $limit,
289
-        );
290
-
291
-        /**
292
-         * Any filters coming in from other routes?
293
-         */
294
-        if (isset($this->_req_data['filterby'])) {
295
-            $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
296
-            if (! $count) {
297
-                $query_params['group_by'] = 'MSG_ID';
298
-            }
299
-        }
300
-
301
-        // view conditionals
302
-        if ($view !== 'all' && $count && $all) {
303
-            $query_params[0]['AND*view_conditional'] = array(
304
-                'STS_ID' => strtoupper($view),
305
-            );
306
-        }
307
-
308
-        if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
309
-            $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
310
-                ? array(
311
-                    'STS_ID' => array(
312
-                        'IN',
313
-                        array(EEM_Message::status_failed, EEM_Message::status_messenger_executing),
314
-                    ),
315
-                )
316
-                : array('STS_ID' => strtoupper($this->_req_data['status']));
317
-        }
318
-
319
-        if (! $all && ! empty($this->_req_data['s'])) {
320
-            $search_string = '%' . $this->_req_data['s'] . '%';
321
-            $query_params[0]['OR'] = array(
322
-                'MSG_to'      => array('LIKE', $search_string),
323
-                'MSG_from'    => array('LIKE', $search_string),
324
-                'MSG_subject' => array('LIKE', $search_string),
325
-                'MSG_content' => array('LIKE', $search_string),
326
-            );
327
-        }
328
-
329
-        // account for debug only status.  We don't show Messages with the EEM_Message::status_debug_only to clients when
330
-        // the messages system is in debug mode.
331
-        // Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
332
-        // messages in the database.
333
-        if (! EEM_Message::debug()) {
334
-            $query_params[0]['AND*debug_only_conditional'] = array(
335
-                'STS_ID' => array('!=', EEM_Message::status_debug_only),
336
-            );
337
-        }
338
-
339
-        // account for filters
340
-        if (
341
-            ! $all
342
-            && isset($this->_req_data['ee_messenger_filter_by'])
343
-            && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
344
-        ) {
345
-            $query_params[0]['AND*messenger_filter'] = array(
346
-                'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'],
347
-            );
348
-        }
349
-        if (
350
-            ! $all
351
-            && ! empty($this->_req_data['ee_message_type_filter_by'])
352
-            && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
353
-        ) {
354
-            $query_params[0]['AND*message_type_filter'] = array(
355
-                'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'],
356
-            );
357
-        }
358
-
359
-        if (
360
-            ! $all
361
-            && ! empty($this->_req_data['ee_context_filter_by'])
362
-            && $this->_req_data['ee_context_filter_by'] !== 'none_selected'
363
-        ) {
364
-            $query_params[0]['AND*context_filter'] = array(
365
-                'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])),
366
-            );
367
-        }
368
-
369
-        return $count
370
-            /** @type int */
371
-            ? EEM_Message::instance()->count($query_params, null, true)
372
-            /** @type EE_Message[] */
373
-            : EEM_Message::instance()->get_all($query_params);
374
-    }
375
-
376
-
377
-    /**
378
-     * Generate dropdown filter select input for messengers.
379
-     *
380
-     * @return string
381
-     */
382
-    protected function _get_messengers_dropdown_filter()
383
-    {
384
-        $messenger_options = array();
385
-        $active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
386
-
387
-        // setup array of messenger options
388
-        foreach ($active_messages_grouped_by_messenger as $active_message) {
389
-            if ($active_message instanceof EE_Message) {
390
-                $messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label());
391
-            }
392
-        }
393
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
394
-    }
395
-
396
-
397
-    /**
398
-     * Generate dropdown filter select input for message types
399
-     *
400
-     * @return string
401
-     */
402
-    protected function _get_message_types_dropdown_filter()
403
-    {
404
-        $message_type_options = array();
405
-        $active_messages_grouped_by_message_type = EEM_Message::instance()->get_all(
406
-            array('group_by' => 'MSG_message_type')
407
-        );
408
-
409
-        // setup array of message type options
410
-        foreach ($active_messages_grouped_by_message_type as $active_message) {
411
-            if ($active_message instanceof EE_Message) {
412
-                $message_type_options[ $active_message->message_type() ] = ucwords(
413
-                    $active_message->message_type_label()
414
-                );
415
-            }
416
-        }
417
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
418
-    }
419
-
420
-
421
-    /**
422
-     * Generate dropdown filter select input for message type contexts
423
-     *
424
-     * @return string
425
-     */
426
-    protected function _get_contexts_for_message_types_dropdown_filter()
427
-    {
428
-        $context_options = array();
429
-        $active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
430
-
431
-        // setup array of context options
432
-        foreach ($active_messages_grouped_by_context as $active_message) {
433
-            if ($active_message instanceof EE_Message) {
434
-                $message_type = $active_message->message_type_object();
435
-                if ($message_type instanceof EE_message_type) {
436
-                    foreach ($message_type->get_contexts() as $context => $context_details) {
437
-                        if (isset($context_details['label'])) {
438
-                            $context_options[ $context ] = $context_details['label'];
439
-                        }
440
-                    }
441
-                }
442
-            }
443
-        }
444
-        return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options);
445
-    }
13
+	/**
14
+	 * @return Messages_Admin_Page
15
+	 */
16
+	public function get_admin_page()
17
+	{
18
+		return $this->_admin_page;
19
+	}
20
+
21
+
22
+	protected function _setup_data()
23
+	{
24
+		$this->_data = $this->_get_messages($this->_per_page, $this->_view);
25
+		$this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
26
+	}
27
+
28
+
29
+	protected function _set_properties()
30
+	{
31
+		$this->_wp_list_args = array(
32
+			'singular' => esc_html__('Message', 'event_espresso'),
33
+			'plural'   => esc_html__('Messages', 'event_espresso'),
34
+			'ajax'     => true,
35
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
36
+		);
37
+
38
+		$this->_columns = array(
39
+			'cb'           => '<input type="checkbox" />',
40
+			'to'           => esc_html__('To', 'event_espresso'),
41
+			'from'         => esc_html__('From', 'event_espresso'),
42
+			'messenger'    => esc_html__('Messenger', 'event_espresso'),
43
+			'message_type' => esc_html__('Message Type', 'event_espresso'),
44
+			'context'      => esc_html__('Context', 'event_espresso'),
45
+			'modified'     => esc_html__('Modified', 'event_espresso'),
46
+			'action'       => esc_html__('Actions', 'event_espresso'),
47
+			'msg_id'       => esc_html__('ID', 'event_espresso'),
48
+		);
49
+
50
+		$this->_sortable_columns = array(
51
+			'modified'     => array('MSG_modified' => true),
52
+			'message_type' => array('MSG_message_type' => false),
53
+			'messenger'    => array('MSG_messenger' => false),
54
+			'to'           => array('MSG_to' => false),
55
+			'from'         => array('MSG_from' => false),
56
+			'context'      => array('MSG_context' => false),
57
+			'msg_id'       => array('MSG_ID', false),
58
+		);
59
+
60
+		$this->_primary_column = 'to';
61
+
62
+		$this->_hidden_columns = array(
63
+			'msg_id',
64
+		);
65
+	}
66
+
67
+
68
+	/**
69
+	 * This simply sets up the row class for the table rows.
70
+	 * Allows for easier overriding of child methods for setting up sorting.
71
+	 *
72
+	 * @param  object $item the current item
73
+	 * @return string
74
+	 */
75
+	protected function _get_row_class($item)
76
+	{
77
+		$class = parent::_get_row_class($item);
78
+		// add status class
79
+		$class .= ' ee-status-strip msg-status-' . $item->STS_ID();
80
+		if ($this->_has_checkbox_column) {
81
+			$class .= ' has-checkbox-column';
82
+		}
83
+		return $class;
84
+	}
85
+
86
+
87
+	/**
88
+	 * _get_table_filters
89
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
90
+	 * get's shown in the table.
91
+	 *
92
+	 * @abstract
93
+	 * @access protected
94
+	 * @return string
95
+	 * @throws \EE_Error
96
+	 */
97
+	protected function _get_table_filters()
98
+	{
99
+		$filters = array();
100
+
101
+		// get select_inputs
102
+		$select_inputs = array(
103
+			$this->_get_messengers_dropdown_filter(),
104
+			$this->_get_message_types_dropdown_filter(),
105
+			$this->_get_contexts_for_message_types_dropdown_filter(),
106
+		);
107
+
108
+		// set filters to select inputs if they aren't empty
109
+		foreach ($select_inputs as $select_input) {
110
+			if ($select_input) {
111
+				$filters[] = $select_input;
112
+			}
113
+		}
114
+		return $filters;
115
+	}
116
+
117
+
118
+	protected function _add_view_counts()
119
+	{
120
+		foreach ($this->_views as $view => $args) {
121
+			$this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
122
+		}
123
+	}
124
+
125
+
126
+	/**
127
+	 * @param EE_Message $message
128
+	 * @return string   checkbox
129
+	 * @throws \EE_Error
130
+	 */
131
+	public function column_cb($message)
132
+	{
133
+		return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param EE_Message $message
139
+	 * @return string
140
+	 * @throws \EE_Error
141
+	 */
142
+	public function column_msg_id(EE_Message $message)
143
+	{
144
+		return $message->ID();
145
+	}
146
+
147
+
148
+	/**
149
+	 * @param EE_Message $message
150
+	 * @return string    The recipient of the message
151
+	 * @throws \EE_Error
152
+	 */
153
+	public function column_to(EE_Message $message)
154
+	{
155
+		EE_Registry::instance()->load_helper('URL');
156
+		$actions = array();
157
+		$actions['delete'] = '<a href="'
158
+							 . EEH_URL::add_query_args_and_nonce(
159
+								 array(
160
+									'page'   => 'espresso_messages',
161
+									'action' => 'delete_ee_message',
162
+									'MSG_ID' => $message->ID(),
163
+								 ),
164
+								 admin_url('admin.php')
165
+							 )
166
+							 . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
167
+		return esc_html($message->to()) . $this->row_actions($actions);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param EE_Message $message
173
+	 * @return string   The sender of the message
174
+	 */
175
+	public function column_from(EE_Message $message)
176
+	{
177
+		return esc_html($message->from());
178
+	}
179
+
180
+
181
+	/**
182
+	 * @param EE_Message $message
183
+	 * @return string  The messenger used to send the message.
184
+	 */
185
+	public function column_messenger(EE_Message $message)
186
+	{
187
+		return ucwords($message->messenger_label());
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param EE_Message $message
193
+	 * @return string  The message type used to generate the message.
194
+	 */
195
+	public function column_message_type(EE_Message $message)
196
+	{
197
+		return ucwords($message->message_type_label());
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param EE_Message $message
203
+	 * @return string  The context the message was generated for.
204
+	 */
205
+	public function column_context(EE_Message $message)
206
+	{
207
+		return $message->context_label();
208
+	}
209
+
210
+
211
+	/**
212
+	 * @param EE_Message $message
213
+	 * @return string    The timestamp when this message was last modified.
214
+	 */
215
+	public function column_modified(EE_Message $message)
216
+	{
217
+		return $message->modified();
218
+	}
219
+
220
+
221
+	/**
222
+	 * @param EE_Message $message
223
+	 * @return string   Actions that can be done on the current message.
224
+	 */
225
+	public function column_action(EE_Message $message)
226
+	{
227
+		EE_Registry::instance()->load_helper('MSG_Template');
228
+		$action_links = array(
229
+			'view'                => EEH_MSG_Template::get_message_action_link('view', $message),
230
+			'error'               => EEH_MSG_Template::get_message_action_link('error', $message),
231
+			'generate_now'        => EEH_MSG_Template::get_message_action_link('generate_now', $message),
232
+			'send_now'            => EEH_MSG_Template::get_message_action_link('send_now', $message),
233
+			'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
234
+			'view_transaction'    => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
235
+		);
236
+		$content = '';
237
+		switch ($message->STS_ID()) {
238
+			case EEM_Message::status_sent:
239
+				$content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
240
+				break;
241
+			case EEM_Message::status_resend:
242
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
243
+				break;
244
+			case EEM_Message::status_retry:
245
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
246
+				break;
247
+			case EEM_Message::status_failed:
248
+			case EEM_Message::status_debug_only:
249
+				$content = $action_links['error'] . $action_links['view_transaction'];
250
+				break;
251
+			case EEM_Message::status_idle:
252
+				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
253
+				break;
254
+			case EEM_Message::status_incomplete:
255
+				$content = $action_links['generate_now'] . $action_links['view_transaction'];
256
+				break;
257
+		}
258
+		return $content;
259
+	}
260
+
261
+
262
+	/**
263
+	 * Retrieve the EE_Message objects for the list table.
264
+	 *
265
+	 * @param int    $perpage The number of items per page
266
+	 * @param string $view    The view items are being retrieved for
267
+	 * @param bool   $count   Whether to just return a count or not.
268
+	 * @param bool   $all     Disregard any paging info (no limit on data returned).
269
+	 * @return int|EE_Message[]
270
+	 * @throws \EE_Error
271
+	 */
272
+	protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false)
273
+	{
274
+
275
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
276
+			? $this->_req_data['paged']
277
+			: 1;
278
+
279
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
280
+			? $this->_req_data['perpage']
281
+			: $perpage;
282
+
283
+		$offset = ($current_page - 1) * $per_page;
284
+		$limit = $all || $count ? null : array($offset, $per_page);
285
+		$query_params = array(
286
+			'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
287
+			'order'    => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
288
+			'limit'    => $limit,
289
+		);
290
+
291
+		/**
292
+		 * Any filters coming in from other routes?
293
+		 */
294
+		if (isset($this->_req_data['filterby'])) {
295
+			$query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
296
+			if (! $count) {
297
+				$query_params['group_by'] = 'MSG_ID';
298
+			}
299
+		}
300
+
301
+		// view conditionals
302
+		if ($view !== 'all' && $count && $all) {
303
+			$query_params[0]['AND*view_conditional'] = array(
304
+				'STS_ID' => strtoupper($view),
305
+			);
306
+		}
307
+
308
+		if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') {
309
+			$query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed
310
+				? array(
311
+					'STS_ID' => array(
312
+						'IN',
313
+						array(EEM_Message::status_failed, EEM_Message::status_messenger_executing),
314
+					),
315
+				)
316
+				: array('STS_ID' => strtoupper($this->_req_data['status']));
317
+		}
318
+
319
+		if (! $all && ! empty($this->_req_data['s'])) {
320
+			$search_string = '%' . $this->_req_data['s'] . '%';
321
+			$query_params[0]['OR'] = array(
322
+				'MSG_to'      => array('LIKE', $search_string),
323
+				'MSG_from'    => array('LIKE', $search_string),
324
+				'MSG_subject' => array('LIKE', $search_string),
325
+				'MSG_content' => array('LIKE', $search_string),
326
+			);
327
+		}
328
+
329
+		// account for debug only status.  We don't show Messages with the EEM_Message::status_debug_only to clients when
330
+		// the messages system is in debug mode.
331
+		// Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only
332
+		// messages in the database.
333
+		if (! EEM_Message::debug()) {
334
+			$query_params[0]['AND*debug_only_conditional'] = array(
335
+				'STS_ID' => array('!=', EEM_Message::status_debug_only),
336
+			);
337
+		}
338
+
339
+		// account for filters
340
+		if (
341
+			! $all
342
+			&& isset($this->_req_data['ee_messenger_filter_by'])
343
+			&& $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
344
+		) {
345
+			$query_params[0]['AND*messenger_filter'] = array(
346
+				'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'],
347
+			);
348
+		}
349
+		if (
350
+			! $all
351
+			&& ! empty($this->_req_data['ee_message_type_filter_by'])
352
+			&& $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
353
+		) {
354
+			$query_params[0]['AND*message_type_filter'] = array(
355
+				'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'],
356
+			);
357
+		}
358
+
359
+		if (
360
+			! $all
361
+			&& ! empty($this->_req_data['ee_context_filter_by'])
362
+			&& $this->_req_data['ee_context_filter_by'] !== 'none_selected'
363
+		) {
364
+			$query_params[0]['AND*context_filter'] = array(
365
+				'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])),
366
+			);
367
+		}
368
+
369
+		return $count
370
+			/** @type int */
371
+			? EEM_Message::instance()->count($query_params, null, true)
372
+			/** @type EE_Message[] */
373
+			: EEM_Message::instance()->get_all($query_params);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Generate dropdown filter select input for messengers.
379
+	 *
380
+	 * @return string
381
+	 */
382
+	protected function _get_messengers_dropdown_filter()
383
+	{
384
+		$messenger_options = array();
385
+		$active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
386
+
387
+		// setup array of messenger options
388
+		foreach ($active_messages_grouped_by_messenger as $active_message) {
389
+			if ($active_message instanceof EE_Message) {
390
+				$messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label());
391
+			}
392
+		}
393
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
394
+	}
395
+
396
+
397
+	/**
398
+	 * Generate dropdown filter select input for message types
399
+	 *
400
+	 * @return string
401
+	 */
402
+	protected function _get_message_types_dropdown_filter()
403
+	{
404
+		$message_type_options = array();
405
+		$active_messages_grouped_by_message_type = EEM_Message::instance()->get_all(
406
+			array('group_by' => 'MSG_message_type')
407
+		);
408
+
409
+		// setup array of message type options
410
+		foreach ($active_messages_grouped_by_message_type as $active_message) {
411
+			if ($active_message instanceof EE_Message) {
412
+				$message_type_options[ $active_message->message_type() ] = ucwords(
413
+					$active_message->message_type_label()
414
+				);
415
+			}
416
+		}
417
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
418
+	}
419
+
420
+
421
+	/**
422
+	 * Generate dropdown filter select input for message type contexts
423
+	 *
424
+	 * @return string
425
+	 */
426
+	protected function _get_contexts_for_message_types_dropdown_filter()
427
+	{
428
+		$context_options = array();
429
+		$active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
430
+
431
+		// setup array of context options
432
+		foreach ($active_messages_grouped_by_context as $active_message) {
433
+			if ($active_message instanceof EE_Message) {
434
+				$message_type = $active_message->message_type_object();
435
+				if ($message_type instanceof EE_message_type) {
436
+					foreach ($message_type->get_contexts() as $context => $context_details) {
437
+						if (isset($context_details['label'])) {
438
+							$context_options[ $context ] = $context_details['label'];
439
+						}
440
+					}
441
+				}
442
+			}
443
+		}
444
+		return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options);
445
+	}
446 446
 }
Please login to merge, or discard this patch.
admin_pages/registrations/qtips/Registration_List_Table_Tips.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
                . esc_html__(
85 85
                    'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
86 86
                    'event_espresso'
87
-               ) . '</p>';
87
+               ).'</p>';
88 88
     }
89 89
 
90 90
 
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class Registration_List_Table_Tips extends EE_Qtip_Config
15 15
 {
16
-    protected function _set_tips_array()
17
-    {
18
-        $this->_qtipsa = array(
19
-            0 => array(
20
-                'content_id' => 'registration-trash-lock',
21
-                'target'     => '.ee-lock-icon',
22
-                'content'    => $this->_registration_trash_message(),
23
-            ),
24
-            /** removing status strips for now because they are triggered anywhere on the row. */
25
-            /**1 => array(
16
+	protected function _set_tips_array()
17
+	{
18
+		$this->_qtipsa = array(
19
+			0 => array(
20
+				'content_id' => 'registration-trash-lock',
21
+				'target'     => '.ee-lock-icon',
22
+				'content'    => $this->_registration_trash_message(),
23
+			),
24
+			/** removing status strips for now because they are triggered anywhere on the row. */
25
+			/**1 => array(
26 26
              * 'content_id' => 'registration-status-' . EEM_Registration::status_id_approved,
27 27
              * 'target' => '.reg-status-' . EEM_Registration::status_id_approved,
28 28
              * 'content' => $this->_registration_status_legend(EEM_Registration::status_id_approved),
@@ -72,37 +72,37 @@  discard block
 block discarded – undo
72 72
              * )
73 73
              * )
74 74
              * )/**/
75
-        );
76
-    }
75
+		);
76
+	}
77 77
 
78 78
 
79
-    private function _registration_trash_message()
80
-    {
81
-        return '<p>'
82
-               . esc_html__(
83
-                   'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
84
-                   'event_espresso'
85
-               ) . '</p>';
86
-    }
79
+	private function _registration_trash_message()
80
+	{
81
+		return '<p>'
82
+			   . esc_html__(
83
+				   'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
84
+				   'event_espresso'
85
+			   ) . '</p>';
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * output the relevant ee-status-legend with the designated status highlighted.
91
-     *
92
-     * @param  EEM_Registration constant $status What status is set (by class)
93
-     * @return string         The status legend with the related status highlighted
94
-     */
95
-    private function _registration_status_legend($status)
96
-    {
89
+	/**
90
+	 * output the relevant ee-status-legend with the designated status highlighted.
91
+	 *
92
+	 * @param  EEM_Registration constant $status What status is set (by class)
93
+	 * @return string         The status legend with the related status highlighted
94
+	 */
95
+	private function _registration_status_legend($status)
96
+	{
97 97
 
98
-        $status_array = array(
99
-            'approved_status' => EEM_Registration::status_id_approved,
100
-            'pending_status' => EEM_Registration::status_id_pending_payment,
101
-            'not_approved' => EEM_Registration::status_id_not_approved,
102
-            'declined_status' => EEM_Registration::status_id_declined,
103
-            'cancelled_status' => EEM_Registration::status_id_cancelled,
104
-        );
98
+		$status_array = array(
99
+			'approved_status' => EEM_Registration::status_id_approved,
100
+			'pending_status' => EEM_Registration::status_id_pending_payment,
101
+			'not_approved' => EEM_Registration::status_id_not_approved,
102
+			'declined_status' => EEM_Registration::status_id_declined,
103
+			'cancelled_status' => EEM_Registration::status_id_cancelled,
104
+		);
105 105
 
106
-        return EEH_Template::status_legend($status_array, $status);
107
-    }
106
+		return EEH_Template::status_legend($status_array, $status);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page_Init.core.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
          * define some events related constants but only if not defined (need to check because unit tests
22 22
          *  may load)
23 23
          */
24
-        if (! defined('EVENTS_PG_SLUG')) {
24
+        if ( ! defined('EVENTS_PG_SLUG')) {
25 25
             define('EVENTS_PG_SLUG', 'espresso_events');
26 26
             define('EVENTS_LABEL', esc_html__('Events', 'event_espresso'));
27
-            define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
28
-            define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
29
-            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
30
-            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
27
+            define('EVENTS_ADMIN', EE_ADMIN_PAGES.'events/');
28
+            define('EVENTS_ADMIN_URL', admin_url('admin.php?page='.EVENTS_PG_SLUG));
29
+            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN.'templates/');
30
+            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'events/assets/');
31 31
         }
32 32
         parent::__construct();
33 33
     }
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -14,42 +14,42 @@
 block discarded – undo
14 14
  */
15 15
 class Events_Admin_Page_Init extends EE_Admin_Page_CPT_Init
16 16
 {
17
-    public function __construct()
18
-    {
19
-        /**
20
-         * define some events related constants but only if not defined (need to check because unit tests
21
-         *  may load)
22
-         */
23
-        if (! defined('EVENTS_PG_SLUG')) {
24
-            define('EVENTS_PG_SLUG', 'espresso_events');
25
-            define('EVENTS_LABEL', esc_html__('Events', 'event_espresso'));
26
-            define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
27
-            define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
28
-            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
29
-            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
30
-        }
31
-        parent::__construct();
32
-    }
17
+	public function __construct()
18
+	{
19
+		/**
20
+		 * define some events related constants but only if not defined (need to check because unit tests
21
+		 *  may load)
22
+		 */
23
+		if (! defined('EVENTS_PG_SLUG')) {
24
+			define('EVENTS_PG_SLUG', 'espresso_events');
25
+			define('EVENTS_LABEL', esc_html__('Events', 'event_espresso'));
26
+			define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
27
+			define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
28
+			define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
29
+			define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
30
+		}
31
+		parent::__construct();
32
+	}
33 33
 
34
-    protected function _set_init_properties()
35
-    {
36
-        $this->label = esc_html__('Event Espresso - Event Details', 'event_espresso');
37
-    }
34
+	protected function _set_init_properties()
35
+	{
36
+		$this->label = esc_html__('Event Espresso - Event Details', 'event_espresso');
37
+	}
38 38
 
39
-    protected function _set_menu_map()
40
-    {
41
-        $this->_menu_map = new EE_Admin_Page_Main_Menu(
42
-            array(
43
-                'menu_group'      => 'main',
44
-                'menu_order'      => 10,
45
-                'subtitle'        => esc_html__('Events', 'event_espresso'),
46
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
-                'parent_slug'     => 'espresso_events',
48
-                'menu_slug'       => 'espresso_events',
49
-                'menu_label'      => esc_html__('Event Espresso', 'event_espresso'),
50
-                'capability'      => 'ee_read_events',
51
-                'admin_init_page' => $this,
52
-            )
53
-        );
54
-    }
39
+	protected function _set_menu_map()
40
+	{
41
+		$this->_menu_map = new EE_Admin_Page_Main_Menu(
42
+			array(
43
+				'menu_group'      => 'main',
44
+				'menu_order'      => 10,
45
+				'subtitle'        => esc_html__('Events', 'event_espresso'),
46
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
+				'parent_slug'     => 'espresso_events',
48
+				'menu_slug'       => 'espresso_events',
49
+				'menu_label'      => esc_html__('Event Espresso', 'event_espresso'),
50
+				'capability'      => 'ee_read_events',
51
+				'admin_init_page' => $this,
52
+			)
53
+		);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
admin_pages/venues/espresso_events_Venues_Hooks.class.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
                 'priority'   => 'high',
38 38
                 'context'    => 'normal',
39 39
             ),
40
-        );/**/
40
+        ); /**/
41 41
 
42 42
         $this->_scripts_styles = array(
43 43
             'registers' => array(
44 44
                 'ee_event_venues'     => array(
45 45
                     'type'    => 'js',
46
-                    'url'     => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js',
46
+                    'url'     => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.js',
47 47
                     'depends' => array('jquery'),
48 48
                 ),
49 49
                 'ee_event_venues_css' => array(
50 50
                     'type' => 'css',
51
-                    'url'  => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css',
51
+                    'url'  => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.css',
52 52
                 ),
53 53
             ),
54 54
             'enqueues'  => array(
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         // first remove default venue callback
75 75
         foreach ($callbacks as $key => $callback) {
76 76
             if ($callback[1] == '_default_venue_update') {
77
-                unset($callbacks[ $key ]);
77
+                unset($callbacks[$key]);
78 78
             }
79 79
         }
80 80
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         }
103 103
 
104 104
         // cap checks
105
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
105
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
106 106
             $vnu_where['VNU_wp_user'] = get_current_user_id();
107 107
         }
108 108
 
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
         $ven_select[0] = esc_html__('Select a Venue', 'event_espresso');
114 114
         // setup venues for selector
115 115
         foreach ($venues as $venue) {
116
-            $ven_select[ $venue->ID() ] = $venue->name();
116
+            $ven_select[$venue->ID()] = $venue->name();
117 117
         }
118 118
 
119 119
         // if $ven_select does not have the existing venue attached to event then let's add that because we'll always
120 120
         // show existing attached venues even if it's trashed (or some other restricted status).
121 121
 
122
-        if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) {
123
-            $ven_select[ $evt_venue_id ] = $evt_venue->name();
122
+        if ($evt_venue_id && ! isset($ven_select[$evt_venue_id])) {
123
+            $ven_select[$evt_venue_id] = $evt_venue->name();
124 124
             $venues = array_merge($venues, array($evt_venue));
125 125
         }
126 126
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         );
185 185
 
186 186
         $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php'
187
-            : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php';
187
+            : EE_VENUES_TEMPLATE_PATH.'event_venues_metabox_content_from_manager.template.php';
188 188
 
189 189
         // Allow events venue metabox template args filtering.
190 190
         $template_args = apply_filters(
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $evt_venue = $evtobj->venues();
208 208
         $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null;
209 209
 
210
-        if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) {
210
+        if ( ! empty($evt_venue) && $evt_venue->ID() != $venue_id) {
211 211
             $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue');
212 212
         }
213 213
 
Please login to merge, or discard this patch.
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -14,207 +14,207 @@
 block discarded – undo
14 14
  */
15 15
 class espresso_events_Venues_Hooks extends EE_Admin_Hooks
16 16
 {
17
-    protected $_event;
18
-
19
-
20
-    public function __construct(EE_Admin_Page $admin_page)
21
-    {
22
-        parent::__construct($admin_page);
23
-    }
24
-
25
-
26
-    protected function _set_hooks_properties()
27
-    {
28
-        $this->_name = 'venues';
29
-
30
-        $this->_metaboxes = array(
31
-            0 => array(
32
-                'page_route' => array('edit', 'create_new'),
33
-                'func'       => 'venue_metabox',
34
-                'label'      => esc_html__('Venue Details', 'event_espresso'),
35
-                'priority'   => 'high',
36
-                'context'    => 'normal',
37
-            ),
38
-        );/**/
39
-
40
-        $this->_scripts_styles = array(
41
-            'registers' => array(
42
-                'ee_event_venues'     => array(
43
-                    'type'    => 'js',
44
-                    'url'     => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js',
45
-                    'depends' => array('jquery'),
46
-                ),
47
-                'ee_event_venues_css' => array(
48
-                    'type' => 'css',
49
-                    'url'  => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css',
50
-                ),
51
-            ),
52
-            'enqueues'  => array(
53
-                'ee_event_venues'     => array('edit', 'create_new'),
54
-                'ee_event_venues_css' => array('edit', 'create_new'),
55
-            ),
56
-        );
57
-
58
-        // hook into the handler for saving venue
59
-        add_filter(
60
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
61
-            array($this, 'modify_callbacks'),
62
-            10
63
-        );
64
-
65
-        // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector)
66
-        add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false');
67
-    }
68
-
69
-
70
-    public function modify_callbacks($callbacks)
71
-    {
72
-        // first remove default venue callback
73
-        foreach ($callbacks as $key => $callback) {
74
-            if ($callback[1] == '_default_venue_update') {
75
-                unset($callbacks[ $key ]);
76
-            }
77
-        }
78
-
79
-        // now let's add the caf version
80
-        $callbacks[] = array($this, 'caf_venue_update');
81
-        return $callbacks;
82
-    }
83
-
84
-
85
-    public function venue_metabox()
86
-    {
87
-        $evt_obj = $this->_adminpage_obj->get_event_object();
88
-        $evt_id = $evt_obj->ID();
89
-
90
-        // first let's see if we have a venue already
91
-        $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array();
92
-        $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null;
93
-        $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null;
94
-
95
-        // possibly private venues.
96
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
97
-            $vnu_where['status'] = array('IN', array('publish', 'private'));
98
-        } else {
99
-            $vnu_where['status'] = 'publish';
100
-        }
101
-
102
-        // cap checks
103
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
104
-            $vnu_where['VNU_wp_user'] = get_current_user_id();
105
-        }
106
-
107
-        $vnumdl = EE_Registry::instance()->load_model('Venue');
108
-        $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC')));
109
-
110
-        $ven_select = array();
111
-        $ven_select[0] = esc_html__('Select a Venue', 'event_espresso');
112
-        // setup venues for selector
113
-        foreach ($venues as $venue) {
114
-            $ven_select[ $venue->ID() ] = $venue->name();
115
-        }
116
-
117
-        // if $ven_select does not have the existing venue attached to event then let's add that because we'll always
118
-        // show existing attached venues even if it's trashed (or some other restricted status).
119
-
120
-        if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) {
121
-            $ven_select[ $evt_venue_id ] = $evt_venue->name();
122
-            $venues = array_merge($venues, array($evt_venue));
123
-        }
124
-
125
-        $template_args['venues'] = $venues;
126
-        $template_args['evt_venue_id'] = $evt_venue_id;
127
-        $venue_selector = new EE_Select_Input(
128
-            $ven_select,
129
-            array(
130
-                'html_name'  => 'venue_id',
131
-                'html_id'    => 'venue_id',
132
-                'html_class' => 'wide',
133
-                'default'    => $evt_venue_id ? $evt_venue_id : '0'
134
-            )
135
-        );
136
-        $template_args['venue_selector'] = $venue_selector->get_html_for_input();
137
-        $enable_for_gmap = new EE_Yes_No_Input(
138
-            array(
139
-                'html_name'  => 'enable_for_gmap',
140
-                'html_id'    => 'enable_for_gmap',
141
-                'default'    => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false
142
-            )
143
-        );
144
-        $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input();
145
-        $template_args['new_venue_link'] = EEH_HTML::link(
146
-            EE_Admin_Page::add_query_args_and_nonce(
147
-                array('action' => 'create_new'),
148
-                EE_VENUES_ADMIN_URL
149
-            ),
150
-            esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'),
151
-            esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'),
152
-            'ev_new_venue_link',
153
-            'button',
154
-            'margin-left:10px;',
155
-            'target="_blank"'
156
-        );
157
-
158
-        // Decide on an info text when there are no venues to display.
159
-        $no_venues_info_txt = esc_html_x(
160
-            'You have not created any venues yet.',
161
-            'Information text displayed in the venues metabox when there are no venues to display',
162
-            'event_espresso'
163
-        );
164
-        if (empty($venues)) {
165
-            $unpublished_where = $vnu_where;
166
-            $unpublished_where['status'] = 'draft';
167
-            $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC')));
168
-            if (count($unpublished_venues) > 0) {
169
-                $no_venues_info_txt = esc_html_x(
170
-                // @codingStandardsIgnoreStart
171
-                    'Use the link below to publish your venue through the venue editor so it appears here for selection.',
172
-                    // @codingStandardsIgnoreEnd
173
-                    'Information text displayed in the venues metabox when there are no venues to display',
174
-                    'event_espresso'
175
-                );
176
-            }
177
-        }
178
-        $template_args['no_venues_info'] = EEH_HTML::p(
179
-            EEH_HTML::strong($no_venues_info_txt),
180
-            'no_venues_info',
181
-            'info'
182
-        );
183
-
184
-        $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php'
185
-            : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php';
186
-
187
-        // Allow events venue metabox template args filtering.
188
-        $template_args = apply_filters(
189
-            'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args',
190
-            $template_args,
191
-            $template_path
192
-        );
193
-
194
-        EEH_Template::display_template($template_path, $template_args);
195
-    }
196
-
197
-
198
-    public function caf_venue_update($evtobj, $data)
199
-    {
200
-        EE_Registry::instance()->load_model('Venue');
201
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
202
-
203
-
204
-        // first let's check if the selected venue matches any existing venue attached to the event
205
-        $evt_venue = $evtobj->venues();
206
-        $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null;
207
-
208
-        if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) {
209
-            $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue');
210
-        }
211
-
212
-        if (empty($venue_id)) {
213
-            return true;
214
-        } //no venue to attach
215
-
216
-        // this should take care of adding to revisions as well as main post object
217
-        $success = $evtobj->_add_relation_to($venue_id, 'Venue');
218
-        return ! empty($success) ? true : false;
219
-    }
17
+	protected $_event;
18
+
19
+
20
+	public function __construct(EE_Admin_Page $admin_page)
21
+	{
22
+		parent::__construct($admin_page);
23
+	}
24
+
25
+
26
+	protected function _set_hooks_properties()
27
+	{
28
+		$this->_name = 'venues';
29
+
30
+		$this->_metaboxes = array(
31
+			0 => array(
32
+				'page_route' => array('edit', 'create_new'),
33
+				'func'       => 'venue_metabox',
34
+				'label'      => esc_html__('Venue Details', 'event_espresso'),
35
+				'priority'   => 'high',
36
+				'context'    => 'normal',
37
+			),
38
+		);/**/
39
+
40
+		$this->_scripts_styles = array(
41
+			'registers' => array(
42
+				'ee_event_venues'     => array(
43
+					'type'    => 'js',
44
+					'url'     => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js',
45
+					'depends' => array('jquery'),
46
+				),
47
+				'ee_event_venues_css' => array(
48
+					'type' => 'css',
49
+					'url'  => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css',
50
+				),
51
+			),
52
+			'enqueues'  => array(
53
+				'ee_event_venues'     => array('edit', 'create_new'),
54
+				'ee_event_venues_css' => array('edit', 'create_new'),
55
+			),
56
+		);
57
+
58
+		// hook into the handler for saving venue
59
+		add_filter(
60
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
61
+			array($this, 'modify_callbacks'),
62
+			10
63
+		);
64
+
65
+		// remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector)
66
+		add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false');
67
+	}
68
+
69
+
70
+	public function modify_callbacks($callbacks)
71
+	{
72
+		// first remove default venue callback
73
+		foreach ($callbacks as $key => $callback) {
74
+			if ($callback[1] == '_default_venue_update') {
75
+				unset($callbacks[ $key ]);
76
+			}
77
+		}
78
+
79
+		// now let's add the caf version
80
+		$callbacks[] = array($this, 'caf_venue_update');
81
+		return $callbacks;
82
+	}
83
+
84
+
85
+	public function venue_metabox()
86
+	{
87
+		$evt_obj = $this->_adminpage_obj->get_event_object();
88
+		$evt_id = $evt_obj->ID();
89
+
90
+		// first let's see if we have a venue already
91
+		$evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array();
92
+		$evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null;
93
+		$evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null;
94
+
95
+		// possibly private venues.
96
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
97
+			$vnu_where['status'] = array('IN', array('publish', 'private'));
98
+		} else {
99
+			$vnu_where['status'] = 'publish';
100
+		}
101
+
102
+		// cap checks
103
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
104
+			$vnu_where['VNU_wp_user'] = get_current_user_id();
105
+		}
106
+
107
+		$vnumdl = EE_Registry::instance()->load_model('Venue');
108
+		$venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC')));
109
+
110
+		$ven_select = array();
111
+		$ven_select[0] = esc_html__('Select a Venue', 'event_espresso');
112
+		// setup venues for selector
113
+		foreach ($venues as $venue) {
114
+			$ven_select[ $venue->ID() ] = $venue->name();
115
+		}
116
+
117
+		// if $ven_select does not have the existing venue attached to event then let's add that because we'll always
118
+		// show existing attached venues even if it's trashed (or some other restricted status).
119
+
120
+		if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) {
121
+			$ven_select[ $evt_venue_id ] = $evt_venue->name();
122
+			$venues = array_merge($venues, array($evt_venue));
123
+		}
124
+
125
+		$template_args['venues'] = $venues;
126
+		$template_args['evt_venue_id'] = $evt_venue_id;
127
+		$venue_selector = new EE_Select_Input(
128
+			$ven_select,
129
+			array(
130
+				'html_name'  => 'venue_id',
131
+				'html_id'    => 'venue_id',
132
+				'html_class' => 'wide',
133
+				'default'    => $evt_venue_id ? $evt_venue_id : '0'
134
+			)
135
+		);
136
+		$template_args['venue_selector'] = $venue_selector->get_html_for_input();
137
+		$enable_for_gmap = new EE_Yes_No_Input(
138
+			array(
139
+				'html_name'  => 'enable_for_gmap',
140
+				'html_id'    => 'enable_for_gmap',
141
+				'default'    => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false
142
+			)
143
+		);
144
+		$template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input();
145
+		$template_args['new_venue_link'] = EEH_HTML::link(
146
+			EE_Admin_Page::add_query_args_and_nonce(
147
+				array('action' => 'create_new'),
148
+				EE_VENUES_ADMIN_URL
149
+			),
150
+			esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'),
151
+			esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'),
152
+			'ev_new_venue_link',
153
+			'button',
154
+			'margin-left:10px;',
155
+			'target="_blank"'
156
+		);
157
+
158
+		// Decide on an info text when there are no venues to display.
159
+		$no_venues_info_txt = esc_html_x(
160
+			'You have not created any venues yet.',
161
+			'Information text displayed in the venues metabox when there are no venues to display',
162
+			'event_espresso'
163
+		);
164
+		if (empty($venues)) {
165
+			$unpublished_where = $vnu_where;
166
+			$unpublished_where['status'] = 'draft';
167
+			$unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC')));
168
+			if (count($unpublished_venues) > 0) {
169
+				$no_venues_info_txt = esc_html_x(
170
+				// @codingStandardsIgnoreStart
171
+					'Use the link below to publish your venue through the venue editor so it appears here for selection.',
172
+					// @codingStandardsIgnoreEnd
173
+					'Information text displayed in the venues metabox when there are no venues to display',
174
+					'event_espresso'
175
+				);
176
+			}
177
+		}
178
+		$template_args['no_venues_info'] = EEH_HTML::p(
179
+			EEH_HTML::strong($no_venues_info_txt),
180
+			'no_venues_info',
181
+			'info'
182
+		);
183
+
184
+		$template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php'
185
+			: EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php';
186
+
187
+		// Allow events venue metabox template args filtering.
188
+		$template_args = apply_filters(
189
+			'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args',
190
+			$template_args,
191
+			$template_path
192
+		);
193
+
194
+		EEH_Template::display_template($template_path, $template_args);
195
+	}
196
+
197
+
198
+	public function caf_venue_update($evtobj, $data)
199
+	{
200
+		EE_Registry::instance()->load_model('Venue');
201
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
202
+
203
+
204
+		// first let's check if the selected venue matches any existing venue attached to the event
205
+		$evt_venue = $evtobj->venues();
206
+		$evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null;
207
+
208
+		if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) {
209
+			$evtobj->_remove_relation_to($evt_venue->ID(), 'Venue');
210
+		}
211
+
212
+		if (empty($venue_id)) {
213
+			return true;
214
+		} //no venue to attach
215
+
216
+		// this should take care of adding to revisions as well as main post object
217
+		$success = $evtobj->_add_relation_to($venue_id, 'Venue');
218
+		return ! empty($success) ? true : false;
219
+	}
220 220
 }
Please login to merge, or discard this patch.
admin_pages/about/About_Admin_Page_Init.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
         // define some events related constants
21 21
         define('EE_ABOUT_PG_SLUG', 'espresso_about');
22 22
         define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
23
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
24
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
25
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
26
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
23
+        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES.'about/');
24
+        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page='.EE_ABOUT_PG_SLUG));
25
+        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN.'templates/');
26
+        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL.'about/assets/');
27 27
         parent::__construct();
28 28
     }
29 29
 
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,37 +14,37 @@
 block discarded – undo
14 14
  */
15 15
 class About_Admin_Page_Init extends EE_Admin_Page_Init
16 16
 {
17
-    public function __construct()
18
-    {
19
-        // define some events related constants
20
-        define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
-        define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
22
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
-        parent::__construct();
27
-    }
17
+	public function __construct()
18
+	{
19
+		// define some events related constants
20
+		define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
+		define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
22
+		define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
+		define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
+		define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
+		define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
+		parent::__construct();
27
+	}
28 28
 
29
-    protected function _set_init_properties()
30
-    {
31
-        $this->label = esc_html__('About Event Espresso', 'event_espresso');
32
-    }
29
+	protected function _set_init_properties()
30
+	{
31
+		$this->label = esc_html__('About Event Espresso', 'event_espresso');
32
+	}
33 33
 
34
-    protected function _set_menu_map()
35
-    {
36
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
-            array(
38
-                'menu_group'              => 'extras',
39
-                'menu_order'              => 40,
40
-                'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
-                'parent_slug'             => 'espresso_events',
42
-                'menu_slug'               => 'espresso_about',
43
-                'menu_label'              => EE_ABOUT_LABEL,
44
-                'capability'              => 'manage_options',
45
-                'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
-                'admin_init_page'         => $this,
47
-            )
48
-        );
49
-    }
34
+	protected function _set_menu_map()
35
+	{
36
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
+			array(
38
+				'menu_group'              => 'extras',
39
+				'menu_order'              => 40,
40
+				'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
+				'parent_slug'             => 'espresso_events',
42
+				'menu_slug'               => 'espresso_about',
43
+				'menu_label'              => EE_ABOUT_LABEL,
44
+				'capability'              => 'manage_options',
45
+				'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
+				'admin_init_page'         => $this,
47
+			)
48
+		);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page_Init.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
         // define some constants
24 24
         define('GEN_SET_PG_SLUG', 'espresso_general_settings');
25 25
         define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso'));
26
-        define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/');
27
-        define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG));
28
-        define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/');
29
-        define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/');
26
+        define('GEN_SET_ADMIN', EE_ADMIN_PAGES.'general_settings/');
27
+        define('GEN_SET_ADMIN_URL', admin_url('admin.php?page='.GEN_SET_PG_SLUG));
28
+        define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN.'templates/');
29
+        define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL.'general_settings/assets/');
30 30
 
31 31
         parent::__construct();
32 32
     }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,37 +17,37 @@
 block discarded – undo
17 17
  */
18 18
 class General_Settings_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20
-    public function __construct()
21
-    {
22
-        // define some constants
23
-        define('GEN_SET_PG_SLUG', 'espresso_general_settings');
24
-        define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso'));
25
-        define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/');
26
-        define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG));
27
-        define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/');
28
-        define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/');
20
+	public function __construct()
21
+	{
22
+		// define some constants
23
+		define('GEN_SET_PG_SLUG', 'espresso_general_settings');
24
+		define('GEN_SET_LABEL', esc_html__('General Settings', 'event_espresso'));
25
+		define('GEN_SET_ADMIN', EE_ADMIN_PAGES . 'general_settings/');
26
+		define('GEN_SET_ADMIN_URL', admin_url('admin.php?page=' . GEN_SET_PG_SLUG));
27
+		define('GEN_SET_TEMPLATE_PATH', GEN_SET_ADMIN . 'templates/');
28
+		define('GEN_SET_ASSETS_URL', EE_ADMIN_PAGES_URL . 'general_settings/assets/');
29 29
 
30
-        parent::__construct();
31
-    }
30
+		parent::__construct();
31
+	}
32 32
 
33
-    protected function _set_init_properties()
34
-    {
35
-        $this->label = GEN_SET_LABEL;
36
-    }
33
+	protected function _set_init_properties()
34
+	{
35
+		$this->label = GEN_SET_LABEL;
36
+	}
37 37
 
38
-    protected function _set_menu_map()
39
-    {
40
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
-            array(
42
-                'menu_group'      => 'settings',
43
-                'menu_order'      => 20,
44
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
-                'parent_slug'     => 'espresso_events',
46
-                'menu_slug'       => GEN_SET_PG_SLUG,
47
-                'menu_label'      => GEN_SET_LABEL,
48
-                'capability'      => 'manage_options',
49
-                'admin_init_page' => $this,
50
-            )
51
-        );
52
-    }
38
+	protected function _set_menu_map()
39
+	{
40
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
+			array(
42
+				'menu_group'      => 'settings',
43
+				'menu_order'      => 20,
44
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
+				'parent_slug'     => 'espresso_events',
46
+				'menu_slug'       => GEN_SET_PG_SLUG,
47
+				'menu_label'      => GEN_SET_LABEL,
48
+				'capability'      => 'manage_options',
49
+				'admin_init_page' => $this,
50
+			)
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@
 block discarded – undo
24 24
         define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25 25
         define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso'));
26 26
         define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
27
+        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES.'registration_form/');
28
+        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
29
+        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
30
+        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN.'assets/');
31
+        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL.'registration_form/assets/');
32
+        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN.'templates/');
33
+        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registration_form/templates/');
34 34
         parent::__construct();
35 35
     }
36 36
 
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -17,41 +17,41 @@
 block discarded – undo
17 17
  */
18 18
 class Registration_Form_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20
-    public function __construct()
21
-    {
22
-        // define some constants
23
-        define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
24
-        define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso'));
25
-        define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
26
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
27
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
28
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
30
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
31
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
32
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
33
-        parent::__construct();
34
-    }
20
+	public function __construct()
21
+	{
22
+		// define some constants
23
+		define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
24
+		define('REGISTRATION_FORM_LABEL', esc_html__('Registration Form', 'event_espresso'));
25
+		define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
26
+		define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
27
+		define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
28
+		define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
+		define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
30
+		define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
31
+		define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
32
+		define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
33
+		parent::__construct();
34
+	}
35 35
 
36
-    protected function _set_init_properties()
37
-    {
38
-        $this->label = esc_html__('Registration Form Overview', 'event_espresso');
39
-    }
36
+	protected function _set_init_properties()
37
+	{
38
+		$this->label = esc_html__('Registration Form Overview', 'event_espresso');
39
+	}
40 40
 
41 41
 
42
-    protected function _set_menu_map()
43
-    {
44
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
45
-            array(
46
-                'menu_group'      => 'management',
47
-                'menu_order'      => 30,
48
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
49
-                'parent_slug'     => 'espresso_events',
50
-                'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
51
-                'menu_label'      => esc_html__('Registration Form', 'event_espresso'),
52
-                'capability'      => 'ee_read_questions',
53
-                'admin_init_page' => $this,
54
-            )
55
-        );
56
-    }
42
+	protected function _set_menu_map()
43
+	{
44
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
45
+			array(
46
+				'menu_group'      => 'management',
47
+				'menu_order'      => 30,
48
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
49
+				'parent_slug'     => 'espresso_events',
50
+				'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
51
+				'menu_label'      => esc_html__('Registration Form', 'event_espresso'),
52
+				'capability'      => 'ee_read_questions',
53
+				'admin_init_page' => $this,
54
+			)
55
+		);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
     public function __construct($routing = true)
35 35
     {
36 36
         parent::__construct($routing);
37
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
38
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
39
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
37
+        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/');
38
+        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/');
39
+        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/');
40 40
     }
41 41
 
42 42
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function _extend_page_config()
50 50
     {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
51
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions';
52 52
 
53 53
         $new_page_routes = array(
54 54
             'reports' => array(
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         wp_register_script(
91 91
             'ee-txn-reports-js',
92
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
92
+            TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js',
93 93
             array('google-charts'),
94 94
             EVENT_ESPRESSO_VERSION,
95 95
             true
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function _transaction_reports()
121 121
     {
122
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
122
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
123 123
         $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
124 124
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
125 125
             $template_path,
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             }
163 163
 
164 164
             // setup the date range.
165
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
165
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
166 166
             $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
167 167
             $subtitle = sprintf(
168 168
                 wp_strip_all_tags(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                 wp_strip_all_tags(
186 186
                     __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
187 187
                 ),
188
-                '<h2>' . $report_title . '</h2><p>',
188
+                '<h2>'.$report_title.'</h2><p>',
189 189
                 '</p>'
190 190
             ),
191 191
         );
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             }
229 229
 
230 230
             // setup the date range.
231
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
231
+            $beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
232 232
             $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
233 233
             $subtitle = sprintf(
234 234
                 wp_strip_all_tags(
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                 wp_strip_all_tags(
252 252
                     __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
253 253
                 ),
254
-                '<h2>' . $report_title . '</h2><p>',
254
+                '<h2>'.$report_title.'</h2><p>',
255 255
                 '</p>'
256 256
             ),
257 257
         );
Please login to merge, or discard this patch.
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -14,246 +14,246 @@
 block discarded – undo
14 14
  */
15 15
 class Extend_Transactions_Admin_Page extends Transactions_Admin_Page
16 16
 {
17
-    /**
18
-     * This is used to hold the reports template data which is setup early in the request.
19
-     *
20
-     * @type array
21
-     */
22
-    protected $_reports_template_data = array();
23
-
24
-    /**
25
-     * @Constructor
26
-     * @access public
27
-     *
28
-     * @param bool $routing
29
-     *
30
-     * @return \Extend_Transactions_Admin_Page
31
-     */
32
-    public function __construct($routing = true)
33
-    {
34
-        parent::__construct($routing);
35
-        define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
36
-        define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
37
-        define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
38
-    }
39
-
40
-
41
-    /**
42
-     *    _extend_page_config
43
-     *
44
-     * @access protected
45
-     * @return void
46
-     */
47
-    protected function _extend_page_config()
48
-    {
49
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
50
-
51
-        $new_page_routes = array(
52
-            'reports' => array(
53
-                'func'       => '_transaction_reports',
54
-                'capability' => 'ee_read_transactions',
55
-            ),
56
-        );
57
-
58
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
59
-
60
-        $new_page_config = array(
61
-            'reports' => array(
62
-                'nav'           => array(
63
-                    'label' => esc_html__('Reports', 'event_espresso'),
64
-                    'order' => 20,
65
-                ),
66
-                'help_tabs'     => array(
67
-                    'transactions_reports_help_tab' => array(
68
-                        'title'    => esc_html__('Transaction Reports', 'event_espresso'),
69
-                        'filename' => 'transactions_reports',
70
-                    ),
71
-                ),
72
-                'require_nonce' => false,
73
-            ),
74
-        );
75
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
76
-    }
77
-
78
-
79
-    /**
80
-     *    load_scripts_styles_reports
81
-     *
82
-     * @access public
83
-     * @return void
84
-     */
85
-    public function load_scripts_styles_reports()
86
-    {
87
-        wp_register_script(
88
-            'ee-txn-reports-js',
89
-            TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
90
-            array('google-charts'),
91
-            EVENT_ESPRESSO_VERSION,
92
-            true
93
-        );
94
-        wp_enqueue_script('ee-txn-reports-js');
95
-        $this->_transaction_reports_js_setup();
96
-        EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
97
-    }
98
-
99
-
100
-    /**
101
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
102
-     * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
103
-     */
104
-    protected function _transaction_reports_js_setup()
105
-    {
106
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
107
-        $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
108
-    }
109
-
110
-
111
-    /**
112
-     * _transaction_reports
113
-     *    generates Business Reports regarding Transactions
114
-     *
115
-     * @return void
116
-     */
117
-    protected function _transaction_reports()
118
-    {
119
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
120
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
121
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
122
-            $template_path,
123
-            $this->_reports_template_data,
124
-            true
125
-        );
126
-
127
-        // the final template wrapper
128
-        $this->display_admin_page_with_no_sidebar();
129
-    }
130
-
131
-
132
-    /**
133
-     * _revenue_per_day_report
134
-     * generates Business Report showing Total Revenue per Day.
135
-     *
136
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
137
-     *
138
-     * @return string
139
-     */
140
-    private function _revenue_per_day_report($period = '-1 month')
141
-    {
142
-
143
-        $report_ID = 'txn-admin-revenue-per-day-report-dv';
144
-
145
-        $TXN = EEM_Transaction::instance();
146
-
147
-        $results = $TXN->get_revenue_per_day_report($period);
148
-        $results = (array) $results;
149
-        $revenue = array();
150
-        $subtitle = '';
151
-
152
-        if ($results) {
153
-            $revenue[] = array(
154
-                esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
155
-                esc_html__('Total Revenue', 'event_espresso'),
156
-            );
157
-            foreach ($results as $result) {
158
-                $revenue[] = array($result->txnDate, (float) $result->revenue);
159
-            }
160
-
161
-            // setup the date range.
162
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
163
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
164
-            $subtitle = sprintf(
165
-                wp_strip_all_tags(
166
-                    _x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
167
-                ),
168
-                $beginning_date->format('Y-m-d'),
169
-                $ending_date->format('Y-m-d')
170
-            );
171
-        }
172
-
173
-        $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso'));
174
-
175
-        $report_params = array(
176
-            'title'     => $report_title,
177
-            'subtitle'  => $subtitle,
178
-            'id'        => $report_ID,
179
-            'revenue'   => $revenue,
180
-            'noResults' => empty($revenue) || count($revenue) === 1,
181
-            'noTxnMsg'  => sprintf(
182
-                wp_strip_all_tags(
183
-                    __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
184
-                ),
185
-                '<h2>' . $report_title . '</h2><p>',
186
-                '</p>'
187
-            ),
188
-        );
189
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
190
-
191
-        return $report_ID;
192
-    }
193
-
194
-
195
-    /**
196
-     * _revenue_per_event_report
197
-     * generates Business Report showing total revenue per event.
198
-     *
199
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200
-     *
201
-     * @return int
202
-     */
203
-    private function _revenue_per_event_report($period = '-1 month')
204
-    {
205
-
206
-        $report_ID = 'txn-admin-revenue-per-event-report-dv';
207
-
208
-        $TXN = EEM_Transaction::instance();
209
-        $results = $TXN->get_revenue_per_event_report($period);
210
-        $results = (array) $results;
211
-        $revenue = array();
212
-        $subtitle = '';
213
-
214
-        if ($results) {
215
-            $revenue[] = array(
216
-                esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
217
-                esc_html__('Total Revenue', 'event_espresso'),
218
-            );
219
-            foreach ($results as $result) {
220
-                if ($result->revenue > 1) {
221
-                    $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
222
-                    $event_name = wp_trim_words($event_name, 5, '...');
223
-                    $revenue[] = array($event_name, (float) $result->revenue);
224
-                }
225
-            }
226
-
227
-            // setup the date range.
228
-            $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
-            $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
-            $subtitle = sprintf(
231
-                wp_strip_all_tags(
232
-                    _x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
233
-                ),
234
-                $beginning_date->format('Y-m-d'),
235
-                $ending_date->format('Y-m-d')
236
-            );
237
-        }
238
-
239
-        $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso'));
240
-
241
-        $report_params = array(
242
-            'title'     => $report_title,
243
-            'subtitle'  => $subtitle,
244
-            'id'        => $report_ID,
245
-            'revenue'   => $revenue,
246
-            'noResults' => empty($revenue),
247
-            'noTxnMsg'  => sprintf(
248
-                wp_strip_all_tags(
249
-                    __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
250
-                ),
251
-                '<h2>' . $report_title . '</h2><p>',
252
-                '</p>'
253
-            ),
254
-        );
255
-        wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
256
-
257
-        return $report_ID;
258
-    }
17
+	/**
18
+	 * This is used to hold the reports template data which is setup early in the request.
19
+	 *
20
+	 * @type array
21
+	 */
22
+	protected $_reports_template_data = array();
23
+
24
+	/**
25
+	 * @Constructor
26
+	 * @access public
27
+	 *
28
+	 * @param bool $routing
29
+	 *
30
+	 * @return \Extend_Transactions_Admin_Page
31
+	 */
32
+	public function __construct($routing = true)
33
+	{
34
+		parent::__construct($routing);
35
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
36
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
37
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
38
+	}
39
+
40
+
41
+	/**
42
+	 *    _extend_page_config
43
+	 *
44
+	 * @access protected
45
+	 * @return void
46
+	 */
47
+	protected function _extend_page_config()
48
+	{
49
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
50
+
51
+		$new_page_routes = array(
52
+			'reports' => array(
53
+				'func'       => '_transaction_reports',
54
+				'capability' => 'ee_read_transactions',
55
+			),
56
+		);
57
+
58
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
59
+
60
+		$new_page_config = array(
61
+			'reports' => array(
62
+				'nav'           => array(
63
+					'label' => esc_html__('Reports', 'event_espresso'),
64
+					'order' => 20,
65
+				),
66
+				'help_tabs'     => array(
67
+					'transactions_reports_help_tab' => array(
68
+						'title'    => esc_html__('Transaction Reports', 'event_espresso'),
69
+						'filename' => 'transactions_reports',
70
+					),
71
+				),
72
+				'require_nonce' => false,
73
+			),
74
+		);
75
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
76
+	}
77
+
78
+
79
+	/**
80
+	 *    load_scripts_styles_reports
81
+	 *
82
+	 * @access public
83
+	 * @return void
84
+	 */
85
+	public function load_scripts_styles_reports()
86
+	{
87
+		wp_register_script(
88
+			'ee-txn-reports-js',
89
+			TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js',
90
+			array('google-charts'),
91
+			EVENT_ESPRESSO_VERSION,
92
+			true
93
+		);
94
+		wp_enqueue_script('ee-txn-reports-js');
95
+		$this->_transaction_reports_js_setup();
96
+		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
97
+	}
98
+
99
+
100
+	/**
101
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
102
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method.
103
+	 */
104
+	protected function _transaction_reports_js_setup()
105
+	{
106
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report();
107
+		$this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report();
108
+	}
109
+
110
+
111
+	/**
112
+	 * _transaction_reports
113
+	 *    generates Business Reports regarding Transactions
114
+	 *
115
+	 * @return void
116
+	 */
117
+	protected function _transaction_reports()
118
+	{
119
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
120
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
121
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
122
+			$template_path,
123
+			$this->_reports_template_data,
124
+			true
125
+		);
126
+
127
+		// the final template wrapper
128
+		$this->display_admin_page_with_no_sidebar();
129
+	}
130
+
131
+
132
+	/**
133
+	 * _revenue_per_day_report
134
+	 * generates Business Report showing Total Revenue per Day.
135
+	 *
136
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
137
+	 *
138
+	 * @return string
139
+	 */
140
+	private function _revenue_per_day_report($period = '-1 month')
141
+	{
142
+
143
+		$report_ID = 'txn-admin-revenue-per-day-report-dv';
144
+
145
+		$TXN = EEM_Transaction::instance();
146
+
147
+		$results = $TXN->get_revenue_per_day_report($period);
148
+		$results = (array) $results;
149
+		$revenue = array();
150
+		$subtitle = '';
151
+
152
+		if ($results) {
153
+			$revenue[] = array(
154
+				esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'),
155
+				esc_html__('Total Revenue', 'event_espresso'),
156
+			);
157
+			foreach ($results as $result) {
158
+				$revenue[] = array($result->txnDate, (float) $result->revenue);
159
+			}
160
+
161
+			// setup the date range.
162
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
163
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
164
+			$subtitle = sprintf(
165
+				wp_strip_all_tags(
166
+					_x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
167
+				),
168
+				$beginning_date->format('Y-m-d'),
169
+				$ending_date->format('Y-m-d')
170
+			);
171
+		}
172
+
173
+		$report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso'));
174
+
175
+		$report_params = array(
176
+			'title'     => $report_title,
177
+			'subtitle'  => $subtitle,
178
+			'id'        => $report_ID,
179
+			'revenue'   => $revenue,
180
+			'noResults' => empty($revenue) || count($revenue) === 1,
181
+			'noTxnMsg'  => sprintf(
182
+				wp_strip_all_tags(
183
+					__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
184
+				),
185
+				'<h2>' . $report_title . '</h2><p>',
186
+				'</p>'
187
+			),
188
+		);
189
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
190
+
191
+		return $report_ID;
192
+	}
193
+
194
+
195
+	/**
196
+	 * _revenue_per_event_report
197
+	 * generates Business Report showing total revenue per event.
198
+	 *
199
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
200
+	 *
201
+	 * @return int
202
+	 */
203
+	private function _revenue_per_event_report($period = '-1 month')
204
+	{
205
+
206
+		$report_ID = 'txn-admin-revenue-per-event-report-dv';
207
+
208
+		$TXN = EEM_Transaction::instance();
209
+		$results = $TXN->get_revenue_per_event_report($period);
210
+		$results = (array) $results;
211
+		$revenue = array();
212
+		$subtitle = '';
213
+
214
+		if ($results) {
215
+			$revenue[] = array(
216
+				esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'),
217
+				esc_html__('Total Revenue', 'event_espresso'),
218
+			);
219
+			foreach ($results as $result) {
220
+				if ($result->revenue > 1) {
221
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
222
+					$event_name = wp_trim_words($event_name, 5, '...');
223
+					$revenue[] = array($event_name, (float) $result->revenue);
224
+				}
225
+			}
226
+
227
+			// setup the date range.
228
+			$beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
229
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
230
+			$subtitle = sprintf(
231
+				wp_strip_all_tags(
232
+					_x('For the period: %s to %s', 'Used to give date range', 'event_espresso')
233
+				),
234
+				$beginning_date->format('Y-m-d'),
235
+				$ending_date->format('Y-m-d')
236
+			);
237
+		}
238
+
239
+		$report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso'));
240
+
241
+		$report_params = array(
242
+			'title'     => $report_title,
243
+			'subtitle'  => $subtitle,
244
+			'id'        => $report_ID,
245
+			'revenue'   => $revenue,
246
+			'noResults' => empty($revenue),
247
+			'noTxnMsg'  => sprintf(
248
+				wp_strip_all_tags(
249
+					__('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso')
250
+				),
251
+				'<h2>' . $report_title . '</h2><p>',
252
+				'</p>'
253
+			),
254
+		);
255
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
256
+
257
+		return $report_ID;
258
+	}
259 259
 }
Please login to merge, or discard this patch.