Completed
Branch dev (e59588)
by
unknown
29:01 queued 21:36
created
admin_pages/messages/help_tabs/messages_settings_messengers.help_tab.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -3,79 +3,79 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
 <p>
11 11
     <?php esc_html_e(
12
-        'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
-        'event_espresso'
14
-    ); ?>
12
+		'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
+		'event_espresso'
14
+	); ?>
15 15
 </p>
16 16
 <p>
17 17
     <?php printf(
18
-        esc_html__(
19
-            'The green colored gear %s indicates that this messenger is currently active.',
20
-            'event_espresso'
21
-        ),
22
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
-        . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
-    );
25
-    printf(
26
-        esc_html__(
27
-            ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
-            'event_espresso'
29
-        ),
30
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
-        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
-    ); ?>
18
+		esc_html__(
19
+			'The green colored gear %s indicates that this messenger is currently active.',
20
+			'event_espresso'
21
+		),
22
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
+		. ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
+	);
25
+	printf(
26
+		esc_html__(
27
+			' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
+			'event_espresso'
29
+		),
30
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
+		. '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
+	); ?>
33 33
 </p>
34 34
 <p>
35 35
     <?php esc_html_e(
36
-        'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
-        'event_espresso'
38
-    ); ?>
36
+		'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
+		'event_espresso'
38
+	); ?>
39 39
 </p>
40 40
 <p>
41 41
     <?php printf(
42
-        esc_html__(
43
-            '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
-            'event_espresso'
45
-        ),
46
-        '<div class="ee-switch">'
47
-        . '<input class="ee-switch__input" type="checkbox" checked disabled>'
48
-        . '<label class="ee-switch__toggle" for="ee-on-off-toggle-on"></label>'
49
-        . '</div>',
50
-        '<div class="ee-switch">'
51
-        . '<input class="ee-switch__input" type="checkbox" disabled>'
52
-        . '<label class="ee-switch__toggle" for="ee-on-off-toggle-off"></label>'
53
-        . '</div>'
54
-    ); ?>
42
+		esc_html__(
43
+			'%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
+			'event_espresso'
45
+		),
46
+		'<div class="ee-switch">'
47
+		. '<input class="ee-switch__input" type="checkbox" checked disabled>'
48
+		. '<label class="ee-switch__toggle" for="ee-on-off-toggle-on"></label>'
49
+		. '</div>',
50
+		'<div class="ee-switch">'
51
+		. '<input class="ee-switch__input" type="checkbox" disabled>'
52
+		. '<label class="ee-switch__toggle" for="ee-on-off-toggle-off"></label>'
53
+		. '</div>'
54
+	); ?>
55 55
 </p>
56 56
 <p>
57 57
     <?php
58
-    esc_html_e(
59
-        'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
-        'event_espresso'
61
-    ); ?>
58
+	esc_html_e(
59
+		'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
+		'event_espresso'
61
+	); ?>
62 62
 </p>
63 63
 <p>
64 64
     <?php esc_html_e(
65
-        'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
-        'event_espresso'
67
-    ); ?>
65
+		'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
+		'event_espresso'
67
+	); ?>
68 68
 </p>
69 69
 <p>
70 70
     <?php esc_html_e(
71
-        'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
-        'event_espresso'
73
-    ); ?>
71
+		'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
+		'event_espresso'
73
+	); ?>
74 74
 </p>
75 75
 <p>
76 76
     <strong><?php esc_html_e('Important', 'event_espresso'); ?></strong><br />
77 77
     <?php esc_html_e(
78
-        'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
-        'event_espresso'
80
-    ); ?>
78
+		'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
+		'event_espresso'
80
+	); ?>
81 81
 </p>
Please login to merge, or discard this patch.
admin_pages/general_settings/templates/countries_settings.template.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 
15 15
     <h2 class="ee-admin-settings-hdr">
16 16
         <?php
17
-        echo esc_html__('Countries and States/Provinces', 'event_espresso');
18
-        echo EEH_Template::get_help_tab_link('country_select_info'); // already escaped
19
-        ?>
17
+		echo esc_html__('Countries and States/Provinces', 'event_espresso');
18
+		echo EEH_Template::get_help_tab_link('country_select_info'); // already escaped
19
+		?>
20 20
     </h2>
21 21
     <table class="ee-admin-two-column-layout form-table">
22 22
         <tbody>
@@ -26,28 +26,28 @@  discard block
 block discarded – undo
26 26
     <br/>
27 27
     <p>
28 28
         <?php esc_html_e(
29
-            'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.',
30
-            'event_espresso'
31
-        ); ?>
29
+			'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.',
30
+			'event_espresso'
31
+		); ?>
32 32
     </p>
33 33
     <p id="country-currency-setting-disabled-pg" style="display: none;">
34 34
         <span class="reminder-spn">
35 35
             <?php printf(
36
-                esc_html__(
37
-                    'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.',
38
-                    'event_espresso'
39
-                ),
40
-                $CNT_name_for_site
41
-            ); ?>
36
+				esc_html__(
37
+					'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.',
38
+					'event_espresso'
39
+				),
40
+				$CNT_name_for_site
41
+			); ?>
42 42
         </span>
43 43
     </p>
44 44
     <div id="country-settings-dv" class="ee-layout-row">
45 45
         <div id="country-details-settings-dv">
46 46
             <h2 class="ee-admin-settings-hdr">
47 47
                 <?php
48
-                echo esc_html__('Country Details', 'event_espresso');
49
-                echo wp_kses(EEH_Template::get_help_tab_link('country_details_info'), AllowedTags::getAllowedTags());
50
-                ?>
48
+				echo esc_html__('Country Details', 'event_espresso');
49
+				echo wp_kses(EEH_Template::get_help_tab_link('country_details_info'), AllowedTags::getAllowedTags());
50
+				?>
51 51
             </h2>
52 52
             <div id="country-details-dv">
53 53
                 <?php echo wp_kses($country_details_settings, AllowedTags::getAllowedTags()); ?>
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
         <div id="country-states-settings-dv">
58 58
             <h2 class="ee-admin-settings-hdr">
59 59
                 <?php
60
-                echo esc_html__('States/Provinces', 'event_espresso');
61
-                echo wp_kses(EEH_Template::get_help_tab_link('country_states_info'), AllowedTags::getAllowedTags());
62
-                ?>
60
+				echo esc_html__('States/Provinces', 'event_espresso');
61
+				echo wp_kses(EEH_Template::get_help_tab_link('country_states_info'), AllowedTags::getAllowedTags());
62
+				?>
63 63
             </h2>
64 64
             <div id="country-states-dv">
65 65
                 <?php echo wp_kses($country_states_settings, AllowedTags::getAllowedTags()); ?>
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 2 patches
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -14,486 +14,486 @@
 block discarded – undo
14 14
  */
15 15
 abstract class EE_Form_Section_Base
