@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
32 | - $class .= ' merge-tag-support mt-position-right '; |
|
31 | + if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
32 | + $class .= ' merge-tag-support mt-position-right '; |
|
33 | 33 | |
34 | - if( empty( $this->field['show_all_fields'] ) ) { |
|
35 | - $class .= ' mt-hide_all_fields '; |
|
36 | - } |
|
37 | - } |
|
34 | + if( empty( $this->field['show_all_fields'] ) ) { |
|
35 | + $class .= ' mt-hide_all_fields '; |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | 39 | $class .= rgar( $this->field, 'class' ); |
40 | 40 | $placeholder = rgar( $this->field, 'placeholder' ); |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | |
56 | 56 | function codemirror( $field_id = '' ) { |
57 | 57 | |
58 | - // Enqueue code editor and settings for manipulating HTML. |
|
59 | - $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
|
58 | + // Enqueue code editor and settings for manipulating HTML. |
|
59 | + $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); |
|
60 | 60 | |
61 | - // Bail if user disabled CodeMirror. |
|
62 | - if ( false === $settings ) { |
|
63 | - return; |
|
64 | - } |
|
61 | + // Bail if user disabled CodeMirror. |
|
62 | + if ( false === $settings ) { |
|
63 | + return; |
|
64 | + } |
|
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | |
68 | 68 | <script> |
69 | 69 | wp.codeEditor.initialize( "<?php echo $field_id;?>", {}); |
70 | 70 | </script> |
71 | 71 | <?php |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | 74 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | ?> |
10 | 10 | <label for="<?php echo $this->get_field_id(); ?>" class="<?php echo $this->get_label_class(); ?>"><?php |
11 | 11 | |
12 | - echo '<span class="gv-label">'.$this->get_field_label().'</span>'; |
|
12 | + echo '<span class="gv-label">' . $this->get_field_label() . '</span>'; |
|
13 | 13 | echo $this->get_tooltip() . $this->get_field_desc(); |
14 | 14 | ?><div> |
15 | 15 | <?php $this->render_input(); ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | |
29 | 29 | $show_mt = $this->show_merge_tags(); |
30 | 30 | |
31 | - if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) { |
|
31 | + if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) { |
|
32 | 32 | $class .= ' merge-tag-support mt-position-right '; |
33 | 33 | |
34 | - if( empty( $this->field['show_all_fields'] ) ) { |
|
34 | + if ( empty( $this->field[ 'show_all_fields' ] ) ) { |
|
35 | 35 | $class .= ' mt-hide_all_fields '; |
36 | 36 | } |
37 | 37 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | # $this->codemirror( $this->get_field_id() ); |
50 | 50 | |
51 | 51 | ?> |
52 | - <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="<?php echo absint( $rows ); ?>"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
52 | + <textarea name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" class="<?php echo gravityview_sanitize_html_class( $class ); ?>" rows="<?php echo absint( $rows ); ?>"><?php echo esc_textarea( $this->value ); ?></textarea> |
|
53 | 53 | <?php |
54 | 54 | } |
55 | 55 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ?> |
67 | 67 | |
68 | 68 | <script> |
69 | - wp.codeEditor.initialize( "<?php echo $field_id;?>", {}); |
|
69 | + wp.codeEditor.initialize( "<?php echo $field_id; ?>", {}); |
|
70 | 70 | </script> |
71 | 71 | <?php |
72 | 72 | } |
@@ -32,25 +32,25 @@ |
||
32 | 32 | |
33 | 33 | public function __construct() { |
34 | 34 | $this->label = esc_html__( 'Link to Single Entry', 'gravityview' ); |
35 | - $this->description = esc_html__('A dedicated link to the single entry with customizable text.', 'gravityview'); |
|
35 | + $this->description = esc_html__( 'A dedicated link to the single entry with customizable text.', 'gravityview' ); |
|
36 | 36 | parent::__construct(); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
40 | 40 | |
41 | 41 | // Always a link! |
42 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
42 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
43 | 43 | |
44 | - if( 'edit' === $context ) { |
|
44 | + if ( 'edit' === $context ) { |
|
45 | 45 | return $field_options; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $add_options = array(); |
49 | - $add_options['entry_link_text'] = array( |
|
49 | + $add_options[ 'entry_link_text' ] = array( |
|
50 | 50 | 'type' => 'text', |
51 | 51 | 'label' => __( 'Link Text:', 'gravityview' ), |
52 | 52 | 'desc' => NULL, |
53 | - 'value' => __('View Details', 'gravityview'), |
|
53 | + 'value' => __( 'View Details', 'gravityview' ), |
|
54 | 54 | 'merge_tags' => true, |
55 | 55 | ); |
56 | 56 |
@@ -354,7 +354,7 @@ |
||
354 | 354 | * |
355 | 355 | * @param array $assets |
356 | 356 | * |
357 | - * @return array |
|
357 | + * @return string[] |
|
358 | 358 | */ |
359 | 359 | function register_gform_noconflict( $assets ) { |
360 | 360 | $assets[] = 'gravityview_selectwoo'; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | array( |
82 | 82 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
83 | 83 | 'action' => 'entry_creator_get_users', |
84 | - 'gf25' => (bool) gravityview()->plugin->is_GF_25(), |
|
84 | + 'gf25' => (bool)gravityview()->plugin->is_GF_25(), |
|
85 | 85 | 'language' => array( |
86 | 86 | 'search_placeholder' => esc_html__( 'Search by ID, login, email, or name.', 'gravityview' ), |
87 | 87 | ), |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | |
108 | - if ( ! wp_verify_nonce( $post_var['gv_nonce'], 'gv_entry_creator' ) ) { |
|
108 | + if ( ! wp_verify_nonce( $post_var[ 'gv_nonce' ], 'gv_entry_creator' ) ) { |
|
109 | 109 | die(); |
110 | 110 | } |
111 | 111 | |
112 | - $search_string = $post_var['q']; |
|
112 | + $search_string = $post_var[ 'q' ]; |
|
113 | 113 | |
114 | 114 | if ( is_numeric( $search_string ) ) { |
115 | 115 | $user_args = array( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
159 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
159 | + $result = RGFormsModel::update_entry_property( (int)$entry[ 'id' ], 'created_by', (int)$user_id, false, true ); |
|
160 | 160 | |
161 | 161 | if ( false === $result ) { |
162 | 162 | $status = __( 'Error', 'gravityview' ); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - GravityView_Entry_Notes::add_note( $entry['id'], - 1, 'GravityView', $note, 'gravityview' ); |
|
181 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], - 1, 'GravityView', $note, 'gravityview' ); |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // If screen mode isn't set, then we're in the wrong place. |
216 | - if ( empty( $_REQUEST['screen_mode'] ) ) { |
|
216 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
241 | 241 | if ( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
242 | - $_POST["screen_mode"] = 'edit'; |
|
242 | + $_POST[ "screen_mode" ] = 'edit'; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $entry_creator_user_id = \GV\Utils::get( $entry, 'created_by' ); |
315 | 315 | |
316 | 316 | $entry_creator_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $entry_creator_user_id ) ); |
317 | - $entry_creator_user = isset( $entry_creator_user[0] ) ? $entry_creator_user[0] : array(); |
|
317 | + $entry_creator_user = isset( $entry_creator_user[ 0 ] ) ? $entry_creator_user[ 0 ] : array(); |
|
318 | 318 | |
319 | 319 | if ( empty( $entry_creator_user ) ) { |
320 | 320 | $output .= '<option value="0"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
@@ -332,18 +332,18 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | $user_count = count_users(); |
335 | - $user_count = $user_count['total_users']; |
|
335 | + $user_count = $user_count[ 'total_users' ]; |
|
336 | 336 | $users_displayed = self::DEFAULT_NUMBER_OF_USERS + ( ! empty( $entry_creator_user ) ? 1 : 0 ); |
337 | 337 | if ( $user_count > $users_displayed ) { |
338 | 338 | $remaining_users = $user_count - $users_displayed; |
339 | - $user_users = _n( esc_html__('user', 'gravityview' ), esc_html__('users', 'gravityview' ), $remaining_users ); |
|
339 | + $user_users = _n( esc_html__( 'user', 'gravityview' ), esc_html__( 'users', 'gravityview' ), $remaining_users ); |
|
340 | 340 | $message = esc_html_x( 'Use the input above to search the remaining %d %s.', '%d is replaced with user count %s is replaced with "user" or "users"', 'gravityview' ); |
341 | 341 | $message = sprintf( $message, $remaining_users, $user_users ); |
342 | - $output .= '<option value="_user_count" disabled="disabled">' . esc_html( $message ) . '</option>'; |
|
342 | + $output .= '<option value="_user_count" disabled="disabled">' . esc_html( $message ) . '</option>'; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $output .= '</select>'; |
346 | - $output .= '<input name="originally_created_by" value="' . esc_attr( $entry['created_by'] ) . '" type="hidden" />'; |
|
346 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
347 | 347 | $output .= wp_nonce_field( 'gv_entry_creator', 'gv_entry_creator_nonce', false, false ); |
348 | 348 | |
349 | 349 | echo $output; |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | * @return array |
358 | 358 | */ |
359 | 359 | function register_gform_noconflict( $assets ) { |
360 | - $assets[] = 'gravityview_selectwoo'; |
|
361 | - $assets[] = 'gravityview_entry_creator'; |
|
360 | + $assets[ ] = 'gravityview_selectwoo'; |
|
361 | + $assets[ ] = 'gravityview_entry_creator'; |
|
362 | 362 | |
363 | 363 | return $assets; |
364 | 364 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @deprecated |
115 | 115 | * @see The `gravityview/view_collection/from_post/meta_keys` filter. |
116 | 116 | */ |
117 | - $meta_keys = (array) apply_filters_deprecated( 'gravityview/data/parse/meta_keys', array( $meta_keys, $post->ID ), '2.0.7', 'gravityview/view_collection/from_post/meta_keys' ); |
|
117 | + $meta_keys = (array)apply_filters_deprecated( 'gravityview/data/parse/meta_keys', array( $meta_keys, $post->ID ), '2.0.7', 'gravityview/view_collection/from_post/meta_keys' ); |
|
118 | 118 | |
119 | 119 | /** What about inside post meta values? */ |
120 | 120 | foreach ( $meta_keys as $meta_key ) { |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | |
169 | 169 | /** Let's find us some [gravityview] shortcodes perhaps. */ |
170 | 170 | foreach ( Shortcode::parse( $content ) as $shortcode ) { |
171 | - if ( $shortcode->name != 'gravityview' || empty( $shortcode->atts['id'] ) ) { |
|
171 | + if ( $shortcode->name != 'gravityview' || empty( $shortcode->atts[ 'id' ] ) ) { |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | |
175 | - if ( is_numeric( $shortcode->atts['id'] ) ) { |
|
176 | - $view = View::by_id( $shortcode->atts['id'] ); |
|
175 | + if ( is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
176 | + $view = View::by_id( $shortcode->atts[ 'id' ] ); |
|
177 | 177 | if ( ! $view ) { |
178 | 178 | continue; |
179 | 179 | } |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | public function dismiss_notice() { |
61 | 61 | |
62 | 62 | // No dismiss sent |
63 | - if( empty( $_GET['gv-dismiss'] ) || empty( $_GET['notice'] ) ) { |
|
63 | + if ( empty( $_GET[ 'gv-dismiss' ] ) || empty( $_GET[ 'notice' ] ) ) { |
|
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Invalid nonce |
68 | - if( !wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
|
68 | + if ( ! wp_verify_nonce( $_GET[ 'gv-dismiss' ], 'dismiss' ) ) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | - $notice_id = esc_attr( $_GET['notice'] ); |
|
72 | + $notice_id = esc_attr( $_GET[ 'notice' ] ); |
|
73 | 73 | |
74 | 74 | //don't display a message if use has dismissed the message for this version |
75 | 75 | $dismissed_notices = (array)get_transient( 'gravityview_dismissed_notices' ); |
76 | 76 | |
77 | - $dismissed_notices[] = $notice_id; |
|
77 | + $dismissed_notices[ ] = $notice_id; |
|
78 | 78 | |
79 | 79 | $dismissed_notices = array_unique( $dismissed_notices ); |
80 | 80 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | private function is_notice_dismissed( $notice ) { |
98 | 98 | |
99 | 99 | // There are no dismissed notices. |
100 | - if( empty( self::$dismissed_notices ) ) { |
|
100 | + if ( empty( self::$dismissed_notices ) ) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Has the |
105 | - $is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices ); |
|
105 | + $is_dismissed = ! empty( $notice[ 'dismiss' ] ) && in_array( $notice[ 'dismiss' ], self::$dismissed_notices ); |
|
106 | 106 | |
107 | 107 | return $is_dismissed ? true : false; |
108 | 108 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | private function check_show_multisite_notices() { |
129 | 129 | |
130 | - if( ! is_multisite() ) { |
|
130 | + if ( ! is_multisite() ) { |
|
131 | 131 | return true; |
132 | 132 | } |
133 | 133 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | // or they don't have admin capabilities |
140 | - if( ! is_super_admin() ) { |
|
140 | + if ( ! is_super_admin() ) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
@@ -160,48 +160,48 @@ discard block |
||
160 | 160 | */ |
161 | 161 | $notices = apply_filters( 'gravityview/admin/notices', self::$admin_notices ); |
162 | 162 | |
163 | - if( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
163 | + if ( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | 167 | //don't display a message if use has dismissed the message for this version |
168 | 168 | // TODO: Use get_user_meta instead of get_transient |
169 | - self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
169 | + self::$dismissed_notices = isset( $_GET[ 'show-dismissed-notices' ] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
170 | 170 | |
171 | 171 | $output = ''; |
172 | 172 | |
173 | - foreach( $notices as $notice ) { |
|
173 | + foreach ( $notices as $notice ) { |
|
174 | 174 | |
175 | 175 | // If the user doesn't have the capability to see the warning |
176 | - if( isset( $notice['cap'] ) && false === GVCommon::has_cap( $notice['cap'] ) ) { |
|
176 | + if ( isset( $notice[ 'cap' ] ) && false === GVCommon::has_cap( $notice[ 'cap' ] ) ) { |
|
177 | 177 | gravityview()->log->debug( 'Notice not shown because user does not have the capability to view it.', array( 'data' => $notice ) ); |
178 | 178 | continue; |
179 | 179 | } |
180 | 180 | |
181 | - if( true === $this->is_notice_dismissed( $notice ) ) { |
|
181 | + if ( true === $this->is_notice_dismissed( $notice ) ) { |
|
182 | 182 | gravityview()->log->debug( 'Notice not shown because the notice has already been dismissed.', array( 'data' => $notice ) ); |
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | |
186 | - $output .= '<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice['class'] ).'">'; |
|
186 | + $output .= '<div id="message" style="position:relative" class="notice ' . gravityview_sanitize_html_class( $notice[ 'class' ] ) . '">'; |
|
187 | 187 | |
188 | 188 | // Too cute to leave out. |
189 | 189 | $output .= gravityview_get_floaty(); |
190 | 190 | |
191 | - if( !empty( $notice['title'] ) ) { |
|
192 | - $output .= '<h3>'.esc_html( $notice['title'] ) .'</h3>'; |
|
191 | + if ( ! empty( $notice[ 'title' ] ) ) { |
|
192 | + $output .= '<h3>' . esc_html( $notice[ 'title' ] ) . '</h3>'; |
|
193 | 193 | } |
194 | 194 | |
195 | - $message = isset( $notice['message'] ) ? $notice['message'] : ''; |
|
195 | + $message = isset( $notice[ 'message' ] ) ? $notice[ 'message' ] : ''; |
|
196 | 196 | |
197 | - if( !empty( $notice['dismiss'] ) ) { |
|
197 | + if ( ! empty( $notice[ 'dismiss' ] ) ) { |
|
198 | 198 | |
199 | - $dismiss = esc_attr($notice['dismiss']); |
|
199 | + $dismiss = esc_attr( $notice[ 'dismiss' ] ); |
|
200 | 200 | |
201 | 201 | $url = esc_url( add_query_arg( array( 'gv-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) ); |
202 | 202 | |
203 | 203 | $align = is_rtl() ? 'alignleft' : 'alignright'; |
204 | - $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="' . $align . ' button button-link">'.esc_html__('Dismiss', 'gravityview' ).'</a></p>'; |
|
204 | + $message .= '<a href="' . $url . '" data-notice="' . $dismiss . '" class="' . $align . ' button button-link">' . esc_html__( 'Dismiss', 'gravityview' ) . '</a></p>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $output .= wpautop( $message ); |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public static function add_notice( $notice = array() ) { |
235 | 235 | |
236 | - if( !isset( $notice['message'] ) ) { |
|
236 | + if ( ! isset( $notice[ 'message' ] ) ) { |
|
237 | 237 | gravityview()->log->error( 'Notice not set', array( 'data' => $notice ) ); |
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
241 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
242 | 242 | |
243 | - self::$admin_notices[] = $notice; |
|
243 | + self::$admin_notices[ ] = $notice; |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 |
@@ -64,6 +64,9 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | + /** |
|
68 | + * @param string $component |
|
69 | + */ |
|
67 | 70 | private function load_components( $component ) { |
68 | 71 | |
69 | 72 | $dir = trailingslashit( self::$file ); |
@@ -104,7 +107,7 @@ discard block |
||
104 | 107 | * |
105 | 108 | * @param array $args Existing reserved args |
106 | 109 | * |
107 | - * @return array |
|
110 | + * @return string[] |
|
108 | 111 | */ |
109 | 112 | public function add_reserved_arg( $args ) { |
110 | 113 | |
@@ -200,7 +203,7 @@ discard block |
||
200 | 203 | * "You can edit this post from the post page" fields, for example. |
201 | 204 | * |
202 | 205 | * @param $entry array Gravity Forms entry object |
203 | - * @param $view_id int GravityView view id |
|
206 | + * @param integer $view_id int GravityView view id |
|
204 | 207 | * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
205 | 208 | * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
206 | 209 | * @return string |
@@ -303,7 +306,7 @@ discard block |
||
303 | 306 | * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
304 | 307 | * |
305 | 308 | * @param array $entry Gravity Forms entry array |
306 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
309 | + * @param integer $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
307 | 310 | * @return bool |
308 | 311 | */ |
309 | 312 | public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
@@ -18,84 +18,84 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | $this->load_components( 'locking' ); |
44 | 44 | |
45 | - $this->load_components( 'render' ); |
|
45 | + $this->load_components( 'render' ); |
|
46 | 46 | |
47 | - // If GF User Registration Add-on exists |
|
48 | - $this->load_components( 'user-registration' ); |
|
47 | + // If GF User Registration Add-on exists |
|
48 | + $this->load_components( 'user-registration' ); |
|
49 | 49 | |
50 | - $this->add_hooks(); |
|
50 | + $this->add_hooks(); |
|
51 | 51 | |
52 | 52 | // Process hooks for addons that may or may not be present |
53 | 53 | $this->addon_specific_hooks(); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | - static function getInstance() { |
|
57 | + static function getInstance() { |
|
58 | 58 | |
59 | - if( empty( self::$instance ) ) { |
|
60 | - self::$instance = new GravityView_Edit_Entry; |
|
61 | - } |
|
59 | + if( empty( self::$instance ) ) { |
|
60 | + self::$instance = new GravityView_Edit_Entry; |
|
61 | + } |
|
62 | 62 | |
63 | - return self::$instance; |
|
64 | - } |
|
63 | + return self::$instance; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - private function load_components( $component ) { |
|
67 | + private function load_components( $component ) { |
|
68 | 68 | |
69 | - $dir = trailingslashit( self::$file ); |
|
69 | + $dir = trailingslashit( self::$file ); |
|
70 | 70 | |
71 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
72 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
71 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
72 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
73 | 73 | |
74 | - // Loads component and pass extension's instance so that component can |
|
75 | - // talk each other. |
|
76 | - require_once $filename; |
|
77 | - $this->instances[ $component ] = new $classname( $this ); |
|
78 | - $this->instances[ $component ]->load(); |
|
74 | + // Loads component and pass extension's instance so that component can |
|
75 | + // talk each other. |
|
76 | + require_once $filename; |
|
77 | + $this->instances[ $component ] = new $classname( $this ); |
|
78 | + $this->instances[ $component ]->load(); |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - private function add_hooks() { |
|
82 | + private function add_hooks() { |
|
83 | 83 | |
84 | - // Add front-end access to Gravity Forms delete file action |
|
85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
84 | + // Add front-end access to Gravity Forms delete file action |
|
85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
86 | 86 | |
87 | - // Make sure this hook is run for non-admins |
|
88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
87 | + // Make sure this hook is run for non-admins |
|
88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
89 | 89 | |
90 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
90 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
91 | 91 | |
92 | - // add template path to check for field |
|
93 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
92 | + // add template path to check for field |
|
93 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
94 | 94 | |
95 | 95 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
96 | 96 | |
97 | 97 | add_filter( 'gravityview/api/reserved_query_args', array( $this, 'add_reserved_arg' ) ); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Adds "edit" to the list of internal reserved query args |
@@ -166,74 +166,74 @@ discard block |
||
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - /** |
|
170 | - * Include this extension templates path |
|
171 | - * @param array $file_paths List of template paths ordered |
|
172 | - */ |
|
173 | - public function add_template_path( $file_paths ) { |
|
174 | - |
|
175 | - // Index 100 is the default GravityView template path. |
|
176 | - $file_paths[ 110 ] = self::$file; |
|
177 | - |
|
178 | - return $file_paths; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * |
|
183 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
184 | - * |
|
185 | - * @param $view_id int GravityView view id |
|
186 | - * @param $form_id int Gravity Forms form id |
|
187 | - * @param $entry_id int Gravity Forms entry id |
|
188 | - * @return string |
|
189 | - */ |
|
190 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
191 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * The edit entry link creates a secure link with a nonce |
|
197 | - * |
|
198 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
199 | - * it formats the display of the edit form like it does in the backend, like |
|
200 | - * "You can edit this post from the post page" fields, for example. |
|
201 | - * |
|
202 | - * @param $entry array Gravity Forms entry object |
|
203 | - * @param $view_id int GravityView view id |
|
204 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
205 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
206 | - * @return string |
|
207 | - */ |
|
208 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
209 | - |
|
210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
211 | - |
|
212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
213 | - |
|
214 | - $url = add_query_arg( array( |
|
215 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
216 | - ), $base ); |
|
217 | - |
|
218 | - if( $post_id ) { |
|
219 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Allow passing params to dynamically populate entry with values |
|
224 | - * @since 1.9.2 |
|
225 | - */ |
|
226 | - if( !empty( $field_values ) ) { |
|
227 | - |
|
228 | - if( is_array( $field_values ) ) { |
|
229 | - // If already an array, no parse_str() needed |
|
230 | - $params = $field_values; |
|
231 | - } else { |
|
232 | - parse_str( $field_values, $params ); |
|
233 | - } |
|
234 | - |
|
235 | - $url = add_query_arg( $params, $url ); |
|
236 | - } |
|
169 | + /** |
|
170 | + * Include this extension templates path |
|
171 | + * @param array $file_paths List of template paths ordered |
|
172 | + */ |
|
173 | + public function add_template_path( $file_paths ) { |
|
174 | + |
|
175 | + // Index 100 is the default GravityView template path. |
|
176 | + $file_paths[ 110 ] = self::$file; |
|
177 | + |
|
178 | + return $file_paths; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * |
|
183 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
184 | + * |
|
185 | + * @param $view_id int GravityView view id |
|
186 | + * @param $form_id int Gravity Forms form id |
|
187 | + * @param $entry_id int Gravity Forms entry id |
|
188 | + * @return string |
|
189 | + */ |
|
190 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
191 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * The edit entry link creates a secure link with a nonce |
|
197 | + * |
|
198 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
199 | + * it formats the display of the edit form like it does in the backend, like |
|
200 | + * "You can edit this post from the post page" fields, for example. |
|
201 | + * |
|
202 | + * @param $entry array Gravity Forms entry object |
|
203 | + * @param $view_id int GravityView view id |
|
204 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
205 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
206 | + * @return string |
|
207 | + */ |
|
208 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
209 | + |
|
210 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
211 | + |
|
212 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
213 | + |
|
214 | + $url = add_query_arg( array( |
|
215 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
216 | + ), $base ); |
|
217 | + |
|
218 | + if( $post_id ) { |
|
219 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Allow passing params to dynamically populate entry with values |
|
224 | + * @since 1.9.2 |
|
225 | + */ |
|
226 | + if( !empty( $field_values ) ) { |
|
227 | + |
|
228 | + if( is_array( $field_values ) ) { |
|
229 | + // If already an array, no parse_str() needed |
|
230 | + $params = $field_values; |
|
231 | + } else { |
|
232 | + parse_str( $field_values, $params ); |
|
233 | + } |
|
234 | + |
|
235 | + $url = add_query_arg( $params, $url ); |
|
236 | + } |
|
237 | 237 | |
238 | 238 | /** |
239 | 239 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param \GV\View $view The View. |
243 | 243 | */ |
244 | 244 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
245 | - } |
|
245 | + } |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Edit mode doesn't allow certain field types. |
@@ -297,19 +297,19 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | |
300 | - /** |
|
301 | - * checks if user has permissions to edit a specific entry |
|
302 | - * |
|
303 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
304 | - * |
|
305 | - * @param array $entry Gravity Forms entry array |
|
306 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
307 | - * @return bool |
|
308 | - */ |
|
309 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
300 | + /** |
|
301 | + * checks if user has permissions to edit a specific entry |
|
302 | + * |
|
303 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
304 | + * |
|
305 | + * @param array $entry Gravity Forms entry array |
|
306 | + * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
307 | + * @return bool |
|
308 | + */ |
|
309 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
310 | 310 | |
311 | - // No permission by default |
|
312 | - $user_can_edit = false; |
|
311 | + // No permission by default |
|
312 | + $user_can_edit = false; |
|
313 | 313 | |
314 | 314 | // get user_edit setting |
315 | 315 | if ( empty( $view ) ) { |
@@ -327,60 +327,60 @@ discard block |
||
327 | 327 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
328 | 328 | } |
329 | 329 | |
330 | - // If they can edit any entries (as defined in Gravity Forms) |
|
331 | - // Or if they can edit other people's entries |
|
332 | - // Then we're good. |
|
333 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
330 | + // If they can edit any entries (as defined in Gravity Forms) |
|
331 | + // Or if they can edit other people's entries |
|
332 | + // Then we're good. |
|
333 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
334 | 334 | |
335 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
335 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
336 | 336 | |
337 | - $user_can_edit = true; |
|
337 | + $user_can_edit = true; |
|
338 | 338 | |
339 | - } else if( !isset( $entry['created_by'] ) ) { |
|
339 | + } else if( !isset( $entry['created_by'] ) ) { |
|
340 | 340 | |
341 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
341 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
342 | 342 | |
343 | - $user_can_edit = false; |
|
343 | + $user_can_edit = false; |
|
344 | 344 | |
345 | - } else { |
|
345 | + } else { |
|
346 | 346 | |
347 | - $current_user = wp_get_current_user(); |
|
347 | + $current_user = wp_get_current_user(); |
|
348 | 348 | |
349 | - // User edit is disabled |
|
350 | - if( empty( $user_edit ) ) { |
|
349 | + // User edit is disabled |
|
350 | + if( empty( $user_edit ) ) { |
|
351 | 351 | |
352 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
352 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
353 | 353 | |
354 | - $user_can_edit = false; |
|
355 | - } |
|
354 | + $user_can_edit = false; |
|
355 | + } |
|
356 | 356 | |
357 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
358 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
357 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
358 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
359 | 359 | |
360 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
360 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
361 | 361 | |
362 | - $user_can_edit = true; |
|
362 | + $user_can_edit = true; |
|
363 | 363 | |
364 | - } else if( ! is_user_logged_in() ) { |
|
364 | + } else if( ! is_user_logged_in() ) { |
|
365 | 365 | |
366 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
366 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
367 | 367 | |
368 | - $user_can_edit = false; // Here just for clarity |
|
369 | - } |
|
368 | + $user_can_edit = false; // Here just for clarity |
|
369 | + } |
|
370 | 370 | |
371 | - } |
|
371 | + } |
|
372 | 372 | |
373 | - /** |
|
374 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
375 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
376 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
377 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
378 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
379 | - */ |
|
380 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
373 | + /** |
|
374 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
375 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
376 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
377 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
378 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
379 | + */ |
|
380 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
381 | 381 | |
382 | - return (bool) $user_can_edit; |
|
383 | - } |
|
382 | + return (bool) $user_can_edit; |
|
383 | + } |
|
384 | 384 | |
385 | 385 | |
386 | 386 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
38 | 38 | |
39 | - if( is_admin() ) { |
|
39 | + if ( is_admin() ) { |
|
40 | 40 | $this->load_components( 'admin' ); |
41 | 41 | } |
42 | 42 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | static function getInstance() { |
58 | 58 | |
59 | - if( empty( self::$instance ) ) { |
|
59 | + if ( empty( self::$instance ) ) { |
|
60 | 60 | self::$instance = new GravityView_Edit_Entry; |
61 | 61 | } |
62 | 62 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | private function add_hooks() { |
83 | 83 | |
84 | 84 | // Add front-end access to Gravity Forms delete file action |
85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
86 | 86 | |
87 | 87 | // Make sure this hook is run for non-admins |
88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
89 | 89 | |
90 | 90 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function add_reserved_arg( $args ) { |
110 | 110 | |
111 | - $args[] = 'edit'; |
|
111 | + $args[ ] = 'edit'; |
|
112 | 112 | |
113 | 113 | return $args; |
114 | 114 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | private function addon_specific_hooks() { |
121 | 121 | |
122 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
123 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
122 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
123 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | } |
@@ -207,15 +207,15 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
209 | 209 | |
210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
210 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
211 | 211 | |
212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
212 | + $base = gv_entry_link( $entry, $post_id ?: $view_id ); |
|
213 | 213 | |
214 | 214 | $url = add_query_arg( array( |
215 | 215 | 'edit' => wp_create_nonce( $nonce_key ) |
216 | 216 | ), $base ); |
217 | 217 | |
218 | - if( $post_id ) { |
|
218 | + if ( $post_id ) { |
|
219 | 219 | $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
220 | 220 | } |
221 | 221 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * Allow passing params to dynamically populate entry with values |
224 | 224 | * @since 1.9.2 |
225 | 225 | */ |
226 | - if( !empty( $field_values ) ) { |
|
226 | + if ( ! empty( $field_values ) ) { |
|
227 | 227 | |
228 | - if( is_array( $field_values ) ) { |
|
228 | + if ( is_array( $field_values ) ) { |
|
229 | 229 | // If already an array, no parse_str() needed |
230 | 230 | $params = $field_values; |
231 | 231 | } else { |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param array $entry The entry. |
242 | 242 | * @param \GV\View $view The View. |
243 | 243 | */ |
244 | - return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
|
244 | + return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
254 | 254 | |
255 | - if( empty( $context ) || $context !== 'edit' ) { |
|
255 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
256 | 256 | return $fields; |
257 | 257 | } |
258 | 258 | |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | // If they can edit any entries (as defined in Gravity Forms) |
331 | 331 | // Or if they can edit other people's entries |
332 | 332 | // Then we're good. |
333 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
333 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
334 | 334 | |
335 | 335 | gravityview()->log->debug( 'User has ability to edit all entries.' ); |
336 | 336 | |
337 | 337 | $user_can_edit = true; |
338 | 338 | |
339 | - } else if( !isset( $entry['created_by'] ) ) { |
|
339 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
340 | 340 | |
341 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
341 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
342 | 342 | |
343 | 343 | $user_can_edit = false; |
344 | 344 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $current_user = wp_get_current_user(); |
348 | 348 | |
349 | 349 | // User edit is disabled |
350 | - if( empty( $user_edit ) ) { |
|
350 | + if ( empty( $user_edit ) ) { |
|
351 | 351 | |
352 | 352 | gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
353 | 353 | |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
358 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
358 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
359 | 359 | |
360 | 360 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
361 | 361 | |
362 | 362 | $user_can_edit = true; |
363 | 363 | |
364 | - } else if( ! is_user_logged_in() ) { |
|
364 | + } else if ( ! is_user_logged_in() ) { |
|
365 | 365 | |
366 | 366 | gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
381 | 381 | |
382 | - return (bool) $user_can_edit; |
|
382 | + return (bool)$user_can_edit; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $this->label = esc_html__( 'Number Sequence', 'gravityview' ); |
42 | 42 | $this->description = esc_html__( 'Display a sequential result number for each entry.', 'gravityview' ); |
43 | 43 | |
44 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips') ); |
|
44 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips' ) ); |
|
45 | 45 | |
46 | 46 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
47 | 47 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return $entry_default_fields; |
66 | 66 | } |
67 | 67 | |
68 | - $entry_default_fields['sequence'] = array( |
|
68 | + $entry_default_fields[ 'sequence' ] = array( |
|
69 | 69 | 'label' => __( 'Result Number', 'gravityview' ), |
70 | 70 | 'type' => $this->name, |
71 | 71 | 'desc' => $this->description, |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | |
85 | 85 | $return = $tooltips; |
86 | 86 | |
87 | - $return['reverse_sequence'] = array( |
|
88 | - 'title' => __('Reverse the order of the result numbers', 'gravityview'), |
|
89 | - 'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'), |
|
87 | + $return[ 'reverse_sequence' ] = array( |
|
88 | + 'title' => __( 'Reverse the order of the result numbers', 'gravityview' ), |
|
89 | + 'value' => __( 'Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview' ), |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | return $return; |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | |
95 | 95 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
96 | 96 | |
97 | - unset ( $field_options['search_filter'] ); |
|
97 | + unset ( $field_options[ 'search_filter' ] ); |
|
98 | 98 | |
99 | 99 | $new_fields = array( |
100 | 100 | 'start' => array( |
101 | 101 | 'type' => 'number', |
102 | 102 | 'label' => __( 'First Number in the Sequence', 'gravityview' ), |
103 | - 'desc' => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'), |
|
103 | + 'desc' => __( 'For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview' ), |
|
104 | 104 | 'value' => '1', |
105 | 105 | 'merge_tags' => false, |
106 | 106 | ), |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | $return = $text; |
157 | 157 | |
158 | 158 | $context = new \GV\Template_Context(); |
159 | - $context->view = \GV\View::by_id( $view_data['view_id'] ); |
|
159 | + $context->view = \GV\View::by_id( $view_data[ 'view_id' ] ); |
|
160 | 160 | $context->entry = \GV\GF_Entry::from_entry( $entry ); |
161 | 161 | |
162 | 162 | $gv_field = \GV\Internal_Field::by_id( 'sequence' ); |
163 | 163 | $merge_tag_context = \GV\Utils::get( $legacy_field, 'UID' ); |
164 | - $merge_tag_context = $entry['id'] . "/{$merge_tag_context}"; |
|
164 | + $merge_tag_context = $entry[ 'id' ] . "/{$merge_tag_context}"; |
|
165 | 165 | |
166 | 166 | foreach ( $matches as $match ) { |
167 | 167 | |
168 | - $full_tag = $match[0]; |
|
169 | - $property = $match[1]; |
|
168 | + $full_tag = $match[ 0 ]; |
|
169 | + $property = $match[ 1 ]; |
|
170 | 170 | |
171 | 171 | $gv_field->reverse = false; |
172 | 172 | $gv_field->start = 1; |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | |
186 | 186 | // If there is a field with the ID of the start number, the merge tag won't work. |
187 | 187 | // In that case, you can use "=" instead: `{sequence start=10}` |
188 | - if( 1 === sizeof( $maybe_start ) ) { |
|
188 | + if ( 1 === sizeof( $maybe_start ) ) { |
|
189 | 189 | $maybe_start = explode( '=', $modifier ); |
190 | 190 | } |
191 | 191 | |
192 | 192 | if ( 'start' === rgar( $maybe_start, 0 ) && is_numeric( rgar( $maybe_start, 1 ) ) ) { |
193 | - $gv_field->start = (int) rgar( $maybe_start, 1 ); |
|
193 | + $gv_field->start = (int)rgar( $maybe_start, 1 ); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $merge_tag_context_modifiers = $merge_tag_context . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
202 | 202 | |
203 | 203 | if ( ! isset( $merge_tag_sequences[ $merge_tag_context_modifiers ] ) ) { |
204 | - $gv_field->UID = $legacy_field['UID'] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
|
204 | + $gv_field->UID = $legacy_field[ 'UID' ] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
|
205 | 205 | $context->field = $gv_field; |
206 | 206 | $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context ); |
207 | 207 | } else { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $total = $context->view->get_entries()->total(); |
247 | 247 | remove_filter( 'gform_gf_query_sql', $callback ); |
248 | 248 | |
249 | - unset( $sql_query['paginate'] ); |
|
249 | + unset( $sql_query[ 'paginate' ] ); |
|
250 | 250 | |
251 | 251 | global $wpdb; |
252 | 252 |
@@ -26,52 +26,52 @@ |
||
26 | 26 | |
27 | 27 | <?php // list all the available templates (type= fresh or custom ) ?> |
28 | 28 | <div class="gv-grid"> |
29 | - <?php foreach( $templates as $id => $template ) { |
|
29 | + <?php foreach ( $templates as $id => $template ) { |
|
30 | 30 | $selected = ( $id == $current_template ) ? ' gv-selected' : ''; |
31 | - $placeholder = ! empty( $template['buy_source'] ); |
|
32 | - $is_included = ! empty( $template['included'] ); |
|
31 | + $placeholder = ! empty( $template[ 'buy_source' ] ); |
|
32 | + $is_included = ! empty( $template[ 'included' ] ); |
|
33 | 33 | $plugin_data = GravityView_Admin_Installer::get_wp_plugins_data( \GV\Utils::get( $template, 'textdomain', '' ) ); |
34 | 34 | $button_text = empty( $plugin_data ) ? esc_html__( 'Install Layout', 'gravityview' ) : esc_html__( 'Activate & Select Layout', 'gravityview' ); |
35 | 35 | $button_class = 'gv-layout-' . ( empty( $plugin_data ) ? 'install' : 'activate' ); |
36 | - $template_path = isset($plugin_data['path']) ? $plugin_data['path'] : ''; |
|
36 | + $template_path = isset( $plugin_data[ 'path' ] ) ? $plugin_data[ 'path' ] : ''; |
|
37 | 37 | |
38 | 38 | ?> |
39 | 39 | <div class="gv-grid-col-1-4"> |
40 | - <div class="gv-view-types-module<?php echo $selected; if( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template['type'] ); ?>"> |
|
40 | + <div class="gv-view-types-module<?php echo $selected; if ( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template[ 'type' ] ); ?>"> |
|
41 | 41 | <div class="gv-view-types-normal"> |
42 | - <img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>"> |
|
43 | - <h5><?php echo esc_html( $template['label'] ); ?></h5> |
|
44 | - <p class="description"><?php echo esc_html( $template['description'] ); ?></p> |
|
42 | + <img src="<?php echo esc_url( $template[ 'logo' ] ); ?>" alt="<?php echo esc_attr( $template[ 'label' ] ); ?>"> |
|
43 | + <h5><?php echo esc_html( $template[ 'label' ] ); ?></h5> |
|
44 | + <p class="description"><?php echo esc_html( $template[ 'description' ] ); ?></p> |
|
45 | 45 | </div> |
46 | 46 | <div class="gv-view-types-hover"> |
47 | 47 | <div> |
48 | 48 | <?php |
49 | - if( $is_included ) { |
|
49 | + if ( $is_included ) { |
|
50 | 50 | ?> |
51 | 51 | <p><a href="<?php echo esc_url( admin_url( 'edit.php?post_type=gravityview&page=gv-admin-installer' ) ); ?>" class="button button-secondary button-hero <?php echo $button_class; ?>" rel="internal" data-template-path="<?php echo $template_path; ?>"><?php echo $button_text; ?></a></p> |
52 | - <?php if( !empty( $template['license'] ) ) { ?> |
|
53 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template['license'] ) ) ); ?></p> |
|
52 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
53 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) ); ?></p> |
|
54 | 54 | <?php } ?> |
55 | 55 | <?php |
56 | - } elseif( $placeholder ) { |
|
57 | - $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template['license'] ) . '&utm_content=' . urlencode( $template['slug'] ); |
|
56 | + } elseif ( $placeholder ) { |
|
57 | + $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template[ 'license' ] ) . '&utm_content=' . urlencode( $template[ 'slug' ] ); |
|
58 | 58 | ?> |
59 | - <p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview'); ?></a></p> |
|
59 | + <p><a href="<?php echo esc_url( $template[ 'buy_source' ] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview' ); ?></a></p> |
|
60 | 60 | |
61 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
62 | - <p><a href="<?php echo esc_url( $template['preview'] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview'); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
61 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
62 | + <p><a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview' ); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
63 | 63 | <?php } ?> |
64 | 64 | |
65 | - <?php if( ! empty( $template['license'] ) ) { ?> |
|
66 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://gravityview.co/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template['license'] ) ) . '</a>' ); ?></p> |
|
65 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
66 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://gravityview.co/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) . '</a>' ); ?></p> |
|
67 | 67 | <?php } ?> |
68 | 68 | <?php } |
69 | 69 | |
70 | - if ($placeholder || $is_included) { ?> </div><div class="hidden"> <?php } ?> |
|
70 | + if ( $placeholder || $is_included ) { ?> </div><div class="hidden"> <?php } ?> |
|
71 | 71 | |
72 | - <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview'); ?></a></p> |
|
73 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
74 | - <a href="<?php echo esc_url( $template['preview'] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-admin-links" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview'); ?>"></i></a> |
|
72 | + <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview' ); ?></a></p> |
|
73 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
74 | + <a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-admin-links" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview' ); ?>"></i></a> |
|
75 | 75 | <?php } ?> |
76 | 76 | </div> |
77 | 77 | </div> |
@@ -97,13 +97,13 @@ |
||
97 | 97 | // Set the $_field_id var |
98 | 98 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); |
99 | 99 | |
100 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
100 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
101 | 101 | $default = 'tick'; |
102 | 102 | } else { |
103 | 103 | $default = 'both'; |
104 | 104 | } |
105 | 105 | |
106 | - $field_options['choice_display'] = array( |
|
106 | + $field_options[ 'choice_display' ] = array( |
|
107 | 107 | 'type' => 'radio', |
108 | 108 | 'class' => 'vertical', |
109 | 109 | 'label' => __( 'What should be displayed:', 'gravityview' ), |