@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | */ |
48 | 48 | $atts = apply_filters( 'gravityview/shortcodes/gventry/atts', $atts ); |
49 | 49 | |
50 | - $view = \GV\View::by_id( $atts['view_id'] ); |
|
50 | + $view = \GV\View::by_id( $atts[ 'view_id' ] ); |
|
51 | 51 | |
52 | 52 | if ( ! $view ) { |
53 | - gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts['view_id'] ) ); |
|
53 | + gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
54 | 54 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts ); |
55 | 55 | } |
56 | 56 | |
57 | - $entry_id = ! empty( $atts['entry_id'] ) ? $atts['entry_id'] : $atts['id']; |
|
57 | + $entry_id = ! empty( $atts[ 'entry_id' ] ) ? $atts[ 'entry_id' ] : $atts[ 'id' ]; |
|
58 | 58 | |
59 | - switch( $entry_id ): |
|
59 | + switch ( $entry_id ): |
|
60 | 60 | case 'last': |
61 | 61 | if ( class_exists( '\GF_Query' ) ) { |
62 | 62 | /** |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here. |
66 | 66 | */ |
67 | 67 | add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) { |
68 | - if ( ! empty( $parameters['sorting'] ) ) { |
|
68 | + if ( ! empty( $parameters[ 'sorting' ] ) ) { |
|
69 | 69 | /** |
70 | 70 | * Reverse existing sorts. |
71 | 71 | */ |
72 | - $sort = &$parameters['sorting']; |
|
73 | - $sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' ); |
|
72 | + $sort = &$parameters[ 'sorting' ]; |
|
73 | + $sort[ 'direction' ] = $sort[ 'direction' ] == 'RAND' ?: ( $sort[ 'direction' ] == 'ASC' ? 'DESC' : 'ASC' ); |
|
74 | 74 | } else { |
75 | 75 | /** |
76 | 76 | * Otherwise, sort by date_created. |
77 | 77 | */ |
78 | - $parameters['sorting'] = array( |
|
78 | + $parameters[ 'sorting' ] = array( |
|
79 | 79 | 'key' => 'id', |
80 | 80 | 'direction' => 'ASC', |
81 | 81 | 'is_numeric' => true |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | /** If a sort already exists, reverse it. */ |
92 | 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 ); |
|
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 ); |
|
94 | 94 | } else { |
95 | 95 | /** Otherwise, sort by date_created */ |
96 | 96 | $entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC ); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | break; |
109 | 109 | default: |
110 | 110 | if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) { |
111 | - gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) ); |
|
111 | + gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
112 | 112 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts ); |
113 | 113 | } |
114 | 114 | endswitch; |
115 | 115 | |
116 | - if ( $view->form->ID != $entry['form_id'] ) { |
|
116 | + if ( $view->form->ID != $entry[ 'form_id' ] ) { |
|
117 | 117 | gravityview()->log->error( 'Entry does not belong to view (form mismatch)' ); |
118 | 118 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
119 | 119 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | return apply_filters( 'gravityview/shortcodes/gventry/output', get_the_password_form( $view->ID ), $view, $entry, $atts ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! $view->form ) { |
|
126 | + if ( ! $view->form ) { |
|
127 | 127 | gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) ); |
128 | 128 | |
129 | 129 | /** |
@@ -146,43 +146,43 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | /** Unapproved entries. */ |
149 | - if ( $entry['status'] != 'active' ) { |
|
149 | + if ( $entry[ 'status' ] != 'active' ) { |
|
150 | 150 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
151 | 151 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
152 | 152 | } |
153 | 153 | |
154 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
154 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
155 | 155 | |
156 | 156 | 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 ) ) ) { |
|
157 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
158 | 158 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
159 | 159 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if ( $atts['edit'] ) { |
|
163 | + if ( $atts[ 'edit' ] ) { |
|
164 | 164 | /** |
165 | 165 | * Based on code in our unit-tests. |
166 | 166 | * Mocks old context, etc. |
167 | 167 | */ |
168 | 168 | $loader = \GravityView_Edit_Entry::getInstance(); |
169 | - $render = $loader->instances['render']; |
|
169 | + $render = $loader->instances[ 'render' ]; |
|
170 | 170 | |
171 | 171 | add_filter( 'gravityview/is_single_entry', '__return_true' ); |
172 | 172 | |
173 | - $form = \GFAPI::get_form( $entry['form_id'] ); |
|
173 | + $form = \GFAPI::get_form( $entry[ 'form_id' ] ); |
|
174 | 174 | |
175 | 175 | $data = \GravityView_View_Data::getInstance( $view ); |
176 | 176 | $template = \GravityView_View::getInstance( array( |
177 | 177 | 'form' => $form, |
178 | - 'form_id' => $form['id'], |
|
178 | + 'form_id' => $form[ 'id' ], |
|
179 | 179 | 'view_id' => $view->ID, |
180 | 180 | 'entries' => array( $entry ), |
181 | 181 | 'atts' => \GVCommon::get_template_settings( $view->ID ), |
182 | 182 | ) ); |
183 | 183 | |
184 | - $_GET['edit'] = wp_create_nonce( |
|
185 | - \GravityView_Edit_Entry::get_nonce_key( $view->ID, $form['id'], $entry['id'] ) |
|
184 | + $_GET[ 'edit' ] = wp_create_nonce( |
|
185 | + \GravityView_Edit_Entry::get_nonce_key( $view->ID, $form[ 'id' ], $entry[ 'id' ] ) |
|
186 | 186 | ); |
187 | 187 | |
188 | 188 | add_filter( 'gravityview/edit_entry/success', $callback = function( $message ) use ( $view, $entry, $atts ) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | return apply_filters( 'gravityview/shortcodes/gventry/edit/success', $message, $view, $entry, $atts ); |
200 | 200 | } ); |
201 | 201 | |
202 | - ob_start() && $render->init( $data, \GV\Entry::by_id( $entry['id'] ), $view ); |
|
202 | + ob_start() && $render->init( $data, \GV\Entry::by_id( $entry[ 'id' ] ), $view ); |
|
203 | 203 | $output = ob_get_clean(); // Render :) |
204 | 204 | |
205 | 205 | remove_filter( 'gravityview/is_single_entry', '__return_true' ); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $renderer = new \GV\Entry_Renderer(); |
212 | 212 | |
213 | 213 | $request = new \GV\Mock_Request(); |
214 | - $request->returns['is_entry'] = $entry; |
|
214 | + $request->returns[ 'is_entry' ] = $entry; |
|
215 | 215 | |
216 | 216 | $output = $renderer->render( $entry, $view, $request ); |
217 | 217 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | parent::add_hooks(); |
44 | 44 | |
45 | - add_shortcode( 'gv_pageviews', array( $this, 'pageviews') ); |
|
45 | + add_shortcode( 'gv_pageviews', array( $this, 'pageviews' ) ); |
|
46 | 46 | |
47 | 47 | add_filter( 'gravityview/fields/custom/decode_shortcodes', array( $this, 'inject_entry_id' ), 10, 3 ); |
48 | 48 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * Used as sort of an action via the gravityview/fields/custom/decode_shortcodes filter. |
69 | 69 | */ |
70 | 70 | public function inject_entry_id( $r, $content, $context ) { |
71 | - if ( ! empty( $context->entry['id'] ) ) { |
|
72 | - $this->next_id = $context->entry['id']; |
|
71 | + if ( ! empty( $context->entry[ 'id' ] ) ) { |
|
72 | + $this->next_id = $context->entry[ 'id' ]; |
|
73 | 73 | } else { |
74 | 74 | $this->next_id = false; // Nothing to look at, move along |
75 | 75 | } |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | 'id' => $this->next_id, |
98 | 98 | ), $atts ); |
99 | 99 | |
100 | - if ( ! $this->atts['id'] ) { |
|
100 | + if ( ! $this->atts[ 'id' ] ) { |
|
101 | 101 | return; // The ID was not set |
102 | 102 | } |
103 | 103 | |
104 | 104 | add_filter( 'pageviews_placeholder_preload', array( $this, 'preload_callback' ) ); |
105 | 105 | |
106 | - $output = Pageviews::placeholder( 'GV' . $this->atts['id'] ); // Prefix the ID to avoid collissions with default post IDs |
|
106 | + $output = Pageviews::placeholder( 'GV' . $this->atts[ 'id' ] ); // Prefix the ID to avoid collissions with default post IDs |
|
107 | 107 | |
108 | 108 | remove_filter( 'pageviews_placeholder_preload', array( $this, 'preload_callback' ) ); |
109 | 109 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Set the preload text. |
115 | 115 | */ |
116 | 116 | public function preload_callback( $preload ) { |
117 | - return $this->atts['preload']; |
|
117 | + return $this->atts[ 'preload' ]; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function increment_callback() { |
124 | 124 | if ( $entry = gravityview()->request->is_entry() ) { |
125 | - $increment = 'GV' . $entry['id']; |
|
125 | + $increment = 'GV' . $entry[ 'id' ]; |
|
126 | 126 | ?> |
127 | 127 | _pv_config.incr = <?php echo json_encode( $increment ); ?>; |
128 | 128 | <?php |
@@ -171,7 +171,6 @@ |
||
171 | 171 | * |
172 | 172 | * @since develop |
173 | 173 | * @param array $visibility_caps Array of capabilities to display in field dropdown. |
174 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
175 | 174 | * @param string $template_id Table slug |
176 | 175 | * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
177 | 176 | * @param string $context What context are we in? Example: `single` or `directory` |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | self::getInstance()->set_entry( $entry ); |
236 | 236 | |
237 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
237 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
238 | 238 | |
239 | 239 | if ( empty( $base ) ) { |
240 | 240 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | 'action' => 'duplicate', |
249 | 249 | 'entry_id' => $entry_slug, |
250 | 250 | 'gvid' => $view_id, |
251 | - 'view_id' => $view_id, |
|
251 | + 'view_id' => $view_id, |
|
252 | 252 | ), $base ); |
253 | 253 | |
254 | 254 | $url = wp_nonce_url( $actionurl, 'duplicate_'.$entry_slug, 'duplicate' ); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @since develop |
434 | 434 | * @param array $duplicated_entry The duplicated entry |
435 | 435 | * @param array $entry The original entry |
436 | - */ |
|
436 | + */ |
|
437 | 437 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
438 | 438 | |
439 | 439 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
101 | 101 | |
102 | 102 | // Always a link, never a filter |
103 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
103 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
104 | 104 | |
105 | 105 | |
106 | 106 | // Duplicate Entry link should only appear to visitors capable of editing entries |
107 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
107 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
108 | 108 | |
109 | - $add_option['duplicate_link'] = array( |
|
109 | + $add_option[ 'duplicate_link' ] = array( |
|
110 | 110 | 'type' => 'text', |
111 | 111 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
112 | 112 | 'desc' => NULL, |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | 'merge_tags' => true, |
115 | 115 | ); |
116 | 116 | |
117 | - $field_options['allow_duplicate_cap'] = array( |
|
117 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
118 | 118 | 'type' => 'select', |
119 | 119 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
120 | 120 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
139 | 139 | |
140 | 140 | if ( 'edit' !== $zone ) { |
141 | - $entry_default_fields['duplicate_link'] = array( |
|
141 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
142 | 142 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
143 | 143 | 'type' => 'duplicate_link', |
144 | 144 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | function add_available_field( $available_fields = array() ) { |
157 | 157 | |
158 | - $available_fields['duplicate_link'] = array( |
|
158 | + $available_fields[ 'duplicate_link' ] = array( |
|
159 | 159 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
160 | 160 | 'field_id' => 'duplicate_link', |
161 | 161 | 'label_type' => 'field', |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | if ( $field_id === 'duplicate_link' ) { |
187 | 187 | |
188 | 188 | // Remove other built-in caps. |
189 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
189 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
190 | 190 | |
191 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
191 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return $caps; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param [type] $entry [description] |
202 | 202 | */ |
203 | 203 | function set_entry( $entry = null ) { |
204 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
204 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | self::getInstance()->set_entry( $entry ); |
236 | 236 | |
237 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
237 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
238 | 238 | |
239 | 239 | if ( empty( $base ) ) { |
240 | 240 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | // Use the slug instead of the ID for consistent security |
245 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
245 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
246 | 246 | |
247 | 247 | $actionurl = add_query_arg( array( |
248 | 248 | 'action' => 'duplicate', |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'view_id' => $view_id, |
252 | 252 | ), $base ); |
253 | 253 | |
254 | - $url = wp_nonce_url( $actionurl, 'duplicate_'.$entry_slug, 'duplicate' ); |
|
254 | + $url = wp_nonce_url( $actionurl, 'duplicate_' . $entry_slug, 'duplicate' ); |
|
255 | 255 | |
256 | 256 | return $url; |
257 | 257 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | function process_duplicate() { |
273 | 273 | |
274 | 274 | // If the form is submitted |
275 | - if ( ! isset( $_GET['action'] ) || 'duplicate' !== $_GET['action'] || ! isset( $_GET['entry_id'] ) ) { |
|
275 | + if ( ! isset( $_GET[ 'action' ] ) || 'duplicate' !== $_GET[ 'action' ] || ! isset( $_GET[ 'entry_id' ] ) ) { |
|
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Make sure it's a GravityView request |
280 | - $valid_nonce_key = wp_verify_nonce( $_GET['duplicate'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
280 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'duplicate' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
281 | 281 | |
282 | 282 | if ( ! $valid_nonce_key ) { |
283 | 283 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | // Get the entry slug |
288 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
288 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
289 | 289 | |
290 | 290 | // See if there's an entry there |
291 | 291 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | private function duplicate_entry( $entry ) { |
349 | 349 | |
350 | - $entry_id = $entry['id']; |
|
350 | + $entry_id = $entry[ 'id' ]; |
|
351 | 351 | |
352 | 352 | gravityview()->log->debug( 'Starting duplicate entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
353 | 353 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'No such entry ID', 'gravityview' ) ); |
363 | 363 | } |
364 | 364 | |
365 | - $row['id'] = null; |
|
366 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
367 | - $row['date_updated'] = $row['date_created']; |
|
368 | - $row['is_starred'] = false; |
|
369 | - $row['is_read'] = false; |
|
370 | - $row['ip'] = GFFormsModel::get_ip(); |
|
371 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
372 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
373 | - $row['created_by'] = wp_get_current_user()->ID; |
|
365 | + $row[ 'id' ] = null; |
|
366 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
367 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
368 | + $row[ 'is_starred' ] = false; |
|
369 | + $row[ 'is_read' ] = false; |
|
370 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
371 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
372 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
373 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -397,14 +397,14 @@ discard block |
||
397 | 397 | |
398 | 398 | $save_this_meta = array(); |
399 | 399 | foreach ( $duplicate_meta->get_output() as $m ) { |
400 | - $save_this_meta[] = array( |
|
401 | - 'meta_key' => $m['meta_key'], |
|
402 | - 'meta_value' => $m['meta_value'], |
|
403 | - 'item_index' => $m['item_index'], |
|
400 | + $save_this_meta[ ] = array( |
|
401 | + 'meta_key' => $m[ 'meta_key' ], |
|
402 | + 'meta_value' => $m[ 'meta_value' ], |
|
403 | + 'item_index' => $m[ 'item_index' ], |
|
404 | 404 | ); |
405 | 405 | } |
406 | 406 | |
407 | - $row['ID'] = $duplicated_id; |
|
407 | + $row[ 'ID' ] = $duplicated_id; |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
416 | 416 | |
417 | 417 | foreach ( $save_this_meta as $data ) { |
418 | - $data['form_id'] = $entry['form_id']; |
|
419 | - $data['entry_id'] = $duplicated_id; |
|
418 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
419 | + $data[ 'entry_id' ] = $duplicated_id; |
|
420 | 420 | |
421 | 421 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
422 | 422 | return new WP_Error( 'gravityview-duplicate-entry-db', __( 'Database error', 'gravityview' ) ); |
@@ -449,13 +449,13 @@ discard block |
||
449 | 449 | public function verify_nonce() { |
450 | 450 | |
451 | 451 | // No duplicate entry request was made |
452 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
452 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | |
456 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
456 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
457 | 457 | |
458 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
458 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | */ |
486 | 486 | $confirm = apply_filters( 'gravityview/duplicate-entry/confirm-text', $confirm ); |
487 | 487 | |
488 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
488 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | |
541 | 541 | $current_user = wp_get_current_user(); |
542 | 542 | |
543 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
543 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
544 | 544 | |
545 | 545 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
546 | 546 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries' ), $entry_id ) ) { |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | if ( ! empty( $field ) ) { |
556 | 556 | |
557 | 557 | // If capability is not defined, something is not right! |
558 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
558 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
559 | 559 | |
560 | 560 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
561 | 561 | |
562 | 562 | return false; |
563 | 563 | } |
564 | 564 | |
565 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
565 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
566 | 566 | |
567 | 567 | // Do not return true if cap is read, as we need to check if the current user created the entry |
568 | - if ( $field['allow_duplicate_cap'] !== 'read' ) { |
|
568 | + if ( $field[ 'allow_duplicate_cap' ] !== 'read' ) { |
|
569 | 569 | return true; |
570 | 570 | } |
571 | 571 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | } |
580 | 580 | |
581 | - if ( ! isset( $entry['created_by'] ) ) { |
|
581 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
582 | 582 | |
583 | 583 | gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
584 | 584 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $current_view = gravityview_get_current_view_data( $view_id ); |
592 | 592 | |
593 | - $user_duplicate = isset( $current_view['atts']['user_duplicate'] ) ? $current_view['atts']['user_duplicate'] : false; |
|
593 | + $user_duplicate = isset( $current_view[ 'atts' ][ 'user_duplicate' ] ) ? $current_view[ 'atts' ][ 'user_duplicate' ] : false; |
|
594 | 594 | |
595 | 595 | if ( empty( $user_duplicate ) ) { |
596 | 596 | |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | // If the logged-in user is the same as the user who created the entry, we're good. |
604 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
604 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
605 | 605 | |
606 | 606 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
607 | 607 | |
@@ -625,16 +625,16 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function display_message( $current_view_id = 0 ) { |
627 | 627 | |
628 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
628 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Entry wasn't duplicateded from current View |
633 | - if ( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
633 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - $status = esc_attr( $_GET['status'] ); |
|
637 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
638 | 638 | $message_from_url = \GV\Utils::_GET( 'message' ); |
639 | 639 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
640 | 640 | $class = ''; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
664 | 664 | |
665 | 665 | // DISPLAY ERROR/SUCCESS MESSAGE |
666 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
666 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 |