16 16
 {
17
-    /**
18
-     * the URL the form is submitted to
19
-     *
20
-     * @var string
21
-     */
22
-    protected $_action;
23
-
24
-    /**
25
-     * POST (default) or GET
26
-     *
27
-     * @var string
28
-     */
29
-    protected $_method;
30
-
31
-    /**
32
-     * html_id and html_name are derived from this by default
33
-     *
34
-     * @var string
35
-     */
36
-    protected $_name;
37
-
38
-    /**
39
-     * $_html_id
40
-     * @var string
41
-     */
42
-    protected $_html_id;
43
-
44
-    /**
45
-     * $_html_class
46
-     * @var string
47
-     */
48
-    protected $_html_class;
49
-
50
-    /**
51
-     * $_html_style
52
-     * @var string
53
-     */
54
-    protected $_html_style;
55
-
56
-    /**
57
-     * $_other_html_attributes
58
-     * @var string
59
-     */
60
-    protected $_other_html_attributes;
61
-
62
-    /**
63
-     * The form section of which this form section is a part
64
-     *
65
-     * @var EE_Form_Section_Proper
66
-     */
67
-    protected $_parent_section;
68
-
69
-    /**
70
-     * flag indicating that _construct_finalize has been called.
71
-     * If it has not been called and we try to use functions which require it, we call it
72
-     * with no parameters. But normally, _construct_finalize should be called by the instantiating class
73
-     *
74
-     * @var boolean
75
-     */
76
-    protected $_construction_finalized;
77
-
78
-    /**
79
-     * Strategy for parsing the form HTML upon display
80
-     *
81
-     * @var FormHtmlFilter
82
-     */
83
-    protected $_form_html_filter;
84
-
85
-
86
-    /**
87
-     * @param array $options_array {
88
-     * @type        $name          string the name for this form section, if you want to explicitly define it
89
-     *                             }
90
-     * @throws InvalidDataTypeException
91
-     */
92
-    public function __construct($options_array = array())
93
-    {
94
-        // used by display strategies
95
-        // assign incoming values to properties
96
-        foreach ($options_array as $key => $value) {
97
-            $key = '_' . $key;
98
-            if (property_exists($this, $key) && empty($this->{$key})) {
99
-                $this->{$key} = $value;
100
-                if ($key === '_subsections' && ! is_array($value)) {
101
-                    throw new InvalidDataTypeException($key, $value, 'array');
102
-                }
103
-            }
104
-        }
105
-        // set parser which allows the form section's rendered HTML to be filtered
106
-        if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
107
-            $this->_form_html_filter = $options_array['form_html_filter'];
108
-        }
109
-    }
110
-
111
-
112
-
113
-    /**
114
-     * @param $parent_form_section
115
-     * @param $name
116
-     * @throws \EE_Error
117
-     */
118
-    protected function _construct_finalize($parent_form_section, $name)
119
-    {
120
-        $this->_construction_finalized = true;
121
-        $this->_parent_section = $parent_form_section;
122
-        if ($name !== null) {
123
-            $this->_name = $name;
124
-        }
125
-    }
126
-
127
-
128
-
129
-    /**
130
-     * make sure construction finalized was called, otherwise children might not be ready
131
-     *
132
-     * @return void
133
-     * @throws \EE_Error
134
-     */
135
-    public function ensure_construct_finalized_called()
136
-    {
137
-        if (! $this->_construction_finalized) {
138
-            $this->_construct_finalize($this->_parent_section, $this->_name);
139
-        }
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @return string
146
-     */
147
-    public function action()
148
-    {
149
-        return $this->_action;
150
-    }
151
-
152
-
153
-
154
-    /**
155
-     * @param string $action
156
-     */
157
-    public function set_action($action)
158
-    {
159
-        $this->_action = $action;
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * @return string
166
-     */
167
-    public function method()
168
-    {
169
-        return ! empty($this->_method) ? $this->_method : 'POST';
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     * @param string $method
176
-     */
177
-    public function set_method($method)
178
-    {
179
-        switch ($method) {
180
-            case 'get':
181
-            case 'GET':
182
-                $this->_method = 'GET';
183
-                break;
184
-            default:
185
-                $this->_method = 'POST';
186
-        }
187
-    }
188
-
189
-
190
-
191
-    /**
192
-     * Sets the html_id to its default value, if none was specified in the constructor.
193
-     * Calculation involves using the name and the parent's html id
194
-     * return void
195
-     *
196
-     * @throws \EE_Error
197
-     */
198
-    protected function _set_default_html_id_if_empty()
199
-    {
200
-        if (! $this->_html_id) {
201
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
202
-                $this->_html_id = $this->_parent_section->html_id()
203
-                                  . '-'
204
-                                  . $this->_prep_name_for_html_id($this->name());
205
-            } else {
206
-                $this->_html_id = $this->_prep_name_for_html_id($this->name());
207
-            }
208
-        }
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     * _prep_name_for_html_id
215
-     *
216
-     * @param $name
217
-     * @return string
218
-     */
219
-    private function _prep_name_for_html_id($name)
220
-    {
221
-        return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
222
-    }
17
+	/**
18
+	 * the URL the form is submitted to
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $_action;
23
+
24
+	/**
25
+	 * POST (default) or GET
26
+	 *
27
+	 * @var string
28
+	 */
29
+	protected $_method;
30
+
31
+	/**
32
+	 * html_id and html_name are derived from this by default
33
+	 *
34
+	 * @var string
35
+	 */
36
+	protected $_name;
37
+
38
+	/**
39
+	 * $_html_id
40
+	 * @var string
41
+	 */
42
+	protected $_html_id;
43
+
44
+	/**
45
+	 * $_html_class
46
+	 * @var string
47
+	 */
48
+	protected $_html_class;
49
+
50
+	/**
51
+	 * $_html_style
52
+	 * @var string
53
+	 */
54
+	protected $_html_style;
55
+
56
+	/**
57
+	 * $_other_html_attributes
58
+	 * @var string
59
+	 */
60
+	protected $_other_html_attributes;
61
+
62
+	/**
63
+	 * The form section of which this form section is a part
64
+	 *
65
+	 * @var EE_Form_Section_Proper
66
+	 */
67
+	protected $_parent_section;
68
+
69
+	/**
70
+	 * flag indicating that _construct_finalize has been called.
71
+	 * If it has not been called and we try to use functions which require it, we call it
72
+	 * with no parameters. But normally, _construct_finalize should be called by the instantiating class
73
+	 *
74
+	 * @var boolean
75
+	 */
76
+	protected $_construction_finalized;
77
+
78
+	/**
79
+	 * Strategy for parsing the form HTML upon display
80
+	 *
81
+	 * @var FormHtmlFilter
82
+	 */
83
+	protected $_form_html_filter;
84
+
85
+
86
+	/**
87
+	 * @param array $options_array {
88
+	 * @type        $name          string the name for this form section, if you want to explicitly define it
89
+	 *                             }
90
+	 * @throws InvalidDataTypeException
91
+	 */
92
+	public function __construct($options_array = array())
93
+	{
94
+		// used by display strategies
95
+		// assign incoming values to properties
96
+		foreach ($options_array as $key => $value) {
97
+			$key = '_' . $key;
98
+			if (property_exists($this, $key) && empty($this->{$key})) {
99
+				$this->{$key} = $value;
100
+				if ($key === '_subsections' && ! is_array($value)) {
101
+					throw new InvalidDataTypeException($key, $value, 'array');
102
+				}
103
+			}
104
+		}
105
+		// set parser which allows the form section's rendered HTML to be filtered
106
+		if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
107
+			$this->_form_html_filter = $options_array['form_html_filter'];
108
+		}
109
+	}
110
+
111
+
112
+
113
+	/**
114
+	 * @param $parent_form_section
115
+	 * @param $name
116
+	 * @throws \EE_Error
117
+	 */
118
+	protected function _construct_finalize($parent_form_section, $name)
119
+	{
120
+		$this->_construction_finalized = true;
121
+		$this->_parent_section = $parent_form_section;
122
+		if ($name !== null) {
123
+			$this->_name = $name;
124
+		}
125
+	}
126
+
127
+
128
+
129
+	/**
130
+	 * make sure construction finalized was called, otherwise children might not be ready
131
+	 *
132
+	 * @return void
133
+	 * @throws \EE_Error
134
+	 */
135
+	public function ensure_construct_finalized_called()
136
+	{
137
+		if (! $this->_construction_finalized) {
138
+			$this->_construct_finalize($this->_parent_section, $this->_name);
139
+		}
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @return string
146
+	 */
147
+	public function action()
148
+	{
149
+		return $this->_action;
150
+	}
151
+
152
+
153
+
154
+	/**
155
+	 * @param string $action
156
+	 */
157
+	public function set_action($action)
158
+	{
159
+		$this->_action = $action;
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * @return string
166
+	 */
167
+	public function method()
168
+	{
169
+		return ! empty($this->_method) ? $this->_method : 'POST';
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 * @param string $method
176
+	 */
177
+	public function set_method($method)
178
+	{
179
+		switch ($method) {
180
+			case 'get':
181
+			case 'GET':
182
+				$this->_method = 'GET';
183
+				break;
184
+			default:
185
+				$this->_method = 'POST';
186
+		}
187
+	}
188
+
189
+
190
+
191
+	/**
192
+	 * Sets the html_id to its default value, if none was specified in the constructor.
193
+	 * Calculation involves using the name and the parent's html id
194
+	 * return void
195
+	 *
196
+	 * @throws \EE_Error
197
+	 */
198
+	protected function _set_default_html_id_if_empty()
199
+	{
200
+		if (! $this->_html_id) {
201
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
202
+				$this->_html_id = $this->_parent_section->html_id()
203
+								  . '-'
204
+								  . $this->_prep_name_for_html_id($this->name());
205
+			} else {
206
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
207
+			}
208
+		}
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 * _prep_name_for_html_id
215
+	 *
216
+	 * @param $name
217
+	 * @return string
218
+	 */
219
+	private function _prep_name_for_html_id($name)
220
+	{
221
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
222
+	}
223 223
 
224 224
 
225 225
 
226
-    /**
227
-     * Returns the HTML, JS, and CSS necessary to display this form section on a page.
228
-     * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
229
-     * and call get_html when you want to output the html. Calling get_html_and_js after
230
-     * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
231
-     * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
232
-     * and so might stop working anytime.
233
-     *
234
-     * @return string
235
-     */
236
-    public function get_html_and_js()
237
-    {
238
-        return $this->get_html();
239
-    }
226
+	/**
227
+	 * Returns the HTML, JS, and CSS necessary to display this form section on a page.
228
+	 * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
229
+	 * and call get_html when you want to output the html. Calling get_html_and_js after
230
+	 * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
231
+	 * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
232
+	 * and so might stop working anytime.
233
+	 *
234
+	 * @return string
235
+	 */
236
+	public function get_html_and_js()
237
+	{
238
+		return $this->get_html();
239
+	}
240 240
 
241 241
 
242
-
243
-    /**
244
-     * Gets the HTML for displaying this form section
245
-     *
246
-     * @return string
247
-     */
248
-    abstract public function get_html();
249
-
250
-
251
-    /**
252
-     * @param bool $add_pound_sign
253
-     * @return string
254
-     * @throws EE_Error
255
-     */
256
-    public function html_id($add_pound_sign = false)
257
-    {
258
-        $this->_set_default_html_id_if_empty();
259
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
260
-    }
261
-
262
-
263
-
264
-    /**
265
-     * @return string
266
-     */
267
-    public function html_class()
268
-    {
269
-        return $this->_html_class;
270
-    }
271
-
272
-
273
-
274
-    /**
275
-     * @return string
276
-     */
277
-    public function html_style()
278
-    {
279
-        return $this->_html_style;
280
-    }
281
-
282
-
283
-
284
-    /**
285
-     * @param mixed $html_class
286
-     */
287
-    public function set_html_class($html_class)
288
-    {
289
-        $this->_html_class = $html_class;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     * @param mixed $html_id
296
-     */
297
-    public function set_html_id($html_id)
298
-    {
299
-        $this->_html_id = $html_id;
300
-    }
301
-
302
-
303
-
304
-    /**
305
-     * @param mixed $html_style
306
-     */
307
-    public function set_html_style($html_style)
308
-    {
309
-        $this->_html_style = $html_style;
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * @param string $other_html_attributes
316
-     */
317
-    public function set_other_html_attributes($other_html_attributes)
318
-    {
319
-        $this->_other_html_attributes = $other_html_attributes;
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * @return string
326
-     */
327
-    public function other_html_attributes()
328
-    {
329
-        return ! empty($this->_other_html_attributes) ? ' ' . $this->_other_html_attributes : '';
330
-    }
331
-
332
-
333
-
334
-    /**
335
-     * Gets the name of the form section. This is not the same as the HTML name.
336
-     *
337
-     * @throws EE_Error
338
-     * @return string
339
-     */
340
-    public function name()
341
-    {
342
-        if (! $this->_construction_finalized) {
343
-            throw new EE_Error(sprintf(esc_html__(
344
-                'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
345
-                'event_espresso'
346
-            ), get_class($this)));
347
-        }
348
-        return $this->_name;
349
-    }
350
-
351
-
352
-
353
-    /**
354
-     * Gets the parent section
355
-     *
356
-     * @return EE_Form_Section_Proper
357
-     */
358
-    public function parent_section()
359
-    {
360
-        return $this->_parent_section;
361
-    }
362
-
363
-
364
-    /**
365
-     * returns HTML for generating the opening form HTML tag (<form>)
366
-     *
367
-     * @param string $action           the URL the form is submitted to
368
-     * @param string $method           POST (default) or GET
369
-     * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
370
-     * @return string
371
-     * @throws EE_Error
372
-     */
373
-    public function form_open($action = '', $method = '', $other_attributes = '')
374
-    {
375
-        if (! empty($action)) {
376
-            $this->set_action($action);
377
-        }
378
-        if (! empty($method)) {
379
-            $this->set_method($method);
380
-        }
381
-        $html = EEH_HTML::nl(1, 'form') . '<form';
382
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
383
-        $html .= ' action="' . esc_url_raw($this->action()) . '"';
384
-        $html .= ' method="' . $this->method() . '"';
385
-        $html .= ' name="' . $this->name() . '"';
386
-        $html .= $other_attributes . '>';
387
-        return $html;
388
-    }
389
-
390
-
391
-
392
-    /**
393
-     * ensures that html id for form either ends in "-form" or "-frm"
394
-     * so that id doesn't conflict/collide with other elements
395
-     *
396
-     * @param string $html_id
397
-     * @return string
398
-     */
399
-    protected function get_html_id_for_form($html_id)
400
-    {
401
-        $strlen = strlen($html_id);
402
-        $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4
403
-            ? $html_id
404
-            : $html_id . '-frm';
405
-        return $html_id;
406
-    }
407
-
408
-
409
-    /**
410
-     * returns HTML for generating the closing form HTML tag (</form>)
411
-     *
412
-     * @return string
413
-     * @throws EE_Error
414
-     */
415
-    public function form_close()
416
-    {
417
-        return EEH_HTML::nl(-1, 'form')
418
-               . '</form>'
419
-               . EEH_HTML::nl()
420
-               . '<!-- end of ee-'
421
-               . $this->html_id()
422
-               . '-form -->'
423
-               . EEH_HTML::nl();
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
430
-     * wp_enqueue_style; the scripts could have optionally been registered earlier)
431
-     * Default does nothing, but child classes can override
432
-     *
433
-     * @return void
434
-     */
435
-    public function enqueue_js()
436
-    {
437
-        // defaults to enqueue NO js or css
438
-    }
439
-
440
-
441
-
442
-    /**
443
-     * Adds any extra data needed by js. Eventually we'll call wp_localize_script
444
-     * with it, and it will be on each form section's 'other_data' property.
445
-     * By default nothing is added, but child classes can extend this method to add something.
446
-     * Eg, if you have an input that will cause a modal dialog to appear,
447
-     * here you could add an entry like 'modal_dialog_inputs' to this array
448
-     * to map between the input's html ID and the modal dialogue's ID, so that
449
-     * your JS code will know where to find the modal dialog when the input is pressed.
450
-     * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
451
-     *
452
-     * @param array $form_other_js_data
453
-     * @return array
454
-     */
455
-    public function get_other_js_data($form_other_js_data = array())
456
-    {
457
-        return $form_other_js_data;
458
-    }
459
-
460
-
461
-
462
-    /**
463
-     * This isn't just the name of an input, it's a path pointing to an input. The
464
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
465
-     * dot-dot-slash (../) means to ascend into the parent section.
466
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
467
-     * which will be returned.
468
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
469
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
470
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
471
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
472
-     * Etc
473
-     *
474
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
475
-     * @return EE_Form_Section_Base
476
-     */
477
-    public function find_section_from_path($form_section_path)
478
-    {
479
-        if (strpos($form_section_path, '/') === 0) {
480
-            $form_section_path = substr($form_section_path, strlen('/'));
481
-        }
482
-        if (empty($form_section_path)) {
483
-            return $this;
484
-        }
485
-        if (strpos($form_section_path, '../') === 0) {
486
-            $parent = $this->parent_section();
487
-            $form_section_path = substr($form_section_path, strlen('../'));
488
-            if ($parent instanceof EE_Form_Section_Base) {
489
-                return $parent->find_section_from_path($form_section_path);
490
-            }
491
-            if (empty($form_section_path)) {
492
-                return $this;
493
-            }
494
-        }
495
-        // couldn't find it using simple parent following
496
-        return null;
497
-    }
242
+
243
+	/**
244
+	 * Gets the HTML for displaying this form section
245
+	 *
246
+	 * @return string
247
+	 */
248
+	abstract public function get_html();
249
+
250
+
251
+	/**
252
+	 * @param bool $add_pound_sign
253
+	 * @return string
254
+	 * @throws EE_Error
255
+	 */
256
+	public function html_id($add_pound_sign = false)
257
+	{
258
+		$this->_set_default_html_id_if_empty();
259
+		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
260
+	}
261
+
262
+
263
+
264
+	/**
265
+	 * @return string
266
+	 */
267
+	public function html_class()
268
+	{
269
+		return $this->_html_class;
270
+	}
271
+
272
+
273
+
274
+	/**
275
+	 * @return string
276
+	 */
277
+	public function html_style()
278
+	{
279
+		return $this->_html_style;
280
+	}
281
+
282
+
283
+
284
+	/**
285
+	 * @param mixed $html_class
286
+	 */
287
+	public function set_html_class($html_class)
288
+	{
289
+		$this->_html_class = $html_class;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 * @param mixed $html_id
296
+	 */
297
+	public function set_html_id($html_id)
298
+	{
299
+		$this->_html_id = $html_id;
300
+	}
301
+
302
+
303
+
304
+	/**
305
+	 * @param mixed $html_style
306
+	 */
307
+	public function set_html_style($html_style)
308
+	{
309
+		$this->_html_style = $html_style;
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * @param string $other_html_attributes
316
+	 */
317
+	public function set_other_html_attributes($other_html_attributes)
318
+	{
319
+		$this->_other_html_attributes = $other_html_attributes;
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * @return string
326
+	 */
327
+	public function other_html_attributes()
328
+	{
329
+		return ! empty($this->_other_html_attributes) ? ' ' . $this->_other_html_attributes : '';
330
+	}
331
+
332
+
333
+
334
+	/**
335
+	 * Gets the name of the form section. This is not the same as the HTML name.
336
+	 *
337
+	 * @throws EE_Error
338
+	 * @return string
339
+	 */
340
+	public function name()
341
+	{
342
+		if (! $this->_construction_finalized) {
343
+			throw new EE_Error(sprintf(esc_html__(
344
+				'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
345
+				'event_espresso'
346
+			), get_class($this)));
347
+		}
348
+		return $this->_name;
349
+	}
350
+
351
+
352
+
353
+	/**
354
+	 * Gets the parent section
355
+	 *
356
+	 * @return EE_Form_Section_Proper
357
+	 */
358
+	public function parent_section()
359
+	{
360
+		return $this->_parent_section;
361
+	}
362
+
363
+
364
+	/**
365
+	 * returns HTML for generating the opening form HTML tag (<form>)
366
+	 *
367
+	 * @param string $action           the URL the form is submitted to
368
+	 * @param string $method           POST (default) or GET
369
+	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
370
+	 * @return string
371
+	 * @throws EE_Error
372
+	 */
373
+	public function form_open($action = '', $method = '', $other_attributes = '')
374
+	{
375
+		if (! empty($action)) {
376
+			$this->set_action($action);
377
+		}
378
+		if (! empty($method)) {
379
+			$this->set_method($method);
380
+		}
381
+		$html = EEH_HTML::nl(1, 'form') . '<form';
382
+		$html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
383
+		$html .= ' action="' . esc_url_raw($this->action()) . '"';
384
+		$html .= ' method="' . $this->method() . '"';
385
+		$html .= ' name="' . $this->name() . '"';
386
+		$html .= $other_attributes . '>';
387
+		return $html;
388
+	}
389
+
390
+
391
+
392
+	/**
393
+	 * ensures that html id for form either ends in "-form" or "-frm"
394
+	 * so that id doesn't conflict/collide with other elements
395
+	 *
396
+	 * @param string $html_id
397
+	 * @return string
398
+	 */
399
+	protected function get_html_id_for_form($html_id)
400
+	{
401
+		$strlen = strlen($html_id);
402
+		$html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4
403
+			? $html_id
404
+			: $html_id . '-frm';
405
+		return $html_id;
406
+	}
407
+
408
+
409
+	/**
410
+	 * returns HTML for generating the closing form HTML tag (</form>)
411
+	 *
412
+	 * @return string
413
+	 * @throws EE_Error
414
+	 */
415
+	public function form_close()
416
+	{
417
+		return EEH_HTML::nl(-1, 'form')
418
+			   . '</form>'
419
+			   . EEH_HTML::nl()
420
+			   . '<!-- end of ee-'
421
+			   . $this->html_id()
422
+			   . '-form -->'
423
+			   . EEH_HTML::nl();
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
430
+	 * wp_enqueue_style; the scripts could have optionally been registered earlier)
431
+	 * Default does nothing, but child classes can override
432
+	 *
433
+	 * @return void
434
+	 */
435
+	public function enqueue_js()
436
+	{
437
+		// defaults to enqueue NO js or css
438
+	}
439
+
440
+
441
+
442
+	/**
443
+	 * Adds any extra data needed by js. Eventually we'll call wp_localize_script
444
+	 * with it, and it will be on each form section's 'other_data' property.
445
+	 * By default nothing is added, but child classes can extend this method to add something.
446
+	 * Eg, if you have an input that will cause a modal dialog to appear,
447
+	 * here you could add an entry like 'modal_dialog_inputs' to this array
448
+	 * to map between the input's html ID and the modal dialogue's ID, so that
449
+	 * your JS code will know where to find the modal dialog when the input is pressed.
450
+	 * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
451
+	 *
452
+	 * @param array $form_other_js_data
453
+	 * @return array
454
+	 */
455
+	public function get_other_js_data($form_other_js_data = array())
456
+	{
457
+		return $form_other_js_data;
458
+	}
459
+
460
+
461
+
462
+	/**
463
+	 * This isn't just the name of an input, it's a path pointing to an input. The
464
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
465
+	 * dot-dot-slash (../) means to ascend into the parent section.
466
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
467
+	 * which will be returned.
468
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
469
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
470
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
471
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
472
+	 * Etc
473
+	 *
474
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
475
+	 * @return EE_Form_Section_Base
476
+	 */
477
+	public function find_section_from_path($form_section_path)
478
+	{
479
+		if (strpos($form_section_path, '/') === 0) {
480
+			$form_section_path = substr($form_section_path, strlen('/'));
481
+		}
482
+		if (empty($form_section_path)) {
483
+			return $this;
484
+		}
485
+		if (strpos($form_section_path, '../') === 0) {
486
+			$parent = $this->parent_section();
487
+			$form_section_path = substr($form_section_path, strlen('../'));
488
+			if ($parent instanceof EE_Form_Section_Base) {
489
+				return $parent->find_section_from_path($form_section_path);
490
+			}
491
+			if (empty($form_section_path)) {
492
+				return $this;
493
+			}
494
+		}
495
+		// couldn't find it using simple parent following
496
+		return null;
497
+	}
498 498
 }
499 499
 // End of file EE_Form_Section_Base.form.php
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         // used by display strategies
95 95
         // assign incoming values to properties
96 96
         foreach ($options_array as $key => $value) {
97
-            $key = '_' . $key;
97
+            $key = '_'.$key;
98 98
             if (property_exists($this, $key) && empty($this->{$key})) {
99 99
                 $this->{$key} = $value;
100 100
                 if ($key === '_subsections' && ! is_array($value)) {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function ensure_construct_finalized_called()
136 136
     {
137
-        if (! $this->_construction_finalized) {
137
+        if ( ! $this->_construction_finalized) {
138 138
             $this->_construct_finalize($this->_parent_section, $this->_name);
139 139
         }
140 140
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     protected function _set_default_html_id_if_empty()
199 199
     {
200
-        if (! $this->_html_id) {
200
+        if ( ! $this->_html_id) {
201 201
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
202 202
                 $this->_html_id = $this->_parent_section->html_id()
203 203
                                   . '-'
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     public function html_id($add_pound_sign = false)
257 257
     {
258 258
         $this->_set_default_html_id_if_empty();
259
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
259
+        return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
260 260
     }
261 261
 
262 262
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      */
327 327
     public function other_html_attributes()
328 328
     {
329
-        return ! empty($this->_other_html_attributes) ? ' ' . $this->_other_html_attributes : '';
329
+        return ! empty($this->_other_html_attributes) ? ' '.$this->_other_html_attributes : '';
330 330
     }
331 331
 
332 332
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      */
340 340
     public function name()
341 341
     {
342
-        if (! $this->_construction_finalized) {
342
+        if ( ! $this->_construction_finalized) {
343 343
             throw new EE_Error(sprintf(esc_html__(
344 344
                 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
345 345
                 'event_espresso'
@@ -372,18 +372,18 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function form_open($action = '', $method = '', $other_attributes = '')
374 374
     {
375
-        if (! empty($action)) {
375
+        if ( ! empty($action)) {
376 376
             $this->set_action($action);
377 377
         }
378
-        if (! empty($method)) {
378
+        if ( ! empty($method)) {
379 379
             $this->set_method($method);
380 380
         }
381
-        $html = EEH_HTML::nl(1, 'form') . '<form';
382
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
383
-        $html .= ' action="' . esc_url_raw($this->action()) . '"';
384
-        $html .= ' method="' . $this->method() . '"';
385
-        $html .= ' name="' . $this->name() . '"';
386
-        $html .= $other_attributes . '>';
381
+        $html = EEH_HTML::nl(1, 'form').'<form';
382
+        $html .= $this->html_id() !== '' ? ' id="'.$this->get_html_id_for_form($this->html_id()).'"' : '';
383
+        $html .= ' action="'.esc_url_raw($this->action()).'"';
384
+        $html .= ' method="'.$this->method().'"';
385
+        $html .= ' name="'.$this->name().'"';
386
+        $html .= $other_attributes.'>';
387 387
         return $html;
388 388
     }
389 389
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $strlen = strlen($html_id);
402 402
         $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4
403 403
             ? $html_id
404
-            : $html_id . '-frm';
404
+            : $html_id.'-frm';
405 405
         return $html_id;
406 406
     }
407 407
 
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/PreviewEventDeletion.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -33,144 +33,144 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class PreviewEventDeletion extends JobHandler
35 35
 {
36
-    /**
37
-     * @var NodeGroupDao
38
-     */
39
-    protected $model_obj_node_group_persister;
36
+	/**
37
+	 * @var NodeGroupDao
38
+	 */
39
+	protected $model_obj_node_group_persister;
40 40
 
41
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
42
-    {
43
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
44
-    }
41
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
42
+	{
43
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
44
+	}
45 45
 
46
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
47 47
 
48
-    /**
49
-     *
50
-     * @param JobParameters $job_parameters
51
-     * @return JobStepResponse
52
-     * @throws EE_Error
53
-     * @throws InvalidDataTypeException
54
-     * @throws InvalidInterfaceException
55
-     * @throws InvalidArgumentException
56
-     * @throws ReflectionException
57
-     */
58
-    public function create_job(JobParameters $job_parameters)
59
-    {
60
-        // Set the "root" model objects we will want to delete (record their ID and model)
61
-        $event_ids = $job_parameters->request_datum('EVT_IDs', array());
62
-        // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
63
-        // prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
64
-        // we have no UI to access them independent of events, so they may as well get deleted too.)
65
-        $roots = [];
66
-        foreach ($event_ids as $event_id) {
67
-            $roots[] = new ModelObjNode(
68
-                $event_id,
69
-                EEM_Event::instance()
70
-            );
71
-            // Also, we want to delete their related, non-global, tickets, prices and message templates
72
-            $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
73
-                [
74
-                    [
75
-                        'TKT_is_default' => false,
76
-                        'Datetime.EVT_ID' => $event_id
77
-                    ]
78
-                ]
79
-            );
80
-            foreach ($related_non_global_tickets as $ticket) {
81
-                $roots[] = new ModelObjNode(
82
-                    $ticket->ID(),
83
-                    $ticket->get_model(),
84
-                    ['Registration']
85
-                );
86
-            }
87
-            $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
88
-                [
89
-                    [
90
-                        'PRC_is_default' => false,
91
-                        'Ticket.Datetime.EVT_ID' => $event_id
92
-                    ]
93
-                ]
94
-            );
95
-            foreach ($related_non_global_prices as $price) {
96
-                $roots[] = new ModelObjNode(
97
-                    $price->ID(),
98
-                    $price->get_model()
99
-                );
100
-            }
101
-        }
102
-        $transactions_ids = $this->getTransactionsToDelete($event_ids);
103
-        foreach ($transactions_ids as $transaction_id) {
104
-            $roots[] = new ModelObjNode(
105
-                $transaction_id,
106
-                EEM_Transaction::instance(),
107
-                ['Registration']
108
-            );
109
-        }
110
-        $job_parameters->add_extra_data('roots', $roots);
111
-        // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
112
-        // an accurate count.)
113
-        $estimated_work_per_model_obj = 10;
114
-        $count_regs = EEM_Registration::instance()->count(
115
-            [
116
-                [
117
-                    'EVT_ID' => ['IN', $event_ids]
118
-                ]
119
-            ]
120
-        );
121
-        $job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
122
-        $this->updateTextHeader(esc_html__('Generating preview of data to be deleted...', 'event_espresso'));
123
-        return new JobStepResponse($job_parameters, $this->feedback);
124
-    }
48
+	/**
49
+	 *
50
+	 * @param JobParameters $job_parameters
51
+	 * @return JobStepResponse
52
+	 * @throws EE_Error
53
+	 * @throws InvalidDataTypeException
54
+	 * @throws InvalidInterfaceException
55
+	 * @throws InvalidArgumentException
56
+	 * @throws ReflectionException
57
+	 */
58
+	public function create_job(JobParameters $job_parameters)
59
+	{
60
+		// Set the "root" model objects we will want to delete (record their ID and model)
61
+		$event_ids = $job_parameters->request_datum('EVT_IDs', array());
62
+		// Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
63
+		// prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
64
+		// we have no UI to access them independent of events, so they may as well get deleted too.)
65
+		$roots = [];
66
+		foreach ($event_ids as $event_id) {
67
+			$roots[] = new ModelObjNode(
68
+				$event_id,
69
+				EEM_Event::instance()
70
+			);
71
+			// Also, we want to delete their related, non-global, tickets, prices and message templates
72
+			$related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
73
+				[
74
+					[
75
+						'TKT_is_default' => false,
76
+						'Datetime.EVT_ID' => $event_id
77
+					]
78
+				]
79
+			);
80
+			foreach ($related_non_global_tickets as $ticket) {
81
+				$roots[] = new ModelObjNode(
82
+					$ticket->ID(),
83
+					$ticket->get_model(),
84
+					['Registration']
85
+				);
86
+			}
87
+			$related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
88
+				[
89
+					[
90
+						'PRC_is_default' => false,
91
+						'Ticket.Datetime.EVT_ID' => $event_id
92
+					]
93
+				]
94
+			);
95
+			foreach ($related_non_global_prices as $price) {
96
+				$roots[] = new ModelObjNode(
97
+					$price->ID(),
98
+					$price->get_model()
99
+				);
100
+			}
101
+		}
102
+		$transactions_ids = $this->getTransactionsToDelete($event_ids);
103
+		foreach ($transactions_ids as $transaction_id) {
104
+			$roots[] = new ModelObjNode(
105
+				$transaction_id,
106
+				EEM_Transaction::instance(),
107
+				['Registration']
108
+			);
109
+		}
110
+		$job_parameters->add_extra_data('roots', $roots);
111
+		// Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
112
+		// an accurate count.)
113
+		$estimated_work_per_model_obj = 10;
114
+		$count_regs = EEM_Registration::instance()->count(
115
+			[
116
+				[
117
+					'EVT_ID' => ['IN', $event_ids]
118
+				]
119
+			]
120
+		);
121
+		$job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
122
+		$this->updateTextHeader(esc_html__('Generating preview of data to be deleted...', 'event_espresso'));
123
+		return new JobStepResponse($job_parameters, $this->feedback);
124
+	}
125 125
 
126
-    /**
127
-     * @since 4.10.12.p
128
-     * @param EE_Base_Class[] $model_objs
129
-     * @param array $dont_traverse_models
130
-     * @return array
131
-     * @throws EE_Error
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidInterfaceException
135
-     * @throws ReflectionException
136
-     */
137
-    protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
138
-    {
139
-        $nodes = [];
140
-        foreach ($model_objs as $model_obj) {
141
-            $nodes[] = new ModelObjNode(
142
-                $model_obj->ID(),
143
-                $model_obj->get_model(),
144
-                $dont_traverse_models
145
-            );
146
-        }
147
-        return $nodes;
148
-    }
126
+	/**
127
+	 * @since 4.10.12.p
128
+	 * @param EE_Base_Class[] $model_objs
129
+	 * @param array $dont_traverse_models
130
+	 * @return array
131
+	 * @throws EE_Error
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidInterfaceException
135
+	 * @throws ReflectionException
136
+	 */
137
+	protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
138
+	{
139
+		$nodes = [];
140
+		foreach ($model_objs as $model_obj) {
141
+			$nodes[] = new ModelObjNode(
142
+				$model_obj->ID(),
143
+				$model_obj->get_model(),
144
+				$dont_traverse_models
145
+			);
146
+		}
147
+		return $nodes;
148
+	}
149 149
 
150
-    /**
151
-     * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
152
-     * (Ones that are related to other events can stay around until those other events are deleted too.)
153
-     * @since 4.10.12.p
154
-     * @param $event_ids
155
-     * @return array of transaction IDs
156
-     */
157
-    protected function getTransactionsToDelete($event_ids)
158
-    {
159
-        if (empty($event_ids)) {
160
-            return [];
161
-        }
162
-        global $wpdb;
163
-        $event_ids = array_map('absint', $event_ids);
164
-        $imploded_sanitized_event_ids = implode(',', $event_ids);
165
-        // Select transactions with registrations for the events $event_ids which also don't have registrations
166
-        // for any events NOT in $event_ids.
167
-        // Notice the outer query searched for transactions whose registrations ARE in $event_ids,
168
-        // whereas the inner query checks if the outer query's transaction has any registrations that are
169
-        // NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
170
-        return array_map(
171
-            'absint',
172
-            $wpdb->get_col(
173
-                "SELECT
150
+	/**
151
+	 * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
152
+	 * (Ones that are related to other events can stay around until those other events are deleted too.)
153
+	 * @since 4.10.12.p
154
+	 * @param $event_ids
155
+	 * @return array of transaction IDs
156
+	 */
157
+	protected function getTransactionsToDelete($event_ids)
158
+	{
159
+		if (empty($event_ids)) {
160
+			return [];
161
+		}
162
+		global $wpdb;
163
+		$event_ids = array_map('absint', $event_ids);
164
+		$imploded_sanitized_event_ids = implode(',', $event_ids);
165
+		// Select transactions with registrations for the events $event_ids which also don't have registrations
166
+		// for any events NOT in $event_ids.
167
+		// Notice the outer query searched for transactions whose registrations ARE in $event_ids,
168
+		// whereas the inner query checks if the outer query's transaction has any registrations that are
169
+		// NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
170
+		return array_map(
171
+			'absint',
172
+			$wpdb->get_col(
173
+				"SELECT
174 174
                       DISTINCT t.TXN_ID
175 175
                     FROM
176 176
                       {$wpdb->prefix}esp_transaction t INNER JOIN
@@ -188,90 +188,90 @@  discard block
 block discarded – undo
188 188
                            tsub.TXN_ID=t.TXN_ID AND
189 189
                            rsub.EVT_ID NOT IN ({$imploded_sanitized_event_ids})
190 190
                        )"
191
-            )
192
-        );
193
-    }
191
+			)
192
+		);
193
+	}
194 194
 
195
-    /**
196
-     * Performs another step of the job
197
-     * @param JobParameters $job_parameters
198
-     * @param int $batch_size
199
-     * @return JobStepResponse
200
-     */
201
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
202
-    {
203
-        // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
204
-        // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
205
-        // 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
206
-        $batch_size *= 3;
207
-        $units_processed = 0;
208
-        foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
209
-            if ($units_processed >= $batch_size) {
210
-                break;
211
-            }
212
-            if (!$root_node instanceof ModelObjNode) {
213
-                throw new InvalidClassException('ModelObjNode');
214
-            }
215
-            if ($root_node->isComplete()) {
216
-                continue;
217
-            }
218
-            $units_processed += $root_node->visit($batch_size - $units_processed);
219
-        }
220
-        $job_parameters->mark_processed($units_processed);
221
-        // If the most-recently processed root node is complete, we must be all done because we're doing them
222
-        // sequentially.
223
-        if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) {
224
-            $job_parameters->set_status(JobParameters::status_complete);
225
-            // Show a full progress bar.
226
-            $job_parameters->set_units_processed($job_parameters->job_size());
227
-            $deletion_job_code = $job_parameters->request_datum('deletion_job_code');
228
-            $this->model_obj_node_group_persister->persistModelObjNodesGroup(
229
-                $job_parameters->extra_datum('roots'),
230
-                $deletion_job_code
231
-            );
232
-            return new JobStepResponse($job_parameters, $this->feedback);
233
-        }
234
-        // Because the job size was a guess, it may have likely been proven wrong.
235
-        // We don't want to show more work done than we originally said there would be.
236
-        // So adjust the estimate.
237
-        if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
238
-            $job_parameters->set_job_size($job_parameters->job_size() * 2);
239
-        }
240
-        $this->displayJobStepResults(
241
-            $units_processed,
242
-            esc_html__('Identified up to %d potential items for deletion.', 'event_espresso')
243
-        );
244
-        return new JobStepResponse($job_parameters, $this->feedback);
245
-    }
195
+	/**
196
+	 * Performs another step of the job
197
+	 * @param JobParameters $job_parameters
198
+	 * @param int $batch_size
199
+	 * @return JobStepResponse
200
+	 */
201
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
202
+	{
203
+		// Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
204
+		// about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
205
+		// 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
206
+		$batch_size *= 3;
207
+		$units_processed = 0;
208
+		foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
209
+			if ($units_processed >= $batch_size) {
210
+				break;
211
+			}
212
+			if (!$root_node instanceof ModelObjNode) {
213
+				throw new InvalidClassException('ModelObjNode');
214
+			}
215
+			if ($root_node->isComplete()) {
216
+				continue;
217
+			}
218
+			$units_processed += $root_node->visit($batch_size - $units_processed);
219
+		}
220
+		$job_parameters->mark_processed($units_processed);
221
+		// If the most-recently processed root node is complete, we must be all done because we're doing them
222
+		// sequentially.
223
+		if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) {
224
+			$job_parameters->set_status(JobParameters::status_complete);
225
+			// Show a full progress bar.
226
+			$job_parameters->set_units_processed($job_parameters->job_size());
227
+			$deletion_job_code = $job_parameters->request_datum('deletion_job_code');
228
+			$this->model_obj_node_group_persister->persistModelObjNodesGroup(
229
+				$job_parameters->extra_datum('roots'),
230
+				$deletion_job_code
231
+			);
232
+			return new JobStepResponse($job_parameters, $this->feedback);
233
+		}
234
+		// Because the job size was a guess, it may have likely been proven wrong.
235
+		// We don't want to show more work done than we originally said there would be.
236
+		// So adjust the estimate.
237
+		if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
238
+			$job_parameters->set_job_size($job_parameters->job_size() * 2);
239
+		}
240
+		$this->displayJobStepResults(
241
+			$units_processed,
242
+			esc_html__('Identified up to %d potential items for deletion.', 'event_espresso')
243
+		);
244
+		return new JobStepResponse($job_parameters, $this->feedback);
245
+	}
246 246
 
247
-    /**
248
-     * Performs any clean-up logic when we know the job is completed
249
-     * @param JobParameters $job_parameters
250
-     * @return JobStepResponse
251
-     */
252
-    public function cleanup_job(JobParameters $job_parameters)
253
-    {
254
-        $this->displayJobFinalResults(
255
-            $job_parameters,
256
-            esc_html__('found %d potential items for deletion.', 'event_espresso')
257
-        );
258
-        $this->updateText(
259
-            $this->infoWrapper(
260
-                sprintf(
261
-                    esc_html__(
262
-                        'If not automatically redirected in %1$s seconds, click here to %2$scontinue to the confirmation step%3$s',
263
-                        'event_espresso'
264
-                    ),
265
-                    '<span id="ee-redirect-timer">10</span>',
266
-                    '<a href="' . $job_parameters->request_datum('return_url') . '">',
267
-                    '</a>'
268
-                )
269
-            )
270
-        );
271
-        // Nothing much to do.
272
-        // We can't delete the option with the built tree because we may need it in a moment for the deletion
273
-        return new JobStepResponse($job_parameters, $this->feedback);
274
-    }
247
+	/**
248
+	 * Performs any clean-up logic when we know the job is completed
249
+	 * @param JobParameters $job_parameters
250
+	 * @return JobStepResponse
251
+	 */
252
+	public function cleanup_job(JobParameters $job_parameters)
253
+	{
254
+		$this->displayJobFinalResults(
255
+			$job_parameters,
256
+			esc_html__('found %d potential items for deletion.', 'event_espresso')
257
+		);
258
+		$this->updateText(
259
+			$this->infoWrapper(
260
+				sprintf(
261
+					esc_html__(
262
+						'If not automatically redirected in %1$s seconds, click here to %2$scontinue to the confirmation step%3$s',
263
+						'event_espresso'
264
+					),
265
+					'<span id="ee-redirect-timer">10</span>',
266
+					'<a href="' . $job_parameters->request_datum('return_url') . '">',
267
+					'</a>'
268
+				)
269
+			)
270
+		);
271
+		// Nothing much to do.
272
+		// We can't delete the option with the built tree because we may need it in a moment for the deletion
273
+		return new JobStepResponse($job_parameters, $this->feedback);
274
+	}
275 275
 }
276 276
 // End of file EventDeletion.php
277 277
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             if ($units_processed >= $batch_size) {
210 210
                 break;
211 211
             }
212
-            if (!$root_node instanceof ModelObjNode) {
212
+            if ( ! $root_node instanceof ModelObjNode) {
213 213
                 throw new InvalidClassException('ModelObjNode');
214 214
             }
215 215
             if ($root_node->isComplete()) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         $job_parameters->mark_processed($units_processed);
221 221
         // If the most-recently processed root node is complete, we must be all done because we're doing them
222 222
         // sequentially.
223
-        if (! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) {
223
+        if ( ! isset($root_node) || ($root_node instanceof ModelObjNode && $root_node->isComplete())) {
224 224
             $job_parameters->set_status(JobParameters::status_complete);
225 225
             // Show a full progress bar.
226 226
             $job_parameters->set_units_processed($job_parameters->job_size());
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                         'event_espresso'
264 264
                     ),
265 265
                     '<span id="ee-redirect-timer">10</span>',
266
-                    '<a href="' . $job_parameters->request_datum('return_url') . '">',
266
+                    '<a href="'.$job_parameters->request_datum('return_url').'">',
267 267
                     '</a>'
268 268
                 )
269 269
             )
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/ExecuteBatchDeletion.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -26,181 +26,181 @@
 block discarded – undo
26 26
  */
27 27
 class ExecuteBatchDeletion extends JobHandler
28 28
 {
29
-    /**
30
-     * @var NodeGroupDao
31
-     */
32
-    protected $model_obj_node_group_persister;
29
+	/**
30
+	 * @var NodeGroupDao
31
+	 */
32
+	protected $model_obj_node_group_persister;
33 33
 
34 34
 
35
-    /**
36
-     * @param NodeGroupDao $model_obj_node_group_persister
37
-     */
38
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
39
-    {
40
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
41
-    }
35
+	/**
36
+	 * @param NodeGroupDao $model_obj_node_group_persister
37
+	 */
38
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
39
+	{
40
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
41
+	}
42 42
 
43 43
 
44
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45 45
 
46 46
 
47
-    /**
48
-     *
49
-     * @param JobParameters $job_parameters
50
-     * @return JobStepResponse
51
-     * @throws EE_Error
52
-     * @throws ReflectionException
53
-     * @throws Exception
54
-     */
55
-    public function create_job(JobParameters $job_parameters)
56
-    {
57
-        $deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
58
-        $roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
59
-        if ($roots === null) {
60
-            throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
61
-        }
62
-        $models_and_ids_to_delete = [];
63
-        foreach ($roots as $root) {
64
-            if (! $root instanceof ModelObjNode) {
65
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
66
-            }
67
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
68
-        }
69
-        $job_parameters->set_extra_data(
70
-            [
71
-                'models_and_ids_to_delete' => $models_and_ids_to_delete
72
-            ]
73
-        );
74
-        // Find the job's actual size.
75
-        $job_size = 0;
76
-        foreach ($models_and_ids_to_delete as $ids) {
77
-            $job_size += count($ids);
78
-        }
79
-        $job_parameters->set_job_size($job_size);
80
-        $this->updateTextHeader(esc_html__('Beginning to delete items...', 'event_espresso'));
81
-        return new JobStepResponse($job_parameters, $this->feedback);
82
-    }
47
+	/**
48
+	 *
49
+	 * @param JobParameters $job_parameters
50
+	 * @return JobStepResponse
51
+	 * @throws EE_Error
52
+	 * @throws ReflectionException
53
+	 * @throws Exception
54
+	 */
55
+	public function create_job(JobParameters $job_parameters)
56
+	{
57
+		$deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
58
+		$roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
59
+		if ($roots === null) {
60
+			throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
61
+		}
62
+		$models_and_ids_to_delete = [];
63
+		foreach ($roots as $root) {
64
+			if (! $root instanceof ModelObjNode) {
65
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
66
+			}
67
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
68
+		}
69
+		$job_parameters->set_extra_data(
70
+			[
71
+				'models_and_ids_to_delete' => $models_and_ids_to_delete
72
+			]
73
+		);
74
+		// Find the job's actual size.
75
+		$job_size = 0;
76
+		foreach ($models_and_ids_to_delete as $ids) {
77
+			$job_size += count($ids);
78
+		}
79
+		$job_parameters->set_job_size($job_size);
80
+		$this->updateTextHeader(esc_html__('Beginning to delete items...', 'event_espresso'));
81
+		return new JobStepResponse($job_parameters, $this->feedback);
82
+	}
83 83
 
84 84
 
85
-    /**
86
-     * Performs another step of the job
87
-     *
88
-     * @param JobParameters $job_parameters
89
-     * @param int           $batch_size
90
-     * @return JobStepResponse
91
-     * @throws EE_Error
92
-     * @throws ReflectionException
93
-     */
94
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
95
-    {
96
-        // We already have the items IDs. So deleting is really fast. Let's speed it up.
97
-        $batch_size *= 10;
98
-        $units_processed = 0;
99
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
100
-        // Build a new list of everything leftover after this request's of deletions.
101
-        $models_and_ids_remaining = [];
102
-        foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
103
-            if ($units_processed < $batch_size) {
104
-                $model = EE_Registry::instance()->load_model($model_name);
105
-                $ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
106
-                if ($model->has_primary_key_field()) {
107
-                    $where_conditions = [
108
-                        $model->primary_key_name() => [
109
-                            'IN',
110
-                            $ids_to_delete_this_query
111
-                        ]
112
-                    ];
113
-                } else {
114
-                    $where_conditions = [
115
-                        'OR' => []
116
-                    ];
117
-                    foreach ($ids_to_delete_this_query as $index_primary_key_string) {
118
-                        $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
119
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
120
-                    }
121
-                }
122
-                // Deleting time!
123
-                // The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
124
-                // two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
125
-                $model->delete_permanently(
126
-                    [
127
-                        $where_conditions
128
-                    ],
129
-                    false
130
-                );
131
-                $units_processed += count($ids_to_delete_this_query);
132
-                $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
133
-                // If there's any more from this model, we'll do them next time.
134
-                if (count($remaining_ids) > 0) {
135
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
136
-                }
137
-            } else {
138
-                $models_and_ids_remaining[ $model_name ] = $ids_to_delete;
139
-            }
140
-        }
141
-        $job_parameters->mark_processed($units_processed);
142
-        // All done deleting for this request. Is there anything to do next time?
143
-        if (empty($models_and_ids_remaining)) {
144
-            $job_parameters->set_status(JobParameters::status_complete);
145
-            return new JobStepResponse($job_parameters, $this->feedback);
146
-        }
147
-        $job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
148
-        $this->displayJobStepResults(
149
-            $units_processed,
150
-            esc_html__('Deleted %d items.', 'event_espresso')
151
-        );
152
-        return new JobStepResponse($job_parameters, $this->feedback);
153
-    }
85
+	/**
86
+	 * Performs another step of the job
87
+	 *
88
+	 * @param JobParameters $job_parameters
89
+	 * @param int           $batch_size
90
+	 * @return JobStepResponse
91
+	 * @throws EE_Error
92
+	 * @throws ReflectionException
93
+	 */
94
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
95
+	{
96
+		// We already have the items IDs. So deleting is really fast. Let's speed it up.
97
+		$batch_size *= 10;
98
+		$units_processed = 0;
99
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
100
+		// Build a new list of everything leftover after this request's of deletions.
101
+		$models_and_ids_remaining = [];
102
+		foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
103
+			if ($units_processed < $batch_size) {
104
+				$model = EE_Registry::instance()->load_model($model_name);
105
+				$ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
106
+				if ($model->has_primary_key_field()) {
107
+					$where_conditions = [
108
+						$model->primary_key_name() => [
109
+							'IN',
110
+							$ids_to_delete_this_query
111
+						]
112
+					];
113
+				} else {
114
+					$where_conditions = [
115
+						'OR' => []
116
+					];
117
+					foreach ($ids_to_delete_this_query as $index_primary_key_string) {
118
+						$keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
119
+						$where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
120
+					}
121
+				}
122
+				// Deleting time!
123
+				// The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
124
+				// two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
125
+				$model->delete_permanently(
126
+					[
127
+						$where_conditions
128
+					],
129
+					false
130
+				);
131
+				$units_processed += count($ids_to_delete_this_query);
132
+				$remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
133
+				// If there's any more from this model, we'll do them next time.
134
+				if (count($remaining_ids) > 0) {
135
+					$models_and_ids_remaining[ $model_name ] = $remaining_ids;
136
+				}
137
+			} else {
138
+				$models_and_ids_remaining[ $model_name ] = $ids_to_delete;
139
+			}
140
+		}
141
+		$job_parameters->mark_processed($units_processed);
142
+		// All done deleting for this request. Is there anything to do next time?
143
+		if (empty($models_and_ids_remaining)) {
144
+			$job_parameters->set_status(JobParameters::status_complete);
145
+			return new JobStepResponse($job_parameters, $this->feedback);
146
+		}
147
+		$job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
148
+		$this->displayJobStepResults(
149
+			$units_processed,
150
+			esc_html__('Deleted %d items.', 'event_espresso')
151
+		);
152
+		return new JobStepResponse($job_parameters, $this->feedback);
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * Performs any clean-up logic when we know the job is completed
158
-     *
159
-     * @param JobParameters $job_parameters
160
-     * @return JobStepResponse
161
-     * @throws EE_Error
162
-     * @throws ReflectionException
163
-     */
164
-    public function cleanup_job(JobParameters $job_parameters)
165
-    {
166
-        $this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
167
-            $job_parameters->request_datum('deletion_job_code')
168
-        );
169
-        // For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
170
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
171
-        foreach ($models_and_ids_to_delete['Event'] as $event_id) {
172
-            // Create a log entry so we know who and when this event was permanently deleted.
173
-            (EE_Change_Log::new_instance(
174
-                [
175
-                    'OBJ_ID' => $event_id,
176
-                    'OBJ_type' => 'Event',
177
-                    'LOG_message' => sprintf(
178
-                        esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
179
-                        $event_id
180
-                    )
181
-                ]
182
-            ))->save();
183
-            do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
184
-        }
185
-        $this->displayJobFinalResults(
186
-            $job_parameters,
187
-            esc_html__('All Done. Deleted a total of %d items.', 'event_espresso')
188
-        );
189
-        $this->updateText(
190
-            $this->infoWrapper(
191
-                sprintf(
192
-                    esc_html__(
193
-                        'If not automatically redirected in %1$s seconds, click here to return to the %2$sprevious admin screen%3$s',
194
-                        'event_espresso'
195
-                    ),
196
-                    '<span id="ee-redirect-timer">10</span>',
197
-                    '<a href="' . $job_parameters->request_datum('return_url') . '">',
198
-                    '</a>'
199
-                )
200
-            )
201
-        );
202
-        return new JobStepResponse($job_parameters, $this->feedback);
203
-    }
156
+	/**
157
+	 * Performs any clean-up logic when we know the job is completed
158
+	 *
159
+	 * @param JobParameters $job_parameters
160
+	 * @return JobStepResponse
161
+	 * @throws EE_Error
162
+	 * @throws ReflectionException
163
+	 */
164
+	public function cleanup_job(JobParameters $job_parameters)
165
+	{
166
+		$this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
167
+			$job_parameters->request_datum('deletion_job_code')
168
+		);
169
+		// For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
170
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
171
+		foreach ($models_and_ids_to_delete['Event'] as $event_id) {
172
+			// Create a log entry so we know who and when this event was permanently deleted.
173
+			(EE_Change_Log::new_instance(
174
+				[
175
+					'OBJ_ID' => $event_id,
176
+					'OBJ_type' => 'Event',
177
+					'LOG_message' => sprintf(
178
+						esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
179
+						$event_id
180
+					)
181
+				]
182
+			))->save();
183
+			do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
184
+		}
185
+		$this->displayJobFinalResults(
186
+			$job_parameters,
187
+			esc_html__('All Done. Deleted a total of %d items.', 'event_espresso')
188
+		);
189
+		$this->updateText(
190
+			$this->infoWrapper(
191
+				sprintf(
192
+					esc_html__(
193
+						'If not automatically redirected in %1$s seconds, click here to return to the %2$sprevious admin screen%3$s',
194
+						'event_espresso'
195
+					),
196
+					'<span id="ee-redirect-timer">10</span>',
197
+					'<a href="' . $job_parameters->request_datum('return_url') . '">',
198
+					'</a>'
199
+				)
200
+			)
201
+		);
202
+		return new JobStepResponse($job_parameters, $this->feedback);
203
+	}
204 204
 }
205 205
 // End of file EventDeletion.php
206 206
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         }
62 62
         $models_and_ids_to_delete = [];
63 63
         foreach ($roots as $root) {
64
-            if (! $root instanceof ModelObjNode) {
64
+            if ( ! $root instanceof ModelObjNode) {
65 65
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
66 66
             }
67 67
             $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                     ];
117 117
                     foreach ($ids_to_delete_this_query as $index_primary_key_string) {
118 118
                         $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
119
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
119
+                        $where_conditions['OR']['AND*'.$index_primary_key_string] = $keys_n_values;
120 120
                     }
121 121
                 }
122 122
                 // Deleting time!
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
                 $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
133 133
                 // If there's any more from this model, we'll do them next time.
134 134
                 if (count($remaining_ids) > 0) {
135
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
135
+                    $models_and_ids_remaining[$model_name] = $remaining_ids;
136 136
                 }
137 137
             } else {
138
-                $models_and_ids_remaining[ $model_name ] = $ids_to_delete;
138
+                $models_and_ids_remaining[$model_name] = $ids_to_delete;
139 139
             }
140 140
         }
141 141
         $job_parameters->mark_processed($units_processed);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                         'event_espresso'
195 195
                     ),
196 196
                     '<span id="ee-redirect-timer">10</span>',
197
-                    '<a href="' . $job_parameters->request_datum('return_url') . '">',
197
+                    '<a href="'.$job_parameters->request_datum('return_url').'">',
198 198
                     '</a>'
199 199
                 )
200 200
             )
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlerBaseClasses/JobHandler.php 2 patches
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -17,271 +17,271 @@
 block discarded – undo
17 17
  */
18 18
 abstract class JobHandler implements JobHandlerInterface
19 19
 {
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $feedback = [];
24
-
25
-    /**
26
-     * incoming Request data
27
-     *
28
-     * @var array
29
-     */
30
-    protected $request_data = [];
31
-
32
-    /**
33
-     * Extra data to include as part of the response, literally gets set as JobStepResponse::$_extra_data
34
-     *
35
-     * @var array
36
-     */
37
-    protected $response_data = [];
38
-
39
-
40
-    /**
41
-     * utilized in newer batch job implementations, but forwarding to existing methods for now.
42
-     * Performs any necessary setup for starting the job. This is also a good
43
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
44
-     * when continue_job will be called
45
-     *
46
-     * @param JobParameters $job_parameters
47
-     * @return JobStepResponse
48
-     * @throws BatchRequestException
49
-     * @since $VID:$
50
-     */
51
-    public function createJob(JobParameters $job_parameters): JobStepResponse
52
-    {
53
-        return $this->create_job($job_parameters);
54
-    }
55
-
56
-
57
-    /**
58
-     * utilized in newer batch job implementations, but forwarding to existing methods for now.
59
-     * Performs another step of the job
60
-     *
61
-     * @param JobParameters $job_parameters
62
-     * @param int           $batch_size
63
-     * @return JobStepResponse
64
-     * @throws BatchRequestException
65
-     * @since $VID:$
66
-     */
67
-    public function continueJob(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse
68
-    {
69
-        return $this->continue_job($job_parameters, $batch_size);
70
-    }
71
-
72
-
73
-    /**
74
-     * utilized in newer batch job implementations, but forwarding to existing methods for now.
75
-     * used to advance from one batch job to another
76
-     * primarily used for executing a job assessment phase where an accurate count of items to update can be made,
77
-     * followed by the actual update job.
78
-     *
79
-     * @param JobParameters $job_parameters
80
-     * @return JobStepResponse
81
-     * @since $VID:$
82
-     */
83
-    public function advanceJob(JobParameters $job_parameters): JobStepResponse
84
-    {
85
-        return $this->advance_job($job_parameters);
86
-    }
87
-
88
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
89
-    /**
90
-     * used to advance from one batch job to another
91
-     * primarily used for executing a job assessment phase where an accurate count of items to update can be made,
92
-     * followed by the actual update job.
93
-     * By default, this function won't do anything until overridden in a chile class.
94
-     *
95
-     * @param JobParameters $job_parameters
96
-     * @return JobStepResponse
97
-     * @since $VID:$
98
-     */
99
-    public function advance_job(JobParameters $job_parameters): JobStepResponse
100
-    {
101
-        $job_parameters->set_status(JobParameters::status_continue);
102
-        return new JobStepResponse($job_parameters, $this->feedback);
103
-    }
104
-
105
-
106
-    /**
107
-     * utilized in newer batch job implementations, but forwarding to existing methods for now.
108
-     * Performs any clean-up logic when we know the job is completed
109
-     *
110
-     * @param JobParameters $job_parameters
111
-     * @return JobStepResponse
112
-     * @throws BatchRequestException
113
-     * @since $VID:$
114
-     */
115
-    public function cleanupJob(JobParameters $job_parameters): JobStepResponse
116
-    {
117
-        return $this->cleanup_job($job_parameters);
118
-    }
119
-
120
-
121
-    /**
122
-     * @return array
123
-     */
124
-    public function requestData(): array
125
-    {
126
-        return $this->request_data;
127
-    }
128
-
129
-
130
-    /**
131
-     * @return mixed
132
-     */
133
-    public function getRequestData($key)
134
-    {
135
-        return $this->request_data[ $key ] ?? null;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param array $request_data
141
-     */
142
-    public function setRequestData(array $request_data): void
143
-    {
144
-        $this->request_data = $request_data;
145
-    }
146
-
147
-
148
-    /**
149
-     * @return array
150
-     */
151
-    public function responseData(): array
152
-    {
153
-        return $this->response_data;
154
-    }
155
-
156
-
157
-    /**
158
-     * @param array $response_data
159
-     */
160
-    public function addResponseData(array $response_data): void
161
-    {
162
-        $this->response_data += $response_data;
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * @param array $response_data
169
-     */
170
-    public function setResponseData(array $response_data): void
171
-    {
172
-        $this->response_data = $response_data;
173
-    }
174
-
175
-
176
-
177
-
178
-    protected function displayJobStepResults(int $processed, string $custom_message = '')
179
-    {
180
-        $this->feedback[] = '
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $feedback = [];
24
+
25
+	/**
26
+	 * incoming Request data
27
+	 *
28
+	 * @var array
29
+	 */
30
+	protected $request_data = [];
31
+
32
+	/**
33
+	 * Extra data to include as part of the response, literally gets set as JobStepResponse::$_extra_data
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected $response_data = [];
38
+
39
+
40
+	/**
41
+	 * utilized in newer batch job implementations, but forwarding to existing methods for now.
42
+	 * Performs any necessary setup for starting the job. This is also a good
43
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
44
+	 * when continue_job will be called
45
+	 *
46
+	 * @param JobParameters $job_parameters
47
+	 * @return JobStepResponse
48
+	 * @throws BatchRequestException
49
+	 * @since $VID:$
50
+	 */
51
+	public function createJob(JobParameters $job_parameters): JobStepResponse
52
+	{
53
+		return $this->create_job($job_parameters);
54
+	}
55
+
56
+
57
+	/**
58
+	 * utilized in newer batch job implementations, but forwarding to existing methods for now.
59
+	 * Performs another step of the job
60
+	 *
61
+	 * @param JobParameters $job_parameters
62
+	 * @param int           $batch_size
63
+	 * @return JobStepResponse
64
+	 * @throws BatchRequestException
65
+	 * @since $VID:$
66
+	 */
67
+	public function continueJob(JobParameters $job_parameters, int $batch_size = 50): JobStepResponse
68
+	{
69
+		return $this->continue_job($job_parameters, $batch_size);
70
+	}
71
+
72
+
73
+	/**
74
+	 * utilized in newer batch job implementations, but forwarding to existing methods for now.
75
+	 * used to advance from one batch job to another
76
+	 * primarily used for executing a job assessment phase where an accurate count of items to update can be made,
77
+	 * followed by the actual update job.
78
+	 *
79
+	 * @param JobParameters $job_parameters
80
+	 * @return JobStepResponse
81
+	 * @since $VID:$
82
+	 */
83
+	public function advanceJob(JobParameters $job_parameters): JobStepResponse
84
+	{
85
+		return $this->advance_job($job_parameters);
86
+	}
87
+
88
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
89
+	/**
90
+	 * used to advance from one batch job to another
91
+	 * primarily used for executing a job assessment phase where an accurate count of items to update can be made,
92
+	 * followed by the actual update job.
93
+	 * By default, this function won't do anything until overridden in a chile class.
94
+	 *
95
+	 * @param JobParameters $job_parameters
96
+	 * @return JobStepResponse
97
+	 * @since $VID:$
98
+	 */
99
+	public function advance_job(JobParameters $job_parameters): JobStepResponse
100
+	{
101
+		$job_parameters->set_status(JobParameters::status_continue);
102
+		return new JobStepResponse($job_parameters, $this->feedback);
103
+	}
104
+
105
+
106
+	/**
107
+	 * utilized in newer batch job implementations, but forwarding to existing methods for now.
108
+	 * Performs any clean-up logic when we know the job is completed
109
+	 *
110
+	 * @param JobParameters $job_parameters
111
+	 * @return JobStepResponse
112
+	 * @throws BatchRequestException
113
+	 * @since $VID:$
114
+	 */
115
+	public function cleanupJob(JobParameters $job_parameters): JobStepResponse
116
+	{
117
+		return $this->cleanup_job($job_parameters);
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return array
123
+	 */
124
+	public function requestData(): array
125
+	{
126
+		return $this->request_data;
127
+	}
128
+
129
+
130
+	/**
131
+	 * @return mixed
132
+	 */
133
+	public function getRequestData($key)
134
+	{
135
+		return $this->request_data[ $key ] ?? null;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param array $request_data
141
+	 */
142
+	public function setRequestData(array $request_data): void
143
+	{
144
+		$this->request_data = $request_data;
145
+	}
146
+
147
+
148
+	/**
149
+	 * @return array
150
+	 */
151
+	public function responseData(): array
152
+	{
153
+		return $this->response_data;
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param array $response_data
159
+	 */
160
+	public function addResponseData(array $response_data): void
161
+	{
162
+		$this->response_data += $response_data;
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * @param array $response_data
169
+	 */
170
+	public function setResponseData(array $response_data): void
171
+	{
172
+		$this->response_data = $response_data;
173
+	}
174
+
175
+
176
+
177
+
178
+	protected function displayJobStepResults(int $processed, string $custom_message = '')
179
+	{
180
+		$this->feedback[] = '
181 181
 			<div class="ee-batch-job-step-results">
182 182
 			' . $this->infoWrapper(
183
-            sprintf(
184
-                $custom_message !== ''
185
-                        ? $custom_message
186
-                        : esc_html__('processed this batch: %d', 'event_espresso'),
187
-                $processed
188
-            )
189
-        ) . '
183
+			sprintf(
184
+				$custom_message !== ''
185
+						? $custom_message
186
+						: esc_html__('processed this batch: %d', 'event_espresso'),
187
+				$processed
188
+			)
189
+		) . '
190 190
 			</div>';
191
-    }
191
+	}
192 192
 
193 193
 
194
-    protected function displayJobFinalResults(JobParameters $job_parameters, string $custom_message = '')
195
-    {
196
-        if ($job_parameters->status() === JobParameters::status_complete) {
197
-            $this->feedback[] = '
194
+	protected function displayJobFinalResults(JobParameters $job_parameters, string $custom_message = '')
195
+	{
196
+		if ($job_parameters->status() === JobParameters::status_complete) {
197
+			$this->feedback[] = '
198 198
 			<div class="ee-batch-job-final-results">
199 199
 				' . $this->okWrapper(
200
-                sprintf(
201
-                    $custom_message !== ''
202
-                            ? $custom_message
203
-                            : esc_html__('total units processed: %d', 'event_espresso'),
204
-                    $job_parameters->units_processed()
205
-                )
206
-            ) . '
200
+				sprintf(
201
+					$custom_message !== ''
202
+							? $custom_message
203
+							: esc_html__('total units processed: %d', 'event_espresso'),
204
+					$job_parameters->units_processed()
205
+				)
206
+			) . '
207 207
 				' . $this->jobStatusNotice($job_parameters) . '
208 208
 			</div>';
209
-        }
210
-    }
209
+		}
210
+	}
211 211
 
212 212
 
213
-    protected function jobStatusNotice(JobParameters $job_parameters): string
214
-    {
215
-        switch ($job_parameters->status()) {
216
-            case JobParameters::status_cleaned_up:
217
-            case JobParameters::status_continue:
218
-            case JobParameters::status_pause:
219
-                break;
220
-            case JobParameters::status_complete:
221
-                return $this->successWrapper('job status: COMPLETE');
222
-            case JobParameters::status_error:
223
-                return $this->errorWrapper('job status: ERROR');
224
-        }
225
-        return '';
226
-    }
213
+	protected function jobStatusNotice(JobParameters $job_parameters): string
214
+	{
215
+		switch ($job_parameters->status()) {
216
+			case JobParameters::status_cleaned_up:
217
+			case JobParameters::status_continue:
218
+			case JobParameters::status_pause:
219
+				break;
220
+			case JobParameters::status_complete:
221
+				return $this->successWrapper('job status: COMPLETE');
222
+			case JobParameters::status_error:
223
+				return $this->errorWrapper('job status: ERROR');
224
+		}
225
+		return '';
226
+	}
227 227
 
228 228
 
229
-    /**
230
-     * @param string $update_text
231
-     */
232
-    protected function updateText(string $update_text)
233
-    {
234
-        $this->feedback[] = "<p class='ee-batch-job-update'>$update_text</p>";
235
-    }
229
+	/**
230
+	 * @param string $update_text
231
+	 */
232
+	protected function updateText(string $update_text)
233
+	{
234
+		$this->feedback[] = "<p class='ee-batch-job-update'>$update_text</p>";
235
+	}
236 236
 
237 237
 
238
-    protected function updateTextHeader(string $update_text)
239
-    {
240
-        $this->feedback[] = "<h4 class='ee-batch-job-update-heading'>$update_text</h4>";
241
-    }
238
+	protected function updateTextHeader(string $update_text)
239
+	{
240
+		$this->feedback[] = "<h4 class='ee-batch-job-update-heading'>$update_text</h4>";
241
+	}
242 242
 
243 243
 
244
-    protected function attentionWrapper(string $update_text): string
245
-    {
246
-        return "<span class='ee-status-outline ee-status-bg--attention'>$update_text</span>";
247
-    }
244
+	protected function attentionWrapper(string $update_text): string
245
+	{
246
+		return "<span class='ee-status-outline ee-status-bg--attention'>$update_text</span>";
247
+	}
248 248
 
249 249
 
250
-    protected function errorWrapper(string $update_text): string
251
-    {
252
-        return "<span class='ee-status-outline ee-status-bg--error'>$update_text</span>";
253
-    }
250
+	protected function errorWrapper(string $update_text): string
251
+	{
252
+		return "<span class='ee-status-outline ee-status-bg--error'>$update_text</span>";
253
+	}
254 254
 
255 255
 
256
-    protected function infoWrapper(string $update_text): string
257
-    {
258
-        return "<span class='ee-status-outline ee-status-bg--info'>$update_text</span>";
259
-    }
256
+	protected function infoWrapper(string $update_text): string
257
+	{
258
+		return "<span class='ee-status-outline ee-status-bg--info'>$update_text</span>";
259
+	}
260 260
 
261 261
 
262
-    protected function okWrapper(string $update_text): string
263
-    {
264
-        return "<span class='ee-status-outline ee-status-bg--ok'>$update_text</span>";
265
-    }
262
+	protected function okWrapper(string $update_text): string
263
+	{
264
+		return "<span class='ee-status-outline ee-status-bg--ok'>$update_text</span>";
265
+	}
266 266
 
267 267
 
268
-    protected function successWrapper(string $update_text): string
269
-    {
270
-        return "<span class='ee-status-outline ee-status-bg--success'>$update_text</span>";
271
-    }
268
+	protected function successWrapper(string $update_text): string
269
+	{
270
+		return "<span class='ee-status-outline ee-status-bg--success'>$update_text</span>";
271
+	}
272 272
 
273 273
 
274
-    protected function warningWrapper(string $update_text): string
275
-    {
276
-        return "<span class='ee-status-outline ee-status-bg--warning'>$update_text</span>";
277
-    }
274
+	protected function warningWrapper(string $update_text): string
275
+	{
276
+		return "<span class='ee-status-outline ee-status-bg--warning'>$update_text</span>";
277
+	}
278 278
 
279 279
 
280
-    /**
281
-     * @return string
282
-     */
283
-    protected function spinner(): string
284
-    {
285
-        return '<span class="spinner"></span>';
286
-    }
280
+	/**
281
+	 * @return string
282
+	 */
283
+	protected function spinner(): string
284
+	{
285
+		return '<span class="spinner"></span>';
286
+	}
287 287
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function getRequestData($key)
134 134
     {
135
-        return $this->request_data[ $key ] ?? null;
135
+        return $this->request_data[$key] ?? null;
136 136
     }
137 137
 
138 138
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                         : esc_html__('processed this batch: %d', 'event_espresso'),
187 187
                 $processed
188 188
             )
189
-        ) . '
189
+        ).'
190 190
 			</div>';
191 191
     }
192 192
 
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
                             : esc_html__('total units processed: %d', 'event_espresso'),
204 204
                     $job_parameters->units_processed()
205 205
                 )
206
-            ) . '
207
-				' . $this->jobStatusNotice($job_parameters) . '
206
+            ).'
207
+				' . $this->jobStatusNotice($job_parameters).'
208 208
 			</div>';
209 209
         }
210 210
     }
