Completed
Pull Request — develop (#1713)
by Zack
17:42
created
future/includes/class-gv-shortcode-gvlogic.php 3 patches
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -12,338 +12,338 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class gvlogic extends \GV\Shortcode
14 14
 {
15
-    /**
16
-     * {@inheritDoc}
17
-     */
18
-    public $name = 'gvlogic';
19
-
20
-    /**
21
-     * {@inheritDoc}
22
-     */
23
-    public static function add($name = null)
24
-    {
25
-        parent::add(); // Me, myself and...
26
-
27
-        /**
28
-         * ...some aliases.
29
-         */
30
-        parent::add('gvlogic2');
31
-        parent::add('gvlogic3'); // This level of nesting is not supported by GravityView support...but go for it!
32
-        parent::add('gvlogicelse');
33
-    }
34
-
35
-    /**
36
-     * Process and output the [gvfield] shortcode.
37
-     *
38
-     * @param array  $atts    The attributes passed.
39
-     * @param string $content The content inside the shortcode.
40
-     * @param string $tag     The tag.
41
-     *
42
-     * @return string The output.
43
-     */
44
-    public function callback($atts, $content = '', $tag = '')
45
-    {
46
-        $request = gravityview()->request;
47
-
48
-        if ($request->is_admin()) {
49
-            return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
50
-        }
51
-
52
-        $atts = $this->parse_atts($atts, $content, $tag);
53
-
54
-        $content = \GravityView_Merge_Tags::replace_get_variables($content);
55
-        $atts = gv_map_deep($atts, ['\GravityView_Merge_Tags', 'replace_get_variables']);
56
-
57
-        // An invalid operation
58
-        if (is_null(\GV\Utils::get($atts, 'logged_in', null)) && false === \GV\Utils::get($atts, 'if', false)) {
59
-            gravityview()->log->error('$atts->if/logged_in is empty.', ['data' => $atts]);
60
-
61
-            return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
62
-        }
63
-
64
-        $authed = $this->authorized($atts);
65
-        $operator = $this->get_operator($atts);
66
-        $value = $this->get_value($atts);
67
-
68
-        if (false === $operator && is_null($value)) {
69
-            if (false !== $atts['if']) { // Only-if test
70
-                $match = $authed && !in_array(strtolower($atts['if']), ['', '0', 'false', 'no']);
71
-            } else {
72
-                $match = $authed; // Just login test
73
-            }
74
-
75
-            $output = $this->get_output($match, $atts, $content);
76
-        } else { // Regular test
77
-
78
-            $output = $content;
79
-
80
-            // Allow checking against multiple values at once
81
-            $and_values = explode('&&', $value);
82
-            $or_values = explode('||', $value);
83
-
84
-            // Cannot combine AND and OR
85
-            if (sizeof($and_values) > 1) {
86
-
87
-                // Need to match all AND
88
-                foreach ($and_values as $and_value) {
89
-                    $match = $authed && \GVCommon::matches_operation($atts['if'], $and_value, $operator);
90
-                    if (!$match) {
91
-                        break;
92
-                    }
93
-                }
94
-            } elseif (sizeof($or_values) > 1) {
95
-
96
-                // Only need to match a single OR
97
-                foreach ($or_values as $or_value) {
98
-                    $match = \GVCommon::matches_operation($atts['if'], $or_value, $operator);
99
-
100
-                    // Negate the negative operators
101
-                    if (($authed && $match) || ($authed && (!$match && in_array($operator, ['isnot', 'not_contains', 'not_in'])))) {
102
-                        break;
103
-                    }
104
-                }
105
-            } else {
106
-                $match = $authed && \GVCommon::matches_operation($atts['if'], $value, $operator);
107
-            }
108
-
109
-            $output = $this->get_output($match, $atts, $output);
110
-        }
111
-
112
-        // Output and get recursive!
113
-        $output = do_shortcode($output);
114
-        $output = \GFCommon::replace_variables($output, [], [], false, true, false);
115
-
116
-        return apply_filters('gravityview/shortcodes/gvlogic/output', $output, $atts);
117
-    }
118
-
119
-    /**
120
-     * Are we authorized to follow the if path?
121
-     *
122
-     * @param array $atts The attributes.
123
-     *
124
-     * @return bool Yes, or no.
125
-     */
126
-    private function authorized($atts)
127
-    {
128
-        $needs_login = \GV\Utils::get($atts, 'logged_in', null);
129
-
130
-        if (is_null($needs_login)) {
131
-            return true; // No auth requirements have been set
132
-        }
133
-
134
-        return !$needs_login ^ is_user_logged_in(); // XNOR
135
-    }
136
-
137
-    /**
138
-     * Fetch the operator.
139
-     *
140
-     * @param array $atts The attributes.
141
-     *
142
-     * @return bool|string The operator.
143
-     */
144
-    private function get_operator($atts)
145
-    {
146
-        $valid_ops = $this->get_operators(false);
147
-
148
-        foreach ($atts as $op => $value) {
149
-            if (in_array($op, ['if', 'else'])) {
150
-                continue;
151
-            }
152
-
153
-            if (in_array($op, $valid_ops, true)) {
154
-                return $op;
155
-            }
156
-        }
157
-
158
-        return false;
159
-    }
160
-
161
-    /**
162
-     * Fetch the value.
163
-     *
164
-     * @param array $atts The attributes.
165
-     *
166
-     * @return null|string The value.
167
-     */
168
-    private function get_value($atts)
169
-    {
170
-        $valid_ops = $this->get_operators(false);
171
-
172
-        foreach ($atts as $op => $value) {
173
-            if (in_array($op, ['if', 'else'])) {
174
-                continue;
175
-            }
176
-
177
-            if (in_array($op, $valid_ops, true)) {
178
-                return $value;
179
-            }
180
-        }
181
-
182
-        return null;
183
-    }
184
-
185
-    /**
186
-     * Get the output content.
187
-     *
188
-     * @param bool   $match   if or else?
189
-     * @param array  $atts    The attributes.
190
-     * @param string $content The content.
191
-     *
192
-     * @return string The output.
193
-     */
194
-    private function get_output($match, $atts, $content)
195
-    {
196
-        if (!$match && !empty($atts['else'])) {
197
-            return $atts['else']; // Attributized else is easy :)
198
-        }
199
-
200
-        $if = '';
201
-        $else = '';
202
-
203
-        $opens = 0; // inner opens
204
-        $found = false; // found split position
205
-
206
-        while ($content) { // scan
207
-
208
-            if (!preg_match('#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches)) {
209
-                if (!$found) { // We're still iffing.
210
-                    $if .= $content;
211
-                } else { // We are elsing
212
-                    $else .= $content;
213
-                }
214
-                break; // No more shortcodes
215
-            }
216
-
217
-            list($_, $before_shortcode, $shortcode, $_, $after_shortcode) = $matches;
218
-
219
-            if (!$found) { // We're still iffing.
220
-                $if .= $before_shortcode;
221
-            } else { // We are elsing
222
-                $else .= $before_shortcode;
223
-            }
224
-
225
-            if (0 === strpos($shortcode, '[else]') && 0 === $opens) {
226
-                // This is the else we need!
227
-                $found = true;
228
-                if ($match) {
229
-                    break; // We just need the if on a match, no need to analyze further
230
-                }
231
-            } elseif ($match && 0 === strpos($shortcode, '[else if') && 0 === $opens) {
232
-                $found = true; // We found a match, do not process further
233
-                break;
234
-            } else {
235
-                // Increment inner tracking counters
236
-                if (0 === strpos($shortcode, '[gvlogic')) {
237
-                    $opens++;
238
-                }
239
-
240
-                if (0 === strpos($shortcode, '[/gvlogic')) {
241
-                    $opens--;
242
-                }
243
-
244
-                // Tack on the shortcode
245
-                if (!$found) { // We're still iffing.
246
-                    $if .= $shortcode;
247
-                } else { // We are elsing
248
-                    $else .= $shortcode;
249
-                }
250
-            }
251
-
252
-            $content = $after_shortcode;
253
-        }
254
-
255
-        gravityview()->log->debug('[gvlogic] output parsing:', [
256
-            'data' => [
257
-                'if'   => $if,
258
-                'else' => $else,
259
-            ],
260
-        ]);
261
-
262
-        if (!$match) {
263
-            while (($position = strpos($if, '[else if=')) !== false) {
264
-                // Try to match one of the elseif's
265
-                $sentinel = wp_generate_password(32, false);
266
-                $if = substr($if, $position); // ...by replacing it with a gvlogic shortcode
267
-                // ..and executing it!
268
-                $result = do_shortcode(preg_replace('#\[else if#', '[gvlogic if', $if, 1)."[else]{$sentinel}[/gvlogic]");
269
-                if ($result !== $sentinel) {
270
-                    // We have an elseif match!
271
-                    return $result;
272
-                }
273
-                $if = substr($if, 1); // Move over to get the next elseif match.. and repeat
274
-            }
275
-        }
276
-
277
-        return $match ? $if : $else;
278
-    }
279
-
280
-    /**
281
-     * Get array of supported operators.
282
-     *
283
-     * @param bool $with_values
284
-     *
285
-     * @return array
286
-     */
287
-    private function get_operators($with_values = false)
288
-    {
289
-        $operators = [
290
-            'is', 'isnot', 'contains', 'starts_with', 'ends_with',
291
-            'greater_than', 'less_than', 'in', 'not_in',
292
-            'contains', 'equals', 'greater_than_or_is', 'greater_than_or_equals',
293
-            'less_than_or_is', 'less_than_or_equals', 'not_contains',
294
-        ];
295
-
296
-        if ($with_values) {
297
-            return array_combine(
298
-                $operators,
299
-                array_fill(0, count($operators), '')
300
-            );
301
-        }
302
-
303
-        return $operators;
304
-    }
305
-
306
-    /**
307
-     * Process the attributes passed to the shortcode. Make sure they're valid.
308
-     *
309
-     * @return array Array of attributes parsed for the shortcode
310
-     */
311
-    private function parse_atts($atts, $content, $tag)
312
-    {
313
-        $supplied_atts = !empty($atts) ? $atts : [];
314
-
315
-        $atts = shortcode_atts([
316
-            'if'        => null,
317
-            'else'      => null,
318
-            'logged_in' => null,
319
-        ] + $this->get_operators(true), $atts, $tag);
320
-
321
-        // Only keep the passed attributes after making sure that they're valid pairs
322
-        $atts = array_intersect_key($supplied_atts, $atts);
323
-
324
-        // Strip whitespace if it's not default false
325
-        if (isset($atts['if']) && is_string($atts['if'])) {
326
-            $atts['if'] = trim($atts['if']);
327
-        } else {
328
-            $atts['if'] = false;
329
-        }
330
-
331
-        if (isset($atts['logged_in'])) {
332
-            // Truthy
333
-            if (in_array(strtolower($atts['logged_in']), ['0', 'false', 'no'])) {
334
-                $atts['logged_in'] = false;
335
-            } else {
336
-                $atts['logged_in'] = true;
337
-            }
338
-        }
339
-
340
-        /**
341
-         * @filter `gravityview/gvlogic/atts` The logic attributes.
342
-         *
343
-         * @since 2.5
344
-         *
345
-         * @param array $atts The logic attributes.
346
-         */
347
-        return apply_filters('gravityview/gvlogic/atts', $atts);
348
-    }
15
+	/**
16
+	 * {@inheritDoc}
17
+	 */
18
+	public $name = 'gvlogic';
19
+
20
+	/**
21
+	 * {@inheritDoc}
22
+	 */
23
+	public static function add($name = null)
24
+	{
25
+		parent::add(); // Me, myself and...
26
+
27
+		/**
28
+		 * ...some aliases.
29
+		 */
30
+		parent::add('gvlogic2');
31
+		parent::add('gvlogic3'); // This level of nesting is not supported by GravityView support...but go for it!
32
+		parent::add('gvlogicelse');
33
+	}
34
+
35
+	/**
36
+	 * Process and output the [gvfield] shortcode.
37
+	 *
38
+	 * @param array  $atts    The attributes passed.
39
+	 * @param string $content The content inside the shortcode.
40
+	 * @param string $tag     The tag.
41
+	 *
42
+	 * @return string The output.
43
+	 */
44
+	public function callback($atts, $content = '', $tag = '')
45
+	{
46
+		$request = gravityview()->request;
47
+
48
+		if ($request->is_admin()) {
49
+			return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
50
+		}
51
+
52
+		$atts = $this->parse_atts($atts, $content, $tag);
53
+
54
+		$content = \GravityView_Merge_Tags::replace_get_variables($content);
55
+		$atts = gv_map_deep($atts, ['\GravityView_Merge_Tags', 'replace_get_variables']);
56
+
57
+		// An invalid operation
58
+		if (is_null(\GV\Utils::get($atts, 'logged_in', null)) && false === \GV\Utils::get($atts, 'if', false)) {
59
+			gravityview()->log->error('$atts->if/logged_in is empty.', ['data' => $atts]);
60
+
61
+			return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
62
+		}
63
+
64
+		$authed = $this->authorized($atts);
65
+		$operator = $this->get_operator($atts);
66
+		$value = $this->get_value($atts);
67
+
68
+		if (false === $operator && is_null($value)) {
69
+			if (false !== $atts['if']) { // Only-if test
70
+				$match = $authed && !in_array(strtolower($atts['if']), ['', '0', 'false', 'no']);
71
+			} else {
72
+				$match = $authed; // Just login test
73
+			}
74
+
75
+			$output = $this->get_output($match, $atts, $content);
76
+		} else { // Regular test
77
+
78
+			$output = $content;
79
+
80
+			// Allow checking against multiple values at once
81
+			$and_values = explode('&&', $value);
82
+			$or_values = explode('||', $value);
83
+
84
+			// Cannot combine AND and OR
85
+			if (sizeof($and_values) > 1) {
86
+
87
+				// Need to match all AND
88
+				foreach ($and_values as $and_value) {
89
+					$match = $authed && \GVCommon::matches_operation($atts['if'], $and_value, $operator);
90
+					if (!$match) {
91
+						break;
92
+					}
93
+				}
94
+			} elseif (sizeof($or_values) > 1) {
95
+
96
+				// Only need to match a single OR
97
+				foreach ($or_values as $or_value) {
98
+					$match = \GVCommon::matches_operation($atts['if'], $or_value, $operator);
99
+
100
+					// Negate the negative operators
101
+					if (($authed && $match) || ($authed && (!$match && in_array($operator, ['isnot', 'not_contains', 'not_in'])))) {
102
+						break;
103
+					}
104
+				}
105
+			} else {
106
+				$match = $authed && \GVCommon::matches_operation($atts['if'], $value, $operator);
107
+			}
108
+
109
+			$output = $this->get_output($match, $atts, $output);
110
+		}
111
+
112
+		// Output and get recursive!
113
+		$output = do_shortcode($output);
114
+		$output = \GFCommon::replace_variables($output, [], [], false, true, false);
115
+
116
+		return apply_filters('gravityview/shortcodes/gvlogic/output', $output, $atts);
117
+	}
118
+
119
+	/**
120
+	 * Are we authorized to follow the if path?
121
+	 *
122
+	 * @param array $atts The attributes.
123
+	 *
124
+	 * @return bool Yes, or no.
125
+	 */
126
+	private function authorized($atts)
127
+	{
128
+		$needs_login = \GV\Utils::get($atts, 'logged_in', null);
129
+
130
+		if (is_null($needs_login)) {
131
+			return true; // No auth requirements have been set
132
+		}
133
+
134
+		return !$needs_login ^ is_user_logged_in(); // XNOR
135
+	}
136
+
137
+	/**
138
+	 * Fetch the operator.
139
+	 *
140
+	 * @param array $atts The attributes.
141
+	 *
142
+	 * @return bool|string The operator.
143
+	 */
144
+	private function get_operator($atts)
145
+	{
146
+		$valid_ops = $this->get_operators(false);
147
+
148
+		foreach ($atts as $op => $value) {
149
+			if (in_array($op, ['if', 'else'])) {
150
+				continue;
151
+			}
152
+
153
+			if (in_array($op, $valid_ops, true)) {
154
+				return $op;
155
+			}
156
+		}
157
+
158
+		return false;
159
+	}
160
+
161
+	/**
162
+	 * Fetch the value.
163
+	 *
164
+	 * @param array $atts The attributes.
165
+	 *
166
+	 * @return null|string The value.
167
+	 */
168
+	private function get_value($atts)
169
+	{
170
+		$valid_ops = $this->get_operators(false);
171
+
172
+		foreach ($atts as $op => $value) {
173
+			if (in_array($op, ['if', 'else'])) {
174
+				continue;
175
+			}
176
+
177
+			if (in_array($op, $valid_ops, true)) {
178
+				return $value;
179
+			}
180
+		}
181
+
182
+		return null;
183
+	}
184
+
185
+	/**
186
+	 * Get the output content.
187
+	 *
188
+	 * @param bool   $match   if or else?
189
+	 * @param array  $atts    The attributes.
190
+	 * @param string $content The content.
191
+	 *
192
+	 * @return string The output.
193
+	 */
194
+	private function get_output($match, $atts, $content)
195
+	{
196
+		if (!$match && !empty($atts['else'])) {
197
+			return $atts['else']; // Attributized else is easy :)
198
+		}
199
+
200
+		$if = '';
201
+		$else = '';
202
+
203
+		$opens = 0; // inner opens
204
+		$found = false; // found split position
205
+
206
+		while ($content) { // scan
207
+
208
+			if (!preg_match('#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches)) {
209
+				if (!$found) { // We're still iffing.
210
+					$if .= $content;
211
+				} else { // We are elsing
212
+					$else .= $content;
213
+				}
214
+				break; // No more shortcodes
215
+			}
216
+
217
+			list($_, $before_shortcode, $shortcode, $_, $after_shortcode) = $matches;
218
+
219
+			if (!$found) { // We're still iffing.
220
+				$if .= $before_shortcode;
221
+			} else { // We are elsing
222
+				$else .= $before_shortcode;
223
+			}
224
+
225
+			if (0 === strpos($shortcode, '[else]') && 0 === $opens) {
226
+				// This is the else we need!
227
+				$found = true;
228
+				if ($match) {
229
+					break; // We just need the if on a match, no need to analyze further
230
+				}
231
+			} elseif ($match && 0 === strpos($shortcode, '[else if') && 0 === $opens) {
232
+				$found = true; // We found a match, do not process further
233
+				break;
234
+			} else {
235
+				// Increment inner tracking counters
236
+				if (0 === strpos($shortcode, '[gvlogic')) {
237
+					$opens++;
238
+				}
239
+
240
+				if (0 === strpos($shortcode, '[/gvlogic')) {
241
+					$opens--;
242
+				}
243
+
244
+				// Tack on the shortcode
245
+				if (!$found) { // We're still iffing.
246
+					$if .= $shortcode;
247
+				} else { // We are elsing
248
+					$else .= $shortcode;
249
+				}
250
+			}
251
+
252
+			$content = $after_shortcode;
253
+		}
254
+
255
+		gravityview()->log->debug('[gvlogic] output parsing:', [
256
+			'data' => [
257
+				'if'   => $if,
258
+				'else' => $else,
259
+			],
260
+		]);
261
+
262
+		if (!$match) {
263
+			while (($position = strpos($if, '[else if=')) !== false) {
264
+				// Try to match one of the elseif's
265
+				$sentinel = wp_generate_password(32, false);
266
+				$if = substr($if, $position); // ...by replacing it with a gvlogic shortcode
267
+				// ..and executing it!
268
+				$result = do_shortcode(preg_replace('#\[else if#', '[gvlogic if', $if, 1)."[else]{$sentinel}[/gvlogic]");
269
+				if ($result !== $sentinel) {
270
+					// We have an elseif match!
271
+					return $result;
272
+				}
273
+				$if = substr($if, 1); // Move over to get the next elseif match.. and repeat
274
+			}
275
+		}
276
+
277
+		return $match ? $if : $else;
278
+	}
279
+
280
+	/**
281
+	 * Get array of supported operators.
282
+	 *
283
+	 * @param bool $with_values
284
+	 *
285
+	 * @return array
286
+	 */
287
+	private function get_operators($with_values = false)
288
+	{
289
+		$operators = [
290
+			'is', 'isnot', 'contains', 'starts_with', 'ends_with',
291
+			'greater_than', 'less_than', 'in', 'not_in',
292
+			'contains', 'equals', 'greater_than_or_is', 'greater_than_or_equals',
293
+			'less_than_or_is', 'less_than_or_equals', 'not_contains',
294
+		];
295
+
296
+		if ($with_values) {
297
+			return array_combine(
298
+				$operators,
299
+				array_fill(0, count($operators), '')
300
+			);
301
+		}
302
+
303
+		return $operators;
304
+	}
305
+
306
+	/**
307
+	 * Process the attributes passed to the shortcode. Make sure they're valid.
308
+	 *
309
+	 * @return array Array of attributes parsed for the shortcode
310
+	 */
311
+	private function parse_atts($atts, $content, $tag)
312
+	{
313
+		$supplied_atts = !empty($atts) ? $atts : [];
314
+
315
+		$atts = shortcode_atts([
316
+			'if'        => null,
317
+			'else'      => null,
318
+			'logged_in' => null,
319
+		] + $this->get_operators(true), $atts, $tag);
320
+
321
+		// Only keep the passed attributes after making sure that they're valid pairs
322
+		$atts = array_intersect_key($supplied_atts, $atts);
323
+
324
+		// Strip whitespace if it's not default false
325
+		if (isset($atts['if']) && is_string($atts['if'])) {
326
+			$atts['if'] = trim($atts['if']);
327
+		} else {
328
+			$atts['if'] = false;
329
+		}
330
+
331
+		if (isset($atts['logged_in'])) {
332
+			// Truthy
333
+			if (in_array(strtolower($atts['logged_in']), ['0', 'false', 'no'])) {
334
+				$atts['logged_in'] = false;
335
+			} else {
336
+				$atts['logged_in'] = true;
337
+			}
338
+		}
339
+
340
+		/**
341
+		 * @filter `gravityview/gvlogic/atts` The logic attributes.
342
+		 *
343
+		 * @since 2.5
344
+		 *
345
+		 * @param array $atts The logic attributes.
346
+		 */
347
+		return apply_filters('gravityview/gvlogic/atts', $atts);
348
+	}
349 349
 }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV\Shortcodes;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -20,16 +20,16 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * {@inheritDoc}
22 22
      */
23
-    public static function add($name = null)
23
+    public static function add( $name = null )
24 24
     {
25 25
         parent::add(); // Me, myself and...
26 26
 
27 27
         /**
28 28
          * ...some aliases.
29 29
          */
30
-        parent::add('gvlogic2');
31
-        parent::add('gvlogic3'); // This level of nesting is not supported by GravityView support...but go for it!
32
-        parent::add('gvlogicelse');
30
+        parent::add( 'gvlogic2' );
31
+        parent::add( 'gvlogic3' ); // This level of nesting is not supported by GravityView support...but go for it!
32
+        parent::add( 'gvlogicelse' );
33 33
     }
34 34
 
35 35
     /**
@@ -41,79 +41,79 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return string The output.
43 43
      */
44
-    public function callback($atts, $content = '', $tag = '')
44
+    public function callback( $atts, $content = '', $tag = '' )
45 45
     {
46 46
         $request = gravityview()->request;
47 47
 
48
-        if ($request->is_admin()) {
49
-            return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
48
+        if ( $request->is_admin() ) {
49
+            return apply_filters( 'gravityview/shortcodes/gvlogic/output', '', $atts );
50 50
         }
51 51
 
52
-        $atts = $this->parse_atts($atts, $content, $tag);
52
+        $atts = $this->parse_atts( $atts, $content, $tag );
53 53
 
54
-        $content = \GravityView_Merge_Tags::replace_get_variables($content);
55
-        $atts = gv_map_deep($atts, ['\GravityView_Merge_Tags', 'replace_get_variables']);
54
+        $content = \GravityView_Merge_Tags::replace_get_variables( $content );
55
+        $atts = gv_map_deep( $atts, [ '\GravityView_Merge_Tags', 'replace_get_variables' ] );
56 56
 
57 57
         // An invalid operation
58
-        if (is_null(\GV\Utils::get($atts, 'logged_in', null)) && false === \GV\Utils::get($atts, 'if', false)) {
59
-            gravityview()->log->error('$atts->if/logged_in is empty.', ['data' => $atts]);
58
+        if ( is_null( \GV\Utils::get( $atts, 'logged_in', null ) ) && false === \GV\Utils::get( $atts, 'if', false ) ) {
59
+            gravityview()->log->error( '$atts->if/logged_in is empty.', [ 'data' => $atts ] );
60 60
 
61
-            return apply_filters('gravityview/shortcodes/gvlogic/output', '', $atts);
61
+            return apply_filters( 'gravityview/shortcodes/gvlogic/output', '', $atts );
62 62
         }
63 63
 
64
-        $authed = $this->authorized($atts);
65
-        $operator = $this->get_operator($atts);
66
-        $value = $this->get_value($atts);
64
+        $authed = $this->authorized( $atts );
65
+        $operator = $this->get_operator( $atts );
66
+        $value = $this->get_value( $atts );
67 67
 
68
-        if (false === $operator && is_null($value)) {
69
-            if (false !== $atts['if']) { // Only-if test
70
-                $match = $authed && !in_array(strtolower($atts['if']), ['', '0', 'false', 'no']);
68
+        if ( false === $operator && is_null( $value ) ) {
69
+            if ( false !== $atts[ 'if' ] ) { // Only-if test
70
+                $match = $authed && ! in_array( strtolower( $atts[ 'if' ] ), [ '', '0', 'false', 'no' ] );
71 71
             } else {
72 72
                 $match = $authed; // Just login test
73 73
             }
74 74
 
75
-            $output = $this->get_output($match, $atts, $content);
75
+            $output = $this->get_output( $match, $atts, $content );
76 76
         } else { // Regular test
77 77
 
78 78
             $output = $content;
79 79
 
80 80
             // Allow checking against multiple values at once
81
-            $and_values = explode('&&', $value);
82
-            $or_values = explode('||', $value);
81
+            $and_values = explode( '&&', $value );
82
+            $or_values = explode( '||', $value );
83 83
 
84 84
             // Cannot combine AND and OR
85
-            if (sizeof($and_values) > 1) {
85
+            if ( sizeof( $and_values ) > 1 ) {
86 86
 
87 87
                 // Need to match all AND
88
-                foreach ($and_values as $and_value) {
89
-                    $match = $authed && \GVCommon::matches_operation($atts['if'], $and_value, $operator);
90
-                    if (!$match) {
88
+                foreach ( $and_values as $and_value ) {
89
+                    $match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $and_value, $operator );
90
+                    if ( ! $match ) {
91 91
                         break;
92 92
                     }
93 93
                 }
94
-            } elseif (sizeof($or_values) > 1) {
94
+            } elseif ( sizeof( $or_values ) > 1 ) {
95 95
 
96 96
                 // Only need to match a single OR
97
-                foreach ($or_values as $or_value) {
98
-                    $match = \GVCommon::matches_operation($atts['if'], $or_value, $operator);
97
+                foreach ( $or_values as $or_value ) {
98
+                    $match = \GVCommon::matches_operation( $atts[ 'if' ], $or_value, $operator );
99 99
 
100 100
                     // Negate the negative operators
101
-                    if (($authed && $match) || ($authed && (!$match && in_array($operator, ['isnot', 'not_contains', 'not_in'])))) {
101
+                    if ( ( $authed && $match ) || ( $authed && ( ! $match && in_array( $operator, [ 'isnot', 'not_contains', 'not_in' ] ) ) ) ) {
102 102
                         break;
103 103
                     }
104 104
                 }
105 105
             } else {
106
-                $match = $authed && \GVCommon::matches_operation($atts['if'], $value, $operator);
106
+                $match = $authed && \GVCommon::matches_operation( $atts[ 'if' ], $value, $operator );
107 107
             }
108 108
 
109
-            $output = $this->get_output($match, $atts, $output);
109
+            $output = $this->get_output( $match, $atts, $output );
110 110
         }
111 111
 
112 112
         // Output and get recursive!
113
-        $output = do_shortcode($output);
114
-        $output = \GFCommon::replace_variables($output, [], [], false, true, false);
113
+        $output = do_shortcode( $output );
114
+        $output = \GFCommon::replace_variables( $output, [ ], [ ], false, true, false );
115 115
 
116
-        return apply_filters('gravityview/shortcodes/gvlogic/output', $output, $atts);
116
+        return apply_filters( 'gravityview/shortcodes/gvlogic/output', $output, $atts );
117 117
     }
118 118
 
119 119
     /**
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return bool Yes, or no.
125 125
      */
126
-    private function authorized($atts)
126
+    private function authorized( $atts )
127 127
     {
128
-        $needs_login = \GV\Utils::get($atts, 'logged_in', null);
128
+        $needs_login = \GV\Utils::get( $atts, 'logged_in', null );
129 129
 
130
-        if (is_null($needs_login)) {
130
+        if ( is_null( $needs_login ) ) {
131 131
             return true; // No auth requirements have been set
132 132
         }
133 133
 
134
-        return !$needs_login ^ is_user_logged_in(); // XNOR
134
+        return ! $needs_login ^ is_user_logged_in(); // XNOR
135 135
     }
136 136
 
137 137
     /**
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
      *
142 142
      * @return bool|string The operator.
143 143
      */
144
-    private function get_operator($atts)
144
+    private function get_operator( $atts )
145 145
     {
146
-        $valid_ops = $this->get_operators(false);
146
+        $valid_ops = $this->get_operators( false );
147 147
 
148
-        foreach ($atts as $op => $value) {
149
-            if (in_array($op, ['if', 'else'])) {
148
+        foreach ( $atts as $op => $value ) {
149
+            if ( in_array( $op, [ 'if', 'else' ] ) ) {
150 150
                 continue;
151 151
             }
152 152
 
153
-            if (in_array($op, $valid_ops, true)) {
153
+            if ( in_array( $op, $valid_ops, true ) ) {
154 154
                 return $op;
155 155
             }
156 156
         }
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
      *
166 166
      * @return null|string The value.
167 167
      */
168
-    private function get_value($atts)
168
+    private function get_value( $atts )
169 169
     {
170
-        $valid_ops = $this->get_operators(false);
170
+        $valid_ops = $this->get_operators( false );
171 171
 
172
-        foreach ($atts as $op => $value) {
173
-            if (in_array($op, ['if', 'else'])) {
172
+        foreach ( $atts as $op => $value ) {
173
+            if ( in_array( $op, [ 'if', 'else' ] ) ) {
174 174
                 continue;
175 175
             }
176 176
 
177
-            if (in_array($op, $valid_ops, true)) {
177
+            if ( in_array( $op, $valid_ops, true ) ) {
178 178
                 return $value;
179 179
             }
180 180
         }
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
      *
192 192
      * @return string The output.
193 193
      */
194
-    private function get_output($match, $atts, $content)
194
+    private function get_output( $match, $atts, $content )
195 195
     {
196
-        if (!$match && !empty($atts['else'])) {
197
-            return $atts['else']; // Attributized else is easy :)
196
+        if ( ! $match && ! empty( $atts[ 'else' ] ) ) {
197
+            return $atts[ 'else' ]; // Attributized else is easy :)
198 198
         }
199 199
 
200 200
         $if = '';
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         $opens = 0; // inner opens
204 204
         $found = false; // found split position
205 205
 
206
-        while ($content) { // scan
206
+        while ( $content ) { // scan
207 207
 
208
-            if (!preg_match('#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches)) {
209
-                if (!$found) { // We're still iffing.
208
+            if ( ! preg_match( '#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches ) ) {
209
+                if ( ! $found ) { // We're still iffing.
210 210
                     $if .= $content;
211 211
                 } else { // We are elsing
212 212
                     $else .= $content;
@@ -214,35 +214,35 @@  discard block
 block discarded – undo
214 214
                 break; // No more shortcodes
215 215
             }
216 216
 
217
-            list($_, $before_shortcode, $shortcode, $_, $after_shortcode) = $matches;
217
+            list( $_, $before_shortcode, $shortcode, $_, $after_shortcode ) = $matches;
218 218
 
219
-            if (!$found) { // We're still iffing.
219
+            if ( ! $found ) { // We're still iffing.
220 220
                 $if .= $before_shortcode;
221 221
             } else { // We are elsing
222 222
                 $else .= $before_shortcode;
223 223
             }
224 224
 
225
-            if (0 === strpos($shortcode, '[else]') && 0 === $opens) {
225
+            if ( 0 === strpos( $shortcode, '[else]' ) && 0 === $opens ) {
226 226
                 // This is the else we need!
227 227
                 $found = true;
228
-                if ($match) {
228
+                if ( $match ) {
229 229
                     break; // We just need the if on a match, no need to analyze further
230 230
                 }
231
-            } elseif ($match && 0 === strpos($shortcode, '[else if') && 0 === $opens) {
231
+            } elseif ( $match && 0 === strpos( $shortcode, '[else if' ) && 0 === $opens ) {
232 232
                 $found = true; // We found a match, do not process further
233 233
                 break;
234 234
             } else {
235 235
                 // Increment inner tracking counters
236
-                if (0 === strpos($shortcode, '[gvlogic')) {
236
+                if ( 0 === strpos( $shortcode, '[gvlogic' ) ) {
237 237
                     $opens++;
238 238
                 }
239 239
 
240
-                if (0 === strpos($shortcode, '[/gvlogic')) {
240
+                if ( 0 === strpos( $shortcode, '[/gvlogic' ) ) {
241 241
                     $opens--;
242 242
                 }
243 243
 
244 244
                 // Tack on the shortcode
245
-                if (!$found) { // We're still iffing.
245
+                if ( ! $found ) { // We're still iffing.
246 246
                     $if .= $shortcode;
247 247
                 } else { // We are elsing
248 248
                     $else .= $shortcode;
@@ -252,25 +252,25 @@  discard block
 block discarded – undo
252 252
             $content = $after_shortcode;
253 253
         }
254 254
 
255
-        gravityview()->log->debug('[gvlogic] output parsing:', [
255
+        gravityview()->log->debug( '[gvlogic] output parsing:', [
256 256
             'data' => [
257 257
                 'if'   => $if,
258 258
                 'else' => $else,
259 259
             ],
260
-        ]);
260
+        ] );
261 261
 
262
-        if (!$match) {
263
-            while (($position = strpos($if, '[else if=')) !== false) {
262
+        if ( ! $match ) {
263
+            while ( ( $position = strpos( $if, '[else if=' ) ) !== false ) {
264 264
                 // Try to match one of the elseif's
265
-                $sentinel = wp_generate_password(32, false);
266
-                $if = substr($if, $position); // ...by replacing it with a gvlogic shortcode
265
+                $sentinel = wp_generate_password( 32, false );
266
+                $if = substr( $if, $position ); // ...by replacing it with a gvlogic shortcode
267 267
                 // ..and executing it!
268
-                $result = do_shortcode(preg_replace('#\[else if#', '[gvlogic if', $if, 1)."[else]{$sentinel}[/gvlogic]");
269
-                if ($result !== $sentinel) {
268
+                $result = do_shortcode( preg_replace( '#\[else if#', '[gvlogic if', $if, 1 ) . "[else]{$sentinel}[/gvlogic]" );
269
+                if ( $result !== $sentinel ) {
270 270
                     // We have an elseif match!
271 271
                     return $result;
272 272
                 }
273
-                $if = substr($if, 1); // Move over to get the next elseif match.. and repeat
273
+                $if = substr( $if, 1 ); // Move over to get the next elseif match.. and repeat
274 274
             }
275 275
         }
276 276
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      *
285 285
      * @return array
286 286
      */
287
-    private function get_operators($with_values = false)
287
+    private function get_operators( $with_values = false )
288 288
     {
289 289
         $operators = [
290 290
             'is', 'isnot', 'contains', 'starts_with', 'ends_with',
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
             'less_than_or_is', 'less_than_or_equals', 'not_contains',
294 294
         ];
295 295
 
296
-        if ($with_values) {
296
+        if ( $with_values ) {
297 297
             return array_combine(
298 298
                 $operators,
299
-                array_fill(0, count($operators), '')
299
+                array_fill( 0, count( $operators ), '' )
300 300
             );
301 301
         }
302 302
 
@@ -308,32 +308,32 @@  discard block
 block discarded – undo
308 308
      *
309 309
      * @return array Array of attributes parsed for the shortcode
310 310
      */
311
-    private function parse_atts($atts, $content, $tag)
311
+    private function parse_atts( $atts, $content, $tag )
312 312
     {
313
-        $supplied_atts = !empty($atts) ? $atts : [];
313
+        $supplied_atts = ! empty( $atts ) ? $atts : [ ];
314 314
 
315
-        $atts = shortcode_atts([
315
+        $atts = shortcode_atts( [
316 316
             'if'        => null,
317 317
             'else'      => null,
318 318
             'logged_in' => null,
319
-        ] + $this->get_operators(true), $atts, $tag);
319
+        ] + $this->get_operators( true ), $atts, $tag );
320 320
 
321 321
         // Only keep the passed attributes after making sure that they're valid pairs
322
-        $atts = array_intersect_key($supplied_atts, $atts);
322
+        $atts = array_intersect_key( $supplied_atts, $atts );
323 323
 
324 324
         // Strip whitespace if it's not default false
325
-        if (isset($atts['if']) && is_string($atts['if'])) {
326
-            $atts['if'] = trim($atts['if']);
325
+        if ( isset( $atts[ 'if' ] ) && is_string( $atts[ 'if' ] ) ) {
326
+            $atts[ 'if' ] = trim( $atts[ 'if' ] );
327 327
         } else {
328
-            $atts['if'] = false;
328
+            $atts[ 'if' ] = false;
329 329
         }
330 330
 
331
-        if (isset($atts['logged_in'])) {
331
+        if ( isset( $atts[ 'logged_in' ] ) ) {
332 332
             // Truthy
333
-            if (in_array(strtolower($atts['logged_in']), ['0', 'false', 'no'])) {
334
-                $atts['logged_in'] = false;
333
+            if ( in_array( strtolower( $atts[ 'logged_in' ] ), [ '0', 'false', 'no' ] ) ) {
334
+                $atts[ 'logged_in' ] = false;
335 335
             } else {
336
-                $atts['logged_in'] = true;
336
+                $atts[ 'logged_in' ] = true;
337 337
             }
338 338
         }
339 339
 
@@ -344,6 +344,6 @@  discard block
 block discarded – undo
344 344
          *
345 345
          * @param array $atts The logic attributes.
346 346
          */
347
-        return apply_filters('gravityview/gvlogic/atts', $atts);
347
+        return apply_filters( 'gravityview/gvlogic/atts', $atts );
348 348
     }
349 349
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -25 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * {@inheritDoc}
22 22
      */
23
-    public static function add($name = null)
24
-    {
23
+    public static function add($name = null) {
25 24
         parent::add(); // Me, myself and...
26 25
 
27 26
         /**
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
      *
42 41
      * @return string The output.
43 42
      */
44
-    public function callback($atts, $content = '', $tag = '')
45
-    {
43
+    public function callback($atts, $content = '', $tag = '') {
46 44
         $request = gravityview()->request;
47 45
 
48 46
         if ($request->is_admin()) {
@@ -66,14 +64,16 @@  discard block
 block discarded – undo
66 64
         $value = $this->get_value($atts);
67 65
 
68 66
         if (false === $operator && is_null($value)) {
69
-            if (false !== $atts['if']) { // Only-if test
67
+            if (false !== $atts['if']) {
68
+// Only-if test
70 69
                 $match = $authed && !in_array(strtolower($atts['if']), ['', '0', 'false', 'no']);
71 70
             } else {
72 71
                 $match = $authed; // Just login test
73 72
             }
74 73
 
75 74
             $output = $this->get_output($match, $atts, $content);
76
-        } else { // Regular test
75
+        } else {
76
+// Regular test
77 77
 
78 78
             $output = $content;
79 79
 
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return bool Yes, or no.
125 125
      */
126
-    private function authorized($atts)
127
-    {
126
+    private function authorized($atts) {
128 127
         $needs_login = \GV\Utils::get($atts, 'logged_in', null);
129 128
 
130 129
         if (is_null($needs_login)) {
@@ -141,8 +140,7 @@  discard block
 block discarded – undo
141 140
      *
142 141
      * @return bool|string The operator.
143 142
      */
144
-    private function get_operator($atts)
145
-    {
143
+    private function get_operator($atts) {
146 144
         $valid_ops = $this->get_operators(false);
147 145
 
148 146
         foreach ($atts as $op => $value) {
@@ -165,8 +163,7 @@  discard block
 block discarded – undo
165 163
      *
166 164
      * @return null|string The value.
167 165
      */
168
-    private function get_value($atts)
169
-    {
166
+    private function get_value($atts) {
170 167
         $valid_ops = $this->get_operators(false);
171 168
 
172 169
         foreach ($atts as $op => $value) {
@@ -191,8 +188,7 @@  discard block
 block discarded – undo
191 188
      *
192 189
      * @return string The output.
193 190
      */
194
-    private function get_output($match, $atts, $content)
195
-    {
191
+    private function get_output($match, $atts, $content) {
196 192
         if (!$match && !empty($atts['else'])) {
197 193
             return $atts['else']; // Attributized else is easy :)
198 194
         }
@@ -203,12 +199,15 @@  discard block
 block discarded – undo
203 199
         $opens = 0; // inner opens
204 200
         $found = false; // found split position
205 201
 
206
-        while ($content) { // scan
202
+        while ($content) {
203
+// scan
207 204
 
208 205
             if (!preg_match('#(.*?)(\[\/?(gvlogic|else).*?])(.*)#s', $content, $matches)) {
209
-                if (!$found) { // We're still iffing.
206
+                if (!$found) {
207
+// We're still iffing.
210 208
                     $if .= $content;
211
-                } else { // We are elsing
209
+                } else {
210
+// We are elsing
212 211
                     $else .= $content;
213 212
                 }
214 213
                 break; // No more shortcodes
@@ -216,9 +215,11 @@  discard block
 block discarded – undo
216 215
 
217 216
             list($_, $before_shortcode, $shortcode, $_, $after_shortcode) = $matches;
218 217
 
219
-            if (!$found) { // We're still iffing.
218
+            if (!$found) {
219
+// We're still iffing.
220 220
                 $if .= $before_shortcode;
221
-            } else { // We are elsing
221
+            } else {
222
+// We are elsing
222 223
                 $else .= $before_shortcode;
223 224
             }
224 225
 
@@ -242,9 +243,11 @@  discard block
 block discarded – undo
242 243
                 }
243 244
 
244 245
                 // Tack on the shortcode
245
-                if (!$found) { // We're still iffing.
246
+                if (!$found) {
247
+// We're still iffing.
246 248
                     $if .= $shortcode;
247
-                } else { // We are elsing
249
+                } else {
250
+// We are elsing
248 251
                     $else .= $shortcode;
249 252
                 }
250 253
             }
@@ -284,8 +287,7 @@  discard block
 block discarded – undo
284 287
      *
285 288
      * @return array
286 289
      */
287
-    private function get_operators($with_values = false)
288
-    {
290
+    private function get_operators($with_values = false) {
289 291
         $operators = [
290 292
             'is', 'isnot', 'contains', 'starts_with', 'ends_with',
291 293
             'greater_than', 'less_than', 'in', 'not_in',
@@ -308,8 +310,7 @@  discard block
 block discarded – undo
308 310
      *
309 311
      * @return array Array of attributes parsed for the shortcode
310 312
      */
311
-    private function parse_atts($atts, $content, $tag)
312
-    {
313
+    private function parse_atts($atts, $content, $tag) {
313 314
         $supplied_atts = !empty($atts) ? $atts : [];
314 315
 
315 316
         $atts = shortcode_atts([
Please login to merge, or discard this patch.
future/includes/class-gv-template-entry.php 3 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @see https://github.com/GaryJones/Gamajo-Template-Loader
14 14
  */
15 15
 if (!class_exists('\GV\Gamajo_Template_Loader')) {
16
-    require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
16
+	require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
17 17
 }
18 18
 
19 19
 /**
@@ -23,172 +23,172 @@  discard block
 block discarded – undo
23 23
  */
24 24
 abstract class Entry_Template extends Template
25 25
 {
26
-    /**
27
-     * Prefix for filter names.
28
-     *
29
-     * @var string
30
-     */
31
-    protected $filter_prefix = 'gravityview/template/entries';
32
-
33
-    /**
34
-     * Directory name where custom templates for this plugin should be found in the theme.
35
-     *
36
-     * @var string
37
-     */
38
-    protected $theme_template_directory = 'gravityview/entries/';
39
-
40
-    /**
41
-     * Directory name where the default templates for this plugin are found.
42
-     *
43
-     * @var string
44
-     */
45
-    protected $plugin_template_directory = 'templates/entries/';
46
-
47
-    /**
48
-     * @var \GV\Entry The entry that need to be rendered.
49
-     */
50
-    public $entry;
51
-
52
-    /**
53
-     * @var \GV\View The view context.
54
-     */
55
-    public $view;
56
-
57
-    /**
58
-     * @var \GV\Request The request context.
59
-     */
60
-    public $request;
61
-
62
-    /**
63
-     * @var string The template slug to be loaded (like "table", "list")
64
-     */
65
-    public static $slug;
66
-
67
-    /**
68
-     * Initializer.
69
-     *
70
-     * @param \GV\View             $view    The View connected to this template.
71
-     * @param \GV\Entry_Collection $entries A collection of entries for this view.
72
-     * @param \GV\Request          $request The request context.
73
-     */
74
-    public function __construct(Entry $entry, View $view, Request $request)
75
-    {
76
-        $this->entry = $entry;
77
-        $this->view = $view;
78
-        $this->request = $request;
79
-
80
-        /** Add granular overrides. */
81
-        add_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates'], 10, 3);
82
-
83
-        parent::__construct();
84
-    }
85
-
86
-    public function __destruct()
87
-    {
88
-        remove_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates']);
89
-    }
90
-
91
-    /**
92
-     * Enable granular template overrides based on current post, view, form, etc.
93
-     *
94
-     * The loading order is:
95
-     *
96
-     * - post-[ID of post or page where view is embedded]-view-[View ID]-entry-[Entry ID]-table-footer.php
97
-     * - post-[ID of post or page where view is embedded]-entry-[Entry ID]-table-footer.php
98
-     * - post-[ID of post or page where view is embedded]-view-[View ID]-table-footer.php
99
-     * - post-[ID of post or page where view is embedded]-table-footer.php
100
-     * - view-[View ID]-entry-[Entry ID]-table-footer.php
101
-     * - form-[Form ID]-entry-[Entry ID]-table-footer.php
102
-     * - view-[View ID]-table-footer.php
103
-     * - form-[Form ID]-table-footer.php
104
-     * - entry-[Entry ID]-table-footer.php
105
-     * - table-footer.php
106
-     *
107
-     * @see  Gamajo_Template_Loader::get_template_file_names() Where the filter is
108
-     *
109
-     * @param array  $templates Existing list of templates.
110
-     * @param string $slug      Name of the template base, example: `table`, `list`, `datatables`, `map`
111
-     * @param string $name      Name of the template part, example: `body`, `footer`, `head`, `single`
112
-     *
113
-     * @return array $templates Modified template array, merged with existing $templates values
114
-     */
115
-    public function add_id_specific_templates($templates, $slug, $name)
116
-    {
117
-        $specifics = [];
118
-
119
-        list($slug_dir, $slug_name) = self::split_slug($slug, $name);
120
-
121
-        global $post;
122
-
123
-        if (!$this->request->is_view() && $post) {
124
-            $specifics[] = sprintf('%spost-%d-view-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $this->entry->ID, $slug_name);
125
-            $specifics[] = sprintf('%spost-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->entry->ID, $slug_name);
126
-            $specifics[] = sprintf('%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name);
127
-            $specifics[] = sprintf('%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name);
128
-        }
129
-
130
-        $specifics[] = sprintf('%sview-%d-entry-%d-%s.php', $slug_dir, $this->view->ID, $this->entry->ID, $slug_name);
131
-        $specifics[] = sprintf('%sform-%d-entry-%d-%s.php', $slug_dir, $this->view->form->ID, $this->entry->ID, $slug_name);
132
-        $specifics[] = sprintf('%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name);
133
-        $specifics[] = sprintf('%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name);
134
-
135
-        $specifics[] = sprintf('%sentry-%d-%s.php', $slug_dir, $this->entry->ID, $slug_name);
136
-
137
-        return array_merge($specifics, $templates);
138
-    }
139
-
140
-    /**
141
-     * Output some HTML.
142
-     *
143
-     * @return void
144
-     */
145
-    public function render()
146
-    {
147
-        $context = Template_Context::from_template($this);
148
-
149
-        /**
150
-         * Make various pieces of data available to the template
151
-         *  under the $gravityview scoped variable.
152
-         *
153
-         * @filter `gravityview/template/entry/context`
154
-         *
155
-         * @param \GV\Template_Context $context  The context for this template.
156
-         * @param \GV\Entry_Template   $template The current template.
157
-         *
158
-         * @since 2.0
159
-         */
160
-        $this->push_template_data(apply_filters('gravityview/template/entry/context', $context, $this), 'gravityview');
161
-
162
-        /** Load the template. */
163
-        $this->get_template_part(static::$slug);
164
-        $this->pop_template_data('gravityview');
165
-    }
166
-
167
-    /**
168
-     * Fetch the back link label for an entry context.
169
-     *
170
-     * @param bool $do_replace Whether to perform merge tag replacements, etc.
171
-     *
172
-     * @see `gravityview/template/links/back/label` filter
173
-     *
174
-     * @return string The link label
175
-     */
176
-    public function get_back_label($do_replace = true)
177
-    {
178
-        if (!$this->view) {
179
-            return '';
180
-        }
181
-
182
-        $back_link_label = $this->view->settings->get('back_link_label', null);
183
-
184
-        if ($do_replace) {
185
-            $back_link_label = \GravityView_API::replace_variables($back_link_label, Utils::get($this->view, 'form/form'), $this->entry->as_entry());
186
-
187
-            return do_shortcode($back_link_label);
188
-        }
189
-
190
-        return $back_link_label;
191
-    }
26
+	/**
27
+	 * Prefix for filter names.
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected $filter_prefix = 'gravityview/template/entries';
32
+
33
+	/**
34
+	 * Directory name where custom templates for this plugin should be found in the theme.
35
+	 *
36
+	 * @var string
37
+	 */
38
+	protected $theme_template_directory = 'gravityview/entries/';
39
+
40
+	/**
41
+	 * Directory name where the default templates for this plugin are found.
42
+	 *
43
+	 * @var string
44
+	 */
45
+	protected $plugin_template_directory = 'templates/entries/';
46
+
47
+	/**
48
+	 * @var \GV\Entry The entry that need to be rendered.
49
+	 */
50
+	public $entry;
51
+
52
+	/**
53
+	 * @var \GV\View The view context.
54
+	 */
55
+	public $view;
56
+
57
+	/**
58
+	 * @var \GV\Request The request context.
59
+	 */
60
+	public $request;
61
+
62
+	/**
63
+	 * @var string The template slug to be loaded (like "table", "list")
64
+	 */
65
+	public static $slug;
66
+
67
+	/**
68
+	 * Initializer.
69
+	 *
70
+	 * @param \GV\View             $view    The View connected to this template.
71
+	 * @param \GV\Entry_Collection $entries A collection of entries for this view.
72
+	 * @param \GV\Request          $request The request context.
73
+	 */
74
+	public function __construct(Entry $entry, View $view, Request $request)
75
+	{
76
+		$this->entry = $entry;
77
+		$this->view = $view;
78
+		$this->request = $request;
79
+
80
+		/** Add granular overrides. */
81
+		add_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates'], 10, 3);
82
+
83
+		parent::__construct();
84
+	}
85
+
86
+	public function __destruct()
87
+	{
88
+		remove_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates']);
89
+	}
90
+
91
+	/**
92
+	 * Enable granular template overrides based on current post, view, form, etc.
93
+	 *
94
+	 * The loading order is:
95
+	 *
96
+	 * - post-[ID of post or page where view is embedded]-view-[View ID]-entry-[Entry ID]-table-footer.php
97
+	 * - post-[ID of post or page where view is embedded]-entry-[Entry ID]-table-footer.php
98
+	 * - post-[ID of post or page where view is embedded]-view-[View ID]-table-footer.php
99
+	 * - post-[ID of post or page where view is embedded]-table-footer.php
100
+	 * - view-[View ID]-entry-[Entry ID]-table-footer.php
101
+	 * - form-[Form ID]-entry-[Entry ID]-table-footer.php
102
+	 * - view-[View ID]-table-footer.php
103
+	 * - form-[Form ID]-table-footer.php
104
+	 * - entry-[Entry ID]-table-footer.php
105
+	 * - table-footer.php
106
+	 *
107
+	 * @see  Gamajo_Template_Loader::get_template_file_names() Where the filter is
108
+	 *
109
+	 * @param array  $templates Existing list of templates.
110
+	 * @param string $slug      Name of the template base, example: `table`, `list`, `datatables`, `map`
111
+	 * @param string $name      Name of the template part, example: `body`, `footer`, `head`, `single`
112
+	 *
113
+	 * @return array $templates Modified template array, merged with existing $templates values
114
+	 */
115
+	public function add_id_specific_templates($templates, $slug, $name)
116
+	{
117
+		$specifics = [];
118
+
119
+		list($slug_dir, $slug_name) = self::split_slug($slug, $name);
120
+
121
+		global $post;
122
+
123
+		if (!$this->request->is_view() && $post) {
124
+			$specifics[] = sprintf('%spost-%d-view-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $this->entry->ID, $slug_name);
125
+			$specifics[] = sprintf('%spost-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->entry->ID, $slug_name);
126
+			$specifics[] = sprintf('%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name);
127
+			$specifics[] = sprintf('%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name);
128
+		}
129
+
130
+		$specifics[] = sprintf('%sview-%d-entry-%d-%s.php', $slug_dir, $this->view->ID, $this->entry->ID, $slug_name);
131
+		$specifics[] = sprintf('%sform-%d-entry-%d-%s.php', $slug_dir, $this->view->form->ID, $this->entry->ID, $slug_name);
132
+		$specifics[] = sprintf('%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name);
133
+		$specifics[] = sprintf('%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name);
134
+
135
+		$specifics[] = sprintf('%sentry-%d-%s.php', $slug_dir, $this->entry->ID, $slug_name);
136
+
137
+		return array_merge($specifics, $templates);
138
+	}
139
+
140
+	/**
141
+	 * Output some HTML.
142
+	 *
143
+	 * @return void
144
+	 */
145
+	public function render()
146
+	{
147
+		$context = Template_Context::from_template($this);
148
+
149
+		/**
150
+		 * Make various pieces of data available to the template
151
+		 *  under the $gravityview scoped variable.
152
+		 *
153
+		 * @filter `gravityview/template/entry/context`
154
+		 *
155
+		 * @param \GV\Template_Context $context  The context for this template.
156
+		 * @param \GV\Entry_Template   $template The current template.
157
+		 *
158
+		 * @since 2.0
159
+		 */
160
+		$this->push_template_data(apply_filters('gravityview/template/entry/context', $context, $this), 'gravityview');
161
+
162
+		/** Load the template. */
163
+		$this->get_template_part(static::$slug);
164
+		$this->pop_template_data('gravityview');
165
+	}
166
+
167
+	/**
168
+	 * Fetch the back link label for an entry context.
169
+	 *
170
+	 * @param bool $do_replace Whether to perform merge tag replacements, etc.
171
+	 *
172
+	 * @see `gravityview/template/links/back/label` filter
173
+	 *
174
+	 * @return string The link label
175
+	 */
176
+	public function get_back_label($do_replace = true)
177
+	{
178
+		if (!$this->view) {
179
+			return '';
180
+		}
181
+
182
+		$back_link_label = $this->view->settings->get('back_link_label', null);
183
+
184
+		if ($do_replace) {
185
+			$back_link_label = \GravityView_API::replace_variables($back_link_label, Utils::get($this->view, 'form/form'), $this->entry->as_entry());
186
+
187
+			return do_shortcode($back_link_label);
188
+		}
189
+
190
+		return $back_link_label;
191
+	}
192 192
 }
193 193
 
194 194
 /** Load implementations. */
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @see https://github.com/GaryJones/Gamajo-Template-Loader
14 14
  */
15
-if (!class_exists('\GV\Gamajo_Template_Loader')) {
16
-    require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
15
+if ( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) {
16
+    require gravityview()->plugin->dir( 'future/lib/class-gamajo-template-loader.php' );
17 17
 }
18 18
 
19 19
 /**
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
      * @param \GV\Entry_Collection $entries A collection of entries for this view.
72 72
      * @param \GV\Request          $request The request context.
73 73
      */
74
-    public function __construct(Entry $entry, View $view, Request $request)
74
+    public function __construct( Entry $entry, View $view, Request $request )
75 75
     {
76 76
         $this->entry = $entry;
77 77
         $this->view = $view;
78 78
         $this->request = $request;
79 79
 
80 80
         /** Add granular overrides. */
81
-        add_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates'], 10, 3);
81
+        add_filter( $this->filter_prefix . '_get_template_part', [ $this, 'add_id_specific_templates' ], 10, 3 );
82 82
 
83 83
         parent::__construct();
84 84
     }
85 85
 
86 86
     public function __destruct()
87 87
     {
88
-        remove_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates']);
88
+        remove_filter( $this->filter_prefix . '_get_template_part', [ $this, 'add_id_specific_templates' ] );
89 89
     }
90 90
 
91 91
     /**
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return array $templates Modified template array, merged with existing $templates values
114 114
      */
115
-    public function add_id_specific_templates($templates, $slug, $name)
115
+    public function add_id_specific_templates( $templates, $slug, $name )
116 116
     {
117
-        $specifics = [];
117
+        $specifics = [ ];
118 118
 
119
-        list($slug_dir, $slug_name) = self::split_slug($slug, $name);
119
+        list( $slug_dir, $slug_name ) = self::split_slug( $slug, $name );
120 120
 
121 121
         global $post;
122 122
 
123
-        if (!$this->request->is_view() && $post) {
124
-            $specifics[] = sprintf('%spost-%d-view-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $this->entry->ID, $slug_name);
125
-            $specifics[] = sprintf('%spost-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->entry->ID, $slug_name);
126
-            $specifics[] = sprintf('%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name);
127
-            $specifics[] = sprintf('%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name);
123
+        if ( ! $this->request->is_view() && $post ) {
124
+            $specifics[ ] = sprintf( '%spost-%d-view-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $this->entry->ID, $slug_name );
125
+            $specifics[ ] = sprintf( '%spost-%d-entry-%d-%s.php', $slug_dir, $post->ID, $this->entry->ID, $slug_name );
126
+            $specifics[ ] = sprintf( '%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name );
127
+            $specifics[ ] = sprintf( '%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name );
128 128
         }
129 129
 
130
-        $specifics[] = sprintf('%sview-%d-entry-%d-%s.php', $slug_dir, $this->view->ID, $this->entry->ID, $slug_name);
131
-        $specifics[] = sprintf('%sform-%d-entry-%d-%s.php', $slug_dir, $this->view->form->ID, $this->entry->ID, $slug_name);
132
-        $specifics[] = sprintf('%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name);
133
-        $specifics[] = sprintf('%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name);
130
+        $specifics[ ] = sprintf( '%sview-%d-entry-%d-%s.php', $slug_dir, $this->view->ID, $this->entry->ID, $slug_name );
131
+        $specifics[ ] = sprintf( '%sform-%d-entry-%d-%s.php', $slug_dir, $this->view->form->ID, $this->entry->ID, $slug_name );
132
+        $specifics[ ] = sprintf( '%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name );
133
+        $specifics[ ] = sprintf( '%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name );
134 134
 
135
-        $specifics[] = sprintf('%sentry-%d-%s.php', $slug_dir, $this->entry->ID, $slug_name);
135
+        $specifics[ ] = sprintf( '%sentry-%d-%s.php', $slug_dir, $this->entry->ID, $slug_name );
136 136
 
137
-        return array_merge($specifics, $templates);
137
+        return array_merge( $specifics, $templates );
138 138
     }
139 139
 
140 140
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function render()
146 146
     {
147
-        $context = Template_Context::from_template($this);
147
+        $context = Template_Context::from_template( $this );
148 148
 
149 149
         /**
150 150
          * Make various pieces of data available to the template
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
          *
158 158
          * @since 2.0
159 159
          */
160
-        $this->push_template_data(apply_filters('gravityview/template/entry/context', $context, $this), 'gravityview');
160
+        $this->push_template_data( apply_filters( 'gravityview/template/entry/context', $context, $this ), 'gravityview' );
161 161
 
162 162
         /** Load the template. */
163
-        $this->get_template_part(static::$slug);
164
-        $this->pop_template_data('gravityview');
163
+        $this->get_template_part( static::$slug );
164
+        $this->pop_template_data( 'gravityview' );
165 165
     }
166 166
 
167 167
     /**
@@ -173,18 +173,18 @@  discard block
 block discarded – undo
173 173
      *
174 174
      * @return string The link label
175 175
      */
176
-    public function get_back_label($do_replace = true)
176
+    public function get_back_label( $do_replace = true )
177 177
     {
178
-        if (!$this->view) {
178
+        if ( ! $this->view ) {
179 179
             return '';
180 180
         }
181 181
 
182
-        $back_link_label = $this->view->settings->get('back_link_label', null);
182
+        $back_link_label = $this->view->settings->get( 'back_link_label', null );
183 183
 
184
-        if ($do_replace) {
185
-            $back_link_label = \GravityView_API::replace_variables($back_link_label, Utils::get($this->view, 'form/form'), $this->entry->as_entry());
184
+        if ( $do_replace ) {
185
+            $back_link_label = \GravityView_API::replace_variables( $back_link_label, Utils::get( $this->view, 'form/form' ), $this->entry->as_entry() );
186 186
 
187
-            return do_shortcode($back_link_label);
187
+            return do_shortcode( $back_link_label );
188 188
         }
189 189
 
190 190
         return $back_link_label;
@@ -192,6 +192,6 @@  discard block
 block discarded – undo
192 192
 }
193 193
 
194 194
 /** Load implementations. */
195
-require gravityview()->plugin->dir('future/includes/class-gv-template-entry-table.php');
196
-require gravityview()->plugin->dir('future/includes/class-gv-template-entry-list.php');
197
-require gravityview()->plugin->dir('future/includes/class-gv-template-entry-legacy.php');
195
+require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-table.php' );
196
+require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-list.php' );
197
+require gravityview()->plugin->dir( 'future/includes/class-gv-template-entry-legacy.php' );
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * Renders a \GV\Entry using a \GV\Entry_Renderer.
23 23
  */
24
-abstract class Entry_Template extends Template
25
-{
24
+abstract class Entry_Template extends Template {
26 25
     /**
27 26
      * Prefix for filter names.
28 27
      *
@@ -71,8 +70,7 @@  discard block
 block discarded – undo
71 70
      * @param \GV\Entry_Collection $entries A collection of entries for this view.
72 71
      * @param \GV\Request          $request The request context.
73 72
      */
74
-    public function __construct(Entry $entry, View $view, Request $request)
75
-    {
73
+    public function __construct(Entry $entry, View $view, Request $request) {
76 74
         $this->entry = $entry;
77 75
         $this->view = $view;
78 76
         $this->request = $request;
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
         parent::__construct();
84 82
     }
85 83
 
86
-    public function __destruct()
87
-    {
84
+    public function __destruct() {
88 85
         remove_filter($this->filter_prefix.'_get_template_part', [$this, 'add_id_specific_templates']);
89 86
     }
90 87
 
@@ -112,8 +109,7 @@  discard block
 block discarded – undo
112 109
      *
113 110
      * @return array $templates Modified template array, merged with existing $templates values
114 111
      */
115
-    public function add_id_specific_templates($templates, $slug, $name)
116
-    {
112
+    public function add_id_specific_templates($templates, $slug, $name) {
117 113
         $specifics = [];
118 114
 
119 115
         list($slug_dir, $slug_name) = self::split_slug($slug, $name);
@@ -142,8 +138,7 @@  discard block
 block discarded – undo
142 138
      *
143 139
      * @return void
144 140
      */
145
-    public function render()
146
-    {
141
+    public function render() {
147 142
         $context = Template_Context::from_template($this);
148 143
 
149 144
         /**
@@ -173,8 +168,7 @@  discard block
 block discarded – undo
173 168
      *
174 169
      * @return string The link label
175 170
      */
176
-    public function get_back_label($do_replace = true)
177
-    {
171
+    public function get_back_label($do_replace = true) {
178 172
         if (!$this->view) {
179 173
             return '';
180 174
         }
Please login to merge, or discard this patch.
future/includes/class-gv-context-template.php 3 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,88 +14,88 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Template_Context extends Context
16 16
 {
17
-    /**
18
-     * @var \GV\Template The template.
19
-     */
20
-    public $template;
21
-
22
-    /**
23
-     * @var \GV\View The view.
24
-     */
25
-    public $view;
26
-
27
-    /**
28
-     * @var \GV\Entry The entry. If single-entry view.
29
-     */
30
-    public $entry;
31
-
32
-    /**
33
-     * @var \GV\Entry_Collection The entries. If directory view.
34
-     */
35
-    public $entries;
36
-
37
-    /**
38
-     * @var \GV\Field_Collection The fields.
39
-     */
40
-    public $fields;
41
-
42
-    /**
43
-     * @var \GV\Field The field. When rendering a single field.
44
-     */
45
-    public $field;
46
-
47
-    /**
48
-     * @var \GV\Source The data source for a field.
49
-     */
50
-    public $source;
51
-
52
-    /**
53
-     * @var mixed The display value for a field.
54
-     */
55
-    public $display_value;
56
-
57
-    /**
58
-     * @var mixed The raw value for a field.
59
-     */
60
-    public $value;
61
-
62
-    /**
63
-     * @var \GV\Request The request.
64
-     */
65
-    public $request;
66
-
67
-    /**
68
-     * Create a context from a Template.
69
-     *
70
-     * @param \GV\Template|array $template The template or array with values expected in a template
71
-     * @param array              $data     Additional data not tied to the template object.
72
-     *
73
-     * @return \GV\Template_Context The context holder.
74
-     */
75
-    public static function from_template($template, $data = [])
76
-    {
77
-        $context = new self();
78
-
79
-        $context->template = $template;
80
-
81
-        /**
82
-         * Data.
83
-         */
84
-        $context->display_value = Utils::get($data, 'display_value');
85
-        $context->value = Utils::get($data, 'value');
86
-
87
-        /**
88
-         * Shortcuts.
89
-         */
90
-        $context->view = Utils::get($template, 'view');
91
-        $context->source = Utils::get($template, 'source');
92
-        $context->field = Utils::get($template, 'field') ?: Utils::get($data, 'field');
93
-        $context->entry = Utils::get($template, 'entry') ?: Utils::get($data, 'entry');
94
-        $context->request = Utils::get($template, 'request');
95
-
96
-        $context->entries = Utils::get($template, 'entries') ? $template->entries : null;
97
-        $context->fields = $context->view ? $context->view->fields : null;
98
-
99
-        return $context;
100
-    }
17
+	/**
18
+	 * @var \GV\Template The template.
19
+	 */
20
+	public $template;
21
+
22
+	/**
23
+	 * @var \GV\View The view.
24
+	 */
25
+	public $view;
26
+
27
+	/**
28
+	 * @var \GV\Entry The entry. If single-entry view.
29
+	 */
30
+	public $entry;
31
+
32
+	/**
33
+	 * @var \GV\Entry_Collection The entries. If directory view.
34
+	 */
35
+	public $entries;
36
+
37
+	/**
38
+	 * @var \GV\Field_Collection The fields.
39
+	 */
40
+	public $fields;
41
+
42
+	/**
43
+	 * @var \GV\Field The field. When rendering a single field.
44
+	 */
45
+	public $field;
46
+
47
+	/**
48
+	 * @var \GV\Source The data source for a field.
49
+	 */
50
+	public $source;
51
+
52
+	/**
53
+	 * @var mixed The display value for a field.
54
+	 */
55
+	public $display_value;
56
+
57
+	/**
58
+	 * @var mixed The raw value for a field.
59
+	 */
60
+	public $value;
61
+
62
+	/**
63
+	 * @var \GV\Request The request.
64
+	 */
65
+	public $request;
66
+
67
+	/**
68
+	 * Create a context from a Template.
69
+	 *
70
+	 * @param \GV\Template|array $template The template or array with values expected in a template
71
+	 * @param array              $data     Additional data not tied to the template object.
72
+	 *
73
+	 * @return \GV\Template_Context The context holder.
74
+	 */
75
+	public static function from_template($template, $data = [])
76
+	{
77
+		$context = new self();
78
+
79
+		$context->template = $template;
80
+
81
+		/**
82
+		 * Data.
83
+		 */
84
+		$context->display_value = Utils::get($data, 'display_value');
85
+		$context->value = Utils::get($data, 'value');
86
+
87
+		/**
88
+		 * Shortcuts.
89
+		 */
90
+		$context->view = Utils::get($template, 'view');
91
+		$context->source = Utils::get($template, 'source');
92
+		$context->field = Utils::get($template, 'field') ?: Utils::get($data, 'field');
93
+		$context->entry = Utils::get($template, 'entry') ?: Utils::get($data, 'entry');
94
+		$context->request = Utils::get($template, 'request');
95
+
96
+		$context->entries = Utils::get($template, 'entries') ? $template->entries : null;
97
+		$context->fields = $context->view ? $context->view->fields : null;
98
+
99
+		return $context;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return \GV\Template_Context The context holder.
74 74
      */
75
-    public static function from_template($template, $data = [])
75
+    public static function from_template( $template, $data = [ ] )
76 76
     {
77 77
         $context = new self();
78 78
 
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
         /**
82 82
          * Data.
83 83
          */
84
-        $context->display_value = Utils::get($data, 'display_value');
85
-        $context->value = Utils::get($data, 'value');
84
+        $context->display_value = Utils::get( $data, 'display_value' );
85
+        $context->value = Utils::get( $data, 'value' );
86 86
 
87 87
         /**
88 88
          * Shortcuts.
89 89
          */
90
-        $context->view = Utils::get($template, 'view');
91
-        $context->source = Utils::get($template, 'source');
92
-        $context->field = Utils::get($template, 'field') ?: Utils::get($data, 'field');
93
-        $context->entry = Utils::get($template, 'entry') ?: Utils::get($data, 'entry');
94
-        $context->request = Utils::get($template, 'request');
90
+        $context->view = Utils::get( $template, 'view' );
91
+        $context->source = Utils::get( $template, 'source' );
92
+        $context->field = Utils::get( $template, 'field' ) ?: Utils::get( $data, 'field' );
93
+        $context->entry = Utils::get( $template, 'entry' ) ?: Utils::get( $data, 'entry' );
94
+        $context->request = Utils::get( $template, 'request' );
95 95
 
96
-        $context->entries = Utils::get($template, 'entries') ? $template->entries : null;
96
+        $context->entries = Utils::get( $template, 'entries' ) ? $template->entries : null;
97 97
         $context->fields = $context->view ? $context->view->fields : null;
98 98
 
99 99
         return $context;
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * This is provided to most template files as a global.
14 14
  */
15
-class Template_Context extends Context
16
-{
15
+class Template_Context extends Context {
17 16
     /**
18 17
      * @var \GV\Template The template.
19 18
      */
@@ -72,8 +71,7 @@  discard block
 block discarded – undo
72 71
      *
73 72
      * @return \GV\Template_Context The context holder.
74 73
      */
75
-    public static function from_template($template, $data = [])
76
-    {
74
+    public static function from_template($template, $data = []) {
77 75
         $context = new self();
78 76
 
79 77
         $context->template = $template;
Please login to merge, or discard this patch.
future/includes/class-gv-renderer-entry.php 3 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,140 +14,140 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Entry_Renderer extends Renderer
16 16
 {
17
-    /**
18
-     * Renders a single \GV\Entry instance.
19
-     *
20
-     * @param \GV\Entry   $entry   The Entry instance to render.
21
-     * @param \GV\View    $view    The View connected to the entry.
22
-     * @param \GV\Request $request The request context we're currently in. Default: `gravityview()->request`
23
-     *
24
-     * @api
25
-     *
26
-     * @since 2.0
27
-     *
28
-     * @return string The rendered Entry.
29
-     */
30
-    public function render(Entry $entry, View $view, Request $request = null)
31
-    {
32
-        if (is_null($request)) {
33
-            $request = &gravityview()->request;
34
-        }
35
-
36
-        if (!$request->is_renderable()) {
37
-            gravityview()->log->error('Renderer unable to render Entry in {request_class} context', ['request_class' => get_class($request)]);
38
-
39
-            return null;
40
-        }
41
-
42
-        /**
43
-         * This View is password protected. Output the form.
44
-         */
45
-        if (post_password_required($view->ID)) {
46
-            return get_the_password_form($view->ID);
47
-        }
48
-
49
-        /**
50
-         * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID
51
-         *
52
-         * @since 1.17
53
-         * @since 2.0
54
-         *
55
-         * @param \GV\Entry   $entry   The entry about to be rendered
56
-         * @param \GV\View    $view    The connected view
57
-         * @param \GV\Request $request The associated request
58
-         */
59
-        do_action('gravityview_render_entry_'.$view->ID, $entry, $view, $request);
60
-
61
-        /** Entry does not belong to this view. */
62
-        if ($view->joins) {
63
-            $form_ids = [];
64
-            foreach ($view->joins as $join) {
65
-                $form_ids[] = $join->join->ID;
66
-                $form_ids[] = $join->join_on->ID;
67
-            }
68
-            foreach ($entry->entries as $e) {
69
-                if (!in_array($e['form_id'], $form_ids)) {
70
-                    gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $e->ID, 'view_id' => $view->ID]);
71
-
72
-                    return null;
73
-                }
74
-            }
75
-        } elseif ($view->form && $view->form->ID != $entry['form_id']) {
76
-            gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $entry->ID, 'view_id' => $view->ID]);
77
-
78
-            return null;
79
-        }
80
-
81
-        /**
82
-         * @filter `gravityview_template_slug_{$template_id}` Modify the template slug about to be loaded in directory views.
83
-         *
84
-         * @since 1.6
85
-         *
86
-         * @param deprecated
87
-         *
88
-         * @see The `gravityview_get_template_id` filter
89
-         *
90
-         * @param string $slug Default: 'table'
91
-         * @param string $view The current view context: single
92
-         */
93
-        $template_slug = apply_filters('gravityview_template_slug_'.$view->settings->get('template'), 'table', 'single');
94
-
95
-        /**
96
-         * Load a legacy override template if exists.
97
-         */
98
-        $override = new \GV\Legacy_Override_Template($view, $entry, null, $request);
99
-        foreach (['single'] as $part) {
100
-            if (($path = $override->get_template_part($template_slug, $part)) && strpos($path, '/deprecated') === false) {
101
-                /**
102
-                 * We have to bail and call the legacy renderer. Crap!
103
-                 */
104
-                gravityview()->log->notice('Legacy templates detected in theme {path}', ['path' => $path]);
105
-
106
-                /**
107
-                 * Show a warning at the top, if View is editable by the user.
108
-                 */
109
-                add_action('gravityview_before', $this->legacy_template_warning($view, $path));
110
-
111
-                return $override->render($template_slug);
112
-            }
113
-        }
114
-
115
-        /**
116
-         * @filter `gravityview/template/entry/class` Filter the template class that is about to be used to render the entry.
117
-         *
118
-         * @since 2.0
119
-         *
120
-         * @param string      $class   The chosen class - Default: \GV\Entry_Table_Template.
121
-         * @param \GV\Entry   $entry   The entry about to be rendered.
122
-         * @param \GV\View    $view    The view connected to it.
123
-         * @param \GV\Request $request The associated request.
124
-         */
125
-        $class = apply_filters('gravityview/template/entry/class', sprintf('\GV\Entry_%s_Template', ucfirst($template_slug)), $entry, $view, $request);
126
-        if (!$class || !class_exists($class)) {
127
-            gravityview()->log->notice('{template_class} not found, falling back to legacy', ['template_class' => $class]);
128
-            $class = '\GV\Entry_Legacy_Template';
129
-        }
130
-        $template = new $class($entry, $view, $request);
131
-
132
-        add_action('gravityview/template/after', $view_id_output = function ($context) {
133
-            printf('<input type="hidden" class="gravityview-view-id" value="%d">', $context->view->ID);
134
-        });
135
-
136
-        /** Mock the legacy state for the widgets and whatnot */
137
-        $entries = new Entry_Collection();
138
-        $entries->add($entry);
139
-        \GV\Mocks\Legacy_Context::push([
140
-            'view'    => $view,
141
-            'entries' => $entries,
142
-            'entry'   => $entry,
143
-            'request' => $request,
144
-        ]);
145
-
146
-        ob_start();
147
-        $template->render();
148
-
149
-        remove_action('gravityview/template/after', $view_id_output);
150
-
151
-        return ob_get_clean();
152
-    }
17
+	/**
18
+	 * Renders a single \GV\Entry instance.
19
+	 *
20
+	 * @param \GV\Entry   $entry   The Entry instance to render.
21
+	 * @param \GV\View    $view    The View connected to the entry.
22
+	 * @param \GV\Request $request The request context we're currently in. Default: `gravityview()->request`
23
+	 *
24
+	 * @api
25
+	 *
26
+	 * @since 2.0
27
+	 *
28
+	 * @return string The rendered Entry.
29
+	 */
30
+	public function render(Entry $entry, View $view, Request $request = null)
31
+	{
32
+		if (is_null($request)) {
33
+			$request = &gravityview()->request;
34
+		}
35
+
36
+		if (!$request->is_renderable()) {
37
+			gravityview()->log->error('Renderer unable to render Entry in {request_class} context', ['request_class' => get_class($request)]);
38
+
39
+			return null;
40
+		}
41
+
42
+		/**
43
+		 * This View is password protected. Output the form.
44
+		 */
45
+		if (post_password_required($view->ID)) {
46
+			return get_the_password_form($view->ID);
47
+		}
48
+
49
+		/**
50
+		 * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID
51
+		 *
52
+		 * @since 1.17
53
+		 * @since 2.0
54
+		 *
55
+		 * @param \GV\Entry   $entry   The entry about to be rendered
56
+		 * @param \GV\View    $view    The connected view
57
+		 * @param \GV\Request $request The associated request
58
+		 */
59
+		do_action('gravityview_render_entry_'.$view->ID, $entry, $view, $request);
60
+
61
+		/** Entry does not belong to this view. */
62
+		if ($view->joins) {
63
+			$form_ids = [];
64
+			foreach ($view->joins as $join) {
65
+				$form_ids[] = $join->join->ID;
66
+				$form_ids[] = $join->join_on->ID;
67
+			}
68
+			foreach ($entry->entries as $e) {
69
+				if (!in_array($e['form_id'], $form_ids)) {
70
+					gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $e->ID, 'view_id' => $view->ID]);
71
+
72
+					return null;
73
+				}
74
+			}
75
+		} elseif ($view->form && $view->form->ID != $entry['form_id']) {
76
+			gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $entry->ID, 'view_id' => $view->ID]);
77
+
78
+			return null;
79
+		}
80
+
81
+		/**
82
+		 * @filter `gravityview_template_slug_{$template_id}` Modify the template slug about to be loaded in directory views.
83
+		 *
84
+		 * @since 1.6
85
+		 *
86
+		 * @param deprecated
87
+		 *
88
+		 * @see The `gravityview_get_template_id` filter
89
+		 *
90
+		 * @param string $slug Default: 'table'
91
+		 * @param string $view The current view context: single
92
+		 */
93
+		$template_slug = apply_filters('gravityview_template_slug_'.$view->settings->get('template'), 'table', 'single');
94
+
95
+		/**
96
+		 * Load a legacy override template if exists.
97
+		 */
98
+		$override = new \GV\Legacy_Override_Template($view, $entry, null, $request);
99
+		foreach (['single'] as $part) {
100
+			if (($path = $override->get_template_part($template_slug, $part)) && strpos($path, '/deprecated') === false) {
101
+				/**
102
+				 * We have to bail and call the legacy renderer. Crap!
103
+				 */
104
+				gravityview()->log->notice('Legacy templates detected in theme {path}', ['path' => $path]);
105
+
106
+				/**
107
+				 * Show a warning at the top, if View is editable by the user.
108
+				 */
109
+				add_action('gravityview_before', $this->legacy_template_warning($view, $path));
110
+
111
+				return $override->render($template_slug);
112
+			}
113
+		}
114
+
115
+		/**
116
+		 * @filter `gravityview/template/entry/class` Filter the template class that is about to be used to render the entry.
117
+		 *
118
+		 * @since 2.0
119
+		 *
120
+		 * @param string      $class   The chosen class - Default: \GV\Entry_Table_Template.
121
+		 * @param \GV\Entry   $entry   The entry about to be rendered.
122
+		 * @param \GV\View    $view    The view connected to it.
123
+		 * @param \GV\Request $request The associated request.
124
+		 */
125
+		$class = apply_filters('gravityview/template/entry/class', sprintf('\GV\Entry_%s_Template', ucfirst($template_slug)), $entry, $view, $request);
126
+		if (!$class || !class_exists($class)) {
127
+			gravityview()->log->notice('{template_class} not found, falling back to legacy', ['template_class' => $class]);
128
+			$class = '\GV\Entry_Legacy_Template';
129
+		}
130
+		$template = new $class($entry, $view, $request);
131
+
132
+		add_action('gravityview/template/after', $view_id_output = function ($context) {
133
+			printf('<input type="hidden" class="gravityview-view-id" value="%d">', $context->view->ID);
134
+		});
135
+
136
+		/** Mock the legacy state for the widgets and whatnot */
137
+		$entries = new Entry_Collection();
138
+		$entries->add($entry);
139
+		\GV\Mocks\Legacy_Context::push([
140
+			'view'    => $view,
141
+			'entries' => $entries,
142
+			'entry'   => $entry,
143
+			'request' => $request,
144
+		]);
145
+
146
+		ob_start();
147
+		$template->render();
148
+
149
+		remove_action('gravityview/template/after', $view_id_output);
150
+
151
+		return ob_get_clean();
152
+	}
153 153
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return string The rendered Entry.
29 29
      */
30
-    public function render(Entry $entry, View $view, Request $request = null)
30
+    public function render( Entry $entry, View $view, Request $request = null )
31 31
     {
32
-        if (is_null($request)) {
32
+        if ( is_null( $request ) ) {
33 33
             $request = &gravityview()->request;
34 34
         }
35 35
 
36
-        if (!$request->is_renderable()) {
37
-            gravityview()->log->error('Renderer unable to render Entry in {request_class} context', ['request_class' => get_class($request)]);
36
+        if ( ! $request->is_renderable() ) {
37
+            gravityview()->log->error( 'Renderer unable to render Entry in {request_class} context', [ 'request_class' => get_class( $request ) ] );
38 38
 
39 39
             return null;
40 40
         }
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
         /**
43 43
          * This View is password protected. Output the form.
44 44
          */
45
-        if (post_password_required($view->ID)) {
46
-            return get_the_password_form($view->ID);
45
+        if ( post_password_required( $view->ID ) ) {
46
+            return get_the_password_form( $view->ID );
47 47
         }
48 48
 
49 49
         /**
@@ -56,24 +56,24 @@  discard block
 block discarded – undo
56 56
          * @param \GV\View    $view    The connected view
57 57
          * @param \GV\Request $request The associated request
58 58
          */
59
-        do_action('gravityview_render_entry_'.$view->ID, $entry, $view, $request);
59
+        do_action( 'gravityview_render_entry_' . $view->ID, $entry, $view, $request );
60 60
 
61 61
         /** Entry does not belong to this view. */
62
-        if ($view->joins) {
63
-            $form_ids = [];
64
-            foreach ($view->joins as $join) {
65
-                $form_ids[] = $join->join->ID;
66
-                $form_ids[] = $join->join_on->ID;
62
+        if ( $view->joins ) {
63
+            $form_ids = [ ];
64
+            foreach ( $view->joins as $join ) {
65
+                $form_ids[ ] = $join->join->ID;
66
+                $form_ids[ ] = $join->join_on->ID;
67 67
             }
68
-            foreach ($entry->entries as $e) {
69
-                if (!in_array($e['form_id'], $form_ids)) {
70
-                    gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $e->ID, 'view_id' => $view->ID]);
68
+            foreach ( $entry->entries as $e ) {
69
+                if ( ! in_array( $e[ 'form_id' ], $form_ids ) ) {
70
+                    gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', [ 'entry_id' => $e->ID, 'view_id' => $view->ID ] );
71 71
 
72 72
                     return null;
73 73
                 }
74 74
             }
75
-        } elseif ($view->form && $view->form->ID != $entry['form_id']) {
76
-            gravityview()->log->error('The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', ['entry_id' => $entry->ID, 'view_id' => $view->ID]);
75
+        } elseif ( $view->form && $view->form->ID != $entry[ 'form_id' ] ) {
76
+            gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', [ 'entry_id' => $entry->ID, 'view_id' => $view->ID ] );
77 77
 
78 78
             return null;
79 79
         }
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
          * @param string $slug Default: 'table'
91 91
          * @param string $view The current view context: single
92 92
          */
93
-        $template_slug = apply_filters('gravityview_template_slug_'.$view->settings->get('template'), 'table', 'single');
93
+        $template_slug = apply_filters( 'gravityview_template_slug_' . $view->settings->get( 'template' ), 'table', 'single' );
94 94
 
95 95
         /**
96 96
          * Load a legacy override template if exists.
97 97
          */
98
-        $override = new \GV\Legacy_Override_Template($view, $entry, null, $request);
99
-        foreach (['single'] as $part) {
100
-            if (($path = $override->get_template_part($template_slug, $part)) && strpos($path, '/deprecated') === false) {
98
+        $override = new \GV\Legacy_Override_Template( $view, $entry, null, $request );
99
+        foreach ( [ 'single' ] as $part ) {
100
+            if ( ( $path = $override->get_template_part( $template_slug, $part ) ) && strpos( $path, '/deprecated' ) === false ) {
101 101
                 /**
102 102
                  * We have to bail and call the legacy renderer. Crap!
103 103
                  */
104
-                gravityview()->log->notice('Legacy templates detected in theme {path}', ['path' => $path]);
104
+                gravityview()->log->notice( 'Legacy templates detected in theme {path}', [ 'path' => $path ] );
105 105
 
106 106
                 /**
107 107
                  * Show a warning at the top, if View is editable by the user.
108 108
                  */
109
-                add_action('gravityview_before', $this->legacy_template_warning($view, $path));
109
+                add_action( 'gravityview_before', $this->legacy_template_warning( $view, $path ) );
110 110
 
111
-                return $override->render($template_slug);
111
+                return $override->render( $template_slug );
112 112
             }
113 113
         }
114 114
 
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
          * @param \GV\View    $view    The view connected to it.
123 123
          * @param \GV\Request $request The associated request.
124 124
          */
125
-        $class = apply_filters('gravityview/template/entry/class', sprintf('\GV\Entry_%s_Template', ucfirst($template_slug)), $entry, $view, $request);
126
-        if (!$class || !class_exists($class)) {
127
-            gravityview()->log->notice('{template_class} not found, falling back to legacy', ['template_class' => $class]);
125
+        $class = apply_filters( 'gravityview/template/entry/class', sprintf( '\GV\Entry_%s_Template', ucfirst( $template_slug ) ), $entry, $view, $request );
126
+        if ( ! $class || ! class_exists( $class ) ) {
127
+            gravityview()->log->notice( '{template_class} not found, falling back to legacy', [ 'template_class' => $class ] );
128 128
             $class = '\GV\Entry_Legacy_Template';
129 129
         }
130
-        $template = new $class($entry, $view, $request);
130
+        $template = new $class( $entry, $view, $request );
131 131
 
132
-        add_action('gravityview/template/after', $view_id_output = function ($context) {
133
-            printf('<input type="hidden" class="gravityview-view-id" value="%d">', $context->view->ID);
132
+        add_action( 'gravityview/template/after', $view_id_output = function( $context ) {
133
+            printf( '<input type="hidden" class="gravityview-view-id" value="%d">', $context->view->ID );
134 134
         });
135 135
 
136 136
         /** Mock the legacy state for the widgets and whatnot */
137 137
         $entries = new Entry_Collection();
138
-        $entries->add($entry);
139
-        \GV\Mocks\Legacy_Context::push([
138
+        $entries->add( $entry );
139
+        \GV\Mocks\Legacy_Context::push( [
140 140
             'view'    => $view,
141 141
             'entries' => $entries,
142 142
             'entry'   => $entry,
143 143
             'request' => $request,
144
-        ]);
144
+        ] );
145 145
 
146 146
         ob_start();
147 147
         $template->render();
148 148
 
149
-        remove_action('gravityview/template/after', $view_id_output);
149
+        remove_action( 'gravityview/template/after', $view_id_output );
150 150
 
151 151
         return ob_get_clean();
152 152
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * Houses some preliminary \GV\Entry rendering functionality.
14 14
  */
15
-class Entry_Renderer extends Renderer
16
-{
15
+class Entry_Renderer extends Renderer {
17 16
     /**
18 17
      * Renders a single \GV\Entry instance.
19 18
      *
@@ -27,8 +26,7 @@  discard block
 block discarded – undo
27 26
      *
28 27
      * @return string The rendered Entry.
29 28
      */
30
-    public function render(Entry $entry, View $view, Request $request = null)
31
-    {
29
+    public function render(Entry $entry, View $view, Request $request = null) {
32 30
         if (is_null($request)) {
33 31
             $request = &gravityview()->request;
34 32
         }
Please login to merge, or discard this patch.
future/includes/class-gv-field-gravityforms.php 3 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -12,174 +12,174 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GF_Field extends Field
14 14
 {
15
-    /**
16
-     * @var \GF_Field The backing Gravity Forms field.
17
-     */
18
-    public $field;
19
-
20
-    /**
21
-     * Create self from a configuration array.
22
-     *
23
-     * @param array $configuration The configuration array.
24
-     *
25
-     * @see \GV\Field::as_configuration()
26
-     *
27
-     * @internal
28
-     *
29
-     * @since 2.0
30
-     *
31
-     * @return \GV\GF_Field|null The field implementation or null on error.
32
-     */
33
-    public static function from_configuration($configuration)
34
-    {
35
-        if (empty($configuration['id']) || !is_numeric($configuration['id'])) {
36
-            gravityview()->log->error('Invalid configuration[id] supplied.');
37
-
38
-            return null;
39
-        }
40
-
41
-        if (empty($configuration['form_id']) || !$form = \GV\GF_Form::by_id($configuration['form_id'])) {
42
-            gravityview()->log->error('Invalid configuration[form_id] supplied.');
43
-
44
-            return null;
45
-        }
46
-
47
-        $field = self::by_id($form, $configuration['id']);
48
-
49
-        if (!$field) {
50
-            gravityview()->log->error('Invalid configuration[id] supplied.');
51
-
52
-            return null;
53
-        }
54
-
55
-        $field->update_configuration($configuration);
56
-
57
-        return $field;
58
-    }
59
-
60
-    /**
61
-     * Get a \GV\GF_Field by \GV\GF_Form and Field ID.
62
-     *
63
-     * @param \GV\GF_Form $form     The Gravity Form form.
64
-     * @param int         $field_id The Gravity Form field ID for the $form.
65
-     *
66
-     * @return \GV\Field|null The requested field or null if not found.
67
-     */
68
-    public static function by_id($form, $field_id)
69
-    {
70
-        if (!$form || !is_object($form) || !is_a($form, '\GV\GF_Form')) {
71
-            gravityview()->log->error('$form is not a \GV\GF_Form instance');
72
-
73
-            return null;
74
-        }
75
-
76
-        if (empty($form->form)) {
77
-            gravityview()->log->error('$form is not initialized with a backing Gravity Forms form');
78
-
79
-            return null;
80
-        }
81
-
82
-        $gv_field = \GFFormsModel::get_field($form->form, $field_id);
83
-
84
-        if (!$gv_field) {
85
-            gravityview()->log->error('Invalid $field_id #{field_id} for current source', ['field_id' => $field_id]);
86
-
87
-            return null;
88
-        }
89
-
90
-        $field = new self();
91
-        $field->ID = $field_id;
92
-        $field->field = $gv_field;
93
-
94
-        return $field;
95
-    }
96
-
97
-    /**
98
-     * Retrieve the label for this field.
99
-     *
100
-     * Requires a \GV\GF_Form in this implementation.
101
-     *
102
-     * @param \GV\View    $view    The view for this context if applicable.
103
-     * @param \GV\Source  $source  The source (form) for this context if applicable.
104
-     * @param \GV\Entry   $entry   The entry for this context if applicable.
105
-     * @param \GV\Request $request The request for this context if applicable.
106
-     *
107
-     * @return string The label for this Gravity Forms field.
108
-     */
109
-    public function get_label(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
110
-    {
111
-        if (!$this->show_label) {
112
-            return '';
113
-        }
114
-
115
-        if ($label = parent::get_label($view, $source, $entry, $request)) {
116
-            return $label;
117
-        }
118
-
119
-        if (!$source || !is_object($source) || !is_a($source, '\GV\GF_Form')) {
120
-            gravityview()->log->error('$source is not a valid \GV\GF_Form instance');
121
-
122
-            return null;
123
-        }
124
-
125
-        if ($this->label) {
126
-            return $this->label;
127
-        }
128
-
129
-        /** This is a complex Gravity Forms input. */
130
-        if ($input = \GFFormsModel::get_input($this->field, $this->ID)) {
131
-            $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
132
-        } else {
133
-            /** This is a field with one label. */
134
-            $label = $this->field->get_field_label(true, $this->label);
135
-        }
136
-
137
-        return $label;
138
-    }
139
-
140
-    /**
141
-     * Retrieve the value for this field.
142
-     *
143
-     * Requires a \GV\GF_Entry in this implementation.
144
-     *
145
-     * @param \GV\View    $view    The view for this context if applicable.
146
-     * @param \GV\Source  $source  The source (form) for this context if applicable.
147
-     * @param \GV\Entry   $entry   The entry for this context if applicable.
148
-     * @param \GV\Request $request The request for this context if applicable.
149
-     *
150
-     * @return mixed The value for this field.
151
-     */
152
-    public function get_value(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
153
-    {
154
-        if (!$entry || !is_object($entry) || !is_a($entry, '\GV\GF_Entry')) {
155
-            gravityview()->log->error('$entry is not a valid \GV\GF_Entry instance');
156
-
157
-            return null;
158
-        }
159
-
160
-        $value = \RGFormsModel::get_lead_field_value($entry->as_entry(), $this->field);
161
-
162
-        /** Apply parent filters. */
163
-        return $this->get_value_filters($value, $view, $source, $entry, $request);
164
-    }
165
-
166
-    /**
167
-     * A proxy getter for the backing GravityView field.
168
-     *
169
-     * The view field configuration is checked first, though.
170
-     *
171
-     * @param string $key The property to get.
172
-     *
173
-     * @return mixed The value of the Gravity View field property, or null if not exists.
174
-     */
175
-    public function __get($key)
176
-    {
177
-        if ($value = parent::__get($key)) {
178
-            return $value;
179
-        }
180
-
181
-        if ($this->field) {
182
-            return $this->field->$key;
183
-        }
184
-    }
15
+	/**
16
+	 * @var \GF_Field The backing Gravity Forms field.
17
+	 */
18
+	public $field;
19
+
20
+	/**
21
+	 * Create self from a configuration array.
22
+	 *
23
+	 * @param array $configuration The configuration array.
24
+	 *
25
+	 * @see \GV\Field::as_configuration()
26
+	 *
27
+	 * @internal
28
+	 *
29
+	 * @since 2.0
30
+	 *
31
+	 * @return \GV\GF_Field|null The field implementation or null on error.
32
+	 */
33
+	public static function from_configuration($configuration)
34
+	{
35
+		if (empty($configuration['id']) || !is_numeric($configuration['id'])) {
36
+			gravityview()->log->error('Invalid configuration[id] supplied.');
37
+
38
+			return null;
39
+		}
40
+
41
+		if (empty($configuration['form_id']) || !$form = \GV\GF_Form::by_id($configuration['form_id'])) {
42
+			gravityview()->log->error('Invalid configuration[form_id] supplied.');
43
+
44
+			return null;
45
+		}
46
+
47
+		$field = self::by_id($form, $configuration['id']);
48
+
49
+		if (!$field) {
50
+			gravityview()->log->error('Invalid configuration[id] supplied.');
51
+
52
+			return null;
53
+		}
54
+
55
+		$field->update_configuration($configuration);
56
+
57
+		return $field;
58
+	}
59
+
60
+	/**
61
+	 * Get a \GV\GF_Field by \GV\GF_Form and Field ID.
62
+	 *
63
+	 * @param \GV\GF_Form $form     The Gravity Form form.
64
+	 * @param int         $field_id The Gravity Form field ID for the $form.
65
+	 *
66
+	 * @return \GV\Field|null The requested field or null if not found.
67
+	 */
68
+	public static function by_id($form, $field_id)
69
+	{
70
+		if (!$form || !is_object($form) || !is_a($form, '\GV\GF_Form')) {
71
+			gravityview()->log->error('$form is not a \GV\GF_Form instance');
72
+
73
+			return null;
74
+		}
75
+
76
+		if (empty($form->form)) {
77
+			gravityview()->log->error('$form is not initialized with a backing Gravity Forms form');
78
+
79
+			return null;
80
+		}
81
+
82
+		$gv_field = \GFFormsModel::get_field($form->form, $field_id);
83
+
84
+		if (!$gv_field) {
85
+			gravityview()->log->error('Invalid $field_id #{field_id} for current source', ['field_id' => $field_id]);
86
+
87
+			return null;
88
+		}
89
+
90
+		$field = new self();
91
+		$field->ID = $field_id;
92
+		$field->field = $gv_field;
93
+
94
+		return $field;
95
+	}
96
+
97
+	/**
98
+	 * Retrieve the label for this field.
99
+	 *
100
+	 * Requires a \GV\GF_Form in this implementation.
101
+	 *
102
+	 * @param \GV\View    $view    The view for this context if applicable.
103
+	 * @param \GV\Source  $source  The source (form) for this context if applicable.
104
+	 * @param \GV\Entry   $entry   The entry for this context if applicable.
105
+	 * @param \GV\Request $request The request for this context if applicable.
106
+	 *
107
+	 * @return string The label for this Gravity Forms field.
108
+	 */
109
+	public function get_label(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
110
+	{
111
+		if (!$this->show_label) {
112
+			return '';
113
+		}
114
+
115
+		if ($label = parent::get_label($view, $source, $entry, $request)) {
116
+			return $label;
117
+		}
118
+
119
+		if (!$source || !is_object($source) || !is_a($source, '\GV\GF_Form')) {
120
+			gravityview()->log->error('$source is not a valid \GV\GF_Form instance');
121
+
122
+			return null;
123
+		}
124
+
125
+		if ($this->label) {
126
+			return $this->label;
127
+		}
128
+
129
+		/** This is a complex Gravity Forms input. */
130
+		if ($input = \GFFormsModel::get_input($this->field, $this->ID)) {
131
+			$label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
132
+		} else {
133
+			/** This is a field with one label. */
134
+			$label = $this->field->get_field_label(true, $this->label);
135
+		}
136
+
137
+		return $label;
138
+	}
139
+
140
+	/**
141
+	 * Retrieve the value for this field.
142
+	 *
143
+	 * Requires a \GV\GF_Entry in this implementation.
144
+	 *
145
+	 * @param \GV\View    $view    The view for this context if applicable.
146
+	 * @param \GV\Source  $source  The source (form) for this context if applicable.
147
+	 * @param \GV\Entry   $entry   The entry for this context if applicable.
148
+	 * @param \GV\Request $request The request for this context if applicable.
149
+	 *
150
+	 * @return mixed The value for this field.
151
+	 */
152
+	public function get_value(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
153
+	{
154
+		if (!$entry || !is_object($entry) || !is_a($entry, '\GV\GF_Entry')) {
155
+			gravityview()->log->error('$entry is not a valid \GV\GF_Entry instance');
156
+
157
+			return null;
158
+		}
159
+
160
+		$value = \RGFormsModel::get_lead_field_value($entry->as_entry(), $this->field);
161
+
162
+		/** Apply parent filters. */
163
+		return $this->get_value_filters($value, $view, $source, $entry, $request);
164
+	}
165
+
166
+	/**
167
+	 * A proxy getter for the backing GravityView field.
168
+	 *
169
+	 * The view field configuration is checked first, though.
170
+	 *
171
+	 * @param string $key The property to get.
172
+	 *
173
+	 * @return mixed The value of the Gravity View field property, or null if not exists.
174
+	 */
175
+	public function __get($key)
176
+	{
177
+		if ($value = parent::__get($key)) {
178
+			return $value;
179
+		}
180
+
181
+		if ($this->field) {
182
+			return $this->field->$key;
183
+		}
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -30,29 +30,29 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return \GV\GF_Field|null The field implementation or null on error.
32 32
      */
33
-    public static function from_configuration($configuration)
33
+    public static function from_configuration( $configuration )
34 34
     {
35
-        if (empty($configuration['id']) || !is_numeric($configuration['id'])) {
36
-            gravityview()->log->error('Invalid configuration[id] supplied.');
35
+        if ( empty( $configuration[ 'id' ] ) || ! is_numeric( $configuration[ 'id' ] ) ) {
36
+            gravityview()->log->error( 'Invalid configuration[id] supplied.' );
37 37
 
38 38
             return null;
39 39
         }
40 40
 
41
-        if (empty($configuration['form_id']) || !$form = \GV\GF_Form::by_id($configuration['form_id'])) {
42
-            gravityview()->log->error('Invalid configuration[form_id] supplied.');
41
+        if ( empty( $configuration[ 'form_id' ] ) || ! $form = \GV\GF_Form::by_id( $configuration[ 'form_id' ] ) ) {
42
+            gravityview()->log->error( 'Invalid configuration[form_id] supplied.' );
43 43
 
44 44
             return null;
45 45
         }
46 46
 
47
-        $field = self::by_id($form, $configuration['id']);
47
+        $field = self::by_id( $form, $configuration[ 'id' ] );
48 48
 
49
-        if (!$field) {
50
-            gravityview()->log->error('Invalid configuration[id] supplied.');
49
+        if ( ! $field ) {
50
+            gravityview()->log->error( 'Invalid configuration[id] supplied.' );
51 51
 
52 52
             return null;
53 53
         }
54 54
 
55
-        $field->update_configuration($configuration);
55
+        $field->update_configuration( $configuration );
56 56
 
57 57
         return $field;
58 58
     }
@@ -65,24 +65,24 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return \GV\Field|null The requested field or null if not found.
67 67
      */
68
-    public static function by_id($form, $field_id)
68
+    public static function by_id( $form, $field_id )
69 69
     {
70
-        if (!$form || !is_object($form) || !is_a($form, '\GV\GF_Form')) {
71
-            gravityview()->log->error('$form is not a \GV\GF_Form instance');
70
+        if ( ! $form || ! is_object( $form ) || ! is_a( $form, '\GV\GF_Form' ) ) {
71
+            gravityview()->log->error( '$form is not a \GV\GF_Form instance' );
72 72
 
73 73
             return null;
74 74
         }
75 75
 
76
-        if (empty($form->form)) {
77
-            gravityview()->log->error('$form is not initialized with a backing Gravity Forms form');
76
+        if ( empty( $form->form ) ) {
77
+            gravityview()->log->error( '$form is not initialized with a backing Gravity Forms form' );
78 78
 
79 79
             return null;
80 80
         }
81 81
 
82
-        $gv_field = \GFFormsModel::get_field($form->form, $field_id);
82
+        $gv_field = \GFFormsModel::get_field( $form->form, $field_id );
83 83
 
84
-        if (!$gv_field) {
85
-            gravityview()->log->error('Invalid $field_id #{field_id} for current source', ['field_id' => $field_id]);
84
+        if ( ! $gv_field ) {
85
+            gravityview()->log->error( 'Invalid $field_id #{field_id} for current source', [ 'field_id' => $field_id ] );
86 86
 
87 87
             return null;
88 88
         }
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @return string The label for this Gravity Forms field.
108 108
      */
109
-    public function get_label(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
109
+    public function get_label( View $view = null, Source $source = null, Entry $entry = null, Request $request = null )
110 110
     {
111
-        if (!$this->show_label) {
111
+        if ( ! $this->show_label ) {
112 112
             return '';
113 113
         }
114 114
 
115
-        if ($label = parent::get_label($view, $source, $entry, $request)) {
115
+        if ( $label = parent::get_label( $view, $source, $entry, $request ) ) {
116 116
             return $label;
117 117
         }
118 118
 
119
-        if (!$source || !is_object($source) || !is_a($source, '\GV\GF_Form')) {
120
-            gravityview()->log->error('$source is not a valid \GV\GF_Form instance');
119
+        if ( ! $source || ! is_object( $source ) || ! is_a( $source, '\GV\GF_Form' ) ) {
120
+            gravityview()->log->error( '$source is not a valid \GV\GF_Form instance' );
121 121
 
122 122
             return null;
123 123
         }
124 124
 
125
-        if ($this->label) {
125
+        if ( $this->label ) {
126 126
             return $this->label;
127 127
         }
128 128
 
129 129
         /** This is a complex Gravity Forms input. */
130
-        if ($input = \GFFormsModel::get_input($this->field, $this->ID)) {
131
-            $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label'];
130
+        if ( $input = \GFFormsModel::get_input( $this->field, $this->ID ) ) {
131
+            $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ];
132 132
         } else {
133 133
             /** This is a field with one label. */
134
-            $label = $this->field->get_field_label(true, $this->label);
134
+            $label = $this->field->get_field_label( true, $this->label );
135 135
         }
136 136
 
137 137
         return $label;
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
      *
150 150
      * @return mixed The value for this field.
151 151
      */
152
-    public function get_value(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
152
+    public function get_value( View $view = null, Source $source = null, Entry $entry = null, Request $request = null )
153 153
     {
154
-        if (!$entry || !is_object($entry) || !is_a($entry, '\GV\GF_Entry')) {
155
-            gravityview()->log->error('$entry is not a valid \GV\GF_Entry instance');
154
+        if ( ! $entry || ! is_object( $entry ) || ! is_a( $entry, '\GV\GF_Entry' ) ) {
155
+            gravityview()->log->error( '$entry is not a valid \GV\GF_Entry instance' );
156 156
 
157 157
             return null;
158 158
         }
159 159
 
160
-        $value = \RGFormsModel::get_lead_field_value($entry->as_entry(), $this->field);
160
+        $value = \RGFormsModel::get_lead_field_value( $entry->as_entry(), $this->field );
161 161
 
162 162
         /** Apply parent filters. */
163
-        return $this->get_value_filters($value, $view, $source, $entry, $request);
163
+        return $this->get_value_filters( $value, $view, $source, $entry, $request );
164 164
     }
165 165
 
166 166
     /**
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @return mixed The value of the Gravity View field property, or null if not exists.
174 174
      */
175
-    public function __get($key)
175
+    public function __get( $key )
176 176
     {
177
-        if ($value = parent::__get($key)) {
177
+        if ( $value = parent::__get( $key ) ) {
178 178
             return $value;
179 179
         }
180 180
 
181
-        if ($this->field) {
181
+        if ( $this->field ) {
182 182
             return $this->field->$key;
183 183
         }
184 184
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * The Gravity Forms {@see \GF_Field} field object wrapper.
12 12
  */
13
-class GF_Field extends Field
14
-{
13
+class GF_Field extends Field {
15 14
     /**
16 15
      * @var \GF_Field The backing Gravity Forms field.
17 16
      */
@@ -30,8 +29,7 @@  discard block
 block discarded – undo
30 29
      *
31 30
      * @return \GV\GF_Field|null The field implementation or null on error.
32 31
      */
33
-    public static function from_configuration($configuration)
34
-    {
32
+    public static function from_configuration($configuration) {
35 33
         if (empty($configuration['id']) || !is_numeric($configuration['id'])) {
36 34
             gravityview()->log->error('Invalid configuration[id] supplied.');
37 35
 
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
      *
66 64
      * @return \GV\Field|null The requested field or null if not found.
67 65
      */
68
-    public static function by_id($form, $field_id)
69
-    {
66
+    public static function by_id($form, $field_id) {
70 67
         if (!$form || !is_object($form) || !is_a($form, '\GV\GF_Form')) {
71 68
             gravityview()->log->error('$form is not a \GV\GF_Form instance');
72 69
 
@@ -106,8 +103,7 @@  discard block
 block discarded – undo
106 103
      *
107 104
      * @return string The label for this Gravity Forms field.
108 105
      */
109
-    public function get_label(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
110
-    {
106
+    public function get_label(View $view = null, Source $source = null, Entry $entry = null, Request $request = null) {
111 107
         if (!$this->show_label) {
112 108
             return '';
113 109
         }
@@ -149,8 +145,7 @@  discard block
 block discarded – undo
149 145
      *
150 146
      * @return mixed The value for this field.
151 147
      */
152
-    public function get_value(View $view = null, Source $source = null, Entry $entry = null, Request $request = null)
153
-    {
148
+    public function get_value(View $view = null, Source $source = null, Entry $entry = null, Request $request = null) {
154 149
         if (!$entry || !is_object($entry) || !is_a($entry, '\GV\GF_Entry')) {
155 150
             gravityview()->log->error('$entry is not a valid \GV\GF_Entry instance');
156 151
 
@@ -172,8 +167,7 @@  discard block
 block discarded – undo
172 167
      *
173 168
      * @return mixed The value of the Gravity View field property, or null if not exists.
174 169
      */
175
-    public function __get($key)
176
-    {
170
+    public function __get($key) {
177 171
         if ($value = parent::__get($key)) {
178 172
             return $value;
179 173
         }
Please login to merge, or discard this patch.
future/includes/class-gv-collection-entry-filter.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -31,4 +31,4 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 /** Load implementations. */
34
-require gravityview()->plugin->dir('future/includes/class-gv-collection-entry-filter-gravityforms.php');
34
+require gravityview()->plugin->dir( 'future/includes/class-gv-collection-entry-filter-gravityforms.php' );
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
  * For now we use the Gravity Forms backend for this, since developing an ORM
27 27
  *  will take us another year :)
28 28
  */
29
-abstract class Entry_Filter
30
-{
29
+abstract class Entry_Filter {
31 30
 }
32 31
 
33 32
 /** Load implementations. */
Please login to merge, or discard this patch.
future/includes/class-gv-request.php 3 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,297 +14,297 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class Request
16 16
 {
17
-    public function __construct()
18
-    {
19
-    }
20
-
21
-    /**
22
-     * Whether this request is something that is renderable.
23
-     *
24
-     * @since 2.5.2
25
-     *
26
-     * @return bool Yes or no.
27
-     */
28
-    public function is_renderable()
29
-    {
30
-        $is_renderable = in_array(get_class($this), [
31
-            'GV\Frontend_Request',
32
-            'GV\Mock_Request',
33
-            'GV\REST\Request',
34
-        ], true);
35
-
36
-        /**
37
-         * @filter `gravityview/request/is_renderable` Is this request renderable?
38
-         *
39
-         * @since 2.5.2
40
-         *
41
-         * @param bool        $is_renderable Huh?
42
-         * @param \GV\Request $this          This.
43
-         */
44
-        return apply_filters('gravityview/request/is_renderable', $is_renderable, $this);
45
-    }
46
-
47
-    /**
48
-     * Check if WordPress is_admin(), and make sure not DOING_AJAX.
49
-     *
50
-     * @return bool
51
-     */
52
-    public static function is_admin()
53
-    {
54
-        $doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false;
55
-        $load_scripts_styles = preg_match('#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER('SCRIPT_NAME'));
56
-
57
-        return is_admin() && !($doing_ajax || $load_scripts_styles);
58
-    }
59
-
60
-    /**
61
-     * This is the frontend.
62
-     *
63
-     * @return bool True or false.
64
-     */
65
-    public static function is_frontend()
66
-    {
67
-        return !is_admin();
68
-    }
69
-
70
-    /**
71
-     * Is this the Add Media / From URL preview request?
72
-     *
73
-     * Will not work in WordPress 4.8+
74
-     *
75
-     * @return bool
76
-     */
77
-    public static function is_add_oembed_preview()
78
-    {
79
-        /** The preview request is a parse-embed AJAX call without a type set. */
80
-        return  self::is_ajax() && !empty($_POST['action']) && $_POST['action'] == 'parse-embed' && !isset($_POST['type']);
81
-    }
82
-
83
-    /**
84
-     * Is this an AJAX call in progress?
85
-     *
86
-     * @return bool
87
-     */
88
-    public static function is_ajax()
89
-    {
90
-        return defined('DOING_AJAX') && DOING_AJAX;
91
-    }
92
-
93
-    /**
94
-     * Is this a REST request? Call after parse_request.
95
-     *
96
-     * @return bool
97
-     */
98
-    public static function is_rest()
99
-    {
100
-        return !empty($GLOBALS['wp']->query_vars['rest_route']);
101
-    }
102
-
103
-    /**
104
-     * The current $post is a View, no?
105
-     *
106
-     * @api
107
-     *
108
-     * @since 2.0
109
-     *
110
-     * @todo tests
111
-     *
112
-     * @return \GV\View|false The view requested or false
113
-     */
114
-    public function is_view()
115
-    {
116
-        global $post;
117
-        if ($post && get_post_type($post) == 'gravityview') {
118
-            return \GV\View::from_post($post);
119
-        }
120
-
121
-        return false;
122
-    }
123
-
124
-    /**
125
-     * Checks whether this is a single entry request.
126
-     *
127
-     * @api
128
-     *
129
-     * @since 2.0
130
-     *
131
-     * @todo tests
132
-     *
133
-     * @param int $form_id The form ID, since slugs can be non-unique. Default: 0.
134
-     *
135
-     * @return \GV\GF_Entry|false The entry requested or false.
136
-     */
137
-    public function is_entry($form_id = 0)
138
-    {
139
-        global $wp_query;
140
-
141
-        if (!$wp_query) {
142
-            return false;
143
-        }
144
-
145
-        $id = get_query_var(Entry::get_endpoint_name());
146
-
147
-        if (!$id) {
148
-            return false;
149
-        }
150
-
151
-        static $entries = [];
152
-
153
-        if (isset($entries["$form_id:$id"])) {
154
-            return $entries["$form_id:$id"];
155
-        }
156
-
157
-        $view = $this->is_view();
158
-
159
-        /**
160
-         * Not CPT, so probably a shortcode.
161
-         */
162
-        if (!$view) {
163
-            $view = gravityview()->views->get();
164
-        }
165
-
166
-        /**
167
-         * A joined request.
168
-         */
169
-        if ($view && ($joins = $view->joins)) {
170
-            $forms = array_merge(wp_list_pluck($joins, 'join'), wp_list_pluck($joins, 'join_on'));
171
-            $valid_forms = array_unique(wp_list_pluck($forms, 'ID'));
172
-
173
-            $multientry = [];
174
-            foreach ($ids = explode(',', $id) as $i => $id) {
175
-                $valid_form = \GV\Utils::get($valid_forms, $i, 0);
176
-
177
-                if (!$e = GF_Entry::by_id($id, $valid_form)) {
178
-                    return false;
179
-                }
180
-
181
-                if (!in_array($e['form_id'], $valid_forms)) {
182
-                    return false;
183
-                }
184
-
185
-                array_push($multientry, $e);
186
-            }
187
-
188
-            // Allow Edit Entry to only edit a single entry on a multi-entry
189
-            $is_edit_entry = apply_filters('gravityview_is_edit_entry', false);
190
-
191
-            // Edit entry links are single-entry based
192
-            if ($is_edit_entry && 1 !== count($multientry)) {
193
-                return false;
194
-            }
195
-
196
-            $entry = Multi_Entry::from_entries(array_filter($multientry));
197
-        } else {
198
-            /**
199
-             * A regular one.
200
-             */
201
-            $entry = GF_Entry::by_id($id, $form_id);
202
-        }
203
-
204
-        $entries["$form_id:$id"] = $entry;
205
-
206
-        return $entry;
207
-    }
208
-
209
-    /**
210
-     * Checks whether this an edit entry request.
211
-     *
212
-     * @api
213
-     *
214
-     * @since 2.0
215
-     *
216
-     * @todo tests
217
-     *
218
-     * @param int $form_id The form ID, since slugs can be non-unique. Default: 0.
219
-     *
220
-     * @return \GV\Entry|false The entry requested or false.
221
-     */
222
-    public function is_edit_entry($form_id = 0)
223
-    {
224
-        /**
225
-         * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
226
-         * The Edit Entry functionality overrides this value.
227
-         *
228
-         * @param bool $is_edit_entry
229
-         */
230
-        if (($entry = $this->is_entry($form_id)) && apply_filters('gravityview_is_edit_entry', false)) {
231
-            if ($entry->is_multi()) {
232
-                return array_pop($entry->entries);
233
-            }
234
-
235
-            return $entry;
236
-        }
237
-
238
-        return false;
239
-    }
240
-
241
-    /**
242
-     * Checks whether this an entry search request.
243
-     *
244
-     * @api
245
-     *
246
-     * @since 2.0
247
-     *
248
-     * @todo implementation
249
-     *
250
-     * @return bool True if this is a search request.
251
-     */
252
-    public function is_search()
253
-    {
254
-        $search_method = apply_filters('gravityview/search/method', 'get');
255
-
256
-        if ('post' === $search_method) {
257
-            $get = $_POST;
258
-        } else {
259
-            $get = $_GET;
260
-        }
261
-
262
-        unset($get['mode']);
263
-
264
-        $get = array_filter($get, 'gravityview_is_not_empty_string');
265
-
266
-        if ($has_field_key = $this->_has_field_key($get)) {
267
-            return true;
268
-        }
269
-
270
-        return isset($get['gv_search']) || isset($get['gv_start']) || isset($get['gv_end']) || isset($get['gv_by']) || isset($get['gv_id']);
271
-    }
272
-
273
-    /**
274
-     * Calculate whether the $_REQUEST has a GravityView field.
275
-     *
276
-     * @internal
277
-     *
278
-     * @todo Roll into the future Search refactor
279
-     *
280
-     * @since 2.0.7
281
-     *
282
-     * @param array $get $_POST or $_GET array
283
-     *
284
-     * @return bool True: GravityView-formatted field detected; False: not detected
285
-     */
286
-    private function _has_field_key($get)
287
-    {
288
-        $has_field_key = false;
289
-
290
-        $fields = \GravityView_Fields::get_all();
291
-
292
-        $meta = [];
293
-        foreach ($fields as $field) {
294
-            if (empty($field->_gf_field_class_name)) {
295
-                $meta[] = preg_quote($field->name);
296
-            }
297
-        }
298
-
299
-        foreach ($get as $key => $value) {
300
-            if (preg_match('/^(filter|input)_(([0-9_]+)|'.implode('|', $meta).')$/sm', $key)) {
301
-                $has_field_key = true;
302
-                break;
303
-            }
304
-        }
305
-
306
-        return $has_field_key;
307
-    }
17
+	public function __construct()
18
+	{
19
+	}
20
+
21
+	/**
22
+	 * Whether this request is something that is renderable.
23
+	 *
24
+	 * @since 2.5.2
25
+	 *
26
+	 * @return bool Yes or no.
27
+	 */
28
+	public function is_renderable()
29
+	{
30
+		$is_renderable = in_array(get_class($this), [
31
+			'GV\Frontend_Request',
32
+			'GV\Mock_Request',
33
+			'GV\REST\Request',
34
+		], true);
35
+
36
+		/**
37
+		 * @filter `gravityview/request/is_renderable` Is this request renderable?
38
+		 *
39
+		 * @since 2.5.2
40
+		 *
41
+		 * @param bool        $is_renderable Huh?
42
+		 * @param \GV\Request $this          This.
43
+		 */
44
+		return apply_filters('gravityview/request/is_renderable', $is_renderable, $this);
45
+	}
46
+
47
+	/**
48
+	 * Check if WordPress is_admin(), and make sure not DOING_AJAX.
49
+	 *
50
+	 * @return bool
51
+	 */
52
+	public static function is_admin()
53
+	{
54
+		$doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false;
55
+		$load_scripts_styles = preg_match('#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER('SCRIPT_NAME'));
56
+
57
+		return is_admin() && !($doing_ajax || $load_scripts_styles);
58
+	}
59
+
60
+	/**
61
+	 * This is the frontend.
62
+	 *
63
+	 * @return bool True or false.
64
+	 */
65
+	public static function is_frontend()
66
+	{
67
+		return !is_admin();
68
+	}
69
+
70
+	/**
71
+	 * Is this the Add Media / From URL preview request?
72
+	 *
73
+	 * Will not work in WordPress 4.8+
74
+	 *
75
+	 * @return bool
76
+	 */
77
+	public static function is_add_oembed_preview()
78
+	{
79
+		/** The preview request is a parse-embed AJAX call without a type set. */
80
+		return  self::is_ajax() && !empty($_POST['action']) && $_POST['action'] == 'parse-embed' && !isset($_POST['type']);
81
+	}
82
+
83
+	/**
84
+	 * Is this an AJAX call in progress?
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	public static function is_ajax()
89
+	{
90
+		return defined('DOING_AJAX') && DOING_AJAX;
91
+	}
92
+
93
+	/**
94
+	 * Is this a REST request? Call after parse_request.
95
+	 *
96
+	 * @return bool
97
+	 */
98
+	public static function is_rest()
99
+	{
100
+		return !empty($GLOBALS['wp']->query_vars['rest_route']);
101
+	}
102
+
103
+	/**
104
+	 * The current $post is a View, no?
105
+	 *
106
+	 * @api
107
+	 *
108
+	 * @since 2.0
109
+	 *
110
+	 * @todo tests
111
+	 *
112
+	 * @return \GV\View|false The view requested or false
113
+	 */
114
+	public function is_view()
115
+	{
116
+		global $post;
117
+		if ($post && get_post_type($post) == 'gravityview') {
118
+			return \GV\View::from_post($post);
119
+		}
120
+
121
+		return false;
122
+	}
123
+
124
+	/**
125
+	 * Checks whether this is a single entry request.
126
+	 *
127
+	 * @api
128
+	 *
129
+	 * @since 2.0
130
+	 *
131
+	 * @todo tests
132
+	 *
133
+	 * @param int $form_id The form ID, since slugs can be non-unique. Default: 0.
134
+	 *
135
+	 * @return \GV\GF_Entry|false The entry requested or false.
136
+	 */
137
+	public function is_entry($form_id = 0)
138
+	{
139
+		global $wp_query;
140
+
141
+		if (!$wp_query) {
142
+			return false;
143
+		}
144
+
145
+		$id = get_query_var(Entry::get_endpoint_name());
146
+
147
+		if (!$id) {
148
+			return false;
149
+		}
150
+
151
+		static $entries = [];
152
+
153
+		if (isset($entries["$form_id:$id"])) {
154
+			return $entries["$form_id:$id"];
155
+		}
156
+
157
+		$view = $this->is_view();
158
+
159
+		/**
160
+		 * Not CPT, so probably a shortcode.
161
+		 */
162
+		if (!$view) {
163
+			$view = gravityview()->views->get();
164
+		}
165
+
166
+		/**
167
+		 * A joined request.
168
+		 */
169
+		if ($view && ($joins = $view->joins)) {
170
+			$forms = array_merge(wp_list_pluck($joins, 'join'), wp_list_pluck($joins, 'join_on'));
171
+			$valid_forms = array_unique(wp_list_pluck($forms, 'ID'));
172
+
173
+			$multientry = [];
174
+			foreach ($ids = explode(',', $id) as $i => $id) {
175
+				$valid_form = \GV\Utils::get($valid_forms, $i, 0);
176
+
177
+				if (!$e = GF_Entry::by_id($id, $valid_form)) {
178
+					return false;
179
+				}
180
+
181
+				if (!in_array($e['form_id'], $valid_forms)) {
182
+					return false;
183
+				}
184
+
185
+				array_push($multientry, $e);
186
+			}
187
+
188
+			// Allow Edit Entry to only edit a single entry on a multi-entry
189
+			$is_edit_entry = apply_filters('gravityview_is_edit_entry', false);
190
+
191
+			// Edit entry links are single-entry based
192
+			if ($is_edit_entry && 1 !== count($multientry)) {
193
+				return false;
194
+			}
195
+
196
+			$entry = Multi_Entry::from_entries(array_filter($multientry));
197
+		} else {
198
+			/**
199
+			 * A regular one.
200
+			 */
201
+			$entry = GF_Entry::by_id($id, $form_id);
202
+		}
203
+
204
+		$entries["$form_id:$id"] = $entry;
205
+
206
+		return $entry;
207
+	}
208
+
209
+	/**
210
+	 * Checks whether this an edit entry request.
211
+	 *
212
+	 * @api
213
+	 *
214
+	 * @since 2.0
215
+	 *
216
+	 * @todo tests
217
+	 *
218
+	 * @param int $form_id The form ID, since slugs can be non-unique. Default: 0.
219
+	 *
220
+	 * @return \GV\Entry|false The entry requested or false.
221
+	 */
222
+	public function is_edit_entry($form_id = 0)
223
+	{
224
+		/**
225
+		 * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
226
+		 * The Edit Entry functionality overrides this value.
227
+		 *
228
+		 * @param bool $is_edit_entry
229
+		 */
230
+		if (($entry = $this->is_entry($form_id)) && apply_filters('gravityview_is_edit_entry', false)) {
231
+			if ($entry->is_multi()) {
232
+				return array_pop($entry->entries);
233
+			}
234
+
235
+			return $entry;
236
+		}
237
+
238
+		return false;
239
+	}
240
+
241
+	/**
242
+	 * Checks whether this an entry search request.
243
+	 *
244
+	 * @api
245
+	 *
246
+	 * @since 2.0
247
+	 *
248
+	 * @todo implementation
249
+	 *
250
+	 * @return bool True if this is a search request.
251
+	 */
252
+	public function is_search()
253
+	{
254
+		$search_method = apply_filters('gravityview/search/method', 'get');
255
+
256
+		if ('post' === $search_method) {
257
+			$get = $_POST;
258
+		} else {
259
+			$get = $_GET;
260
+		}
261
+
262
+		unset($get['mode']);
263
+
264
+		$get = array_filter($get, 'gravityview_is_not_empty_string');
265
+
266
+		if ($has_field_key = $this->_has_field_key($get)) {
267
+			return true;
268
+		}
269
+
270
+		return isset($get['gv_search']) || isset($get['gv_start']) || isset($get['gv_end']) || isset($get['gv_by']) || isset($get['gv_id']);
271
+	}
272
+
273
+	/**
274
+	 * Calculate whether the $_REQUEST has a GravityView field.
275
+	 *
276
+	 * @internal
277
+	 *
278
+	 * @todo Roll into the future Search refactor
279
+	 *
280
+	 * @since 2.0.7
281
+	 *
282
+	 * @param array $get $_POST or $_GET array
283
+	 *
284
+	 * @return bool True: GravityView-formatted field detected; False: not detected
285
+	 */
286
+	private function _has_field_key($get)
287
+	{
288
+		$has_field_key = false;
289
+
290
+		$fields = \GravityView_Fields::get_all();
291
+
292
+		$meta = [];
293
+		foreach ($fields as $field) {
294
+			if (empty($field->_gf_field_class_name)) {
295
+				$meta[] = preg_quote($field->name);
296
+			}
297
+		}
298
+
299
+		foreach ($get as $key => $value) {
300
+			if (preg_match('/^(filter|input)_(([0-9_]+)|'.implode('|', $meta).')$/sm', $key)) {
301
+				$has_field_key = true;
302
+				break;
303
+			}
304
+		}
305
+
306
+		return $has_field_key;
307
+	}
308 308
 }
309 309
 
310 310
 /** Load implementations. */
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function is_renderable()
29 29
     {
30
-        $is_renderable = in_array(get_class($this), [
30
+        $is_renderable = in_array( get_class( $this ), [
31 31
             'GV\Frontend_Request',
32 32
             'GV\Mock_Request',
33 33
             'GV\REST\Request',
34
-        ], true);
34
+        ], true );
35 35
 
36 36
         /**
37 37
          * @filter `gravityview/request/is_renderable` Is this request renderable?
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
          * @param bool        $is_renderable Huh?
42 42
          * @param \GV\Request $this          This.
43 43
          */
44
-        return apply_filters('gravityview/request/is_renderable', $is_renderable, $this);
44
+        return apply_filters( 'gravityview/request/is_renderable', $is_renderable, $this );
45 45
     }
46 46
 
47 47
     /**
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function is_admin()
53 53
     {
54
-        $doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false;
55
-        $load_scripts_styles = preg_match('#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER('SCRIPT_NAME'));
54
+        $doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false;
55
+        $load_scripts_styles = preg_match( '#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER( 'SCRIPT_NAME' ) );
56 56
 
57
-        return is_admin() && !($doing_ajax || $load_scripts_styles);
57
+        return is_admin() && ! ( $doing_ajax || $load_scripts_styles );
58 58
     }
59 59
 
60 60
     /**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public static function is_frontend()
66 66
     {
67
-        return !is_admin();
67
+        return ! is_admin();
68 68
     }
69 69
 
70 70
     /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     public static function is_add_oembed_preview()
78 78
     {
79 79
         /** The preview request is a parse-embed AJAX call without a type set. */
80
-        return  self::is_ajax() && !empty($_POST['action']) && $_POST['action'] == 'parse-embed' && !isset($_POST['type']);
80
+        return  self::is_ajax() && ! empty( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'parse-embed' && ! isset( $_POST[ 'type' ] );
81 81
     }
82 82
 
83 83
     /**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public static function is_ajax()
89 89
     {
90
-        return defined('DOING_AJAX') && DOING_AJAX;
90
+        return defined( 'DOING_AJAX' ) && DOING_AJAX;
91 91
     }
92 92
 
93 93
     /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public static function is_rest()
99 99
     {
100
-        return !empty($GLOBALS['wp']->query_vars['rest_route']);
100
+        return ! empty( $GLOBALS[ 'wp' ]->query_vars[ 'rest_route' ] );
101 101
     }
102 102
 
103 103
     /**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
     public function is_view()
115 115
     {
116 116
         global $post;
117
-        if ($post && get_post_type($post) == 'gravityview') {
118
-            return \GV\View::from_post($post);
117
+        if ( $post && get_post_type( $post ) == 'gravityview' ) {
118
+            return \GV\View::from_post( $post );
119 119
         }
120 120
 
121 121
         return false;
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
      *
135 135
      * @return \GV\GF_Entry|false The entry requested or false.
136 136
      */
137
-    public function is_entry($form_id = 0)
137
+    public function is_entry( $form_id = 0 )
138 138
     {
139 139
         global $wp_query;
140 140
 
141
-        if (!$wp_query) {
141
+        if ( ! $wp_query ) {
142 142
             return false;
143 143
         }
144 144
 
145
-        $id = get_query_var(Entry::get_endpoint_name());
145
+        $id = get_query_var( Entry::get_endpoint_name() );
146 146
 
147
-        if (!$id) {
147
+        if ( ! $id ) {
148 148
             return false;
149 149
         }
150 150
 
151
-        static $entries = [];
151
+        static $entries = [ ];
152 152
 
153
-        if (isset($entries["$form_id:$id"])) {
154
-            return $entries["$form_id:$id"];
153
+        if ( isset( $entries[ "$form_id:$id" ] ) ) {
154
+            return $entries[ "$form_id:$id" ];
155 155
         }
156 156
 
157 157
         $view = $this->is_view();
@@ -159,49 +159,49 @@  discard block
 block discarded – undo
159 159
         /**
160 160
          * Not CPT, so probably a shortcode.
161 161
          */
162
-        if (!$view) {
162
+        if ( ! $view ) {
163 163
             $view = gravityview()->views->get();
164 164
         }
165 165
 
166 166
         /**
167 167
          * A joined request.
168 168
          */
169
-        if ($view && ($joins = $view->joins)) {
170
-            $forms = array_merge(wp_list_pluck($joins, 'join'), wp_list_pluck($joins, 'join_on'));
171
-            $valid_forms = array_unique(wp_list_pluck($forms, 'ID'));
169
+        if ( $view && ( $joins = $view->joins ) ) {
170
+            $forms = array_merge( wp_list_pluck( $joins, 'join' ), wp_list_pluck( $joins, 'join_on' ) );
171
+            $valid_forms = array_unique( wp_list_pluck( $forms, 'ID' ) );
172 172
 
173
-            $multientry = [];
174
-            foreach ($ids = explode(',', $id) as $i => $id) {
175
-                $valid_form = \GV\Utils::get($valid_forms, $i, 0);
173
+            $multientry = [ ];
174
+            foreach ( $ids = explode( ',', $id ) as $i => $id ) {
175
+                $valid_form = \GV\Utils::get( $valid_forms, $i, 0 );
176 176
 
177
-                if (!$e = GF_Entry::by_id($id, $valid_form)) {
177
+                if ( ! $e = GF_Entry::by_id( $id, $valid_form ) ) {
178 178
                     return false;
179 179
                 }
180 180
 
181
-                if (!in_array($e['form_id'], $valid_forms)) {
181
+                if ( ! in_array( $e[ 'form_id' ], $valid_forms ) ) {
182 182
                     return false;
183 183
                 }
184 184
 
185
-                array_push($multientry, $e);
185
+                array_push( $multientry, $e );
186 186
             }
187 187
 
188 188
             // Allow Edit Entry to only edit a single entry on a multi-entry
189
-            $is_edit_entry = apply_filters('gravityview_is_edit_entry', false);
189
+            $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );
190 190
 
191 191
             // Edit entry links are single-entry based
192
-            if ($is_edit_entry && 1 !== count($multientry)) {
192
+            if ( $is_edit_entry && 1 !== count( $multientry ) ) {
193 193
                 return false;
194 194
             }
195 195
 
196
-            $entry = Multi_Entry::from_entries(array_filter($multientry));
196
+            $entry = Multi_Entry::from_entries( array_filter( $multientry ) );
197 197
         } else {
198 198
             /**
199 199
              * A regular one.
200 200
              */
201
-            $entry = GF_Entry::by_id($id, $form_id);
201
+            $entry = GF_Entry::by_id( $id, $form_id );
202 202
         }
203 203
 
204
-        $entries["$form_id:$id"] = $entry;
204
+        $entries[ "$form_id:$id" ] = $entry;
205 205
 
206 206
         return $entry;
207 207
     }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * @return \GV\Entry|false The entry requested or false.
221 221
      */
222
-    public function is_edit_entry($form_id = 0)
222
+    public function is_edit_entry( $form_id = 0 )
223 223
     {
224 224
         /**
225 225
          * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
          *
228 228
          * @param bool $is_edit_entry
229 229
          */
230
-        if (($entry = $this->is_entry($form_id)) && apply_filters('gravityview_is_edit_entry', false)) {
231
-            if ($entry->is_multi()) {
232
-                return array_pop($entry->entries);
230
+        if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) {
231
+            if ( $entry->is_multi() ) {
232
+                return array_pop( $entry->entries );
233 233
             }
234 234
 
235 235
             return $entry;
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function is_search()
253 253
     {
254
-        $search_method = apply_filters('gravityview/search/method', 'get');
254
+        $search_method = apply_filters( 'gravityview/search/method', 'get' );
255 255
 
256
-        if ('post' === $search_method) {
256
+        if ( 'post' === $search_method ) {
257 257
             $get = $_POST;
258 258
         } else {
259 259
             $get = $_GET;
260 260
         }
261 261
 
262
-        unset($get['mode']);
262
+        unset( $get[ 'mode' ] );
263 263
 
264
-        $get = array_filter($get, 'gravityview_is_not_empty_string');
264
+        $get = array_filter( $get, 'gravityview_is_not_empty_string' );
265 265
 
266
-        if ($has_field_key = $this->_has_field_key($get)) {
266
+        if ( $has_field_key = $this->_has_field_key( $get ) ) {
267 267
             return true;
268 268
         }
269 269
 
270
-        return isset($get['gv_search']) || isset($get['gv_start']) || isset($get['gv_end']) || isset($get['gv_by']) || isset($get['gv_id']);
270
+        return isset( $get[ 'gv_search' ] ) || isset( $get[ 'gv_start' ] ) || isset( $get[ 'gv_end' ] ) || isset( $get[ 'gv_by' ] ) || isset( $get[ 'gv_id' ] );
271 271
     }
272 272
 
273 273
     /**
@@ -283,21 +283,21 @@  discard block
 block discarded – undo
283 283
      *
284 284
      * @return bool True: GravityView-formatted field detected; False: not detected
285 285
      */
286
-    private function _has_field_key($get)
286
+    private function _has_field_key( $get )
287 287
     {
288 288
         $has_field_key = false;
289 289
 
290 290
         $fields = \GravityView_Fields::get_all();
291 291
 
292
-        $meta = [];
293
-        foreach ($fields as $field) {
294
-            if (empty($field->_gf_field_class_name)) {
295
-                $meta[] = preg_quote($field->name);
292
+        $meta = [ ];
293
+        foreach ( $fields as $field ) {
294
+            if ( empty( $field->_gf_field_class_name ) ) {
295
+                $meta[ ] = preg_quote( $field->name );
296 296
             }
297 297
         }
298 298
 
299
-        foreach ($get as $key => $value) {
300
-            if (preg_match('/^(filter|input)_(([0-9_]+)|'.implode('|', $meta).')$/sm', $key)) {
299
+        foreach ( $get as $key => $value ) {
300
+            if ( preg_match( '/^(filter|input)_(([0-9_]+)|' . implode( '|', $meta ) . ')$/sm', $key ) ) {
301 301
                 $has_field_key = true;
302 302
                 break;
303 303
             }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 }
309 309
 
310 310
 /** Load implementations. */
311
-require gravityview()->plugin->dir('future/includes/class-gv-request-frontend.php');
312
-require gravityview()->plugin->dir('future/includes/class-gv-request-admin.php');
313
-require gravityview()->plugin->dir('future/includes/rest/class-gv-request-rest.php');
314
-require gravityview()->plugin->dir('future/includes/class-gv-request-mock.php');
311
+require gravityview()->plugin->dir( 'future/includes/class-gv-request-frontend.php' );
312
+require gravityview()->plugin->dir( 'future/includes/class-gv-request-admin.php' );
313
+require gravityview()->plugin->dir( 'future/includes/rest/class-gv-request-rest.php' );
314
+require gravityview()->plugin->dir( 'future/includes/class-gv-request-mock.php' );
Please login to merge, or discard this patch.
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,10 +12,8 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * Knows more about the request than anyone else.
14 14
  */
15
-abstract class Request
16
-{
17
-    public function __construct()
18
-    {
15
+abstract class Request {
16
+    public function __construct() {
19 17
     }
20 18
 
21 19
     /**
@@ -25,8 +23,7 @@  discard block
 block discarded – undo
25 23
      *
26 24
      * @return bool Yes or no.
27 25
      */
28
-    public function is_renderable()
29
-    {
26
+    public function is_renderable() {
30 27
         $is_renderable = in_array(get_class($this), [
31 28
             'GV\Frontend_Request',
32 29
             'GV\Mock_Request',
@@ -49,8 +46,7 @@  discard block
 block discarded – undo
49 46
      *
50 47
      * @return bool
51 48
      */
52
-    public static function is_admin()
53
-    {
49
+    public static function is_admin() {
54 50
         $doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false;
55 51
         $load_scripts_styles = preg_match('#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER('SCRIPT_NAME'));
56 52
 
@@ -62,8 +58,7 @@  discard block
 block discarded – undo
62 58
      *
63 59
      * @return bool True or false.
64 60
      */
65
-    public static function is_frontend()
66
-    {
61
+    public static function is_frontend() {
67 62
         return !is_admin();
68 63
     }
69 64
 
@@ -74,8 +69,7 @@  discard block
 block discarded – undo
74 69
      *
75 70
      * @return bool
76 71
      */
77
-    public static function is_add_oembed_preview()
78
-    {
72
+    public static function is_add_oembed_preview() {
79 73
         /** The preview request is a parse-embed AJAX call without a type set. */
80 74
         return  self::is_ajax() && !empty($_POST['action']) && $_POST['action'] == 'parse-embed' && !isset($_POST['type']);
81 75
     }
@@ -85,8 +79,7 @@  discard block
 block discarded – undo
85 79
      *
86 80
      * @return bool
87 81
      */
88
-    public static function is_ajax()
89
-    {
82
+    public static function is_ajax() {
90 83
         return defined('DOING_AJAX') && DOING_AJAX;
91 84
     }
92 85
 
@@ -95,8 +88,7 @@  discard block
 block discarded – undo
95 88
      *
96 89
      * @return bool
97 90
      */
98
-    public static function is_rest()
99
-    {
91
+    public static function is_rest() {
100 92
         return !empty($GLOBALS['wp']->query_vars['rest_route']);
101 93
     }
102 94
 
@@ -111,8 +103,7 @@  discard block
 block discarded – undo
111 103
      *
112 104
      * @return \GV\View|false The view requested or false
113 105
      */
114
-    public function is_view()
115
-    {
106
+    public function is_view() {
116 107
         global $post;
117 108
         if ($post && get_post_type($post) == 'gravityview') {
118 109
             return \GV\View::from_post($post);
@@ -134,8 +125,7 @@  discard block
 block discarded – undo
134 125
      *
135 126
      * @return \GV\GF_Entry|false The entry requested or false.
136 127
      */
137
-    public function is_entry($form_id = 0)
138
-    {
128
+    public function is_entry($form_id = 0) {
139 129
         global $wp_query;
140 130
 
141 131
         if (!$wp_query) {
@@ -219,8 +209,7 @@  discard block
 block discarded – undo
219 209
      *
220 210
      * @return \GV\Entry|false The entry requested or false.
221 211
      */
222
-    public function is_edit_entry($form_id = 0)
223
-    {
212
+    public function is_edit_entry($form_id = 0) {
224 213
         /**
225 214
          * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
226 215
          * The Edit Entry functionality overrides this value.
@@ -249,8 +238,7 @@  discard block
 block discarded – undo
249 238
      *
250 239
      * @return bool True if this is a search request.
251 240
      */
252
-    public function is_search()
253
-    {
241
+    public function is_search() {
254 242
         $search_method = apply_filters('gravityview/search/method', 'get');
255 243
 
256 244
         if ('post' === $search_method) {
@@ -283,8 +271,7 @@  discard block
 block discarded – undo
283 271
      *
284 272
      * @return bool True: GravityView-formatted field detected; False: not detected
285 273
      */
286
-    private function _has_field_key($get)
287
-    {
274
+    private function _has_field_key($get) {
288 275
         $has_field_key = false;
289 276
 
290 277
         $fields = \GravityView_Fields::get_all();
Please login to merge, or discard this patch.
future/includes/class-gv-template-entry-list.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,93 +14,93 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Entry_List_Template extends Entry_Template
16 16
 {
17
-    /**
18
-     * @var string The template slug to be loaded (like "table", "list")
19
-     */
20
-    public static $slug = 'list';
21
-
22
-    /**
23
-     * Output the field in the list view.
24
-     *
25
-     * @param \GV\Field $field  The field to output.
26
-     * @param array     $extras Extra stuff, like wpautop, etc.
27
-     *
28
-     * @return string
29
-     */
30
-    public function the_field(\GV\Field $field, $extras = null)
31
-    {
32
-        $form = \GV\GF_Form::by_id($field->form_id) ?: $this->view->form;
33
-        $entry = $this->entry->from_field($field);
34
-
35
-        if (!$entry) {
36
-            return '';
37
-        }
38
-
39
-        $renderer = new Field_Renderer();
40
-        $source = is_numeric($field->ID) ? (GF_Form::by_id($field->form_id) ?: $this->view->form) : new Internal_Source();
41
-
42
-        $value = $renderer->render($field, $this->view, $source, $entry, $this->request);
43
-
44
-        $context = Template_Context::from_template($this, compact('field', 'entry'));
45
-
46
-        /**
47
-         * @deprecated Here for back-compatibility.
48
-         */
49
-        $label = apply_filters('gravityview_render_after_label', $field->get_label($this->view, $form, $entry), $field->as_configuration());
50
-        $label = apply_filters('gravityview/template/field_label', $label, $field->as_configuration(), is_numeric($field->ID) ? ($source->form ? $source->form : null) : null, $entry->as_entry());
51
-
52
-        /**
53
-         * @filter `gravityview/template/field/label` Override the field label.
54
-         *
55
-         * @since 2.0
56
-         *
57
-         * @param string               $label   The label to override.
58
-         * @param \GV\Template_Context $context The context.
59
-         */
60
-        $label = apply_filters('gravityview/template/field/label', $label, $context);
61
-
62
-        /**
63
-         * @filter `gravityview/template/table/entry/hide_empty`
64
-         *
65
-         * @param bool                 $hide_empty Should the row be hidden if the value is empty? Default: don't hide.
66
-         * @param \GV\Template_Context $context    The context ;) Love it, cherish it. And don't you dare modify it!
67
-         */
68
-        $hide_empty = apply_filters('gravityview/render/hide-empty-zone', Utils::get($extras, 'hide_empty', $this->view->settings->get('hide_empty', false)), $context);
69
-
70
-        if (is_numeric($field->ID)) {
71
-            $extras['field'] = $field->as_configuration();
72
-        }
73
-
74
-        $extras['entry'] = $this->entry->as_entry();
75
-        $extras['hide_empty'] = $hide_empty;
76
-        $extras['label'] = $label;
77
-        $extras['value'] = $value;
78
-
79
-        return \gravityview_field_output($extras, $context);
80
-    }
81
-
82
-    /**
83
-     * Return an array of variables ready to be extracted.
84
-     *
85
-     * @param string|array $zones The field zones to grab.
86
-     *
87
-     * @return array An array ready to be extract()ed in the form of
88
-     *               $zone => \GV\Field_Collection
89
-     *               has_$zone => int
90
-     */
91
-    public function extract_zone_vars($zones)
92
-    {
93
-        if (!is_array($zones)) {
94
-            $zones = [$zones];
95
-        }
96
-
97
-        $vars = [];
98
-        foreach ($zones as $zone) {
99
-            $zone_var = str_replace('-', '_', $zone);
100
-            $vars[$zone_var] = $this->view->fields->by_position('single_list-'.$zone)->by_visible($this->view);
101
-            $vars["has_$zone_var"] = $vars[$zone_var]->count();
102
-        }
103
-
104
-        return $vars;
105
-    }
17
+	/**
18
+	 * @var string The template slug to be loaded (like "table", "list")
19
+	 */
20
+	public static $slug = 'list';
21
+
22
+	/**
23
+	 * Output the field in the list view.
24
+	 *
25
+	 * @param \GV\Field $field  The field to output.
26
+	 * @param array     $extras Extra stuff, like wpautop, etc.
27
+	 *
28
+	 * @return string
29
+	 */
30
+	public function the_field(\GV\Field $field, $extras = null)
31
+	{
32
+		$form = \GV\GF_Form::by_id($field->form_id) ?: $this->view->form;
33
+		$entry = $this->entry->from_field($field);
34
+
35
+		if (!$entry) {
36
+			return '';
37
+		}
38
+
39
+		$renderer = new Field_Renderer();
40
+		$source = is_numeric($field->ID) ? (GF_Form::by_id($field->form_id) ?: $this->view->form) : new Internal_Source();
41
+
42
+		$value = $renderer->render($field, $this->view, $source, $entry, $this->request);
43
+
44
+		$context = Template_Context::from_template($this, compact('field', 'entry'));
45
+
46
+		/**
47
+		 * @deprecated Here for back-compatibility.
48
+		 */
49
+		$label = apply_filters('gravityview_render_after_label', $field->get_label($this->view, $form, $entry), $field->as_configuration());
50
+		$label = apply_filters('gravityview/template/field_label', $label, $field->as_configuration(), is_numeric($field->ID) ? ($source->form ? $source->form : null) : null, $entry->as_entry());
51
+
52
+		/**
53
+		 * @filter `gravityview/template/field/label` Override the field label.
54
+		 *
55
+		 * @since 2.0
56
+		 *
57
+		 * @param string               $label   The label to override.
58
+		 * @param \GV\Template_Context $context The context.
59
+		 */
60
+		$label = apply_filters('gravityview/template/field/label', $label, $context);
61
+
62
+		/**
63
+		 * @filter `gravityview/template/table/entry/hide_empty`
64
+		 *
65
+		 * @param bool                 $hide_empty Should the row be hidden if the value is empty? Default: don't hide.
66
+		 * @param \GV\Template_Context $context    The context ;) Love it, cherish it. And don't you dare modify it!
67
+		 */
68
+		$hide_empty = apply_filters('gravityview/render/hide-empty-zone', Utils::get($extras, 'hide_empty', $this->view->settings->get('hide_empty', false)), $context);
69
+
70
+		if (is_numeric($field->ID)) {
71
+			$extras['field'] = $field->as_configuration();
72
+		}
73
+
74
+		$extras['entry'] = $this->entry->as_entry();
75
+		$extras['hide_empty'] = $hide_empty;
76
+		$extras['label'] = $label;
77
+		$extras['value'] = $value;
78
+
79
+		return \gravityview_field_output($extras, $context);
80
+	}
81
+
82
+	/**
83
+	 * Return an array of variables ready to be extracted.
84
+	 *
85
+	 * @param string|array $zones The field zones to grab.
86
+	 *
87
+	 * @return array An array ready to be extract()ed in the form of
88
+	 *               $zone => \GV\Field_Collection
89
+	 *               has_$zone => int
90
+	 */
91
+	public function extract_zone_vars($zones)
92
+	{
93
+		if (!is_array($zones)) {
94
+			$zones = [$zones];
95
+		}
96
+
97
+		$vars = [];
98
+		foreach ($zones as $zone) {
99
+			$zone_var = str_replace('-', '_', $zone);
100
+			$vars[$zone_var] = $this->view->fields->by_position('single_list-'.$zone)->by_visible($this->view);
101
+			$vars["has_$zone_var"] = $vars[$zone_var]->count();
102
+		}
103
+
104
+		return $vars;
105
+	}
106 106
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -27,27 +27,27 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return string
29 29
      */
30
-    public function the_field(\GV\Field $field, $extras = null)
30
+    public function the_field( \GV\Field $field, $extras = null )
31 31
     {
32
-        $form = \GV\GF_Form::by_id($field->form_id) ?: $this->view->form;
33
-        $entry = $this->entry->from_field($field);
32
+        $form = \GV\GF_Form::by_id( $field->form_id ) ?: $this->view->form;
33
+        $entry = $this->entry->from_field( $field );
34 34
 
35
-        if (!$entry) {
35
+        if ( ! $entry ) {
36 36
             return '';
37 37
         }
38 38
 
39 39
         $renderer = new Field_Renderer();
40
-        $source = is_numeric($field->ID) ? (GF_Form::by_id($field->form_id) ?: $this->view->form) : new Internal_Source();
40
+        $source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ?: $this->view->form ) : new Internal_Source();
41 41
 
42
-        $value = $renderer->render($field, $this->view, $source, $entry, $this->request);
42
+        $value = $renderer->render( $field, $this->view, $source, $entry, $this->request );
43 43
 
44
-        $context = Template_Context::from_template($this, compact('field', 'entry'));
44
+        $context = Template_Context::from_template( $this, compact( 'field', 'entry' ) );
45 45
 
46 46
         /**
47 47
          * @deprecated Here for back-compatibility.
48 48
          */
49
-        $label = apply_filters('gravityview_render_after_label', $field->get_label($this->view, $form, $entry), $field->as_configuration());
50
-        $label = apply_filters('gravityview/template/field_label', $label, $field->as_configuration(), is_numeric($field->ID) ? ($source->form ? $source->form : null) : null, $entry->as_entry());
49
+        $label = apply_filters( 'gravityview_render_after_label', $field->get_label( $this->view, $form, $entry ), $field->as_configuration() );
50
+        $label = apply_filters( 'gravityview/template/field_label', $label, $field->as_configuration(), is_numeric( $field->ID ) ? ( $source->form ? $source->form : null ) : null, $entry->as_entry() );
51 51
 
52 52
         /**
53 53
          * @filter `gravityview/template/field/label` Override the field label.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
          * @param string               $label   The label to override.
58 58
          * @param \GV\Template_Context $context The context.
59 59
          */
60
-        $label = apply_filters('gravityview/template/field/label', $label, $context);
60
+        $label = apply_filters( 'gravityview/template/field/label', $label, $context );
61 61
 
62 62
         /**
63 63
          * @filter `gravityview/template/table/entry/hide_empty`
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
          * @param bool                 $hide_empty Should the row be hidden if the value is empty? Default: don't hide.
66 66
          * @param \GV\Template_Context $context    The context ;) Love it, cherish it. And don't you dare modify it!
67 67
          */
68
-        $hide_empty = apply_filters('gravityview/render/hide-empty-zone', Utils::get($extras, 'hide_empty', $this->view->settings->get('hide_empty', false)), $context);
68
+        $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context );
69 69
 
70
-        if (is_numeric($field->ID)) {
71
-            $extras['field'] = $field->as_configuration();
70
+        if ( is_numeric( $field->ID ) ) {
71
+            $extras[ 'field' ] = $field->as_configuration();
72 72
         }
73 73
 
74
-        $extras['entry'] = $this->entry->as_entry();
75
-        $extras['hide_empty'] = $hide_empty;
76
-        $extras['label'] = $label;
77
-        $extras['value'] = $value;
74
+        $extras[ 'entry' ] = $this->entry->as_entry();
75
+        $extras[ 'hide_empty' ] = $hide_empty;
76
+        $extras[ 'label' ] = $label;
77
+        $extras[ 'value' ] = $value;
78 78
 
79
-        return \gravityview_field_output($extras, $context);
79
+        return \gravityview_field_output( $extras, $context );
80 80
     }
81 81
 
82 82
     /**
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
      *               $zone => \GV\Field_Collection
89 89
      *               has_$zone => int
90 90
      */
91
-    public function extract_zone_vars($zones)
91
+    public function extract_zone_vars( $zones )
92 92
     {
93
-        if (!is_array($zones)) {
94
-            $zones = [$zones];
93
+        if ( ! is_array( $zones ) ) {
94
+            $zones = [ $zones ];
95 95
         }
96 96
 
97
-        $vars = [];
98
-        foreach ($zones as $zone) {
99
-            $zone_var = str_replace('-', '_', $zone);
100
-            $vars[$zone_var] = $this->view->fields->by_position('single_list-'.$zone)->by_visible($this->view);
101
-            $vars["has_$zone_var"] = $vars[$zone_var]->count();
97
+        $vars = [ ];
98
+        foreach ( $zones as $zone ) {
99
+            $zone_var = str_replace( '-', '_', $zone );
100
+            $vars[ $zone_var ] = $this->view->fields->by_position( 'single_list-' . $zone )->by_visible( $this->view );
101
+            $vars[ "has_$zone_var" ] = $vars[ $zone_var ]->count();
102 102
         }
103 103
 
104 104
         return $vars;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * Renders a \GV\Entry using a \GV\Entry_Renderer.
14 14
  */
15
-class Entry_List_Template extends Entry_Template
16
-{
15
+class Entry_List_Template extends Entry_Template {
17 16
     /**
18 17
      * @var string The template slug to be loaded (like "table", "list")
19 18
      */
@@ -27,8 +26,7 @@  discard block
 block discarded – undo
27 26
      *
28 27
      * @return string
29 28
      */
30
-    public function the_field(\GV\Field $field, $extras = null)
31
-    {
29
+    public function the_field(\GV\Field $field, $extras = null) {
32 30
         $form = \GV\GF_Form::by_id($field->form_id) ?: $this->view->form;
33 31
         $entry = $this->entry->from_field($field);
34 32
 
@@ -88,8 +86,7 @@  discard block
 block discarded – undo
88 86
      *               $zone => \GV\Field_Collection
89 87
      *               has_$zone => int
90 88
      */
91
-    public function extract_zone_vars($zones)
92
-    {
89
+    public function extract_zone_vars($zones) {
93 90
         if (!is_array($zones)) {
94 91
             $zones = [$zones];
95 92
         }
Please login to merge, or discard this patch.
future/includes/class-gv-source.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -18,40 +18,40 @@  discard block
 block discarded – undo
18 18
  */
19 19
 abstract class Source
20 20
 {
21
-    /**
22
-     * @var string BACKEND_INTERNAL The backend identifier for special GravityView data sources
23
-     *             like custom content and the like. Not really a form, but a source nevertheless.
24
-     */
25
-    const BACKEND_INTERNAL = 'internal';
21
+	/**
22
+	 * @var string BACKEND_INTERNAL The backend identifier for special GravityView data sources
23
+	 *             like custom content and the like. Not really a form, but a source nevertheless.
24
+	 */
25
+	const BACKEND_INTERNAL = 'internal';
26 26
 
27
-    /**
28
-     * @var string BACKEND_GRAVITYFORMS The backend identifier for special GravityView data sources
29
-     *             like custom content and the like. Not really a form, but a source nevertheless.
30
-     */
31
-    const BACKEND_GRAVITYFORMS = 'gravityforms';
27
+	/**
28
+	 * @var string BACKEND_GRAVITYFORMS The backend identifier for special GravityView data sources
29
+	 *             like custom content and the like. Not really a form, but a source nevertheless.
30
+	 */
31
+	const BACKEND_GRAVITYFORMS = 'gravityforms';
32 32
 
33
-    /**
34
-     * @var string The identifier of the backend used for this source.
35
-     *
36
-     * @see Constant backend identifiers above and \GV\Source subclasses.
37
-     *
38
-     * @api
39
-     *
40
-     * @since 2.0
41
-     */
42
-    public static $backend = null;
33
+	/**
34
+	 * @var string The identifier of the backend used for this source.
35
+	 *
36
+	 * @see Constant backend identifiers above and \GV\Source subclasses.
37
+	 *
38
+	 * @api
39
+	 *
40
+	 * @since 2.0
41
+	 */
42
+	public static $backend = null;
43 43
 
44
-    /**
45
-     * Get a \GV\Field instance by ID.
46
-     *
47
-     * Accepts a variable number of arguments, see implementations.
48
-     *
49
-     * @return \GV\Field|null A \GV\Field instance.
50
-     */
51
-    public static function get_field(/** varargs */)
52
-    {
53
-        gravityview()->log->error('{source}::get_field not implemented in {source}', ['source' => get_called_class()]);
44
+	/**
45
+	 * Get a \GV\Field instance by ID.
46
+	 *
47
+	 * Accepts a variable number of arguments, see implementations.
48
+	 *
49
+	 * @return \GV\Field|null A \GV\Field instance.
50
+	 */
51
+	public static function get_field(/** varargs */)
52
+	{
53
+		gravityview()->log->error('{source}::get_field not implemented in {source}', ['source' => get_called_class()]);
54 54
 
55
-        return null;
56
-    }
55
+		return null;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return \GV\Field|null A \GV\Field instance.
50 50
      */
51
-    public static function get_field(/** varargs */)
51
+    public static function get_field( /** varargs */ )
52 52
     {
53
-        gravityview()->log->error('{source}::get_field not implemented in {source}', ['source' => get_called_class()]);
53
+        gravityview()->log->error( '{source}::get_field not implemented in {source}', [ 'source' => get_called_class() ] );
54 54
 
55 55
         return null;
56 56
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@  discard block
 block discarded – undo
16 16
  *  from the \GV\View and its \GV\Field configuration. While "gravityforms"
17 17
  *  fields are sourced from \GV\Entry instances.
18 18
  */
19
-abstract class Source
20
-{
19
+abstract class Source {
21 20
     /**
22 21
      * @var string BACKEND_INTERNAL The backend identifier for special GravityView data sources
23 22
      *             like custom content and the like. Not really a form, but a source nevertheless.
@@ -48,8 +47,7 @@  discard block
 block discarded – undo
48 47
      *
49 48
      * @return \GV\Field|null A \GV\Field instance.
50 49
      */
51
-    public static function get_field(/** varargs */)
52
-    {
50
+    public static function get_field(/** varargs */) {
53 51
         gravityview()->log->error('{source}::get_field not implemented in {source}', ['source' => get_called_class()]);
54 52
 
55 53
         return null;
Please login to merge, or discard this patch.