Completed
Branch dependabot/npm_and_yarn/wordpr... (751855)
by
unknown
81:18 queued 73:32
created
core/libraries/shortcodes/EE_Email_Shortcodes.lib.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -19,167 +19,167 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    public function __construct()
23
-    {
24
-        parent::__construct();
25
-    }
26
-
27
-
28
-    protected function _init_props()
29
-    {
30
-        $this->label = esc_html__('Email Shortcodes', 'event_espresso');
31
-        $this->description = esc_html__('All shortcodes related to emails', 'event_espresso');
32
-        $this->_shortcodes = array(
33
-            '[SITE_ADMIN_EMAIL]'               => esc_html__(
34
-                'Will be replaced with the admin email for the site that Event Espresso is installed on',
35
-                'event_espresso'
36
-            ),
37
-            '[EVENT_AUTHOR_FORMATTED_EMAIL]'   => sprintf(
38
-                esc_html__(
39
-                    'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.',
40
-                    'event_espresso'
41
-                ),
42
-                '<strong>',
43
-                '</strong>'
44
-            ),
45
-            '[EVENT_AUTHOR_EMAIL]'             => sprintf(
46
-                esc_html__(
47
-                    'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).',
48
-                    'event_espresso'
49
-                ),
50
-                '[EVENT_AUTHOR_FORMATTED_EMAIL]'
51
-            ),
52
-            '[CO_FORMATTED_EMAIL]'             => esc_html__(
53
-                'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
54
-                'event_espresso'
55
-            ),
56
-            '[CO_EMAIL]'                       => esc_html__(
57
-                'This will parse to the email address only for the organization set in Your Organization Settings.',
58
-                'event_espresso'
59
-            ),
60
-            '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__(
61
-                'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
62
-                'event_espresso'
63
-            ),
64
-            '[ESPRESSO_ADMIN_EMAIL]'           => esc_html__(
65
-                'This parses to the email address only for the organization set in Your Organization Settings page.',
66
-                'event_espresso'
67
-            ),
68
-        );
69
-    }
70
-
71
-
72
-    protected function _parser($shortcode)
73
-    {
74
-
75
-        switch ($shortcode) {
76
-            case '[SITE_ADMIN_EMAIL]':
77
-                return $this->_get_site_admin_email();
78
-                break;
79
-
80
-            case '[EVENT_AUTHOR_FORMATTED_EMAIL]':
81
-                return $this->_get_event_admin_emails();
82
-                break;
83
-
84
-            case '[EVENT_AUTHOR_EMAIL]':
85
-                return $this->_get_event_admin_emails(false);
86
-                break;
87
-
88
-            case '[CO_FORMATTED_EMAIL]':
89
-            case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
90
-                return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
91
-                       . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
92
-                break;
93
-
94
-            case '[CO_EMAIL]':
95
-            case '[ESPRESSO_ADMIN_EMAIL]':
96
-                return EE_Registry::instance()->CFG->organization->get_pretty('email');
97
-                break;
98
-
99
-            default:
100
-                return '';
101
-                break;
102
-        }
103
-    }
104
-
105
-
106
-    /**
107
-     * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode)
108
-     *
109
-     * @access private
110
-     * @return string email address of site admin
111
-     */
112
-    private function _get_site_admin_email()
113
-    {
114
-        return get_bloginfo('admin_email');
115
-    }
116
-
117
-
118
-    private function _get_event_admin_emails($fancy_headers = true)
119
-    {
120
-
121
-        if (! empty($this->_data->admin_email)) {
122
-            if (! $fancy_headers) {
123
-                return $this->_data->admin_email;
124
-            }
125
-            return ! empty($this->_data->fname)
126
-                ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
127
-                : EE_Registry::instance()->CFG->organization->get_pretty(
128
-                    'name'
129
-                ) . ' <' . $this->_data->admin_email . '>';
130
-        }
131
-
132
-        // k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
133
-
134
-        $admin_email = array();
135
-
136
-        // loop through events and set the list of event_ids to retrieve so we can do ONE query.
137
-        foreach ($this->_data->events as $event) {
138
-            $ids[] = $event['ID'];
139
-        }
140
-
141
-        // get all the events
142
-        $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids))));
143
-
144
-        // now loop through each event and setup the details
145
-        $admin_details = array();
146
-        $cnt = 0;
147
-        foreach ($events as $event) {
148
-            $user = get_userdata($event->get('EVT_wp_user'));
149
-            $admin_details[ $cnt ] = new stdClass();
150
-            $admin_details[ $cnt ]->email = $user->user_email;
151
-            $admin_details[ $cnt ]->first_name = $user->user_firstname;
152
-            $admin_details[ $cnt ]->last_name = $user->user_lastname;
153
-            $cnt++;
154
-        }
155
-
156
-        // results?
157
-        if (empty($admin_details) || ! is_array($admin_details)) {
158
-            $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso');
159
-            $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql);
160
-            $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true));
161
-            $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true));
162
-            $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details));
163
-            do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser');
164
-        }
165
-
166
-        foreach ($admin_details as $admin) {
167
-            // only add an admin email if it is present.
168
-            if (empty($admin->email) || $admin->email == '') {
169
-                continue;
170
-            }
171
-
172
-            if (! $fancy_headers) {
173
-                $admin_email[] = $admin->email;
174
-                continue;
175
-            }
176
-
177
-            $admin_email[] = ! empty($admin->first_name)
178
-                ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
179
-                : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
180
-        }
181
-
182
-        $admin_email = implode(',', $admin_email);
183
-        return $admin_email;
184
-    }
22
+	public function __construct()
23
+	{
24
+		parent::__construct();
25
+	}
26
+
27
+
28
+	protected function _init_props()
29
+	{
30
+		$this->label = esc_html__('Email Shortcodes', 'event_espresso');
31
+		$this->description = esc_html__('All shortcodes related to emails', 'event_espresso');
32
+		$this->_shortcodes = array(
33
+			'[SITE_ADMIN_EMAIL]'               => esc_html__(
34
+				'Will be replaced with the admin email for the site that Event Espresso is installed on',
35
+				'event_espresso'
36
+			),
37
+			'[EVENT_AUTHOR_FORMATTED_EMAIL]'   => sprintf(
38
+				esc_html__(
39
+					'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.',
40
+					'event_espresso'
41
+				),
42
+				'<strong>',
43
+				'</strong>'
44
+			),
45
+			'[EVENT_AUTHOR_EMAIL]'             => sprintf(
46
+				esc_html__(
47
+					'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).',
48
+					'event_espresso'
49
+				),
50
+				'[EVENT_AUTHOR_FORMATTED_EMAIL]'
51
+			),
52
+			'[CO_FORMATTED_EMAIL]'             => esc_html__(
53
+				'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
54
+				'event_espresso'
55
+			),
56
+			'[CO_EMAIL]'                       => esc_html__(
57
+				'This will parse to the email address only for the organization set in Your Organization Settings.',
58
+				'event_espresso'
59
+			),
60
+			'[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__(
61
+				'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
62
+				'event_espresso'
63
+			),
64
+			'[ESPRESSO_ADMIN_EMAIL]'           => esc_html__(
65
+				'This parses to the email address only for the organization set in Your Organization Settings page.',
66
+				'event_espresso'
67
+			),
68
+		);
69
+	}
70
+
71
+
72
+	protected function _parser($shortcode)
73
+	{
74
+
75
+		switch ($shortcode) {
76
+			case '[SITE_ADMIN_EMAIL]':
77
+				return $this->_get_site_admin_email();
78
+				break;
79
+
80
+			case '[EVENT_AUTHOR_FORMATTED_EMAIL]':
81
+				return $this->_get_event_admin_emails();
82
+				break;
83
+
84
+			case '[EVENT_AUTHOR_EMAIL]':
85
+				return $this->_get_event_admin_emails(false);
86
+				break;
87
+
88
+			case '[CO_FORMATTED_EMAIL]':
89
+			case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
90
+				return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
91
+					   . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
92
+				break;
93
+
94
+			case '[CO_EMAIL]':
95
+			case '[ESPRESSO_ADMIN_EMAIL]':
96
+				return EE_Registry::instance()->CFG->organization->get_pretty('email');
97
+				break;
98
+
99
+			default:
100
+				return '';
101
+				break;
102
+		}
103
+	}
104
+
105
+
106
+	/**
107
+	 * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode)
108
+	 *
109
+	 * @access private
110
+	 * @return string email address of site admin
111
+	 */
112
+	private function _get_site_admin_email()
113
+	{
114
+		return get_bloginfo('admin_email');
115
+	}
116
+
117
+
118
+	private function _get_event_admin_emails($fancy_headers = true)
119
+	{
120
+
121
+		if (! empty($this->_data->admin_email)) {
122
+			if (! $fancy_headers) {
123
+				return $this->_data->admin_email;
124
+			}
125
+			return ! empty($this->_data->fname)
126
+				? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
127
+				: EE_Registry::instance()->CFG->organization->get_pretty(
128
+					'name'
129
+				) . ' <' . $this->_data->admin_email . '>';
130
+		}
131
+
132
+		// k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
133
+
134
+		$admin_email = array();
135
+
136
+		// loop through events and set the list of event_ids to retrieve so we can do ONE query.
137
+		foreach ($this->_data->events as $event) {
138
+			$ids[] = $event['ID'];
139
+		}
140
+
141
+		// get all the events
142
+		$events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids))));
143
+
144
+		// now loop through each event and setup the details
145
+		$admin_details = array();
146
+		$cnt = 0;
147
+		foreach ($events as $event) {
148
+			$user = get_userdata($event->get('EVT_wp_user'));
149
+			$admin_details[ $cnt ] = new stdClass();
150
+			$admin_details[ $cnt ]->email = $user->user_email;
151
+			$admin_details[ $cnt ]->first_name = $user->user_firstname;
152
+			$admin_details[ $cnt ]->last_name = $user->user_lastname;
153
+			$cnt++;
154
+		}
155
+
156
+		// results?
157
+		if (empty($admin_details) || ! is_array($admin_details)) {
158
+			$msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso');
159
+			$msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql);
160
+			$msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true));
161
+			$msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true));
162
+			$msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details));
163
+			do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser');
164
+		}
165
+
166
+		foreach ($admin_details as $admin) {
167
+			// only add an admin email if it is present.
168
+			if (empty($admin->email) || $admin->email == '') {
169
+				continue;
170
+			}
171
+
172
+			if (! $fancy_headers) {
173
+				$admin_email[] = $admin->email;
174
+				continue;
175
+			}
176
+
177
+			$admin_email[] = ! empty($admin->first_name)
178
+				? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
179
+				: EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
180
+		}
181
+
182
+		$admin_email = implode(',', $admin_email);
183
+		return $admin_email;
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
             case '[CO_FORMATTED_EMAIL]':
