Completed
Branch master (4bd299)
by
unknown
04:49
created
strategies/display/EE_File_Input_Display_Strategy.strategy.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
10 10
  */
11 11
 class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy
12 12
 {
13
-    /**
14
-     * Override's parent to just set the type. May someday support other arguments.
15
-     */
16
-    public function __construct()
17
-    {
18
-        parent::__construct('file');
19
-    }
13
+	/**
14
+	 * Override's parent to just set the type. May someday support other arguments.
15
+	 */
16
+	public function __construct()
17
+	{
18
+		parent::__construct('file');
19
+	}
20 20
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_File_Input.input.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
                     esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56 56
                     implode(', ', $this->allowed_file_extensions)
57 57
                 ),
58
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
58
+                '~.*\.('.implode('|', $this->allowed_file_extensions).')$~'
59 59
             )
60 60
         );
61 61
         parent::__construct($options);
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -19,86 +19,86 @@
 block discarded – undo
19 19
  */
20 20
 class EE_File_Input extends EE_Form_Input_Base
21 21
 {
22
-    /**
23
-     * @var array
24
-     */
25
-    protected $allowed_file_extensions;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	protected $allowed_file_extensions;
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    protected $allowed_mime_types;
27
+	/**
28
+	 * @var array
29
+	 */
30
+	protected $allowed_mime_types;
31 31
 
32
-    /**
33
-     * @param array $options
34
-     * @throws InvalidArgumentException
35
-     */
36
-    public function __construct($options = array())
37
-    {
38
-        if (isset($options['allowed_file_extensions'])) {
39
-            $this->allowed_file_extensions = (array) $options['allowed_file_extensions'];
40
-        } else {
41
-            $this->allowed_file_extensions = ['csv'];
42
-        }
43
-        if (isset($options['allowed_mime_types'])) {
44
-            $this->allowed_mime_types = (array) $options['allowed_file_extensions'];
45
-        } else {
46
-            $this->allowed_mime_types = ['text/csv'];
47
-        }
32
+	/**
33
+	 * @param array $options
34
+	 * @throws InvalidArgumentException
35
+	 */
36
+	public function __construct($options = array())
37
+	{
38
+		if (isset($options['allowed_file_extensions'])) {
39
+			$this->allowed_file_extensions = (array) $options['allowed_file_extensions'];
40
+		} else {
41
+			$this->allowed_file_extensions = ['csv'];
42
+		}
43
+		if (isset($options['allowed_mime_types'])) {
44
+			$this->allowed_mime_types = (array) $options['allowed_file_extensions'];
45
+		} else {
46
+			$this->allowed_mime_types = ['text/csv'];
47
+		}
48 48
 
49
-        $this->_set_display_strategy(new EE_File_Input_Display_Strategy());
50
-        $this->_set_normalization_strategy(new EE_File_Normalization());
51
-        $this->add_validation_strategy(
52
-            new EE_Text_Validation_Strategy(
53
-                sprintf(
54
-                    // translators: %1$s is a list of allowed file extensions.
55
-                    esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56
-                    implode(', ', $this->allowed_file_extensions)
57
-                ),
58
-                '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
59
-            )
60
-        );
61
-        parent::__construct($options);
49
+		$this->_set_display_strategy(new EE_File_Input_Display_Strategy());
50
+		$this->_set_normalization_strategy(new EE_File_Normalization());
51
+		$this->add_validation_strategy(
52
+			new EE_Text_Validation_Strategy(
53
+				sprintf(
54
+					// translators: %1$s is a list of allowed file extensions.
55
+					esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'),
56
+					implode(', ', $this->allowed_file_extensions)
57
+				),
58
+				'~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~'
59
+			)
60
+		);
61
+		parent::__construct($options);
62 62
 
63 63
 //        It would be great to add this HTML attribute, but jQuery validate chokes on it.
64
-        $this->set_other_html_attributes(
65
-            $this->other_html_attributes()
66
-            . ' extension="'
67
-            . implode(
68
-                ',',
69
-                $this->allowed_file_extensions
70
-            )
71
-            . '"'
72
-        );
73
-    }
64
+		$this->set_other_html_attributes(
65
+			$this->other_html_attributes()
66
+			. ' extension="'
67
+			. implode(
68
+				',',
69
+				$this->allowed_file_extensions
70
+			)
71
+			. '"'
72
+		);
73
+	}
74 74
 
75
-    /**
76
-     * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for
77
-     * this input.
78
-     * @since 4.9.80.p
79
-     * @param array $req_data
80
-     * @return FileSubmissionInterface
81
-     * @throws InvalidArgumentException
82
-     * @throws InvalidDataTypeException
83
-     * @throws InvalidInterfaceException
84
-     */
85
-    public function find_form_data_for_this_section($req_data)
86
-    {
87
-        // ignore $req_data. Files are in the files data handler.
88
-        $fileDataHandler = LoaderFactory::getLoader()->getShared(
89
-            'EventEspresso\core\services\request\files\FilesDataHandler'
90
-        );
91
-        return $fileDataHandler->getFileObject($this->html_name());
92
-    }
75
+	/**
76
+	 * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for
77
+	 * this input.
78
+	 * @since 4.9.80.p
79
+	 * @param array $req_data
80
+	 * @return FileSubmissionInterface
81
+	 * @throws InvalidArgumentException
82
+	 * @throws InvalidDataTypeException
83
+	 * @throws InvalidInterfaceException
84
+	 */
85
+	public function find_form_data_for_this_section($req_data)
86
+	{
87
+		// ignore $req_data. Files are in the files data handler.
88
+		$fileDataHandler = LoaderFactory::getLoader()->getShared(
89
+			'EventEspresso\core\services\request\files\FilesDataHandler'
90
+		);
91
+		return $fileDataHandler->getFileObject($this->html_name());
92
+	}
93 93
 
94
-    /**
95
-     * Don't transform the file submission object into a string, thanks.
96
-     *
97
-     * @param string $value
98
-     * @return null|string
99
-     */
100
-    protected function _sanitize($value)
101
-    {
102
-        return $value;
103
-    }
94
+	/**
95
+	 * Don't transform the file submission object into a string, thanks.
96
+	 *
97
+	 * @param string $value
98
+	 * @return null|string
99
+	 */
100
+	protected function _sanitize($value)
101
+	{
102
+		return $value;
103
+	}
104 104
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage_Table.core.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
     {
71 71
         global $wpdb;
72 72
         $start_at_record = $this->count_records_migrated();
73
-        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
73
+        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare(
74 74
             "LIMIT %d, %d",
75 75
             $start_at_record,
76 76
             $limit
Please login to merge, or discard this patch.
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -15,86 +15,86 @@
 block discarded – undo
15 15
  */
16 16
 abstract class EE_Data_Migration_Script_Stage_Table extends EE_Data_Migration_Script_Stage
17 17
 {
18
-    /**
19
-     * @var string The columns to select. May be overridden for children.
20
-     */
21
-    protected string $select_expression = '*';
18
+	/**
19
+	 * @var string The columns to select. May be overridden for children.
20
+	 */
21
+	protected string $select_expression = '*';
22 22
 
23
-    /**
24
-     * Set in the constructor to add this sql to both the counting query in
25
-     * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
26
-     * EE_Data_Migration_Script_Stage_Table::_get_rows().
27
-     * Eg "where column_name like '%some_value%'"
28
-     *
29
-     * @var string|null
30
-     */
31
-    protected ?string $_extra_where_sql = '';
23
+	/**
24
+	 * Set in the constructor to add this sql to both the counting query in
25
+	 * EE_Data_Migration_Script_Stage_Table::_count_records_to_migrate() and
26
+	 * EE_Data_Migration_Script_Stage_Table::_get_rows().
27
+	 * Eg "where column_name like '%some_value%'"
28
+	 *
29
+	 * @var string|null
30
+	 */
31
+	protected ?string $_extra_where_sql = '';
32 32
 
33 33
 
34
-    /**
35
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
36
-     * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
37
-     * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
38
-     * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
39
-     * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
40
-     * very least we MUST report/return 50 items migrated)
41
-     *
42
-     * @param int $num_items_to_migrate
43
-     * @return int number of items ACTUALLY migrated
44
-     */
45
-    public function _migration_step($num_items_to_migrate = 50)
46
-    {
47
-        $rows = $this->_get_rows($num_items_to_migrate);
48
-        $items_actually_migrated = 0;
49
-        foreach ($rows as $old_row) {
50
-            $this->_migrate_old_row($old_row);
51
-            $items_actually_migrated++;
52
-        }
53
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
54
-            $this->set_completed();
55
-        }
56
-        return $items_actually_migrated;
57
-    }
34
+	/**
35
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
36
+	 * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
37
+	 * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
38
+	 * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
39
+	 * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
40
+	 * very least we MUST report/return 50 items migrated)
41
+	 *
42
+	 * @param int $num_items_to_migrate
43
+	 * @return int number of items ACTUALLY migrated
44
+	 */
45
+	public function _migration_step($num_items_to_migrate = 50)
46
+	{
47
+		$rows = $this->_get_rows($num_items_to_migrate);
48
+		$items_actually_migrated = 0;
49
+		foreach ($rows as $old_row) {
50
+			$this->_migrate_old_row($old_row);
51
+			$items_actually_migrated++;
52
+		}
53
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
54
+			$this->set_completed();
55
+		}
56
+		return $items_actually_migrated;
57
+	}
58 58
 
59
-    /**
60
-     * Gets the rows for each migration stage from the old table
61
-     *
62
-     * @global wpdb $wpdb
63
-     * @param int   $limit
64
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
65
-     */
66
-    protected function _get_rows($limit)
67
-    {
68
-        global $wpdb;
69
-        $start_at_record = $this->count_records_migrated();
70
-        $query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
71
-            "LIMIT %d, %d",
72
-            $start_at_record,
73
-            $limit
74
-        );
75
-        return $wpdb->get_results($query, ARRAY_A);
76
-    }
59
+	/**
60
+	 * Gets the rows for each migration stage from the old table
61
+	 *
62
+	 * @global wpdb $wpdb
63
+	 * @param int   $limit
64
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
65
+	 */
66
+	protected function _get_rows($limit)
67
+	{
68
+		global $wpdb;
69
+		$start_at_record = $this->count_records_migrated();
70
+		$query = "SELECT {$this->select_expression} FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
71
+			"LIMIT %d, %d",
72
+			$start_at_record,
73
+			$limit
74
+		);
75
+		return $wpdb->get_results($query, ARRAY_A);
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * Counts the records to migrate; the public version may cache it
81
-     *
82
-     * @return int
83
-     */
84
-    public function _count_records_to_migrate()
85
-    {
86
-        global $wpdb;
87
-        $query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
88
-        return (int) $wpdb->get_var($query);
89
-    }
79
+	/**
80
+	 * Counts the records to migrate; the public version may cache it
81
+	 *
82
+	 * @return int
83
+	 */
84
+	public function _count_records_to_migrate()
85
+	{
86
+		global $wpdb;
87
+		$query = "SELECT COUNT(*) FROM {$this->_old_table} {$this->_extra_where_sql}";
88
+		return (int) $wpdb->get_var($query);
89
+	}
90 90
 
91
-    /**
92
-     * takes care of migrating this particular row from the OLD table to whatever its
93
-     * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a
94
-     * fatal error which prevents all future migrations, throw an exception describing it
95
-     *
96
-     * @param array $old_row an associative array where keys are column names and values are their values.
97
-     * @return void
98
-     */
99
-    abstract protected function _migrate_old_row($old_row);
91
+	/**
92
+	 * takes care of migrating this particular row from the OLD table to whatever its
93
+	 * representation is in the new database. If there are errors, use $this->add_error to log them. If there is a
94
+	 * fatal error which prevents all future migrations, throw an exception describing it
95
+	 *
96
+	 * @param array $old_row an associative array where keys are column names and values are their values.
97
+	 * @return void
98
+	 */
99
+	abstract protected function _migrate_old_row($old_row);
100 100
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Form_Section_Layout_Base.strategy.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         $html = '';
68 68
         // layout_form_begin
69 69
         $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(),
71 71
             $this->layout_form_begin(),
72 72
             $this->_form_section
73 73
         );