Please login to merge, or discard this patch.
core/domain/services/admin/events/data/ConfirmDeletion.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -29,89 +29,89 @@
 block discarded – undo
29 29
  */
30 30
 class ConfirmDeletion
31 31
 {
32
-    /**
33
-     * @var NodeGroupDao
34
-     */
35
-    private $dao;
32
+	/**
33
+	 * @var NodeGroupDao
34
+	 */
35
+	private $dao;
36 36
 
37 37
 
38
-    /**
39
-     * ConfirmDeletion constructor.
40
-     *
41
-     * @param NodeGroupDao $dao
42
-     */
43
-    public function __construct(NodeGroupDao $dao)
44
-    {
45
-        $this->dao = $dao;
46
-    }
38
+	/**
39
+	 * ConfirmDeletion constructor.
40
+	 *
41
+	 * @param NodeGroupDao $dao
42
+	 */
43
+	public function __construct(NodeGroupDao $dao)
44
+	{
45
+		$this->dao = $dao;
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion
51
-     * preview page.
52
-     *
53
-     * @param $request_data
54
-     * @param $admin_base_url
55
-     * @throws EE_Error
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidDataTypeException
58
-     * @throws InvalidInterfaceException
59
-     * @throws ReflectionException
60
-     * @throws UnexpectedEntityException
61
-     * @since 4.10.12.p
62
-     */
63
-    public function handle($request_data, $admin_base_url)
64
-    {
65
-        $deletion_job_code        =
66
-            isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
67
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
68
-        $form                     = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
69
-        // Initialize the form from the request, and check if its valid.
70
-        $form->receive_form_submission($request_data);
71
-        if ($form->is_valid()) {
72
-            // Redirect the user to the deletion batch job.
73
-            EEH_URL::safeRedirectAndExit(
74
-                EE_Admin_Page::add_query_args_and_nonce(
75
-                    [
76
-                        'page'              => EED_Batch::PAGE_SLUG,
77
-                        'batch'             => EED_Batch::batch_job,
78
-                        'deletion_job_code' => $deletion_job_code,
79
-                        'job_handler'       => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
80
-                        'return_url'        => urlencode(
81
-                            add_query_arg(
82
-                                [
83
-                                    'status' => 'trash',
84
-                                ],
85
-                                EVENTS_ADMIN_URL
86
-                            )
87
-                        ),
88
-                    ],
89
-                    admin_url()
90
-                )
91
-            );
92
-        }
93
-        // Dont' use $form->submission_error_message() because it adds the form input's label in front
94
-        // of each validation error which ends up looking quite confusing.
95
-        $validation_errors = $form->get_validation_errors_accumulated();
96
-        foreach ($validation_errors as $validation_error) {
97
-            EE_Error::add_error(
98
-                $validation_error->getMessage(),
99
-                __FILE__,
100
-                __FUNCTION__,
101
-                __LINE__
102
-            );
103
-        }
49
+	/**
50
+	 * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion
51
+	 * preview page.
52
+	 *
53
+	 * @param $request_data
54
+	 * @param $admin_base_url
55
+	 * @throws EE_Error
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidDataTypeException
58
+	 * @throws InvalidInterfaceException
59
+	 * @throws ReflectionException
60
+	 * @throws UnexpectedEntityException
61
+	 * @since 4.10.12.p
62
+	 */
63
+	public function handle($request_data, $admin_base_url)
64
+	{
65
+		$deletion_job_code        =
66
+			isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
67
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
68
+		$form                     = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
69
+		// Initialize the form from the request, and check if its valid.
70
+		$form->receive_form_submission($request_data);
71
+		if ($form->is_valid()) {
72
+			// Redirect the user to the deletion batch job.
73
+			EEH_URL::safeRedirectAndExit(
74
+				EE_Admin_Page::add_query_args_and_nonce(
75
+					[
76
+						'page'              => EED_Batch::PAGE_SLUG,
77
+						'batch'             => EED_Batch::batch_job,
78
+						'deletion_job_code' => $deletion_job_code,
79
+						'job_handler'       => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
80
+						'return_url'        => urlencode(
81
+							add_query_arg(
82
+								[
83
+									'status' => 'trash',
84
+								],
85
+								EVENTS_ADMIN_URL
86
+							)
87
+						),
88
+					],
89
+					admin_url()
90
+				)
91
+			);
92
+		}
93
+		// Dont' use $form->submission_error_message() because it adds the form input's label in front
94
+		// of each validation error which ends up looking quite confusing.
95
+		$validation_errors = $form->get_validation_errors_accumulated();
96
+		foreach ($validation_errors as $validation_error) {
97
+			EE_Error::add_error(
98
+				$validation_error->getMessage(),
99
+				__FILE__,
100
+				__FUNCTION__,
101
+				__LINE__
102
+			);
103
+		}
104 104
 
105
-        EEH_URL::safeRedirectAndExit(
106
-            EE_Admin_Page::add_query_args_and_nonce(
107
-                [
108
-                    'action'            => 'preview_deletion',
109
-                    'deletion_job_code' => $deletion_job_code,
110
-                ],
111
-                $admin_base_url
112
-            )
113
-        );
114
-    }
105
+		EEH_URL::safeRedirectAndExit(
106
+			EE_Admin_Page::add_query_args_and_nonce(
107
+				[
108
+					'action'            => 'preview_deletion',
109
+					'deletion_job_code' => $deletion_job_code,
110
+				],
111
+				$admin_base_url
112
+			)
113
+		);
114
+	}
115 115
 }
116 116
 // End of file ConfirmDeletion.php
117 117
 // Location: EventEspresso\core\domain\services\admin\events\data/ConfirmDeletion.php
Please login to merge, or discard this patch.
core/domain/services/admin/events/data/PreviewDeletion.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -30,121 +30,121 @@
 block discarded – undo
30 30
  */
31 31
 class PreviewDeletion
32 32
 {
33
-    /**
34
-     * @var NodeGroupDao
35
-     */
36
-    protected $dao;
33
+	/**
34
+	 * @var NodeGroupDao
35
+	 */
36
+	protected $dao;
37 37
 
38
-    /**
39
-     * @var EEM_Event
40
-     */
41
-    protected $event_model;
38
+	/**
39
+	 * @var EEM_Event
40
+	 */
41
+	protected $event_model;
42 42
 
43
-    /**
44
-     * @var EEM_Datetime
45
-     */
46
-    protected $datetime_model;
43
+	/**
44
+	 * @var EEM_Datetime
45
+	 */
46
+	protected $datetime_model;
47 47
 
48
-    /**
49
-     * @var EEM_Registration
50
-     */
51
-    protected $registration_model;
48
+	/**
49
+	 * @var EEM_Registration
50
+	 */
51
+	protected $registration_model;
52 52
 
53 53
 
54
-    /**
55
-     * PreviewDeletion constructor.
56
-     *
57
-     * @param NodeGroupDao     $dao
58
-     * @param EEM_Event        $event_model
59
-     * @param EEM_Datetime     $datetime_model
60
-     * @param EEM_Registration $registration_model
61
-     */
62
-    public function __construct(
63
-        NodeGroupDao $dao,
64
-        EEM_Event $event_model,
65
-        EEM_Datetime $datetime_model,
66
-        EEM_Registration $registration_model
67
-    ) {
68
-        $this->dao                = $dao;
69
-        $this->event_model        = $event_model;
70
-        $this->datetime_model     = $datetime_model;
71
-        $this->registration_model = $registration_model;
72
-    }
54
+	/**
55
+	 * PreviewDeletion constructor.
56
+	 *
57
+	 * @param NodeGroupDao     $dao
58
+	 * @param EEM_Event        $event_model
59
+	 * @param EEM_Datetime     $datetime_model
60
+	 * @param EEM_Registration $registration_model
61
+	 */
62
+	public function __construct(
63
+		NodeGroupDao $dao,
64
+		EEM_Event $event_model,
65
+		EEM_Datetime $datetime_model,
66
+		EEM_Registration $registration_model
67
+	) {
68
+		$this->dao                = $dao;
69
+		$this->event_model        = $event_model;
70
+		$this->datetime_model     = $datetime_model;
71
+		$this->registration_model = $registration_model;
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * Renders the preview deletion page.
77
-     *
78
-     * @param array  $request_data
79
-     * @param string $admin_base_url
80
-     * @return array
81
-     * @throws UnexpectedEntityException
82
-     * @throws DomainException
83
-     * @throws EE_Error
84
-     * @throws InvalidDataTypeException
85
-     * @throws InvalidInterfaceException
86
-     * @throws InvalidArgumentException
87
-     * @throws ReflectionException
88
-     * @since 4.10.12.p
89
-     */
90
-    public function handle(array $request_data, string $admin_base_url): array
91
-    {
92
-        $deletion_job_code        = isset($request_data['deletion_job_code'])
93
-            ? sanitize_key($request_data['deletion_job_code'])
94
-            : '';
95
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
96
-        $event_ids                = $models_and_ids_to_delete['Event'] ?? [];
97
-        if (empty($event_ids) || ! is_array($event_ids)) {
98
-            throw new EE_Error(
99
-                esc_html__('No Events were found to delete.', 'event_espresso')
100
-            );
101
-        }
102
-        $datetime_ids = $models_and_ids_to_delete['Datetime'] ?? [];
103
-        if (! is_array($datetime_ids)) {
104
-            throw new UnexpectedEntityException($datetime_ids, 'array');
105
-        }
106
-        $registration_ids = $models_and_ids_to_delete['Registration'] ?? [];
107
-        if (! is_array($registration_ids)) {
108
-            throw new UnexpectedEntityException($registration_ids, 'array');
109
-        }
110
-        $num_registrations_to_show = 10;
111
-        $reg_count                 = count($registration_ids);
112
-        if ($reg_count > $num_registrations_to_show) {
113
-            $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
114
-        }
115
-        $form                  = new ConfirmEventDeletionForm($event_ids);
116
-        $events                = $this->event_model->get_all_deleted_and_undeleted(
117
-            [['EVT_ID' => ['IN', $event_ids]]]
118
-        );
119
-        $datetimes             = $this->datetime_model->get_all_deleted_and_undeleted(
120
-            [['DTT_ID' => ['IN', $datetime_ids]]]
121
-        );
122
-        $registrations         = $this->registration_model->get_all_deleted_and_undeleted(
123
-            [['REG_ID' => ['IN', $registration_ids]]]
124
-        );
125
-        $confirm_deletion_args = [
126
-            'action'            => 'confirm_deletion',
127
-            'deletion_job_code' => $deletion_job_code,
128
-        ];
129
-        return [
130
-            'admin_page_content' => EEH_Template::display_template(
131
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
132
-                [
133
-                    'form_url'                  => EE_Admin_Page::add_query_args_and_nonce(
134
-                        $confirm_deletion_args,
135
-                        $admin_base_url
136
-                    ),
137
-                    'form'                      => $form,
138
-                    'events'                    => $events,
139
-                    'datetimes'                 => $datetimes,
140
-                    'registrations'             => $registrations,
141
-                    'reg_count'                 => $reg_count,
142
-                    'num_registrations_to_show' => $num_registrations_to_show,
143
-                ],
144
-                true
145
-            ),
146
-        ];
147
-    }
75
+	/**
76
+	 * Renders the preview deletion page.
77
+	 *
78
+	 * @param array  $request_data
79
+	 * @param string $admin_base_url
80
+	 * @return array
81
+	 * @throws UnexpectedEntityException
82
+	 * @throws DomainException
83
+	 * @throws EE_Error
84
+	 * @throws InvalidDataTypeException
85
+	 * @throws InvalidInterfaceException
86
+	 * @throws InvalidArgumentException
87
+	 * @throws ReflectionException
88
+	 * @since 4.10.12.p
89
+	 */
90
+	public function handle(array $request_data, string $admin_base_url): array
91
+	{
92
+		$deletion_job_code        = isset($request_data['deletion_job_code'])
93
+			? sanitize_key($request_data['deletion_job_code'])
94
+			: '';
95
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
96
+		$event_ids                = $models_and_ids_to_delete['Event'] ?? [];
97
+		if (empty($event_ids) || ! is_array($event_ids)) {
98
+			throw new EE_Error(
99
+				esc_html__('No Events were found to delete.', 'event_espresso')
100
+			);
101
+		}
102
+		$datetime_ids = $models_and_ids_to_delete['Datetime'] ?? [];
103
+		if (! is_array($datetime_ids)) {
104
+			throw new UnexpectedEntityException($datetime_ids, 'array');
105
+		}
106
+		$registration_ids = $models_and_ids_to_delete['Registration'] ?? [];
107
+		if (! is_array($registration_ids)) {
108
+			throw new UnexpectedEntityException($registration_ids, 'array');
109
+		}
110
+		$num_registrations_to_show = 10;
111
+		$reg_count                 = count($registration_ids);
112
+		if ($reg_count > $num_registrations_to_show) {
113
+			$registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
114
+		}
115
+		$form                  = new ConfirmEventDeletionForm($event_ids);
116
+		$events                = $this->event_model->get_all_deleted_and_undeleted(
117
+			[['EVT_ID' => ['IN', $event_ids]]]
118
+		);
119
+		$datetimes             = $this->datetime_model->get_all_deleted_and_undeleted(
120
+			[['DTT_ID' => ['IN', $datetime_ids]]]
121
+		);
122
+		$registrations         = $this->registration_model->get_all_deleted_and_undeleted(
123
+			[['REG_ID' => ['IN', $registration_ids]]]
124
+		);
125
+		$confirm_deletion_args = [
126
+			'action'            => 'confirm_deletion',
127
+			'deletion_job_code' => $deletion_job_code,
128
+		];
129
+		return [
130
+			'admin_page_content' => EEH_Template::display_template(
131
+				EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
132
+				[
133
+					'form_url'                  => EE_Admin_Page::add_query_args_and_nonce(
134
+						$confirm_deletion_args,
135
+						$admin_base_url
136
+					),
137
+					'form'                      => $form,
138
+					'events'                    => $events,
139
+					'datetimes'                 => $datetimes,
140
+					'registrations'             => $registrations,
141
+					'reg_count'                 => $reg_count,
142
+					'num_registrations_to_show' => $num_registrations_to_show,
143
+				],
144
+				true
145
+			),
146
+		];
147
+	}
148 148
 }
149 149
 // End of file PreviewDeletion.php
150 150
 // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
             );
101 101
         }
