@@ -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 |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | type="' . $field['type'] . '" |
559 | 559 | name="' . esc_attr( $name ) . '" |
560 | 560 | value="' . $value . '" ' . |
561 | - implode( ' ', $attributes ) . |
|
562 | - ' />'; |
|
561 | + implode( ' ', $attributes ) . |
|
562 | + ' />'; |
|
563 | 563 | |
564 | 564 | if ( $echo ) { |
565 | 565 | echo $html; |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
580 | - * Check whether GravityView is being saved |
|
581 | - * |
|
582 | - * The generic is_save_postback() is true for all addons |
|
583 | - * |
|
584 | - * @since 2.0.8 |
|
585 | - * |
|
580 | + * Check whether GravityView is being saved |
|
581 | + * |
|
582 | + * The generic is_save_postback() is true for all addons |
|
583 | + * |
|
584 | + * @since 2.0.8 |
|
585 | + * |
|
586 | 586 | * @return bool |
587 | 587 | */ |
588 | 588 | public function is_save_postback() { |
@@ -596,16 +596,16 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public function license_key_notice() { |
598 | 598 | |
599 | - if( $this->is_save_postback() ) { |
|
600 | - $settings = $this->get_posted_settings(); |
|
601 | - $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
602 | - $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
603 | - } else { |
|
604 | - $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
605 | - $license_key = $this->get( 'license_key' ); |
|
606 | - } |
|
599 | + if( $this->is_save_postback() ) { |
|
600 | + $settings = $this->get_posted_settings(); |
|
601 | + $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
602 | + $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
603 | + } else { |
|
604 | + $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
605 | + $license_key = $this->get( 'license_key' ); |
|
606 | + } |
|
607 | 607 | |
608 | - $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
608 | + $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
609 | 609 | |
610 | 610 | $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' ); |
611 | 611 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | $update_below = false; |
623 | 623 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
624 | 624 | |
625 | - switch ( $license_status ) { |
|
625 | + switch ( $license_status ) { |
|
626 | 626 | /** @since 1.17 */ |
627 | 627 | case 'expired': |
628 | 628 | $title = __( 'Expired License', 'gravityview' ); |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | return; |
661 | 661 | } |
662 | 662 | |
663 | - \GravityView_Admin_Notices::add_notice( array( |
|
664 | - 'message' => $message, |
|
665 | - 'class' => 'notice notice-warning', |
|
666 | - 'title' => $title, |
|
667 | - 'cap' => 'gravityview_edit_settings', |
|
668 | - 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
669 | - ) ); |
|
663 | + \GravityView_Admin_Notices::add_notice( array( |
|
664 | + 'message' => $message, |
|
665 | + 'class' => 'notice notice-warning', |
|
666 | + 'title' => $title, |
|
667 | + 'cap' => 'gravityview_edit_settings', |
|
668 | + 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
669 | + ) ); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -680,12 +680,12 @@ discard block |
||
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
683 | - * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
684 | - * |
|
685 | - * @since 1.21.5 |
|
686 | - * |
|
687 | - * @see GFAddOn::scripts() |
|
688 | - * |
|
683 | + * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
684 | + * |
|
685 | + * @since 1.21.5 |
|
686 | + * |
|
687 | + * @see GFAddOn::scripts() |
|
688 | + * |
|
689 | 689 | * @return array Array of scripts |
690 | 690 | */ |
691 | 691 | public function scripts() { |
@@ -694,10 +694,10 @@ discard block |
||
694 | 694 | $scripts[] = array( |
695 | 695 | 'handle' => 'gform_tooltip_init', |
696 | 696 | 'enqueue' => array( |
697 | - array( |
|
698 | - 'admin_page' => array( 'app_settings' ) |
|
699 | - ) |
|
700 | - ) |
|
697 | + array( |
|
698 | + 'admin_page' => array( 'app_settings' ) |
|
699 | + ) |
|
700 | + ) |
|
701 | 701 | ); |
702 | 702 | |
703 | 703 | return $scripts; |
@@ -715,10 +715,10 @@ discard block |
||
715 | 715 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
716 | 716 | 'version' => Plugin::$version, |
717 | 717 | 'deps' => array( |
718 | - 'gform_admin', |
|
718 | + 'gform_admin', |
|
719 | 719 | 'gaddon_form_settings_css', |
720 | - 'gform_tooltip', |
|
721 | - 'gform_font_awesome', |
|
720 | + 'gform_tooltip', |
|
721 | + 'gform_font_awesome', |
|
722 | 722 | ), |
723 | 723 | 'enqueue' => array( |
724 | 724 | array( 'admin_page' => array( |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | array( |
887 | 887 | 'label' => esc_html__( 'Show me beta versions if they are available.', 'gravityview' ), |
888 | 888 | 'value' => '1', |
889 | - 'name' => 'beta', |
|
889 | + 'name' => 'beta', |
|
890 | 890 | ), |
891 | 891 | ), |
892 | 892 | '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' ), |
@@ -924,38 +924,38 @@ discard block |
||
924 | 924 | |
925 | 925 | if ( empty( $field['disabled'] ) ) { |
926 | 926 | unset( $field['disabled'] ); |
927 | - } |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | - $sections = array( |
|
931 | - array( |
|
932 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
933 | - 'fields' => $fields, |
|
934 | - ) |
|
935 | - ); |
|
930 | + $sections = array( |
|
931 | + array( |
|
932 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
933 | + 'fields' => $fields, |
|
934 | + ) |
|
935 | + ); |
|
936 | 936 | |
937 | - // custom 'update settings' button |
|
938 | - $button = array( |
|
939 | - 'class' => 'button button-primary button-hero', |
|
940 | - 'type' => 'save', |
|
941 | - ); |
|
937 | + // custom 'update settings' button |
|
938 | + $button = array( |
|
939 | + 'class' => 'button button-primary button-hero', |
|
940 | + 'type' => 'save', |
|
941 | + ); |
|
942 | 942 | |
943 | 943 | if ( $disabled_attribute ) { |
944 | 944 | $button['disabled'] = $disabled_attribute; |
945 | 945 | } |
946 | 946 | |
947 | - /** |
|
948 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
949 | - * Extensions can tap in here to insert their own section and settings. |
|
950 | - * <code> |
|
951 | - * $sections[] = array( |
|
952 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
953 | - * 'fields' => $settings, |
|
954 | - * ); |
|
955 | - * </code> |
|
956 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
957 | - */ |
|
958 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
947 | + /** |
|
948 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
949 | + * Extensions can tap in here to insert their own section and settings. |
|
950 | + * <code> |
|
951 | + * $sections[] = array( |
|
952 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
953 | + * 'fields' => $settings, |
|
954 | + * ); |
|
955 | + * </code> |
|
956 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
957 | + */ |
|
958 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
959 | 959 | |
960 | 960 | // If there are extensions, add a section for them |
961 | 961 | if ( ! empty( $extension_sections ) ) { |
@@ -968,13 +968,13 @@ discard block |
||
968 | 968 | } |
969 | 969 | } |
970 | 970 | |
971 | - $k = count( $extension_sections ) - 1 ; |
|
972 | - $extension_sections[ $k ]['fields'][] = $button; |
|
971 | + $k = count( $extension_sections ) - 1 ; |
|
972 | + $extension_sections[ $k ]['fields'][] = $button; |
|
973 | 973 | $sections = array_merge( $sections, $extension_sections ); |
974 | 974 | } else { |
975 | - // add the 'update settings' button to the general section |
|
976 | - $sections[0]['fields'][] = $button; |
|
977 | - } |
|
975 | + // add the 'update settings' button to the general section |
|
976 | + $sections[0]['fields'][] = $button; |
|
977 | + } |
|
978 | 978 | |
979 | 979 | return $sections; |
980 | 980 | } |
@@ -1028,9 +1028,9 @@ discard block |
||
1028 | 1028 | */ |
1029 | 1029 | protected function settings_edd_license( $field, $echo = true ) { |
1030 | 1030 | |
1031 | - if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
1032 | - $field['input_type'] = 'password'; |
|
1033 | - } |
|
1031 | + if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
1032 | + $field['input_type'] = 'password'; |
|
1033 | + } |
|
1034 | 1034 | |
1035 | 1035 | $text = $this->settings_text( $field, false ); |
1036 | 1036 | |
@@ -1047,9 +1047,9 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | /** |
1049 | 1049 | * Allow pure HTML settings row |
1050 | - * |
|
1051 | - * @since 2.0.6 |
|
1052 | - * |
|
1050 | + * |
|
1051 | + * @since 2.0.6 |
|
1052 | + * |
|
1053 | 1053 | * @param array $field |
1054 | 1054 | * @param bool $echo Whether to echo the |
1055 | 1055 | * |
@@ -1115,19 +1115,19 @@ discard block |
||
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
1118 | - * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
1119 | - * |
|
1120 | - * Converts `$field['description']` to `$field['gv_description']` |
|
1121 | - * Converts `$field['subtitle']` to `$field['description']` |
|
1122 | - * |
|
1123 | - * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
1124 | - * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
1125 | - * |
|
1126 | - * @since 1.21.5.2 |
|
1127 | - * |
|
1118 | + * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
1119 | + * |
|
1120 | + * Converts `$field['description']` to `$field['gv_description']` |
|
1121 | + * Converts `$field['subtitle']` to `$field['description']` |
|
1122 | + * |
|
1123 | + * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
1124 | + * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
1125 | + * |
|
1126 | + * @since 1.21.5.2 |
|
1127 | + * |
|
1128 | 1128 | * @param array $field |
1129 | - * |
|
1130 | - * @return void |
|
1129 | + * |
|
1130 | + * @return void |
|
1131 | 1131 | */ |
1132 | 1132 | public function single_setting_row( $field ) { |
1133 | 1133 | $field['gv_description'] = Utils::get( $field, 'description' ); |
@@ -310,12 +310,12 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
313 | - * @hack |
|
314 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
315 | - */ |
|
313 | + * @hack |
|
314 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
315 | + */ |
|
316 | 316 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
317 | - continue; |
|
318 | - } |
|
317 | + continue; |
|
318 | + } |
|
319 | 319 | $fields["{$input['id']}"] = array( |
320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | ), |
1489 | 1489 | ); |
1490 | 1490 | |
1491 | - $fields = $date_created + $fields; |
|
1491 | + $fields = $date_created + $fields; |
|
1492 | 1492 | |
1493 | 1493 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1494 | 1494 | |
@@ -1516,13 +1516,13 @@ discard block |
||
1516 | 1516 | |
1517 | 1517 | } |
1518 | 1518 | |
1519 | - /** |
|
1520 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1521 | - * @since 1.12 |
|
1522 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1523 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1524 | - */ |
|
1525 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1519 | + /** |
|
1520 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1521 | + * @since 1.12 |
|
1522 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1523 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1524 | + */ |
|
1525 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1526 | 1526 | |
1527 | 1527 | return $fields; |
1528 | 1528 | } |
@@ -1814,26 +1814,26 @@ discard block |
||
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | |
1817 | - /** |
|
1818 | - * Display updated/error notice |
|
1819 | - * |
|
1820 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
1821 | - * |
|
1822 | - * @param string $notice text/HTML of notice |
|
1823 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1824 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1825 | - * |
|
1826 | - * @return string |
|
1827 | - */ |
|
1828 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1829 | - |
|
1830 | - // If $cap is defined, only show notice if user has capability |
|
1831 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1832 | - return ''; |
|
1833 | - } |
|
1834 | - |
|
1835 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1836 | - } |
|
1817 | + /** |
|
1818 | + * Display updated/error notice |
|
1819 | + * |
|
1820 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
1821 | + * |
|
1822 | + * @param string $notice text/HTML of notice |
|
1823 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1824 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1825 | + * |
|
1826 | + * @return string |
|
1827 | + */ |
|
1828 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1829 | + |
|
1830 | + // If $cap is defined, only show notice if user has capability |
|
1831 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1832 | + return ''; |
|
1833 | + } |
|
1834 | + |
|
1835 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1836 | + } |
|
1837 | 1837 | |
1838 | 1838 | /** |
1839 | 1839 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Render the page size widget |
79 | - * |
|
79 | + * |
|
80 | 80 | * @param array $widget_args The Widget shortcode args. |
81 | 81 | * @param string $content The content. |
82 | 82 | * @param string|\GV\Template_Context $context The context, if available. |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | <?php } ?> |
118 | 118 | </select> |
119 | 119 | <input type="submit" value="Submit" style="visibility: hidden; position: absolute;" /><?php |
120 | - if( ! empty( $_GET ) ) { |
|
121 | - $get = $_GET; |
|
122 | - unset( $get['page_size'] ); |
|
123 | - foreach ( $get as $key => $value ) { |
|
120 | + if( ! empty( $_GET ) ) { |
|
121 | + $get = $_GET; |
|
122 | + unset( $get['page_size'] ); |
|
123 | + foreach ( $get as $key => $value ) { |
|
124 | 124 | if ( is_array( $value ) ) { |
125 | 125 | foreach ( $value as $_key => $_value ) { |
126 | 126 | printf( '<input type="hidden" name="%s[%s]" value="%s" />', esc_attr( $key ), esc_attr( $_key ), esc_attr( $_value ) ); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | printf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $key ), esc_attr( $value ) ); |
130 | 130 | } |
131 | - } |
|
132 | - } |
|
133 | - ?> |
|
131 | + } |
|
132 | + } |
|
133 | + ?> |
|
134 | 134 | </div> |
135 | 135 | </form> |
136 | 136 | </div> |
@@ -10,175 +10,175 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | if ( ! defined( 'WPINC' ) ) { |
13 | - die; |
|
13 | + die; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | 17 | class GravityView_Edit_Entry_Admin { |
18 | 18 | |
19 | - protected $loader; |
|
19 | + protected $loader; |
|
20 | 20 | |
21 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
22 | - $this->loader = $loader; |
|
23 | - } |
|
21 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
22 | + $this->loader = $loader; |
|
23 | + } |
|
24 | 24 | |
25 | - function load() { |
|
26 | - |
|
27 | - if( !is_admin() ) { |
|
28 | - return; |
|
29 | - } |
|
30 | - |
|
31 | - // Add Edit Link as a default field, outside those set in the Gravity Form form |
|
32 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
33 | - |
|
34 | - // For the Edit Entry Link, you don't want visible to all users. |
|
35 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
25 | + function load() { |
|
26 | + |
|
27 | + if( !is_admin() ) { |
|
28 | + return; |
|
29 | + } |
|
30 | + |
|
31 | + // Add Edit Link as a default field, outside those set in the Gravity Form form |
|
32 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
33 | + |
|
34 | + // For the Edit Entry Link, you don't want visible to all users. |
|
35 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
36 | 36 | |
37 | - // Modify the field options based on the name of the field type |
|
38 | - add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
|
37 | + // Modify the field options based on the name of the field type |
|
38 | + add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
|
39 | 39 | |
40 | - // add tooltips |
|
41 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
42 | - |
|
43 | - // custom fields' options for zone EDIT |
|
44 | - add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
49 | - * @param array $entry_default_fields Existing fields |
|
50 | - * @param string|array $form form_ID or form object |
|
51 | - * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
52 | - */ |
|
53 | - function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
54 | - |
|
55 | - if( $zone !== 'edit' ) { |
|
56 | - |
|
57 | - $entry_default_fields['edit_link'] = array( |
|
58 | - 'label' => __('Edit Entry', 'gravityview'), |
|
59 | - 'type' => 'edit_link', |
|
60 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
61 | - ); |
|
62 | - |
|
63 | - } |
|
64 | - |
|
65 | - return $entry_default_fields; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Change wording for the Edit context to read Entry Creator |
|
70 | - * |
|
71 | - * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
72 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
73 | - * @param string $template_id Table slug |
|
74 | - * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
75 | - * @param string $context What context are we in? Example: `single` or `directory` |
|
76 | - * @param string $input_type (textarea, list, select, etc.) |
|
77 | - * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
78 | - */ |
|
79 | - function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
80 | - |
|
81 | - $caps = $visibility_caps; |
|
82 | - |
|
83 | - // If we're configuring fields in the edit context, we want a limited selection |
|
84 | - if( $context === 'edit' ) { |
|
85 | - |
|
86 | - // Remove other built-in caps. |
|
87 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
88 | - |
|
89 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
90 | - } |
|
91 | - |
|
92 | - return $caps; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Add "Edit Link Text" setting to the edit_link field settings |
|
97 | - * @param [type] $field_options [description] |
|
98 | - * @param [type] $template_id [description] |
|
99 | - * @param [type] $field_id [description] |
|
100 | - * @param [type] $context [description] |
|
101 | - * @param [type] $input_type [description] |
|
102 | - * @return [type] [description] |
|
103 | - */ |
|
104 | - function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
105 | - |
|
106 | - // Always a link, never a filter |
|
107 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
108 | - |
|
109 | - // Edit Entry link should only appear to visitors capable of editing entries |
|
110 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
111 | - |
|
112 | - $add_option['edit_link'] = array( |
|
113 | - 'type' => 'text', |
|
114 | - 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
115 | - 'desc' => NULL, |
|
116 | - 'value' => __('Edit Entry', 'gravityview'), |
|
117 | - 'merge_tags' => true, |
|
118 | - ); |
|
119 | - |
|
120 | - return array_merge( $add_option, $field_options ); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Add tooltips |
|
125 | - * @param array $tooltips Existing tooltips |
|
126 | - * @return array Modified tooltips |
|
127 | - */ |
|
128 | - function tooltips( $tooltips ) { |
|
129 | - |
|
130 | - $return = $tooltips; |
|
131 | - |
|
132 | - $return['allow_edit_cap'] = array( |
|
133 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
134 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
135 | - ); |
|
136 | - |
|
137 | - return $return; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Manipulate the fields' options for the EDIT ENTRY screen |
|
142 | - * @param [type] $field_options [description] |
|
143 | - * @param [type] $template_id [description] |
|
144 | - * @param [type] $field_id [description] |
|
145 | - * @param [type] $context [description] |
|
146 | - * @param [type] $input_type [description] |
|
147 | - * @return [type] [description] |
|
148 | - */ |
|
40 | + // add tooltips |
|
41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
42 | + |
|
43 | + // custom fields' options for zone EDIT |
|
44 | + add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
49 | + * @param array $entry_default_fields Existing fields |
|
50 | + * @param string|array $form form_ID or form object |
|
51 | + * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
52 | + */ |
|
53 | + function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
54 | + |
|
55 | + if( $zone !== 'edit' ) { |
|
56 | + |
|
57 | + $entry_default_fields['edit_link'] = array( |
|
58 | + 'label' => __('Edit Entry', 'gravityview'), |
|
59 | + 'type' => 'edit_link', |
|
60 | + 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
61 | + ); |
|
62 | + |
|
63 | + } |
|
64 | + |
|
65 | + return $entry_default_fields; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Change wording for the Edit context to read Entry Creator |
|
70 | + * |
|
71 | + * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
72 | + * @param string $field_type Type of field options to render (`field` or `widget`) |
|
73 | + * @param string $template_id Table slug |
|
74 | + * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
75 | + * @param string $context What context are we in? Example: `single` or `directory` |
|
76 | + * @param string $input_type (textarea, list, select, etc.) |
|
77 | + * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
78 | + */ |
|
79 | + function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
80 | + |
|
81 | + $caps = $visibility_caps; |
|
82 | + |
|
83 | + // If we're configuring fields in the edit context, we want a limited selection |
|
84 | + if( $context === 'edit' ) { |
|
85 | + |
|
86 | + // Remove other built-in caps. |
|
87 | + unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
88 | + |
|
89 | + $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
90 | + } |
|
91 | + |
|
92 | + return $caps; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Add "Edit Link Text" setting to the edit_link field settings |
|
97 | + * @param [type] $field_options [description] |
|
98 | + * @param [type] $template_id [description] |
|
99 | + * @param [type] $field_id [description] |
|
100 | + * @param [type] $context [description] |
|
101 | + * @param [type] $input_type [description] |
|
102 | + * @return [type] [description] |
|
103 | + */ |
|
104 | + function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
105 | + |
|
106 | + // Always a link, never a filter |
|
107 | + unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
108 | + |
|
109 | + // Edit Entry link should only appear to visitors capable of editing entries |
|
110 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
111 | + |
|
112 | + $add_option['edit_link'] = array( |
|
113 | + 'type' => 'text', |
|
114 | + 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
115 | + 'desc' => NULL, |
|
116 | + 'value' => __('Edit Entry', 'gravityview'), |
|
117 | + 'merge_tags' => true, |
|
118 | + ); |
|
119 | + |
|
120 | + return array_merge( $add_option, $field_options ); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Add tooltips |
|
125 | + * @param array $tooltips Existing tooltips |
|
126 | + * @return array Modified tooltips |
|
127 | + */ |
|
128 | + function tooltips( $tooltips ) { |
|
129 | + |
|
130 | + $return = $tooltips; |
|
131 | + |
|
132 | + $return['allow_edit_cap'] = array( |
|
133 | + 'title' => __('Limiting Edit Access', 'gravityview'), |
|
134 | + 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
135 | + ); |
|
136 | + |
|
137 | + return $return; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Manipulate the fields' options for the EDIT ENTRY screen |
|
142 | + * @param [type] $field_options [description] |
|
143 | + * @param [type] $template_id [description] |
|
144 | + * @param [type] $field_id [description] |
|
145 | + * @param [type] $context [description] |
|
146 | + * @param [type] $input_type [description] |
|
147 | + * @return [type] [description] |
|
148 | + */ |
|
149 | 149 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
150 | 150 | |
151 | - // We only want to modify the settings for the edit context |
|
152 | - if( 'edit' !== $context ) { |
|
153 | - |
|
154 | - /** |
|
155 | - * @since 1.8.4 |
|
156 | - */ |
|
157 | - $field_options['new_window'] = array( |
|
158 | - 'type' => 'checkbox', |
|
159 | - 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
|
160 | - 'value' => false, |
|
161 | - ); |
|
162 | - |
|
163 | - return $field_options; |
|
164 | - } |
|
165 | - |
|
166 | - // Entry field is only for logged in users |
|
167 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
168 | - |
|
169 | - $add_options = array( |
|
170 | - 'allow_edit_cap' => array( |
|
171 | - 'type' => 'select', |
|
172 | - 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
173 | - 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
174 | - 'tooltip' => 'allow_edit_cap', |
|
175 | - 'class' => 'widefat', |
|
176 | - 'value' => 'read', // Default: entry creator |
|
177 | - ), |
|
178 | - ); |
|
179 | - |
|
180 | - return array_merge( $field_options, $add_options ); |
|
181 | - } |
|
151 | + // We only want to modify the settings for the edit context |
|
152 | + if( 'edit' !== $context ) { |
|
153 | + |
|
154 | + /** |
|
155 | + * @since 1.8.4 |
|
156 | + */ |
|
157 | + $field_options['new_window'] = array( |
|
158 | + 'type' => 'checkbox', |
|
159 | + 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
|
160 | + 'value' => false, |
|
161 | + ); |
|
162 | + |
|
163 | + return $field_options; |
|
164 | + } |
|
165 | + |
|
166 | + // Entry field is only for logged in users |
|
167 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
168 | + |
|
169 | + $add_options = array( |
|
170 | + 'allow_edit_cap' => array( |
|
171 | + 'type' => 'select', |
|
172 | + 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
173 | + 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
174 | + 'tooltip' => 'allow_edit_cap', |
|
175 | + 'class' => 'widefat', |
|
176 | + 'value' => 'read', // Default: entry creator |
|
177 | + ), |
|
178 | + ); |
|
179 | + |
|
180 | + return array_merge( $field_options, $add_options ); |
|
181 | + } |
|
182 | 182 | |
183 | 183 | |
184 | 184 | } // end class |
185 | 185 | \ No newline at end of file |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | - * |
|
108 | - * @var int |
|
105 | + * |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function prevent_maybe_process_form() { |
178 | 178 | |
179 | - if( ! $this->is_edit_entry_submission() ) { |
|
179 | + if( ! $this->is_edit_entry_submission() ) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | * When Edit entry view is requested setup the vars |
211 | 211 | */ |
212 | 212 | private function setup_vars() { |
213 | - global $post; |
|
213 | + global $post; |
|
214 | 214 | |
215 | 215 | $gravityview_view = GravityView_View::getInstance(); |
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(); |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | |
360 | 360 | GFFormsModel::save_lead( $form, $this->entry ); |
361 | 361 | |
362 | - // Delete the values for hidden inputs |
|
363 | - $this->unset_hidden_field_values(); |
|
362 | + // Delete the values for hidden inputs |
|
363 | + $this->unset_hidden_field_values(); |
|
364 | 364 | |
365 | 365 | $this->entry['date_created'] = $date_created; |
366 | 366 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | // Perform actions normally performed after updating a lead |
371 | 371 | $this->after_update(); |
372 | 372 | |
373 | - /** |
|
373 | + /** |
|
374 | 374 | * Must be AFTER after_update()! |
375 | 375 | * @see https://github.com/gravityview/GravityView/issues/764 |
376 | 376 | */ |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | /** |
380 | 380 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
381 | - * @since 2.1 Added $gv_data parameter |
|
381 | + * @since 2.1 Added $gv_data parameter |
|
382 | 382 | * @param array $form Gravity Forms form array |
383 | 383 | * @param string $entry_id Numeric ID of the entry that was updated |
384 | 384 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @return void |
403 | 403 | */ |
404 | 404 | private function unset_hidden_field_values() { |
405 | - global $wpdb; |
|
405 | + global $wpdb; |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -424,33 +424,33 @@ discard block |
||
424 | 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 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
427 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
428 | 428 | |
429 | 429 | if ( ! is_numeric( $input_id ) ) { |
430 | 430 | continue; |
431 | 431 | } |
432 | 432 | |
433 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
433 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
434 | 434 | |
435 | - // Reset fields that are hidden |
|
436 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
437 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
435 | + // Reset fields that are hidden |
|
436 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
437 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
438 | 438 | |
439 | 439 | $empty_value = $field->get_value_save_entry( |
440 | 440 | is_array( $field->get_entry_inputs() ) ? array() : '', |
441 | 441 | $this->form, '', $this->entry['id'], $this->entry |
442 | 442 | ); |
443 | 443 | |
444 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
444 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
445 | 445 | |
446 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
446 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
447 | 447 | |
448 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
448 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
449 | 449 | // after submission |
450 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
451 | - $_POST[ $post_input_id ] = ''; |
|
452 | - } |
|
453 | - } |
|
450 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
451 | + $_POST[ $post_input_id ] = ''; |
|
452 | + } |
|
453 | + } |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | $form = $this->filter_conditional_logic( $this->form ); |
546 | 546 | |
547 | - /** @var GF_Field $field */ |
|
547 | + /** @var GF_Field $field */ |
|
548 | 548 | foreach( $form['fields'] as $k => &$field ) { |
549 | 549 | |
550 | 550 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | |
561 | 561 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
562 | 562 | foreach( $field->inputs as $key => $input ) { |
563 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
563 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | foreach ( $this->fields_with_calculation as $field ) { |
596 | 596 | $inputs = $field->get_entry_inputs(); |
597 | 597 | if ( is_array( $inputs ) ) { |
598 | - foreach ( $inputs as $input ) { |
|
598 | + foreach ( $inputs as $input ) { |
|
599 | 599 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
600 | 600 | |
601 | 601 | if ( 'product' === $field->type ) { |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
617 | - } |
|
617 | + } |
|
618 | 618 | } else { |
619 | 619 | // Set to what it previously was if it's not editable |
620 | 620 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
661 | 661 | |
662 | 662 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
663 | - $ary = stripslashes_deep( $ary ); |
|
663 | + $ary = stripslashes_deep( $ary ); |
|
664 | 664 | $img_url = \GV\Utils::get( $ary, 0 ); |
665 | 665 | |
666 | 666 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | private function maybe_update_post_fields( $form ) { |
734 | 734 | |
735 | 735 | if( empty( $this->entry['post_id'] ) ) { |
736 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
736 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
737 | 737 | return; |
738 | 738 | } |
739 | 739 | |
@@ -768,49 +768,49 @@ discard block |
||
768 | 768 | |
769 | 769 | switch( $field->type ) { |
770 | 770 | |
771 | - case 'post_title': |
|
772 | - $post_title = $value; |
|
773 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
774 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
775 | - } |
|
776 | - $updated_post->post_title = $post_title; |
|
777 | - $updated_post->post_name = $post_title; |
|
778 | - unset( $post_title ); |
|
779 | - break; |
|
780 | - |
|
781 | - case 'post_content': |
|
782 | - $post_content = $value; |
|
783 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
784 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
785 | - } |
|
786 | - $updated_post->post_content = $post_content; |
|
787 | - unset( $post_content ); |
|
788 | - break; |
|
789 | - case 'post_excerpt': |
|
790 | - $updated_post->post_excerpt = $value; |
|
791 | - break; |
|
792 | - case 'post_tags': |
|
793 | - wp_set_post_tags( $post_id, $value, false ); |
|
794 | - break; |
|
795 | - case 'post_category': |
|
796 | - break; |
|
797 | - case 'post_custom_field': |
|
771 | + case 'post_title': |
|
772 | + $post_title = $value; |
|
773 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
774 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
775 | + } |
|
776 | + $updated_post->post_title = $post_title; |
|
777 | + $updated_post->post_name = $post_title; |
|
778 | + unset( $post_title ); |
|
779 | + break; |
|
780 | + |
|
781 | + case 'post_content': |
|
782 | + $post_content = $value; |
|
783 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
784 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
785 | + } |
|
786 | + $updated_post->post_content = $post_content; |
|
787 | + unset( $post_content ); |
|
788 | + break; |
|
789 | + case 'post_excerpt': |
|
790 | + $updated_post->post_excerpt = $value; |
|
791 | + break; |
|
792 | + case 'post_tags': |
|
793 | + wp_set_post_tags( $post_id, $value, false ); |
|
794 | + break; |
|
795 | + case 'post_category': |
|
796 | + break; |
|
797 | + case 'post_custom_field': |
|
798 | 798 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
799 | 799 | $value = $value[ $field_id ]; |
800 | 800 | } |
801 | 801 | |
802 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
803 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
804 | - } |
|
802 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
803 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
804 | + } |
|
805 | 805 | |
806 | 806 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
807 | 807 | |
808 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
809 | - break; |
|
808 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
809 | + break; |
|
810 | 810 | |
811 | - case 'post_image': |
|
812 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
813 | - break; |
|
811 | + case 'post_image': |
|
812 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
813 | + break; |
|
814 | 814 | |
815 | 815 | } |
816 | 816 | |
@@ -967,14 +967,14 @@ discard block |
||
967 | 967 | ?><h2 class="gv-edit-entry-title"> |
968 | 968 | <span><?php |
969 | 969 | |
970 | - /** |
|
971 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
972 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
973 | - * @param GravityView_Edit_Entry_Render $this This object |
|
974 | - */ |
|
975 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
970 | + /** |
|
971 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
972 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
973 | + * @param GravityView_Edit_Entry_Render $this This object |
|
974 | + */ |
|
975 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
976 | 976 | |
977 | - echo esc_attr( $edit_entry_title ); |
|
977 | + echo esc_attr( $edit_entry_title ); |
|
978 | 978 | ?></span> |
979 | 979 | </h2> |
980 | 980 | |
@@ -1037,26 +1037,26 @@ discard block |
||
1037 | 1037 | |
1038 | 1038 | switch ( $edit_redirect ) { |
1039 | 1039 | |
1040 | - case '0': |
|
1041 | - $redirect_url = $back_link; |
|
1042 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1043 | - break; |
|
1044 | - |
|
1045 | - case '1': |
|
1046 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1047 | - $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>' ); |
|
1048 | - break; |
|
1049 | - |
|
1050 | - case '2': |
|
1051 | - $redirect_url = $edit_redirect_url; |
|
1052 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1053 | - $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>' ); |
|
1054 | - break; |
|
1055 | - |
|
1056 | - case '': |
|
1057 | - default: |
|
1058 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1059 | - break; |
|
1040 | + case '0': |
|
1041 | + $redirect_url = $back_link; |
|
1042 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1043 | + break; |
|
1044 | + |
|
1045 | + case '1': |
|
1046 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1047 | + $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>' ); |
|
1048 | + break; |
|
1049 | + |
|
1050 | + case '2': |
|
1051 | + $redirect_url = $edit_redirect_url; |
|
1052 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1053 | + $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>' ); |
|
1054 | + break; |
|
1055 | + |
|
1056 | + case '': |
|
1057 | + default: |
|
1058 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1059 | + break; |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | if ( isset( $redirect_url ) ) { |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | ob_get_clean(); |
1115 | 1115 | |
1116 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1116 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1117 | 1117 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1118 | 1118 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1119 | 1119 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | // for now we don't support Save and Continue feature. |
1169 | 1169 | if( ! self::$supports_save_and_continue ) { |
1170 | - unset( $form['save'] ); |
|
1170 | + unset( $form['save'] ); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | $form = $this->unselect_default_values( $form ); |
@@ -1194,30 +1194,30 @@ discard block |
||
1194 | 1194 | return $field_content; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $message = null; |
|
1197 | + $message = null; |
|
1198 | 1198 | |
1199 | - // First, make sure they have the capability to edit the post. |
|
1200 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1199 | + // First, make sure they have the capability to edit the post. |
|
1200 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1201 | 1201 | |
1202 | - /** |
|
1203 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1204 | - * @param string $message The existing "You don't have permission..." text |
|
1205 | - */ |
|
1206 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1202 | + /** |
|
1203 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1204 | + * @param string $message The existing "You don't have permission..." text |
|
1205 | + */ |
|
1206 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1207 | 1207 | |
1208 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1209 | - /** |
|
1210 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1211 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1212 | - */ |
|
1213 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1214 | - } |
|
1208 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1209 | + /** |
|
1210 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1211 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1212 | + */ |
|
1213 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1214 | + } |
|
1215 | 1215 | |
1216 | - if( $message ) { |
|
1217 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1218 | - } |
|
1216 | + if( $message ) { |
|
1217 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1218 | + } |
|
1219 | 1219 | |
1220 | - return $field_content; |
|
1220 | + return $field_content; |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | /** |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | || ! empty( $field_content ) |
1246 | 1246 | || in_array( $field->type, array( 'honeypot' ) ) |
1247 | 1247 | ) { |
1248 | - return $field_content; |
|
1248 | + return $field_content; |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1253,24 +1253,24 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $field_value = $this->get_field_value( $field ); |
1255 | 1255 | |
1256 | - // Prevent any PHP warnings, like undefined index |
|
1257 | - ob_start(); |
|
1256 | + // Prevent any PHP warnings, like undefined index |
|
1257 | + ob_start(); |
|
1258 | 1258 | |
1259 | - $return = null; |
|
1259 | + $return = null; |
|
1260 | 1260 | |
1261 | 1261 | /** @var GravityView_Field $gv_field */ |
1262 | 1262 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1263 | 1263 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1264 | 1264 | } else { |
1265 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1266 | - } |
|
1265 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1266 | + } |
|
1267 | 1267 | |
1268 | - // If there was output, it's an error |
|
1269 | - $warnings = ob_get_clean(); |
|
1268 | + // If there was output, it's an error |
|
1269 | + $warnings = ob_get_clean(); |
|
1270 | 1270 | |
1271 | - if( !empty( $warnings ) ) { |
|
1272 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1273 | - } |
|
1271 | + if( !empty( $warnings ) ) { |
|
1272 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | return $return; |
1276 | 1276 | } |
@@ -1305,8 +1305,8 @@ discard block |
||
1305 | 1305 | $input_id = strval( $input['id'] ); |
1306 | 1306 | |
1307 | 1307 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1308 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1309 | - $allow_pre_populated = false; |
|
1308 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1309 | + $allow_pre_populated = false; |
|
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | } |
@@ -1330,7 +1330,7 @@ discard block |
||
1330 | 1330 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1331 | 1331 | $categories = array(); |
1332 | 1332 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1333 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1333 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1334 | 1334 | } |
1335 | 1335 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1336 | 1336 | } |
@@ -1340,25 +1340,25 @@ discard block |
||
1340 | 1340 | // if value is empty get the default value if defined |
1341 | 1341 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1342 | 1342 | |
1343 | - /** |
|
1344 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1345 | - * @since 1.11 |
|
1346 | - * @since 1.20 Added third param |
|
1347 | - * @param mixed $field_value field value used to populate the input |
|
1348 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1349 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1350 | - */ |
|
1351 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1352 | - |
|
1353 | - /** |
|
1354 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1355 | - * @since 1.17 |
|
1356 | - * @since 1.20 Added third param |
|
1357 | - * @param mixed $field_value field value used to populate the input |
|
1358 | - * @param GF_Field $field Gravity Forms field object |
|
1359 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1360 | - */ |
|
1361 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1343 | + /** |
|
1344 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1345 | + * @since 1.11 |
|
1346 | + * @since 1.20 Added third param |
|
1347 | + * @param mixed $field_value field value used to populate the input |
|
1348 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1349 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1350 | + */ |
|
1351 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1355 | + * @since 1.17 |
|
1356 | + * @since 1.20 Added third param |
|
1357 | + * @param mixed $field_value field value used to populate the input |
|
1358 | + * @param GF_Field $field Gravity Forms field object |
|
1359 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1360 | + */ |
|
1361 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1362 | 1362 | |
1363 | 1363 | return $field_value; |
1364 | 1364 | } |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1386 | 1386 | // expects certain field array items to be set. |
1387 | 1387 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1388 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1388 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1389 | 1389 | } |
1390 | 1390 | |
1391 | 1391 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1399,61 +1399,61 @@ discard block |
||
1399 | 1399 | */ |
1400 | 1400 | case 'fileupload': |
1401 | 1401 | |
1402 | - // Set the previous value |
|
1403 | - $entry = $this->get_entry(); |
|
1402 | + // Set the previous value |
|
1403 | + $entry = $this->get_entry(); |
|
1404 | 1404 | |
1405 | - $input_name = 'input_'.$field->id; |
|
1406 | - $form_id = $form['id']; |
|
1405 | + $input_name = 'input_'.$field->id; |
|
1406 | + $form_id = $form['id']; |
|
1407 | 1407 | |
1408 | - $value = NULL; |
|
1408 | + $value = NULL; |
|
1409 | 1409 | |
1410 | - // Use the previous entry value as the default. |
|
1411 | - if( isset( $entry[ $field->id ] ) ) { |
|
1412 | - $value = $entry[ $field->id ]; |
|
1413 | - } |
|
1410 | + // Use the previous entry value as the default. |
|
1411 | + if( isset( $entry[ $field->id ] ) ) { |
|
1412 | + $value = $entry[ $field->id ]; |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - // If this is a single upload file |
|
1416 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1417 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1418 | - $value = $file_path['url']; |
|
1415 | + // If this is a single upload file |
|
1416 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1417 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1418 | + $value = $file_path['url']; |
|
1419 | 1419 | |
1420 | - } else { |
|
1420 | + } else { |
|
1421 | 1421 | |
1422 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1423 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1424 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1422 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1423 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1424 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1425 | 1425 | |
1426 | - } |
|
1426 | + } |
|
1427 | 1427 | |
1428 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1428 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1429 | 1429 | |
1430 | - // If there are fresh uploads, process and merge them. |
|
1431 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1432 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1433 | - $value = empty( $value ) ? '[]' : $value; |
|
1434 | - $value = stripslashes_deep( $value ); |
|
1435 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1436 | - } |
|
1430 | + // If there are fresh uploads, process and merge them. |
|
1431 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1432 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1433 | + $value = empty( $value ) ? '[]' : $value; |
|
1434 | + $value = stripslashes_deep( $value ); |
|
1435 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1436 | + } |
|
1437 | 1437 | |
1438 | - } else { |
|
1438 | + } else { |
|
1439 | 1439 | |
1440 | - // A file already exists when editing an entry |
|
1441 | - // We set this to solve issue when file upload fields are required. |
|
1442 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1440 | + // A file already exists when editing an entry |
|
1441 | + // We set this to solve issue when file upload fields are required. |
|
1442 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1443 | 1443 | |
1444 | - } |
|
1444 | + } |
|
1445 | 1445 | |
1446 | - $this->entry[ $input_name ] = $value; |
|
1447 | - $_POST[ $input_name ] = $value; |
|
1446 | + $this->entry[ $input_name ] = $value; |
|
1447 | + $_POST[ $input_name ] = $value; |
|
1448 | 1448 | |
1449 | - break; |
|
1449 | + break; |
|
1450 | 1450 | |
1451 | 1451 | case 'number': |
1452 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1453 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1454 | - $_POST['input_'.$field->id ] = NULL; |
|
1455 | - } |
|
1456 | - break; |
|
1452 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1453 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1454 | + $_POST['input_'.$field->id ] = NULL; |
|
1455 | + } |
|
1456 | + break; |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | } |
@@ -1538,43 +1538,43 @@ discard block |
||
1538 | 1538 | case 'fileupload' : |
1539 | 1539 | case 'post_image': |
1540 | 1540 | |
1541 | - // in case nothing is uploaded but there are already files saved |
|
1542 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1543 | - $field->failed_validation = false; |
|
1544 | - unset( $field->validation_message ); |
|
1545 | - } |
|
1541 | + // in case nothing is uploaded but there are already files saved |
|
1542 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1543 | + $field->failed_validation = false; |
|
1544 | + unset( $field->validation_message ); |
|
1545 | + } |
|
1546 | 1546 | |
1547 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1548 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1547 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1548 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1549 | 1549 | |
1550 | - $input_name = 'input_' . $field->id; |
|
1551 | - //uploaded |
|
1552 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1550 | + $input_name = 'input_' . $field->id; |
|
1551 | + //uploaded |
|
1552 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1553 | 1553 | |
1554 | - //existent |
|
1555 | - $entry = $this->get_entry(); |
|
1556 | - $value = NULL; |
|
1557 | - if( isset( $entry[ $field->id ] ) ) { |
|
1558 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1559 | - } |
|
1554 | + //existent |
|
1555 | + $entry = $this->get_entry(); |
|
1556 | + $value = NULL; |
|
1557 | + if( isset( $entry[ $field->id ] ) ) { |
|
1558 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1559 | + } |
|
1560 | 1560 | |
1561 | - // count uploaded files and existent entry files |
|
1562 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1563 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1561 | + // count uploaded files and existent entry files |
|
1562 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1563 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1564 | 1564 | |
1565 | - if( $count_files > $field->maxFiles ) { |
|
1566 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1567 | - $field->failed_validation = 1; |
|
1568 | - $gv_valid = false; |
|
1565 | + if( $count_files > $field->maxFiles ) { |
|
1566 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1567 | + $field->failed_validation = 1; |
|
1568 | + $gv_valid = false; |
|
1569 | 1569 | |
1570 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1571 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1572 | - } |
|
1570 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1571 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1572 | + } |
|
1573 | 1573 | |
1574 | - } |
|
1574 | + } |
|
1575 | 1575 | |
1576 | 1576 | |
1577 | - break; |
|
1577 | + break; |
|
1578 | 1578 | |
1579 | 1579 | } |
1580 | 1580 | |
@@ -1585,47 +1585,47 @@ discard block |
||
1585 | 1585 | |
1586 | 1586 | switch ( $field_type ) { |
1587 | 1587 | |
1588 | - // Captchas don't need to be re-entered. |
|
1589 | - case 'captcha': |
|
1588 | + // Captchas don't need to be re-entered. |
|
1589 | + case 'captcha': |
|
1590 | 1590 | |
1591 | - // Post Image fields aren't editable, so we un-fail them. |
|
1592 | - case 'post_image': |
|
1593 | - $field->failed_validation = false; |
|
1594 | - unset( $field->validation_message ); |
|
1595 | - break; |
|
1591 | + // Post Image fields aren't editable, so we un-fail them. |
|
1592 | + case 'post_image': |
|
1593 | + $field->failed_validation = false; |
|
1594 | + unset( $field->validation_message ); |
|
1595 | + break; |
|
1596 | 1596 | |
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | // You can't continue inside a switch, so we do it after. |
1600 | 1600 | if( empty( $field->failed_validation ) ) { |
1601 | - continue; |
|
1601 | + continue; |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | // checks if the No Duplicates option is not validating entry against itself, since |
1605 | 1605 | // we're editing a stored entry, it would also assume it's a duplicate. |
1606 | 1606 | if( !empty( $field->noDuplicates ) ) { |
1607 | 1607 | |
1608 | - $entry = $this->get_entry(); |
|
1608 | + $entry = $this->get_entry(); |
|
1609 | 1609 | |
1610 | - // If the value of the entry is the same as the stored value |
|
1611 | - // Then we can assume it's not a duplicate, it's the same. |
|
1612 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1613 | - //if value submitted was not changed, then don't validate |
|
1614 | - $field->failed_validation = false; |
|
1610 | + // If the value of the entry is the same as the stored value |
|
1611 | + // Then we can assume it's not a duplicate, it's the same. |
|
1612 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1613 | + //if value submitted was not changed, then don't validate |
|
1614 | + $field->failed_validation = false; |
|
1615 | 1615 | |
1616 | - unset( $field->validation_message ); |
|
1616 | + unset( $field->validation_message ); |
|
1617 | 1617 | |
1618 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1618 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1619 | 1619 | |
1620 | - continue; |
|
1621 | - } |
|
1620 | + continue; |
|
1621 | + } |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1625 | 1625 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1626 | - unset( $field->validation_message ); |
|
1627 | - $field->validation_message = false; |
|
1628 | - continue; |
|
1626 | + unset( $field->validation_message ); |
|
1627 | + $field->validation_message = false; |
|
1628 | + continue; |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | $gv_valid = false; |
@@ -1689,8 +1689,8 @@ discard block |
||
1689 | 1689 | // Hide fields depending on admin settings |
1690 | 1690 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1691 | 1691 | |
1692 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1693 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1692 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1693 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1694 | 1694 | |
1695 | 1695 | /** |
1696 | 1696 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1765,11 +1765,11 @@ discard block |
||
1765 | 1765 | // The edit tab has been configured, so we loop through to configured settings |
1766 | 1766 | foreach ( $configured_fields as $configured_field ) { |
1767 | 1767 | |
1768 | - /** @var GF_Field $field */ |
|
1769 | - foreach ( $fields as $field ) { |
|
1768 | + /** @var GF_Field $field */ |
|
1769 | + foreach ( $fields as $field ) { |
|
1770 | 1770 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1771 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1772 | - break; |
|
1771 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1772 | + break; |
|
1773 | 1773 | } |
1774 | 1774 | |
1775 | 1775 | } |
@@ -1825,28 +1825,28 @@ discard block |
||
1825 | 1825 | */ |
1826 | 1826 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1827 | 1827 | |
1828 | - /** |
|
1828 | + /** |
|
1829 | 1829 | * @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 |
1830 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1831 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1832 | - * @since 1.9.1 |
|
1833 | - * @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. |
|
1834 | - * @param array $form GF Form array |
|
1835 | - * @param int $view_id View ID |
|
1836 | - */ |
|
1837 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1838 | - |
|
1839 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1830 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1831 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1832 | + * @since 1.9.1 |
|
1833 | + * @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. |
|
1834 | + * @param array $form GF Form array |
|
1835 | + * @param int $view_id View ID |
|
1836 | + */ |
|
1837 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1838 | + |
|
1839 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1840 | 1840 | foreach( $fields as $k => $field ) { |
1841 | 1841 | if( $field->adminOnly ) { |
1842 | - unset( $fields[ $k ] ); |
|
1842 | + unset( $fields[ $k ] ); |
|
1843 | 1843 | } |
1844 | 1844 | } |
1845 | 1845 | return array_values( $fields ); |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - foreach( $fields as &$field ) { |
|
1849 | - $field->adminOnly = false; |
|
1848 | + foreach( $fields as &$field ) { |
|
1849 | + $field->adminOnly = false; |
|
1850 | 1850 | } |
1851 | 1851 | |
1852 | 1852 | return $fields; |
@@ -1866,13 +1866,13 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | private function unselect_default_values( $form ) { |
1868 | 1868 | |
1869 | - foreach ( $form['fields'] as &$field ) { |
|
1869 | + foreach ( $form['fields'] as &$field ) { |
|
1870 | 1870 | |
1871 | 1871 | if ( empty( $field->choices ) ) { |
1872 | - continue; |
|
1872 | + continue; |
|
1873 | 1873 | } |
1874 | 1874 | |
1875 | - foreach ( $field->choices as &$choice ) { |
|
1875 | + foreach ( $field->choices as &$choice ) { |
|
1876 | 1876 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1877 | 1877 | $choice['isSelected'] = false; |
1878 | 1878 | } |
@@ -1909,36 +1909,36 @@ discard block |
||
1909 | 1909 | |
1910 | 1910 | if( 'checkbox' === $field->type ) { |
1911 | 1911 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1912 | - $input_id = $input['id']; |
|
1913 | - $choice = $field->choices[ $key ]; |
|
1914 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1915 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1916 | - if( $match ) { |
|
1917 | - $field->choices[ $key ]['isSelected'] = true; |
|
1918 | - } |
|
1912 | + $input_id = $input['id']; |
|
1913 | + $choice = $field->choices[ $key ]; |
|
1914 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1915 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1916 | + if( $match ) { |
|
1917 | + $field->choices[ $key ]['isSelected'] = true; |
|
1918 | + } |
|
1919 | 1919 | } |
1920 | 1920 | } else { |
1921 | 1921 | |
1922 | 1922 | // We need to run through each field to set the default values |
1923 | 1923 | foreach ( $this->entry as $field_id => $field_value ) { |
1924 | 1924 | |
1925 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1925 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1926 | 1926 | |
1927 | - if( 'list' === $field->type ) { |
|
1928 | - $list_rows = maybe_unserialize( $field_value ); |
|
1927 | + if( 'list' === $field->type ) { |
|
1928 | + $list_rows = maybe_unserialize( $field_value ); |
|
1929 | 1929 | |
1930 | - $list_field_value = array(); |
|
1931 | - foreach ( (array) $list_rows as $row ) { |
|
1932 | - foreach ( (array) $row as $column ) { |
|
1933 | - $list_field_value[] = $column; |
|
1934 | - } |
|
1935 | - } |
|
1930 | + $list_field_value = array(); |
|
1931 | + foreach ( (array) $list_rows as $row ) { |
|
1932 | + foreach ( (array) $row as $column ) { |
|
1933 | + $list_field_value[] = $column; |
|
1934 | + } |
|
1935 | + } |
|
1936 | 1936 | |
1937 | - $field->defaultValue = serialize( $list_field_value ); |
|
1938 | - } else { |
|
1939 | - $field->defaultValue = $field_value; |
|
1940 | - } |
|
1941 | - } |
|
1937 | + $field->defaultValue = serialize( $list_field_value ); |
|
1938 | + } else { |
|
1939 | + $field->defaultValue = $field_value; |
|
1940 | + } |
|
1941 | + } |
|
1942 | 1942 | } |
1943 | 1943 | } |
1944 | 1944 | } |
@@ -1999,7 +1999,7 @@ discard block |
||
1999 | 1999 | foreach ( $form['fields'] as &$field ) { |
2000 | 2000 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2001 | 2001 | |
2002 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2002 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2003 | 2003 | |
2004 | 2004 | if ( $field['id'] == $rule_field_id ) { |
2005 | 2005 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | return $has_conditional_logic; |
2051 | 2051 | } |
2052 | 2052 | |
2053 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2053 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2054 | 2054 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2055 | 2055 | } |
2056 | 2056 | |
@@ -2117,14 +2117,14 @@ discard block |
||
2117 | 2117 | |
2118 | 2118 | if( $echo && $error !== true ) { |
2119 | 2119 | |
2120 | - $error = esc_html( $error ); |
|
2120 | + $error = esc_html( $error ); |
|
2121 | 2121 | |
2122 | - /** |
|
2123 | - * @since 1.9 |
|
2124 | - */ |
|
2125 | - if ( ! empty( $this->entry ) ) { |
|
2126 | - $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;" ) ); |
|
2127 | - } |
|
2122 | + /** |
|
2123 | + * @since 1.9 |
|
2124 | + */ |
|
2125 | + if ( ! empty( $this->entry ) ) { |
|
2126 | + $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;" ) ); |
|
2127 | + } |
|
2128 | 2128 | |
2129 | 2129 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2130 | 2130 | } |