Completed
Pull Request — develop (#1487)
by Gennady
07:46
created

gventry::callback()   F

Complexity

Conditions 29
Paths 212

Size

Total Lines 204

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 50
CRAP Score 102.8104

Importance

Changes 0
Metric Value
cc 29
nc 212
nop 3
dl 0
loc 204
ccs 50
cts 90
cp 0.5556
crap 102.8104
rs 2.5466
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
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 [gventry] shortcode.
11
 */
12
class gventry extends \GV\Shortcode {
13
	/**
14
	 * {@inheritDoc}
15
	 */
16
	public $name = 'gventry';
17
18
	/**
19
	 * Process and output the [gventry] shortcode.
20
	 *
21
	 * @param array $passed_atts The attributes passed.
0 ignored issues
show
Bug introduced by
There is no parameter named $passed_atts. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
22
	 * @param string $content The content inside the shortcode.
23
	 * @param string $tag The shortcode tag.
24
	 *
25
	 * @return string|null The output.
26
	 */
27 2
	public function callback( $atts, $content = '', $tag = '' ) {
28 2
		$request = gravityview()->request;
29
30 2
		if ( $request->is_admin() ) {
31 1
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts );
32
		}
33
34 2
		$atts = wp_parse_args( $atts, array(
35 2
			'id'        => 0,
36
			'entry_id'  => 0,
37
			'view_id'   => 0,
38
			'edit'      => 0,
39
		) );
40
41 2
		$atts = gv_map_deep( $atts, array( 'GravityView_Merge_Tags', 'replace_get_variables' ) );
42
43
		/**
44
		 * @filter `gravityview/shortcodes/gventry/atts` Filter the [gventry] shortcode attributes.
45
		 * @param array $atts The initial attributes.
46
		 * @since 2.0
47
		 */
48 2
		$atts = apply_filters( 'gravityview/shortcodes/gventry/atts', $atts );
49
50 2
		$view = \GV\View::by_id( $atts['view_id'] );
51
52 2
		if ( ! $view ) {
53 1
			gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts['view_id'] ) );
54 1
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts );
55
		}
56
57 2
		$entry_id = ! empty( $atts['entry_id'] ) ? $atts['entry_id'] : $atts['id'];
58
59 2
		switch( $entry_id ):
60 2
			case 'last':
61 1
				if ( class_exists( '\GF_Query' ) ) {
62
					/**
63
					 * @todo Remove once we refactor the use of get_view_entries_parameters.
64
					 *
65
					 * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here.
66
					 */
67
					add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $form_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68 1
						if ( ! empty( $parameters['sorting'] ) ) {
69
							/**
70
							 * Reverse existing sorts.
71
							 */
72
							$sort = &$parameters['sorting'];
73
							$sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' );
74
						} else {
75
							/**
76
							 * Otherwise, sort by date_created.
77
							 */
78 1
							$parameters['sorting'] = array(
79
								'key' => 'id',
80
								'direction' => 'ASC',
81
								'is_numeric' => true
82
							);
83
						}
84 1
						return $parameters;
85 1
					}, 10, 3 );
86 1
					$entries = $view->get_entries( null );
87 1
					remove_filter( 'gravityview_get_entries', $filter );
88
				} else {
89
					$entries = $view->get_entries( null );
90
91
					/** If a sort already exists, reverse it. */
92
					if ( $sort = end( $entries->sorts ) ) {
93
						$entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ? : ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode );
0 ignored issues
show
Unused Code introduced by
The call to Entry_Collection::sort() has too many arguments starting with $sort->mode.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
94
					} else {
95
						/** Otherwise, sort by date_created */
96
						$entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC );
0 ignored issues
show
Unused Code introduced by
The call to Entry_Collection::sort() has too many arguments starting with \GV\Entry_Sort::NUMERIC.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
97
					}
98
				}
99
100 1
				if ( ! $entry = $entries->first() ) {
101 1
					return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts );
102
				}
103
				break;
104 2
			case 'first':
105 2
				if ( ! $entry = $view->get_entries( null )->first() ) {
106 1
					return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts );
107
				}
108
				break;
109
			default:
110 2
				if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) {
111 1
					gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) );
112 1
					return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts );
113
				}
114
		endswitch;
115
116 2
		if ( $view->form->ID != $entry['form_id'] ) {
117 1
			gravityview()->log->error( 'Entry does not belong to view (form mismatch)' );
118 1
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
119
		}
