Completed
Branch fix/escaping-2 (5dcb9a)
by
unknown
13:02 queued 10:26
created
core/services/request/Response.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@
 block discarded – undo
15 15
 class Response implements ResponseInterface, ReservedInstanceInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var array $notice
20
-     */
21
-    protected $notice = [];
22
-
23
-    /**
24
-     * rendered output to be returned to WP
25
-     *
26
-     * @var array
27
-     */
28
-    protected $output = [];
29
-
30
-    /**
31
-     * @var bool
32
-     */
33
-    protected $request_terminated = false;
34
-
35
-    /**
36
-     * @var bool $deactivate_plugin
37
-     */
38
-    protected $deactivate_plugin = false;
39
-
40
-
41
-    /**
42
-     * EE_Response constructor.
43
-     */
44
-    public function __construct()
45
-    {
46
-        $this->terminateRequest(false);
47
-    }
48
-
49
-
50
-    /**
51
-     * @param $key
52
-     * @param $value
53
-     * @return    void
54
-     */
55
-    public function setNotice($key, $value)
56
-    {
57
-        $this->notice[ $key ] = $value;
58
-    }
59
-
60
-
61
-    /**
62
-     * @param $key
63
-     * @return    mixed
64
-     */
65
-    public function getNotice($key)
66
-    {
67
-        return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
68
-    }
69
-
70
-
71
-    /**
72
-     * @return array
73
-     */
74
-    public function getNotices()
75
-    {
76
-        return $this->notice;
77
-    }
78
-
79
-
80
-    /**
81
-     * @param string $string
82
-     * @param bool   $append
83
-     */
84
-    public function addOutput($string, $append = true)
85
-    {
86
-        if ($append) {
87
-            $this->output[] = $string;
88
-            return;
89
-        }
90
-        array_unshift($this->output, $string);
91
-    }
92
-
93
-
94
-    /**
95
-     * @param bool   $as_string
96
-     * @param string $separator
97
-     * @return array|string
98
-     */
99
-    public function getOutput($as_string = true, $separator = PHP_EOL)
100
-    {
101
-        return $as_string ? implode($separator, $this->output) : $this->output ;
102
-    }
103
-
104
-
105
-    /**
106
-     * @return boolean
107
-     */
108
-    public function requestTerminated()
109
-    {
110
-        return $this->request_terminated;
111
-    }
112
-
113
-
114
-    /**
115
-     * @param boolean $request_terminated
116
-     */
117
-    public function terminateRequest($request_terminated = true)
118
-    {
119
-        $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
120
-    }
121
-
122
-
123
-    /**
124
-     * @return boolean
125
-     */
126
-    public function pluginDeactivated()
127
-    {
128
-        return $this->deactivate_plugin;
129
-    }
130
-
131
-
132
-    /**
133
-     * sets $deactivate_plugin to true
134
-     */
135
-    public function deactivatePlugin()
136
-    {
137
-        $this->deactivate_plugin = true;
138
-    }
18
+	/**
19
+	 * @var array $notice
20
+	 */
21
+	protected $notice = [];
22
+
23
+	/**
24
+	 * rendered output to be returned to WP
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $output = [];
29
+
30
+	/**
31
+	 * @var bool
32
+	 */
33
+	protected $request_terminated = false;
34
+
35
+	/**
36
+	 * @var bool $deactivate_plugin
37
+	 */
38
+	protected $deactivate_plugin = false;
39
+
40
+
41
+	/**
42
+	 * EE_Response constructor.
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$this->terminateRequest(false);
47
+	}
48
+
49
+
50
+	/**
51
+	 * @param $key
52
+	 * @param $value
53
+	 * @return    void
54
+	 */
55
+	public function setNotice($key, $value)
56
+	{
57
+		$this->notice[ $key ] = $value;
58
+	}
59
+
60
+
61
+	/**
62
+	 * @param $key
63
+	 * @return    mixed
64
+	 */
65
+	public function getNotice($key)
66
+	{
67
+		return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
68
+	}
69
+
70
+
71
+	/**
72
+	 * @return array
73
+	 */
74
+	public function getNotices()
75
+	{
76
+		return $this->notice;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param string $string
82
+	 * @param bool   $append
83
+	 */
84
+	public function addOutput($string, $append = true)
85
+	{
86
+		if ($append) {
87
+			$this->output[] = $string;
88
+			return;
89
+		}
90
+		array_unshift($this->output, $string);
91
+	}
92
+
93
+
94
+	/**
95
+	 * @param bool   $as_string
96
+	 * @param string $separator
97
+	 * @return array|string
98
+	 */
99
+	public function getOutput($as_string = true, $separator = PHP_EOL)
100
+	{
101
+		return $as_string ? implode($separator, $this->output) : $this->output ;
102
+	}
103
+
104
+
105
+	/**
106
+	 * @return boolean
107
+	 */
108
+	public function requestTerminated()
109
+	{
110
+		return $this->request_terminated;
111
+	}
112
+
113
+
114
+	/**
115
+	 * @param boolean $request_terminated
116
+	 */
117
+	public function terminateRequest($request_terminated = true)
118
+	{
119
+		$this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN);
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return boolean
125
+	 */
126
+	public function pluginDeactivated()
127
+	{
128
+		return $this->deactivate_plugin;
129
+	}
130
+
131
+
132
+	/**
133
+	 * sets $deactivate_plugin to true
134
+	 */
135
+	public function deactivatePlugin()
136
+	{
137
+		$this->deactivate_plugin = true;
138
+	}
139 139
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function setNotice($key, $value)
56 56
     {
57
-        $this->notice[ $key ] = $value;
57
+        $this->notice[$key] = $value;
58 58
     }
59 59
 
60 60
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getNotice($key)
66 66
     {
67
-        return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null;
67
+        return isset($this->notice[$key]) ? $this->notice[$key] : null;
68 68
     }
69 69
 
70 70
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function getOutput($as_string = true, $separator = PHP_EOL)
100 100
     {
101
-        return $as_string ? implode($separator, $this->output) : $this->output ;
101
+        return $as_string ? implode($separator, $this->output) : $this->output;
102 102
     }
103 103
 
104 104
 
Please login to merge, or discard this patch.
core/services/container/Mirror.php 2 patches
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -21,268 +21,268 @@
 block discarded – undo
21 21
 class Mirror
22 22
 {
23 23
 
24
-    /**
25
-     * @var ReflectionClass[] $classes
26
-     */
27
-    private $classes = [];
28
-
29
-    /**
30
-     * @var ReflectionMethod[] $constructors
31
-     */
32
-    private $constructors = [];
33
-
34
-    /**
35
-     * @var ReflectionParameter[][] $parameters
36
-     */
37
-    private $parameters = [];
38
-
39
-    /**
40
-     * @var ReflectionParameter[][] $parameters
41
-     */
42
-    private $parameter_classes = [];
43
-
44
-    /**
45
-     * @var ReflectionProperty[][] $properties
46
-     */
47
-    private $properties = [];
48
-
49
-    /**
50
-     * @var ReflectionMethod[][] $methods
51
-     */
52
-    private $methods = [];
53
-
54
-
55
-    /**
56
-     * @param string $class_name
57
-     * @return ReflectionClass
58
-     * @throws ReflectionException
59
-     * @throws InvalidDataTypeException
60
-     */
61
-    public function getReflectionClass($class_name)
62
-    {
63
-        if (! is_string($class_name)) {
64
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65
-        }
66
-        if (! isset($this->classes[ $class_name ])) {
67
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
68
-        }
69
-        return $this->classes[ $class_name ];
70
-    }
71
-
72
-
73
-    /**
74
-     * @param string $class_name
75
-     * @return ReflectionMethod
76
-     * @throws InvalidDataTypeException
77
-     * @throws ReflectionException
78
-     */
79
-    public function getConstructor($class_name)
80
-    {
81
-        if (! is_string($class_name)) {
82
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83
-        }
84
-        if (! isset($this->constructors[ $class_name ])) {
85
-            $reflection_class                  = $this->getReflectionClass($class_name);
86
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
87
-        }
88
-        return $this->constructors[ $class_name ];
89
-    }
90
-
91
-
92
-    /**
93
-     * @param ReflectionClass $reflection_class
94
-     * @return ReflectionMethod
95
-     * @throws InvalidDataTypeException
96
-     * @throws ReflectionException
97
-     */
98
-    public function getConstructorFromReflection(ReflectionClass $reflection_class)
99
-    {
100
-        return $this->getConstructor($reflection_class->getName());
101
-    }
102
-
103
-
104
-    /**
105
-     * @param string $class_name
106
-     * @return ReflectionParameter[]
107
-     * @throws InvalidDataTypeException
108
-     * @throws ReflectionException
109
-     */
110
-    public function getParameters($class_name)
111
-    {
112
-        if (! isset($this->parameters[ $class_name ])) {
113
-            $constructor                     = $this->getConstructor($class_name);
114
-            $this->parameters[ $class_name ] = $constructor->getParameters();
115
-        }
116
-        return $this->parameters[ $class_name ];
117
-    }
118
-
119
-
120
-    /**
121
-     * @param ReflectionClass $reflection_class
122
-     * @return ReflectionParameter[]
123
-     * @throws InvalidDataTypeException
124
-     * @throws ReflectionException
125
-     */
126
-    public function getParametersFromReflection(ReflectionClass $reflection_class)
127
-    {
128
-        return $this->getParameters($reflection_class->getName());
129
-    }
130
-
131
-
132
-    /**
133
-     * @param ReflectionMethod $constructor
134
-     * @return ReflectionParameter[]
135
-     * @throws InvalidDataTypeException
136
-     * @throws ReflectionException
137
-     */
138
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
139
-    {
140
-        return $this->getParameters($constructor->getDeclaringClass());
141
-    }
142
-
143
-
144
-    /**
145
-     * @param ReflectionParameter $param
146
-     * @param string              $class_name
147
-     * @param string              $index
148
-     * @return string|null
149
-     */
150
-    public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151
-    {
152
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
154
-        }
155
-        if (! isset($this->parameter_classes[ $class_name ])) {
156
-            $this->parameter_classes[ $class_name ] = [];
157
-        }
158
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
-            $this->parameter_classes[ $class_name ][ $index ] = [];
160
-        }
161
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
162
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
163
-            ? $this->getParameterClassNameLegacy($param)
164
-            : $this->getParameterClassNamePhp8($param);
165
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
166
-    }
167
-
168
-
169
-    /**
170
-     * @param ReflectionParameter $param
171
-     * @return string|null
172
-     * @since   4.10.13.p
173
-     */
174
-    private function getParameterClassNameLegacy(ReflectionParameter $param)
175
-    {
176
-        $reflection_class = $param->getClass();
177
-        return $reflection_class instanceof ReflectionClass
178
-            ? $reflection_class->getName()
179
-            : null;
180
-    }
181
-
182
-
183
-    /**
184
-     * ReflectionParameter::getClass() is deprecated in PHP 8+,
185
-     * so the class name for a parameter needs to be extracted from the ReflectionType,
186
-     * which can either be a ReflectionNamedType or ReflectionUnionType
187
-     *
188
-     * @param ReflectionParameter $param
189
-     * @return null
190
-     * @since   4.10.13.p
191
-     */
192
-    private function getParameterClassNamePhp8(ReflectionParameter $param)
193
-    {
194
-        $reflection_type = $param->getType();
195
-        if ($reflection_type instanceof \ReflectionNamedType) {
196
-            return $reflection_type->getName();
197
-        }
198
-        if ($reflection_type instanceof \ReflectionUnionType) {
199
-            $reflection_types = $reflection_type->getTypes();
200
-            if (is_array($reflection_types)) {
201
-                $first = reset($reflection_types);
202
-                return $first->getName();
203
-            }
204
-        }
205
-        return null;
206
-    }
207
-
208
-
209
-    /**
210
-     * @param ReflectionParameter $param
211
-     * @param string              $class_name
212
-     * @param string              $index
213
-     * @return string|null
214
-     * @throws ReflectionException
215
-     */
216
-    public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
217
-    {
218
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
219
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
220
-        }
221
-        if (! isset($this->parameter_classes[ $class_name ])) {
222
-            $this->parameter_classes[ $class_name ] = [];
223
-        }
224
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
225
-            $this->parameter_classes[ $class_name ][ $index ] = [];
226
-        }
227
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
228
-            ? $param->getDefaultValue()
229
-            : null;
230
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
231
-    }
232
-
233
-
234
-    /**
235
-     * @param string $class_name
236
-     * @return ReflectionProperty[]
237
-     * @throws InvalidDataTypeException
238
-     * @throws ReflectionException
239
-     */
240
-    public function getProperties($class_name)
241
-    {
242
-        if (! isset($this->properties[ $class_name ])) {
243
-            $reflection_class                = $this->getReflectionClass($class_name);
244
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
245
-        }
246
-        return $this->properties[ $class_name ];
247
-    }
248
-
249
-
250
-    /**
251
-     * @param ReflectionClass $reflection_class
252
-     * @return ReflectionProperty[]
253
-     * @throws InvalidDataTypeException
254
-     * @throws ReflectionException
255
-     */
256
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class)
257
-    {
258
-        return $this->getProperties($reflection_class->getName());
259
-    }
260
-
261
-
262
-    /**
263
-     * @param string $class_name
264
-     * @return ReflectionMethod[]
265
-     * @throws InvalidDataTypeException
266
-     * @throws ReflectionException
267
-     */
268
-    public function getMethods($class_name)
269
-    {
270
-        if (! isset($this->methods[ $class_name ])) {
271
-            $reflection_class             = $this->getReflectionClass($class_name);
272
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
273
-        }
274
-        return $this->methods[ $class_name ];
275
-    }
276
-
277
-
278
-    /**
279
-     * @param ReflectionClass $reflection_class )
280
-     * @return ReflectionMethod[]
281
-     * @throws InvalidDataTypeException
282
-     * @throws ReflectionException
283
-     */
284
-    public function getMethodsFromReflection(ReflectionClass $reflection_class)
285
-    {
286
-        return $this->getMethods($reflection_class->getName());
287
-    }
24
+	/**
25
+	 * @var ReflectionClass[] $classes
26
+	 */
27
+	private $classes = [];
28
+
29
+	/**
30
+	 * @var ReflectionMethod[] $constructors
31
+	 */
32
+	private $constructors = [];
33
+
34
+	/**
35
+	 * @var ReflectionParameter[][] $parameters
36
+	 */
37
+	private $parameters = [];
38
+
39
+	/**
40
+	 * @var ReflectionParameter[][] $parameters
41
+	 */
42
+	private $parameter_classes = [];
43
+
44
+	/**
45
+	 * @var ReflectionProperty[][] $properties
46
+	 */
47
+	private $properties = [];
48
+
49
+	/**
50
+	 * @var ReflectionMethod[][] $methods
51
+	 */
52
+	private $methods = [];
53
+
54
+
55
+	/**
56
+	 * @param string $class_name
57
+	 * @return ReflectionClass
58
+	 * @throws ReflectionException
59
+	 * @throws InvalidDataTypeException
60
+	 */
61
+	public function getReflectionClass($class_name)
62
+	{
63
+		if (! is_string($class_name)) {
64
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65
+		}
66
+		if (! isset($this->classes[ $class_name ])) {
67
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
68
+		}
69
+		return $this->classes[ $class_name ];
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param string $class_name
75
+	 * @return ReflectionMethod
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function getConstructor($class_name)
80
+	{
81
+		if (! is_string($class_name)) {
82
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83
+		}
84
+		if (! isset($this->constructors[ $class_name ])) {
85
+			$reflection_class                  = $this->getReflectionClass($class_name);
86
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
87
+		}
88
+		return $this->constructors[ $class_name ];
89
+	}
90
+
91
+
92
+	/**
93
+	 * @param ReflectionClass $reflection_class
94
+	 * @return ReflectionMethod
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws ReflectionException
97
+	 */
98
+	public function getConstructorFromReflection(ReflectionClass $reflection_class)
99
+	{
100
+		return $this->getConstructor($reflection_class->getName());
101
+	}
102
+
103
+
104
+	/**
105
+	 * @param string $class_name
106
+	 * @return ReflectionParameter[]
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws ReflectionException
109
+	 */
110
+	public function getParameters($class_name)
111
+	{
112
+		if (! isset($this->parameters[ $class_name ])) {
113
+			$constructor                     = $this->getConstructor($class_name);
114
+			$this->parameters[ $class_name ] = $constructor->getParameters();
115
+		}
116
+		return $this->parameters[ $class_name ];
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param ReflectionClass $reflection_class
122
+	 * @return ReflectionParameter[]
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws ReflectionException
125
+	 */
126
+	public function getParametersFromReflection(ReflectionClass $reflection_class)
127
+	{
128
+		return $this->getParameters($reflection_class->getName());
129
+	}
130
+
131
+
132
+	/**
133
+	 * @param ReflectionMethod $constructor
134
+	 * @return ReflectionParameter[]
135
+	 * @throws InvalidDataTypeException
136
+	 * @throws ReflectionException
137
+	 */
138
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
139
+	{
140
+		return $this->getParameters($constructor->getDeclaringClass());
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param ReflectionParameter $param
146
+	 * @param string              $class_name
147
+	 * @param string              $index
148
+	 * @return string|null
149
+	 */
150
+	public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151
+	{
152
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
154
+		}
155
+		if (! isset($this->parameter_classes[ $class_name ])) {
156
+			$this->parameter_classes[ $class_name ] = [];
157
+		}
158
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
+			$this->parameter_classes[ $class_name ][ $index ] = [];
160
+		}
161
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
162
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
163
+			? $this->getParameterClassNameLegacy($param)
164
+			: $this->getParameterClassNamePhp8($param);
165
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param ReflectionParameter $param
171
+	 * @return string|null
172
+	 * @since   4.10.13.p
173
+	 */
174
+	private function getParameterClassNameLegacy(ReflectionParameter $param)
175
+	{
176
+		$reflection_class = $param->getClass();
177
+		return $reflection_class instanceof ReflectionClass
178
+			? $reflection_class->getName()
179
+			: null;
180
+	}
181
+
182
+
183
+	/**
184
+	 * ReflectionParameter::getClass() is deprecated in PHP 8+,
185
+	 * so the class name for a parameter needs to be extracted from the ReflectionType,
186
+	 * which can either be a ReflectionNamedType or ReflectionUnionType
187
+	 *
188
+	 * @param ReflectionParameter $param
189
+	 * @return null
190
+	 * @since   4.10.13.p
191
+	 */
192
+	private function getParameterClassNamePhp8(ReflectionParameter $param)
193
+	{
194
+		$reflection_type = $param->getType();
195
+		if ($reflection_type instanceof \ReflectionNamedType) {
196
+			return $reflection_type->getName();
197
+		}
198
+		if ($reflection_type instanceof \ReflectionUnionType) {
199
+			$reflection_types = $reflection_type->getTypes();
200
+			if (is_array($reflection_types)) {
201
+				$first = reset($reflection_types);
202
+				return $first->getName();
203
+			}
204
+		}
205
+		return null;
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param ReflectionParameter $param
211
+	 * @param string              $class_name
212
+	 * @param string              $index
213
+	 * @return string|null
214
+	 * @throws ReflectionException
215
+	 */
216
+	public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
217
+	{
218
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
219
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
220
+		}
221
+		if (! isset($this->parameter_classes[ $class_name ])) {
222
+			$this->parameter_classes[ $class_name ] = [];
223
+		}
224
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
225
+			$this->parameter_classes[ $class_name ][ $index ] = [];
226
+		}
227
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
228
+			? $param->getDefaultValue()
229
+			: null;
230
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
231
+	}
232
+
233
+
234
+	/**
235
+	 * @param string $class_name
236
+	 * @return ReflectionProperty[]
237
+	 * @throws InvalidDataTypeException
238
+	 * @throws ReflectionException
239
+	 */
240
+	public function getProperties($class_name)
241
+	{
242
+		if (! isset($this->properties[ $class_name ])) {
243
+			$reflection_class                = $this->getReflectionClass($class_name);
244
+			$this->properties[ $class_name ] = $reflection_class->getProperties();
245
+		}
246
+		return $this->properties[ $class_name ];
247
+	}
248
+
249
+
250
+	/**
251
+	 * @param ReflectionClass $reflection_class
252
+	 * @return ReflectionProperty[]
253
+	 * @throws InvalidDataTypeException
254
+	 * @throws ReflectionException
255
+	 */
256
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class)
257
+	{
258
+		return $this->getProperties($reflection_class->getName());
259
+	}
260
+
261
+
262
+	/**
263
+	 * @param string $class_name
264
+	 * @return ReflectionMethod[]
265
+	 * @throws InvalidDataTypeException
266
+	 * @throws ReflectionException
267
+	 */
268
+	public function getMethods($class_name)
269
+	{
270
+		if (! isset($this->methods[ $class_name ])) {
271
+			$reflection_class             = $this->getReflectionClass($class_name);
272
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
273
+		}
274
+		return $this->methods[ $class_name ];
275
+	}
276
+
277
+
278
+	/**
279
+	 * @param ReflectionClass $reflection_class )
280
+	 * @return ReflectionMethod[]
281
+	 * @throws InvalidDataTypeException
282
+	 * @throws ReflectionException
283
+	 */
284
+	public function getMethodsFromReflection(ReflectionClass $reflection_class)
285
+	{
286
+		return $this->getMethods($reflection_class->getName());
287
+	}
288 288
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getReflectionClass($class_name)
62 62
     {
63
-        if (! is_string($class_name)) {
63
+        if ( ! is_string($class_name)) {
64 64
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65 65
         }
66
-        if (! isset($this->classes[ $class_name ])) {
67
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
66
+        if ( ! isset($this->classes[$class_name])) {
67
+            $this->classes[$class_name] = new ReflectionClass($class_name);
68 68
         }
69
-        return $this->classes[ $class_name ];
69
+        return $this->classes[$class_name];
70 70
     }
71 71
 
72 72
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getConstructor($class_name)
80 80
     {
81
-        if (! is_string($class_name)) {
81
+        if ( ! is_string($class_name)) {
82 82
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83 83
         }
84
-        if (! isset($this->constructors[ $class_name ])) {
84
+        if ( ! isset($this->constructors[$class_name])) {
85 85
             $reflection_class                  = $this->getReflectionClass($class_name);
86
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
86
+            $this->constructors[$class_name] = $reflection_class->getConstructor();
87 87
         }
88
-        return $this->constructors[ $class_name ];
88
+        return $this->constructors[$class_name];
89 89
     }
90 90
 
91 91
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getParameters($class_name)
111 111
     {
112
-        if (! isset($this->parameters[ $class_name ])) {
112
+        if ( ! isset($this->parameters[$class_name])) {
113 113
             $constructor                     = $this->getConstructor($class_name);
114
-            $this->parameters[ $class_name ] = $constructor->getParameters();
114
+            $this->parameters[$class_name] = $constructor->getParameters();
115 115
         }
116
-        return $this->parameters[ $class_name ];
116
+        return $this->parameters[$class_name];
117 117
     }
118 118
 
119 119
 
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151 151
     {
152
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
152
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) {
153
+            return $this->parameter_classes[$class_name][$index]['param_class_name'];
154 154
         }
155
-        if (! isset($this->parameter_classes[ $class_name ])) {
156
-            $this->parameter_classes[ $class_name ] = [];
155
+        if ( ! isset($this->parameter_classes[$class_name])) {
156
+            $this->parameter_classes[$class_name] = [];
157 157
         }
158
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
-            $this->parameter_classes[ $class_name ][ $index ] = [];
158
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
159
+            $this->parameter_classes[$class_name][$index] = [];
160 160
         }
161 161
         // ReflectionParameter::getClass() is deprecated in PHP 8+
162
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
162
+        $this->parameter_classes[$class_name][$index]['param_class_name'] = PHP_VERSION_ID < 70100
163 163
             ? $this->getParameterClassNameLegacy($param)
164 164
             : $this->getParameterClassNamePhp8($param);
165
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
165
+        return $this->parameter_classes[$class_name][$index]['param_class_name'];
166 166
     }
167 167
 
168 168
 
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
217 217
     {
218
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
219
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) {
219
+            return $this->parameter_classes[$class_name][$index]['param_class_default'];
220 220
         }
221
-        if (! isset($this->parameter_classes[ $class_name ])) {
222
-            $this->parameter_classes[ $class_name ] = [];
221
+        if ( ! isset($this->parameter_classes[$class_name])) {
222
+            $this->parameter_classes[$class_name] = [];
223 223
         }
224
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
225
-            $this->parameter_classes[ $class_name ][ $index ] = [];
224
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
225
+            $this->parameter_classes[$class_name][$index] = [];
226 226
         }
227
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
227
+        $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable()
228 228
             ? $param->getDefaultValue()
229 229
             : null;
230
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
230
+        return $this->parameter_classes[$class_name][$index]['param_class_default'];
231 231
     }
232 232
 
233 233
 
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function getProperties($class_name)
241 241
     {
242
-        if (! isset($this->properties[ $class_name ])) {
242
+        if ( ! isset($this->properties[$class_name])) {
243 243
             $reflection_class                = $this->getReflectionClass($class_name);
244
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
244
+            $this->properties[$class_name] = $reflection_class->getProperties();
245 245
         }
246
-        return $this->properties[ $class_name ];
246
+        return $this->properties[$class_name];
247 247
     }
248 248
 
249 249
 
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function getMethods($class_name)
269 269
     {
270
-        if (! isset($this->methods[ $class_name ])) {
270
+        if ( ! isset($this->methods[$class_name])) {
271 271
             $reflection_class             = $this->getReflectionClass($class_name);
272
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
272
+            $this->methods[$class_name] = $reflection_class->getMethods();
273 273
         }
274
-        return $this->methods[ $class_name ];
274
+        return $this->methods[$class_name];
275 275
     }
276 276
 
277 277
 
Please login to merge, or discard this patch.
core/services/loaders/ClassInterfaceCache.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $fqn = $this->getFqn($fqn);
51 51
         // have we already seen this FQCN ?
52
-        if (! array_key_exists($fqn, $this->interfaces)) {
53
-            $this->interfaces[ $fqn ] = array();
52
+        if ( ! array_key_exists($fqn, $this->interfaces)) {
53
+            $this->interfaces[$fqn] = array();
54 54
             if (class_exists($fqn)) {
55
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
56
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
-                    ? $this->interfaces[ $fqn ]
55
+                $this->interfaces[$fqn] = class_implements($fqn, false);
56
+                $this->interfaces[$fqn] = $this->interfaces[$fqn] !== false
57
+                    ? $this->interfaces[$fqn]
58 58
                     : array();
59 59
             }
60 60
         }
61
-        return $this->interfaces[ $fqn ];
61
+        return $this->interfaces[$fqn];
62 62
     }
63 63
 
64 64
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
         // are we adding an alias for a specific class?
94 94
         if ($for_class !== '') {
95 95
             // make sure it's set up as an array
96
-            if (! isset($this->aliases[ $for_class ])) {
97
-                $this->aliases[ $for_class ] = array();
96
+            if ( ! isset($this->aliases[$for_class])) {
97
+                $this->aliases[$for_class] = array();
98 98
             }
99
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
99
+            $this->aliases[$for_class][$alias] = $fqn;
100 100
             return;
101 101
         }
102
-        $this->aliases[ $alias ] = $fqn;
102
+        $this->aliases[$alias] = $fqn;
103 103
     }
104 104
 
105 105
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function isDirectAlias($fqn = '')
133 133
     {
134
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
134
+        return isset($this->aliases[(string) $fqn]) && ! is_array($this->aliases[(string) $fqn]);
135 135
     }
136 136
 
137 137
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         return (
148 148
             $for_class !== ''
149
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
149
+            && isset($this->aliases[(string) $for_class][(string) $fqn])
150 150
         );
151 151
     }
152 152
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
     {
172 172
         $alias = $this->getFqn($alias);
173 173
         if ($this->isAliasForClass($alias, $for_class)) {
174
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
174
+            return $this->getFqnForAlias($this->aliases[(string) $for_class][(string) $alias], $for_class);
175 175
         }
176 176
         if ($this->isDirectAlias($alias)) {
177 177
             // note: changed '' to $for_class
178
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
178
+            return $this->getFqnForAlias($this->aliases[(string) $alias], $for_class);
179 179
         }
180 180
         return $alias;
181 181
     }
Please login to merge, or discard this patch.
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -17,180 +17,180 @@
 block discarded – undo
17 17
 class ClassInterfaceCache
18 18
 {
19 19
 
20
-    /**
21
-     * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
22
-     *
23
-     * @var string[][] $interfaces
24
-     */
25
-    private $interfaces = array();
26
-
27
-    /**
28
-     * @type string[][] $aliases
29
-     */
30
-    protected $aliases = array();
31
-
32
-
33
-    /**
34
-     * @param string $fqn
35
-     * @return string
36
-     */
37
-    public function getFqn($fqn)
38
-    {
39
-        $fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
40
-        return ltrim($fqn, '\\');
41
-    }
42
-
43
-
44
-    /**
45
-     * @param string $fqn
46
-     * @return array
47
-     */
48
-    public function getInterfaces($fqn)
49
-    {
50
-        $fqn = $this->getFqn($fqn);
51
-        // have we already seen this FQCN ?
52
-        if (! array_key_exists($fqn, $this->interfaces)) {
53
-            $this->interfaces[ $fqn ] = array();
54
-            if (class_exists($fqn)) {
55
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
56
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
-                    ? $this->interfaces[ $fqn ]
58
-                    : array();
59
-            }
60
-        }
61
-        return $this->interfaces[ $fqn ];
62
-    }
63
-
64
-
65
-    /**
66
-     * @param string $fqn
67
-     * @param string $interface
68
-     * @return bool
69
-     */
70
-    public function hasInterface($fqn, $interface)
71
-    {
72
-        $fqn        = $this->getFqn($fqn);
73
-        $interfaces = $this->getInterfaces($fqn);
74
-        return in_array($interface, $interfaces, true);
75
-    }
76
-
77
-
78
-    /**
79
-     * adds an alias for a classname
80
-     *
81
-     * @param string $fqn       the class name that should be used (concrete class to replace interface)
82
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
83
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
84
-     * @throws InvalidAliasException
85
-     */
86
-    public function addAlias($fqn, $alias, $for_class = '')
87
-    {
88
-        $fqn   = $this->getFqn($fqn);
89
-        $alias = $this->getFqn($alias);
90
-        if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
91
-            throw new InvalidAliasException($fqn, $alias);
92
-        }
93
-        // are we adding an alias for a specific class?
94
-        if ($for_class !== '') {
95
-            // make sure it's set up as an array
96
-            if (! isset($this->aliases[ $for_class ])) {
97
-                $this->aliases[ $for_class ] = array();
98
-            }
99
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
100
-            return;
101
-        }
102
-        $this->aliases[ $alias ] = $fqn;
103
-    }
104
-
105
-
106
-    /**
107
-     * returns TRUE if the provided FQN is an alias
108
-     *
109
-     * @param string $fqn
110
-     * @param string $for_class
111
-     * @return bool
112
-     */
113
-    public function isAlias($fqn = '', $for_class = '')
114
-    {
115
-        $fqn = $this->getFqn($fqn);
116
-        if ($this->isAliasForClass($fqn, $for_class)) {
117
-            return true;
118
-        }
119
-        if ($this->isDirectAlias($fqn)) {
120
-            return true;
121
-        }
122
-        return false;
123
-    }
124
-
125
-
126
-    /**
127
-     * returns TRUE if the provided FQN is an alias
128
-     *
129
-     * @param string $fqn
130
-     * @return bool
131
-     */
132
-    protected function isDirectAlias($fqn = '')
133
-    {
134
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
135
-    }
136
-
137
-
138
-    /**
139
-     * returns TRUE if the provided FQN is an alias for the specified class
140
-     *
141
-     * @param string $fqn
142
-     * @param string $for_class
143
-     * @return bool
144
-     */
145
-    protected function isAliasForClass($fqn = '', $for_class = '')
146
-    {
147
-        return (
148
-            $for_class !== ''
149
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     * returns FQN for provided alias if one exists, otherwise returns the original FQN
156
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
157
-     *  for example:
158
-     *      if the following two entries were added to the aliases array:
159
-     *          array(
160
-     *              'interface_alias'           => 'some\namespace\interface'
161
-     *              'some\namespace\interface'  => 'some\namespace\classname'
162
-     *          )
163
-     *      then one could use Loader::getNew( 'interface_alias' )
164
-     *      to load an instance of 'some\namespace\classname'
165
-     *
166
-     * @param string $alias
167
-     * @param string $for_class
168
-     * @return string
169
-     */
170
-    public function getFqnForAlias($alias = '', $for_class = '')
171
-    {
172
-        $alias = $this->getFqn($alias);
173
-        if ($this->isAliasForClass($alias, $for_class)) {
174
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
175
-        }
176
-        if ($this->isDirectAlias($alias)) {
177
-            // note: changed '' to $for_class
178
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
179
-        }
180
-        return $alias;
181
-    }
182
-
183
-
184
-    // public function debug($for_class = '')
185
-    // {
186
-    //     if ($for_class !== '') {
187
-    //         if ( ! isset($this->aliases[ $for_class ])) {
188
-    //             \EEH_Debug_Tools::printr('NOT FOUND', "aliases[ $for_class ]", __FILE__, __LINE__);
189
-    //             return;
190
-    //         }
191
-    //         \EEH_Debug_Tools::printr($this->aliases[ $for_class ], "aliases[ $for_class ]", __FILE__, __LINE__);
192
-    //         return;
193
-    //     }
194
-    //     \EEH_Debug_Tools::printr($this->aliases, '$this->aliases', __FILE__, __LINE__);
195
-    // }
20
+	/**
21
+	 * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
22
+	 *
23
+	 * @var string[][] $interfaces
24
+	 */
25
+	private $interfaces = array();
26
+
27
+	/**
28
+	 * @type string[][] $aliases
29
+	 */
30
+	protected $aliases = array();
31
+
32
+
33
+	/**
34
+	 * @param string $fqn
35
+	 * @return string
36
+	 */
37
+	public function getFqn($fqn)
38
+	{
39
+		$fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
40
+		return ltrim($fqn, '\\');
41
+	}
42
+
43
+
44
+	/**
45
+	 * @param string $fqn
46
+	 * @return array
47
+	 */
48
+	public function getInterfaces($fqn)
49
+	{
50
+		$fqn = $this->getFqn($fqn);
51
+		// have we already seen this FQCN ?
52
+		if (! array_key_exists($fqn, $this->interfaces)) {
53
+			$this->interfaces[ $fqn ] = array();
54
+			if (class_exists($fqn)) {
55
+				$this->interfaces[ $fqn ] = class_implements($fqn, false);
56
+				$this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
+					? $this->interfaces[ $fqn ]
58
+					: array();
59
+			}
60
+		}
61
+		return $this->interfaces[ $fqn ];
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param string $fqn
67
+	 * @param string $interface
68
+	 * @return bool
69
+	 */
70
+	public function hasInterface($fqn, $interface)
71
+	{
72
+		$fqn        = $this->getFqn($fqn);
73
+		$interfaces = $this->getInterfaces($fqn);
74
+		return in_array($interface, $interfaces, true);
75
+	}
76
+
77
+
78
+	/**
79
+	 * adds an alias for a classname
80
+	 *
81
+	 * @param string $fqn       the class name that should be used (concrete class to replace interface)
82
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
83
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
84
+	 * @throws InvalidAliasException
85
+	 */
86
+	public function addAlias($fqn, $alias, $for_class = '')
87
+	{
88
+		$fqn   = $this->getFqn($fqn);
89
+		$alias = $this->getFqn($alias);
90
+		if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
91
+			throw new InvalidAliasException($fqn, $alias);
92
+		}
93
+		// are we adding an alias for a specific class?
94
+		if ($for_class !== '') {
95
+			// make sure it's set up as an array
96
+			if (! isset($this->aliases[ $for_class ])) {
97
+				$this->aliases[ $for_class ] = array();
98
+			}
99
+			$this->aliases[ $for_class ][ $alias ] = $fqn;
100
+			return;
101
+		}
102
+		$this->aliases[ $alias ] = $fqn;
103
+	}
104
+
105
+
106
+	/**
107
+	 * returns TRUE if the provided FQN is an alias
108
+	 *
109
+	 * @param string $fqn
110
+	 * @param string $for_class
111
+	 * @return bool
112
+	 */
113
+	public function isAlias($fqn = '', $for_class = '')
114
+	{
115
+		$fqn = $this->getFqn($fqn);
116
+		if ($this->isAliasForClass($fqn, $for_class)) {
117
+			return true;
118
+		}
119
+		if ($this->isDirectAlias($fqn)) {
120
+			return true;
121
+		}
122
+		return false;
123
+	}
124
+
125
+
126
+	/**
127
+	 * returns TRUE if the provided FQN is an alias
128
+	 *
129
+	 * @param string $fqn
130
+	 * @return bool
131
+	 */
132
+	protected function isDirectAlias($fqn = '')
133
+	{
134
+		return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
135
+	}
136
+
137
+
138
+	/**
139
+	 * returns TRUE if the provided FQN is an alias for the specified class
140
+	 *
141
+	 * @param string $fqn
142
+	 * @param string $for_class
143
+	 * @return bool
144
+	 */
145
+	protected function isAliasForClass($fqn = '', $for_class = '')
146
+	{
147
+		return (
148
+			$for_class !== ''
149
+			&& isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 * returns FQN for provided alias if one exists, otherwise returns the original FQN
156
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
157
+	 *  for example:
158
+	 *      if the following two entries were added to the aliases array:
159
+	 *          array(
160
+	 *              'interface_alias'           => 'some\namespace\interface'
161
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
162
+	 *          )
163
+	 *      then one could use Loader::getNew( 'interface_alias' )
164
+	 *      to load an instance of 'some\namespace\classname'
165
+	 *
166
+	 * @param string $alias
167
+	 * @param string $for_class
168
+	 * @return string
169
+	 */
170
+	public function getFqnForAlias($alias = '', $for_class = '')
171
+	{
172
+		$alias = $this->getFqn($alias);
173
+		if ($this->isAliasForClass($alias, $for_class)) {
174
+			return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
175
+		}
176
+		if ($this->isDirectAlias($alias)) {
177
+			// note: changed '' to $for_class
178
+			return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
179
+		}
180
+		return $alias;
181
+	}
182
+
183
+
184
+	// public function debug($for_class = '')
185
+	// {
186
+	//     if ($for_class !== '') {
187
+	//         if ( ! isset($this->aliases[ $for_class ])) {
188
+	//             \EEH_Debug_Tools::printr('NOT FOUND', "aliases[ $for_class ]", __FILE__, __LINE__);
189
+	//             return;
190
+	//         }
191
+	//         \EEH_Debug_Tools::printr($this->aliases[ $for_class ], "aliases[ $for_class ]", __FILE__, __LINE__);
192
+	//         return;
193
+	//     }
194
+	//     \EEH_Debug_Tools::printr($this->aliases, '$this->aliases', __FILE__, __LINE__);
195
+	// }
196 196
 }
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -29,210 +29,210 @@
 block discarded – undo
29 29
  */
30 30
 class ShortcodesManager
31 31
 {
32
-    /**
33
-     * @type CurrentPage
34
-     */
35
-    protected $current_page;
36
-
37
-    /**
38
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
-     */
40
-    private $legacy_shortcodes_manager;
41
-
42
-    /**
43
-     * @var ShortcodeInterface[] $shortcodes
44
-     */
45
-    private $shortcodes;
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     * @param CurrentPage             $current_page
53
-     */
54
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
-    {
56
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
-        $this->current_page              = $current_page;
58
-        // assemble a list of installed and active shortcodes
59
-        add_action(
60
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
-            [$this, 'registerShortcodes'],
62
-            999
63
-        );
64
-        //  call add_shortcode() for all installed shortcodes
65
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
-        // check content for shortcodes the old way
67
-        add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
-        // check content for shortcodes the NEW more efficient way
69
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
-    }
71
-
72
-
73
-    /**
74
-     * @return CollectionInterface|ShortcodeInterface[]
75
-     * @throws InvalidIdentifierException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidFilePathException
78
-     * @throws InvalidEntityException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidClassException
81
-     */
82
-    public function getShortcodes()
83
-    {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
85
-            $this->shortcodes = $this->loadShortcodesCollection();
86
-        }
87
-        return $this->shortcodes;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return CollectionInterface|ShortcodeInterface[]
93
-     * @throws InvalidIdentifierException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidFilePathException
96
-     * @throws InvalidEntityException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidClassException
99
-     */
100
-    protected function loadShortcodesCollection()
101
-    {
102
-        $loader = new CollectionLoader(
103
-            new CollectionDetails(
104
-            // collection name
105
-                'shortcodes',
106
-                // collection interface
107
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
109
-                ['EventEspresso\core\domain\entities\shortcodes'],
110
-                // filepaths to classes to add
111
-                [],
112
-                // file mask to use if parsing folder for files to add
113
-                '',
114
-                // what to use as identifier for collection entities
115
-                // using CLASS NAME prevents duplicates (works like a singleton)
116
-                CollectionDetails::ID_CLASS_NAME
117
-            )
118
-        );
119
-        return $loader->getCollection();
120
-    }
121
-
122
-
123
-    /**
124
-     * @return void
125
-     * @throws DomainException
126
-     * @throws InvalidInterfaceException
127
-     * @throws InvalidIdentifierException
128
-     * @throws InvalidFilePathException
129
-     * @throws InvalidEntityException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidClassException
132
-     * @throws Exception
133
-     */
134
-    public function registerShortcodes()
135
-    {
136
-        try {
137
-            $this->shortcodes = apply_filters(
138
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
-                $this->getShortcodes()
140
-            );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
142
-                throw new InvalidEntityException(
143
-                    $this->shortcodes,
144
-                    'CollectionInterface',
145
-                    sprintf(
146
-                        esc_html__(
147
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
-                            'event_espresso'
149
-                        ),
150
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
-                    )
152
-                );
153
-            }
154
-            $this->legacy_shortcodes_manager->registerShortcodes();
155
-        } catch (Exception $exception) {
156
-            new ExceptionStackTraceDisplay($exception);
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * @return void
163
-     * @throws Exception
164
-     */
165
-    public function addShortcodes()
166
-    {
167
-        try {
168
-            // cycle thru shortcode folders
169
-            foreach ($this->shortcodes as $shortcode) {
170
-                if ($shortcode instanceof EnqueueAssetsInterface) {
171
-                    add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
-                    add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
-                }
174
-                // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
176
-                    add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
-                }
178
-            }
179
-            $this->legacy_shortcodes_manager->addShortcodes();
180
-        } catch (Exception $exception) {
181
-            new ExceptionStackTraceDisplay($exception);
182
-        }
183
-    }
184
-
185
-
186
-    /**
187
-     * callback for the "template_redirect" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function templateRedirect()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->current_page->setEspressoPage(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * checks supplied content against list of shortcodes,
218
-     * then initializes any found shortcodes, and returns true.
219
-     * returns false if no shortcodes found.
220
-     *
221
-     * @param string $content
222
-     * @return bool
223
-     */
224
-    public function parseContentForShortcodes($content)
225
-    {
226
-        $has_shortcode = false;
227
-        if (empty($this->shortcodes)) {
228
-            return $has_shortcode;
229
-        }
230
-        foreach ($this->shortcodes as $shortcode) {
231
-            if (has_shortcode($content, $shortcode->getTag())) {
232
-                $shortcode->initializeShortcode();
233
-                $has_shortcode = true;
234
-            }
235
-        }
236
-        return $has_shortcode;
237
-    }
32
+	/**
33
+	 * @type CurrentPage
34
+	 */
35
+	protected $current_page;
36
+
37
+	/**
38
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
+	 */
40
+	private $legacy_shortcodes_manager;
41
+
42
+	/**
43
+	 * @var ShortcodeInterface[] $shortcodes
44
+	 */
45
+	private $shortcodes;
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 * @param CurrentPage             $current_page
53
+	 */
54
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
+	{
56
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
+		$this->current_page              = $current_page;
58
+		// assemble a list of installed and active shortcodes
59
+		add_action(
60
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
+			[$this, 'registerShortcodes'],
62
+			999
63
+		);
64
+		//  call add_shortcode() for all installed shortcodes
65
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
+		// check content for shortcodes the old way
67
+		add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
+		// check content for shortcodes the NEW more efficient way
69
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return CollectionInterface|ShortcodeInterface[]
75
+	 * @throws InvalidIdentifierException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidFilePathException
78
+	 * @throws InvalidEntityException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidClassException
81
+	 */
82
+	public function getShortcodes()
83
+	{
84
+		if (! $this->shortcodes instanceof CollectionInterface) {
85
+			$this->shortcodes = $this->loadShortcodesCollection();
86
+		}
87
+		return $this->shortcodes;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return CollectionInterface|ShortcodeInterface[]
93
+	 * @throws InvalidIdentifierException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidFilePathException
96
+	 * @throws InvalidEntityException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidClassException
99
+	 */
100
+	protected function loadShortcodesCollection()
101
+	{
102
+		$loader = new CollectionLoader(
103
+			new CollectionDetails(
104
+			// collection name
105
+				'shortcodes',
106
+				// collection interface
107
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
109
+				['EventEspresso\core\domain\entities\shortcodes'],
110
+				// filepaths to classes to add
111
+				[],
112
+				// file mask to use if parsing folder for files to add
113
+				'',
114
+				// what to use as identifier for collection entities
115
+				// using CLASS NAME prevents duplicates (works like a singleton)
116
+				CollectionDetails::ID_CLASS_NAME
117
+			)
118
+		);
119
+		return $loader->getCollection();
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return void
125
+	 * @throws DomainException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws InvalidIdentifierException
128
+	 * @throws InvalidFilePathException
129
+	 * @throws InvalidEntityException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidClassException
132
+	 * @throws Exception
133
+	 */
134
+	public function registerShortcodes()
135
+	{
136
+		try {
137
+			$this->shortcodes = apply_filters(
138
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
+				$this->getShortcodes()
140
+			);
141
+			if (! $this->shortcodes instanceof CollectionInterface) {
142
+				throw new InvalidEntityException(
143
+					$this->shortcodes,
144
+					'CollectionInterface',
145
+					sprintf(
146
+						esc_html__(
147
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
+							'event_espresso'
149
+						),
150
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
+					)
152
+				);
153
+			}
154
+			$this->legacy_shortcodes_manager->registerShortcodes();
155
+		} catch (Exception $exception) {
156
+			new ExceptionStackTraceDisplay($exception);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return void
163
+	 * @throws Exception
164
+	 */
165
+	public function addShortcodes()
166
+	{
167
+		try {
168
+			// cycle thru shortcode folders
169
+			foreach ($this->shortcodes as $shortcode) {
170
+				if ($shortcode instanceof EnqueueAssetsInterface) {
171
+					add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
+					add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
+				}
174
+				// add_shortcode() if it has not already been added
175
+				if (! shortcode_exists($shortcode->getTag())) {
176
+					add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
+				}
178
+			}
179
+			$this->legacy_shortcodes_manager->addShortcodes();
180
+		} catch (Exception $exception) {
181
+			new ExceptionStackTraceDisplay($exception);
182
+		}
183
+	}
184
+
185
+
186
+	/**
187
+	 * callback for the "template_redirect" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function templateRedirect()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->current_page->setEspressoPage(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * checks supplied content against list of shortcodes,
218
+	 * then initializes any found shortcodes, and returns true.
219
+	 * returns false if no shortcodes found.
220
+	 *
221
+	 * @param string $content
222
+	 * @return bool
223
+	 */
224
+	public function parseContentForShortcodes($content)
225
+	{
226
+		$has_shortcode = false;
227
+		if (empty($this->shortcodes)) {
228
+			return $has_shortcode;
229
+		}
230
+		foreach ($this->shortcodes as $shortcode) {
231
+			if (has_shortcode($content, $shortcode->getTag())) {
232
+				$shortcode->initializeShortcode();
233
+				$has_shortcode = true;
234
+			}
235
+		}
236
+		return $has_shortcode;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
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.
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
 class Iframe
19 19
 {
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(); // already escaped
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(); // already escaped
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.
core/domain/entities/shortcodes/EspressoCheckout.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -19,56 +19,56 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * the actual shortcode tag that gets registered with WordPress
24
-     *
25
-     * @return string
26
-     */
27
-    public function getTag()
28
-    {
29
-        return 'ESPRESSO_CHECKOUT';
30
-    }
22
+	/**
23
+	 * the actual shortcode tag that gets registered with WordPress
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function getTag()
28
+	{
29
+		return 'ESPRESSO_CHECKOUT';
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * the time in seconds to cache the results of the processShortcode() method
35
-     * 0 means the processShortcode() results will NOT be cached at all
36
-     *
37
-     * @return int
38
-     */
39
-    public function cacheExpiration()
40
-    {
41
-        return 0;
42
-    }
33
+	/**
34
+	 * the time in seconds to cache the results of the processShortcode() method
35
+	 * 0 means the processShortcode() results will NOT be cached at all
36
+	 *
37
+	 * @return int
38
+	 */
39
+	public function cacheExpiration()
40
+	{
41
+		return 0;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * a place for adding any initialization code that needs to run prior to wp_header().
47
-     * this may be required for shortcodes that utilize a corresponding module,
48
-     * and need to enqueue assets for that module
49
-     *
50
-     * @return void
51
-     */
52
-    public function initializeShortcode()
53
-    {
54
-        global $wp_query;
55
-        EED_Single_Page_Checkout::init($wp_query);
56
-        $this->shortcodeHasBeenInitialized();
57
-    }
45
+	/**
46
+	 * a place for adding any initialization code that needs to run prior to wp_header().
47
+	 * this may be required for shortcodes that utilize a corresponding module,
48
+	 * and need to enqueue assets for that module
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public function initializeShortcode()
53
+	{
54
+		global $wp_query;
55
+		EED_Single_Page_Checkout::init($wp_query);
56
+		$this->shortcodeHasBeenInitialized();
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * callback that runs when the shortcode is encountered in post content.
62
-     * IMPORTANT !!!
63
-     * remember that shortcode content should be RETURNED and NOT echoed out
64
-     *
65
-     * @param array $attributes
66
-     * @return string
67
-     */
68
-    public function processShortcode($attributes = array())
69
-    {
70
-        /** @var ResponseInterface $response */
71
-        $response = LoaderFactory::getLoader()->getShared(ResponseInterface::class);
72
-        return $response->getOutput();
73
-    }
60
+	/**
61
+	 * callback that runs when the shortcode is encountered in post content.
62
+	 * IMPORTANT !!!
63
+	 * remember that shortcode content should be RETURNED and NOT echoed out
64
+	 *
65
+	 * @param array $attributes
66
+	 * @return string
67
+	 */
68
+	public function processShortcode($attributes = array())
69
+	{
70
+		/** @var ResponseInterface $response */
71
+		$response = LoaderFactory::getLoader()->getShared(ResponseInterface::class);
72
+		return $response->getOutput();
73
+	}
74 74
 }
Please login to merge, or discard this patch.
modules/events_archive/EventsArchiveIframe.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -23,58 +23,58 @@
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     * EventsArchiveIframe constructor.
28
-     *
29
-     * @param EED_Events_Archive $EED_Events_Archive
30
-     * @throws EE_Error
31
-     * @throws ReflectionException
32
-     */
33
-    public function __construct($EED_Events_Archive)
34
-    {
35
-        /** @var CurrentPage $current_page */
36
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
37
-        $current_page->setEspressoPage(true);
38
-        add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
39
-        $EED_Events_Archive->event_list();
40
-        /** @var EspressoEvents $event_list */
41
-        $event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
42
-        parent::__construct(
43
-            esc_html__('Event List', 'event_espresso'),
44
-            $event_list->processShortcode()
45
-        );
46
-        $this->addStylesheets(
47
-            apply_filters(
48
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
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,
53
-                ],
54
-                $this
55
-            )
56
-        );
57
-        $this->addScripts(
58
-            apply_filters(
59
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
60
-                [
61
-                    'gmap_api' => sprintf(
62
-                        'https://maps.googleapis.com/maps/api/js?key=%s',
63
-                        apply_filters(
64
-                            'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
65
-                            EE_Registry::instance()->CFG->map_settings->google_map_api_key
66
-                        )
67
-                    ),
68
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
69
-                ],
70
-                $this
71
-            )
72
-        );
73
-        $this->addLocalizedVars(
74
-            [
75
-                'ee_gmap' => EEH_Maps::$gmap_vars,
76
-            ],
77
-            'ee_gmap_vars'
78
-        );
79
-    }
26
+	/**
27
+	 * EventsArchiveIframe constructor.
28
+	 *
29
+	 * @param EED_Events_Archive $EED_Events_Archive
30
+	 * @throws EE_Error
31
+	 * @throws ReflectionException
32
+	 */
33
+	public function __construct($EED_Events_Archive)
34
+	{
35
+		/** @var CurrentPage $current_page */
36
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
37
+		$current_page->setEspressoPage(true);
38
+		add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
39
+		$EED_Events_Archive->event_list();
40
+		/** @var EspressoEvents $event_list */
41
+		$event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
42
+		parent::__construct(
43
+			esc_html__('Event List', 'event_espresso'),
44
+			$event_list->processShortcode()
45
+		);
46
+		$this->addStylesheets(
47
+			apply_filters(
48
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
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,
53
+				],
54
+				$this
55
+			)
56
+		);
57
+		$this->addScripts(
58
+			apply_filters(
59
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
60
+				[
61
+					'gmap_api' => sprintf(
62
+						'https://maps.googleapis.com/maps/api/js?key=%s',
63
+						apply_filters(
64
+							'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
65
+							EE_Registry::instance()->CFG->map_settings->google_map_api_key
66
+						)
67
+					),
68
+					'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
69
+				],
70
+				$this
71
+			)
72
+		);
73
+		$this->addLocalizedVars(
74
+			[
75
+				'ee_gmap' => EEH_Maps::$gmap_vars,
76
+			],
77
+			'ee_gmap_vars'
78
+		);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
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.
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
@@ -20,59 +20,59 @@
 block discarded – undo
20 20
 class TicketSelectorSimple extends TicketSelector
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Ticket $ticket
25
-     */
26
-    protected $ticket;
23
+	/**
24
+	 * @var EE_Ticket $ticket
25
+	 */
26
+	protected $ticket;
27 27
 
28 28
 
29
-    /**
30
-     * TicketSelectorSimple constructor.
31
-     *
32
-     * @param EE_Event  $event
33
-     * @param EE_Ticket $ticket
34
-     * @param int       $max_attendees
35
-     * @param array     $template_args
36
-     * @throws EE_Error
37
-     */
38
-    public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
39
-    {
40
-        $this->ticket = $ticket;
41
-        parent::__construct(
42
-            $event,
43
-            [$this->ticket],
44
-            $max_attendees,
45
-            $template_args
46
-        );
47
-    }
29
+	/**
30
+	 * TicketSelectorSimple constructor.
31
+	 *
32
+	 * @param EE_Event  $event
33
+	 * @param EE_Ticket $ticket
34
+	 * @param int       $max_attendees
35
+	 * @param array     $template_args
36
+	 * @throws EE_Error
37
+	 */
38
+	public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
39
+	{
40
+		$this->ticket = $ticket;
41
+		parent::__construct(
42
+			$event,
43
+			[$this->ticket],
44
+			$max_attendees,
45
+			$template_args
46
+		);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * sets any and all template args that are required for this Ticket Selector
52
-     *
53
-     * @return void
54
-     * @throws UnexpectedEntityException
55
-     * @throws EE_Error
56
-     */
57
-    protected function addTemplateArgs()
58
-    {
59
-        $this->ticket_rows = 1;
60
-        unset($this->template_args['tickets']);
61
-        $this->template_args['ticket'] = $this->ticket;
62
-        $ticket_selector_row           = new TicketSelectorRowSimple(
63
-            $this->ticket,
64
-            $this->max_attendees,
65
-            $this->template_args['date_format'],
66
-            $this->template_args['event_status']
67
-        );
68
-        $this->template_args['TKT_ID'] = $this->ticket->ID();
69
-        $ticket_selector_row->setupTicketStatusDisplay();
70
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
71
-        if (empty($this->template_args['ticket_status_display'])) {
72
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
73
-        }
74
-        $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
75
-        $this->template_args['template_path']      =
76
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
77
-    }
50
+	/**
51
+	 * sets any and all template args that are required for this Ticket Selector
52
+	 *
53
+	 * @return void
54
+	 * @throws UnexpectedEntityException
55
+	 * @throws EE_Error
56
+	 */
57
+	protected function addTemplateArgs()
58
+	{
59
+		$this->ticket_rows = 1;
60
+		unset($this->template_args['tickets']);
61
+		$this->template_args['ticket'] = $this->ticket;
62
+		$ticket_selector_row           = new TicketSelectorRowSimple(
63
+			$this->ticket,
64
+			$this->max_attendees,
65
+			$this->template_args['date_format'],
66
+			$this->template_args['event_status']
67
+		);
68
+		$this->template_args['TKT_ID'] = $this->ticket->ID();
69
+		$ticket_selector_row->setupTicketStatusDisplay();
70
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
71
+		if (empty($this->template_args['ticket_status_display'])) {
72
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
73
+		}
74
+		$this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
75
+		$this->template_args['template_path']      =
76
+			TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
77
+	}
78 78
 }
Please login to merge, or discard this patch.
modules/feeds/EED_Feeds.module.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -12,218 +12,218 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Feeds
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
22
-
23
-
24
-    /**
25
-     *    set_hooks - for hooking into EE Core, other modules, etc
26
-     *
27
-     * @access    public
28
-     * @return    void
29
-     */
30
-    public static function set_hooks()
31
-    {
32
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
-    }
37
-
38
-    /**
39
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
-     *
41
-     * @access    public
42
-     * @return    void
43
-     */
44
-    public static function set_hooks_admin()
45
-    {
46
-    }
47
-
48
-
49
-    /**
50
-     *    run - initial module setup
51
-     *
52
-     * @access    public
53
-     * @return    void
54
-     */
55
-    public function run($WP)
56
-    {
57
-    }
58
-
59
-
60
-    /**
61
-     *    default_feed
62
-     *
63
-     * @access    public
64
-     * @param    type    rss2, atom, rss, rdf, rssjs
65
-     * @return    string
66
-     */
67
-    public static function default_feed($type = 'rss2')
68
-    {
69
-        // rss2, atom, rss, rdf, rssjs
70
-        $type = 'rss2';
71
-        return $type;
72
-    }
73
-
74
-
75
-    /**
76
-     *    parse_request
77
-     *
78
-     * @access    public
79
-     * @return    void
80
-     */
81
-    public static function parse_request()
82
-    {
83
-        $request = self::getRequest();
84
-        if ($request->requestParamIsSet('post_type')) {
85
-            // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
87
-            // what kinda post_type are we dealing with ?
88
-            switch ($request->getRequestParam('post_type')) {
89
-                case 'espresso_events':
90
-                    // for rss2, atom, rss, rdf
91
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
93
-                    // for json ( also uses the above filter )
94
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
95
-                    break;
96
-                case 'espresso_venues':
97
-                    // for rss2, atom, rss, rdf
98
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
100
-                    // for json ( also uses the above filter )
101
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
102
-                    break;
103
-            }
104
-        }
105
-    }
106
-
107
-
108
-    /**
109
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
110
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
111
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
112
-     *    espresso_attendees post_type
113
-     *
114
-     * @access    public
115
-     * @param    string $SQL the JOIN clause for the comment feed query
116
-     * @return    void
117
-     */
118
-    public static function comment_feed_join($SQL)
119
-    {
120
-        global $wpdb;
121
-        // check for wp_posts table in JOIN clause
122
-        if (strpos($SQL, $wpdb->posts) !== false) {
123
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
124
-        }
125
-        return $SQL;
126
-    }
127
-
128
-
129
-    /**
130
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
131
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
132
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
133
-     *    espresso_attendees post_type
134
-     *
135
-     * @access    public
136
-     * @param    string $SQL the WHERE clause for the comment feed query
137
-     * @return    void
138
-     */
139
-    public static function comment_feed_where($SQL)
140
-    {
141
-        global $wp_query, $wpdb;
142
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
143
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
144
-        }
145
-        return $SQL;
146
-    }
147
-
148
-
149
-    /**
150
-     *    the_event_feed
151
-     *
152
-     * @access    public
153
-     * @param    string $content
154
-     * @return    void
155
-     */
156
-    public static function the_event_feed($content)
157
-    {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
159
-            global $post;
160
-            $template_args = array(
161
-                'EVT_ID'            => $post->ID,
162
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163
-            );
164
-            $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
166
-                $template_args,
167
-                true
168
-            );
169
-        }
170
-        return $content;
171
-    }
172
-
173
-
174
-    /**
175
-     *    the_event_rssjs_feed
176
-     *
177
-     * @access    public
178
-     * @param    object $item
179
-     * @return    void
180
-     */
181
-    public static function the_event_rssjs_feed($item)
182
-    {
183
-        if (is_feed() && isset($item->description)) {
184
-            $item->description = EED_Feeds::the_event_feed($item->description);
185
-        }
186
-        return $item;
187
-    }
188
-
189
-
190
-    /**
191
-     *    the_venue_feed
192
-     *
193
-     * @access    public
194
-     * @param    string $content
195
-     * @return    void
196
-     */
197
-    public static function the_venue_feed($content)
198
-    {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
200
-            global $post;
201
-            $template_args = array(
202
-                'VNU_ID'            => $post->ID,
203
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204
-            );
205
-            $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
207
-                $template_args,
208
-                true
209
-            );
210
-        }
211
-        return $content;
212
-    }
213
-
214
-
215
-    /**
216
-     *    the_venue_rssjs_feed
217
-     *
218
-     * @access    public
219
-     * @param    object $item
220
-     * @return    void
221
-     */
222
-    public static function the_venue_rssjs_feed($item)
223
-    {
224
-        if (is_feed() && isset($item->description)) {
225
-            $item->description = EED_Feeds::the_venue_feed($item->description);
226
-        }
227
-        return $item;
228
-    }
15
+	/**
16
+	 * @return EED_Feeds
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22
+
23
+
24
+	/**
25
+	 *    set_hooks - for hooking into EE Core, other modules, etc
26
+	 *
27
+	 * @access    public
28
+	 * @return    void
29
+	 */
30
+	public static function set_hooks()
31
+	{
32
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
+	}
37
+
38
+	/**
39
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
+	 *
41
+	 * @access    public
42
+	 * @return    void
43
+	 */
44
+	public static function set_hooks_admin()
45
+	{
46
+	}
47
+
48
+
49
+	/**
50
+	 *    run - initial module setup
51
+	 *
52
+	 * @access    public
53
+	 * @return    void
54
+	 */
55
+	public function run($WP)
56
+	{
57
+	}
58
+
59
+
60
+	/**
61
+	 *    default_feed
62
+	 *
63
+	 * @access    public
64
+	 * @param    type    rss2, atom, rss, rdf, rssjs
65
+	 * @return    string
66
+	 */
67
+	public static function default_feed($type = 'rss2')
68
+	{
69
+		// rss2, atom, rss, rdf, rssjs
70
+		$type = 'rss2';
71
+		return $type;
72
+	}
73
+
74
+
75
+	/**
76
+	 *    parse_request
77
+	 *
78
+	 * @access    public
79
+	 * @return    void
80
+	 */
81
+	public static function parse_request()
82
+	{
83
+		$request = self::getRequest();
84
+		if ($request->requestParamIsSet('post_type')) {
85
+			// define path to templates
86
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
87
+			// what kinda post_type are we dealing with ?
88
+			switch ($request->getRequestParam('post_type')) {
89
+				case 'espresso_events':
90
+					// for rss2, atom, rss, rdf
91
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
93
+					// for json ( also uses the above filter )
94
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
95
+					break;
96
+				case 'espresso_venues':
97
+					// for rss2, atom, rss, rdf
98
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
100
+					// for json ( also uses the above filter )
101
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
102
+					break;
103
+			}
104
+		}
105
+	}
106
+
107
+
108
+	/**
109
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
110
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
111
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
112
+	 *    espresso_attendees post_type
113
+	 *
114
+	 * @access    public
115
+	 * @param    string $SQL the JOIN clause for the comment feed query
116
+	 * @return    void
117
+	 */
118
+	public static function comment_feed_join($SQL)
119
+	{
120
+		global $wpdb;
121
+		// check for wp_posts table in JOIN clause
122
+		if (strpos($SQL, $wpdb->posts) !== false) {
123
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
124
+		}
125
+		return $SQL;
126
+	}
127
+
128
+
129
+	/**
130
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
131
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
132
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
133
+	 *    espresso_attendees post_type
134
+	 *
135
+	 * @access    public
136
+	 * @param    string $SQL the WHERE clause for the comment feed query
137
+	 * @return    void
138
+	 */
139
+	public static function comment_feed_where($SQL)
140
+	{
141
+		global $wp_query, $wpdb;
142
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
143
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
144
+		}
145
+		return $SQL;
146
+	}
147
+
148
+
149
+	/**
150
+	 *    the_event_feed
151
+	 *
152
+	 * @access    public
153
+	 * @param    string $content
154
+	 * @return    void
155
+	 */
156
+	public static function the_event_feed($content)
157
+	{
158
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
159
+			global $post;
160
+			$template_args = array(
161
+				'EVT_ID'            => $post->ID,
162
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163
+			);
164
+			$content = EEH_Template::display_template(
165
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
166
+				$template_args,
167
+				true
168
+			);
169
+		}
170
+		return $content;
171
+	}
172
+
173
+
174
+	/**
175
+	 *    the_event_rssjs_feed
176
+	 *
177
+	 * @access    public
178
+	 * @param    object $item
179
+	 * @return    void
180
+	 */
181
+	public static function the_event_rssjs_feed($item)
182
+	{
183
+		if (is_feed() && isset($item->description)) {
184
+			$item->description = EED_Feeds::the_event_feed($item->description);
185
+		}
186
+		return $item;
187
+	}
188
+
189
+
190
+	/**
191
+	 *    the_venue_feed
192
+	 *
193
+	 * @access    public
194
+	 * @param    string $content
195
+	 * @return    void
196
+	 */
197
+	public static function the_venue_feed($content)
198
+	{
199
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
200
+			global $post;
201
+			$template_args = array(
202
+				'VNU_ID'            => $post->ID,
203
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204
+			);
205
+			$content = EEH_Template::display_template(
206
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
207
+				$template_args,
208
+				true
209
+			);
210
+		}
211
+		return $content;
212
+	}
213
+
214
+
215
+	/**
216
+	 *    the_venue_rssjs_feed
217
+	 *
218
+	 * @access    public
219
+	 * @param    object $item
220
+	 * @return    void
221
+	 */
222
+	public static function the_venue_rssjs_feed($item)
223
+	{
224
+		if (is_feed() && isset($item->description)) {
225
+			$item->description = EED_Feeds::the_venue_feed($item->description);
226
+		}
227
+		return $item;
228
+	}
229 229
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $request = self::getRequest();
84 84
         if ($request->requestParamIsSet('post_type')) {
85 85
             // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
87 87
             // what kinda post_type are we dealing with ?
88 88
             switch ($request->getRequestParam('post_type')) {
89 89
                 case 'espresso_events':
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function the_event_feed($content)
157 157
     {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
159 159
             global $post;
160 160
             $template_args = array(
161 161
                 'EVT_ID'            => $post->ID,
162 162
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163 163
             );
164 164
             $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
166 166
                 $template_args,
167 167
                 true
168 168
             );
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public static function the_venue_feed($content)
198 198
     {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
200 200
             global $post;
201 201
             $template_args = array(
202 202
                 'VNU_ID'            => $post->ID,
203 203
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204 204
             );
205 205
             $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
207 207
                 $template_args,
208 208
                 true
209 209
             );
Please login to merge, or discard this patch.