89 89
             case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
90
-                return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
91
-                       . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
90
+                return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'
91
+                       . EE_Registry::instance()->CFG->organization->get_pretty('email').'>';
92 92
                 break;
93 93
 
94 94
             case '[CO_EMAIL]':
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
     private function _get_event_admin_emails($fancy_headers = true)
119 119
     {
120 120
 
121
-        if (! empty($this->_data->admin_email)) {
122
-            if (! $fancy_headers) {
121
+        if ( ! empty($this->_data->admin_email)) {
122
+            if ( ! $fancy_headers) {
123 123
                 return $this->_data->admin_email;
124 124
             }
125 125
             return ! empty($this->_data->fname)
126
-                ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
126
+                ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>'
127 127
                 : EE_Registry::instance()->CFG->organization->get_pretty(
128 128
                     'name'
129
-                ) . ' <' . $this->_data->admin_email . '>';
129
+                ).' <'.$this->_data->admin_email.'>';
130 130
         }
131 131
 
132 132
         // k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
         $cnt = 0;
147 147
         foreach ($events as $event) {
148 148
             $user = get_userdata($event->get('EVT_wp_user'));
149
-            $admin_details[ $cnt ] = new stdClass();
150
-            $admin_details[ $cnt ]->email = $user->user_email;
151
-            $admin_details[ $cnt ]->first_name = $user->user_firstname;
152
-            $admin_details[ $cnt ]->last_name = $user->user_lastname;
149
+            $admin_details[$cnt] = new stdClass();
150
+            $admin_details[$cnt]->email = $user->user_email;
151
+            $admin_details[$cnt]->first_name = $user->user_firstname;
152
+            $admin_details[$cnt]->last_name = $user->user_lastname;
153 153
             $cnt++;
154 154
         }
155 155
 
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 continue;
170 170
             }
171 171
 
172
-            if (! $fancy_headers) {
172
+            if ( ! $fancy_headers) {
173 173
                 $admin_email[] = $admin->email;
174 174
                 continue;
175 175
             }
176 176
 
177 177
             $admin_email[] = ! empty($admin->first_name)
178
-                ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
179
-                : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
178
+                ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>'
179
+                : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>';
180 180
         }
181 181
 
182 182
         $admin_email = implode(',', $admin_email);
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Messenger_Shortcodes.lib.php 2 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -21,154 +21,154 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * Hold array of active messengers indexed by messenger name.
26
-     *
27
-     * @since 4.5.0
28
-     *
29
-     * @var EE_messenger[]
30
-     */
31
-    protected $_active_messengers = array();
32
-
33
-
34
-    protected function _init_props()
35
-    {
36
-        $this->label = __('Messenger Shortcodes', 'event_espresso');
37
-        $this->description = __('All shortcodes that are messenger specific.', 'event_espresso');
38
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
39
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
40
-        // add messages about what happens  when the messenger is active.
41
-        $this->_active_messengers = $message_resource_manager->active_messengers();
42
-
43
-        $this->_shortcodes['[DISPLAY_HTML_URL]'] = __(
44
-            'This will return a link to view the template in a browser if the html messenger is active.',
45
-            'event_espresso'
46
-        );
47
-        $this->_shortcodes['[DISPLAY_PDF_URL]'] = __(
48
-            'This will return a link to generate a pdf for the template if the pdf messenger is active.',
49
-            'event_espresso'
50
-        );
51
-        $this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = __(
52
-            'This will return html for a download pdf button trigger if the pdf messenger is active.',
53
-            'event_espresso'
54
-        );
55
-
56
-        // show error message about buttons/urls not working as expected if messenger deactivated.
57
-        if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') {
58
-            if (! isset($this->_active_messengers['pdf'])) {
59
-                EE_Error::add_attention(
60
-                    __(
61
-                        'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
62
-                        'event_espresso'
63
-                    )
64
-                );
65
-            }
66
-
67
-            if (! isset($this->_active_messengers['html'])) {
68
-                EE_Error::add_attention(
69
-                    __(
70
-                        'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
71
-                        'event_espresso'
72
-                    )
73
-                );
74
-            }
75
-        }
76
-    }
77
-
78
-
79
-    protected function _parser($shortcode)
80
-    {
81
-        // make sure we end up with a copy of the EE_Messages_Addressee object
82
-        $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
83
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array(
84
-            $this->_data
85
-        ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
86
-            : $recipient;
87
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
88
-            ? $this->_extra_data['data'] : $recipient;
89
-
90
-        if (! $recipient instanceof EE_Messages_Addressee) {
91
-            return '';
92
-        }
93
-
94
-        switch ($shortcode) {
95
-            case '[DISPLAY_HTML_URL]':
96
-                return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : '';
97
-                break;
98
-            case '[DISPLAY_PDF_URL]':
99
-                return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : '';
100
-                break;
101
-            case '[DISPLAY_PDF_BUTTON]':
102
-                return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : '';
103
-                break;
104
-        }
105
-        return '';
106
-    }
107
-
108
-
109
-    /**
110
-     * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses
111
-     * that to generate the html for a button in the template.
112
-     *
113
-     * @since 4.5.0
114
-     *
115
-     * @param EE_Messages_Addressee $recipient
116
-     * @param string                $sending_messenger 'html' or 'pdf'
117
-     *
118
-     * @return string                Generated html
119
-     */
120
-    private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger)
121
-    {
122
-        $download_text = $sending_messenger == 'pdf'
123
-            ? __('Download PDF', 'event_espresso')
124
-            : __(
125
-                'Show HTML',
126
-                'event_espresso'
127
-            );
128
-        $content = '
24
+	/**
25
+	 * Hold array of active messengers indexed by messenger name.
26
+	 *
27
+	 * @since 4.5.0
28
+	 *
29
+	 * @var EE_messenger[]
30
+	 */
31
+	protected $_active_messengers = array();
32
+
33
+
34
+	protected function _init_props()
35
+	{
36
+		$this->label = __('Messenger Shortcodes', 'event_espresso');
37
+		$this->description = __('All shortcodes that are messenger specific.', 'event_espresso');
38
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
39
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
40
+		// add messages about what happens  when the messenger is active.
41
+		$this->_active_messengers = $message_resource_manager->active_messengers();
42
+
43
+		$this->_shortcodes['[DISPLAY_HTML_URL]'] = __(
44
+			'This will return a link to view the template in a browser if the html messenger is active.',
45
+			'event_espresso'
46
+		);
47
+		$this->_shortcodes['[DISPLAY_PDF_URL]'] = __(
48
+			'This will return a link to generate a pdf for the template if the pdf messenger is active.',
49
+			'event_espresso'
50
+		);
51
+		$this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = __(
52
+			'This will return html for a download pdf button trigger if the pdf messenger is active.',
53
+			'event_espresso'
54
+		);
55
+
56
+		// show error message about buttons/urls not working as expected if messenger deactivated.
57
+		if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') {
58
+			if (! isset($this->_active_messengers['pdf'])) {
59
+				EE_Error::add_attention(
60
+					__(
61
+						'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
62
+						'event_espresso'
63
+					)
64
+				);
65
+			}
66
+
67
+			if (! isset($this->_active_messengers['html'])) {
68
+				EE_Error::add_attention(
69
+					__(
70
+						'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
71
+						'event_espresso'
72
+					)
73
+				);
74
+			}
75
+		}
76
+	}
77
+
78
+
79
+	protected function _parser($shortcode)
80
+	{
81
+		// make sure we end up with a copy of the EE_Messages_Addressee object
82
+		$recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
83
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && is_array(
84
+			$this->_data
85
+		) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
86
+			: $recipient;
87
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
88
+			? $this->_extra_data['data'] : $recipient;
89
+
90
+		if (! $recipient instanceof EE_Messages_Addressee) {
91
+			return '';
92
+		}
93
+
94
+		switch ($shortcode) {
95
+			case '[DISPLAY_HTML_URL]':
96
+				return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : '';
97
+				break;
98
+			case '[DISPLAY_PDF_URL]':
99
+				return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : '';
100
+				break;
101
+			case '[DISPLAY_PDF_BUTTON]':
102
+				return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : '';
103
+				break;
104
+		}
105
+		return '';
106
+	}
107
+
108
+
109
+	/**
110
+	 * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses
111
+	 * that to generate the html for a button in the template.
112
+	 *
113
+	 * @since 4.5.0
114
+	 *
115
+	 * @param EE_Messages_Addressee $recipient
116
+	 * @param string                $sending_messenger 'html' or 'pdf'
117
+	 *
118
+	 * @return string                Generated html
119
+	 */
120
+	private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger)
121
+	{
122
+		$download_text = $sending_messenger == 'pdf'
123
+			? __('Download PDF', 'event_espresso')
124
+			: __(
125
+				'Show HTML',
126
+				'event_espresso'
127
+			);
128
+		$content = '
129 129
 <form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" >
130 130
 	<input class="print_button" type="submit" value="' . $download_text . '" />
131 131
 </form>
132 132
 		';
133
-        return $content;
134
-    }
135
-
136
-
137
-    /**
138
-     * This method takes the incoming data and figures out from it what the message type is and
139
-     * evt_id/grp_id and uses that to generate the url for displaying the template in a browser.
140
-     *
141
-     * @since 4.5.0
142
-     *
143
-     * @param EE_Messages_Addressee $recipient
144
-     * @param string                $sending_messenger
145
-     *
146
-     * @return string The generated url for displaying the link.
147
-     * @throws EE_Error
148
-     */
149
-    private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger)
150
-    {
151
-
152
-        $reg = $recipient->reg_obj;
153
-        $reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg;
154
-
155
-
156
-        if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) {
157
-            EE_Registry::instance()->load_helper('MSG_Template');
158
-            try {
159
-                return EEH_MSG_Template::get_url_trigger(
160
-                    $this->_message_type,
161
-                    $this->_message,
162
-                    $reg,
163
-                    $sending_messenger
164
-                );
165
-            } catch (EE_Error $e) {
166
-                if (WP_DEBUG) {
167
-                    $e->get_error();
168
-                }
169
-            }
170
-        }
171
-
172
-        return '';
173
-    }
133
+		return $content;
134
+	}
135
+
136
+
137
+	/**
138
+	 * This method takes the incoming data and figures out from it what the message type is and
139
+	 * evt_id/grp_id and uses that to generate the url for displaying the template in a browser.
140
+	 *
141
+	 * @since 4.5.0
142
+	 *
143
+	 * @param EE_Messages_Addressee $recipient
144
+	 * @param string                $sending_messenger
145
+	 *
146
+	 * @return string The generated url for displaying the link.
147
+	 * @throws EE_Error
148
+	 */
149
+	private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger)
150
+	{
151
+
152
+		$reg = $recipient->reg_obj;
153
+		$reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg;
154
+
155
+
156
+		if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) {
157
+			EE_Registry::instance()->load_helper('MSG_Template');
158
+			try {
159
+				return EEH_MSG_Template::get_url_trigger(
160
+					$this->_message_type,
161
+					$this->_message,
162
+					$reg,
163
+					$sending_messenger
164
+				);
165
+			} catch (EE_Error $e) {
166
+				if (WP_DEBUG) {
167
+					$e->get_error();
168
+				}
169
+			}
170
+		}
171
+
172
+		return '';
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
         // show error message about buttons/urls not working as expected if messenger deactivated.