74 74
         // layout_form_loop
75 75
         $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(),
77 77
             $this->layout_form_loop(),
78 78
             $this->_form_section
79 79
         );
80 80
         // layout_form_end
81 81
         $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(),
83 83
             $this->layout_form_end(),
84 84
             $this->_form_section
85 85
         );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             if ($subsection instanceof EE_Form_Input_Base) {
101 101
                 $html .= apply_filters(
102 102
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
103
+                    . $name.'__in_'.$this->_form_section->name(),
104 104
                     $this->layout_input($subsection),
105 105
                     $this->_form_section,
106 106
                     $subsection
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             } elseif ($subsection instanceof EE_Form_Section_Base) {
109 109
                 $html .= apply_filters(
110 110
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
111
+                    . $name.'__in_'.$this->_form_section->name(),
112 112
                     $this->layout_subsection($subsection),
113 113
                     $this->_form_section,
114 114
                     $subsection
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
             return '';
178 178
         }
179 179
         $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
180
+            ? 'ee-required-label '.$input->html_label_class()
181 181
             : $input->html_label_class();
182 182
         $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
183
+            ? $input->html_label_text().'<span class="ee-asterisk">*</span>'
184 184
             : $input->html_label_text();
185 185
         return '<label id="'
186 186
                . $input->html_label_id()
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                . $class
189 189
                . '" style="'
190 190
                . $input->html_label_style()
191
-               . '" for="' . $input->html_id()
191
+               . '" for="'.$input->html_id()
192 192
                . '">'
193 193
                . $label_text
194 194
                . '</label>';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             // get all the errors on THIS form section (errors which aren't
211 211
             // for specific inputs, but instead for the entire form section)
212 212
             foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
213
+                $html .= $error->getMessage().'<br>';
214 214
             }
215 215
             $html .= '</div>';
216 216
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function display_help_text($input)
256 256
     {
257
-        $help_text  = $input->html_help_text();
257
+        $help_text = $input->html_help_text();
258 258
         if ($help_text !== '' && $help_text !== null) {
259 259
             $tag = is_admin() ? 'p' : 'span';
260 260
             return '<'
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
     {
287 287
         // replace dashes and spaces with underscores
288 288
         $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
289
+        do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section);
290 290
         $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
291
+            'AFEE__Form_Section_Layout__'.$hook_name.'__html',
292 292
             $html,
293 293
             $this->_form_section
294 294
         );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+        $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->';
296
+        $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->';
297 297
         return $html;
298 298
     }
299 299
 }