102 102
         $datetime_ids = $models_and_ids_to_delete['Datetime'] ?? [];
103
-        if (! is_array($datetime_ids)) {
103
+        if ( ! is_array($datetime_ids)) {
104 104
             throw new UnexpectedEntityException($datetime_ids, 'array');
105 105
         }
106 106
         $registration_ids = $models_and_ids_to_delete['Registration'] ?? [];
107
-        if (! is_array($registration_ids)) {
107
+        if ( ! is_array($registration_ids)) {
108 108
             throw new UnexpectedEntityException($registration_ids, 'array');
109 109
         }
110 110
         $num_registrations_to_show = 10;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         ];
129 129
         return [
130 130
             'admin_page_content' => EEH_Template::display_template(
131
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
131
+                EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php',
132 132
                 [
133 133
                     'form_url'                  => EE_Admin_Page::add_query_args_and_nonce(
134 134
                         $confirm_deletion_args,
Please login to merge, or discard this patch.
admin_pages/events/form_sections/ConfirmEventDeletionForm.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -25,67 +25,67 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class ConfirmEventDeletionForm extends EE_Form_Section_Proper
27 27
 {
28
-    /**
29
-     * @throws ReflectionException
30
-     * @throws EE_Error
31
-     */
32
-    public function __construct($event_ids, $options_array = array())
33
-    {
34
-        if (! isset($options_array['subsections'])) {
35
-            $options_array['subsections'] = [];
36
-        }
37
-        if (
38
-            ! (
39
-                isset($options_array['subsections']['events'])
40
-                && $options_array['subsections']['events'] instanceof EE_Form_Section_Proper
41
-            )
42
-        ) {
43
-            $options_array['subsections']['events'] = new EE_Form_Section_Proper();
44
-        }
45
-        $events_subsection = $options_array['subsections']['events'];
46
-        $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
47
-            [
48
-                [
49
-                    'EVT_ID' => ['IN',$event_ids]
50
-                ]
51
-            ]
52
-        );
53
-        if (! is_array($events)) {
54
-            throw new UnexpectedEntityException($event_ids, 'array');
55
-        }
56
-        $events_inputs = [];
57
-        foreach ($events as $event) {
58
-            if ($event instanceof EE_Event) {
59
-                $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
60
-                    [
61
-                        'yes' => $event->name(),
62
-                    ],
63
-                    [
64
-                        'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
65
-                        'required'        => true
66
-                    ]
67
-                );
68
-            }
69
-        }
70
-        $events_subsection->add_subsections($events_inputs);
71
-        $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
72
-            [
73
-                'yes' => esc_html__('I have backed up my database.', 'event_espresso')
74
-            ],
75
-            [
76
-                'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
77
-                'required' => true
78
-            ]
79
-        );
80
-        $events_list_url = EE_Admin_Page::add_query_args_and_nonce(
81
-            [
82
-                'status' => 'trash',
83
-                'return' => 'default',
84
-            ],
85
-            EVENTS_ADMIN_URL
86
-        );
87
-        $options_array['subsections']['buttons'] = new EE_Form_Section_HTML(
88
-            "
28
+	/**
29
+	 * @throws ReflectionException
30
+	 * @throws EE_Error
31
+	 */
32
+	public function __construct($event_ids, $options_array = array())
33
+	{
34
+		if (! isset($options_array['subsections'])) {
35
+			$options_array['subsections'] = [];
36
+		}
37
+		if (
38
+			! (
39
+				isset($options_array['subsections']['events'])
40
+				&& $options_array['subsections']['events'] instanceof EE_Form_Section_Proper
41
+			)
42
+		) {
43
+			$options_array['subsections']['events'] = new EE_Form_Section_Proper();
44
+		}
45
+		$events_subsection = $options_array['subsections']['events'];
46
+		$events = EEM_Event::instance()->get_all_deleted_and_undeleted(
47
+			[
48
+				[
49
+					'EVT_ID' => ['IN',$event_ids]
50
+				]
51
+			]
52
+		);
53
+		if (! is_array($events)) {
54
+			throw new UnexpectedEntityException($event_ids, 'array');
55
+		}
56
+		$events_inputs = [];
57
+		foreach ($events as $event) {
58
+			if ($event instanceof EE_Event) {
59
+				$events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
60
+					[
61
+						'yes' => $event->name(),
62
+					],
63
+					[
64
+						'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
65
+						'required'        => true
66
+					]
67
+				);
68
+			}
69
+		}
70
+		$events_subsection->add_subsections($events_inputs);
71
+		$options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
72
+			[
73
+				'yes' => esc_html__('I have backed up my database.', 'event_espresso')
74
+			],
75
+			[
76
+				'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
77
+				'required' => true
78
+			]
79
+		);
80
+		$events_list_url = EE_Admin_Page::add_query_args_and_nonce(
81
+			[
82
+				'status' => 'trash',
83
+				'return' => 'default',
84
+			],
85
+			EVENTS_ADMIN_URL
86
+		);
87
+		$options_array['subsections']['buttons'] = new EE_Form_Section_HTML(
88
+			"
89 89
         <div class='ee-admin-button-row ee-admin-button-row--align-start'>
90 90
             <input type='submit' 
91 91
                    class='button button--primary' 
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
                 " . esc_html__('Cancel', 'event_espresso') . "
96 96
             </a>
97 97
         </div>"
98
-        );
99
-        parent::__construct($options_array);
100
-    }
98
+		);
99
+		parent::__construct($options_array);
100
+	}
101 101
 }
