@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
| 9 | 9 | $view_id = $gravityview_view->getViewId(); |
| 10 | -$value = $gravityview_view->search_field['value']; |
|
| 11 | -$label = $gravityview_view->search_field['label']; |
|
| 10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
| 11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range gv-search-field-entry_date"> |
| 16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
| 16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | 17 | <label for="gv_start_date_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
| 18 | 18 | <?php } ?> |
| 19 | 19 | <p> |
| 20 | - <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
| 21 | - <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
| 20 | + <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
| 21 | + <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
| 22 | 22 | </p> |
| 23 | 23 | </div> |
| 24 | 24 | \ No newline at end of file |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
| 9 | 9 | $view_id = $gravityview_view->getViewId(); |
| 10 | -$value = $gravityview_view->search_field['value']; |
|
| 11 | -$label = $gravityview_view->search_field['label']; |
|
| 12 | -$name = $gravityview_view->search_field['name']; |
|
| 10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
| 11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
| 12 | +$name = $gravityview_view->search_field[ 'name' ]; |
|
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range"> |
| 16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
| 16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | + <label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
| 18 | 18 | <?php } ?> |
| 19 | 19 | <p> |
| 20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['start'] ); ?>"> |
|
| 21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['end'] ); ?>"> |
|
| 20 | + <input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'start' ] ); ?>"> |
|
| 21 | + <input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'end' ] ); ?>"> |
|
| 22 | 22 | </p> |
| 23 | 23 | </div> |
| 24 | 24 | \ No newline at end of file |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $args = array(); |
| 115 | 115 | |
| 116 | - $view_id = is_null ( $view ) ? null : $view->ID; |
|
| 116 | + $view_id = is_null( $view ) ? null : $view->ID; |
|
| 117 | 117 | |
| 118 | 118 | $permalink = null; |
| 119 | 119 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $view_collection = View_Collection::from_post( $post ); |
| 128 | 128 | |
| 129 | - if( 1 < $view_collection->count() ) { |
|
| 130 | - $args['gvid'] = $view_id; |
|
| 129 | + if ( 1 < $view_collection->count() ) { |
|
| 130 | + $args[ 'gvid' ] = $view_id; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -156,21 +156,21 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | $link_parts = explode( '?', $permalink ); |
| 158 | 158 | |
| 159 | - $query = ! empty( $link_parts[1] ) ? '?' . $link_parts[1] : ''; |
|
| 159 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
| 160 | 160 | |
| 161 | - $permalink = trailingslashit( $link_parts[0] ) . $entry_endpoint_name . '/'. $entry_slug .'/' . $query; |
|
| 161 | + $permalink = trailingslashit( $link_parts[ 0 ] ) . $entry_endpoint_name . '/' . $entry_slug . '/' . $query; |
|
| 162 | 162 | } else { |
| 163 | 163 | $args[ $entry_endpoint_name ] = $entry_slug; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | if ( $track_directory ) { |
| 167 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
| 168 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 167 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
| 168 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if ( $sort = Utils::_GET( 'sort' ) ) { |
| 172 | - $args['sort'] = $sort; |
|
| 173 | - $args['dir'] = Utils::_GET( 'dir' ); |
|
| 172 | + $args[ 'sort' ] = $sort; |
|
| 173 | + $args[ 'dir' ] = Utils::_GET( 'dir' ); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
@@ -79,8 +79,9 @@ |
||
| 79 | 79 | * Check permissions. |
| 80 | 80 | */ |
| 81 | 81 | while ( $error = $view->can_render( array( 'shortcode' ), $request ) ) { |
| 82 | - if ( ! is_wp_error( $error ) ) |
|
| 83 | - break; |
|
| 82 | + if ( ! is_wp_error( $error ) ) { |
|
| 83 | + break; |
|
| 84 | + } |
|
| 84 | 85 | |
| 85 | 86 | switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) { |
| 86 | 87 | case 'post_password_required': |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | 'detail' => null, |
| 42 | 42 | ) ); |
| 43 | 43 | |
| 44 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
| 45 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
| 44 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
| 45 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
| 46 | 46 | $view_id = $view->ID; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 114 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * View details. |
| 118 | 118 | */ |
| 119 | - if ( $atts['detail'] ) { |
|
| 119 | + if ( $atts[ 'detail' ] ) { |
|
| 120 | 120 | $entries = $view->get_entries( $request ); |
| 121 | 121 | return self::_return( $this->detail( $view, $entries, $atts ) ); |
| 122 | 122 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return self::_return( '' ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( $entry['status'] != 'active' ) { |
|
| 136 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 137 | 137 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 138 | 138 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 147 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 147 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 148 | 148 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 149 | 149 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 150 | 150 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $entryset = $entry->is_multi() ? $entry->entries : array( $entry ); |
| 168 | 168 | |
| 169 | 169 | foreach ( $entryset as $e ) { |
| 170 | - if ( $e['status'] != 'active' ) { |
|
| 170 | + if ( $e[ 'status' ] != 'active' ) { |
|
| 171 | 171 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
| 172 | 172 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 181 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 181 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 182 | 182 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
| 183 | 183 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 184 | 184 | } |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | // Mock the request with the actual View, not the global one |
| 205 | 205 | $mock_request = new \GV\Mock_Request(); |
| 206 | - $mock_request->returns['is_view'] = $view; |
|
| 207 | - $mock_request->returns['is_entry'] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 208 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 209 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
| 206 | + $mock_request->returns[ 'is_view' ] = $view; |
|
| 207 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 208 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 209 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
| 210 | 210 | |
| 211 | 211 | $request = $mock_request; |
| 212 | 212 | } |
@@ -242,16 +242,16 @@ discard block |
||
| 242 | 242 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
| 243 | 243 | |
| 244 | 244 | // Only keep the passed attributes after making sure that they're valid pairs |
| 245 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
| 245 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
| 246 | 246 | |
| 247 | 247 | $atts = array(); |
| 248 | 248 | |
| 249 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
| 249 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
| 250 | 250 | |
| 251 | 251 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
| 252 | 252 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
| 253 | 253 | |
| 254 | - switch( $defaults[ $key ]['type'] ) { |
|
| 254 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * Make sure number fields are numeric. |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
| 260 | 260 | */ |
| 261 | 261 | case 'number': |
| 262 | - if( is_numeric( $passed_value ) ) { |
|
| 262 | + if ( is_numeric( $passed_value ) ) { |
|
| 263 | 263 | $atts[ $key ] = ( $passed_value + 0 ); |
| 264 | 264 | } |
| 265 | 265 | break; |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | case 'select': |
| 276 | 276 | case 'radio': |
| 277 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
| 278 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 277 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
| 278 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 279 | 279 | $atts[ $key ] = $passed_value; |
| 280 | 280 | } |
| 281 | 281 | break; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 290 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 291 | 291 | |
| 292 | 292 | return $atts; |
| 293 | 293 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | private function detail( $view, $entries, $atts ) { |
| 305 | 305 | $output = ''; |
| 306 | 306 | |
| 307 | - switch ( $key = $atts['detail'] ): |
|
| 307 | + switch ( $key = $atts[ 'detail' ] ): |
|
| 308 | 308 | case 'total_entries': |
| 309 | 309 | $output = number_format_i18n( $entries->total() ); |
| 310 | 310 | break; |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * |
| 50 | 50 | * @param array $items Scripts or styles to exclude from no-conflict |
| 51 | 51 | * |
| 52 | - * @return array |
|
| 52 | + * @return string[] |
|
| 53 | 53 | */ |
| 54 | 54 | public function register_noconflict( $items ) { |
| 55 | 55 | |
@@ -449,9 +449,7 @@ |
||
| 449 | 449 | $button_label = sprintf( __( 'Upgrade to %s for Access', 'gravityview' ), $required_license ); |
| 450 | 450 | $button_class = 'button-primary button-large'; |
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | - } |
|
| 453 | - |
|
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 452 | + } elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | 453 | $spinner = false; |
| 456 | 454 | $status = 'notinstalled'; |
| 457 | 455 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function register_noconflict( $items ) { |
| 55 | 55 | |
| 56 | - $items[] = 'gravityview-admin-installer'; |
|
| 56 | + $items[ ] = 'gravityview-admin-installer'; |
|
| 57 | 57 | |
| 58 | 58 | return $items; |
| 59 | 59 | } |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
| 75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
| 76 | 76 | foreach ( $downloads_data as $extension ) { |
| 77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
| 77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - return (object) array( |
|
| 82 | - 'slug' => $extension['info']['slug'], |
|
| 83 | - 'name' => $extension['info']['title'], |
|
| 84 | - 'version' => $extension['licensing']['version'], |
|
| 85 | - 'download_link' => $extension['files'][0]['file'], |
|
| 81 | + return (object)array( |
|
| 82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
| 83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
| 84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
| 85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | foreach ( $all_plugins as $path => $plugin ) { |
| 146 | 146 | |
| 147 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
| 147 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
| 148 | 148 | continue; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
| 151 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
| 152 | 152 | 'path' => $path, |
| 153 | - 'version' => $plugin['Version'], |
|
| 153 | + 'version' => $plugin[ 'Version' ], |
|
| 154 | 154 | 'activated' => is_plugin_active( $path ) |
| 155 | 155 | ); |
| 156 | 156 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | return $downloads_data; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if( \GV\Plugin::is_network_activated() ) { |
|
| 211 | + if ( \GV\Plugin::is_network_activated() ) { |
|
| 212 | 212 | $home_url = network_home_url(); |
| 213 | 213 | } else { |
| 214 | 214 | $home_url = home_url(); |
@@ -236,13 +236,13 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 238 | 238 | |
| 239 | - if ( empty( $downloads_data['products'] ) ) { |
|
| 239 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
| 240 | 240 | return array(); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
| 243 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
| 244 | 244 | |
| 245 | - return $downloads_data['products']; |
|
| 245 | + return $downloads_data[ 'products' ]; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | foreach ( $downloads_data as $extension ) { |
| 317 | 317 | |
| 318 | - if ( empty( $extension['info'] ) ) { |
|
| 318 | + if ( empty( $extension[ 'info' ] ) ) { |
|
| 319 | 319 | continue; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -344,29 +344,29 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
| 346 | 346 | |
| 347 | - $download_info = $details['download_info']; |
|
| 347 | + $download_info = $details[ 'download_info' ]; |
|
| 348 | 348 | |
| 349 | 349 | ?> |
| 350 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
| 350 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
| 351 | 351 | <div class="addon-inner"> |
| 352 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
| 353 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
| 352 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
| 353 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
| 354 | 354 | <div> |
| 355 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
| 356 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
| 357 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
| 355 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
| 356 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
| 357 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
| 358 | 358 | </div> |
| 359 | 359 | <?php } ?> |
| 360 | 360 | |
| 361 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
| 362 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
| 363 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
| 361 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
| 362 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
| 363 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
| 364 | 364 | </a> |
| 365 | 365 | </div> |
| 366 | 366 | |
| 367 | 367 | <div class="addon-excerpt"><?php |
| 368 | 368 | |
| 369 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 369 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
| 370 | 370 | |
| 371 | 371 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
| 372 | 372 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | private function get_download_display_details( $download, $wp_plugins ) { |
| 408 | 408 | |
| 409 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
| 409 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
| 410 | 410 | 'thumbnail' => '', |
| 411 | 411 | 'title' => '', |
| 412 | 412 | 'textdomain' => '', |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | 'installer_excerpt' => null, // May not be defined |
| 419 | 419 | ) ); |
| 420 | 420 | |
| 421 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
| 421 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
| 422 | 422 | |
| 423 | - $has_access = ! empty( $download['files'] ); |
|
| 423 | + $has_access = ! empty( $download[ 'files' ] ); |
|
| 424 | 424 | $spinner = true; |
| 425 | 425 | $href = $plugin_path = '#'; |
| 426 | 426 | $status = $item_class = $button_title = $button_class = ''; |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
| 431 | 431 | |
| 432 | 432 | // The license is not active - no matter what level, this should not work |
| 433 | - if( ! $is_active && empty( $base_price ) ) { |
|
| 433 | + if ( ! $is_active && empty( $base_price ) ) { |
|
| 434 | 434 | $spinner = false; |
| 435 | 435 | $status_label = ''; |
| 436 | 436 | $button_class = 'disabled disabled-license'; |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | $status_label = ''; |
| 444 | 444 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
| 445 | 445 | $button_class = 'button-primary button-large'; |
| 446 | - $href = $download_info['link']; |
|
| 446 | + $href = $download_info[ 'link' ]; |
|
| 447 | 447 | $item_class = 'featured'; |
| 448 | 448 | } |
| 449 | 449 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 459 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
| 460 | 460 | $spinner = false; |
| 461 | 461 | $status = 'notinstalled'; |
| 462 | 462 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -471,8 +471,8 @@ discard block |
||
| 471 | 471 | $href = add_query_arg( |
| 472 | 472 | array( |
| 473 | 473 | 'action' => 'install-plugin', |
| 474 | - 'plugin' => $download_info['slug'], |
|
| 475 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
| 474 | + 'plugin' => $download_info[ 'slug' ], |
|
| 475 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
| 476 | 476 | ), |
| 477 | 477 | self_admin_url( 'update.php' ) |
| 478 | 478 | ); |
@@ -484,25 +484,25 @@ discard block |
||
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | // Access and the plugin is installed but not active |
| 487 | - elseif ( false === $wp_plugin['activated'] ) { |
|
| 487 | + elseif ( false === $wp_plugin[ 'activated' ] ) { |
|
| 488 | 488 | $status = 'inactive'; |
| 489 | 489 | $status_label = __( 'Inactive', 'gravityview' ); |
| 490 | 490 | $button_label = __( 'Activate', 'gravityview' ); |
| 491 | - $plugin_path = $wp_plugin['path']; |
|
| 491 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 492 | 492 | |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Access and the plugin is installed and active |
| 496 | 496 | else { |
| 497 | 497 | |
| 498 | - $plugin_path = $wp_plugin['path']; |
|
| 498 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
| 499 | 499 | $status = 'active'; |
| 500 | 500 | $status_label = __( 'Active', 'gravityview' ); |
| 501 | 501 | $button_label = __( 'Deactivate', 'gravityview' ); |
| 502 | 502 | |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 505 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -517,11 +517,11 @@ discard block |
||
| 517 | 517 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
| 518 | 518 | $base_price = \GFCommon::to_number( $base_price ); |
| 519 | 519 | |
| 520 | - unset( $download['pricing']['amount'] ); |
|
| 520 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
| 521 | 521 | |
| 522 | 522 | // Price options array, not single price |
| 523 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
| 524 | - $base_price = array_shift( $download['pricing'] ); |
|
| 523 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
| 524 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return floatval( $base_price ); |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | public function activate_download() { |
| 536 | 536 | $data = \GV\Utils::_POST( 'data', array() ); |
| 537 | 537 | |
| 538 | - if ( empty( $data['path'] ) ) { |
|
| 538 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 539 | 539 | return; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - $result = activate_plugin( $data['path'] ); |
|
| 542 | + $result = activate_plugin( $data[ 'path' ] ); |
|
| 543 | 543 | |
| 544 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
| 544 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
| 545 | 545 | wp_send_json_error( array( |
| 546 | 546 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
| 547 | 547 | ) ); |
@@ -558,13 +558,13 @@ discard block |
||
| 558 | 558 | public function deactivate_download() { |
| 559 | 559 | $data = \GV\Utils::_POST( 'data', array() ); |
| 560 | 560 | |
| 561 | - if ( empty( $data['path'] ) ) { |
|
| 561 | + if ( empty( $data[ 'path' ] ) ) { |
|
| 562 | 562 | return; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - deactivate_plugins( $data['path'] ); |
|
| 565 | + deactivate_plugins( $data[ 'path' ] ); |
|
| 566 | 566 | |
| 567 | - if( is_plugin_active( $data['path'] ) ) { |
|
| 567 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
| 568 | 568 | wp_send_json_error( array( |
| 569 | 569 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
| 570 | 570 | ) ); |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function add_downloads_data_filters() { |
| 68 | 68 | |
| 69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 70 | 70 | |
| 71 | - if ( ! $downloads_data ) { |
|
| 71 | + if ( ! $downloads_data ) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function add_admin_menu() { |
| 99 | 99 | |
| 100 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 100 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 101 | 101 | |
| 102 | 102 | $menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
| 103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | - * |
|
| 115 | + * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | + * |
|
| 117 | 117 | * @param array $notice |
| 118 | 118 | * |
| 119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
| 122 | 122 | |
| 123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
| 124 | - return $notice; |
|
| 125 | - } |
|
| 124 | + return $notice; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -162,43 +162,43 @@ discard block |
||
| 162 | 162 | * Get downloads data from transient or from API; save transient after getting data from API |
| 163 | 163 | * |
| 164 | 164 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
| 165 | - * @type array $info { |
|
| 166 | - * @type string $id int 17 |
|
| 167 | - * @type string $slug Extension slug |
|
| 168 | - * @type string $title Extension title |
|
| 169 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | - * @type string $modified_date |
|
| 171 | - * @type string $status |
|
| 172 | - * @type string $link URL to public plugin page |
|
| 173 | - * @type string $content |
|
| 174 | - * @type string $excerpt |
|
| 175 | - * @type string $thumbnail URL to thumbnail |
|
| 176 | - * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | - * @type int $term_id => int 30 |
|
| 178 | - * @type string $name => string 'Plugins' (length=7) |
|
| 179 | - * @type string $slug => string 'plugins' (length=7) |
|
| 180 | - * @type int $term_group => int 0 |
|
| 181 | - * @type int $term_taxonomy_id => int 30 |
|
| 182 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | - * @type string $description => string '' (length=0) |
|
| 184 | - * @type int $parent => int 0 |
|
| 185 | - * @type int $count => int 4 |
|
| 186 | - * @type string $filter => string 'raw' (length=3) |
|
| 187 | - * } |
|
| 188 | - * @type array $tags {see $category above} |
|
| 189 | - * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | - * } |
|
| 191 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | - * @type array $licensing { |
|
| 193 | - * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | - * @type string $version Version number |
|
| 195 | - * @type string $exp_unit Expiration unit ('years') |
|
| 196 | - * @type string $exp_length Expiration length ('1') |
|
| 197 | - * } |
|
| 198 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | - * @type string $file string URL of the file download |
|
| 200 | - * } |
|
| 201 | - * } |
|
| 165 | + * @type array $info { |
|
| 166 | + * @type string $id int 17 |
|
| 167 | + * @type string $slug Extension slug |
|
| 168 | + * @type string $title Extension title |
|
| 169 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | + * @type string $modified_date |
|
| 171 | + * @type string $status |
|
| 172 | + * @type string $link URL to public plugin page |
|
| 173 | + * @type string $content |
|
| 174 | + * @type string $excerpt |
|
| 175 | + * @type string $thumbnail URL to thumbnail |
|
| 176 | + * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | + * @type int $term_id => int 30 |
|
| 178 | + * @type string $name => string 'Plugins' (length=7) |
|
| 179 | + * @type string $slug => string 'plugins' (length=7) |
|
| 180 | + * @type int $term_group => int 0 |
|
| 181 | + * @type int $term_taxonomy_id => int 30 |
|
| 182 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | + * @type string $description => string '' (length=0) |
|
| 184 | + * @type int $parent => int 0 |
|
| 185 | + * @type int $count => int 4 |
|
| 186 | + * @type string $filter => string 'raw' (length=3) |
|
| 187 | + * } |
|
| 188 | + * @type array $tags {see $category above} |
|
| 189 | + * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | + * } |
|
| 191 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | + * @type array $licensing { |
|
| 193 | + * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | + * @type string $version Version number |
|
| 195 | + * @type string $exp_unit Expiration unit ('years') |
|
| 196 | + * @type string $exp_length Expiration length ('1') |
|
| 197 | + * } |
|
| 198 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | + * @type string $file string URL of the file download |
|
| 200 | + * } |
|
| 201 | + * } |
|
| 202 | 202 | */ |
| 203 | 203 | public function get_downloads_data() { |
| 204 | 204 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | ) ); |
| 231 | 231 | |
| 232 | 232 | if ( is_wp_error( $response ) ) { |
| 233 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 233 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 234 | 234 | return $response; |
| 235 | 235 | } |
| 236 | 236 | |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | <div class="gv-admin-installer-notice notice inline error"> |
| 284 | 284 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
| 285 | 285 | <?php |
| 286 | - if ( is_wp_error( $downloads_data ) ) { |
|
| 287 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 288 | - } |
|
| 289 | - ?> |
|
| 286 | + if ( is_wp_error( $downloads_data ) ) { |
|
| 287 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 288 | + } |
|
| 289 | + ?> |
|
| 290 | 290 | </div> |
| 291 | 291 | </div> |
| 292 | 292 | <?php |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | protected function render_download( $download, $wp_plugins ) { |
| 343 | 343 | |
| 344 | 344 | |
| 345 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 345 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 346 | 346 | |
| 347 | - $download_info = $details['download_info']; |
|
| 347 | + $download_info = $details['download_info']; |
|
| 348 | 348 | |
| 349 | 349 | ?> |
| 350 | 350 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -366,43 +366,43 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | <div class="addon-excerpt"><?php |
| 368 | 368 | |
| 369 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 369 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 370 | 370 | |
| 371 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 372 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 373 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 371 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 372 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 373 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 374 | 374 | |
| 375 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 376 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 375 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 376 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 377 | 377 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
| 378 | 378 | |
| 379 | 379 | echo wpautop( $excerpt ); |
| 380 | - ?></div> |
|
| 380 | + ?></div> |
|
| 381 | 381 | </div> |
| 382 | 382 | </div> |
| 383 | 383 | <?php |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 388 | - * |
|
| 387 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 388 | + * |
|
| 389 | 389 | * @param array $download Single download, as returned by {@see get_downloads_data} |
| 390 | 390 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
| 391 | 391 | * |
| 392 | 392 | * @return array { |
| 393 | - * @type array $download_info |
|
| 394 | - * @type string $plugin_path |
|
| 395 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 396 | - * @type string $status_label |
|
| 397 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 398 | - * @type string $button_class CSS class to use for the button |
|
| 399 | - * @type string $button_label Text to use for the download's anchor link |
|
| 400 | - * @type string $href URL for the download's button |
|
| 401 | - * @type bool $spinner Whether to show the spinner icon |
|
| 402 | - * @type string $item_class CSS class for the download container |
|
| 403 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 404 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 405 | - * } |
|
| 393 | + * @type array $download_info |
|
| 394 | + * @type string $plugin_path |
|
| 395 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 396 | + * @type string $status_label |
|
| 397 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 398 | + * @type string $button_class CSS class to use for the button |
|
| 399 | + * @type string $button_label Text to use for the download's anchor link |
|
| 400 | + * @type string $href URL for the download's button |
|
| 401 | + * @type bool $spinner Whether to show the spinner icon |
|
| 402 | + * @type string $item_class CSS class for the download container |
|
| 403 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 404 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 405 | + * } |
|
| 406 | 406 | */ |
| 407 | 407 | private function get_download_display_details( $download, $wp_plugins ) { |
| 408 | 408 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | 'slug' => '', |
| 414 | 414 | 'excerpt' => '', |
| 415 | 415 | 'link' => '', |
| 416 | - 'coming_soon' => false, |
|
| 416 | + 'coming_soon' => false, |
|
| 417 | 417 | 'installer_title' => null, // May not be defined |
| 418 | 418 | 'installer_excerpt' => null, // May not be defined |
| 419 | 419 | ) ); |
@@ -456,14 +456,14 @@ discard block |
||
| 456 | 456 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 460 | - $spinner = false; |
|
| 461 | - $status = 'notinstalled'; |
|
| 462 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 463 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
| 464 | - $button_class = 'button-primary button-large'; |
|
| 465 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 466 | - } |
|
| 459 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 460 | + $spinner = false; |
|
| 461 | + $status = 'notinstalled'; |
|
| 462 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 463 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
| 464 | + $button_class = 'button-primary button-large'; |
|
| 465 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | 468 | // Access but the plugin is not installed |
| 469 | 469 | elseif ( ! $wp_plugin ) { |
@@ -503,18 +503,18 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | - * Returns the base price for an extension |
|
| 510 | - * |
|
| 509 | + * Returns the base price for an extension |
|
| 510 | + * |
|
| 511 | 511 | * @param array $download |
| 512 | 512 | * |
| 513 | 513 | * @return float Base price for an extension. If not for sale separately, returns 0 |
| 514 | 514 | */ |
| 515 | 515 | private function get_download_base_price( $download ) { |
| 516 | 516 | |
| 517 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 517 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 518 | 518 | $base_price = \GFCommon::to_number( $base_price ); |
| 519 | 519 | |
| 520 | 520 | unset( $download['pricing']['amount'] ); |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return floatval( $base_price ); |
| 528 | - } |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | 530 | /** |
| 531 | 531 | * Handle AJAX request to activate extension |
@@ -543,8 +543,8 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
| 545 | 545 | wp_send_json_error( array( |
| 546 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 547 | - ) ); |
|
| 546 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 547 | + ) ); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | wp_send_json_success(); |
@@ -565,10 +565,10 @@ discard block |
||
| 565 | 565 | deactivate_plugins( $data['path'] ); |
| 566 | 566 | |
| 567 | 567 | if( is_plugin_active( $data['path'] ) ) { |
| 568 | - wp_send_json_error( array( |
|
| 569 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 570 | - ) ); |
|
| 571 | - } |
|
| 568 | + wp_send_json_error( array( |
|
| 569 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 570 | + ) ); |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | 573 | wp_send_json_success(); |
| 574 | 574 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $format = '(?:\.(?P<format>html|json))?'; |
| 134 | 134 | |
| 135 | - register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ) , array( |
|
| 135 | + register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ), array( |
|
| 136 | 136 | array( |
| 137 | 137 | 'methods' => \WP_REST_Server::READABLE, |
| 138 | 138 | 'callback' => array( $this, 'get_sub_item' ), |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @return \WP_REST_Response |
| 384 | 384 | */ |
| 385 | 385 | protected function not_implemented( ) { |
| 386 | - $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
| 386 | + $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
| 387 | 387 | return new \WP_REST_Response( $error, 501 ); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -282,7 +282,7 @@ |
||
| 282 | 282 | /** |
| 283 | 283 | * Process edit entry form save |
| 284 | 284 | * |
| 285 | - * @param array $gv_data The View data. |
|
| 285 | + * @param GravityView_View_Data $gv_data The View data. |
|
| 286 | 286 | */ |
| 287 | 287 | private function process_save( $gv_data ) { |
| 288 | 288 | |
@@ -573,7 +573,8 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | // Only allow quantity to be set if it's allowed to be edited |
| 575 | 575 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 576 | - } else { // otherwise set to what it previously was |
|
| 576 | + } else { |
|
| 577 | +// otherwise set to what it previously was |
|
| 577 | 578 | $_POST[ $input_name ] = $entry[ $input['id'] ]; |
| 578 | 579 | } |
| 579 | 580 | } else { |
@@ -958,7 +959,7 @@ discard block |
||
| 958 | 959 | |
| 959 | 960 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 960 | 961 | |
| 961 | - if( ! $this->is_valid ){ |
|
| 962 | + if( ! $this->is_valid ) { |
|
| 962 | 963 | |
| 963 | 964 | // Keeping this compatible with Gravity Forms. |
| 964 | 965 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -2070,9 +2071,7 @@ discard block |
||
| 2070 | 2071 | // Verify |
| 2071 | 2072 | else if( ! $this->is_edit_entry() ) { |
| 2072 | 2073 | $valid = false; |
| 2073 | - } |
|
| 2074 | - |
|
| 2075 | - else { |
|
| 2074 | + } else { |
|
| 2076 | 2075 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
| 2077 | 2076 | } |
| 2078 | 2077 | |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * ID of the current post. May also be ID of the current View. |
| 105 | - * |
|
| 106 | - * @since 2.0.13 |
|
| 107 | - * |
|
| 108 | - * @var int |
|
| 105 | + * |
|
| 106 | + * @since 2.0.13 |
|
| 107 | + * |
|
| 108 | + * @var int |
|
| 109 | 109 | */ |
| 110 | 110 | public $post_id; |
| 111 | 111 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function prevent_maybe_process_form() { |
| 190 | 190 | |
| 191 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 191 | + if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | * When Edit entry view is requested setup the vars |
| 223 | 223 | */ |
| 224 | 224 | private function setup_vars() { |
| 225 | - global $post; |
|
| 225 | + global $post; |
|
| 226 | 226 | |
| 227 | 227 | $gravityview_view = GravityView_View::getInstance(); |
| 228 | 228 | |
| 229 | 229 | |
| 230 | 230 | $entries = $gravityview_view->getEntries(); |
| 231 | - self::$original_entry = $entries[0]; |
|
| 232 | - $this->entry = $entries[0]; |
|
| 231 | + self::$original_entry = $entries[0]; |
|
| 232 | + $this->entry = $entries[0]; |
|
| 233 | 233 | |
| 234 | 234 | self::$original_form = $gravityview_view->getForm(); |
| 235 | 235 | $this->form = $gravityview_view->getForm(); |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
| 373 | 373 | |
| 374 | - // Delete the values for hidden inputs |
|
| 375 | - $this->unset_hidden_field_values(); |
|
| 374 | + // Delete the values for hidden inputs |
|
| 375 | + $this->unset_hidden_field_values(); |
|
| 376 | 376 | |
| 377 | 377 | $this->entry['date_created'] = $date_created; |
| 378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | // Perform actions normally performed after updating a lead |
| 383 | 383 | $this->after_update(); |
| 384 | 384 | |
| 385 | - /** |
|
| 385 | + /** |
|
| 386 | 386 | * Must be AFTER after_update()! |
| 387 | 387 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 388 | 388 | */ |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 393 | - * @since 2.1 Added $gv_data parameter |
|
| 393 | + * @since 2.1 Added $gv_data parameter |
|
| 394 | 394 | * @param array $form Gravity Forms form array |
| 395 | 395 | * @param string $entry_id Numeric ID of the entry that was updated |
| 396 | 396 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | 416 | private function unset_hidden_field_values() { |
| 417 | - global $wpdb; |
|
| 417 | + global $wpdb; |
|
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -438,17 +438,17 @@ discard block |
||
| 438 | 438 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 441 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 442 | 442 | |
| 443 | 443 | if ( ! is_numeric( $input_id ) ) { |
| 444 | 444 | continue; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 447 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 448 | 448 | |
| 449 | - // Reset fields that are hidden |
|
| 450 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 451 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 449 | + // Reset fields that are hidden |
|
| 450 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 451 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 452 | 452 | |
| 453 | 453 | $empty_value = $field->get_value_save_entry( |
| 454 | 454 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -460,16 +460,16 @@ discard block |
||
| 460 | 460 | $empty_value = ''; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 463 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 464 | 464 | |
| 465 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 465 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 466 | 466 | |
| 467 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 467 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 468 | 468 | // after submission |
| 469 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 470 | - $_POST[ $post_input_id ] = ''; |
|
| 471 | - } |
|
| 472 | - } |
|
| 469 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 470 | + $_POST[ $post_input_id ] = ''; |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | /** |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | $form = $this->filter_conditional_logic( $this->form ); |
| 565 | 565 | |
| 566 | - /** @var GF_Field $field */ |
|
| 566 | + /** @var GF_Field $field */ |
|
| 567 | 567 | foreach( $form['fields'] as $k => &$field ) { |
| 568 | 568 | |
| 569 | 569 | /** |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 581 | 581 | foreach( $field->inputs as $key => $input ) { |
| 582 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 582 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | $inputs = $field->get_entry_inputs(); |
| 621 | 621 | if ( is_array( $inputs ) ) { |
| 622 | - foreach ( $inputs as $input ) { |
|
| 622 | + foreach ( $inputs as $input ) { |
|
| 623 | 623 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 624 | 624 | |
| 625 | 625 | if ( 'product' === $field->type ) { |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 641 | - } |
|
| 641 | + } |
|
| 642 | 642 | } else { |
| 643 | 643 | // Set to what it previously was if it's not editable |
| 644 | 644 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 685 | 685 | |
| 686 | 686 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 687 | - $ary = stripslashes_deep( $ary ); |
|
| 687 | + $ary = stripslashes_deep( $ary ); |
|
| 688 | 688 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 689 | 689 | |
| 690 | 690 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | private function maybe_update_post_fields( $form ) { |
| 758 | 758 | |
| 759 | 759 | if( empty( $this->entry['post_id'] ) ) { |
| 760 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 760 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 761 | 761 | return; |
| 762 | 762 | } |
| 763 | 763 | |
@@ -792,49 +792,49 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | switch( $field->type ) { |
| 794 | 794 | |
| 795 | - case 'post_title': |
|
| 796 | - $post_title = $value; |
|
| 797 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 798 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 799 | - } |
|
| 800 | - $updated_post->post_title = $post_title; |
|
| 801 | - $updated_post->post_name = $post_title; |
|
| 802 | - unset( $post_title ); |
|
| 803 | - break; |
|
| 804 | - |
|
| 805 | - case 'post_content': |
|
| 806 | - $post_content = $value; |
|
| 807 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 808 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 809 | - } |
|
| 810 | - $updated_post->post_content = $post_content; |
|
| 811 | - unset( $post_content ); |
|
| 812 | - break; |
|
| 813 | - case 'post_excerpt': |
|
| 814 | - $updated_post->post_excerpt = $value; |
|
| 815 | - break; |
|
| 816 | - case 'post_tags': |
|
| 817 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 818 | - break; |
|
| 819 | - case 'post_category': |
|
| 820 | - break; |
|
| 821 | - case 'post_custom_field': |
|
| 795 | + case 'post_title': |
|
| 796 | + $post_title = $value; |
|
| 797 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 798 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 799 | + } |
|
| 800 | + $updated_post->post_title = $post_title; |
|
| 801 | + $updated_post->post_name = $post_title; |
|
| 802 | + unset( $post_title ); |
|
| 803 | + break; |
|
| 804 | + |
|
| 805 | + case 'post_content': |
|
| 806 | + $post_content = $value; |
|
| 807 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 808 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 809 | + } |
|
| 810 | + $updated_post->post_content = $post_content; |
|
| 811 | + unset( $post_content ); |
|
| 812 | + break; |
|
| 813 | + case 'post_excerpt': |
|
| 814 | + $updated_post->post_excerpt = $value; |
|
| 815 | + break; |
|
| 816 | + case 'post_tags': |
|
| 817 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 818 | + break; |
|
| 819 | + case 'post_category': |
|
| 820 | + break; |
|
| 821 | + case 'post_custom_field': |
|
| 822 | 822 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 823 | 823 | $value = $value[ $field_id ]; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 827 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 828 | - } |
|
| 826 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 827 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 828 | + } |
|
| 829 | 829 | |
| 830 | 830 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 831 | 831 | |
| 832 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 833 | - break; |
|
| 832 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 833 | + break; |
|
| 834 | 834 | |
| 835 | - case 'post_image': |
|
| 836 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 837 | - break; |
|
| 835 | + case 'post_image': |
|
| 836 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 837 | + break; |
|
| 838 | 838 | |
| 839 | 839 | } |
| 840 | 840 | |
@@ -991,14 +991,14 @@ discard block |
||
| 991 | 991 | ?><h2 class="gv-edit-entry-title"> |
| 992 | 992 | <span><?php |
| 993 | 993 | |
| 994 | - /** |
|
| 995 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 996 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 997 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 998 | - */ |
|
| 999 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 994 | + /** |
|
| 995 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 996 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 997 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 998 | + */ |
|
| 999 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1000 | 1000 | |
| 1001 | - echo esc_attr( $edit_entry_title ); |
|
| 1001 | + echo esc_attr( $edit_entry_title ); |
|
| 1002 | 1002 | ?></span> |
| 1003 | 1003 | </h2> |
| 1004 | 1004 | |
@@ -1053,13 +1053,13 @@ discard block |
||
| 1053 | 1053 | ); |
| 1054 | 1054 | |
| 1055 | 1055 | /** |
| 1056 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1057 | - * @since 1.16.3 |
|
| 1058 | - * @param array $labels Default button labels associative array |
|
| 1059 | - * @param array $form The Gravity Forms form |
|
| 1060 | - * @param array $entry The Gravity Forms entry |
|
| 1061 | - * @param int $view_id The current View ID |
|
| 1062 | - */ |
|
| 1056 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1057 | + * @since 1.16.3 |
|
| 1058 | + * @param array $labels Default button labels associative array |
|
| 1059 | + * @param array $form The Gravity Forms form |
|
| 1060 | + * @param array $entry The Gravity Forms entry |
|
| 1061 | + * @param int $view_id The current View ID |
|
| 1062 | + */ |
|
| 1063 | 1063 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1064 | 1064 | |
| 1065 | 1065 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1096,26 +1096,26 @@ discard block |
||
| 1096 | 1096 | |
| 1097 | 1097 | switch ( $edit_redirect ) { |
| 1098 | 1098 | |
| 1099 | - case '0': |
|
| 1100 | - $redirect_url = $back_link; |
|
| 1101 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1102 | - break; |
|
| 1103 | - |
|
| 1104 | - case '1': |
|
| 1105 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1106 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1107 | - break; |
|
| 1108 | - |
|
| 1109 | - case '2': |
|
| 1110 | - $redirect_url = $edit_redirect_url; |
|
| 1111 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1112 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1113 | - break; |
|
| 1114 | - |
|
| 1115 | - case '': |
|
| 1116 | - default: |
|
| 1117 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1118 | - break; |
|
| 1099 | + case '0': |
|
| 1100 | + $redirect_url = $back_link; |
|
| 1101 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1102 | + break; |
|
| 1103 | + |
|
| 1104 | + case '1': |
|
| 1105 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1106 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1107 | + break; |
|
| 1108 | + |
|
| 1109 | + case '2': |
|
| 1110 | + $redirect_url = $edit_redirect_url; |
|
| 1111 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1112 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1113 | + break; |
|
| 1114 | + |
|
| 1115 | + case '': |
|
| 1116 | + default: |
|
| 1117 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1118 | + break; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | if ( isset( $redirect_url ) ) { |
@@ -1181,13 +1181,13 @@ discard block |
||
| 1181 | 1181 | ); |
| 1182 | 1182 | |
| 1183 | 1183 | /** |
| 1184 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1185 | - * @since 1.16.3 |
|
| 1186 | - * @param array $labels Default button labels associative array |
|
| 1187 | - * @param array $form The Gravity Forms form |
|
| 1188 | - * @param array $entry The Gravity Forms entry |
|
| 1189 | - * @param int $view_id The current View ID |
|
| 1190 | - */ |
|
| 1184 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1185 | + * @since 1.16.3 |
|
| 1186 | + * @param array $labels Default button labels associative array |
|
| 1187 | + * @param array $form The Gravity Forms form |
|
| 1188 | + * @param array $entry The Gravity Forms entry |
|
| 1189 | + * @param int $view_id The current View ID |
|
| 1190 | + */ |
|
| 1191 | 1191 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1192 | 1192 | |
| 1193 | 1193 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | |
| 1230 | 1230 | ob_get_clean(); |
| 1231 | 1231 | |
| 1232 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1232 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1233 | 1233 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1234 | 1234 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1235 | 1235 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | |
| 1286 | 1286 | // for now we don't support Save and Continue feature. |
| 1287 | 1287 | if( ! self::$supports_save_and_continue ) { |
| 1288 | - unset( $form['save'] ); |
|
| 1288 | + unset( $form['save'] ); |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | $form = $this->unselect_default_values( $form ); |
@@ -1312,30 +1312,30 @@ discard block |
||
| 1312 | 1312 | return $field_content; |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | - $message = null; |
|
| 1315 | + $message = null; |
|
| 1316 | 1316 | |
| 1317 | - // First, make sure they have the capability to edit the post. |
|
| 1318 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1317 | + // First, make sure they have the capability to edit the post. |
|
| 1318 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1319 | 1319 | |
| 1320 | - /** |
|
| 1321 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1322 | - * @param string $message The existing "You don't have permission..." text |
|
| 1323 | - */ |
|
| 1324 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1320 | + /** |
|
| 1321 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1322 | + * @param string $message The existing "You don't have permission..." text |
|
| 1323 | + */ |
|
| 1324 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1325 | 1325 | |
| 1326 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1327 | - /** |
|
| 1328 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1329 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1330 | - */ |
|
| 1331 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1332 | - } |
|
| 1326 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1327 | + /** |
|
| 1328 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1329 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1330 | + */ |
|
| 1331 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | - if( $message ) { |
|
| 1335 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1336 | - } |
|
| 1334 | + if( $message ) { |
|
| 1335 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1336 | + } |
|
| 1337 | 1337 | |
| 1338 | - return $field_content; |
|
| 1338 | + return $field_content; |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /** |
@@ -1363,7 +1363,7 @@ discard block |
||
| 1363 | 1363 | || ! empty( $field_content ) |
| 1364 | 1364 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1365 | 1365 | ) { |
| 1366 | - return $field_content; |
|
| 1366 | + return $field_content; |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1371,24 +1371,24 @@ discard block |
||
| 1371 | 1371 | |
| 1372 | 1372 | $field_value = $this->get_field_value( $field ); |
| 1373 | 1373 | |
| 1374 | - // Prevent any PHP warnings, like undefined index |
|
| 1375 | - ob_start(); |
|
| 1374 | + // Prevent any PHP warnings, like undefined index |
|
| 1375 | + ob_start(); |
|
| 1376 | 1376 | |
| 1377 | - $return = null; |
|
| 1377 | + $return = null; |
|
| 1378 | 1378 | |
| 1379 | 1379 | /** @var GravityView_Field $gv_field */ |
| 1380 | 1380 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1381 | 1381 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1382 | 1382 | } else { |
| 1383 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1384 | - } |
|
| 1383 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1384 | + } |
|
| 1385 | 1385 | |
| 1386 | - // If there was output, it's an error |
|
| 1387 | - $warnings = ob_get_clean(); |
|
| 1386 | + // If there was output, it's an error |
|
| 1387 | + $warnings = ob_get_clean(); |
|
| 1388 | 1388 | |
| 1389 | - if( !empty( $warnings ) ) { |
|
| 1390 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1391 | - } |
|
| 1389 | + if( !empty( $warnings ) ) { |
|
| 1390 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1391 | + } |
|
| 1392 | 1392 | |
| 1393 | 1393 | return $return; |
| 1394 | 1394 | } |
@@ -1423,8 +1423,8 @@ discard block |
||
| 1423 | 1423 | $input_id = strval( $input['id'] ); |
| 1424 | 1424 | |
| 1425 | 1425 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1426 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1427 | - $allow_pre_populated = false; |
|
| 1426 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1427 | + $allow_pre_populated = false; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | } |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1449 | 1449 | $categories = array(); |
| 1450 | 1450 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1451 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1451 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1454 | 1454 | } |
@@ -1458,25 +1458,25 @@ discard block |
||
| 1458 | 1458 | // if value is empty get the default value if defined |
| 1459 | 1459 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1460 | 1460 | |
| 1461 | - /** |
|
| 1462 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1463 | - * @since 1.11 |
|
| 1464 | - * @since 1.20 Added third param |
|
| 1465 | - * @param mixed $field_value field value used to populate the input |
|
| 1466 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1467 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1468 | - */ |
|
| 1469 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1470 | - |
|
| 1471 | - /** |
|
| 1472 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1473 | - * @since 1.17 |
|
| 1474 | - * @since 1.20 Added third param |
|
| 1475 | - * @param mixed $field_value field value used to populate the input |
|
| 1476 | - * @param GF_Field $field Gravity Forms field object |
|
| 1477 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1478 | - */ |
|
| 1479 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1461 | + /** |
|
| 1462 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1463 | + * @since 1.11 |
|
| 1464 | + * @since 1.20 Added third param |
|
| 1465 | + * @param mixed $field_value field value used to populate the input |
|
| 1466 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1467 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1468 | + */ |
|
| 1469 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1470 | + |
|
| 1471 | + /** |
|
| 1472 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1473 | + * @since 1.17 |
|
| 1474 | + * @since 1.20 Added third param |
|
| 1475 | + * @param mixed $field_value field value used to populate the input |
|
| 1476 | + * @param GF_Field $field Gravity Forms field object |
|
| 1477 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1478 | + */ |
|
| 1479 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1480 | 1480 | |
| 1481 | 1481 | return $field_value; |
| 1482 | 1482 | } |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1504 | 1504 | // expects certain field array items to be set. |
| 1505 | 1505 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1506 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1506 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1517,61 +1517,61 @@ discard block |
||
| 1517 | 1517 | */ |
| 1518 | 1518 | case 'fileupload': |
| 1519 | 1519 | |
| 1520 | - // Set the previous value |
|
| 1521 | - $entry = $this->get_entry(); |
|
| 1520 | + // Set the previous value |
|
| 1521 | + $entry = $this->get_entry(); |
|
| 1522 | 1522 | |
| 1523 | - $input_name = 'input_'.$field->id; |
|
| 1524 | - $form_id = $form['id']; |
|
| 1523 | + $input_name = 'input_'.$field->id; |
|
| 1524 | + $form_id = $form['id']; |
|
| 1525 | 1525 | |
| 1526 | - $value = NULL; |
|
| 1526 | + $value = NULL; |
|
| 1527 | 1527 | |
| 1528 | - // Use the previous entry value as the default. |
|
| 1529 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1530 | - $value = $entry[ $field->id ]; |
|
| 1531 | - } |
|
| 1528 | + // Use the previous entry value as the default. |
|
| 1529 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1530 | + $value = $entry[ $field->id ]; |
|
| 1531 | + } |
|
| 1532 | 1532 | |
| 1533 | - // If this is a single upload file |
|
| 1534 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1535 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1536 | - $value = $file_path['url']; |
|
| 1533 | + // If this is a single upload file |
|
| 1534 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1535 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1536 | + $value = $file_path['url']; |
|
| 1537 | 1537 | |
| 1538 | - } else { |
|
| 1538 | + } else { |
|
| 1539 | 1539 | |
| 1540 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1541 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1542 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1540 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1541 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1542 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1543 | 1543 | |
| 1544 | - } |
|
| 1544 | + } |
|
| 1545 | 1545 | |
| 1546 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1546 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1547 | 1547 | |
| 1548 | - // If there are fresh uploads, process and merge them. |
|
| 1549 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1550 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1551 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1552 | - $value = stripslashes_deep( $value ); |
|
| 1553 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1554 | - } |
|
| 1548 | + // If there are fresh uploads, process and merge them. |
|
| 1549 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1550 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1551 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1552 | + $value = stripslashes_deep( $value ); |
|
| 1553 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1554 | + } |
|
| 1555 | 1555 | |
| 1556 | - } else { |
|
| 1556 | + } else { |
|
| 1557 | 1557 | |
| 1558 | - // A file already exists when editing an entry |
|
| 1559 | - // We set this to solve issue when file upload fields are required. |
|
| 1560 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1558 | + // A file already exists when editing an entry |
|
| 1559 | + // We set this to solve issue when file upload fields are required. |
|
| 1560 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1561 | 1561 | |
| 1562 | - } |
|
| 1562 | + } |
|
| 1563 | 1563 | |
| 1564 | - $this->entry[ $input_name ] = $value; |
|
| 1565 | - $_POST[ $input_name ] = $value; |
|
| 1564 | + $this->entry[ $input_name ] = $value; |
|
| 1565 | + $_POST[ $input_name ] = $value; |
|
| 1566 | 1566 | |
| 1567 | - break; |
|
| 1567 | + break; |
|
| 1568 | 1568 | |
| 1569 | 1569 | case 'number': |
| 1570 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1571 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1572 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1573 | - } |
|
| 1574 | - break; |
|
| 1570 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1571 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1572 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1573 | + } |
|
| 1574 | + break; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | } |
@@ -1656,43 +1656,43 @@ discard block |
||
| 1656 | 1656 | case 'fileupload' : |
| 1657 | 1657 | case 'post_image': |
| 1658 | 1658 | |
| 1659 | - // in case nothing is uploaded but there are already files saved |
|
| 1660 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1661 | - $field->failed_validation = false; |
|
| 1662 | - unset( $field->validation_message ); |
|
| 1663 | - } |
|
| 1659 | + // in case nothing is uploaded but there are already files saved |
|
| 1660 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1661 | + $field->failed_validation = false; |
|
| 1662 | + unset( $field->validation_message ); |
|
| 1663 | + } |
|
| 1664 | 1664 | |
| 1665 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1666 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1665 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1666 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1667 | 1667 | |
| 1668 | - $input_name = 'input_' . $field->id; |
|
| 1669 | - //uploaded |
|
| 1670 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1668 | + $input_name = 'input_' . $field->id; |
|
| 1669 | + //uploaded |
|
| 1670 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1671 | 1671 | |
| 1672 | - //existent |
|
| 1673 | - $entry = $this->get_entry(); |
|
| 1674 | - $value = NULL; |
|
| 1675 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1676 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1677 | - } |
|
| 1672 | + //existent |
|
| 1673 | + $entry = $this->get_entry(); |
|
| 1674 | + $value = NULL; |
|
| 1675 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1676 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1677 | + } |
|
| 1678 | 1678 | |
| 1679 | - // count uploaded files and existent entry files |
|
| 1680 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1681 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1679 | + // count uploaded files and existent entry files |
|
| 1680 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1681 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1682 | 1682 | |
| 1683 | - if( $count_files > $field->maxFiles ) { |
|
| 1684 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1685 | - $field->failed_validation = 1; |
|
| 1686 | - $gv_valid = false; |
|
| 1683 | + if( $count_files > $field->maxFiles ) { |
|
| 1684 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1685 | + $field->failed_validation = 1; |
|
| 1686 | + $gv_valid = false; |
|
| 1687 | 1687 | |
| 1688 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1689 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1690 | - } |
|
| 1688 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1689 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1690 | + } |
|
| 1691 | 1691 | |
| 1692 | - } |
|
| 1692 | + } |
|
| 1693 | 1693 | |
| 1694 | 1694 | |
| 1695 | - break; |
|
| 1695 | + break; |
|
| 1696 | 1696 | |
| 1697 | 1697 | } |
| 1698 | 1698 | |
@@ -1703,47 +1703,47 @@ discard block |
||
| 1703 | 1703 | |
| 1704 | 1704 | switch ( $field_type ) { |
| 1705 | 1705 | |
| 1706 | - // Captchas don't need to be re-entered. |
|
| 1707 | - case 'captcha': |
|
| 1706 | + // Captchas don't need to be re-entered. |
|
| 1707 | + case 'captcha': |
|
| 1708 | 1708 | |
| 1709 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1710 | - case 'post_image': |
|
| 1711 | - $field->failed_validation = false; |
|
| 1712 | - unset( $field->validation_message ); |
|
| 1713 | - break; |
|
| 1709 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1710 | + case 'post_image': |
|
| 1711 | + $field->failed_validation = false; |
|
| 1712 | + unset( $field->validation_message ); |
|
| 1713 | + break; |
|
| 1714 | 1714 | |
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | // You can't continue inside a switch, so we do it after. |
| 1718 | 1718 | if( empty( $field->failed_validation ) ) { |
| 1719 | - continue; |
|
| 1719 | + continue; |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1723 | 1723 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1724 | 1724 | if( !empty( $field->noDuplicates ) ) { |
| 1725 | 1725 | |
| 1726 | - $entry = $this->get_entry(); |
|
| 1726 | + $entry = $this->get_entry(); |
|
| 1727 | 1727 | |
| 1728 | - // If the value of the entry is the same as the stored value |
|
| 1729 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1730 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1731 | - //if value submitted was not changed, then don't validate |
|
| 1732 | - $field->failed_validation = false; |
|
| 1728 | + // If the value of the entry is the same as the stored value |
|
| 1729 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1730 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1731 | + //if value submitted was not changed, then don't validate |
|
| 1732 | + $field->failed_validation = false; |
|
| 1733 | 1733 | |
| 1734 | - unset( $field->validation_message ); |
|
| 1734 | + unset( $field->validation_message ); |
|
| 1735 | 1735 | |
| 1736 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1736 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1737 | 1737 | |
| 1738 | - continue; |
|
| 1739 | - } |
|
| 1738 | + continue; |
|
| 1739 | + } |
|
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1743 | 1743 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1744 | - unset( $field->validation_message ); |
|
| 1745 | - $field->validation_message = false; |
|
| 1746 | - continue; |
|
| 1744 | + unset( $field->validation_message ); |
|
| 1745 | + $field->validation_message = false; |
|
| 1746 | + continue; |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | $gv_valid = false; |
@@ -1807,8 +1807,8 @@ discard block |
||
| 1807 | 1807 | // Hide fields depending on admin settings |
| 1808 | 1808 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1809 | 1809 | |
| 1810 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1811 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1810 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1811 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1812 | 1812 | |
| 1813 | 1813 | /** |
| 1814 | 1814 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1887,11 +1887,11 @@ discard block |
||
| 1887 | 1887 | // The edit tab has been configured, so we loop through to configured settings |
| 1888 | 1888 | foreach ( $configured_fields as $configured_field ) { |
| 1889 | 1889 | |
| 1890 | - /** @var GF_Field $field */ |
|
| 1891 | - foreach ( $fields as $field ) { |
|
| 1890 | + /** @var GF_Field $field */ |
|
| 1891 | + foreach ( $fields as $field ) { |
|
| 1892 | 1892 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1893 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1894 | - break; |
|
| 1893 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1894 | + break; |
|
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | } |
@@ -1947,28 +1947,28 @@ discard block |
||
| 1947 | 1947 | */ |
| 1948 | 1948 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1949 | 1949 | |
| 1950 | - /** |
|
| 1950 | + /** |
|
| 1951 | 1951 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
| 1952 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1953 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1954 | - * @since 1.9.1 |
|
| 1955 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 1956 | - * @param array $form GF Form array |
|
| 1957 | - * @param int $view_id View ID |
|
| 1958 | - */ |
|
| 1959 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1960 | - |
|
| 1961 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1952 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1953 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1954 | + * @since 1.9.1 |
|
| 1955 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
| 1956 | + * @param array $form GF Form array |
|
| 1957 | + * @param int $view_id View ID |
|
| 1958 | + */ |
|
| 1959 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1960 | + |
|
| 1961 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1962 | 1962 | foreach( $fields as $k => $field ) { |
| 1963 | 1963 | if( $field->adminOnly ) { |
| 1964 | - unset( $fields[ $k ] ); |
|
| 1964 | + unset( $fields[ $k ] ); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | } |
| 1967 | 1967 | return array_values( $fields ); |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - foreach( $fields as &$field ) { |
|
| 1971 | - $field->adminOnly = false; |
|
| 1970 | + foreach( $fields as &$field ) { |
|
| 1971 | + $field->adminOnly = false; |
|
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | 1974 | return $fields; |
@@ -1988,13 +1988,13 @@ discard block |
||
| 1988 | 1988 | */ |
| 1989 | 1989 | private function unselect_default_values( $form ) { |
| 1990 | 1990 | |
| 1991 | - foreach ( $form['fields'] as &$field ) { |
|
| 1991 | + foreach ( $form['fields'] as &$field ) { |
|
| 1992 | 1992 | |
| 1993 | 1993 | if ( empty( $field->choices ) ) { |
| 1994 | - continue; |
|
| 1994 | + continue; |
|
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | - foreach ( $field->choices as &$choice ) { |
|
| 1997 | + foreach ( $field->choices as &$choice ) { |
|
| 1998 | 1998 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1999 | 1999 | $choice['isSelected'] = false; |
| 2000 | 2000 | } |
@@ -2031,36 +2031,36 @@ discard block |
||
| 2031 | 2031 | |
| 2032 | 2032 | if( 'checkbox' === $field->type ) { |
| 2033 | 2033 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2034 | - $input_id = $input['id']; |
|
| 2035 | - $choice = $field->choices[ $key ]; |
|
| 2036 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2037 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2038 | - if( $match ) { |
|
| 2039 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2040 | - } |
|
| 2034 | + $input_id = $input['id']; |
|
| 2035 | + $choice = $field->choices[ $key ]; |
|
| 2036 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2037 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2038 | + if( $match ) { |
|
| 2039 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 2040 | + } |
|
| 2041 | 2041 | } |
| 2042 | 2042 | } else { |
| 2043 | 2043 | |
| 2044 | 2044 | // We need to run through each field to set the default values |
| 2045 | 2045 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2046 | 2046 | |
| 2047 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2047 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2048 | 2048 | |
| 2049 | - if( 'list' === $field->type ) { |
|
| 2050 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 2049 | + if( 'list' === $field->type ) { |
|
| 2050 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 2051 | 2051 | |
| 2052 | - $list_field_value = array(); |
|
| 2053 | - foreach ( (array) $list_rows as $row ) { |
|
| 2054 | - foreach ( (array) $row as $column ) { |
|
| 2055 | - $list_field_value[] = $column; |
|
| 2056 | - } |
|
| 2057 | - } |
|
| 2052 | + $list_field_value = array(); |
|
| 2053 | + foreach ( (array) $list_rows as $row ) { |
|
| 2054 | + foreach ( (array) $row as $column ) { |
|
| 2055 | + $list_field_value[] = $column; |
|
| 2056 | + } |
|
| 2057 | + } |
|
| 2058 | 2058 | |
| 2059 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 2060 | - } else { |
|
| 2061 | - $field->defaultValue = $field_value; |
|
| 2062 | - } |
|
| 2063 | - } |
|
| 2059 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 2060 | + } else { |
|
| 2061 | + $field->defaultValue = $field_value; |
|
| 2062 | + } |
|
| 2063 | + } |
|
| 2064 | 2064 | } |
| 2065 | 2065 | } |
| 2066 | 2066 | } |
@@ -2121,7 +2121,7 @@ discard block |
||
| 2121 | 2121 | foreach ( $form['fields'] as &$field ) { |
| 2122 | 2122 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2123 | 2123 | |
| 2124 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2124 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2125 | 2125 | |
| 2126 | 2126 | if ( $field['id'] == $rule_field_id ) { |
| 2127 | 2127 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2172,7 +2172,7 @@ discard block |
||
| 2172 | 2172 | return $has_conditional_logic; |
| 2173 | 2173 | } |
| 2174 | 2174 | |
| 2175 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2175 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2176 | 2176 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2177 | 2177 | } |
| 2178 | 2178 | |
@@ -2239,14 +2239,14 @@ discard block |
||
| 2239 | 2239 | |
| 2240 | 2240 | if( $echo && $error !== true ) { |
| 2241 | 2241 | |
| 2242 | - $error = esc_html( $error ); |
|
| 2242 | + $error = esc_html( $error ); |
|
| 2243 | 2243 | |
| 2244 | - /** |
|
| 2245 | - * @since 1.9 |
|
| 2246 | - */ |
|
| 2247 | - if ( ! empty( $this->entry ) ) { |
|
| 2248 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 2249 | - } |
|
| 2244 | + /** |
|
| 2245 | + * @since 1.9 |
|
| 2246 | + */ |
|
| 2247 | + if ( ! empty( $this->entry ) ) { |
|
| 2248 | + $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 2249 | + } |
|
| 2250 | 2250 | |
| 2251 | 2251 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2252 | 2252 | } |
@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | function load() { |
| 136 | 136 | |
| 137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 139 | 139 | |
| 140 | 140 | // Don't display an embedded form when editing an entry |
| 141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 142 | 142 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 143 | 143 | |
| 144 | 144 | // Stop Gravity Forms processing what is ours! |
| 145 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 145 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 146 | 146 | |
| 147 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 147 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 148 | 148 | |
| 149 | 149 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
| 150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 156 | 156 | |
| 157 | 157 | // Add fields expected by GFFormDisplay::validate() |
| 158 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 158 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 159 | 159 | |
| 160 | 160 | // Fix multiselect value for GF 2.2 |
| 161 | 161 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | * @return void |
| 173 | 173 | */ |
| 174 | 174 | public function prevent_render_form() { |
| 175 | - if( $this->is_edit_entry() ) { |
|
| 176 | - if( 'wp_head' === current_filter() ) { |
|
| 175 | + if ( $this->is_edit_entry() ) { |
|
| 176 | + if ( 'wp_head' === current_filter() ) { |
|
| 177 | 177 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 178 | 178 | } else { |
| 179 | 179 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function prevent_maybe_process_form() { |
| 190 | 190 | |
| 191 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 191 | + if ( ! $this->is_edit_entry_submission() ) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
| 196 | 196 | |
| 197 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 198 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 197 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 198 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function is_edit_entry() { |
| 206 | 206 | |
| 207 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 207 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 208 | 208 | |
| 209 | 209 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 210 | 210 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @return boolean |
| 216 | 216 | */ |
| 217 | 217 | public function is_edit_entry_submission() { |
| 218 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 218 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | |
| 230 | 230 | $entries = $gravityview_view->getEntries(); |
| 231 | - self::$original_entry = $entries[0]; |
|
| 232 | - $this->entry = $entries[0]; |
|
| 231 | + self::$original_entry = $entries[ 0 ]; |
|
| 232 | + $this->entry = $entries[ 0 ]; |
|
| 233 | 233 | |
| 234 | 234 | self::$original_form = $gravityview_view->getForm(); |
| 235 | 235 | $this->form = $gravityview_view->getForm(); |
| 236 | - $this->form_id = $this->entry['form_id']; |
|
| 236 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
| 237 | 237 | $this->view_id = $gravityview_view->getViewId(); |
| 238 | 238 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 239 | 239 | |
| 240 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 240 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | private function print_scripts() { |
| 297 | 297 | $gravityview_view = GravityView_View::getInstance(); |
| 298 | 298 | |
| 299 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 299 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 300 | 300 | |
| 301 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 301 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 302 | 302 | |
| 303 | 303 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 304 | 304 | |
@@ -314,19 +314,19 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | private function process_save( $gv_data ) { |
| 316 | 316 | |
| 317 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 317 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 318 | 318 | return; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // Make sure the entry, view, and form IDs are all correct |
| 322 | 322 | $valid = $this->verify_nonce(); |
| 323 | 323 | |
| 324 | - if ( !$valid ) { |
|
| 324 | + if ( ! $valid ) { |
|
| 325 | 325 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 326 | 326 | return; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 329 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 330 | 330 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 331 | 331 | return; |
| 332 | 332 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $this->validate(); |
| 339 | 339 | |
| 340 | - if( $this->is_valid ) { |
|
| 340 | + if ( $this->is_valid ) { |
|
| 341 | 341 | |
| 342 | 342 | gravityview()->log->debug( 'Submission is valid.' ); |
| 343 | 343 | |
@@ -349,15 +349,15 @@ discard block |
||
| 349 | 349 | /** |
| 350 | 350 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 351 | 351 | */ |
| 352 | - unset( $_GET['page'] ); |
|
| 352 | + unset( $_GET[ 'page' ] ); |
|
| 353 | 353 | |
| 354 | - $date_created = $this->entry['date_created']; |
|
| 354 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 358 | 358 | * @since 1.17.2 |
| 359 | 359 | */ |
| 360 | - unset( $this->entry['date_created'] ); |
|
| 360 | + unset( $this->entry[ 'date_created' ] ); |
|
| 361 | 361 | |
| 362 | 362 | /** |
| 363 | 363 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -367,14 +367,14 @@ discard block |
||
| 367 | 367 | * @param GravityView_Edit_Entry_Render $this This object |
| 368 | 368 | * @param GravityView_View_Data $gv_data The View data |
| 369 | 369 | */ |
| 370 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
| 370 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 371 | 371 | |
| 372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
| 373 | 373 | |
| 374 | 374 | // Delete the values for hidden inputs |
| 375 | 375 | $this->unset_hidden_field_values(); |
| 376 | 376 | |
| 377 | - $this->entry['date_created'] = $date_created; |
|
| 377 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 378 | 378 | |
| 379 | 379 | // Process calculation fields |
| 380 | 380 | $this->update_calculation_fields(); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | * @param GravityView_Edit_Entry_Render $this This object |
| 397 | 397 | * @param GravityView_View_Data $gv_data The View data |
| 398 | 398 | */ |
| 399 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 399 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 400 | 400 | |
| 401 | 401 | } else { |
| 402 | 402 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -426,16 +426,16 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | $this->unset_hidden_calculations = array(); |
| 428 | 428 | |
| 429 | - if( ! $unset_hidden_field_values ) { |
|
| 429 | + if ( ! $unset_hidden_field_values ) { |
|
| 430 | 430 | return; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 434 | 434 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 435 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 435 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 436 | 436 | } else { |
| 437 | 437 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 438 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 438 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | $empty_value = $field->get_value_save_entry( |
| 454 | 454 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 455 | - $this->form, '', $this->entry['id'], $this->entry |
|
| 455 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
| 456 | 456 | ); |
| 457 | 457 | |
| 458 | 458 | if ( $field->has_calculation() ) { |
| 459 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
| 459 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
| 460 | 460 | $empty_value = ''; |
| 461 | 461 | } |
| 462 | 462 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | /** No file is being uploaded. */ |
| 530 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 530 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 531 | 531 | /** So return the original upload */ |
| 532 | 532 | return $entry[ $input_id ]; |
| 533 | 533 | } |
@@ -545,11 +545,11 @@ discard block |
||
| 545 | 545 | * @return mixed |
| 546 | 546 | */ |
| 547 | 547 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 548 | - if( ! $this->is_edit_entry() ) { |
|
| 548 | + if ( ! $this->is_edit_entry() ) { |
|
| 549 | 549 | return $plupload_init; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 552 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 553 | 553 | |
| 554 | 554 | return $plupload_init; |
| 555 | 555 | } |
@@ -564,27 +564,27 @@ discard block |
||
| 564 | 564 | $form = $this->filter_conditional_logic( $this->form ); |
| 565 | 565 | |
| 566 | 566 | /** @var GF_Field $field */ |
| 567 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 567 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 568 | 568 | |
| 569 | 569 | /** |
| 570 | 570 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 571 | 571 | * @since 1.16.3 |
| 572 | 572 | * @var GF_Field $field |
| 573 | 573 | */ |
| 574 | - if( $field->has_calculation() ) { |
|
| 575 | - unset( $form['fields'][ $k ] ); |
|
| 574 | + if ( $field->has_calculation() ) { |
|
| 575 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | $field->adminOnly = false; |
| 579 | 579 | |
| 580 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 581 | - foreach( $field->inputs as $key => $input ) { |
|
| 582 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 580 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 581 | + foreach ( $field->inputs as $key => $input ) { |
|
| 582 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 587 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 588 | 588 | |
| 589 | 589 | return $form; |
| 590 | 590 | } |
@@ -596,14 +596,14 @@ discard block |
||
| 596 | 596 | $update = false; |
| 597 | 597 | |
| 598 | 598 | // get the most up to date entry values |
| 599 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 599 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 600 | 600 | |
| 601 | 601 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 602 | 602 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 603 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 603 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 604 | 604 | } else { |
| 605 | 605 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 606 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 606 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | |
@@ -620,24 +620,24 @@ discard block |
||
| 620 | 620 | $inputs = $field->get_entry_inputs(); |
| 621 | 621 | if ( is_array( $inputs ) ) { |
| 622 | 622 | foreach ( $inputs as $input ) { |
| 623 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
| 623 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
| 624 | 624 | |
| 625 | 625 | if ( 'product' === $field->type ) { |
| 626 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 626 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 627 | 627 | |
| 628 | 628 | // Only allow quantity to be set if it's allowed to be edited |
| 629 | 629 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 630 | 630 | } else { // otherwise set to what it previously was |
| 631 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 631 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 632 | 632 | } |
| 633 | 633 | } else { |
| 634 | 634 | // Set to what it previously was if it's not editable |
| 635 | 635 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
| 636 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 636 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 640 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 641 | 641 | } |
| 642 | 642 | } else { |
| 643 | 643 | // Set to what it previously was if it's not editable |
@@ -677,19 +677,19 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $input_name = 'input_' . $field_id; |
| 679 | 679 | |
| 680 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 680 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 681 | 681 | |
| 682 | 682 | // We have a new image |
| 683 | 683 | |
| 684 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 684 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 685 | 685 | |
| 686 | 686 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 687 | 687 | $ary = stripslashes_deep( $ary ); |
| 688 | 688 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 689 | 689 | |
| 690 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 691 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 692 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 690 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 691 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 692 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 693 | 693 | |
| 694 | 694 | $image_meta = array( |
| 695 | 695 | 'post_excerpt' => $img_caption, |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 700 | 700 | if ( ! empty( $img_title ) ) { |
| 701 | - $image_meta['post_title'] = $img_title; |
|
| 701 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | */ |
| 757 | 757 | private function maybe_update_post_fields( $form ) { |
| 758 | 758 | |
| 759 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 759 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 760 | 760 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 761 | 761 | return; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - $post_id = $this->entry['post_id']; |
|
| 764 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 765 | 765 | |
| 766 | 766 | // Security check |
| 767 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 767 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 768 | 768 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 769 | 769 | return; |
| 770 | 770 | } |
@@ -777,25 +777,25 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 779 | 779 | |
| 780 | - if( ! $field ) { |
|
| 780 | + if ( ! $field ) { |
|
| 781 | 781 | continue; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 784 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 785 | 785 | |
| 786 | 786 | // Get the value of the field, including $_POSTed value |
| 787 | 787 | $value = RGFormsModel::get_field_value( $field ); |
| 788 | 788 | |
| 789 | 789 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 790 | 790 | $entry_tmp = $this->entry; |
| 791 | - $entry_tmp["{$field_id}"] = $value; |
|
| 791 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 792 | 792 | |
| 793 | - switch( $field->type ) { |
|
| 793 | + switch ( $field->type ) { |
|
| 794 | 794 | |
| 795 | 795 | case 'post_title': |
| 796 | 796 | $post_title = $value; |
| 797 | 797 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 798 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 798 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 799 | 799 | } |
| 800 | 800 | $updated_post->post_title = $post_title; |
| 801 | 801 | $updated_post->post_name = $post_title; |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | case 'post_content': |
| 806 | 806 | $post_content = $value; |
| 807 | 807 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 808 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 808 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 809 | 809 | } |
| 810 | 810 | $updated_post->post_content = $post_content; |
| 811 | 811 | unset( $post_content ); |
@@ -823,11 +823,11 @@ discard block |
||
| 823 | 823 | $value = $value[ $field_id ]; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 826 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 827 | 827 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
| 830 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
| 831 | 831 | |
| 832 | 832 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
| 833 | 833 | break; |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | // update entry after |
| 842 | - $this->entry["{$field_id}"] = $value; |
|
| 842 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 843 | 843 | |
| 844 | 844 | $update_entry = true; |
| 845 | 845 | |
@@ -848,11 +848,11 @@ discard block |
||
| 848 | 848 | |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - if( $update_entry ) { |
|
| 851 | + if ( $update_entry ) { |
|
| 852 | 852 | |
| 853 | 853 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 854 | 854 | |
| 855 | - if( is_wp_error( $return_entry ) ) { |
|
| 855 | + if ( is_wp_error( $return_entry ) ) { |
|
| 856 | 856 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 857 | 857 | } else { |
| 858 | 858 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $return_post = wp_update_post( $updated_post, true ); |
| 864 | 864 | |
| 865 | - if( is_wp_error( $return_post ) ) { |
|
| 865 | + if ( is_wp_error( $return_post ) ) { |
|
| 866 | 866 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 867 | 867 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 868 | 868 | } else { |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 897 | 897 | |
| 898 | 898 | // replace conditional shortcodes |
| 899 | - if( $do_shortcode ) { |
|
| 899 | + if ( $do_shortcode ) { |
|
| 900 | 900 | $output = do_shortcode( $output ); |
| 901 | 901 | } |
| 902 | 902 | |
@@ -915,19 +915,19 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | private function after_update() { |
| 917 | 917 | |
| 918 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 919 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 918 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 919 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 920 | 920 | |
| 921 | 921 | // Re-define the entry now that we've updated it. |
| 922 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 922 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 923 | 923 | |
| 924 | 924 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
| 925 | 925 | |
| 926 | 926 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 927 | 927 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 928 | 928 | // we have just updated. |
| 929 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 930 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 929 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 930 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | |
@@ -937,11 +937,11 @@ discard block |
||
| 937 | 937 | * @since develop |
| 938 | 938 | */ |
| 939 | 939 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
| 940 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
| 940 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
| 941 | 941 | if ( ! is_wp_error( $feeds ) ) { |
| 942 | 942 | $registered_feeds = array(); |
| 943 | 943 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
| 944 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 944 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 945 | 945 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
| 946 | 946 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
| 947 | 947 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -949,8 +949,8 @@ discard block |
||
| 949 | 949 | } |
| 950 | 950 | } |
| 951 | 951 | foreach ( $feeds as $feed ) { |
| 952 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
| 953 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
| 952 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
| 953 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
| 954 | 954 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
| 955 | 955 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
| 956 | 956 | $entry = $returned_entry; |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | |
| 981 | 981 | <div class="gv-edit-entry-wrapper"><?php |
| 982 | 982 | |
| 983 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 983 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 984 | 984 | |
| 985 | 985 | /** |
| 986 | 986 | * Fixes weird wpautop() issue |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 997 | 997 | * @param GravityView_Edit_Entry_Render $this This object |
| 998 | 998 | */ |
| 999 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 999 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 1000 | 1000 | |
| 1001 | 1001 | echo esc_attr( $edit_entry_title ); |
| 1002 | 1002 | ?></span> |
@@ -1062,18 +1062,18 @@ discard block |
||
| 1062 | 1062 | */ |
| 1063 | 1063 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1064 | 1064 | |
| 1065 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
| 1065 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 1069 | 1069 | |
| 1070 | - if( ! $this->is_valid ){ |
|
| 1070 | + if ( ! $this->is_valid ) { |
|
| 1071 | 1071 | |
| 1072 | 1072 | // Keeping this compatible with Gravity Forms. |
| 1073 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 1074 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 1073 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 1074 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 1075 | 1075 | |
| 1076 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 1076 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 1077 | 1077 | |
| 1078 | 1078 | } elseif ( false === $this->is_paged_submitted ) { |
| 1079 | 1079 | // Paged form that hasn't been submitted on the last page yet |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | * @param int $view_id View ID |
| 1087 | 1087 | * @param array $entry Gravity Forms entry array |
| 1088 | 1088 | */ |
| 1089 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
| 1089 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
| 1090 | 1090 | |
| 1091 | 1091 | echo GVCommon::generate_notice( $message ); |
| 1092 | 1092 | } else { |
@@ -1098,23 +1098,23 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | case '0': |
| 1100 | 1100 | $redirect_url = $back_link; |
| 1101 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1101 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
| 1102 | 1102 | break; |
| 1103 | 1103 | |
| 1104 | 1104 | case '1': |
| 1105 | 1105 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
| 1106 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1106 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1107 | 1107 | break; |
| 1108 | 1108 | |
| 1109 | 1109 | case '2': |
| 1110 | 1110 | $redirect_url = $edit_redirect_url; |
| 1111 | 1111 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
| 1112 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1112 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1113 | 1113 | break; |
| 1114 | 1114 | |
| 1115 | 1115 | case '': |
| 1116 | 1116 | default: |
| 1117 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1117 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1118 | 1118 | break; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | * @param array $entry Gravity Forms entry array |
| 1131 | 1131 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 1132 | 1132 | */ |
| 1133 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1133 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1134 | 1134 | |
| 1135 | 1135 | echo GVCommon::generate_notice( $message ); |
| 1136 | 1136 | } |
@@ -1154,8 +1154,8 @@ discard block |
||
| 1154 | 1154 | */ |
| 1155 | 1155 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1156 | 1156 | |
| 1157 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1158 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1157 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1158 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1159 | 1159 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1160 | 1160 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
| 1161 | 1161 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1164,14 +1164,14 @@ discard block |
||
| 1164 | 1164 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1165 | 1165 | |
| 1166 | 1166 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1167 | - unset( $_GET['page'] ); |
|
| 1167 | + unset( $_GET[ 'page' ] ); |
|
| 1168 | 1168 | |
| 1169 | 1169 | $this->show_next_button = false; |
| 1170 | 1170 | $this->show_previous_button = false; |
| 1171 | 1171 | |
| 1172 | 1172 | // TODO: Verify multiple-page forms |
| 1173 | 1173 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
| 1174 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
| 1174 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
| 1175 | 1175 | |
| 1176 | 1176 | $labels = array( |
| 1177 | 1177 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1190,16 +1190,16 @@ discard block |
||
| 1190 | 1190 | */ |
| 1191 | 1191 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1192 | 1192 | |
| 1193 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
| 1194 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
| 1193 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
| 1194 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
| 1195 | 1195 | |
| 1196 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
| 1196 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
| 1197 | 1197 | $page_number++; |
| 1198 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
| 1198 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
| 1199 | 1199 | $page_number--; |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number; |
|
| 1202 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | |
| 1226 | 1226 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1227 | 1227 | |
| 1228 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1228 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1229 | 1229 | |
| 1230 | 1230 | ob_get_clean(); |
| 1231 | 1231 | |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | * @return string |
| 1254 | 1254 | */ |
| 1255 | 1255 | public function render_form_buttons() { |
| 1256 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1256 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | |
@@ -1273,10 +1273,10 @@ discard block |
||
| 1273 | 1273 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1274 | 1274 | |
| 1275 | 1275 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1276 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
| 1276 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
| 1277 | 1277 | $form = $this->form_after_validation; |
| 1278 | 1278 | } else { |
| 1279 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1279 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | $form = $this->filter_conditional_logic( $form ); |
@@ -1284,8 +1284,8 @@ discard block |
||
| 1284 | 1284 | $form = $this->prefill_conditional_logic( $form ); |
| 1285 | 1285 | |
| 1286 | 1286 | // for now we don't support Save and Continue feature. |
| 1287 | - if( ! self::$supports_save_and_continue ) { |
|
| 1288 | - unset( $form['save'] ); |
|
| 1287 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1288 | + unset( $form[ 'save' ] ); |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | $form = $this->unselect_default_values( $form ); |
@@ -1308,31 +1308,31 @@ discard block |
||
| 1308 | 1308 | */ |
| 1309 | 1309 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1310 | 1310 | |
| 1311 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1311 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1312 | 1312 | return $field_content; |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | $message = null; |
| 1316 | 1316 | |
| 1317 | 1317 | // First, make sure they have the capability to edit the post. |
| 1318 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1318 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1319 | 1319 | |
| 1320 | 1320 | /** |
| 1321 | 1321 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1322 | 1322 | * @param string $message The existing "You don't have permission..." text |
| 1323 | 1323 | */ |
| 1324 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1324 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1325 | 1325 | |
| 1326 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1326 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1327 | 1327 | /** |
| 1328 | 1328 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1329 | 1329 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1330 | 1330 | */ |
| 1331 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1331 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - if( $message ) { |
|
| 1335 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1334 | + if ( $message ) { |
|
| 1335 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | return $field_content; |
@@ -1356,8 +1356,8 @@ discard block |
||
| 1356 | 1356 | |
| 1357 | 1357 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1358 | 1358 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1359 | - if( |
|
| 1360 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1359 | + if ( |
|
| 1360 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1361 | 1361 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1362 | 1362 | && ! GFCommon::is_product_field( $field->type ) |
| 1363 | 1363 | || ! empty( $field_content ) |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | $return = null; |
| 1378 | 1378 | |
| 1379 | 1379 | /** @var GravityView_Field $gv_field */ |
| 1380 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1380 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1381 | 1381 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1382 | 1382 | } else { |
| 1383 | 1383 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | // If there was output, it's an error |
| 1387 | 1387 | $warnings = ob_get_clean(); |
| 1388 | 1388 | |
| 1389 | - if( !empty( $warnings ) ) { |
|
| 1389 | + if ( ! empty( $warnings ) ) { |
|
| 1390 | 1390 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1391 | 1391 | } |
| 1392 | 1392 | |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1412 | 1412 | |
| 1413 | 1413 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1414 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1414 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1415 | 1415 | |
| 1416 | 1416 | $field_value = array(); |
| 1417 | 1417 | |
@@ -1420,10 +1420,10 @@ discard block |
||
| 1420 | 1420 | |
| 1421 | 1421 | foreach ( (array)$field->inputs as $input ) { |
| 1422 | 1422 | |
| 1423 | - $input_id = strval( $input['id'] ); |
|
| 1423 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1424 | 1424 | |
| 1425 | 1425 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1426 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1426 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1427 | 1427 | $allow_pre_populated = false; |
| 1428 | 1428 | } |
| 1429 | 1429 | |
@@ -1431,7 +1431,7 @@ discard block |
||
| 1431 | 1431 | |
| 1432 | 1432 | $pre_value = $field->get_value_submission( array(), false ); |
| 1433 | 1433 | |
| 1434 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1434 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1435 | 1435 | |
| 1436 | 1436 | } else { |
| 1437 | 1437 | |
@@ -1442,13 +1442,13 @@ discard block |
||
| 1442 | 1442 | |
| 1443 | 1443 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1444 | 1444 | // or pre-populated value if not empty and set to override saved value |
| 1445 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1445 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1446 | 1446 | |
| 1447 | 1447 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1448 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1448 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1449 | 1449 | $categories = array(); |
| 1450 | 1450 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1451 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1451 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1454 | 1454 | } |
@@ -1476,7 +1476,7 @@ discard block |
||
| 1476 | 1476 | * @param GF_Field $field Gravity Forms field object |
| 1477 | 1477 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1478 | 1478 | */ |
| 1479 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1479 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1480 | 1480 | |
| 1481 | 1481 | return $field_value; |
| 1482 | 1482 | } |
@@ -1493,12 +1493,12 @@ discard block |
||
| 1493 | 1493 | */ |
| 1494 | 1494 | public function gform_pre_validation( $form ) { |
| 1495 | 1495 | |
| 1496 | - if( ! $this->verify_nonce() ) { |
|
| 1496 | + if ( ! $this->verify_nonce() ) { |
|
| 1497 | 1497 | return $form; |
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | // Fix PHP warning regarding undefined index. |
| 1501 | - foreach ( $form['fields'] as &$field) { |
|
| 1501 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1502 | 1502 | |
| 1503 | 1503 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1504 | 1504 | // expects certain field array items to be set. |
@@ -1506,7 +1506,7 @@ discard block |
||
| 1506 | 1506 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1509 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1510 | 1510 | |
| 1511 | 1511 | /** |
| 1512 | 1512 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1520,26 +1520,26 @@ discard block |
||
| 1520 | 1520 | // Set the previous value |
| 1521 | 1521 | $entry = $this->get_entry(); |
| 1522 | 1522 | |
| 1523 | - $input_name = 'input_'.$field->id; |
|
| 1524 | - $form_id = $form['id']; |
|
| 1523 | + $input_name = 'input_' . $field->id; |
|
| 1524 | + $form_id = $form[ 'id' ]; |
|
| 1525 | 1525 | |
| 1526 | 1526 | $value = NULL; |
| 1527 | 1527 | |
| 1528 | 1528 | // Use the previous entry value as the default. |
| 1529 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1529 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1530 | 1530 | $value = $entry[ $field->id ]; |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | // If this is a single upload file |
| 1534 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1535 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1536 | - $value = $file_path['url']; |
|
| 1534 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1535 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1536 | + $value = $file_path[ 'url' ]; |
|
| 1537 | 1537 | |
| 1538 | 1538 | } else { |
| 1539 | 1539 | |
| 1540 | 1540 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1541 | 1541 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1542 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1542 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1543 | 1543 | |
| 1544 | 1544 | } |
| 1545 | 1545 | |
@@ -1547,10 +1547,10 @@ discard block |
||
| 1547 | 1547 | |
| 1548 | 1548 | // If there are fresh uploads, process and merge them. |
| 1549 | 1549 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1550 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1550 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1551 | 1551 | $value = empty( $value ) ? '[]' : $value; |
| 1552 | 1552 | $value = stripslashes_deep( $value ); |
| 1553 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1553 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | 1556 | } else { |
@@ -1568,8 +1568,8 @@ discard block |
||
| 1568 | 1568 | |
| 1569 | 1569 | case 'number': |
| 1570 | 1570 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1571 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1572 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1571 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1572 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1573 | 1573 | } |
| 1574 | 1574 | break; |
| 1575 | 1575 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | * You can enter whatever you want! |
| 1607 | 1607 | * We try validating, and customize the results using `self::custom_validation()` |
| 1608 | 1608 | */ |
| 1609 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1609 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1610 | 1610 | |
| 1611 | 1611 | // Needed by the validate funtion |
| 1612 | 1612 | $failed_validation_page = NULL; |
@@ -1614,14 +1614,14 @@ discard block |
||
| 1614 | 1614 | |
| 1615 | 1615 | // Prevent entry limit from running when editing an entry, also |
| 1616 | 1616 | // prevent form scheduling from preventing editing |
| 1617 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1617 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1618 | 1618 | |
| 1619 | 1619 | // Hide fields depending on Edit Entry settings |
| 1620 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1620 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1621 | 1621 | |
| 1622 | 1622 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1623 | 1623 | |
| 1624 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1624 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | |
| 1645 | 1645 | $gv_valid = true; |
| 1646 | 1646 | |
| 1647 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1647 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1648 | 1648 | |
| 1649 | 1649 | $value = RGFormsModel::get_field_value( $field ); |
| 1650 | 1650 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1657,22 +1657,22 @@ discard block |
||
| 1657 | 1657 | case 'post_image': |
| 1658 | 1658 | |
| 1659 | 1659 | // in case nothing is uploaded but there are already files saved |
| 1660 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1660 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1661 | 1661 | $field->failed_validation = false; |
| 1662 | 1662 | unset( $field->validation_message ); |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | 1665 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1666 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1666 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1667 | 1667 | |
| 1668 | 1668 | $input_name = 'input_' . $field->id; |
| 1669 | 1669 | //uploaded |
| 1670 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1670 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1671 | 1671 | |
| 1672 | 1672 | //existent |
| 1673 | 1673 | $entry = $this->get_entry(); |
| 1674 | 1674 | $value = NULL; |
| 1675 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1675 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1676 | 1676 | $value = json_decode( $entry[ $field->id ], true ); |
| 1677 | 1677 | } |
| 1678 | 1678 | |
@@ -1680,13 +1680,13 @@ discard block |
||
| 1680 | 1680 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
| 1681 | 1681 | ( is_array( $value ) ? count( $value ) : 0 ); |
| 1682 | 1682 | |
| 1683 | - if( $count_files > $field->maxFiles ) { |
|
| 1683 | + if ( $count_files > $field->maxFiles ) { |
|
| 1684 | 1684 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1685 | 1685 | $field->failed_validation = 1; |
| 1686 | 1686 | $gv_valid = false; |
| 1687 | 1687 | |
| 1688 | 1688 | // in case of error make sure the newest upload files are removed from the upload input |
| 1689 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1689 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | } |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | // This field has failed validation. |
| 1700 | - if( !empty( $field->failed_validation ) ) { |
|
| 1700 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1701 | 1701 | |
| 1702 | 1702 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1703 | 1703 | |
@@ -1715,19 +1715,19 @@ discard block |
||
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | // You can't continue inside a switch, so we do it after. |
| 1718 | - if( empty( $field->failed_validation ) ) { |
|
| 1718 | + if ( empty( $field->failed_validation ) ) { |
|
| 1719 | 1719 | continue; |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1723 | 1723 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1724 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1724 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1725 | 1725 | |
| 1726 | 1726 | $entry = $this->get_entry(); |
| 1727 | 1727 | |
| 1728 | 1728 | // If the value of the entry is the same as the stored value |
| 1729 | 1729 | // Then we can assume it's not a duplicate, it's the same. |
| 1730 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1730 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1731 | 1731 | //if value submitted was not changed, then don't validate |
| 1732 | 1732 | $field->failed_validation = false; |
| 1733 | 1733 | |
@@ -1740,7 +1740,7 @@ discard block |
||
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1743 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1743 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1744 | 1744 | unset( $field->validation_message ); |
| 1745 | 1745 | $field->validation_message = false; |
| 1746 | 1746 | continue; |
@@ -1752,12 +1752,12 @@ discard block |
||
| 1752 | 1752 | |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1755 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1756 | 1756 | |
| 1757 | 1757 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1758 | 1758 | |
| 1759 | 1759 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1760 | - $this->form_after_validation = $validation_results['form']; |
|
| 1760 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1761 | 1761 | |
| 1762 | 1762 | return $validation_results; |
| 1763 | 1763 | } |
@@ -1770,7 +1770,7 @@ discard block |
||
| 1770 | 1770 | */ |
| 1771 | 1771 | public function get_entry() { |
| 1772 | 1772 | |
| 1773 | - if( empty( $this->entry ) ) { |
|
| 1773 | + if ( empty( $this->entry ) ) { |
|
| 1774 | 1774 | // Get the database value of the entry that's being edited |
| 1775 | 1775 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1776 | 1776 | } |
@@ -1802,10 +1802,10 @@ discard block |
||
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | // If edit tab not yet configured, show all fields |
| 1805 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1805 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1806 | 1806 | |
| 1807 | 1807 | // Hide fields depending on admin settings |
| 1808 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1808 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1809 | 1809 | |
| 1810 | 1810 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1811 | 1811 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1838,7 +1838,7 @@ discard block |
||
| 1838 | 1838 | */ |
| 1839 | 1839 | private function filter_fields( $fields, $configured_fields ) { |
| 1840 | 1840 | |
| 1841 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1841 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1842 | 1842 | return $fields; |
| 1843 | 1843 | } |
| 1844 | 1844 | |
@@ -1855,12 +1855,12 @@ discard block |
||
| 1855 | 1855 | |
| 1856 | 1856 | // Remove the fields that have calculation properties and keep them to be used later |
| 1857 | 1857 | // @since 1.16.2 |
| 1858 | - if( $field->has_calculation() ) { |
|
| 1859 | - $this->fields_with_calculation[] = $field; |
|
| 1858 | + if ( $field->has_calculation() ) { |
|
| 1859 | + $this->fields_with_calculation[ ] = $field; |
|
| 1860 | 1860 | // don't remove the calculation fields on form render. |
| 1861 | 1861 | } |
| 1862 | 1862 | |
| 1863 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1863 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1864 | 1864 | unset( $fields[ $key ] ); |
| 1865 | 1865 | } |
| 1866 | 1866 | } |
@@ -1878,7 +1878,7 @@ discard block |
||
| 1878 | 1878 | continue; // Same |
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | - $out_fields[] = $field; |
|
| 1881 | + $out_fields[ ] = $field; |
|
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | 1884 | return array_values( $out_fields ); |
@@ -1889,8 +1889,8 @@ discard block |
||
| 1889 | 1889 | |
| 1890 | 1890 | /** @var GF_Field $field */ |
| 1891 | 1891 | foreach ( $fields as $field ) { |
| 1892 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1893 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1892 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1893 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1894 | 1894 | break; |
| 1895 | 1895 | } |
| 1896 | 1896 | |
@@ -1913,14 +1913,14 @@ discard block |
||
| 1913 | 1913 | |
| 1914 | 1914 | $return_field = $field; |
| 1915 | 1915 | |
| 1916 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1916 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1917 | 1917 | $return_field->label = ''; |
| 1918 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1919 | - $return_field->label = $field_setting['custom_label']; |
|
| 1918 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1919 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1920 | 1920 | } |
| 1921 | 1921 | |
| 1922 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1923 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1922 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1923 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | 1926 | /** |
@@ -1958,16 +1958,16 @@ discard block |
||
| 1958 | 1958 | */ |
| 1959 | 1959 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1960 | 1960 | |
| 1961 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1962 | - foreach( $fields as $k => $field ) { |
|
| 1963 | - if( $field->adminOnly ) { |
|
| 1961 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1962 | + foreach ( $fields as $k => $field ) { |
|
| 1963 | + if ( $field->adminOnly ) { |
|
| 1964 | 1964 | unset( $fields[ $k ] ); |
| 1965 | 1965 | } |
| 1966 | 1966 | } |
| 1967 | 1967 | return array_values( $fields ); |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - foreach( $fields as &$field ) { |
|
| 1970 | + foreach ( $fields as &$field ) { |
|
| 1971 | 1971 | $field->adminOnly = false; |
| 1972 | 1972 | } |
| 1973 | 1973 | |
@@ -1988,7 +1988,7 @@ discard block |
||
| 1988 | 1988 | */ |
| 1989 | 1989 | private function unselect_default_values( $form ) { |
| 1990 | 1990 | |
| 1991 | - foreach ( $form['fields'] as &$field ) { |
|
| 1991 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1992 | 1992 | |
| 1993 | 1993 | if ( empty( $field->choices ) ) { |
| 1994 | 1994 | continue; |
@@ -1996,7 +1996,7 @@ discard block |
||
| 1996 | 1996 | |
| 1997 | 1997 | foreach ( $field->choices as &$choice ) { |
| 1998 | 1998 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1999 | - $choice['isSelected'] = false; |
|
| 1999 | + $choice[ 'isSelected' ] = false; |
|
| 2000 | 2000 | } |
| 2001 | 2001 | } |
| 2002 | 2002 | } |
@@ -2021,22 +2021,22 @@ discard block |
||
| 2021 | 2021 | */ |
| 2022 | 2022 | function prefill_conditional_logic( $form ) { |
| 2023 | 2023 | |
| 2024 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2024 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2025 | 2025 | return $form; |
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 2029 | 2029 | /** @var GF_Field $field */ |
| 2030 | - foreach ( $form['fields'] as &$field ) { |
|
| 2030 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2031 | 2031 | |
| 2032 | - if( 'checkbox' === $field->type ) { |
|
| 2032 | + if ( 'checkbox' === $field->type ) { |
|
| 2033 | 2033 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2034 | - $input_id = $input['id']; |
|
| 2034 | + $input_id = $input[ 'id' ]; |
|
| 2035 | 2035 | $choice = $field->choices[ $key ]; |
| 2036 | 2036 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 2037 | 2037 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 2038 | - if( $match ) { |
|
| 2039 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2038 | + if ( $match ) { |
|
| 2039 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | } |
| 2042 | 2042 | } else { |
@@ -2044,15 +2044,15 @@ discard block |
||
| 2044 | 2044 | // We need to run through each field to set the default values |
| 2045 | 2045 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2046 | 2046 | |
| 2047 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2047 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2048 | 2048 | |
| 2049 | - if( 'list' === $field->type ) { |
|
| 2049 | + if ( 'list' === $field->type ) { |
|
| 2050 | 2050 | $list_rows = maybe_unserialize( $field_value ); |
| 2051 | 2051 | |
| 2052 | 2052 | $list_field_value = array(); |
| 2053 | - foreach ( (array) $list_rows as $row ) { |
|
| 2054 | - foreach ( (array) $row as $column ) { |
|
| 2055 | - $list_field_value[] = $column; |
|
| 2053 | + foreach ( (array)$list_rows as $row ) { |
|
| 2054 | + foreach ( (array)$row as $column ) { |
|
| 2055 | + $list_field_value[ ] = $column; |
|
| 2056 | 2056 | } |
| 2057 | 2057 | } |
| 2058 | 2058 | |
@@ -2085,32 +2085,32 @@ discard block |
||
| 2085 | 2085 | * @see https://github.com/gravityview/GravityView/issues/840 |
| 2086 | 2086 | * @since develop |
| 2087 | 2087 | */ |
| 2088 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
| 2088 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
| 2089 | 2089 | $editable_ids = array(); |
| 2090 | - foreach ( $form['fields'] as $field ) { |
|
| 2091 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
| 2090 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 2091 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
| 2092 | 2092 | } |
| 2093 | 2093 | $remove_conditions_rule = array(); |
| 2094 | - foreach ( $the_form['fields'] as $field ) { |
|
| 2095 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
| 2096 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
| 2097 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
| 2094 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
| 2095 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
| 2096 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
| 2097 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
| 2098 | 2098 | /** |
| 2099 | 2099 | * This conditional field is not editable in this View. |
| 2100 | 2100 | * We need to remove the rule, but only if it matches. |
| 2101 | 2101 | */ |
| 2102 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
| 2102 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
| 2103 | 2103 | $value = $_field->get_value_export( $this->entry ); |
| 2104 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
| 2105 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
| 2104 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
| 2105 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
| 2106 | 2106 | } else { |
| 2107 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
| 2107 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
| 2108 | 2108 | } |
| 2109 | 2109 | |
| 2110 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
| 2110 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
| 2111 | 2111 | |
| 2112 | 2112 | if ( $match ) { |
| 2113 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
| 2113 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
| 2114 | 2114 | } |
| 2115 | 2115 | } |
| 2116 | 2116 | } |
@@ -2118,21 +2118,21 @@ discard block |
||
| 2118 | 2118 | } |
| 2119 | 2119 | |
| 2120 | 2120 | if ( $remove_conditions_rule ) { |
| 2121 | - foreach ( $form['fields'] as &$field ) { |
|
| 2121 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2122 | 2122 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2123 | 2123 | |
| 2124 | 2124 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
| 2125 | 2125 | |
| 2126 | - if ( $field['id'] == $rule_field_id ) { |
|
| 2127 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
| 2128 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
| 2126 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
| 2127 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
| 2128 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | } |
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | 2134 | /** Normalize the indices... */ |
| 2135 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 2135 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 2136 | 2136 | |
| 2137 | 2137 | /** |
| 2138 | 2138 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2142,16 +2142,16 @@ discard block |
||
| 2142 | 2142 | */ |
| 2143 | 2143 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 2144 | 2144 | |
| 2145 | - if( $use_conditional_logic ) { |
|
| 2145 | + if ( $use_conditional_logic ) { |
|
| 2146 | 2146 | return $form; |
| 2147 | 2147 | } |
| 2148 | 2148 | |
| 2149 | - foreach( $form['fields'] as &$field ) { |
|
| 2149 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2150 | 2150 | /* @var GF_Field $field */ |
| 2151 | 2151 | $field->conditionalLogic = null; |
| 2152 | 2152 | } |
| 2153 | 2153 | |
| 2154 | - unset( $form['button']['conditionalLogic'] ); |
|
| 2154 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 2155 | 2155 | |
| 2156 | 2156 | return $form; |
| 2157 | 2157 | |
@@ -2168,7 +2168,7 @@ discard block |
||
| 2168 | 2168 | */ |
| 2169 | 2169 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 2170 | 2170 | |
| 2171 | - if( ! $this->is_edit_entry() ) { |
|
| 2171 | + if ( ! $this->is_edit_entry() ) { |
|
| 2172 | 2172 | return $has_conditional_logic; |
| 2173 | 2173 | } |
| 2174 | 2174 | |
@@ -2200,44 +2200,44 @@ discard block |
||
| 2200 | 2200 | * 2. There are two entries embedded using oEmbed |
| 2201 | 2201 | * 3. One of the entries has just been saved |
| 2202 | 2202 | */ |
| 2203 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 2203 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 2204 | 2204 | |
| 2205 | 2205 | $error = true; |
| 2206 | 2206 | |
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 2209 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 2210 | 2210 | |
| 2211 | 2211 | $error = true; |
| 2212 | 2212 | |
| 2213 | - } elseif( ! $this->verify_nonce() ) { |
|
| 2213 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 2214 | 2214 | |
| 2215 | 2215 | /** |
| 2216 | 2216 | * If the Entry is embedded, there may be two entries on the same page. |
| 2217 | 2217 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 2218 | 2218 | */ |
| 2219 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2219 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2220 | 2220 | $error = true; |
| 2221 | 2221 | } else { |
| 2222 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 2222 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2228 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 2227 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2228 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | - if( $this->entry['status'] === 'trash' ) { |
|
| 2232 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2231 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 2232 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | 2235 | // No errors; everything's fine here! |
| 2236 | - if( empty( $error ) ) { |
|
| 2236 | + if ( empty( $error ) ) { |
|
| 2237 | 2237 | return true; |
| 2238 | 2238 | } |
| 2239 | 2239 | |
| 2240 | - if( $echo && $error !== true ) { |
|
| 2240 | + if ( $echo && $error !== true ) { |
|
| 2241 | 2241 | |
| 2242 | 2242 | $error = esc_html( $error ); |
| 2243 | 2243 | |
@@ -2245,10 +2245,10 @@ discard block |
||
| 2245 | 2245 | * @since 1.9 |
| 2246 | 2246 | */ |
| 2247 | 2247 | if ( ! empty( $this->entry ) ) { |
| 2248 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 2248 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2251 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2268,17 +2268,17 @@ discard block |
||
| 2268 | 2268 | |
| 2269 | 2269 | $error = NULL; |
| 2270 | 2270 | |
| 2271 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2272 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2271 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2272 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2273 | 2273 | } |
| 2274 | 2274 | |
| 2275 | 2275 | // No errors; everything's fine here! |
| 2276 | - if( empty( $error ) ) { |
|
| 2276 | + if ( empty( $error ) ) { |
|
| 2277 | 2277 | return true; |
| 2278 | 2278 | } |
| 2279 | 2279 | |
| 2280 | - if( $echo ) { |
|
| 2281 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2280 | + if ( $echo ) { |
|
| 2281 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2299,14 +2299,14 @@ discard block |
||
| 2299 | 2299 | private function check_user_cap_edit_field( $field ) { |
| 2300 | 2300 | |
| 2301 | 2301 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2302 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2302 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2303 | 2303 | return true; |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2306 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2307 | 2307 | |
| 2308 | - if( $field_cap ) { |
|
| 2309 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2308 | + if ( $field_cap ) { |
|
| 2309 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2310 | 2310 | } |
| 2311 | 2311 | |
| 2312 | 2312 | return false; |
@@ -2320,17 +2320,17 @@ discard block |
||
| 2320 | 2320 | public function verify_nonce() { |
| 2321 | 2321 | |
| 2322 | 2322 | // Verify form submitted for editing single |
| 2323 | - if( $this->is_edit_entry_submission() ) { |
|
| 2323 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2324 | 2324 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | 2327 | // Verify |
| 2328 | - else if( ! $this->is_edit_entry() ) { |
|
| 2328 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2329 | 2329 | $valid = false; |
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | 2332 | else { |
| 2333 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2333 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2334 | 2334 | } |
| 2335 | 2335 | |
| 2336 | 2336 | /** |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | gravityview()->log->debug( '$passed_atts: ', array( 'data' => $passed_atts ) ); |
| 49 | 49 | |
| 50 | 50 | // Get details about the current View |
| 51 | - if( !empty( $passed_atts['detail'] ) ) { |
|
| 52 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
| 51 | + if ( ! empty( $passed_atts[ 'detail' ] ) ) { |
|
| 52 | + return $this->get_view_detail( $passed_atts[ 'detail' ] ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
@@ -85,16 +85,16 @@ discard block |
||
| 85 | 85 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
| 86 | 86 | |
| 87 | 87 | // Only keep the passed attributes after making sure that they're valid pairs |
| 88 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
| 88 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
| 89 | 89 | |
| 90 | 90 | $atts = array(); |
| 91 | 91 | |
| 92 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
| 92 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
| 93 | 93 | |
| 94 | 94 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
| 95 | 95 | $passed_value = GravityView_Merge_Tags::replace_variables( $passed_value ); |
| 96 | 96 | |
| 97 | - switch( $defaults[ $key ]['type'] ) { |
|
| 97 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Make sure number fields are numeric. |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
| 103 | 103 | */ |
| 104 | 104 | case 'number': |
| 105 | - if( is_numeric( $passed_value ) ) { |
|
| 105 | + if ( is_numeric( $passed_value ) ) { |
|
| 106 | 106 | $atts[ $key ] = ( $passed_value + 0 ); |
| 107 | 107 | } |
| 108 | 108 | break; |
| 109 | 109 | |
| 110 | 110 | /** @since 2.1 */ |
| 111 | 111 | case 'operator': |
| 112 | - if( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
| 112 | + if ( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
| 113 | 113 | $atts[ $key ] = $passed_value; |
| 114 | 114 | } |
| 115 | 115 | break; |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | case 'select': |
| 126 | 126 | case 'radio': |
| 127 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
| 128 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 127 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
| 128 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 129 | 129 | $atts[ $key ] = $passed_value; |
| 130 | 130 | } |
| 131 | 131 | break; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $gravityview_view = GravityView_View::getInstance(); |
| 155 | 155 | $return = ''; |
| 156 | 156 | |
| 157 | - switch( $detail ) { |
|
| 157 | + switch ( $detail ) { |
|
| 158 | 158 | case 'total_entries': |
| 159 | 159 | $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
| 160 | 160 | break; |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | abstract class GravityView_Extension extends \GV\Extension { |
| 16 | 16 | public function __construct() { |
| 17 | - if( ! in_array( $this->_author, array( 'GravityView', 'Katz Web Services, Inc.', true ) ) ) { |
|
| 17 | + if ( ! in_array( $this->_author, array( 'GravityView', 'Katz Web Services, Inc.', true ) ) ) { |
|
| 18 | 18 | gravityview()->log->warning( '\GravityView_Extension is deprecated. Inherit from \GV\Extension instead', array( 'data' => $this ) ); |
| 19 | 19 | } |
| 20 | 20 | parent::__construct(); |