120
121 2
		if ( post_password_required( $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...
122 1
			gravityview()->log->notice( 'Post password is required for View #{view_id}', array( '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...
123 1
			return apply_filters( 'gravityview/shortcodes/gventry/output', get_the_password_form( $view->ID ), $view, $entry, $atts );
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...
124
		}
125
126 1
		if ( ! $view->form  ) {
127
			gravityview()->log->notice( 'View #{id} has no form attached to it.', array( '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...
128
129
			/**
130
			 * This View has no data source. There's nothing to show really.
131
			 * ...apart from a nice message if the user can do anything about it.
132
			 */
133
			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...
134
				$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...
135
				return apply_filters( 'gravityview/shortcodes/gventry/output', $return, $view, $entry, $atts );
136
			}
137
138
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
139
		}
140
141
		/** Private, pending, draft, etc. */
142 1
		$public_states = get_post_stati( array( 'public' => true ) );
143 1
		if ( ! in_array( $view->post_status, $public_states ) && ! \GVCommon::has_cap( 'read_gravityview', $view->ID ) ) {
0 ignored issues
show
Documentation introduced by
The property post_status 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...
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...
144
			gravityview()->log->notice( 'The current user cannot access this View #{view_id}', array( '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...
145
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
146
		}
147
148
		/** Unapproved entries. */
149 1
		if ( $entry['status'] != 'active' ) {
150
			gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
151
			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
152
		}
153
154 1
		$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...
155
156 1
		if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
157
			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
158
				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
159
				return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
160
			}
161
		}
162
163 1
		if ( $atts['edit'] ) {
164
			/**
165
			 * Based on code in our unit-tests.
166
			 * Mocks old context, etc.
167
			 */
168
			$loader = \GravityView_Edit_Entry::getInstance();
169
			$render = $loader->instances['render'];
170
171
			add_filter( 'gravityview/is_single_entry', '__return_true' );
172
173
			$form = \GFAPI::get_form( $entry['form_id'] );
174
175
			$data = \GravityView_View_Data::getInstance( $view );
176
			$template = \GravityView_View::getInstance( array(
177
				'form' => $form,
178
				'form_id' => $form['id'],
179
				'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...
180
				'entries' => array( $entry ),
181
				'atts' => \GVCommon::get_template_settings( $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...
182
			) );
183
184
			$_GET['edit'] = wp_create_nonce(
185
				\GravityView_Edit_Entry::get_nonce_key( $view->ID, $form['id'], $entry['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...
186
			);
187
188
			add_filter( 'gravityview/edit_entry/success', $callback = function( $message ) use ( $view, $entry, $atts ) {
0 ignored issues
show
Unused Code introduced by
The parameter $message is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
189
				$message = __( 'Entry Updated', 'gravityview' );
190
191
				/**
192
				 * @filter `gravityview/shortcodes/gventry/edit/success` Modify the edit entry success message in [gventry].
193
				 * @since develop
194
				 * @param[in,out] string $message The message.
195
				 * @param \GV\View $view The View.
196
				 * @param \GV\Entry $entry The entry.
197
				 * @param array $atts The attributes.
198
				 */
199
				return apply_filters( 'gravityview/shortcodes/gventry/edit/success', $message, $view, $entry, $atts );
200
			} );
201
202
			ob_start() && $render->init( $data, \GV\Entry::by_id( $entry['id'] ), $view );
203
			$output = ob_get_clean(); // Render :)
204
205
			remove_filter( 'gravityview/is_single_entry', '__return_true' );
206
			remove_filter( 'gravityview/edit_entry/success', $callback );
207
		} else {
208
			/** Remove the back link. */
209 1
			add_filter( 'gravityview/template/links/back/url', '__return_false' );
210
211 1
			$renderer = new \GV\Entry_Renderer();
212
213 1
			$request = new \GV\Mock_Request();
214 1
			$request->returns['is_entry'] = $entry;
215
216 1
			$output = $renderer->render( $entry, $view, $request );
217
218 1
			remove_filter( 'gravityview/template/links/back/url', '__return_false' );
219
		}
220
221
		/**
222
		 * @filter `gravityview/shortcodes/gventry/output` Filter the [gventry] output.
223
		 * @param string $output The output.
224
		 * @param \GV\View|null $view The View detected or null.
225
		 * @param \GV\Entry|null $entry The Entry or null.
226
		 *
227
		 * @since 2.0
228
		 */
229 1
		return apply_filters( 'gravityview/shortcodes/gventry/output', $output, $view, $entry, $atts );
230
	}
231
}
232