102 102
 // End of file ConfirmEventDeletionForm.php
103 103
 // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct($event_ids, $options_array = array())
33 33
     {
34
-        if (! isset($options_array['subsections'])) {
34
+        if ( ! isset($options_array['subsections'])) {
35 35
             $options_array['subsections'] = [];
36 36
         }
37 37
         if (
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
47 47
             [
48 48
                 [
49
-                    'EVT_ID' => ['IN',$event_ids]
49
+                    'EVT_ID' => ['IN', $event_ids]
50 50
                 ]
51 51
             ]
52 52
         );
53
-        if (! is_array($events)) {
53
+        if ( ! is_array($events)) {
54 54
             throw new UnexpectedEntityException($event_ids, 'array');
55 55
         }
56 56
         $events_inputs = [];
57 57
         foreach ($events as $event) {
58 58
             if ($event instanceof EE_Event) {
59
-                $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
59
+                $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input(
60 60
                     [
61 61
                         'yes' => $event->name(),
62 62
                     ],
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
         <div class='ee-admin-button-row ee-admin-button-row--align-start'>
90 90
             <input type='submit' 
91 91
                    class='button button--primary' 
92
-                   value='" . esc_attr__('Confirm', 'event_espresso') . "'
92
+                   value='" . esc_attr__('Confirm', 'event_espresso')."'
93 93
             />
94
-            <a href='" . esc_url_raw($events_list_url) . ";' class='button button--secondary'>
95
-                " . esc_html__('Cancel', 'event_espresso') . "
94
+            <a href='" . esc_url_raw($events_list_url).";' class='button button--secondary'>
95
+                " . esc_html__('Cancel', 'event_espresso')."
96 96
             </a>
97 97
         </div>"
98 98
         );
Please login to merge, or discard this patch.