Completed
Push — develop ( e63648...3edd81 )
by Zack
19:54 queued 12:35
created

gravityview   F

Complexity

Total Complexity 62

Size/Duplication

Total Lines 328
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 15

Test Coverage

Coverage 70.15%

Importance

Changes 0
Metric Value
dl 0
loc 328
ccs 94
cts 134
cp 0.7015
rs 3.44
c 0
b 0
f 0
wmc 62
lcom 1
cbo 15

4 Methods

Rating   Name   Duplication   Size   Complexity  
C parse_and_sanitize_atts() 0 59 11
A detail() 0 32 5
A _return() 0 4 1
F callback() 0 182 45

How to fix   Complexity   

Complex Class

Complex classes like gravityview often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use gravityview, and based on these observations, apply Extract Interface, too.

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace GV\Shortcodes;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6
	die();
7
}
8
9
/**
10
 * The [gravityview] shortcode.
11
 */
12
class gravityview extends \GV\Shortcode {
0 ignored issues
show
Coding Style introduced by
Class name "gravityview" is not in camel caps format
Loading history...
13
	/**
14
	 * {@inheritDoc}
15
	 */
16
	public $name = 'gravityview';
17
18
	/**
19
	 * A stack of calls to track nested shortcodes.
20
	 */
21
	public static $callstack = array();
22
23
	/**
24
	 * Process and output the [gravityview] shortcode.
25
	 *
26
	 * @param array $passed_atts The attributes passed.
27
	 * @param string $content The content inside the shortcode.
28
	 *
29
	 * @return string|null The output.
30
	 */
31 7
	public function callback( $passed_atts, $content = null ) {
32 7
		$request = gravityview()->request;
33
34 7
		if ( $request->is_admin() ) {
35
			return '';
36
		}
37
38 7
		$atts = wp_parse_args( $passed_atts, array(
39 7
			'id' => 0,
40
			'view_id' => 0,
41
			'detail' => null,
42
		) );
43
		
44 7
		if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) {
45
			if ( $atts['detail'] && $view = $request->is_view() ) {
46
				$view_id = $view->ID;
0 ignored issues
show
Bug introduced by
The property ID does not seem to exist in GV\View.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
47
			}
48
		}
49
50 7
		$view = \GV\View::by_id( $view_id );
51
52 7
		if ( ! $view ) {
53
			gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $view_id ) );
54
			return '';
55
		}
56
57 7
		gravityview()->views->set( $view );
0 ignored issues
show
Documentation introduced by
The property views does not exist on object<GV\Core>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
58
59
		/**
60
		 * When this shortcode is embedded inside a View we can only display it as a directory. There's no other way.
61
		 * Try to detect that we're not embedded to allow edit and single contexts.
62
		 */
63 7
		$is_reembedded = false; // Assume not embedded unless detected otherwise.
64 7
		if ( in_array( get_class( $request ), array( 'GV\Frontend_Request', 'GV\Mock_Request' ) ) ) {
65
66 7
			if ( ( $_view = $request->is_view() ) && $_view->ID !== $view->ID ) {
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
67
				$is_reembedded = true;
68
69 7
			} elseif ( $request->is_entry() && self::$callstack ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression self::$callstack of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
70 1
				$is_reembedded = true;
71
			}
72
		}
73
74 7
		array_push( self::$callstack, true );
75
76
		/**
77
		 * Remove Widgets on a nested embedded View.
78
		 */
79 7
		if ( $is_reembedded ) {
80 1
			$view->widgets = new \GV\Widget_Collection();
81
		}
82
83 7
		$atts = $this->parse_and_sanitize_atts( $atts );
84
85 7
		$view->settings->update( $atts );
86 7
		$entries = $view->get_entries( $request );
87
88
		/**
89
		 * Check permissions.
90
		 */
91 7
		while ( $error = $view->can_render( array( 'shortcode' ), $request ) ) {
92 7
			if ( ! is_wp_error( $error ) )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
93 7
				break;
94
95 1
			switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
96 1
				case 'post_password_required':
97 1
					return self::_return( get_the_password_form( $view->ID ) );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
98 1
				case 'no_form_attached':
99
					/**
100
					 * This View has no data source. There's nothing to show really.
101
					 * ...apart from a nice message if the user can do anything about it.
102
					 */
103
					if ( \GVCommon::has_cap( array( 'edit_gravityviews', 'edit_gravityview' ), $view->ID ) ) {
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
104
						return self::_return( __( sprintf( 'This View is not configured properly. Start by <a href="%s">selecting a form</a>.', esc_url( get_edit_post_link( $view->ID, false ) ) ), 'gravityview' ) );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
introduced by
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'sprintf'
Loading history...
105
					}
106
					break;
107 1
				case 'no_direct_access':
108 1
				case 'embed_only':
109 1
				case 'not_public':
110 1
					return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
111
			}
