@@ -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 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function prevent_maybe_process_form() { |
189 | 189 | |
190 | - if( ! $this->is_edit_entry_submission() ) { |
|
190 | + if( ! $this->is_edit_entry_submission() ) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | * When Edit entry view is requested setup the vars |
222 | 222 | */ |
223 | 223 | private function setup_vars() { |
224 | - global $post; |
|
224 | + global $post; |
|
225 | 225 | |
226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
227 | 227 | |
228 | 228 | |
229 | 229 | $entries = $gravityview_view->getEntries(); |
230 | - self::$original_entry = $entries[0]; |
|
231 | - $this->entry = $entries[0]; |
|
230 | + self::$original_entry = $entries[0]; |
|
231 | + $this->entry = $entries[0]; |
|
232 | 232 | |
233 | 233 | self::$original_form = $gravityview_view->getForm(); |
234 | 234 | $this->form = $gravityview_view->getForm(); |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | |
371 | 371 | GFFormsModel::save_lead( $form, $this->entry ); |
372 | 372 | |
373 | - // Delete the values for hidden inputs |
|
374 | - $this->unset_hidden_field_values(); |
|
373 | + // Delete the values for hidden inputs |
|
374 | + $this->unset_hidden_field_values(); |
|
375 | 375 | |
376 | 376 | $this->entry['date_created'] = $date_created; |
377 | 377 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // Perform actions normally performed after updating a lead |
382 | 382 | $this->after_update(); |
383 | 383 | |
384 | - /** |
|
384 | + /** |
|
385 | 385 | * Must be AFTER after_update()! |
386 | 386 | * @see https://github.com/gravityview/GravityView/issues/764 |
387 | 387 | */ |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | /** |
391 | 391 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
392 | - * @since 2.1 Added $gv_data parameter |
|
392 | + * @since 2.1 Added $gv_data parameter |
|
393 | 393 | * @param array $form Gravity Forms form array |
394 | 394 | * @param string $entry_id Numeric ID of the entry that was updated |
395 | 395 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @return void |
414 | 414 | */ |
415 | 415 | private function unset_hidden_field_values() { |
416 | - global $wpdb; |
|
416 | + global $wpdb; |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -437,17 +437,17 @@ discard block |
||
437 | 437 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
438 | 438 | } |
439 | 439 | |
440 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
440 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
441 | 441 | |
442 | 442 | if ( ! is_numeric( $input_id ) ) { |
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | |
446 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
446 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
447 | 447 | |
448 | - // Reset fields that are hidden |
|
449 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
450 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
448 | + // Reset fields that are hidden |
|
449 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
450 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
451 | 451 | |
452 | 452 | $empty_value = $field->get_value_save_entry( |
453 | 453 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | $empty_value = ''; |
460 | 460 | } |
461 | 461 | |
462 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
462 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
463 | 463 | |
464 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
464 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
465 | 465 | |
466 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
466 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
467 | 467 | // after submission |
468 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
469 | - $_POST[ $post_input_id ] = ''; |
|
470 | - } |
|
471 | - } |
|
468 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
469 | + $_POST[ $post_input_id ] = ''; |
|
470 | + } |
|
471 | + } |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | |
563 | 563 | $form = $this->filter_conditional_logic( $this->form ); |
564 | 564 | |
565 | - /** @var GF_Field $field */ |
|
565 | + /** @var GF_Field $field */ |
|
566 | 566 | foreach( $form['fields'] as $k => &$field ) { |
567 | 567 | |
568 | 568 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | |
579 | 579 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
580 | 580 | foreach( $field->inputs as $key => $input ) { |
581 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
581 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | $inputs = $field->get_entry_inputs(); |
620 | 620 | if ( is_array( $inputs ) ) { |
621 | - foreach ( $inputs as $input ) { |
|
621 | + foreach ( $inputs as $input ) { |
|
622 | 622 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
623 | 623 | |
624 | 624 | if ( 'product' === $field->type ) { |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | } |
638 | 638 | |
639 | 639 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
640 | - } |
|
640 | + } |
|
641 | 641 | } else { |
642 | 642 | // Set to what it previously was if it's not editable |
643 | 643 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
684 | 684 | |
685 | 685 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
686 | - $ary = stripslashes_deep( $ary ); |
|
686 | + $ary = stripslashes_deep( $ary ); |
|
687 | 687 | $img_url = \GV\Utils::get( $ary, 0 ); |
688 | 688 | |
689 | 689 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | private function maybe_update_post_fields( $form ) { |
757 | 757 | |
758 | 758 | if( empty( $this->entry['post_id'] ) ) { |
759 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
759 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
760 | 760 | return; |
761 | 761 | } |
762 | 762 | |
@@ -791,49 +791,49 @@ discard block |
||
791 | 791 | |
792 | 792 | switch( $field->type ) { |
793 | 793 | |
794 | - case 'post_title': |
|
795 | - $post_title = $value; |
|
796 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
797 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
798 | - } |
|
799 | - $updated_post->post_title = $post_title; |
|
800 | - $updated_post->post_name = $post_title; |
|
801 | - unset( $post_title ); |
|
802 | - break; |
|
803 | - |
|
804 | - case 'post_content': |
|
805 | - $post_content = $value; |
|
806 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
807 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
808 | - } |
|
809 | - $updated_post->post_content = $post_content; |
|
810 | - unset( $post_content ); |
|
811 | - break; |
|
812 | - case 'post_excerpt': |
|
813 | - $updated_post->post_excerpt = $value; |
|
814 | - break; |
|
815 | - case 'post_tags': |
|
816 | - wp_set_post_tags( $post_id, $value, false ); |
|
817 | - break; |
|
818 | - case 'post_category': |
|
819 | - break; |
|
820 | - case 'post_custom_field': |
|
794 | + case 'post_title': |
|
795 | + $post_title = $value; |
|
796 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
797 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
798 | + } |
|
799 | + $updated_post->post_title = $post_title; |
|
800 | + $updated_post->post_name = $post_title; |
|
801 | + unset( $post_title ); |
|
802 | + break; |
|
803 | + |
|
804 | + case 'post_content': |
|
805 | + $post_content = $value; |
|
806 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
807 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
808 | + } |
|
809 | + $updated_post->post_content = $post_content; |
|
810 | + unset( $post_content ); |
|
811 | + break; |
|
812 | + case 'post_excerpt': |
|
813 | + $updated_post->post_excerpt = $value; |
|
814 | + break; |
|
815 | + case 'post_tags': |
|
816 | + wp_set_post_tags( $post_id, $value, false ); |
|
817 | + break; |
|
818 | + case 'post_category': |
|
819 | + break; |
|
820 | + case 'post_custom_field': |
|
821 | 821 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
822 | 822 | $value = $value[ $field_id ]; |
823 | 823 | } |
824 | 824 | |
825 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
826 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
827 | - } |
|
825 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
826 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
827 | + } |
|
828 | 828 | |
829 | 829 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
830 | 830 | |
831 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
832 | - break; |
|
831 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
832 | + break; |
|
833 | 833 | |
834 | - case 'post_image': |
|
835 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
836 | - break; |
|
834 | + case 'post_image': |
|
835 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
836 | + break; |
|
837 | 837 | |
838 | 838 | } |
839 | 839 | |
@@ -990,14 +990,14 @@ discard block |
||
990 | 990 | ?><h2 class="gv-edit-entry-title"> |
991 | 991 | <span><?php |
992 | 992 | |
993 | - /** |
|
994 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
995 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
996 | - * @param GravityView_Edit_Entry_Render $this This object |
|
997 | - */ |
|
998 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
993 | + /** |
|
994 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
995 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
996 | + * @param GravityView_Edit_Entry_Render $this This object |
|
997 | + */ |
|
998 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
999 | 999 | |
1000 | - echo esc_attr( $edit_entry_title ); |
|
1000 | + echo esc_attr( $edit_entry_title ); |
|
1001 | 1001 | ?></span> |
1002 | 1002 | </h2> |
1003 | 1003 | |
@@ -1060,26 +1060,26 @@ discard block |
||
1060 | 1060 | |
1061 | 1061 | switch ( $edit_redirect ) { |
1062 | 1062 | |
1063 | - case '0': |
|
1064 | - $redirect_url = $back_link; |
|
1065 | - $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 | - break; |
|
1067 | - |
|
1068 | - case '1': |
|
1069 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1070 | - $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 | - break; |
|
1072 | - |
|
1073 | - case '2': |
|
1074 | - $redirect_url = $edit_redirect_url; |
|
1075 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1076 | - $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 | - break; |
|
1078 | - |
|
1079 | - case '': |
|
1080 | - default: |
|
1081 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1082 | - break; |
|
1063 | + case '0': |
|
1064 | + $redirect_url = $back_link; |
|
1065 | + $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 | + break; |
|
1067 | + |
|
1068 | + case '1': |
|
1069 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1070 | + $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 | + break; |
|
1072 | + |
|
1073 | + case '2': |
|
1074 | + $redirect_url = $edit_redirect_url; |
|
1075 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1076 | + $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 | + break; |
|
1078 | + |
|
1079 | + case '': |
|
1080 | + default: |
|
1081 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1082 | + break; |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | if ( isset( $redirect_url ) ) { |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | ob_get_clean(); |
1170 | 1170 | |
1171 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1171 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1172 | 1172 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1173 | 1173 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1174 | 1174 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | |
1225 | 1225 | // for now we don't support Save and Continue feature. |
1226 | 1226 | if( ! self::$supports_save_and_continue ) { |
1227 | - unset( $form['save'] ); |
|
1227 | + unset( $form['save'] ); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | $form = $this->unselect_default_values( $form ); |
@@ -1251,30 +1251,30 @@ discard block |
||
1251 | 1251 | return $field_content; |
1252 | 1252 | } |
1253 | 1253 | |
1254 | - $message = null; |
|
1254 | + $message = null; |
|
1255 | 1255 | |
1256 | - // First, make sure they have the capability to edit the post. |
|
1257 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1256 | + // First, make sure they have the capability to edit the post. |
|
1257 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1258 | 1258 | |
1259 | - /** |
|
1260 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1261 | - * @param string $message The existing "You don't have permission..." text |
|
1262 | - */ |
|
1263 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1259 | + /** |
|
1260 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1261 | + * @param string $message The existing "You don't have permission..." text |
|
1262 | + */ |
|
1263 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1264 | 1264 | |
1265 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1266 | - /** |
|
1267 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1268 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1269 | - */ |
|
1270 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1271 | - } |
|
1265 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1266 | + /** |
|
1267 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1268 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1269 | + */ |
|
1270 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1271 | + } |
|
1272 | 1272 | |
1273 | - if( $message ) { |
|
1274 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1275 | - } |
|
1273 | + if( $message ) { |
|
1274 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1275 | + } |
|
1276 | 1276 | |
1277 | - return $field_content; |
|
1277 | + return $field_content; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | /** |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | || ! empty( $field_content ) |
1303 | 1303 | || in_array( $field->type, array( 'honeypot' ) ) |
1304 | 1304 | ) { |
1305 | - return $field_content; |
|
1305 | + return $field_content; |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1310,24 +1310,24 @@ discard block |
||
1310 | 1310 | |
1311 | 1311 | $field_value = $this->get_field_value( $field ); |
1312 | 1312 | |
1313 | - // Prevent any PHP warnings, like undefined index |
|
1314 | - ob_start(); |
|
1313 | + // Prevent any PHP warnings, like undefined index |
|
1314 | + ob_start(); |
|
1315 | 1315 | |
1316 | - $return = null; |
|
1316 | + $return = null; |
|
1317 | 1317 | |
1318 | 1318 | /** @var GravityView_Field $gv_field */ |
1319 | 1319 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1320 | 1320 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1321 | 1321 | } else { |
1322 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1323 | - } |
|
1322 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1323 | + } |
|
1324 | 1324 | |
1325 | - // If there was output, it's an error |
|
1326 | - $warnings = ob_get_clean(); |
|
1325 | + // If there was output, it's an error |
|
1326 | + $warnings = ob_get_clean(); |
|
1327 | 1327 | |
1328 | - if( !empty( $warnings ) ) { |
|
1329 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1330 | - } |
|
1328 | + if( !empty( $warnings ) ) { |
|
1329 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1330 | + } |
|
1331 | 1331 | |
1332 | 1332 | return $return; |
1333 | 1333 | } |
@@ -1362,8 +1362,8 @@ discard block |
||
1362 | 1362 | $input_id = strval( $input['id'] ); |
1363 | 1363 | |
1364 | 1364 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1365 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1366 | - $allow_pre_populated = false; |
|
1365 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1366 | + $allow_pre_populated = false; |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | } |
@@ -1387,7 +1387,7 @@ discard block |
||
1387 | 1387 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1388 | 1388 | $categories = array(); |
1389 | 1389 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1390 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1390 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1391 | 1391 | } |
1392 | 1392 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1393 | 1393 | } |
@@ -1397,25 +1397,25 @@ discard block |
||
1397 | 1397 | // if value is empty get the default value if defined |
1398 | 1398 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1399 | 1399 | |
1400 | - /** |
|
1401 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1402 | - * @since 1.11 |
|
1403 | - * @since 1.20 Added third param |
|
1404 | - * @param mixed $field_value field value used to populate the input |
|
1405 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1406 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1407 | - */ |
|
1408 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1409 | - |
|
1410 | - /** |
|
1411 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1412 | - * @since 1.17 |
|
1413 | - * @since 1.20 Added third param |
|
1414 | - * @param mixed $field_value field value used to populate the input |
|
1415 | - * @param GF_Field $field Gravity Forms field object |
|
1416 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1417 | - */ |
|
1418 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1400 | + /** |
|
1401 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1402 | + * @since 1.11 |
|
1403 | + * @since 1.20 Added third param |
|
1404 | + * @param mixed $field_value field value used to populate the input |
|
1405 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1406 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1407 | + */ |
|
1408 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1409 | + |
|
1410 | + /** |
|
1411 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1412 | + * @since 1.17 |
|
1413 | + * @since 1.20 Added third param |
|
1414 | + * @param mixed $field_value field value used to populate the input |
|
1415 | + * @param GF_Field $field Gravity Forms field object |
|
1416 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1417 | + */ |
|
1418 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1419 | 1419 | |
1420 | 1420 | return $field_value; |
1421 | 1421 | } |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1443 | 1443 | // expects certain field array items to be set. |
1444 | 1444 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1445 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1445 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1456,61 +1456,61 @@ discard block |
||
1456 | 1456 | */ |
1457 | 1457 | case 'fileupload': |
1458 | 1458 | |
1459 | - // Set the previous value |
|
1460 | - $entry = $this->get_entry(); |
|
1459 | + // Set the previous value |
|
1460 | + $entry = $this->get_entry(); |
|
1461 | 1461 | |
1462 | - $input_name = 'input_'.$field->id; |
|
1463 | - $form_id = $form['id']; |
|
1462 | + $input_name = 'input_'.$field->id; |
|
1463 | + $form_id = $form['id']; |
|
1464 | 1464 | |
1465 | - $value = NULL; |
|
1465 | + $value = NULL; |
|
1466 | 1466 | |
1467 | - // Use the previous entry value as the default. |
|
1468 | - if( isset( $entry[ $field->id ] ) ) { |
|
1469 | - $value = $entry[ $field->id ]; |
|
1470 | - } |
|
1467 | + // Use the previous entry value as the default. |
|
1468 | + if( isset( $entry[ $field->id ] ) ) { |
|
1469 | + $value = $entry[ $field->id ]; |
|
1470 | + } |
|
1471 | 1471 | |
1472 | - // If this is a single upload file |
|
1473 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1474 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1475 | - $value = $file_path['url']; |
|
1472 | + // If this is a single upload file |
|
1473 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1474 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1475 | + $value = $file_path['url']; |
|
1476 | 1476 | |
1477 | - } else { |
|
1477 | + } else { |
|
1478 | 1478 | |
1479 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1480 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1481 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1479 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1480 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1481 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1482 | 1482 | |
1483 | - } |
|
1483 | + } |
|
1484 | 1484 | |
1485 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1485 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1486 | 1486 | |
1487 | - // If there are fresh uploads, process and merge them. |
|
1488 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1489 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1490 | - $value = empty( $value ) ? '[]' : $value; |
|
1491 | - $value = stripslashes_deep( $value ); |
|
1492 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1493 | - } |
|
1487 | + // If there are fresh uploads, process and merge them. |
|
1488 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1489 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1490 | + $value = empty( $value ) ? '[]' : $value; |
|
1491 | + $value = stripslashes_deep( $value ); |
|
1492 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1493 | + } |
|
1494 | 1494 | |
1495 | - } else { |
|
1495 | + } else { |
|
1496 | 1496 | |
1497 | - // A file already exists when editing an entry |
|
1498 | - // We set this to solve issue when file upload fields are required. |
|
1499 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1497 | + // A file already exists when editing an entry |
|
1498 | + // We set this to solve issue when file upload fields are required. |
|
1499 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1500 | 1500 | |
1501 | - } |
|
1501 | + } |
|
1502 | 1502 | |
1503 | - $this->entry[ $input_name ] = $value; |
|
1504 | - $_POST[ $input_name ] = $value; |
|
1503 | + $this->entry[ $input_name ] = $value; |
|
1504 | + $_POST[ $input_name ] = $value; |
|
1505 | 1505 | |
1506 | - break; |
|
1506 | + break; |
|
1507 | 1507 | |
1508 | 1508 | case 'number': |
1509 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1510 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1511 | - $_POST['input_'.$field->id ] = NULL; |
|
1512 | - } |
|
1513 | - break; |
|
1509 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1510 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1511 | + $_POST['input_'.$field->id ] = NULL; |
|
1512 | + } |
|
1513 | + break; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | } |
@@ -1595,43 +1595,43 @@ discard block |
||
1595 | 1595 | case 'fileupload' : |
1596 | 1596 | case 'post_image': |
1597 | 1597 | |
1598 | - // in case nothing is uploaded but there are already files saved |
|
1599 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1600 | - $field->failed_validation = false; |
|
1601 | - unset( $field->validation_message ); |
|
1602 | - } |
|
1598 | + // in case nothing is uploaded but there are already files saved |
|
1599 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1600 | + $field->failed_validation = false; |
|
1601 | + unset( $field->validation_message ); |
|
1602 | + } |
|
1603 | 1603 | |
1604 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1605 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1604 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1605 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1606 | 1606 | |
1607 | - $input_name = 'input_' . $field->id; |
|
1608 | - //uploaded |
|
1609 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1607 | + $input_name = 'input_' . $field->id; |
|
1608 | + //uploaded |
|
1609 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1610 | 1610 | |
1611 | - //existent |
|
1612 | - $entry = $this->get_entry(); |
|
1613 | - $value = NULL; |
|
1614 | - if( isset( $entry[ $field->id ] ) ) { |
|
1615 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1616 | - } |
|
1611 | + //existent |
|
1612 | + $entry = $this->get_entry(); |
|
1613 | + $value = NULL; |
|
1614 | + if( isset( $entry[ $field->id ] ) ) { |
|
1615 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1616 | + } |
|
1617 | 1617 | |
1618 | - // count uploaded files and existent entry files |
|
1619 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1620 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1618 | + // count uploaded files and existent entry files |
|
1619 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1620 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1621 | 1621 | |
1622 | - if( $count_files > $field->maxFiles ) { |
|
1623 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1624 | - $field->failed_validation = 1; |
|
1625 | - $gv_valid = false; |
|
1622 | + if( $count_files > $field->maxFiles ) { |
|
1623 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1624 | + $field->failed_validation = 1; |
|
1625 | + $gv_valid = false; |
|
1626 | 1626 | |
1627 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1628 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1629 | - } |
|
1627 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1628 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1629 | + } |
|
1630 | 1630 | |
1631 | - } |
|
1631 | + } |
|
1632 | 1632 | |
1633 | 1633 | |
1634 | - break; |
|
1634 | + break; |
|
1635 | 1635 | |
1636 | 1636 | } |
1637 | 1637 | |
@@ -1642,47 +1642,47 @@ discard block |
||
1642 | 1642 | |
1643 | 1643 | switch ( $field_type ) { |
1644 | 1644 | |
1645 | - // Captchas don't need to be re-entered. |
|
1646 | - case 'captcha': |
|
1645 | + // Captchas don't need to be re-entered. |
|
1646 | + case 'captcha': |
|
1647 | 1647 | |
1648 | - // Post Image fields aren't editable, so we un-fail them. |
|
1649 | - case 'post_image': |
|
1650 | - $field->failed_validation = false; |
|
1651 | - unset( $field->validation_message ); |
|
1652 | - break; |
|
1648 | + // Post Image fields aren't editable, so we un-fail them. |
|
1649 | + case 'post_image': |
|
1650 | + $field->failed_validation = false; |
|
1651 | + unset( $field->validation_message ); |
|
1652 | + break; |
|
1653 | 1653 | |
1654 | 1654 | } |
1655 | 1655 | |
1656 | 1656 | // You can't continue inside a switch, so we do it after. |
1657 | 1657 | if( empty( $field->failed_validation ) ) { |
1658 | - continue; |
|
1658 | + continue; |
|
1659 | 1659 | } |
1660 | 1660 | |
1661 | 1661 | // checks if the No Duplicates option is not validating entry against itself, since |
1662 | 1662 | // we're editing a stored entry, it would also assume it's a duplicate. |
1663 | 1663 | if( !empty( $field->noDuplicates ) ) { |
1664 | 1664 | |
1665 | - $entry = $this->get_entry(); |
|
1665 | + $entry = $this->get_entry(); |
|
1666 | 1666 | |
1667 | - // If the value of the entry is the same as the stored value |
|
1668 | - // Then we can assume it's not a duplicate, it's the same. |
|
1669 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1670 | - //if value submitted was not changed, then don't validate |
|
1671 | - $field->failed_validation = false; |
|
1667 | + // If the value of the entry is the same as the stored value |
|
1668 | + // Then we can assume it's not a duplicate, it's the same. |
|
1669 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1670 | + //if value submitted was not changed, then don't validate |
|
1671 | + $field->failed_validation = false; |
|
1672 | 1672 | |
1673 | - unset( $field->validation_message ); |
|
1673 | + unset( $field->validation_message ); |
|
1674 | 1674 | |
1675 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1675 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1676 | 1676 | |
1677 | - continue; |
|
1678 | - } |
|
1677 | + continue; |
|
1678 | + } |
|
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1682 | 1682 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1683 | - unset( $field->validation_message ); |
|
1684 | - $field->validation_message = false; |
|
1685 | - continue; |
|
1683 | + unset( $field->validation_message ); |
|
1684 | + $field->validation_message = false; |
|
1685 | + continue; |
|
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | $gv_valid = false; |
@@ -1746,8 +1746,8 @@ discard block |
||
1746 | 1746 | // Hide fields depending on admin settings |
1747 | 1747 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1748 | 1748 | |
1749 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1750 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1749 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1750 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1751 | 1751 | |
1752 | 1752 | /** |
1753 | 1753 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1826,11 +1826,11 @@ discard block |
||
1826 | 1826 | // The edit tab has been configured, so we loop through to configured settings |
1827 | 1827 | foreach ( $configured_fields as $configured_field ) { |
1828 | 1828 | |
1829 | - /** @var GF_Field $field */ |
|
1830 | - foreach ( $fields as $field ) { |
|
1829 | + /** @var GF_Field $field */ |
|
1830 | + foreach ( $fields as $field ) { |
|
1831 | 1831 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1832 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1833 | - break; |
|
1832 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1833 | + break; |
|
1834 | 1834 | } |
1835 | 1835 | |
1836 | 1836 | } |
@@ -1886,28 +1886,28 @@ discard block |
||
1886 | 1886 | */ |
1887 | 1887 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1888 | 1888 | |
1889 | - /** |
|
1889 | + /** |
|
1890 | 1890 | * @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 |
1891 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1892 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1893 | - * @since 1.9.1 |
|
1894 | - * @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. |
|
1895 | - * @param array $form GF Form array |
|
1896 | - * @param int $view_id View ID |
|
1897 | - */ |
|
1898 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1899 | - |
|
1900 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1891 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1892 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1893 | + * @since 1.9.1 |
|
1894 | + * @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. |
|
1895 | + * @param array $form GF Form array |
|
1896 | + * @param int $view_id View ID |
|
1897 | + */ |
|
1898 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1899 | + |
|
1900 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1901 | 1901 | foreach( $fields as $k => $field ) { |
1902 | 1902 | if( $field->adminOnly ) { |
1903 | - unset( $fields[ $k ] ); |
|
1903 | + unset( $fields[ $k ] ); |
|
1904 | 1904 | } |
1905 | 1905 | } |
1906 | 1906 | return array_values( $fields ); |
1907 | 1907 | } |
1908 | 1908 | |
1909 | - foreach( $fields as &$field ) { |
|
1910 | - $field->adminOnly = false; |
|
1909 | + foreach( $fields as &$field ) { |
|
1910 | + $field->adminOnly = false; |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | return $fields; |
@@ -1927,13 +1927,13 @@ discard block |
||
1927 | 1927 | */ |
1928 | 1928 | private function unselect_default_values( $form ) { |
1929 | 1929 | |
1930 | - foreach ( $form['fields'] as &$field ) { |
|
1930 | + foreach ( $form['fields'] as &$field ) { |
|
1931 | 1931 | |
1932 | 1932 | if ( empty( $field->choices ) ) { |
1933 | - continue; |
|
1933 | + continue; |
|
1934 | 1934 | } |
1935 | 1935 | |
1936 | - foreach ( $field->choices as &$choice ) { |
|
1936 | + foreach ( $field->choices as &$choice ) { |
|
1937 | 1937 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1938 | 1938 | $choice['isSelected'] = false; |
1939 | 1939 | } |
@@ -1970,36 +1970,36 @@ discard block |
||
1970 | 1970 | |
1971 | 1971 | if( 'checkbox' === $field->type ) { |
1972 | 1972 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1973 | - $input_id = $input['id']; |
|
1974 | - $choice = $field->choices[ $key ]; |
|
1975 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1976 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1977 | - if( $match ) { |
|
1978 | - $field->choices[ $key ]['isSelected'] = true; |
|
1979 | - } |
|
1973 | + $input_id = $input['id']; |
|
1974 | + $choice = $field->choices[ $key ]; |
|
1975 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1976 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1977 | + if( $match ) { |
|
1978 | + $field->choices[ $key ]['isSelected'] = true; |
|
1979 | + } |
|
1980 | 1980 | } |
1981 | 1981 | } else { |
1982 | 1982 | |
1983 | 1983 | // We need to run through each field to set the default values |
1984 | 1984 | foreach ( $this->entry as $field_id => $field_value ) { |
1985 | 1985 | |
1986 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1986 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1987 | 1987 | |
1988 | - if( 'list' === $field->type ) { |
|
1989 | - $list_rows = maybe_unserialize( $field_value ); |
|
1988 | + if( 'list' === $field->type ) { |
|
1989 | + $list_rows = maybe_unserialize( $field_value ); |
|
1990 | 1990 | |
1991 | - $list_field_value = array(); |
|
1992 | - foreach ( (array) $list_rows as $row ) { |
|
1993 | - foreach ( (array) $row as $column ) { |
|
1994 | - $list_field_value[] = $column; |
|
1995 | - } |
|
1996 | - } |
|
1991 | + $list_field_value = array(); |
|
1992 | + foreach ( (array) $list_rows as $row ) { |
|
1993 | + foreach ( (array) $row as $column ) { |
|
1994 | + $list_field_value[] = $column; |
|
1995 | + } |
|
1996 | + } |
|
1997 | 1997 | |
1998 | - $field->defaultValue = serialize( $list_field_value ); |
|
1999 | - } else { |
|
2000 | - $field->defaultValue = $field_value; |
|
2001 | - } |
|
2002 | - } |
|
1998 | + $field->defaultValue = serialize( $list_field_value ); |
|
1999 | + } else { |
|
2000 | + $field->defaultValue = $field_value; |
|
2001 | + } |
|
2002 | + } |
|
2003 | 2003 | } |
2004 | 2004 | } |
2005 | 2005 | } |
@@ -2060,7 +2060,7 @@ discard block |
||
2060 | 2060 | foreach ( $form['fields'] as &$field ) { |
2061 | 2061 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2062 | 2062 | |
2063 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2063 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
2064 | 2064 | |
2065 | 2065 | if ( $field['id'] == $rule_field_id ) { |
2066 | 2066 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2111,7 +2111,7 @@ discard block |
||
2111 | 2111 | return $has_conditional_logic; |
2112 | 2112 | } |
2113 | 2113 | |
2114 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2114 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2115 | 2115 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2116 | 2116 | } |
2117 | 2117 | |
@@ -2178,14 +2178,14 @@ discard block |
||
2178 | 2178 | |
2179 | 2179 | if( $echo && $error !== true ) { |
2180 | 2180 | |
2181 | - $error = esc_html( $error ); |
|
2181 | + $error = esc_html( $error ); |
|
2182 | 2182 | |
2183 | - /** |
|
2184 | - * @since 1.9 |
|
2185 | - */ |
|
2186 | - if ( ! empty( $this->entry ) ) { |
|
2187 | - $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;" ) ); |
|
2188 | - } |
|
2183 | + /** |
|
2184 | + * @since 1.9 |
|
2185 | + */ |
|
2186 | + if ( ! empty( $this->entry ) ) { |
|
2187 | + $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;" ) ); |
|
2188 | + } |
|
2189 | 2189 | |
2190 | 2190 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2191 | 2191 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function add_downloads_data_filters() { |
68 | 68 | |
69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
70 | 70 | |
71 | - if ( ! $downloads_data ) { |
|
71 | + if ( ! $downloads_data ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function add_admin_menu() { |
99 | 99 | |
100 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
100 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
101 | 101 | |
102 | 102 | $menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * When on the Installer page, show a different notice than on the Settings page |
|
116 | - * |
|
115 | + * When on the Installer page, show a different notice than on the Settings page |
|
116 | + * |
|
117 | 117 | * @param array $notice |
118 | 118 | * |
119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
122 | 122 | |
123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
124 | - return $notice; |
|
125 | - } |
|
124 | + return $notice; |
|
125 | + } |
|
126 | 126 | |
127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -162,43 +162,43 @@ discard block |
||
162 | 162 | * Get downloads data from transient or from API; save transient after getting data from API |
163 | 163 | * |
164 | 164 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
165 | - * @type array $info { |
|
166 | - * @type string $id int 17 |
|
167 | - * @type string $slug Extension slug |
|
168 | - * @type string $title Extension title |
|
169 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
170 | - * @type string $modified_date |
|
171 | - * @type string $status |
|
172 | - * @type string $link URL to public plugin page |
|
173 | - * @type string $content |
|
174 | - * @type string $excerpt |
|
175 | - * @type string $thumbnail URL to thumbnail |
|
176 | - * @type array $category Taxonomy details for the plugin's category { |
|
177 | - * @type int $term_id => int 30 |
|
178 | - * @type string $name => string 'Plugins' (length=7) |
|
179 | - * @type string $slug => string 'plugins' (length=7) |
|
180 | - * @type int $term_group => int 0 |
|
181 | - * @type int $term_taxonomy_id => int 30 |
|
182 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
183 | - * @type string $description => string '' (length=0) |
|
184 | - * @type int $parent => int 0 |
|
185 | - * @type int $count => int 4 |
|
186 | - * @type string $filter => string 'raw' (length=3) |
|
187 | - * } |
|
188 | - * @type array $tags {see $category above} |
|
189 | - * @type string $textdomain string 'gravityview' (length=11) |
|
190 | - * } |
|
191 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
192 | - * @type array $licensing { |
|
193 | - * @type bool $enabled Is licensing enabled for the extension |
|
194 | - * @type string $version Version number |
|
195 | - * @type string $exp_unit Expiration unit ('years') |
|
196 | - * @type string $exp_length Expiration length ('1') |
|
197 | - * } |
|
198 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
199 | - * @type string $file string URL of the file download |
|
200 | - * } |
|
201 | - * } |
|
165 | + * @type array $info { |
|
166 | + * @type string $id int 17 |
|
167 | + * @type string $slug Extension slug |
|
168 | + * @type string $title Extension title |
|
169 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
170 | + * @type string $modified_date |
|
171 | + * @type string $status |
|
172 | + * @type string $link URL to public plugin page |
|
173 | + * @type string $content |
|
174 | + * @type string $excerpt |
|
175 | + * @type string $thumbnail URL to thumbnail |
|
176 | + * @type array $category Taxonomy details for the plugin's category { |
|
177 | + * @type int $term_id => int 30 |
|
178 | + * @type string $name => string 'Plugins' (length=7) |
|
179 | + * @type string $slug => string 'plugins' (length=7) |
|
180 | + * @type int $term_group => int 0 |
|
181 | + * @type int $term_taxonomy_id => int 30 |
|
182 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
183 | + * @type string $description => string '' (length=0) |
|
184 | + * @type int $parent => int 0 |
|
185 | + * @type int $count => int 4 |
|
186 | + * @type string $filter => string 'raw' (length=3) |
|
187 | + * } |
|
188 | + * @type array $tags {see $category above} |
|
189 | + * @type string $textdomain string 'gravityview' (length=11) |
|
190 | + * } |
|
191 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
192 | + * @type array $licensing { |
|
193 | + * @type bool $enabled Is licensing enabled for the extension |
|
194 | + * @type string $version Version number |
|
195 | + * @type string $exp_unit Expiration unit ('years') |
|
196 | + * @type string $exp_length Expiration length ('1') |
|
197 | + * } |
|
198 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
199 | + * @type string $file string URL of the file download |
|
200 | + * } |
|
201 | + * } |
|
202 | 202 | */ |
203 | 203 | public function get_downloads_data() { |
204 | 204 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ) ); |
231 | 231 | |
232 | 232 | if ( is_wp_error( $response ) ) { |
233 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
233 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
234 | 234 | return $response; |
235 | 235 | } |
236 | 236 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | <div class="gv-admin-installer-notice notice inline error"> |
284 | 284 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
285 | 285 | <?php |
286 | - if ( is_wp_error( $downloads_data ) ) { |
|
287 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
288 | - } |
|
289 | - ?> |
|
286 | + if ( is_wp_error( $downloads_data ) ) { |
|
287 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
288 | + } |
|
289 | + ?> |
|
290 | 290 | </div> |
291 | 291 | </div> |
292 | 292 | <?php |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | protected function render_download( $download, $wp_plugins ) { |
343 | 343 | |
344 | 344 | |
345 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
345 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
346 | 346 | |
347 | - $download_info = $details['download_info']; |
|
347 | + $download_info = $details['download_info']; |
|
348 | 348 | |
349 | 349 | ?> |
350 | 350 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -366,43 +366,43 @@ discard block |
||
366 | 366 | |
367 | 367 | <div class="addon-excerpt"><?php |
368 | 368 | |
369 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
369 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
370 | 370 | |
371 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
372 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
373 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
371 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
372 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
373 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
374 | 374 | |
375 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
376 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
375 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
376 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
377 | 377 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
378 | 378 | |
379 | 379 | echo wpautop( $excerpt ); |
380 | - ?></div> |
|
380 | + ?></div> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | 383 | <?php |
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
387 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
388 | - * |
|
387 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
388 | + * |
|
389 | 389 | * @param array $download Single download, as returned by {@see get_downloads_data} |
390 | 390 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
391 | 391 | * |
392 | 392 | * @return array { |
393 | - * @type array $download_info |
|
394 | - * @type string $plugin_path |
|
395 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
396 | - * @type string $status_label |
|
397 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
398 | - * @type string $button_class CSS class to use for the button |
|
399 | - * @type string $button_label Text to use for the download's anchor link |
|
400 | - * @type string $href URL for the download's button |
|
401 | - * @type bool $spinner Whether to show the spinner icon |
|
402 | - * @type string $item_class CSS class for the download container |
|
403 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
404 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
405 | - * } |
|
393 | + * @type array $download_info |
|
394 | + * @type string $plugin_path |
|
395 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
396 | + * @type string $status_label |
|
397 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
398 | + * @type string $button_class CSS class to use for the button |
|
399 | + * @type string $button_label Text to use for the download's anchor link |
|
400 | + * @type string $href URL for the download's button |
|
401 | + * @type bool $spinner Whether to show the spinner icon |
|
402 | + * @type string $item_class CSS class for the download container |
|
403 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
404 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
405 | + * } |
|
406 | 406 | */ |
407 | 407 | private function get_download_display_details( $download, $wp_plugins ) { |
408 | 408 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | 'slug' => '', |
414 | 414 | 'excerpt' => '', |
415 | 415 | 'link' => '', |
416 | - 'coming_soon' => false, |
|
416 | + 'coming_soon' => false, |
|
417 | 417 | 'installer_title' => null, // May not be defined |
418 | 418 | 'installer_excerpt' => null, // May not be defined |
419 | 419 | ) ); |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
457 | 457 | } |
458 | 458 | |
459 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
460 | - $spinner = false; |
|
461 | - $status = 'notinstalled'; |
|
462 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
463 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
464 | - $button_class = 'button-primary button-large'; |
|
465 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
466 | - } |
|
459 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
460 | + $spinner = false; |
|
461 | + $status = 'notinstalled'; |
|
462 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
463 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
464 | + $button_class = 'button-primary button-large'; |
|
465 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
466 | + } |
|
467 | 467 | |
468 | 468 | // Access but the plugin is not installed |
469 | 469 | elseif ( ! $wp_plugin ) { |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | } |
504 | 504 | |
505 | 505 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
506 | - } |
|
506 | + } |
|
507 | 507 | |
508 | 508 | /** |
509 | - * Returns the base price for an extension |
|
510 | - * |
|
509 | + * Returns the base price for an extension |
|
510 | + * |
|
511 | 511 | * @param array $download |
512 | 512 | * |
513 | 513 | * @return float Base price for an extension. If not for sale separately, returns 0 |
514 | 514 | */ |
515 | 515 | private function get_download_base_price( $download ) { |
516 | 516 | |
517 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
517 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
518 | 518 | $base_price = \GFCommon::to_number( $base_price ); |
519 | 519 | |
520 | 520 | unset( $download['pricing']['amount'] ); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } |
526 | 526 | |
527 | 527 | return floatval( $base_price ); |
528 | - } |
|
528 | + } |
|
529 | 529 | |
530 | 530 | /** |
531 | 531 | * Handle AJAX request to activate extension |
@@ -543,8 +543,8 @@ discard block |
||
543 | 543 | |
544 | 544 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
545 | 545 | wp_send_json_error( array( |
546 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
547 | - ) ); |
|
546 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
547 | + ) ); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | wp_send_json_success(); |
@@ -565,10 +565,10 @@ discard block |
||
565 | 565 | deactivate_plugins( $data['path'] ); |
566 | 566 | |
567 | 567 | if( is_plugin_active( $data['path'] ) ) { |
568 | - wp_send_json_error( array( |
|
569 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
570 | - ) ); |
|
571 | - } |
|
568 | + wp_send_json_error( array( |
|
569 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
570 | + ) ); |
|
571 | + } |
|
572 | 572 | |
573 | 573 | wp_send_json_success(); |
574 | 574 | } |