Please login to merge, or discard this patch.
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -11,287 +11,287 @@
 block discarded – undo
11 11
  */
12 12
 abstract class EE_Form_Section_Layout_Base
13 13
 {
14
-    /**
15
-     * Form section to lay out
16
-     *
17
-     * @var EE_Form_Section_Proper
18
-     */
19
-    protected $_form_section;
20
-
21
-
22
-
23
-    /**
24
-     *  __construct
25
-     */
26
-    public function __construct()
27
-    {
28
-    }
29
-
30
-
31
-
32
-    /**
33
-     * The form section on which this strategy is to perform
34
-     *
35
-     * @param EE_Form_Section_Proper $form
36
-     */
37
-    public function _construct_finalize(EE_Form_Section_Proper $form)
38
-    {
39
-        $this->_form_section = $form;
40
-    }
41
-
42
-
43
-
44
-    /**
45
-     * @return EE_Form_Section_Proper
46
-     */
47
-    public function form_section()
48
-    {
49
-        return $this->_form_section;
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * Also has teh side effect of enqueuing any needed JS and CSS for
56
-     * this form.
57
-     * Creates all the HTML necessary for displaying this form, its inputs, and
58
-     * proper subsections.
59
-     * Returns the HTML
60
-     *
61
-     * @return string HTML for displaying
62
-     * @throws EE_Error
63
-     */
64
-    public function layout_form()
65
-    {
66
-        $html = '';
67
-        // layout_form_begin
68
-        $html .= apply_filters(
69
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
-            $this->layout_form_begin(),
71
-            $this->_form_section
72
-        );
73
-        // layout_form_loop
74
-        $html .= apply_filters(
75
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
-            $this->layout_form_loop(),
77
-            $this->_form_section
78
-        );
79
-        // layout_form_end
80
-        $html .= apply_filters(
81
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
-            $this->layout_form_end(),
83
-            $this->_form_section
84
-        );
85
-        return $this->add_form_section_hooks_and_filters($html);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * @return string
92
-     * @throws EE_Error
93
-     */
94
-    public function layout_form_loop()
95
-    {
96
-        $html = '';
97
-        foreach ($this->_form_section->subsections() as $name => $subsection) {
98
-            if ($subsection instanceof EE_Form_Input_Base) {
99
-                $html .= apply_filters(
100
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
101
-                    . $name . '__in_' . $this->_form_section->name(),
102
-                    $this->layout_input($subsection),
103
-                    $this->_form_section,
104
-                    $subsection
105
-                );
106
-            } elseif ($subsection instanceof EE_Form_Section_Base) {
107
-                $html .= apply_filters(
108
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
109
-                    . $name . '__in_' . $this->_form_section->name(),
110
-                    $this->layout_subsection($subsection),
111
-                    $this->_form_section,
112
-                    $subsection
113
-                );
114
-            }
115
-        }
116
-        return $html;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
123
-     *
124
-     * @return string
125
-     */
126
-    abstract public function layout_form_begin();
127
-
128
-
129
-
130
-    /**
131
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc.)
132
-     *
133
-     * @return string
134
-     */
135
-    abstract public function layout_form_end();
136
-
137
-
138
-
139
-    /**
140
-     * Should be used internally by layout_form() to lay out each input (eg, if this layout
141
-     * is putting each input in a row of its own, this should probably be called by a
142
-     *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
143
-     * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
144
-     * customize the form's layout, but would like to make use of it for laying out
145
-     * 'easy-to-layout' inputs
146
-     *
147
-     * @param EE_Form_Input_Base $input
148
-     * @return string html
149
-     */
150
-    abstract public function layout_input($input);
151
-
152
-
153
-
154
-    /**
155
-     * Similar to layout_input(), should be used internally by layout_form() within a
156
-     * loop to lay out each proper subsection. Unlike layout_input(), however, it is assumed
157
-     * that the proper subsection will lay out its container, label, etc on its own.
158
-     *
159
-     * @param EE_Form_Section_Base $subsection
160
-     * @return string html
161
-     */
162
-    abstract public function layout_subsection($subsection);
163
-
164
-
165
-    /**
166
-     * Gets the HTML for the label tag and its contents for the input
167
-     *
168
-     * @param EE_Form_Input_Base $input
169
-     * @return string
170
-     * @throws EE_Error
171
-     */
172
-    public function display_label($input)
173
-    {
174
-        if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
175
-            return '';
176
-        }
177
-        $class = $input->required()
178
-            ? 'ee-required-label ' . $input->html_label_class()
179
-            : $input->html_label_class();
180
-        $label_text = $input->required()
181
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
182
-            : $input->html_label_text();
183
-        return '<label id="'
184
-               . $input->html_label_id()
185
-               . '" class="'
186
-               . $class
187
-               . '" style="'
188
-               . $input->html_label_style()
189
-               . '" for="' . $input->html_id()
190
-               . '">'
191
-               . $label_text
192
-               . '</label>';
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * Gets the HTML for all the form's form-wide errors (ie, errors which
199
-     * are not for specific inputs. E.g., if two inputs somehow disagree,
200
-     * those errors would probably be on the form section, not one of its inputs)
201
-     * @return string
202
-     */
203
-    public function display_form_wide_errors()
204
-    {
205
-        $html = '';
206
-        if ($this->_form_section->get_validation_errors()) {
207
-            $html .= "<div class='ee-form-wide-errors'>";
208
-            // get all the errors on THIS form section (errors which aren't
209
-            // for specific inputs, but instead for the entire form section)
210
-            foreach ($this->_form_section->get_validation_errors() as $error) {
211
-                $html .= $error->getMessage() . '<br>';
212
-            }
213
-            $html .= '</div>';
214
-        }
215
-        return apply_filters(
216
-            'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
217
-            $html,
218
-            $this
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * returns the HTML for the server-side validation errors for the specified input
225
-     * Note that if JS is enabled, it should remove these and instead
226
-     * populate the form's errors in the jquery validate fashion
227
-     * using the localized data provided to the JS
228
-     *
229
-     * @param EE_Form_Input_Base $input
230
-     * @return string
231
-     * @throws EE_Error
232
-     */
233
-    public function display_errors($input)
234
-    {
235
-        if ($input->get_validation_errors()) {
236
-            return "<label  id='"
237
-                   . $input->html_id()
238
-                   . "-error' class='error' for='{$input->html_name()}'>"
239
-                   . $input->get_validation_error_string()
240
-                   . '</label>';
241
-        }
242
-        return '';
243
-    }
244
-
245
-
246
-    /**
247
-     * Displays the help span for the specified input
248
-     *
249
-     * @param EE_Form_Input_Base $input
250
-     * @return string
251
-     * @throws EE_Error
252
-     */
253
-    public function display_help_text($input)
254
-    {
255
-        $help_text  = $input->html_help_text();
256
-        if ($help_text !== '' && $help_text !== null) {
257
-            $tag = is_admin() ? 'p' : 'span';
258
-            return '<'
259
-                   . $tag
260
-                   . ' id="'
261
-                   . $input->html_id()
262
-                   . '-help" class="'
263
-                   . $input->html_help_class()
264
-                   . '" style="'
265
-                   . $input->html_help_style()
266
-                   . '">'
267
-                   . $help_text
268
-                   . '</'
269
-                   . $tag
270
-                   . '>';
271
-        }
272
-        return '';
273
-    }
274
-
275
-
276
-    /**
277
-     * Does an action and hook onto the end of teh form
278
-     *
279
-     * @param string $html
280
-     * @return string
281
-     * @throws EE_Error
282
-     */
283
-    public function add_form_section_hooks_and_filters($html)
284
-    {
285
-        // replace dashes and spaces with underscores
286
-        $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
287
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
288
-        $html = (string) apply_filters(
289
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
290
-            $html,
291
-            $this->_form_section
292
-        );
293
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
294
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
-        return $html;
296
-    }
14
+	/**
15
+	 * Form section to lay out
16
+	 *
17
+	 * @var EE_Form_Section_Proper
18
+	 */
19
+	protected $_form_section;
20
+
21
+
22
+
23
+	/**
24
+	 *  __construct
25
+	 */
26
+	public function __construct()
27
+	{
28
+	}
29
+
30
+
31
+
32
+	/**
33
+	 * The form section on which this strategy is to perform
34
+	 *
35
+	 * @param EE_Form_Section_Proper $form
36
+	 */
37
+	public function _construct_finalize(EE_Form_Section_Proper $form)
38
+	{
39
+		$this->_form_section = $form;
40
+	}
41
+
42
+
43
+
44
+	/**
45
+	 * @return EE_Form_Section_Proper
46
+	 */
47
+	public function form_section()
48
+	{
49
+		return $this->_form_section;
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * Also has teh side effect of enqueuing any needed JS and CSS for
56
+	 * this form.
57
+	 * Creates all the HTML necessary for displaying this form, its inputs, and
58
+	 * proper subsections.
59
+	 * Returns the HTML
60
+	 *
61
+	 * @return string HTML for displaying
62
+	 * @throws EE_Error
63
+	 */
64
+	public function layout_form()
65
+	{
66
+		$html = '';
67
+		// layout_form_begin
68
+		$html .= apply_filters(
69
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+			$this->layout_form_begin(),
71
+			$this->_form_section
72
+		);
73
+		// layout_form_loop
74
+		$html .= apply_filters(
75
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+			$this->layout_form_loop(),
77
+			$this->_form_section
78
+		);
79
+		// layout_form_end
80
+		$html .= apply_filters(
81
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+			$this->layout_form_end(),
83
+			$this->_form_section
84
+		);
85
+		return $this->add_form_section_hooks_and_filters($html);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * @return string
92
+	 * @throws EE_Error
93
+	 */
94
+	public function layout_form_loop()
95
+	{
96
+		$html = '';
97
+		foreach ($this->_form_section->subsections() as $name => $subsection) {
98
+			if ($subsection instanceof EE_Form_Input_Base) {
99
+				$html .= apply_filters(
100
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
101
+					. $name . '__in_' . $this->_form_section->name(),
102
+					$this->layout_input($subsection),
103
+					$this->_form_section,
104
+					$subsection
105
+				);
106
+			} elseif ($subsection instanceof EE_Form_Section_Base) {
107
+				$html .= apply_filters(
108
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
109
+					. $name . '__in_' . $this->_form_section->name(),
110
+					$this->layout_subsection($subsection),
111
+					$this->_form_section,
112
+					$subsection
113
+				);
114
+			}
115
+		}
116
+		return $html;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
123
+	 *
124
+	 * @return string
125
+	 */
126
+	abstract public function layout_form_begin();
127
+
128
+
129
+
130
+	/**
131
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc.)
132
+	 *
133
+	 * @return string
134
+	 */
135
+	abstract public function layout_form_end();
136
+
137
+
138
+
139
+	/**
140
+	 * Should be used internally by layout_form() to lay out each input (eg, if this layout
141
+	 * is putting each input in a row of its own, this should probably be called by a
142
+	 *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
143
+	 * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
144
+	 * customize the form's layout, but would like to make use of it for laying out
145
+	 * 'easy-to-layout' inputs
146
+	 *
147
+	 * @param EE_Form_Input_Base $input
148
+	 * @return string html
149
+	 */
150
+	abstract public function layout_input($input);
151
+
152
+
153
+
154
+	/**
155
+	 * Similar to layout_input(), should be used internally by layout_form() within a
156
+	 * loop to lay out each proper subsection. Unlike layout_input(), however, it is assumed
157
+	 * that the proper subsection will lay out its container, label, etc on its own.
158
+	 *
159
+	 * @param EE_Form_Section_Base $subsection
160
+	 * @return string html
161
+	 */
162
+	abstract public function layout_subsection($subsection);
163
+
164
+
165
+	/**
166
+	 * Gets the HTML for the label tag and its contents for the input
167
+	 *
168
+	 * @param EE_Form_Input_Base $input
169
+	 * @return string
170
+	 * @throws EE_Error
171
+	 */
172
+	public function display_label($input)
173
+	{
174
+		if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
175
+			return '';
176
+		}
177
+		$class = $input->required()
178
+			? 'ee-required-label ' . $input->html_label_class()
179
+			: $input->html_label_class();
180
+		$label_text = $input->required()
181
+			? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
182
+			: $input->html_label_text();
183
+		return '<label id="'
184
+			   . $input->html_label_id()
185
+			   . '" class="'
186
+			   . $class
187
+			   . '" style="'
188
+			   . $input->html_label_style()
189
+			   . '" for="' . $input->html_id()
190
+			   . '">'
191
+			   . $label_text
192
+			   . '</label>';
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * Gets the HTML for all the form's form-wide errors (ie, errors which
199
+	 * are not for specific inputs. E.g., if two inputs somehow disagree,
200
+	 * those errors would probably be on the form section, not one of its inputs)
201
+	 * @return string
202
+	 */
203
+	public function display_form_wide_errors()
204
+	{
205
+		$html = '';
206
+		if ($this->_form_section->get_validation_errors()) {
207
+			$html .= "<div class='ee-form-wide-errors'>";
208
+			// get all the errors on THIS form section (errors which aren't
209
+			// for specific inputs, but instead for the entire form section)
210
+			foreach ($this->_form_section->get_validation_errors() as $error) {
211
+				$html .= $error->getMessage() . '<br>';
212
+			}
213
+			$html .= '</div>';
214
+		}
215
+		return apply_filters(
216
+			'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
217
+			$html,
218
+			$this
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * returns the HTML for the server-side validation errors for the specified input
225
+	 * Note that if JS is enabled, it should remove these and instead
226
+	 * populate the form's errors in the jquery validate fashion
227
+	 * using the localized data provided to the JS
228
+	 *
229
+	 * @param EE_Form_Input_Base $input
230
+	 * @return string
231
+	 * @throws EE_Error
232
+	 */
233
+	public function display_errors($input)
234
+	{
235
+		if ($input->get_validation_errors()) {
236
+			return "<label  id='"
237
+				   . $input->html_id()
238
+				   . "-error' class='error' for='{$input->html_name()}'>"
239
+				   . $input->get_validation_error_string()
240
+				   . '</label>';
241
+		}
242
+		return '';
243
+	}
244
+
245
+
246
+	/**
247
+	 * Displays the help span for the specified input
248
+	 *
249
+	 * @param EE_Form_Input_Base $input
250
+	 * @return string
251
+	 * @throws EE_Error
252
+	 */
253
+	public function display_help_text($input)
254
+	{
255
+		$help_text  = $input->html_help_text();
256
+		if ($help_text !== '' && $help_text !== null) {
257
+			$tag = is_admin() ? 'p' : 'span';
258
+			return '<'
259
+				   . $tag
260
+				   . ' id="'
261
+				   . $input->html_id()
262
+				   . '-help" class="'
263
+				   . $input->html_help_class()
264
+				   . '" style="'
265
+				   . $input->html_help_style()
266
+				   . '">'
267
+				   . $help_text
268
+				   . '</'
269
+				   . $tag
270
+				   . '>';
271
+		}
272
+		return '';
273
+	}
274
+
275
+
276
+	/**
277
+	 * Does an action and hook onto the end of teh form
278
+	 *
279
+	 * @param string $html
280
+	 * @return string
281
+	 * @throws EE_Error
282
+	 */
283
+	public function add_form_section_hooks_and_filters($html)
284
+	{
285
+		// replace dashes and spaces with underscores
286
+		$hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
287
+		do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
288
+		$html = (string) apply_filters(
289
+			'AFEE__Form_Section_Layout__' . $hook_name . '__html',
290
+			$html,
291
+			$this->_form_section
292
+		);
293
+		$html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
294
+		$html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+		return $html;
296
+	}
297 297
 }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/InvisibleRecaptcha.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
         static $previous_recaptcha_response = array();
136 136
         $grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
137 137
         // if this token has already been verified, then return previous response
138
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
139
-            return $previous_recaptcha_response[ $grecaptcha_response ];
138
+        if (isset($previous_recaptcha_response[$grecaptcha_response])) {
139
+            return $previous_recaptcha_response[$grecaptcha_response];
140 140
         }
141 141
         // still here but no g-recaptcha-response ? - verification failed
142
-        if (! $grecaptcha_response) {
142
+        if ( ! $grecaptcha_response) {
143 143
             EE_Error::add_error(
144 144
                 sprintf(
145 145
                     /* translators: 1: missing parameter */
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             return false;
159 159
         }
160 160
         // will update to true if everything passes
161
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
161
+        $previous_recaptcha_response[$grecaptcha_response] = false;
162 162
         $response                                            = wp_safe_remote_post(
163 163
             InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
164 164
             array(
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
         }
176 176
         $results = json_decode(wp_remote_retrieve_body($response), true);
177 177
         if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
178
-            $errors   = array_map(
178
+            $errors = array_map(
179 179
                 array($this, 'getErrorCode'),
180 180
                 $results['error-codes']
181 181
             );
182 182
             if (isset($results['challenge_ts'])) {
183
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
183
+                $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.';
184 184
             }
185 185
             $this->generateError(implode(' ', $errors), true);
186 186
         }
187
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
187
+        $previous_recaptcha_response[$grecaptcha_response] = true;
188 188
         add_action('shutdown', array($this, 'setSessionData'));
189 189
         return true;
190 190
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             'bad-request'            => 'The request is invalid or malformed.',
226 226
             'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
227 227
         );
228
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
228
+        return isset($error_codes[$error_code]) ? $error_codes[$error_code] : '';
229 229
     }
230 230
 
231 231
 
Please login to merge, or discard this patch.
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -26,272 +26,272 @@
 block discarded – undo
26 26
  */
27 27
 class InvisibleRecaptcha
28 28
 {
29
-    const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
29
+	const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
30 30
 
31
-    const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
31
+	const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
32 32
 
33
-    /**
34
-     * @var EE_Registration_Config $config
35
-     */
36
-    private $config;
33
+	/**
34
+	 * @var EE_Registration_Config $config
35
+	 */
36
+	private $config;
37 37
 
38
-    /**
39
-     * @var EE_Session $session
40
-     */
41
-    private $session;
38
+	/**
39
+	 * @var EE_Session $session
40
+	 */
41
+	private $session;
42 42
 
43
-    /**
44
-     * @var boolean $recaptcha_passed
45
-     */
46
-    private $recaptcha_passed;
43
+	/**
44
+	 * @var boolean $recaptcha_passed
45
+	 */
46
+	private $recaptcha_passed;
47 47
 
48 48
 
49
-    /**
50
-     * InvisibleRecaptcha constructor.
51
-     *
52
-     * @param EE_Registration_Config $registration_config
53
-     * @param EE_Session             $session
54
-     */
55
-    public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null)
56
-    {
57
-        $this->config = $registration_config;
58
-        $this->session = $session;
59
-    }
49
+	/**
50
+	 * InvisibleRecaptcha constructor.
51
+	 *
52
+	 * @param EE_Registration_Config $registration_config
53
+	 * @param EE_Session             $session
54
+	 */
55
+	public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null)
56
+	{
57
+		$this->config = $registration_config;
58
+		$this->session = $session;
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * @return boolean
64
-     */
65
-    public function useInvisibleRecaptcha()
66
-    {
67
-        return $this->session instanceof EE_Session
68
-               && $this->config->use_captcha
69
-               && $this->config->recaptcha_theme === 'invisible';
70
-    }
62
+	/**
63
+	 * @return boolean
64
+	 */
65
+	public function useInvisibleRecaptcha()
66
+	{
67
+		return $this->session instanceof EE_Session
68
+			   && $this->config->use_captcha
69
+			   && $this->config->recaptcha_theme === 'invisible';
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * @param array $input_settings
75
-     * @return EE_Invisible_Recaptcha_Input
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws InvalidArgumentException
79
-     * @throws DomainException
80
-     */
81
-    public function getInput(array $input_settings = array())
82
-    {
83
-        return new EE_Invisible_Recaptcha_Input(
84
-            $input_settings,
85
-            $this->config
86
-        );
87
-    }
73
+	/**
74
+	 * @param array $input_settings
75
+	 * @return EE_Invisible_Recaptcha_Input
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws InvalidArgumentException
79
+	 * @throws DomainException
80
+	 */
81
+	public function getInput(array $input_settings = array())
82
+	{
83
+		return new EE_Invisible_Recaptcha_Input(
84
+			$input_settings,
85
+			$this->config
86
+		);
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * @param array $input_settings
92
-     * @return string
93
-     * @throws EE_Error
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidArgumentException
97
-     * @throws DomainException
98
-     */
99
-    public function getInputHtml(array $input_settings = array())
100
-    {
101
-        return $this->getInput($input_settings)->get_html_for_input();
102
-    }
90
+	/**
91
+	 * @param array $input_settings
92
+	 * @return string
93
+	 * @throws EE_Error
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidArgumentException
97
+	 * @throws DomainException
98
+	 */
99
+	public function getInputHtml(array $input_settings = array())
100
+	{
101
+		return $this->getInput($input_settings)->get_html_for_input();
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * @param EE_Form_Section_Proper $form
107
-     * @param array                  $input_settings
108
-     * @throws EE_Error
109
-     * @throws InvalidArgumentException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     * @throws DomainException
113
-     */
114
-    public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
115
-    {
116
-        $form->add_subsections(
117
-            array(
118
-                'espresso_recaptcha' => $this->getInput($input_settings),
119
-            ),
120
-            null,
121
-            false
122
-        );
123
-    }
105
+	/**
106
+	 * @param EE_Form_Section_Proper $form
107
+	 * @param array                  $input_settings
108
+	 * @throws EE_Error
109
+	 * @throws InvalidArgumentException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 * @throws DomainException
113
+	 */
114
+	public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
115
+	{
116
+		$form->add_subsections(
117
+			array(
118
+				'espresso_recaptcha' => $this->getInput($input_settings),
119
+			),
120
+			null,
121
+			false
122
+		);
123
+	}
124 124
 
125 125
 
126
-    /**
127
-     * @param RequestInterface $request
128
-     * @return boolean
129
-     * @throws InvalidArgumentException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidInterfaceException
132
-     * @throws RuntimeException
133
-     */
134
-    public function verifyToken(RequestInterface $request)
135
-    {
136
-        static $previous_recaptcha_response = array();
137
-        $grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
138
-        // if this token has already been verified, then return previous response
139
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
140
-            return $previous_recaptcha_response[ $grecaptcha_response ];
141
-        }
142
-        // still here but no g-recaptcha-response ? - verification failed
143
-        if (! $grecaptcha_response) {
144
-            EE_Error::add_error(
145
-                sprintf(
146
-                    /* translators: 1: missing parameter */
147
-                    esc_html__(
148
-                        // @codingStandardsIgnoreStart
149
-                        'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.',
150
-                        // @codingStandardsIgnoreEnd
151
-                        'event_espresso'
152
-                    ),
153
-                    'g-recaptcha-response'
154
-                ),
155
-                __FILE__,
156
-                __FUNCTION__,
157
-                __LINE__
158
-            );
159
-            return false;
160
-        }
161
-        // will update to true if everything passes
162
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
163
-        $response                                            = wp_safe_remote_post(
164
-            InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
165
-            array(
166
-                'body' => array(
167
-                    'secret'   => $this->config->recaptcha_privatekey,
168
-                    'response' => $grecaptcha_response,
169
-                    'remoteip' => $request->ipAddress(),
170
-                ),
171
-            )
172
-        );
173
-        if ($response instanceof WP_Error) {
174
-            $this->generateError($response->get_error_messages());
175
-            return false;
176
-        }
177
-        $results = json_decode(wp_remote_retrieve_body($response), true);
178
-        if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
179
-            $errors   = array_map(
180
-                array($this, 'getErrorCode'),
181
-                $results['error-codes']
182
-            );
183
-            if (isset($results['challenge_ts'])) {
184
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
185
-            }
186
-            $this->generateError(implode(' ', $errors), true);
187
-        }
188
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
189
-        add_action('shutdown', array($this, 'setSessionData'));
190
-        return true;
191
-    }
126
+	/**
127
+	 * @param RequestInterface $request
128
+	 * @return boolean
129
+	 * @throws InvalidArgumentException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidInterfaceException
132
+	 * @throws RuntimeException
133
+	 */
134
+	public function verifyToken(RequestInterface $request)
135
+	{
136
+		static $previous_recaptcha_response = array();
137
+		$grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
138
+		// if this token has already been verified, then return previous response
139
+		if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
140
+			return $previous_recaptcha_response[ $grecaptcha_response ];
141
+		}
142
+		// still here but no g-recaptcha-response ? - verification failed
143
+		if (! $grecaptcha_response) {
144
+			EE_Error::add_error(
145
+				sprintf(
146
+					/* translators: 1: missing parameter */
147
+					esc_html__(
148
+						// @codingStandardsIgnoreStart
149
+						'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.',
150
+						// @codingStandardsIgnoreEnd
151
+						'event_espresso'
152
+					),
153
+					'g-recaptcha-response'
154
+				),
155
+				__FILE__,
156
+				__FUNCTION__,
157
+				__LINE__
158
+			);
159
+			return false;
160
+		}
161
+		// will update to true if everything passes
162
+		$previous_recaptcha_response[ $grecaptcha_response ] = false;
163
+		$response                                            = wp_safe_remote_post(
164
+			InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
165
+			array(
166
+				'body' => array(
167
+					'secret'   => $this->config->recaptcha_privatekey,
168
+					'response' => $grecaptcha_response,
169
+					'remoteip' => $request->ipAddress(),
170
+				),
171
+			)
172
+		);
173
+		if ($response instanceof WP_Error) {
174
+			$this->generateError($response->get_error_messages());
175
+			return false;
176
+		}
177
+		$results = json_decode(wp_remote_retrieve_body($response), true);
178
+		if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
179
+			$errors   = array_map(
180
+				array($this, 'getErrorCode'),
181
+				$results['error-codes']
182
+			);
183
+			if (isset($results['challenge_ts'])) {
184
+				$errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
185
+			}
186
+			$this->generateError(implode(' ', $errors), true);
187
+		}
188
+		$previous_recaptcha_response[ $grecaptcha_response ] = true;
189
+		add_action('shutdown', array($this, 'setSessionData'));
190
+		return true;
191
+	}
192 192
 
193 193
 
194
-    /**
195
-     * @param string $error_response
196
-     * @param bool   $show_errors
197
-     * @return void
198
-     * @throws RuntimeException
199
-     */
200
-    public function generateError($error_response = '', $show_errors = false)
201
-    {
202
-        throw new RuntimeException(
203
-            sprintf(
204
-                esc_html__(
205
-                    'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
206
-                    'event_espresso'
207
-                ),
208
-                '<br />',
209
-                $show_errors || current_user_can('manage_options') ? $error_response : ''
210
-            )
211
-        );
212
-    }
194
+	/**
195
+	 * @param string $error_response
196
+	 * @param bool   $show_errors
197
+	 * @return void
198
+	 * @throws RuntimeException
199
+	 */
200
+	public function generateError($error_response = '', $show_errors = false)
201
+	{
202
+		throw new RuntimeException(
203
+			sprintf(
204
+				esc_html__(
205
+					'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
206
+					'event_espresso'
207
+				),
208
+				'<br />',
209
+				$show_errors || current_user_can('manage_options') ? $error_response : ''
210
+			)
211
+		);
212
+	}
213 213
 
214 214
 
215
-    /**
216
-     * @param string $error_code
217
-     * @return string
218
-     */
219
-    public function getErrorCode(&$error_code)
220
-    {
221
-        $error_codes = array(
222
-            'missing-input-secret'   => 'The secret parameter is missing.',
223
-            'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
224
-            'missing-input-response' => 'The response parameter is missing.',
225
-            'invalid-input-response' => 'The response parameter is invalid or malformed.',
226
-            'bad-request'            => 'The request is invalid or malformed.',
227
-            'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
228
-        );
229
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
230
-    }
215
+	/**
216
+	 * @param string $error_code
217
+	 * @return string
218
+	 */
219
+	public function getErrorCode(&$error_code)
220
+	{
221
+		$error_codes = array(
222
+			'missing-input-secret'   => 'The secret parameter is missing.',
223
+			'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
224
+			'missing-input-response' => 'The response parameter is missing.',
225
+			'invalid-input-response' => 'The response parameter is invalid or malformed.',
226
+			'bad-request'            => 'The request is invalid or malformed.',
227
+			'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
228
+		);
229
+		return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * @return array
235
-     * @throws InvalidInterfaceException
236
-     * @throws InvalidDataTypeException
237
-     * @throws InvalidArgumentException
238
-     */
239
-    public function getLocalizedVars()
240
-    {
241
-        return (array) apply_filters(
242
-            'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
243
-            array(
244
-                'siteKey'          => $this->config->recaptcha_publickey,
245
-                'recaptcha_passed' => $this->recaptchaPassed(),
246
-                'wp_debug'         => WP_DEBUG,
247
-                'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
248
-                'failed_message'   => wp_strip_all_tags(
249
-                    __(
250
-                        'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.',
251
-                        'event_espresso'
252
-                    )
253
-                )
254
-            )
255
-        );
256
-    }
233
+	/**
234
+	 * @return array
235
+	 * @throws InvalidInterfaceException
236
+	 * @throws InvalidDataTypeException
237
+	 * @throws InvalidArgumentException
238
+	 */
239
+	public function getLocalizedVars()
240
+	{
241
+		return (array) apply_filters(
242
+			'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
243
+			array(
244
+				'siteKey'          => $this->config->recaptcha_publickey,
245
+				'recaptcha_passed' => $this->recaptchaPassed(),
246
+				'wp_debug'         => WP_DEBUG,
247
+				'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
248
+				'failed_message'   => wp_strip_all_tags(
249
+					__(
250
+						'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.',
251
+						'event_espresso'
252
+					)
253
+				)
254
+			)
255
+		);
256
+	}
257 257
 
258 258
 
259
-    /**
260
-     * @return boolean
261
-     * @throws InvalidInterfaceException
262
-     * @throws InvalidDataTypeException
263
-     * @throws InvalidArgumentException
264
-     */
265
-    public function recaptchaPassed()
266
-    {
267
-        if ($this->recaptcha_passed !== null) {
268
-            return $this->recaptcha_passed;
269
-        }
270
-        // logged in means you have already passed a turing test of sorts
271
-        if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
272
-            $this->recaptcha_passed = true;
273
-            return $this->recaptcha_passed;
274
-        }
275
-        // was test already passed?
276
-        $this->recaptcha_passed = filter_var(
277
-            $this->session->get_session_data(
278
-                InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
279
-            ),
280
-            FILTER_VALIDATE_BOOLEAN
281
-        );
282
-        return $this->recaptcha_passed;
283
-    }
259
+	/**
260
+	 * @return boolean
261
+	 * @throws InvalidInterfaceException
262
+	 * @throws InvalidDataTypeException
263
+	 * @throws InvalidArgumentException
264
+	 */
265
+	public function recaptchaPassed()
266
+	{
267
+		if ($this->recaptcha_passed !== null) {
268
+			return $this->recaptcha_passed;
269
+		}
270
+		// logged in means you have already passed a turing test of sorts
271
+		if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
272
+			$this->recaptcha_passed = true;
273
+			return $this->recaptcha_passed;
274
+		}
275
+		// was test already passed?
276
+		$this->recaptcha_passed = filter_var(
277
+			$this->session->get_session_data(
278
+				InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
279
+			),
280
+			FILTER_VALIDATE_BOOLEAN
281
+		);
282
+		return $this->recaptcha_passed;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * @throws InvalidArgumentException
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidInterfaceException
290
-     */
291
-    public function setSessionData()
292
-    {
293
-        if ($this->session instanceof EE_Session) {
294
-            $this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]);
295
-        }
296
-    }
286
+	/**
287
+	 * @throws InvalidArgumentException
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidInterfaceException
290
+	 */
291
+	public function setSessionData()
292
+	{
293
+		if ($this->session instanceof EE_Session) {
294
+			$this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]);
295
+		}
296
+	}
297 297
 }
Please login to merge, or discard this patch.
core/services/json/JsonSerializableAndUnserializable.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@
 block discarded – undo
15 15
  */
16 16
 interface JsonSerializableAndUnserializable
17 17
 {
18
-    /**
19
-     * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
-     * wp_json_serialize().
21
-     * @since 4.9.80.p
22
-     * @return mixed
23
-     */
24
-    public function toJsonSerializableData();
18
+	/**
19
+	 * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
+	 * wp_json_serialize().
21
+	 * @since 4.9.80.p
22
+	 * @return mixed
23
+	 */
24
+	public function toJsonSerializableData();
25 25
 
26
-    /**
27
-     * Initializes this object from data
28
-     * @since 4.9.80.p
29
-     * @param mixed $data
30
-     * @return boolean success
31
-     */
32
-    public function fromJsonSerializedData($data);
26
+	/**
27
+	 * Initializes this object from data
28
+	 * @since 4.9.80.p
29
+	 * @param mixed $data
30
+	 * @return boolean success
31
+	 */
32
+	public function fromJsonSerializedData($data);
33 33
 }
34 34
 // End of file JsonSerializableAndUnserializable.php
35 35
 // Location: EventEspresso\core\services\json/JsonSerializableAndUnserializable.php
Please login to merge, or discard this patch.
core/services/options/JsonWpOptionSerializableInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
  */
18 18
 interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable
19 19
 {
20
-    /**
21
-     * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
-     * determine what option name to use.
23
-     * @since 4.9.80.p
24
-     * @return string
25
-     */
26
-    public function getWpOptionName();
20
+	/**
21
+	 * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
+	 * determine what option name to use.
23
+	 * @since 4.9.80.p
24
+	 * @return string
25
+	 */
26
+	public function getWpOptionName();
27 27
 }
28 28
 // End of file JsonWpOptionSerializableInterface.php
29 29
 // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php
Please login to merge, or discard this patch.
admin/new/pricing/help_tabs/pricing_add_new_price_type.help_tab.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 <p><strong><?php esc_html_e('Add New Price Type', 'event_espresso'); ?></strong></p>
5 5
 <p>
6 6
 <?php printf(
7
-    esc_html__('This page allows you to create a new price type for %s.', 'event_espresso'),
8
-    Domain::brandName()
7
+	esc_html__('This page allows you to create a new price type for %s.', 'event_espresso'),
8
+	Domain::brandName()
9 9
 ); ?>
10 10
 </p>
11 11
 <ul>
Please login to merge, or discard this patch.
admin/new/pricing/help_tabs/pricing_edit_default_price.help_tab.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 <p><strong><?php esc_html_e('Edit Default Price', 'event_espresso'); ?></strong></p>
5 5
 <p>
6 6
 <?php printf(
7
-    esc_html__('This page allows you to edit a default price for %s.', 'event_espresso'),
8
-    Domain::brandName()
7
+	esc_html__('This page allows you to edit a default price for %s.', 'event_espresso'),
8
+	Domain::brandName()
9 9
 ); ?>
10 10
 </p>
11 11
 <ul>
Please login to merge, or discard this patch.