112
		}
113
114 7
		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
115
116
		/**
117
		 * View details.
118
		 */
119 7
		if ( $atts['detail'] ) {
120 2
			return self::_return( $this->detail( $view, $entries, $atts ) );
121
122
		/**
123
		 * Editing a single entry.
124
		 */
125 6
		} else if ( ! $is_reembedded && ( $entry = $request->is_edit_entry() ) ) {
126
127
			/**
128
			 * When editing an entry don't render multiple views.
129
			 */
130
			if ( ( $selected = \GV\Utils::_GET( 'gvid' ) ) && $view->ID != $selected ) {
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
131
				gravityview()->log->notice( 'Entry ID #{entry_id} not rendered because another View ID was passed using `?gvid`: #{selected}', array( 'entry_id' => $entry->ID, 'selected' => $selected ) );
132
				return self::_return( '' );
133
			}
134
135
			if ( $entry['status'] != 'active' ) {
0 ignored issues
show
introduced by
Found "!= '". Use Yoda Condition checks, you must
Loading history...
136
				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
137
				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
138
			}
139
140
			if ( apply_filters( 'gravityview_custom_entry_slug', false ) && $entry->slug != get_query_var( \GV\Entry::get_endpoint_name() ) ) {
141
				gravityview()->log->error( 'Entry ID #{entry_id} was accessed by a bad slug', array( 'entry_id' => $entry->ID ) );
142
				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
143
			}
144
145
			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
146
				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
147
					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
148
					return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
149
				}
150
			}
151
152
			$renderer = new \GV\Edit_Entry_Renderer();
153
			return self::_return( $renderer->render( $entry, $view, $request ) );
154
155
		/**
156
		 * Viewing a single entry.
157
		 */
158 6
		} else if ( ! $is_reembedded && ( $entry = $request->is_entry() ) ) {
159
			/**
160
			 * When viewing an entry don't render multiple views.
161
			 */
162 3
			if ( ( $selected = \GV\Utils::_GET( 'gvid' ) ) && $view->ID != $selected ) {
0 ignored issues
show
Documentation introduced by
The property ID does not exist on object<GV\View>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
163
				return self::_return( '' );
164
			}
165
166 3
			if ( $entry['status'] != 'active' ) {
0 ignored issues
show
introduced by
Found "!= '". Use Yoda Condition checks, you must
Loading history...
167 1
				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
168 1
				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
169
			}
170
171 3
			if ( apply_filters( 'gravityview_custom_entry_slug', false ) && $entry->slug != get_query_var( \GV\Entry::get_endpoint_name() ) ) {
172 1
				gravityview()->log->error( 'Entry ID #{entry_id} was accessed by a bad slug', array( 'entry_id' => $entry->ID ) );
173 1
				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
174
			}
175
176 3
			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
177 1
				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
178 1
					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
179 1
					return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
180
				}
181
			}
182
183 3
			$error = \GVCommon::check_entry_display( $entry->as_entry() );
184
185 3
			if( is_wp_error( $error ) ) {
186 1
				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) );
187 1
				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
188
			}
189
190 3
			$renderer = new \GV\Entry_Renderer();
191 3
			return self::_return( $renderer->render( $entry, $view, $request ) );
192
193
		/**
194
		 * Just this view.
195
		 */
196
		} else {
197 4
			if ( $is_reembedded ) {
198
				
199
				// Mock the request with the actual View, not the global one
200 1
				$mock_request = new \GV\Mock_Request();
201 1
				$mock_request->returns['is_view'] = $view;
202 1
				$mock_request->returns['is_entry'] = $request->is_entry();
203 1
				$mock_request->returns['is_edit_entry'] = $request->is_edit_entry();
204 1
				$mock_request->returns['is_search'] = $request->is_search();
205
206 1
				$request = $mock_request;
207
			}
208
209 4
			$renderer = new \GV\View_Renderer();
210 4
			return self::_return( $renderer->render( $view, $request ) );
211
		}
212
	}
