Completed
Branch dependabot/composer/wp-graphql... (d51bd9)
by
unknown
05:53 queued 14s
created
core/domain/services/admin/events/editor/FormBuilder.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 $UUID = $section->UUID();
56 56
 
57 57
                 // Avoid duplicates, if any
58
-                $sections[ $UUID ] = [
58
+                $sections[$UUID] = [
59 59
                     'id'         => $UUID,
60 60
                     'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
61 61
                     'attributes' => $section->attributes()->toJson(),
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 $UUID = $element->UUID();
86 86
 
87 87
             // Avoid duplicates
88
-                $elements[ $UUID ] = [
88
+                $elements[$UUID] = [
89 89
                 'id'         => $UUID,
90 90
                 'adminOnly'  => $element->adminOnly(),
91 91
                 'attributes' => $element->attributes()->toJson(),
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -23,87 +23,87 @@
 block discarded – undo
23 23
  */
24 24
 class FormBuilder implements EventEditorDataInterface
25 25
 {
26
-    /**
27
-     * @param int $eventId
28
-     * @return array
29
-     * @throws EE_Error
30
-     * @throws ReflectionException
31
-     */
32
-    public function getData(int $eventId): array
33
-    {
34
-        /** @var EE_Event $event */
35
-        $event = EEM_Event::instance()->get_one_by_ID($eventId);
36
-        $topLevelSectionId = $event->registrationFormUuid();
26
+	/**
27
+	 * @param int $eventId
28
+	 * @return array
29
+	 * @throws EE_Error
30
+	 * @throws ReflectionException
31
+	 */
32
+	public function getData(int $eventId): array
33
+	{
34
+		/** @var EE_Event $event */
35
+		$event = EEM_Event::instance()->get_one_by_ID($eventId);
36
+		$topLevelSectionId = $event->registrationFormUuid();
37 37
 
38
-        /** @var EE_Form_Section[] $form_sections */
39
-        $form_sections = EEM_Form_Section::instance()->get_all([
40
-            [
41
-                'OR' => [
42
-                    'FSC_UUID'      => $topLevelSectionId, // top level form
43
-                    'FSC_belongsTo' => $topLevelSectionId, // child form sections
44
-                    'FSC_status'    => FormStatus::SHARED, // shared form sections
45
-                ]
46
-                ],
47
-            'order_by' => ['FSC_order' => 'ASC'],
48
-        ]);
38
+		/** @var EE_Form_Section[] $form_sections */
39
+		$form_sections = EEM_Form_Section::instance()->get_all([
40
+			[
41
+				'OR' => [
42
+					'FSC_UUID'      => $topLevelSectionId, // top level form
43
+					'FSC_belongsTo' => $topLevelSectionId, // child form sections
44
+					'FSC_status'    => FormStatus::SHARED, // shared form sections
45
+				]
46
+				],
47
+			'order_by' => ['FSC_order' => 'ASC'],
48
+		]);
49 49
 
50
-        $sections = [];
51
-        foreach ($form_sections as $section) {
52
-            if ($section instanceof EE_Form_Section) {
53
-                $UUID = $section->UUID();
50
+		$sections = [];
51
+		foreach ($form_sections as $section) {
52
+			if ($section instanceof EE_Form_Section) {
53
+				$UUID = $section->UUID();
54 54
 
55
-                // Avoid duplicates, if any
56
-                $sections[ $UUID ] = [
57
-                    'id'         => $UUID,
58
-                    'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
59
-                    'attributes' => $section->attributes()->toJson(),
60
-                    'belongsTo'  => $section->belongsTo(),
61
-                    'isActive'   => $section->isActive(),
62
-                    'isArchived' => $section->isArchived(),
63
-                    'isDefault'  => $section->isDefault(),
64
-                    'isShared'   => $section->isShared(),
65
-                    'isTrashed'  => $section->isTrashed(),
66
-                    'label'      => $section->label()->toJson(),
67
-                    'order'      => $section->order(),
68
-                    'status'     => GQLUtils::formatEnumKey($section->status()),
69
-                ];
70
-            }
71
-        }
55
+				// Avoid duplicates, if any
56
+				$sections[ $UUID ] = [
57
+					'id'         => $UUID,
58
+					'appliesTo'  => GQLUtils::formatEnumKey($section->appliesTo()),
59
+					'attributes' => $section->attributes()->toJson(),
60
+					'belongsTo'  => $section->belongsTo(),
61
+					'isActive'   => $section->isActive(),
62
+					'isArchived' => $section->isArchived(),
63
+					'isDefault'  => $section->isDefault(),
64
+					'isShared'   => $section->isShared(),
65
+					'isTrashed'  => $section->isTrashed(),
66
+					'label'      => $section->label()->toJson(),
67
+					'order'      => $section->order(),
68
+					'status'     => GQLUtils::formatEnumKey($section->status()),
69
+				];
70
+			}
71
+		}
72 72
 
73
-        /** @var EE_Form_Element[] $form_elements */
74
-        $form_elements = EEM_Form_Element::instance()->get_all([
75
-            [
76
-                'FSC_UUID' => ['IN', array_keys($sections)]
77
-            ]
78
-        ]);
73
+		/** @var EE_Form_Element[] $form_elements */
74
+		$form_elements = EEM_Form_Element::instance()->get_all([
75
+			[
76
+				'FSC_UUID' => ['IN', array_keys($sections)]
77
+			]
78
+		]);
79 79
 
80
-        $elements = [];
81
-        foreach ($form_elements as $element) {
82
-            if ($element instanceof EE_Form_Element) {
83
-                $UUID = $element->UUID();
80
+		$elements = [];
81
+		foreach ($form_elements as $element) {
82
+			if ($element instanceof EE_Form_Element) {
83
+				$UUID = $element->UUID();
84 84
 
85
-            // Avoid duplicates
86
-                $elements[ $UUID ] = [
87
-                'id'         => $UUID,
88
-                'adminOnly'  => $element->adminOnly(),
89
-                'attributes' => $element->attributes()->toJson(),
90
-                'belongsTo'  => $element->belongsTo(),
91
-                'helpText'   => $element->helpText()->toJson(),
92
-                'label'      => $element->label()->toJson(),
93
-                'mapsTo'     => $element->mapsTo(),
94
-                'options'    => $element->options()->toJson(),
95
-                'order'      => $element->order(),
96
-                'required'   => $element->required()->toJson(),
97
-                'status'     => GQLUtils::formatEnumKey($element->status()),
98
-                'type'       => GQLUtils::formatEnumKey($element->type()),
99
-                ];
100
-            }
101
-        }
85
+			// Avoid duplicates
86
+				$elements[ $UUID ] = [
87
+				'id'         => $UUID,
88
+				'adminOnly'  => $element->adminOnly(),
89
+				'attributes' => $element->attributes()->toJson(),
90
+				'belongsTo'  => $element->belongsTo(),
91
+				'helpText'   => $element->helpText()->toJson(),
92
+				'label'      => $element->label()->toJson(),
93
+				'mapsTo'     => $element->mapsTo(),
94
+				'options'    => $element->options()->toJson(),
95
+				'order'      => $element->order(),
96
+				'required'   => $element->required()->toJson(),
97
+				'status'     => GQLUtils::formatEnumKey($element->status()),
98
+				'type'       => GQLUtils::formatEnumKey($element->type()),
99
+				];
100
+			}
101
+		}
102 102
 
103
-        return [
104
-            'elements'          => array_values($elements),
105
-            'sections'          => array_values($sections),
106
-            'topLevelSectionId' => $event->registrationFormUuid()
107
-        ];
108
-    }
103
+		return [
104
+			'elements'          => array_values($elements),
105
+			'sections'          => array_values($sections),
106
+			'topLevelSectionId' => $event->registrationFormUuid()
107
+		];
108
+	}
109 109
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Text.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -4,61 +4,61 @@
 block discarded – undo
4 4
 
5 5
 class Text
6 6
 {
7
-    /**
8
-     * indicates that the HTML input type is 'email'
9
-     */
10
-    public const TYPE_EMAIL = 'email';
7
+	/**
8
+	 * indicates that the HTML input type is 'email'
9
+	 */
10
+	public const TYPE_EMAIL = 'email';
11 11
 
12
-    /**
13
-     * indicates that the input is used to confirm an email address
14
-     */
15
-    public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation';
12
+	/**
13
+	 * indicates that the input is used to confirm an email address
14
+	 */
15
+	public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation';
16 16
 
17
-    /**
18
-     * indicates that the HTML input type is 'text'
19
-     */
20
-    public const TYPE_TEXT = 'text';
17
+	/**
18
+	 * indicates that the HTML input type is 'text'
19
+	 */
20
+	public const TYPE_TEXT = 'text';
21 21
 
22
-    /**
23
-     * indicates that the input is a TEXTAREA that only allows plain text
24
-     */
25
-    public const TYPE_TEXTAREA = 'textarea';
22
+	/**
23
+	 * indicates that the input is a TEXTAREA that only allows plain text
24
+	 */
25
+	public const TYPE_TEXTAREA = 'textarea';
26 26
 
27
-    /**
28
-     * indicates that the input is a TEXTAREA that allows simple html
29
-     */
30
-    public const TYPE_TEXTAREA_HTML = 'textarea-html';
27
+	/**
28
+	 * indicates that the input is a TEXTAREA that allows simple html
29
+	 */
30
+	public const TYPE_TEXTAREA_HTML = 'textarea-html';
31 31
 
32 32
 
33
-    /**
34
-     * @var array
35
-     */
36
-    private $valid_type_options;
33
+	/**
34
+	 * @var array
35
+	 */
36
+	private $valid_type_options;
37 37
 
38 38
 
39
-    public function __construct()
40
-    {
41
-        $this->valid_type_options = apply_filters(
42
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options',
43
-            [
44
-                Text::TYPE_EMAIL              => esc_html__('Email', 'event_espresso'),
45
-                Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'),
46
-                Text::TYPE_TEXT               => esc_html__('Plain Text', 'event_espresso'),
47
-                Text::TYPE_TEXTAREA           => esc_html__('Plain Textarea', 'event_espresso'),
48
-                Text::TYPE_TEXTAREA_HTML      => esc_html__('Simple HTML Textarea', 'event_espresso'),
49
-            ]
50
-        );
51
-    }
39
+	public function __construct()
40
+	{
41
+		$this->valid_type_options = apply_filters(
42
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options',
43
+			[
44
+				Text::TYPE_EMAIL              => esc_html__('Email', 'event_espresso'),
45
+				Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'),
46
+				Text::TYPE_TEXT               => esc_html__('Plain Text', 'event_espresso'),
47
+				Text::TYPE_TEXTAREA           => esc_html__('Plain Textarea', 'event_espresso'),
48
+				Text::TYPE_TEXTAREA_HTML      => esc_html__('Simple HTML Textarea', 'event_espresso'),
49
+			]
50
+		);
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @param bool $constants_only
56
-     * @return array
57
-     */
58
-    public function validTypeOptions(bool $constants_only = false): array
59
-    {
60
-        return $constants_only
61
-            ? array_keys($this->valid_type_options)
62
-            : $this->valid_type_options;
63
-    }
54
+	/**
55
+	 * @param bool $constants_only
56
+	 * @return array
57
+	 */
58
+	public function validTypeOptions(bool $constants_only = false): array
59
+	{
60
+		return $constants_only
61
+			? array_keys($this->valid_type_options)
62
+			: $this->valid_type_options;
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Input.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -5,90 +5,90 @@
 block discarded – undo
5 5
 class Input
6 6
 {
7 7
 
8
-    /**
9
-     * indicates that the HTML input type is 'checkbox'
10
-     */
11
-    public const TYPE_CHECKBOX = 'checkbox';
12
-
13
-    /**
14
-     * indicates that the HTML input type is 'multi checkbox'
15
-     */
16
-    public const TYPE_CHECKBOX_MULTI = 'checkbox-multi';
17
-
18
-    /**
19
-     * indicates that the HTML input type is 'color'
20
-     */
21
-    public const TYPE_COLOR = 'color';
22
-
23
-    /**
24
-     * indicates that the HTML input type is 'file'
25
-     */
26
-    public const TYPE_FILE = 'file';
27
-
28
-    /**
29
-     * indicates that the HTML input type is 'hidden'
30
-     */
31
-    public const TYPE_HIDDEN = 'hidden';
32
-
33
-    /**
34
-     * indicates that the HTML input type is 'image'
35
-     */
36
-    public const TYPE_IMAGE = 'image';
37
-
38
-    /**
39
-     * indicates that the HTML input type is 'password'
40
-     */
41
-    public const TYPE_PASSWORD = 'password';
42
-
43
-    /**
44
-     * indicates that the input is used to confirm a password
45
-     */
46
-    public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation';
47
-
48
-    /**
49
-     * indicates that the HTML input type is 'radio'
50
-     */
51
-    public const TYPE_RADIO = 'radio';
52
-
53
-    /**
54
-     * indicates that the HTML input type is 'url'
55
-     */
56
-    public const TYPE_URL = 'url';
57
-
58
-    /**
59
-     * @var array
60
-     */
61
-    private $valid_type_options;
62
-
63
-
64
-    public function __construct()
65
-    {
66
-        $this->valid_type_options = apply_filters(
67
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options',
68
-            [
69
-                Input::TYPE_CHECKBOX              => esc_html__('Checkbox', 'event_espresso'),
70
-                Input::TYPE_CHECKBOX_MULTI        => esc_html__('Multi Checkbox', 'event_espresso'),
71
-                Input::TYPE_COLOR                 => esc_html__('Color Picker', 'event_espresso'),
72
-                Input::TYPE_FILE                  => esc_html__('File Upload', 'event_espresso'),
73
-                Input::TYPE_HIDDEN                => esc_html__('Hidden', 'event_espresso'),
74
-                Input::TYPE_IMAGE                 => esc_html__('Image Upload', 'event_espresso'),
75
-                Input::TYPE_PASSWORD              => esc_html__('Password', 'event_espresso'),
76
-                Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'),
77
-                Input::TYPE_RADIO                 => esc_html__('Radio Button', 'event_espresso'),
78
-                Input::TYPE_URL                   => esc_html__('URL', 'event_espresso'),
79
-            ]
80
-        );
81
-    }
82
-
83
-
84
-    /**
85
-     * @param bool $constants_only
86
-     * @return array
87
-     */
88
-    public function validTypeOptions(bool $constants_only = false): array
89
-    {
90
-        return $constants_only
91
-            ? array_keys($this->valid_type_options)
92
-            : $this->valid_type_options;
93
-    }
8
+	/**
9
+	 * indicates that the HTML input type is 'checkbox'
10
+	 */
11
+	public const TYPE_CHECKBOX = 'checkbox';
12
+
13
+	/**
14
+	 * indicates that the HTML input type is 'multi checkbox'
15
+	 */
16
+	public const TYPE_CHECKBOX_MULTI = 'checkbox-multi';
17
+
18
+	/**
19
+	 * indicates that the HTML input type is 'color'
20
+	 */
21
+	public const TYPE_COLOR = 'color';
22
+
23
+	/**
24
+	 * indicates that the HTML input type is 'file'
25
+	 */
26
+	public const TYPE_FILE = 'file';
27
+
28
+	/**
29
+	 * indicates that the HTML input type is 'hidden'
30
+	 */
31
+	public const TYPE_HIDDEN = 'hidden';
32
+
33
+	/**
34
+	 * indicates that the HTML input type is 'image'
35
+	 */
36
+	public const TYPE_IMAGE = 'image';
37
+
38
+	/**
39
+	 * indicates that the HTML input type is 'password'
40
+	 */
41
+	public const TYPE_PASSWORD = 'password';
42
+
43
+	/**
44
+	 * indicates that the input is used to confirm a password
45
+	 */
46
+	public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation';
47
+
48
+	/**
49
+	 * indicates that the HTML input type is 'radio'
50
+	 */
51
+	public const TYPE_RADIO = 'radio';
52
+
53
+	/**
54
+	 * indicates that the HTML input type is 'url'
55
+	 */
56
+	public const TYPE_URL = 'url';
57
+
58
+	/**
59
+	 * @var array
60
+	 */
61
+	private $valid_type_options;
62
+
63
+
64
+	public function __construct()
65
+	{
66
+		$this->valid_type_options = apply_filters(
67
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options',
68
+			[
69
+				Input::TYPE_CHECKBOX              => esc_html__('Checkbox', 'event_espresso'),
70
+				Input::TYPE_CHECKBOX_MULTI        => esc_html__('Multi Checkbox', 'event_espresso'),
71
+				Input::TYPE_COLOR                 => esc_html__('Color Picker', 'event_espresso'),
72
+				Input::TYPE_FILE                  => esc_html__('File Upload', 'event_espresso'),
73
+				Input::TYPE_HIDDEN                => esc_html__('Hidden', 'event_espresso'),
74
+				Input::TYPE_IMAGE                 => esc_html__('Image Upload', 'event_espresso'),
75
+				Input::TYPE_PASSWORD              => esc_html__('Password', 'event_espresso'),
76
+				Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'),
77
+				Input::TYPE_RADIO                 => esc_html__('Radio Button', 'event_espresso'),
78
+				Input::TYPE_URL                   => esc_html__('URL', 'event_espresso'),
79
+			]
80
+		);
81
+	}
82
+
83
+
84
+	/**
85
+	 * @param bool $constants_only
86
+	 * @return array
87
+	 */
88
+	public function validTypeOptions(bool $constants_only = false): array
89
+	{
90
+		return $constants_only
91
+			? array_keys($this->valid_type_options)
92
+			: $this->valid_type_options;
93
+	}
94 94
 }
Please login to merge, or discard this patch.
core/services/progress_steps/ProgressStepManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
         $this->setDisplayStrategy($display_strategy_name);
76 76
         $this->setDefaultStep($default_step);
77 77
         $this->setFormStepUrlKey($form_step_url_key);
78
-        if (! $collection instanceof CollectionInterface) {
78
+        if ( ! $collection instanceof CollectionInterface) {
79 79
             $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
80 80
         }
81 81
         $this->collection = $collection;
82
-        if (! $request instanceof RequestInterface) {
82
+        if ( ! $request instanceof RequestInterface) {
83 83
             /** @var RequestInterface $request */
84 84
             $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
85 85
         }
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
96 96
     {
97
-        if (! is_string($display_strategy_name)) {
97
+        if ( ! is_string($display_strategy_name)) {
98 98
             throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
99 99
         }
100 100
         // build up FQCN from incoming display strategy folder name
101 101
         $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
102
-        $display_strategy_class .= $display_strategy_name . '\\';
102
+        $display_strategy_class .= $display_strategy_name.'\\';
103 103
         $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
104 104
         $display_strategy_class .= 'ProgressStepsDisplay';
105 105
         $display_strategy_class = apply_filters(
106 106
             'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
107 107
             $display_strategy_class
108 108
         );
109
-        if (! class_exists($display_strategy_class)) {
109
+        if ( ! class_exists($display_strategy_class)) {
110 110
             throw new InvalidClassException($display_strategy_class);
111 111
         }
112 112
         $display_strategy = new $display_strategy_class();
113
-        if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
113
+        if ( ! $display_strategy instanceof ProgressStepsDisplayInterface) {
114 114
             throw new InvalidClassException(
115 115
                 $display_strategy_class,
116 116
                 sprintf(
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function setDefaultStep($default_step)
132 132
     {
133
-        if (! is_string($default_step)) {
133
+        if ( ! is_string($default_step)) {
134 134
             throw new InvalidDataTypeException('$default_step', $default_step, 'string');
135 135
         }
136 136
         $this->default_step = $default_step;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
145 145
     {
146
-        if (! is_string($form_step_url_key)) {
146
+        if ( ! is_string($form_step_url_key)) {
147 147
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
148 148
         }
149 149
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // grab the step previously known as current, in case we need to revert
164 164
         $current_current_step = $this->collection->current();
165 165
         // verify that requested step exists
166
-        if (! $this->collection->has($step)) {
166
+        if ( ! $this->collection->has($step)) {
167 167
             throw new InvalidIdentifierException($step, $this->default_step);
168 168
         }
169 169
         if ($this->collection->setCurrent($step)) {
Please login to merge, or discard this patch.
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -26,225 +26,225 @@
 block discarded – undo
26 26
  */
27 27
 class ProgressStepManager
28 28
 {
29
-    /**
30
-     * @var ProgressStepInterface[]
31
-     */
32
-    private $collection;
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    private $default_step;
38
-
39
-    /**
40
-     * the key used for the URL param that denotes the current form step
41
-     * defaults to 'ee-form-step'
42
-     *
43
-     * @var string
44
-     */
45
-    private $form_step_url_key = '';
46
-
47
-    /**
48
-     * @var ProgressStepsDisplayInterface
49
-     */
50
-    private $display_strategy;
51
-
52
-    /**
53
-     * @var RequestInterface
54
-     */
55
-    private $request;
56
-
57
-
58
-    /**
59
-     * ProgressStepManager constructor
60
-     *
61
-     * @param string              $display_strategy_name
62
-     * @param string              $default_step
63
-     * @param string              $form_step_url_key
64
-     * @param CollectionInterface $collection
65
-     * @param RequestInterface    $request
66
-     */
67
-    public function __construct(
68
-        $display_strategy_name = 'number_bubbles',
69
-        $default_step = '',
70
-        $form_step_url_key = '',
71
-        CollectionInterface $collection = null,
72
-        RequestInterface $request = null
73
-    ) {
74
-        $this->setDisplayStrategy($display_strategy_name);
75
-        $this->setDefaultStep($default_step);
76
-        $this->setFormStepUrlKey($form_step_url_key);
77
-        if (! $collection instanceof CollectionInterface) {
78
-            $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
79
-        }
80
-        $this->collection = $collection;
81
-        if (! $request instanceof RequestInterface) {
82
-            /** @var RequestInterface $request */
83
-            $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
84
-        }
85
-        $this->request = $request;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string $display_strategy_name
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidClassException
93
-     */
94
-    protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
95
-    {
96
-        if (! is_string($display_strategy_name)) {
97
-            throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
98
-        }
99
-        // build up FQCN from incoming display strategy folder name
100
-        $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
101
-        $display_strategy_class .= $display_strategy_name . '\\';
102
-        $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
103
-        $display_strategy_class .= 'ProgressStepsDisplay';
104
-        $display_strategy_class = apply_filters(
105
-            'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
106
-            $display_strategy_class
107
-        );
108
-        if (! class_exists($display_strategy_class)) {
109
-            throw new InvalidClassException($display_strategy_class);
110
-        }
111
-        $display_strategy = new $display_strategy_class();
112
-        if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
113
-            throw new InvalidClassException(
114
-                $display_strategy_class,
115
-                sprintf(
116
-                    esc_html__('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'),
117
-                    $display_strategy_class,
118
-                    '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface'
119
-                )
120
-            );
121
-        }
122
-        $this->display_strategy = $display_strategy;
123
-    }
124
-
125
-
126
-    /**
127
-     * @param string $default_step
128
-     * @throws InvalidDataTypeException
129
-     */
130
-    public function setDefaultStep($default_step)
131
-    {
132
-        if (! is_string($default_step)) {
133
-            throw new InvalidDataTypeException('$default_step', $default_step, 'string');
134
-        }
135
-        $this->default_step = $default_step;
136
-    }
137
-
138
-
139
-    /**
140
-     * @param string $form_step_url_key
141
-     * @throws InvalidDataTypeException
142
-     */
143
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
144
-    {
145
-        if (! is_string($form_step_url_key)) {
146
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
147
-        }
148
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
149
-    }
150
-
151
-
152
-    /**
153
-     * @param string $step
154
-     * @throws InvalidIdentifierException
155
-     */
156
-    public function setCurrentStep($step = '')
157
-    {
158
-        // use incoming value if it's set, otherwise use request param if it's set, otherwise use default
159
-        $step = ! empty($step)
160
-            ? $step
161
-            : $this->request->getRequestParam($this->form_step_url_key, $this->default_step);
162
-        // grab the step previously known as current, in case we need to revert
163
-        $current_current_step = $this->collection->current();
164
-        // verify that requested step exists
165
-        if (! $this->collection->has($step)) {
166
-            throw new InvalidIdentifierException($step, $this->default_step);
167
-        }
168
-        if ($this->collection->setCurrent($step)) {
169
-            // if the old boss is the same as the new boss, then nothing changes
170
-            if ($this->collection->current() !== $current_current_step) {
171
-                $current_current_step->setIsCurrent(false);
172
-            }
173
-            $this->collection->current()->setIsCurrent();
174
-        } else {
175
-            $this->collection->setCurrent($current_current_step->id());
176
-            $current_current_step->setIsCurrent(true);
177
-        }
178
-    }
179
-
180
-
181
-    /**
182
-     * setPreviousStepsCompleted
183
-     */
184
-    public function setPreviousStepsCompleted()
185
-    {
186
-        $current_current_step = $this->collection->current();
187
-        $this->collection->rewind();
188
-        while ($this->collection->valid()) {
189
-            if ($this->collection->current() === $current_current_step) {
190
-                break;
191
-            }
192
-            $this->setCurrentStepCompleted();
193
-            $this->collection->next();
194
-        }
195
-        $this->collection->setCurrentUsingObject($current_current_step);
196
-        return false;
197
-    }
198
-
199
-
200
-    /**
201
-     * @return ProgressStepInterface
202
-     */
203
-    public function currentStep()
204
-    {
205
-        return $this->collection->current();
206
-    }
207
-
208
-
209
-    /**
210
-     * @return ProgressStepInterface
211
-     */
212
-    public function nextStep()
213
-    {
214
-        return $this->collection->next();
215
-    }
216
-
217
-
218
-    /**
219
-     * @return void
220
-     */
221
-    public function enqueueStylesAndScripts()
222
-    {
223
-        $this->display_strategy->enqueueStylesAndScripts();
224
-    }
225
-
226
-
227
-    /**
228
-     * echos out HTML
229
-     *
230
-     * @return string
231
-     */
232
-    public function displaySteps()
233
-    {
234
-        return EEH_Template::display_template(
235
-            $this->display_strategy->getTemplate(),
236
-            array('progress_steps' => $this->collection),
237
-            true
238
-        );
239
-    }
240
-
241
-
242
-    /**
243
-     * @param bool $completed
244
-     * @return ProgressStepInterface
245
-     */
246
-    public function setCurrentStepCompleted($completed = true)
247
-    {
248
-        return $this->collection->current()->setIsCompleted($completed);
249
-    }
29
+	/**
30
+	 * @var ProgressStepInterface[]
31
+	 */
32
+	private $collection;
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	private $default_step;
38
+
39
+	/**
40
+	 * the key used for the URL param that denotes the current form step
41
+	 * defaults to 'ee-form-step'
42
+	 *
43
+	 * @var string
44
+	 */
45
+	private $form_step_url_key = '';
46
+
47
+	/**
48
+	 * @var ProgressStepsDisplayInterface
49
+	 */
50
+	private $display_strategy;
51
+
52
+	/**
53
+	 * @var RequestInterface
54
+	 */
55
+	private $request;
56
+
57
+
58
+	/**
59
+	 * ProgressStepManager constructor
60
+	 *
61
+	 * @param string              $display_strategy_name
62
+	 * @param string              $default_step
63
+	 * @param string              $form_step_url_key
64
+	 * @param CollectionInterface $collection
65
+	 * @param RequestInterface    $request
66
+	 */
67
+	public function __construct(
68
+		$display_strategy_name = 'number_bubbles',
69
+		$default_step = '',
70
+		$form_step_url_key = '',
71
+		CollectionInterface $collection = null,
72
+		RequestInterface $request = null
73
+	) {
74
+		$this->setDisplayStrategy($display_strategy_name);
75
+		$this->setDefaultStep($default_step);
76
+		$this->setFormStepUrlKey($form_step_url_key);
77
+		if (! $collection instanceof CollectionInterface) {
78
+			$collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
79
+		}
80
+		$this->collection = $collection;
81
+		if (! $request instanceof RequestInterface) {
82
+			/** @var RequestInterface $request */
83
+			$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
84
+		}
85
+		$this->request = $request;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string $display_strategy_name
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidClassException
93
+	 */
94
+	protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
95
+	{
96
+		if (! is_string($display_strategy_name)) {
97
+			throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
98
+		}
99
+		// build up FQCN from incoming display strategy folder name
100
+		$display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
101
+		$display_strategy_class .= $display_strategy_name . '\\';
102
+		$display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
103
+		$display_strategy_class .= 'ProgressStepsDisplay';
104
+		$display_strategy_class = apply_filters(
105
+			'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
106
+			$display_strategy_class
107
+		);
108
+		if (! class_exists($display_strategy_class)) {
109
+			throw new InvalidClassException($display_strategy_class);
110
+		}
111
+		$display_strategy = new $display_strategy_class();
112
+		if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
113
+			throw new InvalidClassException(
114
+				$display_strategy_class,
115
+				sprintf(
116
+					esc_html__('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'),
117
+					$display_strategy_class,
118
+					'\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface'
119
+				)
120
+			);
121
+		}
122
+		$this->display_strategy = $display_strategy;
123
+	}
124
+
125
+
126
+	/**
127
+	 * @param string $default_step
128
+	 * @throws InvalidDataTypeException
129
+	 */
130
+	public function setDefaultStep($default_step)
131
+	{
132
+		if (! is_string($default_step)) {
133
+			throw new InvalidDataTypeException('$default_step', $default_step, 'string');
134
+		}
135
+		$this->default_step = $default_step;
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param string $form_step_url_key
141
+	 * @throws InvalidDataTypeException
142
+	 */
143
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
144
+	{
145
+		if (! is_string($form_step_url_key)) {
146
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
147
+		}
148
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param string $step
154
+	 * @throws InvalidIdentifierException
155
+	 */
156
+	public function setCurrentStep($step = '')
157
+	{
158
+		// use incoming value if it's set, otherwise use request param if it's set, otherwise use default
159
+		$step = ! empty($step)
160
+			? $step
161
+			: $this->request->getRequestParam($this->form_step_url_key, $this->default_step);
162
+		// grab the step previously known as current, in case we need to revert
163
+		$current_current_step = $this->collection->current();
164
+		// verify that requested step exists
165
+		if (! $this->collection->has($step)) {
166
+			throw new InvalidIdentifierException($step, $this->default_step);
167
+		}
168
+		if ($this->collection->setCurrent($step)) {
169
+			// if the old boss is the same as the new boss, then nothing changes
170
+			if ($this->collection->current() !== $current_current_step) {
171
+				$current_current_step->setIsCurrent(false);
172
+			}
173
+			$this->collection->current()->setIsCurrent();
174
+		} else {
175
+			$this->collection->setCurrent($current_current_step->id());
176
+			$current_current_step->setIsCurrent(true);
177
+		}
178
+	}
179
+
180
+
181
+	/**
182
+	 * setPreviousStepsCompleted
183
+	 */
184
+	public function setPreviousStepsCompleted()
185
+	{
186
+		$current_current_step = $this->collection->current();
187
+		$this->collection->rewind();
188
+		while ($this->collection->valid()) {
189
+			if ($this->collection->current() === $current_current_step) {
190
+				break;
191
+			}
192
+			$this->setCurrentStepCompleted();
193
+			$this->collection->next();
194
+		}
195
+		$this->collection->setCurrentUsingObject($current_current_step);
196
+		return false;
197
+	}
198
+
199
+
200
+	/**
201
+	 * @return ProgressStepInterface
202
+	 */
203
+	public function currentStep()
204
+	{
205
+		return $this->collection->current();
206
+	}
207
+
208
+
209
+	/**
210
+	 * @return ProgressStepInterface
211
+	 */
212
+	public function nextStep()
213
+	{
214
+		return $this->collection->next();
215
+	}
216
+
217
+
218
+	/**
219
+	 * @return void
220
+	 */
221
+	public function enqueueStylesAndScripts()
222
+	{
223
+		$this->display_strategy->enqueueStylesAndScripts();
224
+	}
225
+
226
+
227
+	/**
228
+	 * echos out HTML
229
+	 *
230
+	 * @return string
231
+	 */
232
+	public function displaySteps()
233
+	{
234
+		return EEH_Template::display_template(
235
+			$this->display_strategy->getTemplate(),
236
+			array('progress_steps' => $this->collection),
237
+			true
238
+		);
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param bool $completed
244
+	 * @return ProgressStepInterface
245
+	 */
246
+	public function setCurrentStepCompleted($completed = true)
247
+	{
248
+		return $this->collection->current()->setIsCompleted($completed);
249
+	}
250 250
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function setBaseUrl($base_url)
142 142
     {
143
-        if (! is_string($base_url)) {
143
+        if ( ! is_string($base_url)) {
144 144
             throw new InvalidDataTypeException('$base_url', $base_url, 'string');
145 145
         }
146 146
         if (empty($base_url)) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
173 173
     {
174
-        if (! is_string($form_step_url_key)) {
174
+        if ( ! is_string($form_step_url_key)) {
175 175
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
176 176
         }
177 177
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function setDefaultFormStep($default_form_step)
195 195
     {
196
-        if (! is_string($default_form_step)) {
196
+        if ( ! is_string($default_form_step)) {
197 197
             throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
198 198
         }
199 199
         $this->default_form_step = $default_form_step;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     protected function setCurrentStepFromRequest()
209 209
     {
210 210
         $current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
211
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
211
+        if ( ! $this->form_steps->setCurrent($current_step_slug)) {
212 212
             throw new InvalidIdentifierException(
213 213
                 $current_step_slug,
214 214
                 $this->defaultFormStep(),
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function getCurrentStep()
229 229
     {
230
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
230
+        if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
231 231
             throw new InvalidFormHandlerException($this->form_steps->current());
232 232
         }
233 233
         return $this->form_steps->current();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function formAction()
242 242
     {
243
-        if (! is_string($this->form_action) || empty($this->form_action)) {
243
+        if ( ! is_string($this->form_action) || empty($this->form_action)) {
244 244
             $this->form_action = $this->baseUrl();
245 245
         }
246 246
         return $this->form_action;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      */
254 254
     public function setFormAction($form_action)
255 255
     {
256
-        if (! is_string($form_action)) {
256
+        if ( ! is_string($form_action)) {
257 257
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
258 258
         }
259 259
         $this->form_action = $form_action;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function addFormActionArgs($form_action_args = array())
269 269
     {
270
-        if (! is_array($form_action_args)) {
270
+        if ( ! is_array($form_action_args)) {
271 271
             throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
272 272
         }
273 273
         $form_action_args = ! empty($form_action_args)
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     protected function getProgressStepsCollection()
333 333
     {
334 334
         static $collection = null;
335
-        if (! $collection instanceof ProgressStepCollection) {
335
+        if ( ! $collection instanceof ProgressStepCollection) {
336 336
             $collection = new ProgressStepCollection();
337 337
         }
338 338
         return $collection;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         /** @var SequentialStepForm $form_step */
355 355
         foreach ($this->form_steps as $form_step) {
356 356
             // is this step active ?
357
-            if (! $form_step->initialize()) {
357
+            if ( ! $form_step->initialize()) {
358 358
                 continue;
359 359
             }
360 360
             $progress_steps_collection->add(
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     {
424 424
         $form_step = $this->buildCurrentStepForm();
425 425
         // no displayable content ? then skip straight to processing
426
-        if (! $form_step->displayable()) {
426
+        if ( ! $form_step->displayable()) {
427 427
             $this->addFormActionArgs();
428 428
             $form_step->setFormAction($this->formAction());
429 429
             wp_safe_redirect($form_step->formAction());
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     public function displayProgressSteps($return_as_string = true)
500 500
     {
501 501
         $form_step = $this->getCurrentStep();
502
-        if (! $form_step->displayable()) {
502
+        if ( ! $form_step->displayable()) {
503 503
             return '';
504 504
         }
505 505
         $progress_steps = apply_filters(
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -30,583 +30,583 @@
 block discarded – undo
30 30
  */
31 31
 abstract class SequentialStepFormManager
32 32
 {
33
-    /**
34
-     * a simplified URL with no form related parameters
35
-     * that will be used to build the form's redirect URLs
36
-     *
37
-     * @var string $base_url
38
-     */
39
-    private $base_url = '';
40
-
41
-    /**
42
-     * the key used for the URL param that denotes the current form step
43
-     * defaults to 'ee-form-step'
44
-     *
45
-     * @var string $form_step_url_key
46
-     */
47
-    private $form_step_url_key = '';
48
-
49
-    /**
50
-     * @var string $default_form_step
51
-     */
52
-    private $default_form_step = '';
53
-
54
-    /**
55
-     * @var string $form_action
56
-     */
57
-    private $form_action;
58
-
59
-    /**
60
-     * value of one of the string constant above
61
-     *
62
-     * @var string $form_config
63
-     */
64
-    private $form_config;
65
-
66
-    /**
67
-     * @var string $progress_step_style
68
-     */
69
-    private $progress_step_style = '';
70
-
71
-    /**
72
-     * @var RequestInterface $request
73
-     */
74
-    private $request;
75
-
76
-    /**
77
-     * @var Collection $form_steps
78
-     */
79
-    protected $form_steps;
80
-
81
-    /**
82
-     * @var ProgressStepManager $progress_step_manager
83
-     */
84
-    protected $progress_step_manager;
85
-
86
-
87
-    /**
88
-     * @return Collection|null
89
-     */
90
-    abstract protected function getFormStepsCollection();
91
-
92
-    // phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
93
-    /**
94
-     * StepsManager constructor
95
-     *
96
-     * @param string                           $base_url
97
-     * @param string                           $default_form_step
98
-     * @param string                           $form_action
99
-     * @param string                           $form_config
100
-     * @param EE_Request|RequestInterface|null $request
101
-     * @param string                           $progress_step_style
102
-     * @throws InvalidDataTypeException
103
-     * @throws InvalidArgumentException
104
-     */
105
-    public function __construct(
106
-        $base_url,
107
-        $default_form_step,
108
-        $form_action = '',
109
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
110
-        $progress_step_style = 'number_bubbles',
111
-        $request = null
112
-    ) {
113
-        $this->setBaseUrl($base_url);
114
-        $this->setDefaultFormStep($default_form_step);
115
-        $this->setFormAction($form_action);
116
-        $this->setFormConfig($form_config);
117
-        $this->setProgressStepStyle($progress_step_style);
118
-        $this->request = $request instanceof RequestInterface
119
-            ? $request
120
-            : LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
121
-    }
122
-
123
-
124
-    /**
125
-     * @return string
126
-     * @throws InvalidFormHandlerException
127
-     */
128
-    public function baseUrl()
129
-    {
130
-        if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
131
-            add_query_arg(
132
-                array($this->form_step_url_key => $this->getCurrentStep()->slug()),
133
-                $this->base_url
134
-            );
135
-        }
136
-        return $this->base_url;
137
-    }
138
-
139
-
140
-    /**
141
-     * @param string $base_url
142
-     * @throws InvalidDataTypeException
143
-     * @throws InvalidArgumentException
144
-     */
145
-    protected function setBaseUrl($base_url)
146
-    {
147
-        if (! is_string($base_url)) {
148
-            throw new InvalidDataTypeException('$base_url', $base_url, 'string');
149
-        }
150
-        if (empty($base_url)) {
151
-            throw new InvalidArgumentException(
152
-                esc_html__('The base URL can not be an empty string.', 'event_espresso')
153
-            );
154
-        }
155
-        $this->base_url = $base_url;
156
-    }
157
-
158
-
159
-    /**
160
-     * @return string
161
-     * @throws InvalidDataTypeException
162
-     */
163
-    public function formStepUrlKey()
164
-    {
165
-        if (empty($this->form_step_url_key)) {
166
-            $this->setFormStepUrlKey();
167
-        }
168
-        return $this->form_step_url_key;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param string $form_step_url_key
174
-     * @throws InvalidDataTypeException
175
-     */
176
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
177
-    {
178
-        if (! is_string($form_step_url_key)) {
179
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
180
-        }
181
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
182
-    }
183
-
184
-
185
-    /**
186
-     * @return string
187
-     */
188
-    public function defaultFormStep()
189
-    {
190
-        return $this->default_form_step;
191
-    }
192
-
193
-
194
-    /**
195
-     * @param $default_form_step
196
-     * @throws InvalidDataTypeException
197
-     */
198
-    protected function setDefaultFormStep($default_form_step)
199
-    {
200
-        if (! is_string($default_form_step)) {
201
-            throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
202
-        }
203
-        $this->default_form_step = $default_form_step;
204
-    }
205
-
206
-
207
-    /**
208
-     * @return void
209
-     * @throws InvalidIdentifierException
210
-     * @throws InvalidDataTypeException
211
-     */
212
-    protected function setCurrentStepFromRequest()
213
-    {
214
-        $current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
215
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
216
-            throw new InvalidIdentifierException(
217
-                $current_step_slug,
218
-                $this->defaultFormStep(),
219
-                sprintf(
220
-                    esc_html__('The "%1$s" form step could not be set.', 'event_espresso'),
221
-                    $current_step_slug
222
-                )
223
-            );
224
-        }
225
-    }
226
-
227
-
228
-    /**
229
-     * @return SequentialStepFormInterface|object
230
-     * @throws InvalidFormHandlerException
231
-     */
232
-    public function getCurrentStep()
233
-    {
234
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
-            throw new InvalidFormHandlerException($this->form_steps->current());
236
-        }
237
-        return $this->form_steps->current();
238
-    }
239
-
240
-
241
-    /**
242
-     * @return string
243
-     * @throws InvalidFormHandlerException
244
-     */
245
-    public function formAction()
246
-    {
247
-        if (! is_string($this->form_action) || empty($this->form_action)) {
248
-            $this->form_action = $this->baseUrl();
249
-        }
250
-        return $this->form_action;
251
-    }
252
-
253
-
254
-    /**
255
-     * @param string $form_action
256
-     * @throws InvalidDataTypeException
257
-     */
258
-    public function setFormAction($form_action)
259
-    {
260
-        if (! is_string($form_action)) {
261
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
-        }
263
-        $this->form_action = $form_action;
264
-    }
265
-
266
-
267
-    /**
268
-     * @param array $form_action_args
269
-     * @throws InvalidDataTypeException
270
-     * @throws InvalidFormHandlerException
271
-     */
272
-    public function addFormActionArgs($form_action_args = array())
273
-    {
274
-        if (! is_array($form_action_args)) {
275
-            throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
-        }
277
-        $form_action_args = ! empty($form_action_args)
278
-            ? $form_action_args
279
-            : array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
-        $this->getCurrentStep()->setFormAction(
281
-            add_query_arg($form_action_args, $this->formAction())
282
-        );
283
-        $this->form_action = $this->getCurrentStep()->formAction();
284
-    }
285
-
286
-
287
-    /**
288
-     * @return string
289
-     */
290
-    public function formConfig()
291
-    {
292
-        return $this->form_config;
293
-    }
294
-
295
-
296
-    /**
297
-     * @param string $form_config
298
-     */
299
-    public function setFormConfig($form_config)
300
-    {
301
-        $this->form_config = $form_config;
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function progressStepStyle()
309
-    {
310
-        return $this->progress_step_style;
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $progress_step_style
316
-     */
317
-    public function setProgressStepStyle($progress_step_style)
318
-    {
319
-        $this->progress_step_style = $progress_step_style;
320
-    }
321
-
322
-
323
-    /**
324
-     * @return RequestInterface
325
-     */
326
-    public function request()
327
-    {
328
-        return $this->request;
329
-    }
330
-
331
-
332
-    /**
333
-     * @return Collection|null
334
-     * @throws InvalidInterfaceException
335
-     */
336
-    protected function getProgressStepsCollection()
337
-    {
338
-        static $collection = null;
339
-        if (! $collection instanceof ProgressStepCollection) {
340
-            $collection = new ProgressStepCollection();
341
-        }
342
-        return $collection;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param Collection $progress_steps_collection
348
-     * @return ProgressStepManager
349
-     * @throws InvalidInterfaceException
350
-     * @throws InvalidClassException
351
-     * @throws InvalidDataTypeException
352
-     * @throws InvalidEntityException
353
-     * @throws InvalidFormHandlerException
354
-     */
355
-    protected function generateProgressSteps(Collection $progress_steps_collection)
356
-    {
357
-        $current_step = $this->getCurrentStep();
358
-        /** @var SequentialStepForm $form_step */
359
-        foreach ($this->form_steps as $form_step) {
360
-            // is this step active ?
361
-            if (! $form_step->initialize()) {
362
-                continue;
363
-            }
364
-            $progress_steps_collection->add(
365
-                new ProgressStep(
366
-                    $form_step->order(),
367
-                    $form_step->slug(),
368
-                    $form_step->slug(),
369
-                    $form_step->formName()
370
-                ),
371
-                $form_step->slug()
372
-            );
373
-        }
374
-        // set collection pointer back to current step
375
-        $this->form_steps->setCurrentUsingObject($current_step);
376
-        return new ProgressStepManager(
377
-            $this->progressStepStyle(),
378
-            $this->defaultFormStep(),
379
-            $this->formStepUrlKey(),
380
-            $progress_steps_collection
381
-        );
382
-    }
383
-
384
-
385
-    /**
386
-     * @throws InvalidClassException
387
-     * @throws InvalidDataTypeException
388
-     * @throws InvalidEntityException
389
-     * @throws InvalidIdentifierException
390
-     * @throws InvalidInterfaceException
391
-     * @throws InvalidArgumentException
392
-     * @throws InvalidFormHandlerException
393
-     */
394
-    public function buildForm()
395
-    {
396
-        $this->buildCurrentStepFormForDisplay();
397
-    }
398
-
399
-
400
-    /**
401
-     * @param array $form_data
402
-     * @throws InvalidArgumentException
403
-     * @throws InvalidClassException
404
-     * @throws InvalidDataTypeException
405
-     * @throws InvalidEntityException
406
-     * @throws InvalidFormHandlerException
407
-     * @throws InvalidIdentifierException
408
-     * @throws InvalidInterfaceException
409
-     */
410
-    public function processForm($form_data = array())
411
-    {
412
-        $this->buildCurrentStepFormForProcessing();
413
-        $this->processCurrentStepForm($form_data);
414
-    }
415
-
416
-
417
-    /**
418
-     * @throws InvalidClassException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidEntityException
421
-     * @throws InvalidInterfaceException
422
-     * @throws InvalidIdentifierException
423
-     * @throws InvalidArgumentException
424
-     * @throws InvalidFormHandlerException
425
-     */
426
-    public function buildCurrentStepFormForDisplay()
427
-    {
428
-        $form_step = $this->buildCurrentStepForm();
429
-        // no displayable content ? then skip straight to processing
430
-        if (! $form_step->displayable()) {
431
-            $this->addFormActionArgs();
432
-            $form_step->setFormAction($this->formAction());
433
-            wp_safe_redirect($form_step->formAction());
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     * @throws InvalidClassException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidEntityException
442
-     * @throws InvalidInterfaceException
443
-     * @throws InvalidIdentifierException
444
-     * @throws InvalidArgumentException
445
-     * @throws InvalidFormHandlerException
446
-     */
447
-    public function buildCurrentStepFormForProcessing()
448
-    {
449
-        $this->buildCurrentStepForm(false);
450
-    }
451
-
452
-
453
-    /**
454
-     * @param bool $for_display
455
-     * @return SequentialStepFormInterface
456
-     * @throws InvalidArgumentException
457
-     * @throws InvalidClassException
458
-     * @throws InvalidDataTypeException
459
-     * @throws InvalidEntityException
460
-     * @throws InvalidFormHandlerException
461
-     * @throws InvalidIdentifierException
462
-     * @throws InvalidInterfaceException
463
-     */
464
-    private function buildCurrentStepForm($for_display = true)
465
-    {
466
-        $this->form_steps = $this->getFormStepsCollection();
467
-        $this->setCurrentStepFromRequest();
468
-        $form_step = $this->getCurrentStep();
469
-        if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
-            $form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
-        }
472
-        if ($for_display && $form_step->displayable()) {
473
-            $this->progress_step_manager = $this->generateProgressSteps(
474
-                $this->getProgressStepsCollection()
475
-            );
476
-            $this->progress_step_manager->setCurrentStep(
477
-                $form_step->slug()
478
-            );
479
-            // mark all previous progress steps as completed
480
-            $this->progress_step_manager->setPreviousStepsCompleted();
481
-            $this->progress_step_manager->enqueueStylesAndScripts();
482
-            $this->addFormActionArgs();
483
-            $form_step->setFormAction($this->formAction());
484
-        } else {
485
-            $form_step->setRedirectUrl($this->baseUrl());
486
-            $form_step->addRedirectArgs(
487
-                array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
-            );
489
-        }
490
-        $form_step->generate();
491
-        if ($for_display) {
492
-            $form_step->enqueueStylesAndScripts();
493
-        }
494
-        return $form_step;
495
-    }
496
-
497
-
498
-    /**
499
-     * @param bool $return_as_string
500
-     * @return string
501
-     * @throws InvalidFormHandlerException
502
-     */
503
-    public function displayProgressSteps($return_as_string = true)
504
-    {
505
-        $form_step = $this->getCurrentStep();
506
-        if (! $form_step->displayable()) {
507
-            return '';
508
-        }
509
-        $progress_steps = apply_filters(
510
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
-            ''
512
-        );
513
-        $progress_steps .= $this->progress_step_manager->displaySteps();
514
-        $progress_steps .= apply_filters(
515
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
-            ''
517
-        );
518
-        if ($return_as_string) {
519
-            return $progress_steps;
520
-        }
521
-        echo wp_kses($progress_steps, AllowedTags::getWithFormTags());
522
-        return '';
523
-    }
524
-
525
-
526
-    /**
527
-     * @param bool $return_as_string
528
-     * @return string
529
-     * @throws InvalidFormHandlerException
530
-     */
531
-    public function displayCurrentStepForm($return_as_string = true)
532
-    {
533
-        if ($return_as_string) {
534
-            return $this->getCurrentStep()->display();
535
-        }
536
-        echo wp_kses($this->getCurrentStep()->display(), AllowedTags::getWithFormTags());
537
-        return '';
538
-    }
539
-
540
-
541
-    /**
542
-     * @param array $form_data
543
-     * @return void
544
-     * @throws InvalidArgumentException
545
-     * @throws InvalidDataTypeException
546
-     * @throws InvalidFormHandlerException
547
-     */
548
-    public function processCurrentStepForm($form_data = array())
549
-    {
550
-        // grab instance of current step because after calling next() below,
551
-        // any calls to getCurrentStep() will return the "next" step because we advanced
552
-        $current_step = $this->getCurrentStep();
553
-        try {
554
-            // form processing should either throw exceptions or return true
555
-            $current_step->process($form_data);
556
-        } catch (Exception $e) {
557
-            // something went wrong, convert the Exception to an EE_Error
558
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
559
-            // prevent redirect to next step or other if exception was thrown
560
-            if (
561
-                $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
562
-                || $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
563
-            ) {
564
-                $current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
565
-            }
566
-        }
567
-        // save notices to a transient so that when we redirect back
568
-        // to the display portion for this step
569
-        // those notices can be displayed
570
-        EE_Error::get_notices(false, true);
571
-        $this->redirectForm($current_step);
572
-    }
573
-
574
-
575
-    /**
576
-     * handles where to go to next
577
-     *
578
-     * @param SequentialStepFormInterface $current_step
579
-     * @throws InvalidArgumentException
580
-     * @throws InvalidDataTypeException
581
-     * @throws InvalidFormHandlerException
582
-     */
583
-    public function redirectForm(SequentialStepFormInterface $current_step)
584
-    {
585
-        $redirect_step = $current_step;
586
-        switch ($current_step->redirectTo()) {
587
-            case SequentialStepForm::REDIRECT_TO_OTHER:
588
-                // going somewhere else, so just check out now
589
-                wp_safe_redirect($redirect_step->redirectUrl());
590
-                exit();
591
-            case SequentialStepForm::REDIRECT_TO_PREV_STEP:
592
-                $redirect_step = $this->form_steps->previous();
593
-                break;
594
-            case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
595
-                $this->form_steps->next();
596
-                if ($this->form_steps->valid()) {
597
-                    $redirect_step = $this->form_steps->current();
598
-                }
599
-                break;
600
-            case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
601
-            default:
602
-                // $redirect_step is already set
603
-        }
604
-        $current_step->setRedirectUrl($this->baseUrl());
605
-        $current_step->addRedirectArgs(
606
-            // use the slug for whatever step we are redirecting too
607
-            array($this->formStepUrlKey() => $redirect_step->slug())
608
-        );
609
-        wp_safe_redirect($current_step->redirectUrl());
610
-        exit();
611
-    }
33
+	/**
34
+	 * a simplified URL with no form related parameters
35
+	 * that will be used to build the form's redirect URLs
36
+	 *
37
+	 * @var string $base_url
38
+	 */
39
+	private $base_url = '';
40
+
41
+	/**
42
+	 * the key used for the URL param that denotes the current form step
43
+	 * defaults to 'ee-form-step'
44
+	 *
45
+	 * @var string $form_step_url_key
46
+	 */
47
+	private $form_step_url_key = '';
48
+
49
+	/**
50
+	 * @var string $default_form_step
51
+	 */
52
+	private $default_form_step = '';
53
+
54
+	/**
55
+	 * @var string $form_action
56
+	 */
57
+	private $form_action;
58
+
59
+	/**
60
+	 * value of one of the string constant above
61
+	 *
62
+	 * @var string $form_config
63
+	 */
64
+	private $form_config;
65
+
66
+	/**
67
+	 * @var string $progress_step_style
68
+	 */
69
+	private $progress_step_style = '';
70
+
71
+	/**
72
+	 * @var RequestInterface $request
73
+	 */
74
+	private $request;
75
+
76
+	/**
77
+	 * @var Collection $form_steps
78
+	 */
79
+	protected $form_steps;
80
+
81
+	/**
82
+	 * @var ProgressStepManager $progress_step_manager
83
+	 */
84
+	protected $progress_step_manager;
85
+
86
+
87
+	/**
88
+	 * @return Collection|null
89
+	 */
90
+	abstract protected function getFormStepsCollection();
91
+
92
+	// phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
93
+	/**
94
+	 * StepsManager constructor
95
+	 *
96
+	 * @param string                           $base_url
97
+	 * @param string                           $default_form_step
98
+	 * @param string                           $form_action
99
+	 * @param string                           $form_config
100
+	 * @param EE_Request|RequestInterface|null $request
101
+	 * @param string                           $progress_step_style
102
+	 * @throws InvalidDataTypeException
103
+	 * @throws InvalidArgumentException
104
+	 */
105
+	public function __construct(
106
+		$base_url,
107
+		$default_form_step,
108
+		$form_action = '',
109
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
110
+		$progress_step_style = 'number_bubbles',
111
+		$request = null
112
+	) {
113
+		$this->setBaseUrl($base_url);
114
+		$this->setDefaultFormStep($default_form_step);
115
+		$this->setFormAction($form_action);
116
+		$this->setFormConfig($form_config);
117
+		$this->setProgressStepStyle($progress_step_style);
118
+		$this->request = $request instanceof RequestInterface
119
+			? $request
120
+			: LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return string
126
+	 * @throws InvalidFormHandlerException
127
+	 */
128
+	public function baseUrl()
129
+	{
130
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
131
+			add_query_arg(
132
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
133
+				$this->base_url
134
+			);
135
+		}
136
+		return $this->base_url;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param string $base_url
142
+	 * @throws InvalidDataTypeException
143
+	 * @throws InvalidArgumentException
144
+	 */
145
+	protected function setBaseUrl($base_url)
146
+	{
147
+		if (! is_string($base_url)) {
148
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
149
+		}
150
+		if (empty($base_url)) {
151
+			throw new InvalidArgumentException(
152
+				esc_html__('The base URL can not be an empty string.', 'event_espresso')
153
+			);
154
+		}
155
+		$this->base_url = $base_url;
156
+	}
157
+
158
+
159
+	/**
160
+	 * @return string
161
+	 * @throws InvalidDataTypeException
162
+	 */
163
+	public function formStepUrlKey()
164
+	{
165
+		if (empty($this->form_step_url_key)) {
166
+			$this->setFormStepUrlKey();
167
+		}
168
+		return $this->form_step_url_key;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param string $form_step_url_key
174
+	 * @throws InvalidDataTypeException
175
+	 */
176
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
177
+	{
178
+		if (! is_string($form_step_url_key)) {
179
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
180
+		}
181
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return string
187
+	 */
188
+	public function defaultFormStep()
189
+	{
190
+		return $this->default_form_step;
191
+	}
192
+
193
+
194
+	/**
195
+	 * @param $default_form_step
196
+	 * @throws InvalidDataTypeException
197
+	 */
198
+	protected function setDefaultFormStep($default_form_step)
199
+	{
200
+		if (! is_string($default_form_step)) {
201
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
202
+		}
203
+		$this->default_form_step = $default_form_step;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @return void
209
+	 * @throws InvalidIdentifierException
210
+	 * @throws InvalidDataTypeException
211
+	 */
212
+	protected function setCurrentStepFromRequest()
213
+	{
214
+		$current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
215
+		if (! $this->form_steps->setCurrent($current_step_slug)) {
216
+			throw new InvalidIdentifierException(
217
+				$current_step_slug,
218
+				$this->defaultFormStep(),
219
+				sprintf(
220
+					esc_html__('The "%1$s" form step could not be set.', 'event_espresso'),
221
+					$current_step_slug
222
+				)
223
+			);
224
+		}
225
+	}
226
+
227
+
228
+	/**
229
+	 * @return SequentialStepFormInterface|object
230
+	 * @throws InvalidFormHandlerException
231
+	 */
232
+	public function getCurrentStep()
233
+	{
234
+		if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
+			throw new InvalidFormHandlerException($this->form_steps->current());
236
+		}
237
+		return $this->form_steps->current();
238
+	}
239
+
240
+
241
+	/**
242
+	 * @return string
243
+	 * @throws InvalidFormHandlerException
244
+	 */
245
+	public function formAction()
246
+	{
247
+		if (! is_string($this->form_action) || empty($this->form_action)) {
248
+			$this->form_action = $this->baseUrl();
249
+		}
250
+		return $this->form_action;
251
+	}
252
+
253
+
254
+	/**
255
+	 * @param string $form_action
256
+	 * @throws InvalidDataTypeException
257
+	 */
258
+	public function setFormAction($form_action)
259
+	{
260
+		if (! is_string($form_action)) {
261
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
+		}
263
+		$this->form_action = $form_action;
264
+	}
265
+
266
+
267
+	/**
268
+	 * @param array $form_action_args
269
+	 * @throws InvalidDataTypeException
270
+	 * @throws InvalidFormHandlerException
271
+	 */
272
+	public function addFormActionArgs($form_action_args = array())
273
+	{
274
+		if (! is_array($form_action_args)) {
275
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
+		}
277
+		$form_action_args = ! empty($form_action_args)
278
+			? $form_action_args
279
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
+		$this->getCurrentStep()->setFormAction(
281
+			add_query_arg($form_action_args, $this->formAction())
282
+		);
283
+		$this->form_action = $this->getCurrentStep()->formAction();
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return string
289
+	 */
290
+	public function formConfig()
291
+	{
292
+		return $this->form_config;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param string $form_config
298
+	 */
299
+	public function setFormConfig($form_config)
300
+	{
301
+		$this->form_config = $form_config;
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function progressStepStyle()
309
+	{
310
+		return $this->progress_step_style;
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $progress_step_style
316
+	 */
317
+	public function setProgressStepStyle($progress_step_style)
318
+	{
319
+		$this->progress_step_style = $progress_step_style;
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return RequestInterface
325
+	 */
326
+	public function request()
327
+	{
328
+		return $this->request;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @return Collection|null
334
+	 * @throws InvalidInterfaceException
335
+	 */
336
+	protected function getProgressStepsCollection()
337
+	{
338
+		static $collection = null;
339
+		if (! $collection instanceof ProgressStepCollection) {
340
+			$collection = new ProgressStepCollection();
341
+		}
342
+		return $collection;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param Collection $progress_steps_collection
348
+	 * @return ProgressStepManager
349
+	 * @throws InvalidInterfaceException
350
+	 * @throws InvalidClassException
351
+	 * @throws InvalidDataTypeException
352
+	 * @throws InvalidEntityException
353
+	 * @throws InvalidFormHandlerException
354
+	 */
355
+	protected function generateProgressSteps(Collection $progress_steps_collection)
356
+	{
357
+		$current_step = $this->getCurrentStep();
358
+		/** @var SequentialStepForm $form_step */
359
+		foreach ($this->form_steps as $form_step) {
360
+			// is this step active ?
361
+			if (! $form_step->initialize()) {
362
+				continue;
363
+			}
364
+			$progress_steps_collection->add(
365
+				new ProgressStep(
366
+					$form_step->order(),
367
+					$form_step->slug(),
368
+					$form_step->slug(),
369
+					$form_step->formName()
370
+				),
371
+				$form_step->slug()
372
+			);
373
+		}
374
+		// set collection pointer back to current step
375
+		$this->form_steps->setCurrentUsingObject($current_step);
376
+		return new ProgressStepManager(
377
+			$this->progressStepStyle(),
378
+			$this->defaultFormStep(),
379
+			$this->formStepUrlKey(),
380
+			$progress_steps_collection
381
+		);
382
+	}
383
+
384
+
385
+	/**
386
+	 * @throws InvalidClassException
387
+	 * @throws InvalidDataTypeException
388
+	 * @throws InvalidEntityException
389
+	 * @throws InvalidIdentifierException
390
+	 * @throws InvalidInterfaceException
391
+	 * @throws InvalidArgumentException
392
+	 * @throws InvalidFormHandlerException
393
+	 */
394
+	public function buildForm()
395
+	{
396
+		$this->buildCurrentStepFormForDisplay();
397
+	}
398
+
399
+
400
+	/**
401
+	 * @param array $form_data
402
+	 * @throws InvalidArgumentException
403
+	 * @throws InvalidClassException
404
+	 * @throws InvalidDataTypeException
405
+	 * @throws InvalidEntityException
406
+	 * @throws InvalidFormHandlerException
407
+	 * @throws InvalidIdentifierException
408
+	 * @throws InvalidInterfaceException
409
+	 */
410
+	public function processForm($form_data = array())
411
+	{
412
+		$this->buildCurrentStepFormForProcessing();
413
+		$this->processCurrentStepForm($form_data);
414
+	}
415
+
416
+
417
+	/**
418
+	 * @throws InvalidClassException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidEntityException
421
+	 * @throws InvalidInterfaceException
422
+	 * @throws InvalidIdentifierException
423
+	 * @throws InvalidArgumentException
424
+	 * @throws InvalidFormHandlerException
425
+	 */
426
+	public function buildCurrentStepFormForDisplay()
427
+	{
428
+		$form_step = $this->buildCurrentStepForm();
429
+		// no displayable content ? then skip straight to processing
430
+		if (! $form_step->displayable()) {
431
+			$this->addFormActionArgs();
432
+			$form_step->setFormAction($this->formAction());
433
+			wp_safe_redirect($form_step->formAction());
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 * @throws InvalidClassException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidEntityException
442
+	 * @throws InvalidInterfaceException
443
+	 * @throws InvalidIdentifierException
444
+	 * @throws InvalidArgumentException
445
+	 * @throws InvalidFormHandlerException
446
+	 */
447
+	public function buildCurrentStepFormForProcessing()
448
+	{
449
+		$this->buildCurrentStepForm(false);
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param bool $for_display
455
+	 * @return SequentialStepFormInterface
456
+	 * @throws InvalidArgumentException
457
+	 * @throws InvalidClassException
458
+	 * @throws InvalidDataTypeException
459
+	 * @throws InvalidEntityException
460
+	 * @throws InvalidFormHandlerException
461
+	 * @throws InvalidIdentifierException
462
+	 * @throws InvalidInterfaceException
463
+	 */
464
+	private function buildCurrentStepForm($for_display = true)
465
+	{
466
+		$this->form_steps = $this->getFormStepsCollection();
467
+		$this->setCurrentStepFromRequest();
468
+		$form_step = $this->getCurrentStep();
469
+		if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
+			$form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
+		}
472
+		if ($for_display && $form_step->displayable()) {
473
+			$this->progress_step_manager = $this->generateProgressSteps(
474
+				$this->getProgressStepsCollection()
475
+			);
476
+			$this->progress_step_manager->setCurrentStep(
477
+				$form_step->slug()
478
+			);
479
+			// mark all previous progress steps as completed
480
+			$this->progress_step_manager->setPreviousStepsCompleted();
481
+			$this->progress_step_manager->enqueueStylesAndScripts();
482
+			$this->addFormActionArgs();
483
+			$form_step->setFormAction($this->formAction());
484
+		} else {
485
+			$form_step->setRedirectUrl($this->baseUrl());
486
+			$form_step->addRedirectArgs(
487
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
+			);
489
+		}
490
+		$form_step->generate();
491
+		if ($for_display) {
492
+			$form_step->enqueueStylesAndScripts();
493
+		}
494
+		return $form_step;
495
+	}
496
+
497
+
498
+	/**
499
+	 * @param bool $return_as_string
500
+	 * @return string
501
+	 * @throws InvalidFormHandlerException
502
+	 */
503
+	public function displayProgressSteps($return_as_string = true)
504
+	{
505
+		$form_step = $this->getCurrentStep();
506
+		if (! $form_step->displayable()) {
507
+			return '';
508
+		}
509
+		$progress_steps = apply_filters(
510
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
+			''
512
+		);
513
+		$progress_steps .= $this->progress_step_manager->displaySteps();
514
+		$progress_steps .= apply_filters(
515
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
+			''
517
+		);
518
+		if ($return_as_string) {
519
+			return $progress_steps;
520
+		}
521
+		echo wp_kses($progress_steps, AllowedTags::getWithFormTags());
522
+		return '';
523
+	}
524
+
525
+
526
+	/**
527
+	 * @param bool $return_as_string
528
+	 * @return string
529
+	 * @throws InvalidFormHandlerException
530
+	 */
531
+	public function displayCurrentStepForm($return_as_string = true)
532
+	{
533
+		if ($return_as_string) {
534
+			return $this->getCurrentStep()->display();
535
+		}
536
+		echo wp_kses($this->getCurrentStep()->display(), AllowedTags::getWithFormTags());
537
+		return '';
538
+	}
539
+
540
+
541
+	/**
542
+	 * @param array $form_data
543
+	 * @return void
544
+	 * @throws InvalidArgumentException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws InvalidFormHandlerException
547
+	 */
548
+	public function processCurrentStepForm($form_data = array())
549
+	{
550
+		// grab instance of current step because after calling next() below,
551
+		// any calls to getCurrentStep() will return the "next" step because we advanced
552
+		$current_step = $this->getCurrentStep();
553
+		try {
554
+			// form processing should either throw exceptions or return true
555
+			$current_step->process($form_data);
556
+		} catch (Exception $e) {
557
+			// something went wrong, convert the Exception to an EE_Error
558
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
559
+			// prevent redirect to next step or other if exception was thrown
560
+			if (
561
+				$current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
562
+				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
563
+			) {
564
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
565
+			}
566
+		}
567
+		// save notices to a transient so that when we redirect back
568
+		// to the display portion for this step
569
+		// those notices can be displayed
570
+		EE_Error::get_notices(false, true);
571
+		$this->redirectForm($current_step);
572
+	}
573
+
574
+
575
+	/**
576
+	 * handles where to go to next
577
+	 *
578
+	 * @param SequentialStepFormInterface $current_step
579
+	 * @throws InvalidArgumentException
580
+	 * @throws InvalidDataTypeException
581
+	 * @throws InvalidFormHandlerException
582
+	 */
583
+	public function redirectForm(SequentialStepFormInterface $current_step)
584
+	{
585
+		$redirect_step = $current_step;
586
+		switch ($current_step->redirectTo()) {
587
+			case SequentialStepForm::REDIRECT_TO_OTHER:
588
+				// going somewhere else, so just check out now
589
+				wp_safe_redirect($redirect_step->redirectUrl());
590
+				exit();
591
+			case SequentialStepForm::REDIRECT_TO_PREV_STEP:
592
+				$redirect_step = $this->form_steps->previous();
593
+				break;
594
+			case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
595
+				$this->form_steps->next();
596
+				if ($this->form_steps->valid()) {
597
+					$redirect_step = $this->form_steps->current();
598
+				}
599
+				break;
600
+			case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
601
+			default:
602
+				// $redirect_step is already set
603
+		}
604
+		$current_step->setRedirectUrl($this->baseUrl());
605
+		$current_step->addRedirectArgs(
606
+			// use the slug for whatever step we are redirecting too
607
+			array($this->formStepUrlKey() => $redirect_step->slug())
608
+		);
609
+		wp_safe_redirect($current_step->redirectUrl());
610
+		exit();
611
+	}
612 612
 }
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function getShortcodes()
83 83
     {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
84
+        if ( ! $this->shortcodes instanceof CollectionInterface) {
85 85
             $this->shortcodes = $this->loadShortcodesCollection();
86 86
         }
87 87
         return $this->shortcodes;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139 139
                 $this->getShortcodes()
140 140
             );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
141
+            if ( ! $this->shortcodes instanceof CollectionInterface) {
142 142
                 throw new InvalidEntityException(
143 143
                     $this->shortcodes,
144 144
                     'CollectionInterface',
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173 173
                 }
174 174
                 // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
175
+                if ( ! shortcode_exists($shortcode->getTag())) {
176 176
                     add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177 177
                 }
178 178
             }
Please login to merge, or discard this patch.
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -31,221 +31,221 @@
 block discarded – undo
31 31
  */
32 32
 class ShortcodesManager
33 33
 {
34
-    protected CurrentPage $current_page;
35
-
36
-    private LegacyShortcodesManager $legacy_shortcodes_manager;
37
-
38
-    /**
39
-     * @var CollectionInterface|ShortcodeInterface[] $shortcodes
40
-     */
41
-    private $shortcodes;
42
-
43
-
44
-    /**
45
-     * ShortcodesManager constructor
46
-     *
47
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
48
-     * @param CurrentPage             $current_page
49
-     */
50
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
51
-    {
52
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
53
-        $this->current_page              = $current_page;
54
-    }
55
-
56
-
57
-    public function setHooks()
58
-    {
59
-        // assemble a list of installed and active shortcodes
60
-        add_action(
61
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
62
-            [$this, 'registerShortcodes'],
63
-            999
64
-        );
65
-        //  call add_shortcode() for all installed shortcodes
66
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
67
-        // check content for shortcodes the old way
68
-        add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
69
-        // check content for shortcodes the NEW more efficient way
70
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
71
-    }
72
-
73
-
74
-    /**
75
-     * @return CollectionInterface|ShortcodeInterface[]
76
-     * @throws InvalidIdentifierException
77
-     * @throws InvalidInterfaceException
78
-     * @throws InvalidFilePathException
79
-     * @throws InvalidEntityException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidClassException
82
-     */
83
-    public function getShortcodes()
84
-    {
85
-        if (! $this->shortcodes instanceof CollectionInterface) {
86
-            $this->shortcodes = $this->loadShortcodesCollection();
87
-        }
88
-        return $this->shortcodes;
89
-    }
90
-
91
-
92
-    /**
93
-     * @return CollectionInterface|ShortcodeInterface[]
94
-     * @throws InvalidIdentifierException
95
-     * @throws InvalidInterfaceException
96
-     * @throws InvalidFilePathException
97
-     * @throws InvalidEntityException
98
-     * @throws InvalidDataTypeException
99
-     * @throws InvalidClassException
100
-     */
101
-    protected function loadShortcodesCollection()
102
-    {
103
-        $loader = new CollectionLoader(
104
-            new CollectionDetails(
105
-            // collection name
106
-                'shortcodes',
107
-                // collection interface
108
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
109
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
110
-                ['EventEspresso\core\domain\entities\shortcodes'],
111
-                // filepaths to classes to add
112
-                [],
113
-                // file mask to use if parsing folder for files to add
114
-                '',
115
-                // what to use as identifier for collection entities
116
-                // using CLASS NAME prevents duplicates (works like a singleton)
117
-                CollectionDetails::ID_CLASS_NAME
118
-            )
119
-        );
120
-        return $loader->getCollection();
121
-    }
122
-
123
-
124
-    /**
125
-     * @return void
126
-     * @throws DomainException
127
-     * @throws InvalidInterfaceException
128
-     * @throws InvalidIdentifierException
129
-     * @throws InvalidFilePathException
130
-     * @throws InvalidEntityException
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidClassException
133
-     * @throws Exception
134
-     * @throws Throwable
135
-     */
136
-    public function registerShortcodes()
137
-    {
138
-        try {
139
-            $this->shortcodes = apply_filters(
140
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
141
-                $this->getShortcodes()
142
-            );
143
-            if (! $this->shortcodes instanceof CollectionInterface) {
144
-                throw new InvalidEntityException(
145
-                    $this->shortcodes,
146
-                    'CollectionInterface',
147
-                    sprintf(
148
-                        esc_html__(
149
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
150
-                            'event_espresso'
151
-                        ),
152
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
153
-                    )
154
-                );
155
-            }
156
-            $this->legacy_shortcodes_manager->registerShortcodes();
157
-        } catch (Exception $exception) {
158
-            new ExceptionStackTraceDisplay($exception);
159
-        }
160
-    }
161
-
162
-
163
-    /**
164
-     * @return void
165
-     * @throws Exception
166
-     * @throws Throwable
167
-     */
168
-    public function addShortcodes()
169
-    {
170
-        try {
171
-            // cycle thru shortcode folders
172
-            foreach ($this->shortcodes as $shortcode) {
173
-                if ($shortcode instanceof EnqueueAssetsInterface) {
174
-                    add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets']);
175
-                    add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
176
-                }
177
-                // add_shortcode() if it has not already been added
178
-                if (! shortcode_exists($shortcode->getTag())) {
179
-                    add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
180
-                }
181
-            }
182
-            $this->legacy_shortcodes_manager->addShortcodes();
183
-        } catch (Exception $exception) {
184
-            new ExceptionStackTraceDisplay($exception);
185
-        }
186
-    }
187
-
188
-
189
-    /**
190
-     * callback for the "template_redirect" hook point
191
-     * checks posts for EE shortcodes, and initializes them,
192
-     * then toggles filter switch that loads core default assets
193
-     *
194
-     * @return void
195
-     */
196
-    public function templateRedirect()
197
-    {
198
-        global $wp_query;
199
-        if (empty($wp_query->posts)) {
200
-            return;
201
-        }
202
-        $load_assets = false;
203
-        // array of posts displayed in current request
204
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
205
-        foreach ($posts as $post) {
206
-            // now check post content and excerpt for EE shortcodes
207
-            // and typcast to string despite WP_Post object typehint because it is not always correct
208
-            $load_assets = $this->parseContentForShortcodes((string) $post->post_content, $post)
209
-                ? true
210
-                : $load_assets;
211
-        }
212
-        if ($load_assets) {
213
-            $this->current_page->setEspressoPage(true);
214
-            add_filter('FHEE_load_css', '__return_true');
215
-            add_filter('FHEE_load_js', '__return_true');
216
-        }
217
-    }
218
-
219
-
220
-    /**
221
-     * checks supplied content against list of shortcodes,
222
-     * then initializes any found shortcodes, and returns true.
223
-     * returns false if no shortcodes found.
224
-     *
225
-     * @param string  $content
226
-     * @param WP_Post $post
227
-     * @return bool
228
-     */
229
-    public function parseContentForShortcodes(string $content, WP_Post $post): bool
230
-    {
231
-        if (empty($this->shortcodes)) {
232
-            return false;
233
-        }
234
-        $has_shortcode = false;
235
-        foreach ($this->shortcodes as $shortcode) {
236
-            if (
237
-                apply_filters(
238
-                    'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__parseContentForShortcodes__has_shortcode',
239
-                    has_shortcode($content, $shortcode->getTag()),
240
-                    $content,
241
-                    $post,
242
-                    $shortcode
243
-                )
244
-            ) {
245
-                $shortcode->initializeShortcode();
246
-                $has_shortcode = true;
247
-            }
248
-        }
249
-        return $has_shortcode;
250
-    }
34
+	protected CurrentPage $current_page;
35
+
36
+	private LegacyShortcodesManager $legacy_shortcodes_manager;
37
+
38
+	/**
39
+	 * @var CollectionInterface|ShortcodeInterface[] $shortcodes
40
+	 */
41
+	private $shortcodes;
42
+
43
+
44
+	/**
45
+	 * ShortcodesManager constructor
46
+	 *
47
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
48
+	 * @param CurrentPage             $current_page
49
+	 */
50
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
51
+	{
52
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
53
+		$this->current_page              = $current_page;
54
+	}
55
+
56
+
57
+	public function setHooks()
58
+	{
59
+		// assemble a list of installed and active shortcodes
60
+		add_action(
61
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
62
+			[$this, 'registerShortcodes'],
63
+			999
64
+		);
65
+		//  call add_shortcode() for all installed shortcodes
66
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
67
+		// check content for shortcodes the old way
68
+		add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
69
+		// check content for shortcodes the NEW more efficient way
70
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return CollectionInterface|ShortcodeInterface[]
76
+	 * @throws InvalidIdentifierException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws InvalidFilePathException
79
+	 * @throws InvalidEntityException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidClassException
82
+	 */
83
+	public function getShortcodes()
84
+	{
85
+		if (! $this->shortcodes instanceof CollectionInterface) {
86
+			$this->shortcodes = $this->loadShortcodesCollection();
87
+		}
88
+		return $this->shortcodes;
89
+	}
90
+
91
+
92
+	/**
93
+	 * @return CollectionInterface|ShortcodeInterface[]
94
+	 * @throws InvalidIdentifierException
95
+	 * @throws InvalidInterfaceException
96
+	 * @throws InvalidFilePathException
97
+	 * @throws InvalidEntityException
98
+	 * @throws InvalidDataTypeException
99
+	 * @throws InvalidClassException
100
+	 */
101
+	protected function loadShortcodesCollection()
102
+	{
103
+		$loader = new CollectionLoader(
104
+			new CollectionDetails(
105
+			// collection name
106
+				'shortcodes',
107
+				// collection interface
108
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
109
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
110
+				['EventEspresso\core\domain\entities\shortcodes'],
111
+				// filepaths to classes to add
112
+				[],
113
+				// file mask to use if parsing folder for files to add
114
+				'',
115
+				// what to use as identifier for collection entities
116
+				// using CLASS NAME prevents duplicates (works like a singleton)
117
+				CollectionDetails::ID_CLASS_NAME
118
+			)
119
+		);
120
+		return $loader->getCollection();
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return void
126
+	 * @throws DomainException
127
+	 * @throws InvalidInterfaceException
128
+	 * @throws InvalidIdentifierException
129
+	 * @throws InvalidFilePathException
130
+	 * @throws InvalidEntityException
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidClassException
133
+	 * @throws Exception
134
+	 * @throws Throwable
135
+	 */
136
+	public function registerShortcodes()
137
+	{
138
+		try {
139
+			$this->shortcodes = apply_filters(
140
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
141
+				$this->getShortcodes()
142
+			);
143
+			if (! $this->shortcodes instanceof CollectionInterface) {
144
+				throw new InvalidEntityException(
145
+					$this->shortcodes,
146
+					'CollectionInterface',
147
+					sprintf(
148
+						esc_html__(
149
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
150
+							'event_espresso'
151
+						),
152
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
153
+					)
154
+				);
155
+			}
156
+			$this->legacy_shortcodes_manager->registerShortcodes();
157
+		} catch (Exception $exception) {
158
+			new ExceptionStackTraceDisplay($exception);
159
+		}
160
+	}
161
+
162
+
163
+	/**
164
+	 * @return void
165
+	 * @throws Exception
166
+	 * @throws Throwable
167
+	 */
168
+	public function addShortcodes()
169
+	{
170
+		try {
171
+			// cycle thru shortcode folders
172
+			foreach ($this->shortcodes as $shortcode) {
173
+				if ($shortcode instanceof EnqueueAssetsInterface) {
174
+					add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets']);
175
+					add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
176
+				}
177
+				// add_shortcode() if it has not already been added
178
+				if (! shortcode_exists($shortcode->getTag())) {
179
+					add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
180
+				}
181
+			}
182
+			$this->legacy_shortcodes_manager->addShortcodes();
183
+		} catch (Exception $exception) {
184
+			new ExceptionStackTraceDisplay($exception);
185
+		}
186
+	}
187
+
188
+
189
+	/**
190
+	 * callback for the "template_redirect" hook point
191
+	 * checks posts for EE shortcodes, and initializes them,
192
+	 * then toggles filter switch that loads core default assets
193
+	 *
194
+	 * @return void
195
+	 */
196
+	public function templateRedirect()
197
+	{
198
+		global $wp_query;
199
+		if (empty($wp_query->posts)) {
200
+			return;
201
+		}
202
+		$load_assets = false;
203
+		// array of posts displayed in current request
204
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
205
+		foreach ($posts as $post) {
206
+			// now check post content and excerpt for EE shortcodes
207
+			// and typcast to string despite WP_Post object typehint because it is not always correct
208
+			$load_assets = $this->parseContentForShortcodes((string) $post->post_content, $post)
209
+				? true
210
+				: $load_assets;
211
+		}
212
+		if ($load_assets) {
213
+			$this->current_page->setEspressoPage(true);
214
+			add_filter('FHEE_load_css', '__return_true');
215
+			add_filter('FHEE_load_js', '__return_true');
216
+		}
217
+	}
218
+
219
+
220
+	/**
221
+	 * checks supplied content against list of shortcodes,
222
+	 * then initializes any found shortcodes, and returns true.
223
+	 * returns false if no shortcodes found.
224
+	 *
225
+	 * @param string  $content
226
+	 * @param WP_Post $post
227
+	 * @return bool
228
+	 */
229
+	public function parseContentForShortcodes(string $content, WP_Post $post): bool
230
+	{
231
+		if (empty($this->shortcodes)) {
232
+			return false;
233
+		}
234
+		$has_shortcode = false;
235
+		foreach ($this->shortcodes as $shortcode) {
236
+			if (
237
+				apply_filters(
238
+					'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__parseContentForShortcodes__has_shortcode',
239
+					has_shortcode($content, $shortcode->getTag()),
240
+					$content,
241
+					$post,
242
+					$shortcode
243
+				)
244
+			) {
245
+				$shortcode->initializeShortcode();
246
+				$has_shortcode = true;
247
+			}
248
+		}
249
+		return $has_shortcode;
250
+	}
251 251
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/Iframe.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function __construct($title, $content)
84 84
     {
85 85
         global $wp_version;
86
-        if (! defined('EE_IFRAME_DIR_URL')) {
86
+        if ( ! defined('EE_IFRAME_DIR_URL')) {
87 87
             define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
88 88
         }
89 89
         $this->setContent($content);
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
94 94
                 array(
95 95
                     'site_theme'       => get_stylesheet_directory_uri()
96
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
97
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
96
+                                          . '/style.css?ver='.EVENT_ESPRESSO_VERSION,
97
+                    'dashicons'        => includes_url('css/dashicons.min.css?ver='.$wp_version),
98 98
                     'espresso_default' => EE_GLOBAL_ASSETS_URL
99
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
+                                          . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
100 100
                 ),
101 101
                 $this
102 102
             )
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
             apply_filters(
106 106
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
107 107
                 array(
108
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
+                    'jquery'        => includes_url('js/jquery/jquery.js?ver='.$wp_version),
109 109
                     'espresso_core' => EE_GLOBAL_ASSETS_URL
110
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
+                                       . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
111 111
                 ),
112 112
                 $this
113 113
             )
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             );
182 182
         }
183 183
         foreach ($stylesheets as $handle => $stylesheet) {
184
-            $this->css[ $handle ] = $stylesheet;
184
+            $this->css[$handle] = $stylesheet;
185 185
         }
186 186
     }
187 187
 
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         }
204 204
         foreach ($scripts as $handle => $script) {
205 205
             if ($add_to_header) {
206
-                $this->header_js[ $handle ] = $script;
206
+                $this->header_js[$handle] = $script;
207 207
             } else {
208
-                $this->footer_js[ $handle ] = $script;
208
+                $this->footer_js[$handle] = $script;
209 209
             }
210 210
         }
211 211
     }
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
         }
229 229
         foreach ($script_attributes as $handle => $script_attribute) {
230 230
             if ($add_to_header) {
231
-                $this->header_js_attributes[ $handle ] = $script_attribute;
231
+                $this->header_js_attributes[$handle] = $script_attribute;
232 232
             } else {
233
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
233
+                $this->footer_js_attributes[$handle] = $script_attribute;
234 234
             }
235 235
         }
236 236
     }
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
         }
254 254
         foreach ($vars as $handle => $var) {
255 255
             if ($var_name === 'eei18n') {
256
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
256
+                EE_Registry::$i18n_js_strings[$handle] = $var;
257 257
             } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
258
-                $this->localized_vars[ $var_name ] = $var;
258
+                $this->localized_vars[$var_name] = $var;
259 259
             } else {
260
-                if (! isset($this->localized_vars[ $var_name ])) {
261
-                    $this->localized_vars[ $var_name ] = array();
260
+                if ( ! isset($this->localized_vars[$var_name])) {
261
+                    $this->localized_vars[$var_name] = array();
262 262
                 }
263
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
263
+                $this->localized_vars[$var_name][$handle] = $var;
264 264
             }
265 265
         }
266 266
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     public function getTemplate()
291 291
     {
292 292
         return EEH_Template::display_template(
293
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
293
+            __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php',
294 294
             array(
295 295
                 'title'                => apply_filters(
296 296
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
                 ),
335 335
                 'eei18n'               => apply_filters(
336 336
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
337
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
337
+                    EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(),
338 338
                     $this
339 339
                 ),
340 340
                 'notices'              => EEH_Template::display_template(
341
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
341
+                    EE_TEMPLATES.'espresso-ajax-notices.template.php',
342 342
                     array(),
343 343
                     true
344 344
                 ),
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     {
359 359
         $JSON = '';
360 360
         foreach ($this->localized_vars as $var_name => $vars) {
361
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
361
+            $this->localized_vars[$var_name] = $this->encodeJsonVars($vars);
362 362
             $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
363
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
363
+            $JSON .= wp_json_encode($this->localized_vars[$var_name]);
364 364
             $JSON .= '; /* ]]> */';
365 365
         }
366 366
         return $JSON;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         if (is_array($var)) {
377 377
             $localized_vars = array();
378 378
             foreach ((array) $var as $key => $value) {
379
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
379
+                $localized_vars[$key] = $this->encodeJsonVars($value);
380 380
             }
381 381
             return $localized_vars;
382 382
         }
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -18,373 +18,373 @@
 block discarded – undo
18 18
  */
19 19
 class Iframe
20 20
 {
21
-    /*
21
+	/*
22 22
     * HTML for notices and ajax gif
23 23
     * @var string $title
24 24
     */
25
-    protected $title = '';
25
+	protected $title = '';
26 26
 
27
-    /*
27
+	/*
28 28
     * HTML for the content being displayed
29 29
     * @var string $content
30 30
     */
31
-    protected $content = '';
31
+	protected $content = '';
32 32
 
33
-    /*
33
+	/*
34 34
     * whether or not to call wp_head() and wp_footer()
35 35
     * @var boolean $enqueue_wp_assets
36 36
     */
37
-    protected $enqueue_wp_assets = false;
37
+	protected $enqueue_wp_assets = false;
38 38
 
39
-    /*
39
+	/*
40 40
     * an array of CSS URLs
41 41
     * @var array $css
42 42
     */
43
-    protected $css = array();
43
+	protected $css = array();
44 44
 
45
-    /*
45
+	/*
46 46
     * an array of JS URLs to be set in the HTML header.
47 47
     * @var array $header_js
48 48
     */
49
-    protected $header_js = array();
49
+	protected $header_js = array();
50 50
 
51
-    /*
51
+	/*
52 52
     * an array of additional attributes to be added to <script> tags for header JS
53 53
     * @var array $footer_js
54 54
     */
55
-    protected $header_js_attributes = array();
55
+	protected $header_js_attributes = array();
56 56
 
57
-    /*
57
+	/*
58 58
     * an array of JS URLs to be displayed before the HTML </body> tag
59 59
     * @var array $footer_js
60 60
     */
61
-    protected $footer_js = array();
61
+	protected $footer_js = array();
62 62
 
63
-    /*
63
+	/*
64 64
     * an array of additional attributes to be added to <script> tags for footer JS
65 65
     * @var array $footer_js_attributes
66 66
     */
67
-    protected $footer_js_attributes = array();
67
+	protected $footer_js_attributes = array();
68 68
 
69
-    /*
69
+	/*
70 70
     * an array of JSON vars to be set in the HTML header.
71 71
     * @var array $localized_vars
72 72
     */
73
-    protected $localized_vars = array();
74
-
75
-
76
-    /**
77
-     * Iframe constructor
78
-     *
79
-     * @param string $title
80
-     * @param string $content
81
-     * @throws DomainException
82
-     */
83
-    public function __construct($title, $content)
84
-    {
85
-        global $wp_version;
86
-        if (! defined('EE_IFRAME_DIR_URL')) {
87
-            define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
88
-        }
89
-        $this->setContent($content);
90
-        $this->setTitle($title);
91
-        $this->addStylesheets(
92
-            apply_filters(
93
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
94
-                array(
95
-                    'site_theme'       => get_stylesheet_directory_uri()
96
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
97
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
98
-                    'espresso_default' => EE_GLOBAL_ASSETS_URL
99
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
100
-                ),
101
-                $this
102
-            )
103
-        );
104
-        $this->addScripts(
105
-            apply_filters(
106
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
107
-                array(
108
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
109
-                    'espresso_core' => EE_GLOBAL_ASSETS_URL
110
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
111
-                ),
112
-                $this
113
-            )
114
-        );
115
-        if (
116
-            apply_filters(
117
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
118
-                false
119
-            )
120
-        ) {
121
-            $this->addStylesheets(
122
-                apply_filters(
123
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
124
-                    array('default_theme_stylesheet' => get_stylesheet_uri()),
125
-                    $this
126
-                )
127
-            );
128
-        }
129
-    }
130
-
131
-
132
-    /**
133
-     * @param string $title
134
-     * @throws DomainException
135
-     */
136
-    public function setTitle($title)
137
-    {
138
-        if (empty($title)) {
139
-            throw new DomainException(
140
-                esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
141
-            );
142
-        }
143
-        $this->title = $title;
144
-    }
145
-
146
-
147
-    /**
148
-     * @param string $content
149
-     * @throws DomainException
150
-     */
151
-    public function setContent($content)
152
-    {
153
-        if (empty($content)) {
154
-            throw new DomainException(
155
-                esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
156
-            );
157
-        }
158
-        $this->content = $content;
159
-    }
160
-
161
-
162
-    /**
163
-     * @param boolean $enqueue_wp_assets
164
-     */
165
-    public function setEnqueueWpAssets($enqueue_wp_assets)
166
-    {
167
-        $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
168
-    }
169
-
170
-
171
-    /**
172
-     * @param array $stylesheets
173
-     * @throws DomainException
174
-     */
175
-    public function addStylesheets(array $stylesheets)
176
-    {
177
-        if (empty($stylesheets)) {
178
-            throw new DomainException(
179
-                esc_html__(
180
-                    'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
181
-                    'event_espresso'
182
-                )
183
-            );
184
-        }
185
-        foreach ($stylesheets as $handle => $stylesheet) {
186
-            $this->css[ $handle ] = $stylesheet;
187
-        }
188
-    }
189
-
190
-
191
-    /**
192
-     * @param array $scripts
193
-     * @param bool  $add_to_header
194
-     * @throws DomainException
195
-     */
196
-    public function addScripts(array $scripts, $add_to_header = false)
197
-    {
198
-        if (empty($scripts)) {
199
-            throw new DomainException(
200
-                esc_html__(
201
-                    'A non-empty array of URLs, is required to add Javascript to an iframe.',
202
-                    'event_espresso'
203
-                )
204
-            );
205
-        }
206
-        foreach ($scripts as $handle => $script) {
207
-            if ($add_to_header) {
208
-                $this->header_js[ $handle ] = $script;
209
-            } else {
210
-                $this->footer_js[ $handle ] = $script;
211
-            }
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * @param array $script_attributes
218
-     * @param bool  $add_to_header
219
-     * @throws DomainException
220
-     */
221
-    public function addScriptAttributes(array $script_attributes, $add_to_header = false)
222
-    {
223
-        if (empty($script_attributes)) {
224
-            throw new DomainException(
225
-                esc_html__(
226
-                    'A non-empty array of strings, is required to add attributes to iframe Javascript.',
227
-                    'event_espresso'
228
-                )
229
-            );
230
-        }
231
-        foreach ($script_attributes as $handle => $script_attribute) {
232
-            if ($add_to_header) {
233
-                $this->header_js_attributes[ $handle ] = $script_attribute;
234
-            } else {
235
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
236
-            }
237
-        }
238
-    }
239
-
240
-
241
-    /**
242
-     * @param array  $vars
243
-     * @param string $var_name
244
-     * @throws DomainException
245
-     */
246
-    public function addLocalizedVars(array $vars, $var_name = 'eei18n')
247
-    {
248
-        if (empty($vars)) {
249
-            throw new DomainException(
250
-                esc_html__(
251
-                    'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
252
-                    'event_espresso'
253
-                )
254
-            );
255
-        }
256
-        foreach ($vars as $handle => $var) {
257
-            if ($var_name === 'eei18n') {
258
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
259
-            } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
260
-                $this->localized_vars[ $var_name ] = $var;
261
-            } else {
262
-                if (! isset($this->localized_vars[ $var_name ])) {
263
-                    $this->localized_vars[ $var_name ] = array();
264
-                }
265
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
266
-            }
267
-        }
268
-    }
269
-
270
-
271
-    /**
272
-     * @param string $utm_content
273
-     * @throws DomainException
274
-     */
275
-    public function display($utm_content = '')
276
-    {
277
-        $this->content .= EEH_Template::powered_by_event_espresso(
278
-            '',
279
-            '',
280
-            ! empty($utm_content) ? array('utm_content' => $utm_content) : array()
281
-        );
282
-        EE_System::do_not_cache();
283
-        echo $this->getTemplate();
284
-        exit;
285
-    }
286
-
287
-
288
-    /**
289
-     * @return string
290
-     * @throws DomainException
291
-     */
292
-    public function getTemplate()
293
-    {
294
-        return EEH_Template::display_template(
295
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
296
-            array(
297
-                'title'                => apply_filters(
298
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
299
-                    $this->title,
300
-                    $this
301
-                ),
302
-                'content'              => apply_filters(
303
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
304
-                    $this->content,
305
-                    $this
306
-                ),
307
-                'enqueue_wp_assets'    => apply_filters(
308
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
309
-                    $this->enqueue_wp_assets,
310
-                    $this
311
-                ),
312
-                'css'                  => (array) apply_filters(
313
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
314
-                    $this->css,
315
-                    $this
316
-                ),
317
-                'header_js'            => (array) apply_filters(
318
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
319
-                    $this->header_js,
320
-                    $this
321
-                ),
322
-                'header_js_attributes' => (array) apply_filters(
323
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
324
-                    $this->header_js_attributes,
325
-                    $this
326
-                ),
327
-                'footer_js'            => (array) apply_filters(
328
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
329
-                    $this->footer_js,
330
-                    $this
331
-                ),
332
-                'footer_js_attributes' => (array) apply_filters(
333
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
334
-                    $this->footer_js_attributes,
335
-                    $this
336
-                ),
337
-                'eei18n'               => apply_filters(
338
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
339
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
340
-                    $this
341
-                ),
342
-                'notices'              => EEH_Template::display_template(
343
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
344
-                    array(),
345
-                    true
346
-                ),
347
-            ),
348
-            true,
349
-            true
350
-        );
351
-    }
352
-
353
-
354
-    /**
355
-     * localizeJsonVars
356
-     *
357
-     * @return string
358
-     */
359
-    public function localizeJsonVars()
360
-    {
361
-        $JSON = '';
362
-        foreach ($this->localized_vars as $var_name => $vars) {
363
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
364
-            $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
365
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
366
-            $JSON .= '; /* ]]> */';
367
-        }
368
-        return $JSON;
369
-    }
370
-
371
-
372
-    /**
373
-     * @param bool|int|float|string|array $var
374
-     * @return array|string|null
375
-     */
376
-    public function encodeJsonVars($var)
377
-    {
378
-        if (is_array($var)) {
379
-            $localized_vars = array();
380
-            foreach ((array) $var as $key => $value) {
381
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
382
-            }
383
-            return $localized_vars;
384
-        }
385
-        if (is_scalar($var)) {
386
-            return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
387
-        }
388
-        return null;
389
-    }
73
+	protected $localized_vars = array();
74
+
75
+
76
+	/**
77
+	 * Iframe constructor
78
+	 *
79
+	 * @param string $title
80
+	 * @param string $content
81
+	 * @throws DomainException
82
+	 */
83
+	public function __construct($title, $content)
84
+	{
85
+		global $wp_version;
86
+		if (! defined('EE_IFRAME_DIR_URL')) {
87
+			define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
88
+		}
89
+		$this->setContent($content);
90
+		$this->setTitle($title);
91
+		$this->addStylesheets(
92
+			apply_filters(
93
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
94
+				array(
95
+					'site_theme'       => get_stylesheet_directory_uri()
96
+										  . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
97
+					'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
98
+					'espresso_default' => EE_GLOBAL_ASSETS_URL
99
+										  . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
100
+				),
101
+				$this
102
+			)
103
+		);
104
+		$this->addScripts(
105
+			apply_filters(
106
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
107
+				array(
108
+					'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
109
+					'espresso_core' => EE_GLOBAL_ASSETS_URL
110
+									   . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
111
+				),
112
+				$this
113
+			)
114
+		);
115
+		if (
116
+			apply_filters(
117
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
118
+				false
119
+			)
120
+		) {
121
+			$this->addStylesheets(
122
+				apply_filters(
123
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
124
+					array('default_theme_stylesheet' => get_stylesheet_uri()),
125
+					$this
126
+				)
127
+			);
128
+		}
129
+	}
130
+
131
+
132
+	/**
133
+	 * @param string $title
134
+	 * @throws DomainException
135
+	 */
136
+	public function setTitle($title)
137
+	{
138
+		if (empty($title)) {
139
+			throw new DomainException(
140
+				esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
141
+			);
142
+		}
143
+		$this->title = $title;
144
+	}
145
+
146
+
147
+	/**
148
+	 * @param string $content
149
+	 * @throws DomainException
150
+	 */
151
+	public function setContent($content)
152
+	{
153
+		if (empty($content)) {
154
+			throw new DomainException(
155
+				esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
156
+			);
157
+		}
158
+		$this->content = $content;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param boolean $enqueue_wp_assets
164
+	 */
165
+	public function setEnqueueWpAssets($enqueue_wp_assets)
166
+	{
167
+		$this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param array $stylesheets
173
+	 * @throws DomainException
174
+	 */
175
+	public function addStylesheets(array $stylesheets)
176
+	{
177
+		if (empty($stylesheets)) {
178
+			throw new DomainException(
179
+				esc_html__(
180
+					'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
181
+					'event_espresso'
182
+				)
183
+			);
184
+		}
185
+		foreach ($stylesheets as $handle => $stylesheet) {
186
+			$this->css[ $handle ] = $stylesheet;
187
+		}
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param array $scripts
193
+	 * @param bool  $add_to_header
194
+	 * @throws DomainException
195
+	 */
196
+	public function addScripts(array $scripts, $add_to_header = false)
197
+	{
198
+		if (empty($scripts)) {
199
+			throw new DomainException(
200
+				esc_html__(
201
+					'A non-empty array of URLs, is required to add Javascript to an iframe.',
202
+					'event_espresso'
203
+				)
204
+			);
205
+		}
206
+		foreach ($scripts as $handle => $script) {
207
+			if ($add_to_header) {
208
+				$this->header_js[ $handle ] = $script;
209
+			} else {
210
+				$this->footer_js[ $handle ] = $script;
211
+			}
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * @param array $script_attributes
218
+	 * @param bool  $add_to_header
219
+	 * @throws DomainException
220
+	 */
221
+	public function addScriptAttributes(array $script_attributes, $add_to_header = false)
222
+	{
223
+		if (empty($script_attributes)) {
224
+			throw new DomainException(
225
+				esc_html__(
226
+					'A non-empty array of strings, is required to add attributes to iframe Javascript.',
227
+					'event_espresso'
228
+				)
229
+			);
230
+		}
231
+		foreach ($script_attributes as $handle => $script_attribute) {
232
+			if ($add_to_header) {
233
+				$this->header_js_attributes[ $handle ] = $script_attribute;
234
+			} else {
235
+				$this->footer_js_attributes[ $handle ] = $script_attribute;
236
+			}
237
+		}
238
+	}
239
+
240
+
241
+	/**
242
+	 * @param array  $vars
243
+	 * @param string $var_name
244
+	 * @throws DomainException
245
+	 */
246
+	public function addLocalizedVars(array $vars, $var_name = 'eei18n')
247
+	{
248
+		if (empty($vars)) {
249
+			throw new DomainException(
250
+				esc_html__(
251
+					'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
252
+					'event_espresso'
253
+				)
254
+			);
255
+		}
256
+		foreach ($vars as $handle => $var) {
257
+			if ($var_name === 'eei18n') {
258
+				EE_Registry::$i18n_js_strings[ $handle ] = $var;
259
+			} elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
260
+				$this->localized_vars[ $var_name ] = $var;
261
+			} else {
262
+				if (! isset($this->localized_vars[ $var_name ])) {
263
+					$this->localized_vars[ $var_name ] = array();
264
+				}
265
+				$this->localized_vars[ $var_name ][ $handle ] = $var;
266
+			}
267
+		}
268
+	}
269
+
270
+
271
+	/**
272
+	 * @param string $utm_content
273
+	 * @throws DomainException
274
+	 */
275
+	public function display($utm_content = '')
276
+	{
277
+		$this->content .= EEH_Template::powered_by_event_espresso(
278
+			'',
279
+			'',
280
+			! empty($utm_content) ? array('utm_content' => $utm_content) : array()
281
+		);
282
+		EE_System::do_not_cache();
283
+		echo $this->getTemplate();
284
+		exit;
285
+	}
286
+
287
+
288
+	/**
289
+	 * @return string
290
+	 * @throws DomainException
291
+	 */
292
+	public function getTemplate()
293
+	{
294
+		return EEH_Template::display_template(
295
+			__DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
296
+			array(
297
+				'title'                => apply_filters(
298
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
299
+					$this->title,
300
+					$this
301
+				),
302
+				'content'              => apply_filters(
303
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
304
+					$this->content,
305
+					$this
306
+				),
307
+				'enqueue_wp_assets'    => apply_filters(
308
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
309
+					$this->enqueue_wp_assets,
310
+					$this
311
+				),
312
+				'css'                  => (array) apply_filters(
313
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
314
+					$this->css,
315
+					$this
316
+				),
317
+				'header_js'            => (array) apply_filters(
318
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
319
+					$this->header_js,
320
+					$this
321
+				),
322
+				'header_js_attributes' => (array) apply_filters(
323
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
324
+					$this->header_js_attributes,
325
+					$this
326
+				),
327
+				'footer_js'            => (array) apply_filters(
328
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
329
+					$this->footer_js,
330
+					$this
331
+				),
332
+				'footer_js_attributes' => (array) apply_filters(
333
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
334
+					$this->footer_js_attributes,
335
+					$this
336
+				),
337
+				'eei18n'               => apply_filters(
338
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
339
+					EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
340
+					$this
341
+				),
342
+				'notices'              => EEH_Template::display_template(
343
+					EE_TEMPLATES . 'espresso-ajax-notices.template.php',
344
+					array(),
345
+					true
346
+				),
347
+			),
348
+			true,
349
+			true
350
+		);
351
+	}
352
+
353
+
354
+	/**
355
+	 * localizeJsonVars
356
+	 *
357
+	 * @return string
358
+	 */
359
+	public function localizeJsonVars()
360
+	{
361
+		$JSON = '';
362
+		foreach ($this->localized_vars as $var_name => $vars) {
363
+			$this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
364
+			$JSON .= "/* <![CDATA[ */ var {$var_name} = ";
365
+			$JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
366
+			$JSON .= '; /* ]]> */';
367
+		}
368
+		return $JSON;
369
+	}
370
+
371
+
372
+	/**
373
+	 * @param bool|int|float|string|array $var
374
+	 * @return array|string|null
375
+	 */
376
+	public function encodeJsonVars($var)
377
+	{
378
+		if (is_array($var)) {
379
+			$localized_vars = array();
380
+			foreach ((array) $var as $key => $value) {
381
+				$localized_vars[ $key ] = $this->encodeJsonVars($value);
382
+			}
383
+			return $localized_vars;
384
+		}
385
+		if (is_scalar($var)) {
386
+			return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
387
+		}
388
+		return null;
389
+	}
390 390
 }
Please login to merge, or discard this patch.
modules/events_archive/EventsArchiveIframe.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
             apply_filters(
48 48
                 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
49 49
                 [
50
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
51
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
52
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
50
+                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
51
+                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
52
+                        : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
53 53
                 ],
54 54
                 $this
55 55
             )
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                             EE_Registry::instance()->CFG->map_settings->google_map_api_key
66 66
                         )
67 67
                     ),
68
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
68
+                    'ee_gmap'  => EE_HELPERS_ASSETS.'ee_gmap.js?ver=1.0',
69 69
                 ],
70 70
                 $this
71 71
             )
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -21,62 +21,62 @@
 block discarded – undo
21 21
  */
22 22
 class EventsArchiveIframe extends Iframe
23 23
 {
24
-    /**
25
-     * EventsArchiveIframe constructor.
26
-     *
27
-     * @param EED_Events_Archive $EED_Events_Archive
28
-     * @throws EE_Error
29
-     * @throws ReflectionException
30
-     */
31
-    public function __construct($EED_Events_Archive)
32
-    {
33
-        /** @var CurrentPage $current_page */
34
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
-        $current_page->setEspressoPage(true);
36
-        add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
-        $EED_Events_Archive->event_list();
38
-        /** @var EspressoEvents $event_list */
39
-        $event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
-        $shortcode_content = $event_list->processShortcode();
41
-        if (empty($shortcode_content)) {
42
-            return;
43
-        }
44
-        parent::__construct(
45
-            esc_html__('Event List', 'event_espresso'),
46
-            $shortcode_content
47
-        );
48
-        $this->addStylesheets(
49
-            apply_filters(
50
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
51
-                [
52
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
53
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
54
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
55
-                ],
56
-                $this
57
-            )
58
-        );
59
-        $this->addScripts(
60
-            apply_filters(
61
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
62
-                [
63
-                    'gmap_api' => sprintf(
64
-                        'https://maps.googleapis.com/maps/api/js?key=%s',
65
-                        apply_filters(
66
-                            'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
67
-                            EE_Registry::instance()->CFG->map_settings->google_map_api_key
68
-                        )
69
-                    ),
70
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
71
-                ],
72
-                $this
73
-            )
74
-        );
75
-        $this->addLocalizedVars(
76
-            [
77
-                'ee_gmap' => EEH_Maps::$gmap_vars,
78
-            ],
79
-            'ee_gmap_vars'
80
-        );
81
-    }
24
+	/**
25
+	 * EventsArchiveIframe constructor.
26
+	 *
27
+	 * @param EED_Events_Archive $EED_Events_Archive
28
+	 * @throws EE_Error
29
+	 * @throws ReflectionException
30
+	 */
31
+	public function __construct($EED_Events_Archive)
32
+	{
33
+		/** @var CurrentPage $current_page */
34
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
+		$current_page->setEspressoPage(true);
36
+		add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
+		$EED_Events_Archive->event_list();
38
+		/** @var EspressoEvents $event_list */
39
+		$event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
+		$shortcode_content = $event_list->processShortcode();
41
+		if (empty($shortcode_content)) {
42
+			return;
43
+		}
44
+		parent::__construct(
45
+			esc_html__('Event List', 'event_espresso'),
46
+			$shortcode_content
47
+		);
48
+		$this->addStylesheets(
49
+			apply_filters(
50
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
51
+				[
52
+					'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
53
+						? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
54
+						: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
55
+				],
56
+				$this
57
+			)
58
+		);
59
+		$this->addScripts(
60
+			apply_filters(
61
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
62
+				[
63
+					'gmap_api' => sprintf(
64
+						'https://maps.googleapis.com/maps/api/js?key=%s',
65
+						apply_filters(
66
+							'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
67
+							EE_Registry::instance()->CFG->map_settings->google_map_api_key
68
+						)
69
+					),
70
+					'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
71
+				],
72
+				$this
73
+			)
74
+		);
75
+		$this->addLocalizedVars(
76
+			[
77
+				'ee_gmap' => EEH_Maps::$gmap_vars,
78
+			],
79
+			'ee_gmap_vars'
80
+		);
81
+	}
82 82
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorSimple.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,6 +72,6 @@
 block discarded – undo
72 72
         }
73 73
         $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74 74
         $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
75
+            TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php';
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
  */
20 20
 class TicketSelectorSimple extends TicketSelector
21 21
 {
22
-    /**
23
-     * @var EE_Ticket $ticket
24
-     */
25
-    protected $ticket;
22
+	/**
23
+	 * @var EE_Ticket $ticket
24
+	 */
25
+	protected $ticket;
26 26
 
27 27
 
28
-    /**
29
-     * TicketSelectorSimple constructor.
30
-     *
31
-     * @param EE_Event  $event
32
-     * @param EE_Ticket $ticket
33
-     * @param int       $max_attendees
34
-     * @param array     $template_args
35
-     * @throws EE_Error
36
-     */
37
-    public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
-    {
39
-        $this->ticket = $ticket;
40
-        parent::__construct(
41
-            $event,
42
-            [$this->ticket],
43
-            $max_attendees,
44
-            $template_args
45
-        );
46
-    }
28
+	/**
29
+	 * TicketSelectorSimple constructor.
30
+	 *
31
+	 * @param EE_Event  $event
32
+	 * @param EE_Ticket $ticket
33
+	 * @param int       $max_attendees
34
+	 * @param array     $template_args
35
+	 * @throws EE_Error
36
+	 */
37
+	public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
+	{
39
+		$this->ticket = $ticket;
40
+		parent::__construct(
41
+			$event,
42
+			[$this->ticket],
43
+			$max_attendees,
44
+			$template_args
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * sets any and all template args that are required for this Ticket Selector
51
-     *
52
-     * @return void
53
-     * @throws UnexpectedEntityException
54
-     * @throws EE_Error
55
-     */
56
-    protected function addTemplateArgs()
57
-    {
58
-        $this->ticket_rows = 1;
59
-        unset($this->template_args['tickets']);
60
-        $this->template_args['ticket'] = $this->ticket;
61
-        $ticket_selector_row           = new TicketSelectorRowSimple(
62
-            $this->ticket,
63
-            $this->max_attendees,
64
-            $this->template_args['date_format'],
65
-            $this->template_args['event_status']
66
-        );
67
-        $this->template_args['TKT_ID'] = $this->ticket->ID();
68
-        $ticket_selector_row->setupTicketStatusDisplay();
69
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
-        if (empty($this->template_args['ticket_status_display'])) {
71
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
-        }
73
-        $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
-        $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
-    }
49
+	/**
50
+	 * sets any and all template args that are required for this Ticket Selector
51
+	 *
52
+	 * @return void
53
+	 * @throws UnexpectedEntityException
54
+	 * @throws EE_Error
55
+	 */
56
+	protected function addTemplateArgs()
57
+	{
58
+		$this->ticket_rows = 1;
59
+		unset($this->template_args['tickets']);
60
+		$this->template_args['ticket'] = $this->ticket;
61
+		$ticket_selector_row           = new TicketSelectorRowSimple(
62
+			$this->ticket,
63
+			$this->max_attendees,
64
+			$this->template_args['date_format'],
65
+			$this->template_args['event_status']
66
+		);
67
+		$this->template_args['TKT_ID'] = $this->ticket->ID();
68
+		$ticket_selector_row->setupTicketStatusDisplay();
69
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
+		if (empty($this->template_args['ticket_status_display'])) {
71
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
+		}
73
+		$this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
+		$this->template_args['template_path']      =
75
+			TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
+	}
77 77
 }
Please login to merge, or discard this patch.