57 57
         if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') {
58
-            if (! isset($this->_active_messengers['pdf'])) {
58
+            if ( ! isset($this->_active_messengers['pdf'])) {
59 59
                 EE_Error::add_attention(
60 60
                     __(
61 61
                         'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                 );
65 65
             }
66 66
 
67
-            if (! isset($this->_active_messengers['html'])) {
67
+            if ( ! isset($this->_active_messengers['html'])) {
68 68
                 EE_Error::add_attention(
69 69
                     __(
70 70
                         'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
88 88
             ? $this->_extra_data['data'] : $recipient;
89 89
 
90
-        if (! $recipient instanceof EE_Messages_Addressee) {
90
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
91 91
             return '';
92 92
         }
93 93
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
                 'event_espresso'
127 127
             );
128 128
         $content = '
129
-<form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" >
130
-	<input class="print_button" type="submit" value="' . $download_text . '" />
129
+<form method="post" action="' . $this->_get_url($recipient, $sending_messenger).'" >
130
+	<input class="print_button" type="submit" value="' . $download_text.'" />
131 131
 </form>
132 132
 		';
133 133
         return $content;
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/FormHandlerInterface.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -19,206 +19,206 @@
 block discarded – undo
19 19
 interface FormHandlerInterface
20 20
 {
21 21
 
22
-    /**
23
-     * the absolute top level form section being used on the page
24
-     *
25
-     * @return \EE_Form_Section_Proper
26
-     */
27
-    public function form();
22
+	/**
23
+	 * the absolute top level form section being used on the page
24
+	 *
25
+	 * @return \EE_Form_Section_Proper
26
+	 */
27
+	public function form();
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * @param \EE_Form_Section_Proper $form
33
-     */
34
-    public function setForm(\EE_Form_Section_Proper $form);
31
+	/**
32
+	 * @param \EE_Form_Section_Proper $form
33
+	 */
34
+	public function setForm(\EE_Form_Section_Proper $form);
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * if set to false, then this form has no displayable content,
40
-     * and will only be used for processing data sent passed via GET or POST
41
-     *
42
-     * @return boolean
43
-     */
44
-    public function displayable();
38
+	/**
39
+	 * if set to false, then this form has no displayable content,
40
+	 * and will only be used for processing data sent passed via GET or POST
41
+	 *
42
+	 * @return boolean
43
+	 */
44
+	public function displayable();
45 45
 
46 46
 
47 47
 
48
-    /**
49
-     * @param boolean $displayable
50
-     */
51
-    public function setDisplayable($displayable = false);
48
+	/**
49
+	 * @param boolean $displayable
50
+	 */
51
+	public function setDisplayable($displayable = false);
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * a public name for the form that can be displayed on the frontend of a site
57
-     *
58
-     * @return string
59
-     */
60
-    public function formName();
55
+	/**
56
+	 * a public name for the form that can be displayed on the frontend of a site
57
+	 *
58
+	 * @return string
59
+	 */
60
+	public function formName();
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * a public name for the form that can be displayed, but only in the admin
66
-     *
67
-     * @return string
68
-     */
69
-    public function adminName();
64
+	/**
65
+	 * a public name for the form that can be displayed, but only in the admin
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function adminName();
70 70
 
71 71
 
72 72
 
73
-    /**
74
-     * a URL friendly string that can be used for identifying the form
75
-     *
76
-     * @return string
77
-     */
78
-    public function slug();
73
+	/**
74
+	 * a URL friendly string that can be used for identifying the form
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function slug();
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * @return string
84
-     */
85
-    public function submitBtnText();
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function submitBtnText();
86 86
 
87 87
 
88 88
 
89
-    /**
90
-     * @param string $submit_btn_text
91
-     */
92
-    public function setSubmitBtnText($submit_btn_text);
89
+	/**
90
+	 * @param string $submit_btn_text
91
+	 */
92
+	public function setSubmitBtnText($submit_btn_text);
93 93
 
94 94
 
95 95
 
96
-    /**
97
-     * @return string
98
-     */
99
-    public function formAction();
96
+	/**
97
+	 * @return string
98
+	 */
99
+	public function formAction();
100 100
 
101 101
 
102 102
 
103
-    /**
104
-     * @param string $form_action
105
-     */
106
-    public function setFormAction($form_action);
103
+	/**
104
+	 * @param string $form_action
105
+	 */
106
+	public function setFormAction($form_action);
107 107
 
108 108
 
109 109
 
110
-    /**
111
-     * @param array $form_args
112
-     */
113
-    public function addFormActionArgs($form_args = array());
110
+	/**
111
+	 * @param array $form_args
112
+	 */
113
+	public function addFormActionArgs($form_args = array());
114 114
 
115 115
 
116 116
 
117
-    /**
118
-     * if data regarding the form's state needs to be persisted,
119
-     * then this method can be used to retrieve that data
120
-     *
121
-     * @return string
122
-     */
123
-    public function formConfig();
117
+	/**
118
+	 * if data regarding the form's state needs to be persisted,
119
+	 * then this method can be used to retrieve that data
120
+	 *
121
+	 * @return string
122
+	 */
123
+	public function formConfig();
124 124
 
125 125
 
126 126
 
127
-    /**
128
-     * if data regarding the form's state needs to be persisted,
129
-     * the this method can be used for setting the persisted data locally
130
-     *
131
-     * @param string $form_config
132
-     */
133
-    public function setFormConfig($form_config);
127
+	/**
128
+	 * if data regarding the form's state needs to be persisted,
129
+	 * the this method can be used for setting the persisted data locally
130
+	 *
131
+	 * @param string $form_config
132
+	 */
133
+	public function setFormConfig($form_config);
134 134
 
135 135
 
136 136
 
137
-    /**
138
-     * called after the form is instantiated
139
-     * and used for performing any logic that needs to occur early
140
-     * before any of the other methods are called.
141
-     * returns true if everything is ok to proceed,
142
-     * and false if no further form logic should be implemented
143
-     *
144
-     * @return boolean
145
-     */
146
-    public function initialize();
137
+	/**
138
+	 * called after the form is instantiated
139
+	 * and used for performing any logic that needs to occur early
140
+	 * before any of the other methods are called.
141
+	 * returns true if everything is ok to proceed,
142
+	 * and false if no further form logic should be implemented
143
+	 *
144
+	 * @return boolean
145
+	 */
146
+	public function initialize();
147 147
 
148 148
 
149 149
 
150
-    /**
151
-     * used for setting up css and js
152
-     *
153
-     * @return void
154
-     */
155
-    public function enqueueStylesAndScripts();
150
+	/**
151
+	 * used for setting up css and js
152
+	 *
153
+	 * @return void
154
+	 */
155
+	public function enqueueStylesAndScripts();
156 156
 
157 157
 
158 158
 
159
-    /**
160
-     * creates and returns the actual form
161
-     *
162
-     * @return EE_Form_Section_Proper
163
-     */
164
-    public function generate();
159
+	/**
160
+	 * creates and returns the actual form
161
+	 *
162
+	 * @return EE_Form_Section_Proper
163
+	 */
164
+	public function generate();
165 165
 
166 166
 
167 167
 
168
-    /**
169
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
170
-     * returns a string of HTML that can be directly echoed in a template
171
-     *
172
-     * @return string
173
-     */
174
-    public function display();
168
+	/**
169
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
170
+	 * returns a string of HTML that can be directly echoed in a template
171
+	 *
172
+	 * @return string
173
+	 */
174
+	public function display();
175 175
 
176 176
 
177 177
 
178
-    /**
179
-     * handles processing the form submission
180
-     * returns true or false depending on whether the form was processed successfully or not
181
-     *
182
-     * @param array $submitted_form_data
183
-     * @return bool
184
-     */
185
-    public function process($submitted_form_data = array());
178
+	/**
179
+	 * handles processing the form submission
180
+	 * returns true or false depending on whether the form was processed successfully or not
181
+	 *
182
+	 * @param array $submitted_form_data
183
+	 * @return bool
184
+	 */
185
+	public function process($submitted_form_data = array());
186 186
 
187 187
 
188 188
 
189
-    /**
190
-     * creates and returns an EE_Submit_Input labeled "Submit"
191
-     *
192
-     * @param string $text
193
-     * @return \EE_Submit_Input
194
-     */
195
-    public function generateSubmitButton($text = '');
189
+	/**
190
+	 * creates and returns an EE_Submit_Input labeled "Submit"
191
+	 *
192
+	 * @param string $text
193
+	 * @return \EE_Submit_Input
194
+	 */
195
+	public function generateSubmitButton($text = '');
196 196
 
197 197
 
198 198
 
199
-    /**
200
-     * calls generateSubmitButton() and appends it onto the form along with a float clearing div
201
-     *
202
-     * @return void
203
-     */
204
-    public function appendSubmitButton();
199
+	/**
200
+	 * calls generateSubmitButton() and appends it onto the form along with a float clearing div
201
+	 *
202
+	 * @return void
203
+	 */
204
+	public function appendSubmitButton();
205 205
 
206 206
 
207 207
 
208
-    /**
209
-     * creates and returns an EE_Submit_Input labeled "Cancel"
210
-     *
211
-     * @param string $text
212
-     * @return \EE_Submit_Input
213
-     */
214
-    public function generateCancelButton($text = '');
208
+	/**
209
+	 * creates and returns an EE_Submit_Input labeled "Cancel"
210
+	 *
211
+	 * @param string $text
212
+	 * @return \EE_Submit_Input
213
+	 */
214
+	public function generateCancelButton($text = '');
215 215
 
216 216
 
217 217
 
218
-    /**
219
-     * appends a float clearing div onto end of form
220
-     *
221
-     * @return void
222
-     */
223
-    public function clearFormButtonFloats();
218
+	/**
219
+	 * appends a float clearing div onto end of form
220
+	 *
221
+	 * @return void
222
+	 */
223
+	public function clearFormButtonFloats();
224 224
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormInterface.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,55 +16,55 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @return int
21
-     */
22
-    public function order();
19
+	/**
20
+	 * @return int
21
+	 */
22
+	public function order();
23 23
 
24 24
 
25 25
 
26
-    /**
27
-     * @param int $order
28
-     * @throws InvalidArgumentException
29
-     */
30
-    public function setOrder($order);
26
+	/**
27
+	 * @param int $order
28
+	 * @throws InvalidArgumentException
29
+	 */
30
+	public function setOrder($order);
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * @return string
36
-     */
37
-    public function redirectUrl();
34
+	/**
35
+	 * @return string
36
+	 */
37
+	public function redirectUrl();
38 38
 
39 39
 
40 40
 
41
-    /**
42
-     * @param string $redirect_url
43
-     * @throws InvalidDataTypeException
44
-     * @throws InvalidArgumentException
45
-     */
46
-    public function setRedirectUrl($redirect_url);
41
+	/**
42
+	 * @param string $redirect_url
43
+	 * @throws InvalidDataTypeException
44
+	 * @throws InvalidArgumentException
45
+	 */
46
+	public function setRedirectUrl($redirect_url);
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * @param array $redirect_args
52
-     * @throws InvalidDataTypeException
53
-     * @throws InvalidArgumentException
54
-     */
55
-    public function addRedirectArgs($redirect_args = array());
50
+	/**
51
+	 * @param array $redirect_args
52
+	 * @throws InvalidDataTypeException
53
+	 * @throws InvalidArgumentException
54
+	 */
55
+	public function addRedirectArgs($redirect_args = array());
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * @return string
61
-     */
62
-    public function redirectTo();
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public function redirectTo();
63 63
 
64 64
 
65 65
 
66
-    /**
67
-     * @param string $redirect_to
68
-     */
69
-    public function setRedirectTo($redirect_to);
66
+	/**
67
+	 * @param string $redirect_to
68
+	 */
69
+	public function setRedirectTo($redirect_to);
70 70
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepForm.php 2 patches
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -19,227 +19,227 @@
 block discarded – undo
19 19
 abstract class SequentialStepForm extends FormHandler implements SequentialStepFormInterface
20 20
 {
21 21
 
22
-    const REDIRECT_TO_NEXT_STEP    = 'redirect_to_next_step';
23
-
24
-    const REDIRECT_TO_CURRENT_STEP = 'redirect_to_current_step';
25
-
26
-    const REDIRECT_TO_PREV_STEP    = 'redirect_to_prev_step';
27
-
28
-    const REDIRECT_TO_OTHER        = 'redirect_to_other';
29
-
30
-    /**
31
-     * numerical value used for sorting form steps
32
-     *
33
-     * @var int $order
34
-     */
35
-    private $order = 1;
36
-
37
-    /**
38
-     * a final URL with all form related parameters added
39
-     * that will be used to advance to the next step
40
-     *
41
-     * @var string $redirect_url
42
-     */
43
-    private $redirect_url = '';
44
-
45
-    /**
46
-     * URL params in key value pairs
47
-     *
48
-     * @var array $redirect_args
49
-     */
50
-    private $redirect_args = array();
51
-
52
-    /**
53
-     * Which step should be redirected to after form processing.
54
-     * Usually after successfully processing this value would be REDIRECT_TO_NEXT_STEP
55
-     * If a form is invalid and requires errors to be corrected,
56
-     * then this value would be REDIRECT_TO_CURRENT_STEP so that form can be resubmitted
57
-     * Some form handlers do not have a form that is displayable,
58
-     * and only perform data processing, but if an error occurs,
59
-     * then this value needs to be set to REDIRECT_TO_PREV_STEP
60
-     * since the current step has no displayable content.
61
-     * if the form is completely finished, and needs to redirect to somewhere
62
-     * completely different, then this value will be REDIRECT_TO_OTHER
63
-     *
64
-     * @var string $redirect_to
65
-     */
66
-    private $redirect_to = SequentialStepForm::REDIRECT_TO_CURRENT_STEP;
67
-
68
-
69
-
70
-    /**
71
-     * SequentialStepForm constructor
72
-     *
73
-     * @param int         $order
74
-     * @param string      $form_name
75
-     * @param string      $admin_name
76
-     * @param string      $slug
77
-     * @param string      $form_action
78
-     * @param string      $form_config
79
-     * @param EE_Registry $registry
80
-     * @throws InvalidArgumentException
81
-     * @throws InvalidDataTypeException
82
-     * @throws DomainException
83
-     */
84
-    public function __construct(
85
-        $order,
86
-        $form_name,
87
-        $admin_name,
88
-        $slug,
89
-        $form_action = '',
90
-        $form_config = 'add_form_tags_and_submit',
91
-        EE_Registry $registry
92
-    ) {
93
-        $this->setOrder($order);
94
-        parent::__construct($form_name, $admin_name, $slug, $form_action, $form_config, $registry);
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * @return int
101
-     */
102
-    public function order()
103
-    {
104
-        return $this->order;
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @param int $order
111
-     * @throws InvalidArgumentException
112
-     */
113
-    public function setOrder($order)
114
-    {
115
-        $order = absint($order);
116
-        if (! $order > 0) {
117
-            throw new InvalidArgumentException(
118
-                esc_html__('The form order property must be a positive integer.', 'event_espresso')
119
-            );
120
-        }
121
-        $this->order = $order;
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @return string
128
-     */
129
-    public function redirectUrl()
130
-    {
131
-        return ! empty($this->redirect_args)
132
-            ? add_query_arg($this->redirect_args, $this->redirect_url)
133
-            : $this->redirect_url;
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     * @param string $redirect_url
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidArgumentException
142
-     */
143
-    public function setRedirectUrl($redirect_url)
144
-    {
145
-        if (! is_string($redirect_url)) {
146
-            throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
147
-        }
148
-        if (empty($redirect_url)) {
149
-            throw new InvalidArgumentException(
150
-                esc_html__('The redirect URL can not be an empty string.', 'event_espresso')
151
-            );
152
-        }
153
-        $this->redirect_url = $redirect_url;
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * @param array $redirect_args
160
-     * @throws InvalidDataTypeException
161
-     * @throws InvalidArgumentException
162
-     */
163
-    public function addRedirectArgs($redirect_args = array())
164
-    {
165
-        if (is_object($redirect_args)) {
166
-            throw new InvalidDataTypeException(
167
-                '$redirect_args',
168
-                $redirect_args,
169
-                'anything other than an object was expected.'
170
-            );
171
-        }
172
-        if (empty($redirect_args)) {
173
-            throw new InvalidArgumentException(
174
-                esc_html__('The redirect argument can not be an empty array.', 'event_espresso')
175
-            );
176
-        }
177
-        $this->redirect_args = array_merge($this->redirect_args, (array) $redirect_args);
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     * @param array $redirect_arg_keys_to_remove
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidArgumentException
186
-     */
187
-    public function removeRedirectArgs($redirect_arg_keys_to_remove = array())
188
-    {
189
-        if (is_object($redirect_arg_keys_to_remove)) {
190
-            throw new InvalidDataTypeException(
191
-                '$redirect_arg_keys_to_remove',
192
-                $redirect_arg_keys_to_remove,
193
-                'anything other than an object was expected.'
194
-            );
195
-        }
196
-        if (empty($redirect_arg_keys_to_remove)) {
197
-            throw new InvalidArgumentException(
198
-                esc_html__('The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso')
199
-            );
200
-        }
201
-        foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) {
202
-            unset($this->redirect_args[ $redirect_arg_key ]);
203
-        }
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * @return string
210
-     */
211
-    public function redirectTo()
212
-    {
213
-        return $this->redirect_to;
214
-    }
215
-
216
-
217
-
218
-    /**
219
-     * @param string $redirect_to
220
-     * @throws InvalidDataTypeException
221
-     */
222
-    public function setRedirectTo($redirect_to)
223
-    {
224
-        if (! in_array(
225
-            $redirect_to,
226
-            array(
227
-                    SequentialStepForm::REDIRECT_TO_NEXT_STEP,
228
-                    SequentialStepForm::REDIRECT_TO_CURRENT_STEP,
229
-                    SequentialStepForm::REDIRECT_TO_PREV_STEP,
230
-                    SequentialStepForm::REDIRECT_TO_OTHER,
231
-                ),
232
-            true
233
-        )
234
-        ) {
235
-            throw new InvalidDataTypeException(
236
-                'setRedirectTo()',
237
-                $redirect_to,
238
-                'one of the SequentialStepForm class constants was expected.'
239
-            );
240
-        }
241
-        $this->redirect_to = $redirect_to;
242
-    }
22
+	const REDIRECT_TO_NEXT_STEP    = 'redirect_to_next_step';
23
+
24
+	const REDIRECT_TO_CURRENT_STEP = 'redirect_to_current_step';
25
+
26
+	const REDIRECT_TO_PREV_STEP    = 'redirect_to_prev_step';
27
+
28
+	const REDIRECT_TO_OTHER        = 'redirect_to_other';
29
+
30
+	/**
31
+	 * numerical value used for sorting form steps
32
+	 *
33
+	 * @var int $order
34
+	 */
35
+	private $order = 1;
36
+
37
+	/**
38
+	 * a final URL with all form related parameters added
39
+	 * that will be used to advance to the next step
40
+	 *
41
+	 * @var string $redirect_url
42
+	 */
43
+	private $redirect_url = '';
44
+
45
+	/**
46
+	 * URL params in key value pairs
47
+	 *
48
+	 * @var array $redirect_args
49
+	 */
50
+	private $redirect_args = array();
51
+
52
+	/**
53
+	 * Which step should be redirected to after form processing.
54
+	 * Usually after successfully processing this value would be REDIRECT_TO_NEXT_STEP
55
+	 * If a form is invalid and requires errors to be corrected,
56
+	 * then this value would be REDIRECT_TO_CURRENT_STEP so that form can be resubmitted
57
+	 * Some form handlers do not have a form that is displayable,
58
+	 * and only perform data processing, but if an error occurs,
59
+	 * then this value needs to be set to REDIRECT_TO_PREV_STEP
60
+	 * since the current step has no displayable content.
61
+	 * if the form is completely finished, and needs to redirect to somewhere
62
+	 * completely different, then this value will be REDIRECT_TO_OTHER
63
+	 *
64
+	 * @var string $redirect_to
65
+	 */
66
+	private $redirect_to = SequentialStepForm::REDIRECT_TO_CURRENT_STEP;
67
+
68
+
69
+
70
+	/**
71
+	 * SequentialStepForm constructor
72
+	 *
73
+	 * @param int         $order
74
+	 * @param string      $form_name
75
+	 * @param string      $admin_name
76
+	 * @param string      $slug
77
+	 * @param string      $form_action
78
+	 * @param string      $form_config
79
+	 * @param EE_Registry $registry
80
+	 * @throws InvalidArgumentException
81
+	 * @throws InvalidDataTypeException
82
+	 * @throws DomainException
83
+	 */
84
+	public function __construct(
85
+		$order,
86
+		$form_name,
87
+		$admin_name,
88
+		$slug,
89
+		$form_action = '',
90
+		$form_config = 'add_form_tags_and_submit',
91
+		EE_Registry $registry
92
+	) {
93
+		$this->setOrder($order);
94
+		parent::__construct($form_name, $admin_name, $slug, $form_action, $form_config, $registry);
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * @return int
101
+	 */
102
+	public function order()
103
+	{
104
+		return $this->order;
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @param int $order
111
+	 * @throws InvalidArgumentException
112
+	 */
113
+	public function setOrder($order)
114
+	{
115
+		$order = absint($order);
116
+		if (! $order > 0) {
117
+			throw new InvalidArgumentException(
118
+				esc_html__('The form order property must be a positive integer.', 'event_espresso')
119
+			);
120
+		}
121
+		$this->order = $order;
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @return string
128
+	 */
129
+	public function redirectUrl()
130
+	{
131
+		return ! empty($this->redirect_args)
132
+			? add_query_arg($this->redirect_args, $this->redirect_url)
133
+			: $this->redirect_url;
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 * @param string $redirect_url
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidArgumentException
142
+	 */
143
+	public function setRedirectUrl($redirect_url)
144
+	{
145
+		if (! is_string($redirect_url)) {
146
+			throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
147
+		}
148
+		if (empty($redirect_url)) {
149
+			throw new InvalidArgumentException(
150
+				esc_html__('The redirect URL can not be an empty string.', 'event_espresso')
151
+			);
152
+		}
153
+		$this->redirect_url = $redirect_url;
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * @param array $redirect_args
160
+	 * @throws InvalidDataTypeException
161
+	 * @throws InvalidArgumentException
162
+	 */
163
+	public function addRedirectArgs($redirect_args = array())
164
+	{
165
+		if (is_object($redirect_args)) {
166
+			throw new InvalidDataTypeException(
167
+				'$redirect_args',
168
+				$redirect_args,
169
+				'anything other than an object was expected.'
170
+			);
171
+		}
172
+		if (empty($redirect_args)) {
173
+			throw new InvalidArgumentException(
174
+				esc_html__('The redirect argument can not be an empty array.', 'event_espresso')
175
+			);
176
+		}
177
+		$this->redirect_args = array_merge($this->redirect_args, (array) $redirect_args);
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 * @param array $redirect_arg_keys_to_remove
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidArgumentException
186
+	 */
187
+	public function removeRedirectArgs($redirect_arg_keys_to_remove = array())
188
+	{
189
+		if (is_object($redirect_arg_keys_to_remove)) {
190
+			throw new InvalidDataTypeException(
191
+				'$redirect_arg_keys_to_remove',
192
+				$redirect_arg_keys_to_remove,
193
+				'anything other than an object was expected.'
194
+			);
195
+		}
196
+		if (empty($redirect_arg_keys_to_remove)) {
197
+			throw new InvalidArgumentException(
198
+				esc_html__('The $redirect_arg_keys_to_remove argument can not be an empty array.', 'event_espresso')
199
+			);
200
+		}
201
+		foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) {
202
+			unset($this->redirect_args[ $redirect_arg_key ]);
203
+		}
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * @return string
210
+	 */
211
+	public function redirectTo()
212
+	{
213
+		return $this->redirect_to;
214
+	}
215
+
216
+
217
+
218
+	/**
219
+	 * @param string $redirect_to
220
+	 * @throws InvalidDataTypeException
221
+	 */
222
+	public function setRedirectTo($redirect_to)
223
+	{
224
+		if (! in_array(
225
+			$redirect_to,
226
+			array(
227
+					SequentialStepForm::REDIRECT_TO_NEXT_STEP,
228
+					SequentialStepForm::REDIRECT_TO_CURRENT_STEP,
229
+					SequentialStepForm::REDIRECT_TO_PREV_STEP,
230
+					SequentialStepForm::REDIRECT_TO_OTHER,
231
+				),
232
+			true
233
+		)
234
+		) {
235
+			throw new InvalidDataTypeException(
236
+				'setRedirectTo()',
237
+				$redirect_to,
238
+				'one of the SequentialStepForm class constants was expected.'
239
+			);
240
+		}
241
+		$this->redirect_to = $redirect_to;
242
+	}
243 243
 }
244 244
 // End of file SequentialStepForm.php
245 245
 // Location: /SequentialStepForm.php
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     public function setOrder($order)
114 114
     {
115 115
         $order = absint($order);
116
-        if (! $order > 0) {
116
+        if ( ! $order > 0) {
117 117
             throw new InvalidArgumentException(
118 118
                 esc_html__('The form order property must be a positive integer.', 'event_espresso')
119 119
             );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function setRedirectUrl($redirect_url)
144 144
     {
145
-        if (! is_string($redirect_url)) {
145
+        if ( ! is_string($redirect_url)) {
146 146
             throw new InvalidDataTypeException('$redirect_url', $redirect_url, 'string');
147 147
         }
148 148
         if (empty($redirect_url)) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             );
200 200
         }
201 201
         foreach ($redirect_arg_keys_to_remove as $redirect_arg_key) {
202
-            unset($this->redirect_args[ $redirect_arg_key ]);
202
+            unset($this->redirect_args[$redirect_arg_key]);
203 203
         }
204 204
     }
205 205
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function setRedirectTo($redirect_to)
223 223
     {
224
-        if (! in_array(
224
+        if ( ! in_array(
225 225
             $redirect_to,
226 226
             array(
227 227
                     SequentialStepForm::REDIRECT_TO_NEXT_STEP,
Please login to merge, or discard this patch.
form_sections/inputs/EE_Checkbox_Dropdown_Selector_Input.input.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -12,68 +12,68 @@
 block discarded – undo
12 12
 class EE_Checkbox_Dropdown_Selector_Input extends EE_Form_Input_With_Options_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @var string text to display on the select button itself
17
-     */
18
-    protected $_select_button_text;
15
+	/**
16
+	 * @var string text to display on the select button itself
17
+	 */
18
+	protected $_select_button_text;
19 19
 
20
-    /**
21
-     * @param array $answer_options
22
-     * @param array $input_settings
23
-     */
24
-    public function __construct($answer_options, $input_settings = array())
25
-    {
26
-        $this->_select_button_text = EEH_Array::is_set(
27
-            $input_settings,
28
-            'select_button_text',
29
-            esc_html__('Select', 'event_espresso')
30
-        );
31
-        $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy();
32
-        $this->_set_display_strategy($display_strategy);
33
-        $this->load_iframe_assets($display_strategy);
34
-        $this->_add_validation_strategy(
35
-            new EE_Many_Valued_Validation_Strategy(
36
-                array(
37
-                    new EE_Enum_Validation_Strategy(
38
-                        isset($input_settings['validation_error_message'])
39
-                            ? $input_settings['validation_error_message']
40
-                            : null
41
-                    ),
42
-                )
43
-            )
44
-        );
45
-        $this->_multiple_selections = true;
46
-        parent::__construct($answer_options, $input_settings);
47
-    }
20
+	/**
21
+	 * @param array $answer_options
22
+	 * @param array $input_settings
23
+	 */
24
+	public function __construct($answer_options, $input_settings = array())
25
+	{
26
+		$this->_select_button_text = EEH_Array::is_set(
27
+			$input_settings,
28
+			'select_button_text',
29
+			esc_html__('Select', 'event_espresso')
30
+		);
31
+		$display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy();
32
+		$this->_set_display_strategy($display_strategy);
33
+		$this->load_iframe_assets($display_strategy);
34
+		$this->_add_validation_strategy(
35
+			new EE_Many_Valued_Validation_Strategy(
36
+				array(
37
+					new EE_Enum_Validation_Strategy(
38
+						isset($input_settings['validation_error_message'])
39
+							? $input_settings['validation_error_message']
40
+							: null
41
+					),
42
+				)
43
+			)
44
+		);
45
+		$this->_multiple_selections = true;
46
+		parent::__construct($answer_options, $input_settings);
47
+	}
48 48
 
49
-    /*
49
+	/*
50 50
      * Returns the text to display in the select button
51 51
      */
52
-    public function select_button_text()
53
-    {
54
-        return $this->_select_button_text;
55
-    }
52
+	public function select_button_text()
53
+	{
54
+		return $this->_select_button_text;
55
+	}
56 56
 
57
-    /*
57
+	/*
58 58
      * add css and js for iframes
59 59
      */
60
-    protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy)
61
-    {
62
-        add_filter(
63
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
64
-            array($display_strategy, 'iframe_css')
65
-        );
66
-        add_filter(
67
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
68
-            array($display_strategy, 'iframe_js')
69
-        );
70
-        add_filter(
71
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
72
-            array($display_strategy, 'iframe_css')
73
-        );
74
-        add_filter(
75
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
76
-            array($display_strategy, 'iframe_js')
77
-        );
78
-    }
60
+	protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy)
61
+	{
62
+		add_filter(
63
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
64
+			array($display_strategy, 'iframe_css')
65
+		);
66
+		add_filter(
67
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
68
+			array($display_strategy, 'iframe_js')
69
+		);
70
+		add_filter(
71
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
72
+			array($display_strategy, 'iframe_css')
73
+		);
74
+		add_filter(
75
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
76
+			array($display_strategy, 'iframe_js')
77
+		);
78
+	}
79 79
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Button_Input.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 class EE_Button_Input extends EE_Form_Input_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @var string of HTML to put between the button tags
16
-     */
17
-    protected $_button_content;
18
-    /**
19
-     * @param array $options
20
-     */
21
-    public function __construct($options = array())
22
-    {
23
-        if (empty($options['button_content'])) {
24
-            $options['button_content'] = esc_html__('Button', 'event_espresso');
25
-        }
26
-        $this->_set_display_strategy(new EE_Button_Display_Strategy());
27
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
28
-        $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
29
-        parent::__construct($options);
30
-    }
14
+	/**
15
+	 * @var string of HTML to put between the button tags
16
+	 */
17
+	protected $_button_content;
18
+	/**
19
+	 * @param array $options
20
+	 */
21
+	public function __construct($options = array())
22
+	{
23
+		if (empty($options['button_content'])) {
24
+			$options['button_content'] = esc_html__('Button', 'event_espresso');
25
+		}
26
+		$this->_set_display_strategy(new EE_Button_Display_Strategy());
27
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
28
+		$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
29
+		parent::__construct($options);
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * Sets the button content
36
-     * @see EE_Button_Input::$_button_content
37
-     * @param string $new_content
38
-     */
39
-    public function set_button_content($new_content)
40
-    {
41
-        $this->_button_content = $new_content;
42
-    }
34
+	/**
35
+	 * Sets the button content
36
+	 * @see EE_Button_Input::$_button_content
37
+	 * @param string $new_content
38
+	 */
39
+	public function set_button_content($new_content)
40
+	{
41
+		$this->_button_content = $new_content;
42
+	}
43 43
     
44
-    /**
45
-     * Gets the button content
46
-     * @return string
47
-     */
48
-    public function button_content()
49
-    {
50
-        return $this->_button_content;
51
-    }
44
+	/**
45
+	 * Gets the button content
46
+	 * @return string
47
+	 */
48
+	public function button_content()
49
+	{
50
+		return $this->_button_content;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Submit_Input.input.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
 class EE_Submit_Input extends EE_Form_Input_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $options
16
-     */
17
-    public function __construct($options = array())
18
-    {
19
-        if (empty($options['default'])) {
20
-            $options['default'] = esc_html__('Submit', 'event_espresso');
21
-        }
22
-        $this->_set_display_strategy(new EE_Submit_Input_Display_Strategy());
23
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
24
-        $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
25
-        parent::__construct($options);
26
-    }
14
+	/**
15
+	 * @param array $options
16
+	 */
17
+	public function __construct($options = array())
18
+	{
19
+		if (empty($options['default'])) {
20
+			$options['default'] = esc_html__('Submit', 'event_espresso');
21
+		}
22
+		$this->_set_display_strategy(new EE_Submit_Input_Display_Strategy());
23
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
24
+		$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
25
+		parent::__construct($options);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Checkbox_Multi_Input.input.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param array $input_settings
19
-     * @param array | EE_Question_Option[] $answer_options
20
-     */
21
-    public function __construct($answer_options, $input_settings = array())
22
-    {
23
-        $this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
25
-        $this->_multiple_selections = true;
26
-        parent::__construct($answer_options, $input_settings);
27
-    }
17
+	/**
18
+	 * @param array $input_settings
19
+	 * @param array | EE_Question_Option[] $answer_options
20
+	 */
21
+	public function __construct($answer_options, $input_settings = array())
22
+	{
23
+		$this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
+		$this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
25
+		$this->_multiple_selections = true;
26
+		parent::__construct($answer_options, $input_settings);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     public function __construct($answer_options, $input_settings = array())
22 22
     {
23 23
         $this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
24
+        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null))));
25 25
         $this->_multiple_selections = true;
26 26
         parent::__construct($answer_options, $input_settings);
27 27
     }
Please login to merge, or discard this patch.