213
214
	/**
215
	 * Validate attributes passed to the [gravityview] shortcode. Supports {get} Merge Tags values.
216
	 *
217
	 * Attributes passed to the shortcode are compared to registered attributes {@see \GV\View_Settings::defaults}
218
	 * Only attributes that are defined will be allowed through.
219
	 *
220
	 * Then, {get} merge tags are replaced with their $_GET values, if passed
221
	 *
222
	 * Then, attributes are sanitized based on the type of setting (number, checkbox, select, radio, text)
223
	 *
224
	 * @see \GV\View_Settings::defaults() Only attributes defined in default() are valid to be passed via the shortcode
225
	 *
226
	 * @param array $passed_atts Attribute pairs defined to render the View
227
	 *
228
	 * @return array Valid and sanitized attribute pairs
229
	 */
230 6
	private function parse_and_sanitize_atts( $passed_atts ) {
231
232 6
		$defaults = \GV\View_Settings::defaults( true );
233
234 6
		$supported_atts = array_fill_keys( array_keys( $defaults ), '' );
235
236
		// Whittle down the attributes to only valid pairs
237 6
		$filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' );
238
239
		// Only keep the passed attributes after making sure that they're valid pairs
240 6
		$filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts );
241
242 6
		$atts = array();
243
244 6
		foreach( $filtered_atts as $key => $passed_value ) {
245
246
			// Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
247 6
			$passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value );
248
249 6
			switch( $defaults[ $key ]['type'] ) {
250
251
				/**
252
				 * Make sure number fields are numeric.
253
				 * Also, convert mixed number strings to numbers
254
				 * @see http://php.net/manual/en/function.is-numeric.php#107326
255
				 */
256 6
				case 'number':
257 6
					if( is_numeric( $passed_value ) ) {
258 6
						$atts[ $key ] = ( $passed_value + 0 );
259
					}
260 6
					break;
261
262
				// Checkboxes should be 1 or 0
263 1
				case 'checkbox':
264
					$atts[ $key ] = gv_empty( $passed_value, true, false ) ? 0 : 1;
265
					break;
266
267
				/**
268
				 * Only allow values that are defined in the settings
269
				 */
270 1
				case 'select':
271 1
				case 'radio':
272
					$options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options'];
273
					if( in_array( $passed_value, array_keys( $options ) ) ) {
274
						$atts[ $key ] = $passed_value;
275
					}
276
					break;
277
278 1
				case 'text':
279
				default:
280 1
					$atts[ $key ] = $passed_value;
281 6
					break;
282
			}
283
		}
284
285 6
		$atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null );
286
287 6
		return $atts;
288
	}
289
290
	/**
291
	 * Output view details.
292
	 *
293
	 * @param \GV\View $view The View.
294
	 * @param \GV\Entry_Collection $entries The calculated entries.
295
	 * @param array $atts The shortcode attributes (with defaults).
296
	 *
297
	 * @return string The output.
298
	 */
299 1
	private function detail( $view, $entries, $atts ) {
300 1
		$output = '';
301
302 1
		switch ( $key = $atts['detail'] ):
303 1
			case 'total_entries':
304 1
				$output = number_format_i18n( $entries->total() );
305 1
				break;
306
			case 'first_entry':
307
				$output = number_format_i18n( min( $entries->total(), $view->settings->get( 'offset' ) + 1 ) );
308
				break;
309
			case 'last_entry':
310
				$output = number_format_i18n( $view->settings->get( 'page_size' ) + $view->settings->get( 'offset' ) );
311
				break;
312
			case 'page_size':
313
				$output = number_format_i18n( $view->settings->get( $key ) );
314
				break;
315
		endswitch;
316
317
		/**
318
		 * @filter `gravityview/shortcode/detail/{$detail}` Filter the detail output returned from `[gravityview detail="$detail"]`
319
		 * @since 1.13
320
		 * @param string[in,out] $output Existing output
0 ignored issues
show
Documentation introduced by
The doc-type string[in,out] could not be parsed: Expected "]" at position 2, but found "in". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
321
		 *
322
		 * @since 2.0.3
323
		 * @param \GV\View $view The view.
324
		 * @param \GV\Entry_Collection $entries The entries.
325
		 * @param array $atts The shortcode atts with defaults.
326
		 */
327 1
		$output = apply_filters( "gravityview/shortcode/detail/$key", $output, $view );
328
329 1
		return $output;
330
	}
331
332
	/**
333
	 * Pop the callstack and return the value.
334
	 */
335 6
	private static function _return( $value ) {
336 6
		array_pop( self::$callstack );
337 6
		return $value;
338
	}
339
}
340