@@ -7,13 +7,13 @@ |
||
| 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 | <div class="gv-search-box gv-search-field-entry_id"> |
| 15 | 15 | <div class="gv-search"> |
| 16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
| 16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | 17 | <label for="gv_entry_id_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
| 18 | 18 | <?php } ?> |
| 19 | 19 | <p><input type="text" name="gv_id" id="gv_entry_id_<?php echo $view_id; ?>" value="<?php echo esc_attr( $value ); ?>" /></p> |
@@ -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 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | return self::_return( '' ); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( $entry['status'] != 'active' ) { |
|
| 167 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 168 | 168 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
| 169 | 169 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 178 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 178 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 179 | 179 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
| 180 | 180 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 181 | 181 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $error = \GVCommon::check_entry_display( $entry->as_entry(), $view ); |
| 185 | 185 | |
| 186 | - if( is_wp_error( $error ) ) { |
|
| 186 | + if ( is_wp_error( $error ) ) { |
|
| 187 | 187 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) ); |
| 188 | 188 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
| 189 | 189 | } |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | // Mock the request with the actual View, not the global one |
| 201 | 201 | $mock_request = new \GV\Mock_Request(); |
| 202 | - $mock_request->returns['is_view'] = $view; |
|
| 203 | - $mock_request->returns['is_entry'] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 204 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 205 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
| 202 | + $mock_request->returns[ 'is_view' ] = $view; |
|
| 203 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
| 204 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
| 205 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
| 206 | 206 | |
| 207 | 207 | $request = $mock_request; |
| 208 | 208 | } |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
| 239 | 239 | |
| 240 | 240 | // Only keep the passed attributes after making sure that they're valid pairs |
| 241 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
| 241 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
| 242 | 242 | |
| 243 | 243 | $atts = array(); |
| 244 | 244 | |
| 245 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
| 245 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
| 246 | 246 | |
| 247 | 247 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
| 248 | 248 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
| 249 | 249 | |
| 250 | - switch( $defaults[ $key ]['type'] ) { |
|
| 250 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | 253 | * Make sure number fields are numeric. |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
| 256 | 256 | */ |
| 257 | 257 | case 'number': |
| 258 | - if( is_numeric( $passed_value ) ) { |
|
| 258 | + if ( is_numeric( $passed_value ) ) { |
|
| 259 | 259 | $atts[ $key ] = ( $passed_value + 0 ); |
| 260 | 260 | } |
| 261 | 261 | break; |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | case 'select': |
| 272 | 272 | case 'radio': |
| 273 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
| 274 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 273 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
| 274 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 275 | 275 | $atts[ $key ] = $passed_value; |
| 276 | 276 | } |
| 277 | 277 | break; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 286 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
| 287 | 287 | |
| 288 | 288 | return $atts; |
| 289 | 289 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | private function detail( $view, $entries, $atts ) { |
| 301 | 301 | $output = ''; |
| 302 | 302 | |
| 303 | - switch ( $key = $atts['detail'] ): |
|
| 303 | + switch ( $key = $atts[ 'detail' ] ): |
|
| 304 | 304 | case 'total_entries': |
| 305 | 305 | $output = number_format_i18n( $entries->total() ); |
| 306 | 306 | 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 | |
@@ -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">%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 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | ) ); |
| 227 | 227 | |
| 228 | 228 | if ( is_wp_error( $response ) ) { |
| 229 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 229 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 230 | 230 | return $response; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | <div class="gv-admin-installer-notice notice inline error"> |
| 280 | 280 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
| 281 | 281 | <?php |
| 282 | - if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | - } |
|
| 285 | - ?> |
|
| 282 | + if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | + } |
|
| 285 | + ?> |
|
| 286 | 286 | </div> |
| 287 | 287 | </div> |
| 288 | 288 | <?php |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | protected function render_download( $download, $wp_plugins ) { |
| 339 | 339 | |
| 340 | 340 | |
| 341 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 341 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 342 | 342 | |
| 343 | - $download_info = $details['download_info']; |
|
| 343 | + $download_info = $details['download_info']; |
|
| 344 | 344 | |
| 345 | 345 | ?> |
| 346 | 346 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -362,43 +362,43 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | <div class="addon-excerpt"><?php |
| 364 | 364 | |
| 365 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 365 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 366 | 366 | |
| 367 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 367 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 370 | 370 | |
| 371 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 371 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 373 | 373 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
| 374 | 374 | |
| 375 | 375 | echo wpautop( $excerpt ); |
| 376 | - ?></div> |
|
| 376 | + ?></div> |
|
| 377 | 377 | </div> |
| 378 | 378 | </div> |
| 379 | 379 | <?php |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | - * |
|
| 383 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | + * |
|
| 385 | 385 | * @param array $download Single download, as returned by {@see get_downloads_data} |
| 386 | 386 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
| 387 | 387 | * |
| 388 | 388 | * @return array { |
| 389 | - * @type array $download_info |
|
| 390 | - * @type string $plugin_path |
|
| 391 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | - * @type string $status_label |
|
| 393 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | - * @type string $button_class CSS class to use for the button |
|
| 395 | - * @type string $button_label Text to use for the download's anchor link |
|
| 396 | - * @type string $href URL for the download's button |
|
| 397 | - * @type bool $spinner Whether to show the spinner icon |
|
| 398 | - * @type string $item_class CSS class for the download container |
|
| 399 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | - * } |
|
| 389 | + * @type array $download_info |
|
| 390 | + * @type string $plugin_path |
|
| 391 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | + * @type string $status_label |
|
| 393 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | + * @type string $button_class CSS class to use for the button |
|
| 395 | + * @type string $button_label Text to use for the download's anchor link |
|
| 396 | + * @type string $href URL for the download's button |
|
| 397 | + * @type bool $spinner Whether to show the spinner icon |
|
| 398 | + * @type string $item_class CSS class for the download container |
|
| 399 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | + * } |
|
| 402 | 402 | */ |
| 403 | 403 | private function get_download_display_details( $download, $wp_plugins ) { |
| 404 | 404 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | 'slug' => '', |
| 410 | 410 | 'excerpt' => '', |
| 411 | 411 | 'link' => '', |
| 412 | - 'coming_soon' => false, |
|
| 412 | + 'coming_soon' => false, |
|
| 413 | 413 | 'installer_title' => null, // May not be defined |
| 414 | 414 | 'installer_excerpt' => null, // May not be defined |
| 415 | 415 | ) ); |
@@ -451,14 +451,14 @@ discard block |
||
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | - $spinner = false; |
|
| 456 | - $status = 'notinstalled'; |
|
| 457 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | - $button_class = 'button-primary button-large'; |
|
| 460 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | - } |
|
| 454 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | + $spinner = false; |
|
| 456 | + $status = 'notinstalled'; |
|
| 457 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | + $button_class = 'button-primary button-large'; |
|
| 460 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | 463 | // Access but the plugin is not installed |
| 464 | 464 | elseif ( ! $wp_plugin ) { |
@@ -498,18 +498,18 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Returns the base price for an extension |
|
| 505 | - * |
|
| 504 | + * Returns the base price for an extension |
|
| 505 | + * |
|
| 506 | 506 | * @param array $download |
| 507 | 507 | * |
| 508 | 508 | * @return float Base price for an extension. If not for sale separately, returns 0 |
| 509 | 509 | */ |
| 510 | 510 | private function get_download_base_price( $download ) { |
| 511 | 511 | |
| 512 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 512 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 513 | 513 | $base_price = \GFCommon::to_number( $base_price ); |
| 514 | 514 | |
| 515 | 515 | unset( $download['pricing']['amount'] ); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | return floatval( $base_price ); |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | 526 | * Handle AJAX request to activate extension |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
| 540 | 540 | wp_send_json_error( array( |
| 541 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | - ) ); |
|
| 541 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | + ) ); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | wp_send_json_success(); |
@@ -560,10 +560,10 @@ discard block |
||
| 560 | 560 | deactivate_plugins( $data['path'] ); |
| 561 | 561 | |
| 562 | 562 | if( is_plugin_active( $data['path'] ) ) { |
| 563 | - wp_send_json_error( array( |
|
| 564 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | - ) ); |
|
| 566 | - } |
|
| 563 | + wp_send_json_error( array( |
|
| 564 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | + ) ); |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | wp_send_json_success(); |
| 569 | 569 | } |
@@ -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 | ) ); |
@@ -134,28 +134,28 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function add_network_menu() { |
| 136 | 136 | |
| 137 | - if ( ! gravityview()->plugin->is_network_activated() ) { |
|
| 137 | + if ( ! gravityview()->plugin->is_network_activated() ) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
| 141 | + add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | - * Uninstall all traces of GravityView |
|
| 146 | - * |
|
| 147 | - * Note: method is public because parent method is public |
|
| 148 | - * |
|
| 145 | + * Uninstall all traces of GravityView |
|
| 146 | + * |
|
| 147 | + * Note: method is public because parent method is public |
|
| 148 | + * |
|
| 149 | 149 | * @return bool |
| 150 | 150 | */ |
| 151 | 151 | public function uninstall() { |
| 152 | 152 | gravityview()->plugin->uninstall(); |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * Set the path so that Gravity Forms can de-activate GravityView |
|
| 156 | - * @see GFAddOn::uninstall_addon |
|
| 157 | - * @uses deactivate_plugins() |
|
| 158 | - */ |
|
| 155 | + * Set the path so that Gravity Forms can de-activate GravityView |
|
| 156 | + * @see GFAddOn::uninstall_addon |
|
| 157 | + * @uses deactivate_plugins() |
|
| 158 | + */ |
|
| 159 | 159 | $this->_path = GRAVITYVIEW_FILE; |
| 160 | 160 | |
| 161 | 161 | return true; |
@@ -185,42 +185,42 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | - * Get an array of reasons why the plugin might be uninstalled |
|
| 189 | - * |
|
| 190 | - * @since 1.17.5 |
|
| 191 | - * |
|
| 188 | + * Get an array of reasons why the plugin might be uninstalled |
|
| 189 | + * |
|
| 190 | + * @since 1.17.5 |
|
| 191 | + * |
|
| 192 | 192 | * @return array Array of reasons with the label and followup questions for each uninstall reason |
| 193 | 193 | */ |
| 194 | 194 | private function get_uninstall_reasons() { |
| 195 | 195 | $reasons = array( |
| 196 | 196 | 'will-continue' => array( |
| 197 | - 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 198 | - ), |
|
| 197 | + 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 198 | + ), |
|
| 199 | 199 | 'no-longer-need' => array( |
| 200 | - 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 201 | - ), |
|
| 200 | + 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 201 | + ), |
|
| 202 | 202 | 'doesnt-work' => array( |
| 203 | - 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 204 | - ), |
|
| 203 | + 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 204 | + ), |
|
| 205 | 205 | 'found-other' => array( |
| 206 | - 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 207 | - 'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ), |
|
| 208 | - ), |
|
| 206 | + 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 207 | + 'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ), |
|
| 208 | + ), |
|
| 209 | 209 | 'other' => array( |
| 210 | - 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 211 | - ), |
|
| 210 | + 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 211 | + ), |
|
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | 214 | shuffle( $reasons ); |
| 215 | 215 | |
| 216 | 216 | return $reasons; |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * Display a feedback form when the plugin is uninstalled |
|
| 221 | - * |
|
| 222 | - * @since 1.17.5 |
|
| 223 | - * |
|
| 220 | + * Display a feedback form when the plugin is uninstalled |
|
| 221 | + * |
|
| 222 | + * @since 1.17.5 |
|
| 223 | + * |
|
| 224 | 224 | * @return string HTML of the uninstallation form |
| 225 | 225 | */ |
| 226 | 226 | public function uninstall_form() { |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | <h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2> |
| 301 | 301 | <ul> |
| 302 | 302 | <?php |
| 303 | - $reasons = $this->get_uninstall_reasons(); |
|
| 303 | + $reasons = $this->get_uninstall_reasons(); |
|
| 304 | 304 | foreach ( $reasons as $reason ) { |
| 305 | 305 | printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get( $reason, 'followup' ), Utils::get( $reason, 'label' ) ); |
| 306 | 306 | } |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | public function app_settings_tab() { |
| 397 | - parent::app_settings_tab(); |
|
| 397 | + parent::app_settings_tab(); |
|
| 398 | 398 | |
| 399 | 399 | if ( $this->maybe_uninstall() ) { |
| 400 | - echo $this->uninstall_form(); |
|
| 400 | + echo $this->uninstall_form(); |
|
| 401 | 401 | } |
| 402 | - } |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | 405 | * The Settings title |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @return array The settings. |
| 485 | 485 | */ |
| 486 | 486 | public function all() { |
| 487 | - return wp_parse_args( get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', array() ), $this->defaults() ); |
|
| 487 | + return wp_parse_args( get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', array() ), $this->defaults() ); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | type="' . $field['type'] . '" |
| 554 | 554 | name="' . esc_attr( $name ) . '" |
| 555 | 555 | value="' . $value . '" ' . |
| 556 | - implode( ' ', $attributes ) . |
|
| 557 | - ' />'; |
|
| 556 | + implode( ' ', $attributes ) . |
|
| 557 | + ' />'; |
|
| 558 | 558 | |
| 559 | 559 | if ( $echo ) { |
| 560 | 560 | echo $html; |
@@ -572,12 +572,12 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
| 575 | - * Check whether GravityView is being saved |
|
| 576 | - * |
|
| 577 | - * The generic is_save_postback() is true for all addons |
|
| 578 | - * |
|
| 579 | - * @since 2.0.8 |
|
| 580 | - * |
|
| 575 | + * Check whether GravityView is being saved |
|
| 576 | + * |
|
| 577 | + * The generic is_save_postback() is true for all addons |
|
| 578 | + * |
|
| 579 | + * @since 2.0.8 |
|
| 580 | + * |
|
| 581 | 581 | * @return bool |
| 582 | 582 | */ |
| 583 | 583 | public function is_save_postback() { |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function license_key_notice() { |
| 593 | 593 | |
| 594 | - if( $this->is_save_postback() ) { |
|
| 595 | - $settings = $this->get_posted_settings(); |
|
| 596 | - $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
| 597 | - $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
| 598 | - } else { |
|
| 599 | - $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
| 600 | - $license_key = $this->get( 'license_key' ); |
|
| 601 | - } |
|
| 594 | + if( $this->is_save_postback() ) { |
|
| 595 | + $settings = $this->get_posted_settings(); |
|
| 596 | + $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
| 597 | + $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
| 598 | + } else { |
|
| 599 | + $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
| 600 | + $license_key = $this->get( 'license_key' ); |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
| 603 | + $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
| 604 | 604 | |
| 605 | 605 | $message = esc_html__( 'Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
| 606 | 606 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | $update_below = false; |
| 618 | 618 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
| 619 | 619 | |
| 620 | - switch ( $license_status ) { |
|
| 620 | + switch ( $license_status ) { |
|
| 621 | 621 | /** @since 1.17 */ |
| 622 | 622 | case 'expired': |
| 623 | 623 | $title = __( 'Expired License', 'gravityview' ); |
@@ -655,13 +655,13 @@ discard block |
||
| 655 | 655 | return; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - \GravityView_Admin_Notices::add_notice( array( |
|
| 659 | - 'message' => $message, |
|
| 660 | - 'class' => 'notice notice-warning', |
|
| 661 | - 'title' => $title, |
|
| 662 | - 'cap' => 'gravityview_edit_settings', |
|
| 663 | - 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
| 664 | - ) ); |
|
| 658 | + \GravityView_Admin_Notices::add_notice( array( |
|
| 659 | + 'message' => $message, |
|
| 660 | + 'class' => 'notice notice-warning', |
|
| 661 | + 'title' => $title, |
|
| 662 | + 'cap' => 'gravityview_edit_settings', |
|
| 663 | + 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
| 664 | + ) ); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 679 | - * |
|
| 680 | - * @since 1.21.5 |
|
| 681 | - * |
|
| 682 | - * @see GFAddOn::scripts() |
|
| 683 | - * |
|
| 678 | + * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 679 | + * |
|
| 680 | + * @since 1.21.5 |
|
| 681 | + * |
|
| 682 | + * @see GFAddOn::scripts() |
|
| 683 | + * |
|
| 684 | 684 | * @return array Array of scripts |
| 685 | 685 | */ |
| 686 | 686 | public function scripts() { |
@@ -689,10 +689,10 @@ discard block |
||
| 689 | 689 | $scripts[] = array( |
| 690 | 690 | 'handle' => 'gform_tooltip_init', |
| 691 | 691 | 'enqueue' => array( |
| 692 | - array( |
|
| 693 | - 'admin_page' => array( 'app_settings' ) |
|
| 694 | - ) |
|
| 695 | - ) |
|
| 692 | + array( |
|
| 693 | + 'admin_page' => array( 'app_settings' ) |
|
| 694 | + ) |
|
| 695 | + ) |
|
| 696 | 696 | ); |
| 697 | 697 | |
| 698 | 698 | return $scripts; |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
| 711 | 711 | 'version' => Plugin::$version, |
| 712 | 712 | 'deps' => array( |
| 713 | - 'gform_admin', |
|
| 713 | + 'gform_admin', |
|
| 714 | 714 | 'gaddon_form_settings_css', |
| 715 | - 'gform_tooltip', |
|
| 716 | - 'gform_font_awesome', |
|
| 715 | + 'gform_tooltip', |
|
| 716 | + 'gform_font_awesome', |
|
| 717 | 717 | ), |
| 718 | 718 | 'enqueue' => array( |
| 719 | 719 | array( 'admin_page' => array( |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | array( |
| 882 | 882 | 'label' => _x( 'Show me beta versions if they are available.', 'gravityview' ), |
| 883 | 883 | 'value' => '1', |
| 884 | - 'name' => 'beta', |
|
| 884 | + 'name' => 'beta', |
|
| 885 | 885 | ), |
| 886 | 886 | ), |
| 887 | 887 | 'description' => __( 'You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview' ), |
@@ -919,38 +919,38 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | if ( empty( $field['disabled'] ) ) { |
| 921 | 921 | unset( $field['disabled'] ); |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - $sections = array( |
|
| 926 | - array( |
|
| 927 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
| 928 | - 'fields' => $fields, |
|
| 929 | - ) |
|
| 930 | - ); |
|
| 925 | + $sections = array( |
|
| 926 | + array( |
|
| 927 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
| 928 | + 'fields' => $fields, |
|
| 929 | + ) |
|
| 930 | + ); |
|
| 931 | 931 | |
| 932 | - // custom 'update settings' button |
|
| 933 | - $button = array( |
|
| 934 | - 'class' => 'button button-primary button-hero', |
|
| 935 | - 'type' => 'save', |
|
| 936 | - ); |
|
| 932 | + // custom 'update settings' button |
|
| 933 | + $button = array( |
|
| 934 | + 'class' => 'button button-primary button-hero', |
|
| 935 | + 'type' => 'save', |
|
| 936 | + ); |
|
| 937 | 937 | |
| 938 | 938 | if ( $disabled_attribute ) { |
| 939 | 939 | $button['disabled'] = $disabled_attribute; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - /** |
|
| 943 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 944 | - * Extensions can tap in here to insert their own section and settings. |
|
| 945 | - * <code> |
|
| 946 | - * $sections[] = array( |
|
| 947 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 948 | - * 'fields' => $settings, |
|
| 949 | - * ); |
|
| 950 | - * </code> |
|
| 951 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
| 952 | - */ |
|
| 953 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 942 | + /** |
|
| 943 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 944 | + * Extensions can tap in here to insert their own section and settings. |
|
| 945 | + * <code> |
|
| 946 | + * $sections[] = array( |
|
| 947 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 948 | + * 'fields' => $settings, |
|
| 949 | + * ); |
|
| 950 | + * </code> |
|
| 951 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
| 952 | + */ |
|
| 953 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 954 | 954 | |
| 955 | 955 | // If there are extensions, add a section for them |
| 956 | 956 | if ( ! empty( $extension_sections ) ) { |
@@ -963,13 +963,13 @@ discard block |
||
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - $k = count( $extension_sections ) - 1 ; |
|
| 967 | - $extension_sections[ $k ]['fields'][] = $button; |
|
| 966 | + $k = count( $extension_sections ) - 1 ; |
|
| 967 | + $extension_sections[ $k ]['fields'][] = $button; |
|
| 968 | 968 | $sections = array_merge( $sections, $extension_sections ); |
| 969 | 969 | } else { |
| 970 | - // add the 'update settings' button to the general section |
|
| 971 | - $sections[0]['fields'][] = $button; |
|
| 972 | - } |
|
| 970 | + // add the 'update settings' button to the general section |
|
| 971 | + $sections[0]['fields'][] = $button; |
|
| 972 | + } |
|
| 973 | 973 | |
| 974 | 974 | return $sections; |
| 975 | 975 | } |
@@ -1023,9 +1023,9 @@ discard block |
||
| 1023 | 1023 | */ |
| 1024 | 1024 | protected function settings_edd_license( $field, $echo = true ) { |
| 1025 | 1025 | |
| 1026 | - if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 1027 | - $field['input_type'] = 'password'; |
|
| 1028 | - } |
|
| 1026 | + if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 1027 | + $field['input_type'] = 'password'; |
|
| 1028 | + } |
|
| 1029 | 1029 | |
| 1030 | 1030 | $text = $this->settings_text( $field, false ); |
| 1031 | 1031 | |
@@ -1042,9 +1042,9 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | /** |
| 1044 | 1044 | * Allow pure HTML settings row |
| 1045 | - * |
|
| 1046 | - * @since 2.0.6 |
|
| 1047 | - * |
|
| 1045 | + * |
|
| 1046 | + * @since 2.0.6 |
|
| 1047 | + * |
|
| 1048 | 1048 | * @param array $field |
| 1049 | 1049 | * @param bool $echo Whether to echo the |
| 1050 | 1050 | * |
@@ -1110,19 +1110,19 @@ discard block |
||
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | /** |
| 1113 | - * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 1114 | - * |
|
| 1115 | - * Converts `$field['description']` to `$field['gv_description']` |
|
| 1116 | - * Converts `$field['subtitle']` to `$field['description']` |
|
| 1117 | - * |
|
| 1118 | - * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 1119 | - * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 1120 | - * |
|
| 1121 | - * @since 1.21.5.2 |
|
| 1122 | - * |
|
| 1113 | + * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 1114 | + * |
|
| 1115 | + * Converts `$field['description']` to `$field['gv_description']` |
|
| 1116 | + * Converts `$field['subtitle']` to `$field['description']` |
|
| 1117 | + * |
|
| 1118 | + * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 1119 | + * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 1120 | + * |
|
| 1121 | + * @since 1.21.5.2 |
|
| 1122 | + * |
|
| 1123 | 1123 | * @param array $field |
| 1124 | - * |
|
| 1125 | - * @return void |
|
| 1124 | + * |
|
| 1125 | + * @return void |
|
| 1126 | 1126 | */ |
| 1127 | 1127 | public function single_setting_row( $field ) { |
| 1128 | 1128 | $field['gv_description'] = Utils::get( $field, 'description' ); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return array |
| 103 | 103 | */ |
| 104 | 104 | public function modify_app_settings_menu_title( $setting_tabs ) { |
| 105 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' ); |
|
| 105 | + $setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' ); |
|
| 106 | 106 | return $setting_tabs; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -308,15 +308,15 @@ discard block |
||
| 308 | 308 | </ul> |
| 309 | 309 | <div class="gv-followup widefat"> |
| 310 | 310 | <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p> |
| 311 | - <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview') ?>" placeholder="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview'); ?>" class="large-text"></textarea> |
|
| 311 | + <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea> |
|
| 312 | 312 | </div> |
| 313 | 313 | <div class="scale-description"> |
| 314 | 314 | <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p> |
| 315 | 315 | <ul class="inline"> |
| 316 | 316 | <?php |
| 317 | 317 | $i = 0; |
| 318 | - while( $i < 11 ) { |
|
| 319 | - echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>'; |
|
| 318 | + while ( $i < 11 ) { |
|
| 319 | + echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>'; |
|
| 320 | 320 | $i++; |
| 321 | 321 | } |
| 322 | 322 | ?> |
@@ -533,15 +533,15 @@ discard block |
||
| 533 | 533 | * @return string The HTML |
| 534 | 534 | */ |
| 535 | 535 | public function as_html( $field, $echo = true ) { |
| 536 | - $field['type'] = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit'; |
|
| 536 | + $field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit'; |
|
| 537 | 537 | |
| 538 | 538 | $attributes = $this->get_field_attributes( $field ); |
| 539 | 539 | $default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) ); |
| 540 | - $value = $this->get( $field['name'], $default_value ); |
|
| 540 | + $value = $this->get( $field[ 'name' ], $default_value ); |
|
| 541 | 541 | |
| 542 | 542 | |
| 543 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
| 544 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name']; |
|
| 543 | + $attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton'; |
|
| 544 | + $name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ]; |
|
| 545 | 545 | |
| 546 | 546 | if ( empty( $value ) ) { |
| 547 | 547 | $value = __( 'Update Settings', 'gravityview' ); |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $attributes = $this->get_field_attributes( $field ); |
| 551 | 551 | |
| 552 | 552 | $html = '<input |
| 553 | - type="' . $field['type'] . '" |
|
| 553 | + type="' . $field[ 'type' ] . '" |
|
| 554 | 554 | name="' . esc_attr( $name ) . '" |
| 555 | 555 | value="' . $value . '" ' . |
| 556 | 556 | implode( ' ', $attributes ) . |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return bool |
| 582 | 582 | */ |
| 583 | 583 | public function is_save_postback() { |
| 584 | - return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] ); |
|
| 584 | + return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] ); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | /** |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function license_key_notice() { |
| 593 | 593 | |
| 594 | - if( $this->is_save_postback() ) { |
|
| 594 | + if ( $this->is_save_postback() ) { |
|
| 595 | 595 | $settings = $this->get_posted_settings(); |
| 596 | 596 | $license_key = \GV\Utils::get( $settings, 'license_key' ); |
| 597 | 597 | $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * but didn't want to mess up the translation strings for the translators. |
| 613 | 613 | */ |
| 614 | 614 | $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 ); |
| 615 | - $title = __( 'Inactive License', 'gravityview'); |
|
| 615 | + $title = __( 'Inactive License', 'gravityview' ); |
|
| 616 | 616 | $status = ''; |
| 617 | 617 | $update_below = false; |
| 618 | 618 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $update_below = __( 'Activate your license key below.', 'gravityview' ); |
| 643 | 643 | break; |
| 644 | 644 | } |
| 645 | - $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
|
| 645 | + $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice'; |
|
| 646 | 646 | |
| 647 | 647 | // Show a different notice on settings page for inactive licenses (hide the buttons) |
| 648 | 648 | if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) { |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | public function scripts() { |
| 687 | 687 | $scripts = parent::scripts(); |
| 688 | 688 | |
| 689 | - $scripts[] = array( |
|
| 689 | + $scripts[ ] = array( |
|
| 690 | 690 | 'handle' => 'gform_tooltip_init', |
| 691 | 691 | 'enqueue' => array( |
| 692 | 692 | array( |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | public function styles() { |
| 706 | 706 | $styles = parent::styles(); |
| 707 | 707 | |
| 708 | - $styles[] = array( |
|
| 708 | + $styles[ ] = array( |
|
| 709 | 709 | 'handle' => 'gravityview_settings', |
| 710 | 710 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
| 711 | 711 | 'version' => Plugin::$version, |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | * If multisite and not network admin, we don't want the settings to show. |
| 737 | 737 | * @since 1.7.6 |
| 738 | 738 | */ |
| 739 | - $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
| 739 | + $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | 742 | * Override whether to show the Settings menu on a per-blog basis. |
@@ -784,26 +784,26 @@ discard block |
||
| 784 | 784 | 'label' => __( 'License Key', 'gravityview' ), |
| 785 | 785 | 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ) . $this->get_license_handler()->license_details( $this->get_app_setting( 'license_key_response' ) ), |
| 786 | 786 | 'type' => 'edd_license', |
| 787 | - 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
| 787 | + 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
| 788 | 788 | 'data-pending-text' => __( 'Verifying license…', 'gravityview' ), |
| 789 | - 'default_value' => $default_settings['license_key'], |
|
| 789 | + 'default_value' => $default_settings[ 'license_key' ], |
|
| 790 | 790 | 'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
| 791 | 791 | ), |
| 792 | 792 | array( |
| 793 | 793 | 'name' => 'license_key_response', |
| 794 | - 'default_value' => $default_settings['license_key_response'], |
|
| 794 | + 'default_value' => $default_settings[ 'license_key_response' ], |
|
| 795 | 795 | 'type' => 'hidden', |
| 796 | 796 | ), |
| 797 | 797 | array( |
| 798 | 798 | 'name' => 'license_key_status', |
| 799 | - 'default_value' => $default_settings['license_key_status'], |
|
| 799 | + 'default_value' => $default_settings[ 'license_key_status' ], |
|
| 800 | 800 | 'type' => 'hidden', |
| 801 | 801 | ), |
| 802 | 802 | array( |
| 803 | 803 | 'name' => 'support-email', |
| 804 | 804 | 'type' => 'text', |
| 805 | 805 | 'validate' => 'email', |
| 806 | - 'default_value' => $default_settings['support-email'], |
|
| 806 | + 'default_value' => $default_settings[ 'support-email' ], |
|
| 807 | 807 | 'label' => __( 'Support Email', 'gravityview' ), |
| 808 | 808 | 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
| 809 | 809 | 'class' => 'code regular-text', |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | 'name' => 'support_port', |
| 816 | 816 | 'type' => 'radio', |
| 817 | 817 | 'label' => __( 'Show Support Port?', 'gravityview' ), |
| 818 | - 'default_value' => $default_settings['support_port'], |
|
| 818 | + 'default_value' => $default_settings[ 'support_port' ], |
|
| 819 | 819 | 'horizontal' => 1, |
| 820 | 820 | 'choices' => array( |
| 821 | 821 | array( |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | 'name' => 'no-conflict-mode', |
| 835 | 835 | 'type' => 'radio', |
| 836 | 836 | 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
| 837 | - 'default_value' => $default_settings['no-conflict-mode'], |
|
| 837 | + 'default_value' => $default_settings[ 'no-conflict-mode' ], |
|
| 838 | 838 | 'horizontal' => 1, |
| 839 | 839 | 'choices' => array( |
| 840 | 840 | array( |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | 'name' => 'rest_api', |
| 857 | 857 | 'type' => 'radio', |
| 858 | 858 | 'label' => __( 'REST API', 'gravityview' ), |
| 859 | - 'default_value' => $default_settings['rest_api'], |
|
| 859 | + 'default_value' => $default_settings[ 'rest_api' ], |
|
| 860 | 860 | 'horizontal' => 1, |
| 861 | 861 | 'choices' => array( |
| 862 | 862 | array( |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | 'name' => 'beta', |
| 876 | 876 | 'type' => 'checkbox', |
| 877 | 877 | 'label' => __( 'Become a Beta Tester', 'gravityview' ), |
| 878 | - 'default_value' => $default_settings['beta'], |
|
| 878 | + 'default_value' => $default_settings[ 'beta' ], |
|
| 879 | 879 | 'horizontal' => 1, |
| 880 | 880 | 'choices' => array( |
| 881 | 881 | array( |
@@ -908,17 +908,17 @@ discard block |
||
| 908 | 908 | * @since 1.7.4 |
| 909 | 909 | */ |
| 910 | 910 | foreach ( $fields as &$field ) { |
| 911 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' ); |
|
| 912 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' ); |
|
| 913 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' ); |
|
| 914 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' ); |
|
| 911 | + $field[ 'name' ] = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' ); |
|
| 912 | + $field[ 'label' ] = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' ); |
|
| 913 | + $field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' ); |
|
| 914 | + $field[ 'description' ] = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' ); |
|
| 915 | 915 | |
| 916 | 916 | if ( $disabled_attribute ) { |
| 917 | - $field['disabled'] = $disabled_attribute; |
|
| 917 | + $field[ 'disabled' ] = $disabled_attribute; |
|
| 918 | 918 | } |
| 919 | 919 | |
| 920 | - if ( empty( $field['disabled'] ) ) { |
|
| 921 | - unset( $field['disabled'] ); |
|
| 920 | + if ( empty( $field[ 'disabled' ] ) ) { |
|
| 921 | + unset( $field[ 'disabled' ] ); |
|
| 922 | 922 | } |
| 923 | 923 | } |
| 924 | 924 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | ); |
| 937 | 937 | |
| 938 | 938 | if ( $disabled_attribute ) { |
| 939 | - $button['disabled'] = $disabled_attribute; |
|
| 939 | + $button[ 'disabled' ] = $disabled_attribute; |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | /** |
@@ -955,20 +955,20 @@ discard block |
||
| 955 | 955 | // If there are extensions, add a section for them |
| 956 | 956 | if ( ! empty( $extension_sections ) ) { |
| 957 | 957 | |
| 958 | - if( $disabled_attribute ) { |
|
| 958 | + if ( $disabled_attribute ) { |
|
| 959 | 959 | foreach ( $extension_sections as &$section ) { |
| 960 | - foreach ( $section['fields'] as &$field ) { |
|
| 961 | - $field['disabled'] = $disabled_attribute; |
|
| 960 | + foreach ( $section[ 'fields' ] as &$field ) { |
|
| 961 | + $field[ 'disabled' ] = $disabled_attribute; |
|
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - $k = count( $extension_sections ) - 1 ; |
|
| 967 | - $extension_sections[ $k ]['fields'][] = $button; |
|
| 966 | + $k = count( $extension_sections ) - 1; |
|
| 967 | + $extension_sections[ $k ][ 'fields' ][ ] = $button; |
|
| 968 | 968 | $sections = array_merge( $sections, $extension_sections ); |
| 969 | 969 | } else { |
| 970 | 970 | // add the 'update settings' button to the general section |
| 971 | - $sections[0]['fields'][] = $button; |
|
| 971 | + $sections[ 0 ][ 'fields' ][ ] = $button; |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | return $sections; |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | protected function settings_edd_license( $field, $echo = true ) { |
| 1025 | 1025 | |
| 1026 | 1026 | if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
| 1027 | - $field['input_type'] = 'password'; |
|
| 1027 | + $field[ 'input_type' ] = 'password'; |
|
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | $text = $this->settings_text( $field, false ); |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | public function single_setting_row_html( $field ) { |
| 1074 | 1074 | ?> |
| 1075 | 1075 | |
| 1076 | - <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>"> |
|
| 1076 | + <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>"> |
|
| 1077 | 1077 | <td colspan="2"> |
| 1078 | 1078 | <?php $this->single_setting( $field ); ?> |
| 1079 | 1079 | </td> |
@@ -1091,10 +1091,10 @@ discard block |
||
| 1091 | 1091 | * @return string |
| 1092 | 1092 | */ |
| 1093 | 1093 | public function settings_save( $field, $echo = true ) { |
| 1094 | - $field['type'] = 'submit'; |
|
| 1095 | - $field['name'] = 'gform-settings-save'; |
|
| 1096 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
| 1097 | - $field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
| 1094 | + $field[ 'type' ] = 'submit'; |
|
| 1095 | + $field[ 'name' ] = 'gform-settings-save'; |
|
| 1096 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton'; |
|
| 1097 | + $field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
| 1098 | 1098 | |
| 1099 | 1099 | $output = $this->settings_submit( $field, false ); |
| 1100 | 1100 | |
@@ -1125,8 +1125,8 @@ discard block |
||
| 1125 | 1125 | * @return void |
| 1126 | 1126 | */ |
| 1127 | 1127 | public function single_setting_row( $field ) { |
| 1128 | - $field['gv_description'] = Utils::get( $field, 'description' ); |
|
| 1129 | - $field['description'] = Utils::get( $field, 'subtitle' ); |
|
| 1128 | + $field[ 'gv_description' ] = Utils::get( $field, 'description' ); |
|
| 1129 | + $field[ 'description' ] = Utils::get( $field, 'subtitle' ); |
|
| 1130 | 1130 | parent::single_setting_row( $field ); |
| 1131 | 1131 | } |
| 1132 | 1132 | |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | public function single_setting_label( $field ) { |
| 1139 | 1139 | parent::single_setting_label( $field ); |
| 1140 | 1140 | if ( $description = Utils::get( $field, 'gv_description' ) ) { |
| 1141 | - echo '<span class="description">'. $description .'</span>'; |
|
| 1141 | + echo '<span class="description">' . $description . '</span>'; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1175,9 +1175,9 @@ discard block |
||
| 1175 | 1175 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
| 1176 | 1176 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
| 1177 | 1177 | if ( $local_key !== $response_key ) { |
| 1178 | - unset( $posted_settings['license_key_response'] ); |
|
| 1179 | - unset( $posted_settings['license_key_status'] ); |
|
| 1180 | - \GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
| 1178 | + unset( $posted_settings[ 'license_key_response' ] ); |
|
| 1179 | + unset( $posted_settings[ 'license_key_status' ] ); |
|
| 1180 | + \GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | return $posted_settings; |
| 1183 | 1183 | } |
@@ -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 | |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * ID of the current post. May also be ID of the current View. |
| 97 | - * |
|
| 98 | - * @since 2.0.13 |
|
| 99 | - * |
|
| 100 | - * @var int |
|
| 97 | + * |
|
| 98 | + * @since 2.0.13 |
|
| 99 | + * |
|
| 100 | + * @var int |
|
| 101 | 101 | */ |
| 102 | 102 | public $post_id; |
| 103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | 171 | if( ! empty( $_POST ) ) { |
| 172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if( $this->is_edit_entry_submission() ) { |
| 176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | * When Edit entry view is requested setup the vars |
| 203 | 203 | */ |
| 204 | 204 | private function setup_vars() { |
| 205 | - global $post; |
|
| 205 | + global $post; |
|
| 206 | 206 | |
| 207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[0]; |
|
| 212 | + $this->entry = $entries[0]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | GFFormsModel::save_lead( $form, $this->entry ); |
| 345 | 345 | |
| 346 | - // Delete the values for hidden inputs |
|
| 347 | - $this->unset_hidden_field_values(); |
|
| 346 | + // Delete the values for hidden inputs |
|
| 347 | + $this->unset_hidden_field_values(); |
|
| 348 | 348 | |
| 349 | 349 | $this->entry['date_created'] = $date_created; |
| 350 | 350 | |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | // Perform actions normally performed after updating a lead |
| 355 | 355 | $this->after_update(); |
| 356 | 356 | |
| 357 | - /** |
|
| 357 | + /** |
|
| 358 | 358 | * Must be AFTER after_update()! |
| 359 | 359 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 360 | 360 | */ |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 365 | - * @since 2.1 Added $gv_data parameter |
|
| 365 | + * @since 2.1 Added $gv_data parameter |
|
| 366 | 366 | * @param array $form Gravity Forms form array |
| 367 | 367 | * @param string $entry_id Numeric ID of the entry that was updated |
| 368 | 368 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * @return void |
| 387 | 387 | */ |
| 388 | 388 | private function unset_hidden_field_values() { |
| 389 | - global $wpdb; |
|
| 389 | + global $wpdb; |
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -408,29 +408,29 @@ discard block |
||
| 408 | 408 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 411 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 412 | 412 | |
| 413 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 413 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 414 | 414 | |
| 415 | - // Reset fields that are hidden |
|
| 416 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 417 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 415 | + // Reset fields that are hidden |
|
| 416 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 417 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 418 | 418 | |
| 419 | 419 | $empty_value = $field->get_value_save_entry( |
| 420 | 420 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 421 | 421 | $this->form, '', $this->entry['id'], $this->entry |
| 422 | 422 | ); |
| 423 | 423 | |
| 424 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 424 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 425 | 425 | |
| 426 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 426 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 427 | 427 | |
| 428 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 428 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 429 | 429 | // after submission |
| 430 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 431 | - $_POST[ $post_input_id ] = ''; |
|
| 432 | - } |
|
| 433 | - } |
|
| 430 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 431 | + $_POST[ $post_input_id ] = ''; |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | $non_submitted_fields = array(); |
| 528 | 528 | |
| 529 | - /** @var GF_Field $field */ |
|
| 529 | + /** @var GF_Field $field */ |
|
| 530 | 530 | foreach( $form['fields'] as $k => &$field ) { |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | |
| 543 | 543 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 544 | 544 | foreach( $field->inputs as $key => $input ) { |
| 545 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 545 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | foreach ( $this->fields_with_calculation as $field ) { |
| 604 | 604 | $inputs = $field->get_entry_inputs(); |
| 605 | 605 | if ( is_array( $inputs ) ) { |
| 606 | - foreach ( $inputs as $input ) { |
|
| 606 | + foreach ( $inputs as $input ) { |
|
| 607 | 607 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 608 | 608 | |
| 609 | 609 | if ( 'product' === $field->type ) { |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 625 | - } |
|
| 625 | + } |
|
| 626 | 626 | } else { |
| 627 | 627 | // Set to what it previously was if it's not editable |
| 628 | 628 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 669 | 669 | |
| 670 | 670 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 671 | - $ary = stripslashes_deep( $ary ); |
|
| 671 | + $ary = stripslashes_deep( $ary ); |
|
| 672 | 672 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 673 | 673 | |
| 674 | 674 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | private function maybe_update_post_fields( $form ) { |
| 742 | 742 | |
| 743 | 743 | if( empty( $this->entry['post_id'] ) ) { |
| 744 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 744 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 745 | 745 | return; |
| 746 | 746 | } |
| 747 | 747 | |
@@ -776,49 +776,49 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | switch( $field->type ) { |
| 778 | 778 | |
| 779 | - case 'post_title': |
|
| 780 | - $post_title = $value; |
|
| 781 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 782 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 783 | - } |
|
| 784 | - $updated_post->post_title = $post_title; |
|
| 785 | - $updated_post->post_name = $post_title; |
|
| 786 | - unset( $post_title ); |
|
| 787 | - break; |
|
| 788 | - |
|
| 789 | - case 'post_content': |
|
| 790 | - $post_content = $value; |
|
| 791 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 792 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 793 | - } |
|
| 794 | - $updated_post->post_content = $post_content; |
|
| 795 | - unset( $post_content ); |
|
| 796 | - break; |
|
| 797 | - case 'post_excerpt': |
|
| 798 | - $updated_post->post_excerpt = $value; |
|
| 799 | - break; |
|
| 800 | - case 'post_tags': |
|
| 801 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 802 | - break; |
|
| 803 | - case 'post_category': |
|
| 804 | - break; |
|
| 805 | - case 'post_custom_field': |
|
| 779 | + case 'post_title': |
|
| 780 | + $post_title = $value; |
|
| 781 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 782 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 783 | + } |
|
| 784 | + $updated_post->post_title = $post_title; |
|
| 785 | + $updated_post->post_name = $post_title; |
|
| 786 | + unset( $post_title ); |
|
| 787 | + break; |
|
| 788 | + |
|
| 789 | + case 'post_content': |
|
| 790 | + $post_content = $value; |
|
| 791 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 792 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 793 | + } |
|
| 794 | + $updated_post->post_content = $post_content; |
|
| 795 | + unset( $post_content ); |
|
| 796 | + break; |
|
| 797 | + case 'post_excerpt': |
|
| 798 | + $updated_post->post_excerpt = $value; |
|
| 799 | + break; |
|
| 800 | + case 'post_tags': |
|
| 801 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 802 | + break; |
|
| 803 | + case 'post_category': |
|
| 804 | + break; |
|
| 805 | + case 'post_custom_field': |
|
| 806 | 806 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 807 | 807 | $value = $value[ $field_id ]; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 811 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 812 | - } |
|
| 810 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 811 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | 814 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 815 | 815 | |
| 816 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 817 | - break; |
|
| 816 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 817 | + break; |
|
| 818 | 818 | |
| 819 | - case 'post_image': |
|
| 820 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 821 | - break; |
|
| 819 | + case 'post_image': |
|
| 820 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 821 | + break; |
|
| 822 | 822 | |
| 823 | 823 | } |
| 824 | 824 | |
@@ -941,14 +941,14 @@ discard block |
||
| 941 | 941 | ?><h2 class="gv-edit-entry-title"> |
| 942 | 942 | <span><?php |
| 943 | 943 | |
| 944 | - /** |
|
| 945 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 946 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 947 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 948 | - */ |
|
| 949 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 944 | + /** |
|
| 945 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 946 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 947 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 948 | + */ |
|
| 949 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 950 | 950 | |
| 951 | - echo esc_attr( $edit_entry_title ); |
|
| 951 | + echo esc_attr( $edit_entry_title ); |
|
| 952 | 952 | ?></span> |
| 953 | 953 | </h2> |
| 954 | 954 | |
@@ -1011,26 +1011,26 @@ discard block |
||
| 1011 | 1011 | |
| 1012 | 1012 | switch ( $edit_redirect ) { |
| 1013 | 1013 | |
| 1014 | - case '0': |
|
| 1015 | - $redirect_url = $back_link; |
|
| 1016 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1017 | - break; |
|
| 1018 | - |
|
| 1019 | - case '1': |
|
| 1020 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1021 | - $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>' ); |
|
| 1022 | - break; |
|
| 1023 | - |
|
| 1024 | - case '2': |
|
| 1025 | - $redirect_url = $edit_redirect_url; |
|
| 1026 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1027 | - $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>' ); |
|
| 1028 | - break; |
|
| 1029 | - |
|
| 1030 | - case '': |
|
| 1031 | - default: |
|
| 1032 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1033 | - break; |
|
| 1014 | + case '0': |
|
| 1015 | + $redirect_url = $back_link; |
|
| 1016 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1017 | + break; |
|
| 1018 | + |
|
| 1019 | + case '1': |
|
| 1020 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1021 | + $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>' ); |
|
| 1022 | + break; |
|
| 1023 | + |
|
| 1024 | + case '2': |
|
| 1025 | + $redirect_url = $edit_redirect_url; |
|
| 1026 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1027 | + $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>' ); |
|
| 1028 | + break; |
|
| 1029 | + |
|
| 1030 | + case '': |
|
| 1031 | + default: |
|
| 1032 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1033 | + break; |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | if ( isset( $redirect_url ) ) { |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | |
| 1088 | 1088 | ob_get_clean(); |
| 1089 | 1089 | |
| 1090 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1090 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1091 | 1091 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1092 | 1092 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1093 | 1093 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | // for now we don't support Save and Continue feature. |
| 1143 | 1143 | if( ! self::$supports_save_and_continue ) { |
| 1144 | - unset( $form['save'] ); |
|
| 1144 | + unset( $form['save'] ); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | $form = $this->unselect_default_values( $form ); |
@@ -1168,30 +1168,30 @@ discard block |
||
| 1168 | 1168 | return $field_content; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - $message = null; |
|
| 1171 | + $message = null; |
|
| 1172 | 1172 | |
| 1173 | - // First, make sure they have the capability to edit the post. |
|
| 1174 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1173 | + // First, make sure they have the capability to edit the post. |
|
| 1174 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1175 | 1175 | |
| 1176 | - /** |
|
| 1177 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1178 | - * @param string $message The existing "You don't have permission..." text |
|
| 1179 | - */ |
|
| 1180 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1176 | + /** |
|
| 1177 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1178 | + * @param string $message The existing "You don't have permission..." text |
|
| 1179 | + */ |
|
| 1180 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1181 | 1181 | |
| 1182 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1183 | - /** |
|
| 1184 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1185 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1186 | - */ |
|
| 1187 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1188 | - } |
|
| 1182 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1183 | + /** |
|
| 1184 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1185 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1186 | + */ |
|
| 1187 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1188 | + } |
|
| 1189 | 1189 | |
| 1190 | - if( $message ) { |
|
| 1191 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1192 | - } |
|
| 1190 | + if( $message ) { |
|
| 1191 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | - return $field_content; |
|
| 1194 | + return $field_content; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | || ! empty( $field_content ) |
| 1220 | 1220 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1221 | 1221 | ) { |
| 1222 | - return $field_content; |
|
| 1222 | + return $field_content; |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1227,24 +1227,24 @@ discard block |
||
| 1227 | 1227 | |
| 1228 | 1228 | $field_value = $this->get_field_value( $field ); |
| 1229 | 1229 | |
| 1230 | - // Prevent any PHP warnings, like undefined index |
|
| 1231 | - ob_start(); |
|
| 1230 | + // Prevent any PHP warnings, like undefined index |
|
| 1231 | + ob_start(); |
|
| 1232 | 1232 | |
| 1233 | - $return = null; |
|
| 1233 | + $return = null; |
|
| 1234 | 1234 | |
| 1235 | 1235 | /** @var GravityView_Field $gv_field */ |
| 1236 | 1236 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1237 | 1237 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1238 | 1238 | } else { |
| 1239 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1240 | - } |
|
| 1239 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | - // If there was output, it's an error |
|
| 1243 | - $warnings = ob_get_clean(); |
|
| 1242 | + // If there was output, it's an error |
|
| 1243 | + $warnings = ob_get_clean(); |
|
| 1244 | 1244 | |
| 1245 | - if( !empty( $warnings ) ) { |
|
| 1246 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1247 | - } |
|
| 1245 | + if( !empty( $warnings ) ) { |
|
| 1246 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1247 | + } |
|
| 1248 | 1248 | |
| 1249 | 1249 | return $return; |
| 1250 | 1250 | } |
@@ -1279,8 +1279,8 @@ discard block |
||
| 1279 | 1279 | $input_id = strval( $input['id'] ); |
| 1280 | 1280 | |
| 1281 | 1281 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1282 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1283 | - $allow_pre_populated = false; |
|
| 1282 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1283 | + $allow_pre_populated = false; |
|
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | 1286 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
| 1304 | 1304 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1305 | 1305 | $categories = array(); |
| 1306 | 1306 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1307 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1307 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1310 | 1310 | } |
@@ -1314,25 +1314,25 @@ discard block |
||
| 1314 | 1314 | // if value is empty get the default value if defined |
| 1315 | 1315 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1316 | 1316 | |
| 1317 | - /** |
|
| 1318 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1319 | - * @since 1.11 |
|
| 1320 | - * @since 1.20 Added third param |
|
| 1321 | - * @param mixed $field_value field value used to populate the input |
|
| 1322 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1323 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1324 | - */ |
|
| 1325 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1326 | - |
|
| 1327 | - /** |
|
| 1328 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1329 | - * @since 1.17 |
|
| 1330 | - * @since 1.20 Added third param |
|
| 1331 | - * @param mixed $field_value field value used to populate the input |
|
| 1332 | - * @param GF_Field $field Gravity Forms field object |
|
| 1333 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1334 | - */ |
|
| 1335 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1317 | + /** |
|
| 1318 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1319 | + * @since 1.11 |
|
| 1320 | + * @since 1.20 Added third param |
|
| 1321 | + * @param mixed $field_value field value used to populate the input |
|
| 1322 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1323 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1324 | + */ |
|
| 1325 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1326 | + |
|
| 1327 | + /** |
|
| 1328 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1329 | + * @since 1.17 |
|
| 1330 | + * @since 1.20 Added third param |
|
| 1331 | + * @param mixed $field_value field value used to populate the input |
|
| 1332 | + * @param GF_Field $field Gravity Forms field object |
|
| 1333 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1334 | + */ |
|
| 1335 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1336 | 1336 | |
| 1337 | 1337 | return $field_value; |
| 1338 | 1338 | } |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1360 | 1360 | // expects certain field array items to be set. |
| 1361 | 1361 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1362 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1362 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1373,61 +1373,61 @@ discard block |
||
| 1373 | 1373 | */ |
| 1374 | 1374 | case 'fileupload': |
| 1375 | 1375 | |
| 1376 | - // Set the previous value |
|
| 1377 | - $entry = $this->get_entry(); |
|
| 1376 | + // Set the previous value |
|
| 1377 | + $entry = $this->get_entry(); |
|
| 1378 | 1378 | |
| 1379 | - $input_name = 'input_'.$field->id; |
|
| 1380 | - $form_id = $form['id']; |
|
| 1379 | + $input_name = 'input_'.$field->id; |
|
| 1380 | + $form_id = $form['id']; |
|
| 1381 | 1381 | |
| 1382 | - $value = NULL; |
|
| 1382 | + $value = NULL; |
|
| 1383 | 1383 | |
| 1384 | - // Use the previous entry value as the default. |
|
| 1385 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1386 | - $value = $entry[ $field->id ]; |
|
| 1387 | - } |
|
| 1384 | + // Use the previous entry value as the default. |
|
| 1385 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1386 | + $value = $entry[ $field->id ]; |
|
| 1387 | + } |
|
| 1388 | 1388 | |
| 1389 | - // If this is a single upload file |
|
| 1390 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1391 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1392 | - $value = $file_path['url']; |
|
| 1389 | + // If this is a single upload file |
|
| 1390 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1391 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1392 | + $value = $file_path['url']; |
|
| 1393 | 1393 | |
| 1394 | - } else { |
|
| 1394 | + } else { |
|
| 1395 | 1395 | |
| 1396 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1397 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1398 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1396 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1397 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1398 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1399 | 1399 | |
| 1400 | - } |
|
| 1400 | + } |
|
| 1401 | 1401 | |
| 1402 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1402 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1403 | 1403 | |
| 1404 | - // If there are fresh uploads, process and merge them. |
|
| 1405 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1406 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1407 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1408 | - $value = stripslashes_deep( $value ); |
|
| 1409 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1410 | - } |
|
| 1404 | + // If there are fresh uploads, process and merge them. |
|
| 1405 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1406 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1407 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1408 | + $value = stripslashes_deep( $value ); |
|
| 1409 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1410 | + } |
|
| 1411 | 1411 | |
| 1412 | - } else { |
|
| 1412 | + } else { |
|
| 1413 | 1413 | |
| 1414 | - // A file already exists when editing an entry |
|
| 1415 | - // We set this to solve issue when file upload fields are required. |
|
| 1416 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1414 | + // A file already exists when editing an entry |
|
| 1415 | + // We set this to solve issue when file upload fields are required. |
|
| 1416 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1417 | 1417 | |
| 1418 | - } |
|
| 1418 | + } |
|
| 1419 | 1419 | |
| 1420 | - $this->entry[ $input_name ] = $value; |
|
| 1421 | - $_POST[ $input_name ] = $value; |
|
| 1420 | + $this->entry[ $input_name ] = $value; |
|
| 1421 | + $_POST[ $input_name ] = $value; |
|
| 1422 | 1422 | |
| 1423 | - break; |
|
| 1423 | + break; |
|
| 1424 | 1424 | |
| 1425 | 1425 | case 'number': |
| 1426 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1427 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1428 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1429 | - } |
|
| 1430 | - break; |
|
| 1426 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1427 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1428 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1429 | + } |
|
| 1430 | + break; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | } |
@@ -1512,42 +1512,42 @@ discard block |
||
| 1512 | 1512 | case 'fileupload' : |
| 1513 | 1513 | case 'post_image': |
| 1514 | 1514 | |
| 1515 | - // in case nothing is uploaded but there are already files saved |
|
| 1516 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1517 | - $field->failed_validation = false; |
|
| 1518 | - unset( $field->validation_message ); |
|
| 1519 | - } |
|
| 1515 | + // in case nothing is uploaded but there are already files saved |
|
| 1516 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1517 | + $field->failed_validation = false; |
|
| 1518 | + unset( $field->validation_message ); |
|
| 1519 | + } |
|
| 1520 | 1520 | |
| 1521 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1522 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1521 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1522 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1523 | 1523 | |
| 1524 | - $input_name = 'input_' . $field->id; |
|
| 1525 | - //uploaded |
|
| 1526 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1524 | + $input_name = 'input_' . $field->id; |
|
| 1525 | + //uploaded |
|
| 1526 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1527 | 1527 | |
| 1528 | - //existent |
|
| 1529 | - $entry = $this->get_entry(); |
|
| 1530 | - $value = NULL; |
|
| 1531 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1532 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1533 | - } |
|
| 1528 | + //existent |
|
| 1529 | + $entry = $this->get_entry(); |
|
| 1530 | + $value = NULL; |
|
| 1531 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1532 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1533 | + } |
|
| 1534 | 1534 | |
| 1535 | - // count uploaded files and existent entry files |
|
| 1536 | - $count_files = count( $file_names ) + count( $value ); |
|
| 1535 | + // count uploaded files and existent entry files |
|
| 1536 | + $count_files = count( $file_names ) + count( $value ); |
|
| 1537 | 1537 | |
| 1538 | - if( $count_files > $field->maxFiles ) { |
|
| 1539 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1540 | - $field->failed_validation = 1; |
|
| 1541 | - $gv_valid = false; |
|
| 1538 | + if( $count_files > $field->maxFiles ) { |
|
| 1539 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1540 | + $field->failed_validation = 1; |
|
| 1541 | + $gv_valid = false; |
|
| 1542 | 1542 | |
| 1543 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1544 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1545 | - } |
|
| 1543 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1544 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1545 | + } |
|
| 1546 | 1546 | |
| 1547 | - } |
|
| 1547 | + } |
|
| 1548 | 1548 | |
| 1549 | 1549 | |
| 1550 | - break; |
|
| 1550 | + break; |
|
| 1551 | 1551 | |
| 1552 | 1552 | } |
| 1553 | 1553 | |
@@ -1558,47 +1558,47 @@ discard block |
||
| 1558 | 1558 | |
| 1559 | 1559 | switch ( $field_type ) { |
| 1560 | 1560 | |
| 1561 | - // Captchas don't need to be re-entered. |
|
| 1562 | - case 'captcha': |
|
| 1561 | + // Captchas don't need to be re-entered. |
|
| 1562 | + case 'captcha': |
|
| 1563 | 1563 | |
| 1564 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1565 | - case 'post_image': |
|
| 1566 | - $field->failed_validation = false; |
|
| 1567 | - unset( $field->validation_message ); |
|
| 1568 | - break; |
|
| 1564 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1565 | + case 'post_image': |
|
| 1566 | + $field->failed_validation = false; |
|
| 1567 | + unset( $field->validation_message ); |
|
| 1568 | + break; |
|
| 1569 | 1569 | |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | // You can't continue inside a switch, so we do it after. |
| 1573 | 1573 | if( empty( $field->failed_validation ) ) { |
| 1574 | - continue; |
|
| 1574 | + continue; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1578 | 1578 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1579 | 1579 | if( !empty( $field->noDuplicates ) ) { |
| 1580 | 1580 | |
| 1581 | - $entry = $this->get_entry(); |
|
| 1581 | + $entry = $this->get_entry(); |
|
| 1582 | 1582 | |
| 1583 | - // If the value of the entry is the same as the stored value |
|
| 1584 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1585 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1586 | - //if value submitted was not changed, then don't validate |
|
| 1587 | - $field->failed_validation = false; |
|
| 1583 | + // If the value of the entry is the same as the stored value |
|
| 1584 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1585 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1586 | + //if value submitted was not changed, then don't validate |
|
| 1587 | + $field->failed_validation = false; |
|
| 1588 | 1588 | |
| 1589 | - unset( $field->validation_message ); |
|
| 1589 | + unset( $field->validation_message ); |
|
| 1590 | 1590 | |
| 1591 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1591 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1592 | 1592 | |
| 1593 | - continue; |
|
| 1594 | - } |
|
| 1593 | + continue; |
|
| 1594 | + } |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1598 | 1598 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1599 | - unset( $field->validation_message ); |
|
| 1600 | - $field->validation_message = false; |
|
| 1601 | - continue; |
|
| 1599 | + unset( $field->validation_message ); |
|
| 1600 | + $field->validation_message = false; |
|
| 1601 | + continue; |
|
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | $gv_valid = false; |
@@ -1662,8 +1662,8 @@ discard block |
||
| 1662 | 1662 | // Hide fields depending on admin settings |
| 1663 | 1663 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1664 | 1664 | |
| 1665 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1666 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1665 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1666 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1667 | 1667 | |
| 1668 | 1668 | /** |
| 1669 | 1669 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1723,11 +1723,11 @@ discard block |
||
| 1723 | 1723 | // The edit tab has been configured, so we loop through to configured settings |
| 1724 | 1724 | foreach ( $configured_fields as $configured_field ) { |
| 1725 | 1725 | |
| 1726 | - /** @var GF_Field $field */ |
|
| 1727 | - foreach ( $fields as $field ) { |
|
| 1726 | + /** @var GF_Field $field */ |
|
| 1727 | + foreach ( $fields as $field ) { |
|
| 1728 | 1728 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1729 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1730 | - break; |
|
| 1729 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1730 | + break; |
|
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | 1733 | } |
@@ -1783,28 +1783,28 @@ discard block |
||
| 1783 | 1783 | */ |
| 1784 | 1784 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1785 | 1785 | |
| 1786 | - /** |
|
| 1786 | + /** |
|
| 1787 | 1787 | * @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 |
| 1788 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1789 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1790 | - * @since 1.9.1 |
|
| 1791 | - * @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. |
|
| 1792 | - * @param array $form GF Form array |
|
| 1793 | - * @param int $view_id View ID |
|
| 1794 | - */ |
|
| 1795 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1796 | - |
|
| 1797 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1788 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1789 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1790 | + * @since 1.9.1 |
|
| 1791 | + * @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. |
|
| 1792 | + * @param array $form GF Form array |
|
| 1793 | + * @param int $view_id View ID |
|
| 1794 | + */ |
|
| 1795 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1796 | + |
|
| 1797 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1798 | 1798 | foreach( $fields as $k => $field ) { |
| 1799 | 1799 | if( $field->adminOnly ) { |
| 1800 | - unset( $fields[ $k ] ); |
|
| 1800 | + unset( $fields[ $k ] ); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | } |
| 1803 | 1803 | return array_values( $fields ); |
| 1804 | 1804 | } |
| 1805 | 1805 | |
| 1806 | - foreach( $fields as &$field ) { |
|
| 1807 | - $field->adminOnly = false; |
|
| 1806 | + foreach( $fields as &$field ) { |
|
| 1807 | + $field->adminOnly = false; |
|
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | return $fields; |
@@ -1824,13 +1824,13 @@ discard block |
||
| 1824 | 1824 | */ |
| 1825 | 1825 | private function unselect_default_values( $form ) { |
| 1826 | 1826 | |
| 1827 | - foreach ( $form['fields'] as &$field ) { |
|
| 1827 | + foreach ( $form['fields'] as &$field ) { |
|
| 1828 | 1828 | |
| 1829 | 1829 | if ( empty( $field->choices ) ) { |
| 1830 | - continue; |
|
| 1830 | + continue; |
|
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | - foreach ( $field->choices as &$choice ) { |
|
| 1833 | + foreach ( $field->choices as &$choice ) { |
|
| 1834 | 1834 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1835 | 1835 | $choice['isSelected'] = false; |
| 1836 | 1836 | } |
@@ -1867,36 +1867,36 @@ discard block |
||
| 1867 | 1867 | |
| 1868 | 1868 | if( 'checkbox' === $field->type ) { |
| 1869 | 1869 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1870 | - $input_id = $input['id']; |
|
| 1871 | - $choice = $field->choices[ $key ]; |
|
| 1872 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1873 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1874 | - if( $match ) { |
|
| 1875 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1876 | - } |
|
| 1870 | + $input_id = $input['id']; |
|
| 1871 | + $choice = $field->choices[ $key ]; |
|
| 1872 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1873 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1874 | + if( $match ) { |
|
| 1875 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1876 | + } |
|
| 1877 | 1877 | } |
| 1878 | 1878 | } else { |
| 1879 | 1879 | |
| 1880 | 1880 | // We need to run through each field to set the default values |
| 1881 | 1881 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1882 | 1882 | |
| 1883 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1883 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1884 | 1884 | |
| 1885 | - if( 'list' === $field->type ) { |
|
| 1886 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1885 | + if( 'list' === $field->type ) { |
|
| 1886 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1887 | 1887 | |
| 1888 | - $list_field_value = array(); |
|
| 1889 | - foreach ( (array) $list_rows as $row ) { |
|
| 1890 | - foreach ( (array) $row as $column ) { |
|
| 1891 | - $list_field_value[] = $column; |
|
| 1892 | - } |
|
| 1893 | - } |
|
| 1888 | + $list_field_value = array(); |
|
| 1889 | + foreach ( (array) $list_rows as $row ) { |
|
| 1890 | + foreach ( (array) $row as $column ) { |
|
| 1891 | + $list_field_value[] = $column; |
|
| 1892 | + } |
|
| 1893 | + } |
|
| 1894 | 1894 | |
| 1895 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1896 | - } else { |
|
| 1897 | - $field->defaultValue = $field_value; |
|
| 1898 | - } |
|
| 1899 | - } |
|
| 1895 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1896 | + } else { |
|
| 1897 | + $field->defaultValue = $field_value; |
|
| 1898 | + } |
|
| 1899 | + } |
|
| 1900 | 1900 | } |
| 1901 | 1901 | } |
| 1902 | 1902 | } |
@@ -1953,7 +1953,7 @@ discard block |
||
| 1953 | 1953 | return $has_conditional_logic; |
| 1954 | 1954 | } |
| 1955 | 1955 | |
| 1956 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1956 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1957 | 1957 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 1958 | 1958 | } |
| 1959 | 1959 | |
@@ -2020,14 +2020,14 @@ discard block |
||
| 2020 | 2020 | |
| 2021 | 2021 | if( $echo && $error !== true ) { |
| 2022 | 2022 | |
| 2023 | - $error = esc_html( $error ); |
|
| 2023 | + $error = esc_html( $error ); |
|
| 2024 | 2024 | |
| 2025 | - /** |
|
| 2026 | - * @since 1.9 |
|
| 2027 | - */ |
|
| 2028 | - if ( ! empty( $this->entry ) ) { |
|
| 2029 | - $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;" ) ); |
|
| 2030 | - } |
|
| 2025 | + /** |
|
| 2026 | + * @since 1.9 |
|
| 2027 | + */ |
|
| 2028 | + if ( ! empty( $this->entry ) ) { |
|
| 2029 | + $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;" ) ); |
|
| 2030 | + } |
|
| 2031 | 2031 | |
| 2032 | 2032 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2033 | 2033 | } |
@@ -123,16 +123,16 @@ discard block |
||
| 123 | 123 | function load() { |
| 124 | 124 | |
| 125 | 125 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 126 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 126 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 127 | 127 | |
| 128 | 128 | // Don't display an embedded form when editing an entry |
| 129 | 129 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 130 | 130 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 131 | 131 | |
| 132 | 132 | // Stop Gravity Forms processing what is ours! |
| 133 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 133 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 134 | 134 | |
| 135 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 135 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 136 | 136 | |
| 137 | 137 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
| 138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 144 | 144 | |
| 145 | 145 | // Add fields expected by GFFormDisplay::validate() |
| 146 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 146 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 147 | 147 | |
| 148 | 148 | // Fix multiselect value for GF 2.2 |
| 149 | 149 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @return void |
| 161 | 161 | */ |
| 162 | 162 | public function prevent_render_form() { |
| 163 | - if( $this->is_edit_entry() ) { |
|
| 164 | - if( 'wp_head' === current_filter() ) { |
|
| 163 | + if ( $this->is_edit_entry() ) { |
|
| 164 | + if ( 'wp_head' === current_filter() ) { |
|
| 165 | 165 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 166 | 166 | } else { |
| 167 | 167 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function prevent_maybe_process_form() { |
| 178 | 178 | |
| 179 | - if( ! empty( $_POST ) ) { |
|
| 179 | + if ( ! empty( $_POST ) ) { |
|
| 180 | 180 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if( $this->is_edit_entry_submission() ) { |
|
| 184 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 185 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 183 | + if ( $this->is_edit_entry_submission() ) { |
|
| 184 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 185 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function is_edit_entry() { |
| 194 | 194 | |
| 195 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 195 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 196 | 196 | |
| 197 | 197 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @return boolean |
| 204 | 204 | */ |
| 205 | 205 | public function is_edit_entry_submission() { |
| 206 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 206 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -216,16 +216,16 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | $entries = $gravityview_view->getEntries(); |
| 219 | - self::$original_entry = $entries[0]; |
|
| 220 | - $this->entry = $entries[0]; |
|
| 219 | + self::$original_entry = $entries[ 0 ]; |
|
| 220 | + $this->entry = $entries[ 0 ]; |
|
| 221 | 221 | |
| 222 | 222 | self::$original_form = $gravityview_view->getForm(); |
| 223 | 223 | $this->form = $gravityview_view->getForm(); |
| 224 | - $this->form_id = $this->entry['form_id']; |
|
| 224 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
| 225 | 225 | $this->view_id = $gravityview_view->getViewId(); |
| 226 | 226 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 227 | 227 | |
| 228 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 228 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | private function print_scripts() { |
| 285 | 285 | $gravityview_view = GravityView_View::getInstance(); |
| 286 | 286 | |
| 287 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 287 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 288 | 288 | |
| 289 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 289 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 290 | 290 | |
| 291 | 291 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 292 | 292 | |
@@ -302,19 +302,19 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | private function process_save( $gv_data ) { |
| 304 | 304 | |
| 305 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 305 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 306 | 306 | return; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Make sure the entry, view, and form IDs are all correct |
| 310 | 310 | $valid = $this->verify_nonce(); |
| 311 | 311 | |
| 312 | - if ( !$valid ) { |
|
| 312 | + if ( ! $valid ) { |
|
| 313 | 313 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 314 | 314 | return; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 317 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 318 | 318 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 319 | 319 | return; |
| 320 | 320 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | $this->validate(); |
| 327 | 327 | |
| 328 | - if( $this->is_valid ) { |
|
| 328 | + if ( $this->is_valid ) { |
|
| 329 | 329 | |
| 330 | 330 | gravityview()->log->debug( 'Submission is valid.' ); |
| 331 | 331 | |
@@ -337,15 +337,15 @@ discard block |
||
| 337 | 337 | /** |
| 338 | 338 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 339 | 339 | */ |
| 340 | - unset( $_GET['page'] ); |
|
| 340 | + unset( $_GET[ 'page' ] ); |
|
| 341 | 341 | |
| 342 | - $date_created = $this->entry['date_created']; |
|
| 342 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | 345 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 346 | 346 | * @since 1.17.2 |
| 347 | 347 | */ |
| 348 | - unset( $this->entry['date_created'] ); |
|
| 348 | + unset( $this->entry[ 'date_created' ] ); |
|
| 349 | 349 | |
| 350 | 350 | /** |
| 351 | 351 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -355,14 +355,14 @@ discard block |
||
| 355 | 355 | * @param GravityView_Edit_Entry_Render $this This object |
| 356 | 356 | * @param GravityView_View_Data $gv_data The View data |
| 357 | 357 | */ |
| 358 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
| 358 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 359 | 359 | |
| 360 | 360 | GFFormsModel::save_lead( $form, $this->entry ); |
| 361 | 361 | |
| 362 | 362 | // Delete the values for hidden inputs |
| 363 | 363 | $this->unset_hidden_field_values(); |
| 364 | 364 | |
| 365 | - $this->entry['date_created'] = $date_created; |
|
| 365 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 366 | 366 | |
| 367 | 367 | // Process calculation fields |
| 368 | 368 | $this->update_calculation_fields(); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @param GravityView_Edit_Entry_Render $this This object |
| 385 | 385 | * @param GravityView_View_Data $gv_data The View data |
| 386 | 386 | */ |
| 387 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 387 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 388 | 388 | |
| 389 | 389 | } else { |
| 390 | 390 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -412,16 +412,16 @@ discard block |
||
| 412 | 412 | */ |
| 413 | 413 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 414 | 414 | |
| 415 | - if( ! $unset_hidden_field_values ) { |
|
| 415 | + if ( ! $unset_hidden_field_values ) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 420 | 420 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 421 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 421 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 422 | 422 | } else { |
| 423 | 423 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 424 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 424 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | $empty_value = $field->get_value_save_entry( |
| 436 | 436 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 437 | - $this->form, '', $this->entry['id'], $this->entry |
|
| 437 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** No file is being uploaded. */ |
| 507 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 507 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 508 | 508 | /** So return the original upload */ |
| 509 | 509 | return $entry[ $input_id ]; |
| 510 | 510 | } |
@@ -522,11 +522,11 @@ discard block |
||
| 522 | 522 | * @return mixed |
| 523 | 523 | */ |
| 524 | 524 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 525 | - if( ! $this->is_edit_entry() ) { |
|
| 525 | + if ( ! $this->is_edit_entry() ) { |
|
| 526 | 526 | return $plupload_init; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 529 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 530 | 530 | |
| 531 | 531 | return $plupload_init; |
| 532 | 532 | } |
@@ -543,22 +543,22 @@ discard block |
||
| 543 | 543 | $non_submitted_fields = array(); |
| 544 | 544 | |
| 545 | 545 | /** @var GF_Field $field */ |
| 546 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 546 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 547 | 547 | |
| 548 | 548 | /** |
| 549 | 549 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 550 | 550 | * @since 1.16.3 |
| 551 | 551 | * @var GF_Field $field |
| 552 | 552 | */ |
| 553 | - if( $field->has_calculation() ) { |
|
| 554 | - unset( $form['fields'][ $k ] ); |
|
| 553 | + if ( $field->has_calculation() ) { |
|
| 554 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | $field->adminOnly = false; |
| 558 | 558 | |
| 559 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 560 | - foreach( $field->inputs as $key => $input ) { |
|
| 561 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 559 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 560 | + foreach ( $field->inputs as $key => $input ) { |
|
| 561 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | |
@@ -567,11 +567,11 @@ discard block |
||
| 567 | 567 | * are not present in the edit view fields. |
| 568 | 568 | * @since develop |
| 569 | 569 | */ |
| 570 | - if ( ! empty( $field['conditionalLogic'] ) && ! empty( $field['conditionalLogic']['rules'] ) ) { |
|
| 571 | - foreach ( wp_list_pluck( $field['conditionalLogic']['rules'], 'fieldId' ) as $conditional_id ) { |
|
| 570 | + if ( ! empty( $field[ 'conditionalLogic' ] ) && ! empty( $field[ 'conditionalLogic' ][ 'rules' ] ) ) { |
|
| 571 | + foreach ( wp_list_pluck( $field[ 'conditionalLogic' ][ 'rules' ], 'fieldId' ) as $conditional_id ) { |
|
| 572 | 572 | $post_input_id = 'input_' . str_replace( '.', '_', $conditional_id ); |
| 573 | 573 | if ( ! isset( $_POST[ $post_input_id ] ) ) { |
| 574 | - $non_submitted_fields []= $conditional_id; |
|
| 574 | + $non_submitted_fields [ ] = $conditional_id; |
|
| 575 | 575 | } |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | * (or need) to remove all fields that are not being submitted. Or look |
| 584 | 584 | * at the view edit configuration. |
| 585 | 585 | */ |
| 586 | - foreach ( $form['fields'] as $k => $field ) { |
|
| 587 | - if ( in_array( $field['id'], $non_submitted_fields ) ) { |
|
| 588 | - unset( $form['fields'][ $k ] ); |
|
| 586 | + foreach ( $form[ 'fields' ] as $k => $field ) { |
|
| 587 | + if ( in_array( $field[ 'id' ], $non_submitted_fields ) ) { |
|
| 588 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 592 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 593 | 593 | |
| 594 | 594 | return $form; |
| 595 | 595 | } |
@@ -601,14 +601,14 @@ discard block |
||
| 601 | 601 | $update = false; |
| 602 | 602 | |
| 603 | 603 | // get the most up to date entry values |
| 604 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 604 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 605 | 605 | |
| 606 | 606 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 607 | 607 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 608 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 608 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 609 | 609 | } else { |
| 610 | 610 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 611 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 611 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | |
@@ -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> |
@@ -1046,13 +1046,13 @@ discard block |
||
| 1046 | 1046 | |
| 1047 | 1047 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 1048 | 1048 | |
| 1049 | - if( ! $this->is_valid ){ |
|
| 1049 | + if ( ! $this->is_valid ) { |
|
| 1050 | 1050 | |
| 1051 | 1051 | // Keeping this compatible with Gravity Forms. |
| 1052 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 1053 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 1052 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 1053 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 1054 | 1054 | |
| 1055 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 1055 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 1056 | 1056 | |
| 1057 | 1057 | } else { |
| 1058 | 1058 | $view = \GV\View::by_id( $this->view_id ); |
@@ -1063,23 +1063,23 @@ discard block |
||
| 1063 | 1063 | |
| 1064 | 1064 | case '0': |
| 1065 | 1065 | $redirect_url = $back_link; |
| 1066 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1066 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
| 1067 | 1067 | break; |
| 1068 | 1068 | |
| 1069 | 1069 | case '1': |
| 1070 | 1070 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
| 1071 | - $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>' ); |
|
| 1071 | + $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>' ); |
|
| 1072 | 1072 | break; |
| 1073 | 1073 | |
| 1074 | 1074 | case '2': |
| 1075 | 1075 | $redirect_url = $edit_redirect_url; |
| 1076 | 1076 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
| 1077 | - $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>' ); |
|
| 1077 | + $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>' ); |
|
| 1078 | 1078 | break; |
| 1079 | 1079 | |
| 1080 | 1080 | case '': |
| 1081 | 1081 | default: |
| 1082 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1082 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1083 | 1083 | break; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | * @param array $entry Gravity Forms entry array |
| 1096 | 1096 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 1097 | 1097 | */ |
| 1098 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1098 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1099 | 1099 | |
| 1100 | 1100 | echo GVCommon::generate_notice( $message ); |
| 1101 | 1101 | } |
@@ -1119,21 +1119,21 @@ discard block |
||
| 1119 | 1119 | */ |
| 1120 | 1120 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1121 | 1121 | |
| 1122 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1123 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1122 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1123 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1124 | 1124 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1125 | 1125 | |
| 1126 | 1126 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1127 | 1127 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1128 | 1128 | |
| 1129 | 1129 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1130 | - unset( $_GET['page'] ); |
|
| 1130 | + unset( $_GET[ 'page' ] ); |
|
| 1131 | 1131 | |
| 1132 | 1132 | // TODO: Verify multiple-page forms |
| 1133 | 1133 | |
| 1134 | 1134 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1135 | 1135 | |
| 1136 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1136 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1137 | 1137 | |
| 1138 | 1138 | ob_get_clean(); |
| 1139 | 1139 | |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | * @return string |
| 1160 | 1160 | */ |
| 1161 | 1161 | public function render_form_buttons() { |
| 1162 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1162 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | |
@@ -1179,10 +1179,10 @@ discard block |
||
| 1179 | 1179 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1180 | 1180 | |
| 1181 | 1181 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1182 | - if( isset( $this->form_after_validation ) ) { |
|
| 1182 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1183 | 1183 | $form = $this->form_after_validation; |
| 1184 | 1184 | } else { |
| 1185 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1185 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | $form = $this->filter_conditional_logic( $form ); |
@@ -1190,8 +1190,8 @@ discard block |
||
| 1190 | 1190 | $form = $this->prefill_conditional_logic( $form ); |
| 1191 | 1191 | |
| 1192 | 1192 | // for now we don't support Save and Continue feature. |
| 1193 | - if( ! self::$supports_save_and_continue ) { |
|
| 1194 | - unset( $form['save'] ); |
|
| 1193 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1194 | + unset( $form[ 'save' ] ); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | $form = $this->unselect_default_values( $form ); |
@@ -1214,31 +1214,31 @@ discard block |
||
| 1214 | 1214 | */ |
| 1215 | 1215 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1216 | 1216 | |
| 1217 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1217 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1218 | 1218 | return $field_content; |
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | $message = null; |
| 1222 | 1222 | |
| 1223 | 1223 | // First, make sure they have the capability to edit the post. |
| 1224 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1224 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1225 | 1225 | |
| 1226 | 1226 | /** |
| 1227 | 1227 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1228 | 1228 | * @param string $message The existing "You don't have permission..." text |
| 1229 | 1229 | */ |
| 1230 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1230 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1231 | 1231 | |
| 1232 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1232 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1233 | 1233 | /** |
| 1234 | 1234 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1235 | 1235 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1236 | 1236 | */ |
| 1237 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1237 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | - if( $message ) { |
|
| 1241 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1240 | + if ( $message ) { |
|
| 1241 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | return $field_content; |
@@ -1262,8 +1262,8 @@ discard block |
||
| 1262 | 1262 | |
| 1263 | 1263 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1264 | 1264 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1265 | - if( |
|
| 1266 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1265 | + if ( |
|
| 1266 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1267 | 1267 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1268 | 1268 | && ! GFCommon::is_product_field( $field->type ) |
| 1269 | 1269 | || ! empty( $field_content ) |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | $return = null; |
| 1284 | 1284 | |
| 1285 | 1285 | /** @var GravityView_Field $gv_field */ |
| 1286 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1286 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1287 | 1287 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1288 | 1288 | } else { |
| 1289 | 1289 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1292,7 +1292,7 @@ discard block |
||
| 1292 | 1292 | // If there was output, it's an error |
| 1293 | 1293 | $warnings = ob_get_clean(); |
| 1294 | 1294 | |
| 1295 | - if( !empty( $warnings ) ) { |
|
| 1295 | + if ( ! empty( $warnings ) ) { |
|
| 1296 | 1296 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1297 | 1297 | } |
| 1298 | 1298 | |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1318 | 1318 | |
| 1319 | 1319 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1320 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1320 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1321 | 1321 | |
| 1322 | 1322 | $field_value = array(); |
| 1323 | 1323 | |
@@ -1326,10 +1326,10 @@ discard block |
||
| 1326 | 1326 | |
| 1327 | 1327 | foreach ( (array)$field->inputs as $input ) { |
| 1328 | 1328 | |
| 1329 | - $input_id = strval( $input['id'] ); |
|
| 1329 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1330 | 1330 | |
| 1331 | 1331 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1332 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1332 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1333 | 1333 | $allow_pre_populated = false; |
| 1334 | 1334 | } |
| 1335 | 1335 | |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | |
| 1338 | 1338 | $pre_value = $field->get_value_submission( array(), false ); |
| 1339 | 1339 | |
| 1340 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1340 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1341 | 1341 | |
| 1342 | 1342 | } else { |
| 1343 | 1343 | |
@@ -1348,13 +1348,13 @@ discard block |
||
| 1348 | 1348 | |
| 1349 | 1349 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1350 | 1350 | // or pre-populated value if not empty and set to override saved value |
| 1351 | - $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; |
|
| 1351 | + $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; |
|
| 1352 | 1352 | |
| 1353 | 1353 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1354 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1354 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1355 | 1355 | $categories = array(); |
| 1356 | 1356 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1357 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1357 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1358 | 1358 | } |
| 1359 | 1359 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1360 | 1360 | } |
@@ -1382,7 +1382,7 @@ discard block |
||
| 1382 | 1382 | * @param GF_Field $field Gravity Forms field object |
| 1383 | 1383 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1384 | 1384 | */ |
| 1385 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1385 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1386 | 1386 | |
| 1387 | 1387 | return $field_value; |
| 1388 | 1388 | } |
@@ -1399,12 +1399,12 @@ discard block |
||
| 1399 | 1399 | */ |
| 1400 | 1400 | public function gform_pre_validation( $form ) { |
| 1401 | 1401 | |
| 1402 | - if( ! $this->verify_nonce() ) { |
|
| 1402 | + if ( ! $this->verify_nonce() ) { |
|
| 1403 | 1403 | return $form; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | // Fix PHP warning regarding undefined index. |
| 1407 | - foreach ( $form['fields'] as &$field) { |
|
| 1407 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1408 | 1408 | |
| 1409 | 1409 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1410 | 1410 | // expects certain field array items to be set. |
@@ -1412,7 +1412,7 @@ discard block |
||
| 1412 | 1412 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1415 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1416 | 1416 | |
| 1417 | 1417 | /** |
| 1418 | 1418 | * 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. |
@@ -1426,26 +1426,26 @@ discard block |
||
| 1426 | 1426 | // Set the previous value |
| 1427 | 1427 | $entry = $this->get_entry(); |
| 1428 | 1428 | |
| 1429 | - $input_name = 'input_'.$field->id; |
|
| 1430 | - $form_id = $form['id']; |
|
| 1429 | + $input_name = 'input_' . $field->id; |
|
| 1430 | + $form_id = $form[ 'id' ]; |
|
| 1431 | 1431 | |
| 1432 | 1432 | $value = NULL; |
| 1433 | 1433 | |
| 1434 | 1434 | // Use the previous entry value as the default. |
| 1435 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1435 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1436 | 1436 | $value = $entry[ $field->id ]; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | // If this is a single upload file |
| 1440 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1441 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1442 | - $value = $file_path['url']; |
|
| 1440 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1441 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1442 | + $value = $file_path[ 'url' ]; |
|
| 1443 | 1443 | |
| 1444 | 1444 | } else { |
| 1445 | 1445 | |
| 1446 | 1446 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1447 | 1447 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1448 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1448 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1449 | 1449 | |
| 1450 | 1450 | } |
| 1451 | 1451 | |
@@ -1453,10 +1453,10 @@ discard block |
||
| 1453 | 1453 | |
| 1454 | 1454 | // If there are fresh uploads, process and merge them. |
| 1455 | 1455 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1456 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1456 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1457 | 1457 | $value = empty( $value ) ? '[]' : $value; |
| 1458 | 1458 | $value = stripslashes_deep( $value ); |
| 1459 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1459 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | } else { |
@@ -1474,8 +1474,8 @@ discard block |
||
| 1474 | 1474 | |
| 1475 | 1475 | case 'number': |
| 1476 | 1476 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1477 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1478 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1477 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1478 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | break; |
| 1481 | 1481 | } |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | * You can enter whatever you want! |
| 1513 | 1513 | * We try validating, and customize the results using `self::custom_validation()` |
| 1514 | 1514 | */ |
| 1515 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1515 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1516 | 1516 | |
| 1517 | 1517 | // Needed by the validate funtion |
| 1518 | 1518 | $failed_validation_page = NULL; |
@@ -1520,14 +1520,14 @@ discard block |
||
| 1520 | 1520 | |
| 1521 | 1521 | // Prevent entry limit from running when editing an entry, also |
| 1522 | 1522 | // prevent form scheduling from preventing editing |
| 1523 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1523 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1524 | 1524 | |
| 1525 | 1525 | // Hide fields depending on Edit Entry settings |
| 1526 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1526 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1527 | 1527 | |
| 1528 | 1528 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1529 | 1529 | |
| 1530 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1530 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | |
| 1551 | 1551 | $gv_valid = true; |
| 1552 | 1552 | |
| 1553 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1553 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1554 | 1554 | |
| 1555 | 1555 | $value = RGFormsModel::get_field_value( $field ); |
| 1556 | 1556 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1563,35 +1563,35 @@ discard block |
||
| 1563 | 1563 | case 'post_image': |
| 1564 | 1564 | |
| 1565 | 1565 | // in case nothing is uploaded but there are already files saved |
| 1566 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1566 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1567 | 1567 | $field->failed_validation = false; |
| 1568 | 1568 | unset( $field->validation_message ); |
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1572 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1572 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1573 | 1573 | |
| 1574 | 1574 | $input_name = 'input_' . $field->id; |
| 1575 | 1575 | //uploaded |
| 1576 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1576 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1577 | 1577 | |
| 1578 | 1578 | //existent |
| 1579 | 1579 | $entry = $this->get_entry(); |
| 1580 | 1580 | $value = NULL; |
| 1581 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1581 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1582 | 1582 | $value = json_decode( $entry[ $field->id ], true ); |
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | 1585 | // count uploaded files and existent entry files |
| 1586 | 1586 | $count_files = count( $file_names ) + count( $value ); |
| 1587 | 1587 | |
| 1588 | - if( $count_files > $field->maxFiles ) { |
|
| 1588 | + if ( $count_files > $field->maxFiles ) { |
|
| 1589 | 1589 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1590 | 1590 | $field->failed_validation = 1; |
| 1591 | 1591 | $gv_valid = false; |
| 1592 | 1592 | |
| 1593 | 1593 | // in case of error make sure the newest upload files are removed from the upload input |
| 1594 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1594 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | } |
@@ -1602,7 +1602,7 @@ discard block |
||
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | // This field has failed validation. |
| 1605 | - if( !empty( $field->failed_validation ) ) { |
|
| 1605 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1606 | 1606 | |
| 1607 | 1607 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1608 | 1608 | |
@@ -1620,19 +1620,19 @@ discard block |
||
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | // You can't continue inside a switch, so we do it after. |
| 1623 | - if( empty( $field->failed_validation ) ) { |
|
| 1623 | + if ( empty( $field->failed_validation ) ) { |
|
| 1624 | 1624 | continue; |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1628 | 1628 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1629 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1629 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1630 | 1630 | |
| 1631 | 1631 | $entry = $this->get_entry(); |
| 1632 | 1632 | |
| 1633 | 1633 | // If the value of the entry is the same as the stored value |
| 1634 | 1634 | // Then we can assume it's not a duplicate, it's the same. |
| 1635 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1635 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1636 | 1636 | //if value submitted was not changed, then don't validate |
| 1637 | 1637 | $field->failed_validation = false; |
| 1638 | 1638 | |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | } |
| 1646 | 1646 | |
| 1647 | 1647 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1648 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1648 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1649 | 1649 | unset( $field->validation_message ); |
| 1650 | 1650 | $field->validation_message = false; |
| 1651 | 1651 | continue; |
@@ -1657,12 +1657,12 @@ discard block |
||
| 1657 | 1657 | |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1660 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1661 | 1661 | |
| 1662 | 1662 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1663 | 1663 | |
| 1664 | 1664 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1665 | - $this->form_after_validation = $validation_results['form']; |
|
| 1665 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1666 | 1666 | |
| 1667 | 1667 | return $validation_results; |
| 1668 | 1668 | } |
@@ -1675,7 +1675,7 @@ discard block |
||
| 1675 | 1675 | */ |
| 1676 | 1676 | public function get_entry() { |
| 1677 | 1677 | |
| 1678 | - if( empty( $this->entry ) ) { |
|
| 1678 | + if ( empty( $this->entry ) ) { |
|
| 1679 | 1679 | // Get the database value of the entry that's being edited |
| 1680 | 1680 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1681 | 1681 | } |
@@ -1707,10 +1707,10 @@ discard block |
||
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | 1709 | // If edit tab not yet configured, show all fields |
| 1710 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1710 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1711 | 1711 | |
| 1712 | 1712 | // Hide fields depending on admin settings |
| 1713 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1713 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1714 | 1714 | |
| 1715 | 1715 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1716 | 1716 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | */ |
| 1743 | 1743 | private function filter_fields( $fields, $configured_fields ) { |
| 1744 | 1744 | |
| 1745 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1745 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1746 | 1746 | return $fields; |
| 1747 | 1747 | } |
| 1748 | 1748 | |
@@ -1755,18 +1755,18 @@ discard block |
||
| 1755 | 1755 | |
| 1756 | 1756 | // Remove the fields that have calculation properties and keep them to be used later |
| 1757 | 1757 | // @since 1.16.2 |
| 1758 | - if( $field->has_calculation() ) { |
|
| 1759 | - $this->fields_with_calculation[] = $field; |
|
| 1758 | + if ( $field->has_calculation() ) { |
|
| 1759 | + $this->fields_with_calculation[ ] = $field; |
|
| 1760 | 1760 | // don't remove the calculation fields on form render. |
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1763 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1764 | 1764 | unset( $fields[ $key ] ); |
| 1765 | 1765 | } |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | // The Edit tab has not been configured, so we return all fields by default. |
| 1769 | - if( empty( $configured_fields ) ) { |
|
| 1769 | + if ( empty( $configured_fields ) ) { |
|
| 1770 | 1770 | return array_values( $fields ); |
| 1771 | 1771 | } |
| 1772 | 1772 | |
@@ -1775,8 +1775,8 @@ discard block |
||
| 1775 | 1775 | |
| 1776 | 1776 | /** @var GF_Field $field */ |
| 1777 | 1777 | foreach ( $fields as $field ) { |
| 1778 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1779 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1778 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1779 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1780 | 1780 | break; |
| 1781 | 1781 | } |
| 1782 | 1782 | |
@@ -1799,14 +1799,14 @@ discard block |
||
| 1799 | 1799 | |
| 1800 | 1800 | $return_field = $field; |
| 1801 | 1801 | |
| 1802 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1802 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1803 | 1803 | $return_field->label = ''; |
| 1804 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1805 | - $return_field->label = $field_setting['custom_label']; |
|
| 1804 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1805 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1809 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1808 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1809 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | 1812 | /** |
@@ -1844,16 +1844,16 @@ discard block |
||
| 1844 | 1844 | */ |
| 1845 | 1845 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1846 | 1846 | |
| 1847 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1848 | - foreach( $fields as $k => $field ) { |
|
| 1849 | - if( $field->adminOnly ) { |
|
| 1847 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1848 | + foreach ( $fields as $k => $field ) { |
|
| 1849 | + if ( $field->adminOnly ) { |
|
| 1850 | 1850 | unset( $fields[ $k ] ); |
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | return array_values( $fields ); |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | - foreach( $fields as &$field ) { |
|
| 1856 | + foreach ( $fields as &$field ) { |
|
| 1857 | 1857 | $field->adminOnly = false; |
| 1858 | 1858 | } |
| 1859 | 1859 | |
@@ -1874,7 +1874,7 @@ discard block |
||
| 1874 | 1874 | */ |
| 1875 | 1875 | private function unselect_default_values( $form ) { |
| 1876 | 1876 | |
| 1877 | - foreach ( $form['fields'] as &$field ) { |
|
| 1877 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1878 | 1878 | |
| 1879 | 1879 | if ( empty( $field->choices ) ) { |
| 1880 | 1880 | continue; |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | |
| 1883 | 1883 | foreach ( $field->choices as &$choice ) { |
| 1884 | 1884 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1885 | - $choice['isSelected'] = false; |
|
| 1885 | + $choice[ 'isSelected' ] = false; |
|
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | 1888 | } |
@@ -1907,22 +1907,22 @@ discard block |
||
| 1907 | 1907 | */ |
| 1908 | 1908 | function prefill_conditional_logic( $form ) { |
| 1909 | 1909 | |
| 1910 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1910 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1911 | 1911 | return $form; |
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | 1914 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1915 | 1915 | /** @var GF_Field $field */ |
| 1916 | - foreach ( $form['fields'] as &$field ) { |
|
| 1916 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1917 | 1917 | |
| 1918 | - if( 'checkbox' === $field->type ) { |
|
| 1918 | + if ( 'checkbox' === $field->type ) { |
|
| 1919 | 1919 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1920 | - $input_id = $input['id']; |
|
| 1920 | + $input_id = $input[ 'id' ]; |
|
| 1921 | 1921 | $choice = $field->choices[ $key ]; |
| 1922 | 1922 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1923 | 1923 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1924 | - if( $match ) { |
|
| 1925 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1924 | + if ( $match ) { |
|
| 1925 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1926 | 1926 | } |
| 1927 | 1927 | } |
| 1928 | 1928 | } else { |
@@ -1930,15 +1930,15 @@ discard block |
||
| 1930 | 1930 | // We need to run through each field to set the default values |
| 1931 | 1931 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1932 | 1932 | |
| 1933 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1933 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1934 | 1934 | |
| 1935 | - if( 'list' === $field->type ) { |
|
| 1935 | + if ( 'list' === $field->type ) { |
|
| 1936 | 1936 | $list_rows = maybe_unserialize( $field_value ); |
| 1937 | 1937 | |
| 1938 | 1938 | $list_field_value = array(); |
| 1939 | - foreach ( (array) $list_rows as $row ) { |
|
| 1940 | - foreach ( (array) $row as $column ) { |
|
| 1941 | - $list_field_value[] = $column; |
|
| 1939 | + foreach ( (array)$list_rows as $row ) { |
|
| 1940 | + foreach ( (array)$row as $column ) { |
|
| 1941 | + $list_field_value[ ] = $column; |
|
| 1942 | 1942 | } |
| 1943 | 1943 | } |
| 1944 | 1944 | |
@@ -1973,16 +1973,16 @@ discard block |
||
| 1973 | 1973 | */ |
| 1974 | 1974 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1975 | 1975 | |
| 1976 | - if( $use_conditional_logic ) { |
|
| 1976 | + if ( $use_conditional_logic ) { |
|
| 1977 | 1977 | return $form; |
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | - foreach( $form['fields'] as &$field ) { |
|
| 1980 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1981 | 1981 | /* @var GF_Field $field */ |
| 1982 | 1982 | $field->conditionalLogic = null; |
| 1983 | 1983 | } |
| 1984 | 1984 | |
| 1985 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1985 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1986 | 1986 | |
| 1987 | 1987 | return $form; |
| 1988 | 1988 | |
@@ -1999,7 +1999,7 @@ discard block |
||
| 1999 | 1999 | */ |
| 2000 | 2000 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 2001 | 2001 | |
| 2002 | - if( ! $this->is_edit_entry() ) { |
|
| 2002 | + if ( ! $this->is_edit_entry() ) { |
|
| 2003 | 2003 | return $has_conditional_logic; |
| 2004 | 2004 | } |
| 2005 | 2005 | |
@@ -2031,44 +2031,44 @@ discard block |
||
| 2031 | 2031 | * 2. There are two entries embedded using oEmbed |
| 2032 | 2032 | * 3. One of the entries has just been saved |
| 2033 | 2033 | */ |
| 2034 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 2034 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 2035 | 2035 | |
| 2036 | 2036 | $error = true; |
| 2037 | 2037 | |
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 2040 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 2041 | 2041 | |
| 2042 | 2042 | $error = true; |
| 2043 | 2043 | |
| 2044 | - } elseif( ! $this->verify_nonce() ) { |
|
| 2044 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 2045 | 2045 | |
| 2046 | 2046 | /** |
| 2047 | 2047 | * If the Entry is embedded, there may be two entries on the same page. |
| 2048 | 2048 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 2049 | 2049 | */ |
| 2050 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2050 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2051 | 2051 | $error = true; |
| 2052 | 2052 | } else { |
| 2053 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 2053 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2059 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 2058 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2059 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | - if( $this->entry['status'] === 'trash' ) { |
|
| 2063 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2062 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 2063 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | // No errors; everything's fine here! |
| 2067 | - if( empty( $error ) ) { |
|
| 2067 | + if ( empty( $error ) ) { |
|
| 2068 | 2068 | return true; |
| 2069 | 2069 | } |
| 2070 | 2070 | |
| 2071 | - if( $echo && $error !== true ) { |
|
| 2071 | + if ( $echo && $error !== true ) { |
|
| 2072 | 2072 | |
| 2073 | 2073 | $error = esc_html( $error ); |
| 2074 | 2074 | |
@@ -2076,10 +2076,10 @@ discard block |
||
| 2076 | 2076 | * @since 1.9 |
| 2077 | 2077 | */ |
| 2078 | 2078 | if ( ! empty( $this->entry ) ) { |
| 2079 | - $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;" ) ); |
|
| 2079 | + $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;" ) ); |
|
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2082 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2099,17 +2099,17 @@ discard block |
||
| 2099 | 2099 | |
| 2100 | 2100 | $error = NULL; |
| 2101 | 2101 | |
| 2102 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2103 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2102 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2103 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | 2106 | // No errors; everything's fine here! |
| 2107 | - if( empty( $error ) ) { |
|
| 2107 | + if ( empty( $error ) ) { |
|
| 2108 | 2108 | return true; |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | - if( $echo ) { |
|
| 2112 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2111 | + if ( $echo ) { |
|
| 2112 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2113 | 2113 | } |
| 2114 | 2114 | |
| 2115 | 2115 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2130,14 +2130,14 @@ discard block |
||
| 2130 | 2130 | private function check_user_cap_edit_field( $field ) { |
| 2131 | 2131 | |
| 2132 | 2132 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2133 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2133 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2134 | 2134 | return true; |
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2137 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2138 | 2138 | |
| 2139 | - if( $field_cap ) { |
|
| 2140 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2139 | + if ( $field_cap ) { |
|
| 2140 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | return false; |
@@ -2151,17 +2151,17 @@ discard block |
||
| 2151 | 2151 | public function verify_nonce() { |
| 2152 | 2152 | |
| 2153 | 2153 | // Verify form submitted for editing single |
| 2154 | - if( $this->is_edit_entry_submission() ) { |
|
| 2154 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2155 | 2155 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2156 | 2156 | } |
| 2157 | 2157 | |
| 2158 | 2158 | // Verify |
| 2159 | - else if( ! $this->is_edit_entry() ) { |
|
| 2159 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2160 | 2160 | $valid = false; |
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | else { |
| 2164 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2164 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | /** |