@@ -134,28 +134,28 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function add_network_menu() { |
| 136 | 136 | |
| 137 | - if ( ! gravityview()->plugin->is_network_activated() ) { |
|
| 137 | + if ( ! gravityview()->plugin->is_network_activated() ) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
| 141 | + add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | - * Uninstall all traces of GravityView |
|
| 146 | - * |
|
| 147 | - * Note: method is public because parent method is public |
|
| 148 | - * |
|
| 145 | + * Uninstall all traces of GravityView |
|
| 146 | + * |
|
| 147 | + * Note: method is public because parent method is public |
|
| 148 | + * |
|
| 149 | 149 | * @return bool |
| 150 | 150 | */ |
| 151 | 151 | public function uninstall() { |
| 152 | 152 | gravityview()->plugin->uninstall(); |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * Set the path so that Gravity Forms can de-activate GravityView |
|
| 156 | - * @see GFAddOn::uninstall_addon |
|
| 157 | - * @uses deactivate_plugins() |
|
| 158 | - */ |
|
| 155 | + * Set the path so that Gravity Forms can de-activate GravityView |
|
| 156 | + * @see GFAddOn::uninstall_addon |
|
| 157 | + * @uses deactivate_plugins() |
|
| 158 | + */ |
|
| 159 | 159 | $this->_path = GRAVITYVIEW_FILE; |
| 160 | 160 | |
| 161 | 161 | return true; |
@@ -185,42 +185,42 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | - * Get an array of reasons why the plugin might be uninstalled |
|
| 189 | - * |
|
| 190 | - * @since 1.17.5 |
|
| 191 | - * |
|
| 188 | + * Get an array of reasons why the plugin might be uninstalled |
|
| 189 | + * |
|
| 190 | + * @since 1.17.5 |
|
| 191 | + * |
|
| 192 | 192 | * @return array Array of reasons with the label and followup questions for each uninstall reason |
| 193 | 193 | */ |
| 194 | 194 | private function get_uninstall_reasons() { |
| 195 | 195 | $reasons = array( |
| 196 | 196 | 'will-continue' => array( |
| 197 | - 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 198 | - ), |
|
| 197 | + 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 198 | + ), |
|
| 199 | 199 | 'no-longer-need' => array( |
| 200 | - 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 201 | - ), |
|
| 200 | + 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 201 | + ), |
|
| 202 | 202 | 'doesnt-work' => array( |
| 203 | - 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 204 | - ), |
|
| 203 | + 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 204 | + ), |
|
| 205 | 205 | 'found-other' => array( |
| 206 | - 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 207 | - 'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ), |
|
| 208 | - ), |
|
| 206 | + 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 207 | + 'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ), |
|
| 208 | + ), |
|
| 209 | 209 | 'other' => array( |
| 210 | - 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 211 | - ), |
|
| 210 | + 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 211 | + ), |
|
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | 214 | shuffle( $reasons ); |
| 215 | 215 | |
| 216 | 216 | return $reasons; |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * Display a feedback form when the plugin is uninstalled |
|
| 221 | - * |
|
| 222 | - * @since 1.17.5 |
|
| 223 | - * |
|
| 220 | + * Display a feedback form when the plugin is uninstalled |
|
| 221 | + * |
|
| 222 | + * @since 1.17.5 |
|
| 223 | + * |
|
| 224 | 224 | * @return string HTML of the uninstallation form |
| 225 | 225 | */ |
| 226 | 226 | public function uninstall_form() { |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | <h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2> |
| 301 | 301 | <ul> |
| 302 | 302 | <?php |
| 303 | - $reasons = $this->get_uninstall_reasons(); |
|
| 303 | + $reasons = $this->get_uninstall_reasons(); |
|
| 304 | 304 | foreach ( $reasons as $reason ) { |
| 305 | 305 | printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get( $reason, 'followup' ), Utils::get( $reason, 'label' ) ); |
| 306 | 306 | } |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | public function app_settings_tab() { |
| 397 | - parent::app_settings_tab(); |
|
| 397 | + parent::app_settings_tab(); |
|
| 398 | 398 | |
| 399 | 399 | if ( $this->maybe_uninstall() ) { |
| 400 | - echo $this->uninstall_form(); |
|
| 400 | + echo $this->uninstall_form(); |
|
| 401 | 401 | } |
| 402 | - } |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | 404 | /** |
| 405 | 405 | * The Settings title |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @return array The settings. |
| 485 | 485 | */ |
| 486 | 486 | public function all() { |
| 487 | - return wp_parse_args( get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', array() ), $this->defaults() ); |
|
| 487 | + return wp_parse_args( get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', array() ), $this->defaults() ); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | type="' . $field['type'] . '" |
| 554 | 554 | name="' . esc_attr( $name ) . '" |
| 555 | 555 | value="' . $value . '" ' . |
| 556 | - implode( ' ', $attributes ) . |
|
| 557 | - ' />'; |
|
| 556 | + implode( ' ', $attributes ) . |
|
| 557 | + ' />'; |
|
| 558 | 558 | |
| 559 | 559 | if ( $echo ) { |
| 560 | 560 | echo $html; |
@@ -572,12 +572,12 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
| 575 | - * Check whether GravityView is being saved |
|
| 576 | - * |
|
| 577 | - * The generic is_save_postback() is true for all addons |
|
| 578 | - * |
|
| 579 | - * @since 2.0.8 |
|
| 580 | - * |
|
| 575 | + * Check whether GravityView is being saved |
|
| 576 | + * |
|
| 577 | + * The generic is_save_postback() is true for all addons |
|
| 578 | + * |
|
| 579 | + * @since 2.0.8 |
|
| 580 | + * |
|
| 581 | 581 | * @return bool |
| 582 | 582 | */ |
| 583 | 583 | public function is_save_postback() { |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function license_key_notice() { |
| 593 | 593 | |
| 594 | - if( $this->is_save_postback() ) { |
|
| 595 | - $settings = $this->get_posted_settings(); |
|
| 596 | - $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
| 597 | - $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
| 598 | - } else { |
|
| 599 | - $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
| 600 | - $license_key = $this->get( 'license_key' ); |
|
| 601 | - } |
|
| 594 | + if( $this->is_save_postback() ) { |
|
| 595 | + $settings = $this->get_posted_settings(); |
|
| 596 | + $license_key = \GV\Utils::get( $settings, 'license_key' ); |
|
| 597 | + $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
|
| 598 | + } else { |
|
| 599 | + $license_status = $this->get( 'license_key_status', 'inactive' ); |
|
| 600 | + $license_key = $this->get( 'license_key' ); |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
| 603 | + $license_id = empty( $license_key ) ? 'license' : $license_key; |
|
| 604 | 604 | |
| 605 | 605 | $message = esc_html__( 'Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
| 606 | 606 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | $update_below = false; |
| 618 | 618 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
| 619 | 619 | |
| 620 | - switch ( $license_status ) { |
|
| 620 | + switch ( $license_status ) { |
|
| 621 | 621 | /** @since 1.17 */ |
| 622 | 622 | case 'expired': |
| 623 | 623 | $title = __( 'Expired License', 'gravityview' ); |
@@ -655,13 +655,13 @@ discard block |
||
| 655 | 655 | return; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - \GravityView_Admin_Notices::add_notice( array( |
|
| 659 | - 'message' => $message, |
|
| 660 | - 'class' => 'notice notice-warning', |
|
| 661 | - 'title' => $title, |
|
| 662 | - 'cap' => 'gravityview_edit_settings', |
|
| 663 | - 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
| 664 | - ) ); |
|
| 658 | + \GravityView_Admin_Notices::add_notice( array( |
|
| 659 | + 'message' => $message, |
|
| 660 | + 'class' => 'notice notice-warning', |
|
| 661 | + 'title' => $title, |
|
| 662 | + 'cap' => 'gravityview_edit_settings', |
|
| 663 | + 'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default) |
|
| 664 | + ) ); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -675,12 +675,12 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | - * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 679 | - * |
|
| 680 | - * @since 1.21.5 |
|
| 681 | - * |
|
| 682 | - * @see GFAddOn::scripts() |
|
| 683 | - * |
|
| 678 | + * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 679 | + * |
|
| 680 | + * @since 1.21.5 |
|
| 681 | + * |
|
| 682 | + * @see GFAddOn::scripts() |
|
| 683 | + * |
|
| 684 | 684 | * @return array Array of scripts |
| 685 | 685 | */ |
| 686 | 686 | public function scripts() { |
@@ -689,10 +689,10 @@ discard block |
||
| 689 | 689 | $scripts[] = array( |
| 690 | 690 | 'handle' => 'gform_tooltip_init', |
| 691 | 691 | 'enqueue' => array( |
| 692 | - array( |
|
| 693 | - 'admin_page' => array( 'app_settings' ) |
|
| 694 | - ) |
|
| 695 | - ) |
|
| 692 | + array( |
|
| 693 | + 'admin_page' => array( 'app_settings' ) |
|
| 694 | + ) |
|
| 695 | + ) |
|
| 696 | 696 | ); |
| 697 | 697 | |
| 698 | 698 | return $scripts; |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
| 711 | 711 | 'version' => Plugin::$version, |
| 712 | 712 | 'deps' => array( |
| 713 | - 'gform_admin', |
|
| 713 | + 'gform_admin', |
|
| 714 | 714 | 'gaddon_form_settings_css', |
| 715 | - 'gform_tooltip', |
|
| 716 | - 'gform_font_awesome', |
|
| 715 | + 'gform_tooltip', |
|
| 716 | + 'gform_font_awesome', |
|
| 717 | 717 | ), |
| 718 | 718 | 'enqueue' => array( |
| 719 | 719 | array( 'admin_page' => array( |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | array( |
| 882 | 882 | 'label' => _x( 'Show me beta versions if they are available.', 'gravityview' ), |
| 883 | 883 | 'value' => '1', |
| 884 | - 'name' => 'beta', |
|
| 884 | + 'name' => 'beta', |
|
| 885 | 885 | ), |
| 886 | 886 | ), |
| 887 | 887 | 'description' => __( 'You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview' ), |
@@ -919,38 +919,38 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | if ( empty( $field['disabled'] ) ) { |
| 921 | 921 | unset( $field['disabled'] ); |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - $sections = array( |
|
| 926 | - array( |
|
| 927 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
| 928 | - 'fields' => $fields, |
|
| 929 | - ) |
|
| 930 | - ); |
|
| 925 | + $sections = array( |
|
| 926 | + array( |
|
| 927 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) ), |
|
| 928 | + 'fields' => $fields, |
|
| 929 | + ) |
|
| 930 | + ); |
|
| 931 | 931 | |
| 932 | - // custom 'update settings' button |
|
| 933 | - $button = array( |
|
| 934 | - 'class' => 'button button-primary button-hero', |
|
| 935 | - 'type' => 'save', |
|
| 936 | - ); |
|
| 932 | + // custom 'update settings' button |
|
| 933 | + $button = array( |
|
| 934 | + 'class' => 'button button-primary button-hero', |
|
| 935 | + 'type' => 'save', |
|
| 936 | + ); |
|
| 937 | 937 | |
| 938 | 938 | if ( $disabled_attribute ) { |
| 939 | 939 | $button['disabled'] = $disabled_attribute; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - /** |
|
| 943 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 944 | - * Extensions can tap in here to insert their own section and settings. |
|
| 945 | - * <code> |
|
| 946 | - * $sections[] = array( |
|
| 947 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 948 | - * 'fields' => $settings, |
|
| 949 | - * ); |
|
| 950 | - * </code> |
|
| 951 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
| 952 | - */ |
|
| 953 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 942 | + /** |
|
| 943 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 944 | + * Extensions can tap in here to insert their own section and settings. |
|
| 945 | + * <code> |
|
| 946 | + * $sections[] = array( |
|
| 947 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 948 | + * 'fields' => $settings, |
|
| 949 | + * ); |
|
| 950 | + * </code> |
|
| 951 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
| 952 | + */ |
|
| 953 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 954 | 954 | |
| 955 | 955 | // If there are extensions, add a section for them |
| 956 | 956 | if ( ! empty( $extension_sections ) ) { |
@@ -963,13 +963,13 @@ discard block |
||
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - $k = count( $extension_sections ) - 1 ; |
|
| 967 | - $extension_sections[ $k ]['fields'][] = $button; |
|
| 966 | + $k = count( $extension_sections ) - 1 ; |
|
| 967 | + $extension_sections[ $k ]['fields'][] = $button; |
|
| 968 | 968 | $sections = array_merge( $sections, $extension_sections ); |
| 969 | 969 | } else { |
| 970 | - // add the 'update settings' button to the general section |
|
| 971 | - $sections[0]['fields'][] = $button; |
|
| 972 | - } |
|
| 970 | + // add the 'update settings' button to the general section |
|
| 971 | + $sections[0]['fields'][] = $button; |
|
| 972 | + } |
|
| 973 | 973 | |
| 974 | 974 | return $sections; |
| 975 | 975 | } |
@@ -1023,9 +1023,9 @@ discard block |
||
| 1023 | 1023 | */ |
| 1024 | 1024 | protected function settings_edd_license( $field, $echo = true ) { |
| 1025 | 1025 | |
| 1026 | - if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 1027 | - $field['input_type'] = 'password'; |
|
| 1028 | - } |
|
| 1026 | + if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 1027 | + $field['input_type'] = 'password'; |
|
| 1028 | + } |
|
| 1029 | 1029 | |
| 1030 | 1030 | $text = $this->settings_text( $field, false ); |
| 1031 | 1031 | |
@@ -1042,9 +1042,9 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | /** |
| 1044 | 1044 | * Allow pure HTML settings row |
| 1045 | - * |
|
| 1046 | - * @since 2.0.6 |
|
| 1047 | - * |
|
| 1045 | + * |
|
| 1046 | + * @since 2.0.6 |
|
| 1047 | + * |
|
| 1048 | 1048 | * @param array $field |
| 1049 | 1049 | * @param bool $echo Whether to echo the |
| 1050 | 1050 | * |
@@ -1110,19 +1110,19 @@ discard block |
||
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | /** |
| 1113 | - * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 1114 | - * |
|
| 1115 | - * Converts `$field['description']` to `$field['gv_description']` |
|
| 1116 | - * Converts `$field['subtitle']` to `$field['description']` |
|
| 1117 | - * |
|
| 1118 | - * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 1119 | - * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 1120 | - * |
|
| 1121 | - * @since 1.21.5.2 |
|
| 1122 | - * |
|
| 1113 | + * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 1114 | + * |
|
| 1115 | + * Converts `$field['description']` to `$field['gv_description']` |
|
| 1116 | + * Converts `$field['subtitle']` to `$field['description']` |
|
| 1117 | + * |
|
| 1118 | + * @see \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 1119 | + * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 1120 | + * |
|
| 1121 | + * @since 1.21.5.2 |
|
| 1122 | + * |
|
| 1123 | 1123 | * @param array $field |
| 1124 | - * |
|
| 1125 | - * @return void |
|
| 1124 | + * |
|
| 1125 | + * @return void |
|
| 1126 | 1126 | */ |
| 1127 | 1127 | public function single_setting_row( $field ) { |
| 1128 | 1128 | $field['gv_description'] = Utils::get( $field, 'description' ); |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * ID of the current post. May also be ID of the current View. |
| 97 | - * |
|
| 98 | - * @since 2.0.13 |
|
| 99 | - * |
|
| 100 | - * @var int |
|
| 97 | + * |
|
| 98 | + * @since 2.0.13 |
|
| 99 | + * |
|
| 100 | + * @var int |
|
| 101 | 101 | */ |
| 102 | 102 | public $post_id; |
| 103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | 171 | if( ! empty( $_POST ) ) { |
| 172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if( $this->is_edit_entry_submission() ) { |
| 176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | * When Edit entry view is requested setup the vars |
| 203 | 203 | */ |
| 204 | 204 | private function setup_vars() { |
| 205 | - global $post; |
|
| 205 | + global $post; |
|
| 206 | 206 | |
| 207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[0]; |
|
| 212 | + $this->entry = $entries[0]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
| 335 | 335 | |
| 336 | - // Delete the values for hidden inputs |
|
| 337 | - $this->unset_hidden_field_values(); |
|
| 336 | + // Delete the values for hidden inputs |
|
| 337 | + $this->unset_hidden_field_values(); |
|
| 338 | 338 | |
| 339 | 339 | $this->entry['date_created'] = $date_created; |
| 340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | // Perform actions normally performed after updating a lead |
| 345 | 345 | $this->after_update(); |
| 346 | 346 | |
| 347 | - /** |
|
| 347 | + /** |
|
| 348 | 348 | * Must be AFTER after_update()! |
| 349 | 349 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 350 | 350 | */ |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | 354 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 355 | - * @since 2.1 Added $gv_data parameter |
|
| 355 | + * @since 2.1 Added $gv_data parameter |
|
| 356 | 356 | * @param array $form Gravity Forms form array |
| 357 | 357 | * @param string $entry_id Numeric ID of the entry that was updated |
| 358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * @return void |
| 377 | 377 | */ |
| 378 | 378 | private function unset_hidden_field_values() { |
| 379 | - global $wpdb; |
|
| 379 | + global $wpdb; |
|
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -398,27 +398,27 @@ discard block |
||
| 398 | 398 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 401 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 402 | 402 | |
| 403 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 403 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 404 | 404 | |
| 405 | - // Reset fields that are hidden |
|
| 406 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 407 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 405 | + // Reset fields that are hidden |
|
| 406 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 407 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 408 | 408 | |
| 409 | - // List fields are stored as empty arrays when empty |
|
| 410 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 409 | + // List fields are stored as empty arrays when empty |
|
| 410 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 411 | 411 | |
| 412 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 412 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 413 | 413 | |
| 414 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 414 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 415 | 415 | |
| 416 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 416 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 417 | 417 | // after submission |
| 418 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 419 | - $_POST[ $post_input_id ] = ''; |
|
| 420 | - } |
|
| 421 | - } |
|
| 418 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 419 | + $_POST[ $post_input_id ] = ''; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $form = $this->form; |
| 514 | 514 | |
| 515 | - /** @var GF_Field $field */ |
|
| 515 | + /** @var GF_Field $field */ |
|
| 516 | 516 | foreach( $form['fields'] as $k => &$field ) { |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | |
| 529 | 529 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 530 | 530 | foreach( $field->inputs as $key => $input ) { |
| 531 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 531 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -549,13 +549,13 @@ discard block |
||
| 549 | 549 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 550 | 550 | $inputs = $calc_field->get_entry_inputs(); |
| 551 | 551 | if ( is_array( $inputs ) ) { |
| 552 | - foreach ( $inputs as $input ) { |
|
| 553 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 554 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 555 | - } |
|
| 552 | + foreach ( $inputs as $input ) { |
|
| 553 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 554 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 555 | + } |
|
| 556 | 556 | } else { |
| 557 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 558 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 557 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 558 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 604 | 604 | |
| 605 | 605 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 606 | - $ary = stripslashes_deep( $ary ); |
|
| 606 | + $ary = stripslashes_deep( $ary ); |
|
| 607 | 607 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 608 | 608 | |
| 609 | 609 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | private function maybe_update_post_fields( $form ) { |
| 677 | 677 | |
| 678 | 678 | if( empty( $this->entry['post_id'] ) ) { |
| 679 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 679 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 680 | 680 | return; |
| 681 | 681 | } |
| 682 | 682 | |
@@ -711,51 +711,51 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | switch( $field->type ) { |
| 713 | 713 | |
| 714 | - case 'post_title': |
|
| 715 | - $post_title = $value; |
|
| 716 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 717 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 718 | - } |
|
| 719 | - $updated_post->post_title = $post_title; |
|
| 720 | - $updated_post->post_name = $post_title; |
|
| 721 | - unset( $post_title ); |
|
| 722 | - break; |
|
| 723 | - |
|
| 724 | - case 'post_content': |
|
| 725 | - $post_content = $value; |
|
| 726 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 727 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 728 | - } |
|
| 729 | - $updated_post->post_content = $post_content; |
|
| 730 | - unset( $post_content ); |
|
| 731 | - break; |
|
| 732 | - case 'post_excerpt': |
|
| 733 | - $updated_post->post_excerpt = $value; |
|
| 734 | - break; |
|
| 735 | - case 'post_tags': |
|
| 736 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 737 | - break; |
|
| 738 | - case 'post_category': |
|
| 739 | - break; |
|
| 740 | - case 'post_custom_field': |
|
| 714 | + case 'post_title': |
|
| 715 | + $post_title = $value; |
|
| 716 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 717 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 718 | + } |
|
| 719 | + $updated_post->post_title = $post_title; |
|
| 720 | + $updated_post->post_name = $post_title; |
|
| 721 | + unset( $post_title ); |
|
| 722 | + break; |
|
| 723 | + |
|
| 724 | + case 'post_content': |
|
| 725 | + $post_content = $value; |
|
| 726 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 727 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 728 | + } |
|
| 729 | + $updated_post->post_content = $post_content; |
|
| 730 | + unset( $post_content ); |
|
| 731 | + break; |
|
| 732 | + case 'post_excerpt': |
|
| 733 | + $updated_post->post_excerpt = $value; |
|
| 734 | + break; |
|
| 735 | + case 'post_tags': |
|
| 736 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 737 | + break; |
|
| 738 | + case 'post_category': |
|
| 739 | + break; |
|
| 740 | + case 'post_custom_field': |
|
| 741 | 741 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 742 | 742 | $value = $value[ $field_id ]; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 746 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 747 | - } |
|
| 745 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 746 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 747 | + } |
|
| 748 | 748 | |
| 749 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 750 | - $value = wp_json_encode( $value ); |
|
| 751 | - } |
|
| 749 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 750 | + $value = wp_json_encode( $value ); |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 754 | - break; |
|
| 753 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 754 | + break; |
|
| 755 | 755 | |
| 756 | - case 'post_image': |
|
| 757 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 758 | - break; |
|
| 756 | + case 'post_image': |
|
| 757 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 758 | + break; |
|
| 759 | 759 | |
| 760 | 760 | } |
| 761 | 761 | |
@@ -800,20 +800,20 @@ discard block |
||
| 800 | 800 | */ |
| 801 | 801 | private function is_field_json_encoded( $field ) { |
| 802 | 802 | |
| 803 | - $json_encoded = false; |
|
| 803 | + $json_encoded = false; |
|
| 804 | 804 | |
| 805 | 805 | $input_type = RGFormsModel::get_input_type( $field ); |
| 806 | 806 | |
| 807 | - // Only certain custom field types are supported |
|
| 808 | - switch( $input_type ) { |
|
| 809 | - case 'fileupload': |
|
| 810 | - case 'list': |
|
| 811 | - case 'multiselect': |
|
| 812 | - $json_encoded = true; |
|
| 813 | - break; |
|
| 814 | - } |
|
| 807 | + // Only certain custom field types are supported |
|
| 808 | + switch( $input_type ) { |
|
| 809 | + case 'fileupload': |
|
| 810 | + case 'list': |
|
| 811 | + case 'multiselect': |
|
| 812 | + $json_encoded = true; |
|
| 813 | + break; |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | - return $json_encoded; |
|
| 816 | + return $json_encoded; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
@@ -903,14 +903,14 @@ discard block |
||
| 903 | 903 | ?><h2 class="gv-edit-entry-title"> |
| 904 | 904 | <span><?php |
| 905 | 905 | |
| 906 | - /** |
|
| 907 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 908 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 909 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 910 | - */ |
|
| 911 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 906 | + /** |
|
| 907 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 908 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 909 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 910 | + */ |
|
| 911 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 912 | 912 | |
| 913 | - echo esc_attr( $edit_entry_title ); |
|
| 913 | + echo esc_attr( $edit_entry_title ); |
|
| 914 | 914 | ?></span> |
| 915 | 915 | </h2> |
| 916 | 916 | |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | |
| 1020 | 1020 | ob_get_clean(); |
| 1021 | 1021 | |
| 1022 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1022 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1023 | 1023 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1024 | 1024 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1025 | 1025 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | |
| 1074 | 1074 | // for now we don't support Save and Continue feature. |
| 1075 | 1075 | if( ! self::$supports_save_and_continue ) { |
| 1076 | - unset( $form['save'] ); |
|
| 1076 | + unset( $form['save'] ); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | $form = $this->unselect_default_values( $form ); |
@@ -1100,30 +1100,30 @@ discard block |
||
| 1100 | 1100 | return $field_content; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - $message = null; |
|
| 1103 | + $message = null; |
|
| 1104 | 1104 | |
| 1105 | - // First, make sure they have the capability to edit the post. |
|
| 1106 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1105 | + // First, make sure they have the capability to edit the post. |
|
| 1106 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1107 | 1107 | |
| 1108 | - /** |
|
| 1109 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1110 | - * @param string $message The existing "You don't have permission..." text |
|
| 1111 | - */ |
|
| 1112 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1108 | + /** |
|
| 1109 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1110 | + * @param string $message The existing "You don't have permission..." text |
|
| 1111 | + */ |
|
| 1112 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1113 | 1113 | |
| 1114 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1115 | - /** |
|
| 1116 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1117 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1118 | - */ |
|
| 1119 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1120 | - } |
|
| 1114 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1115 | + /** |
|
| 1116 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1117 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1118 | + */ |
|
| 1119 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1120 | + } |
|
| 1121 | 1121 | |
| 1122 | - if( $message ) { |
|
| 1123 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1124 | - } |
|
| 1122 | + if( $message ) { |
|
| 1123 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | - return $field_content; |
|
| 1126 | + return $field_content; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | /** |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | || ! empty( $field_content ) |
| 1152 | 1152 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1153 | 1153 | ) { |
| 1154 | - return $field_content; |
|
| 1154 | + return $field_content; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1159,24 +1159,24 @@ discard block |
||
| 1159 | 1159 | |
| 1160 | 1160 | $field_value = $this->get_field_value( $field ); |
| 1161 | 1161 | |
| 1162 | - // Prevent any PHP warnings, like undefined index |
|
| 1163 | - ob_start(); |
|
| 1162 | + // Prevent any PHP warnings, like undefined index |
|
| 1163 | + ob_start(); |
|
| 1164 | 1164 | |
| 1165 | - $return = null; |
|
| 1165 | + $return = null; |
|
| 1166 | 1166 | |
| 1167 | 1167 | /** @var GravityView_Field $gv_field */ |
| 1168 | 1168 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1169 | 1169 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1170 | 1170 | } else { |
| 1171 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1172 | - } |
|
| 1171 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1172 | + } |
|
| 1173 | 1173 | |
| 1174 | - // If there was output, it's an error |
|
| 1175 | - $warnings = ob_get_clean(); |
|
| 1174 | + // If there was output, it's an error |
|
| 1175 | + $warnings = ob_get_clean(); |
|
| 1176 | 1176 | |
| 1177 | - if( !empty( $warnings ) ) { |
|
| 1178 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1179 | - } |
|
| 1177 | + if( !empty( $warnings ) ) { |
|
| 1178 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | 1181 | return $return; |
| 1182 | 1182 | } |
@@ -1211,8 +1211,8 @@ discard block |
||
| 1211 | 1211 | $input_id = strval( $input['id'] ); |
| 1212 | 1212 | |
| 1213 | 1213 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1214 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1215 | - $allow_pre_populated = false; |
|
| 1214 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1215 | + $allow_pre_populated = false; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1237 | 1237 | $categories = array(); |
| 1238 | 1238 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1239 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1239 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1240 | 1240 | } |
| 1241 | 1241 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1242 | 1242 | } |
@@ -1246,25 +1246,25 @@ discard block |
||
| 1246 | 1246 | // if value is empty get the default value if defined |
| 1247 | 1247 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1248 | 1248 | |
| 1249 | - /** |
|
| 1250 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1251 | - * @since 1.11 |
|
| 1252 | - * @since 1.20 Added third param |
|
| 1253 | - * @param mixed $field_value field value used to populate the input |
|
| 1254 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1255 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1256 | - */ |
|
| 1257 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1261 | - * @since 1.17 |
|
| 1262 | - * @since 1.20 Added third param |
|
| 1263 | - * @param mixed $field_value field value used to populate the input |
|
| 1264 | - * @param GF_Field $field Gravity Forms field object |
|
| 1265 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1266 | - */ |
|
| 1267 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1249 | + /** |
|
| 1250 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1251 | + * @since 1.11 |
|
| 1252 | + * @since 1.20 Added third param |
|
| 1253 | + * @param mixed $field_value field value used to populate the input |
|
| 1254 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1255 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1256 | + */ |
|
| 1257 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1261 | + * @since 1.17 |
|
| 1262 | + * @since 1.20 Added third param |
|
| 1263 | + * @param mixed $field_value field value used to populate the input |
|
| 1264 | + * @param GF_Field $field Gravity Forms field object |
|
| 1265 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1266 | + */ |
|
| 1267 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1268 | 1268 | |
| 1269 | 1269 | return $field_value; |
| 1270 | 1270 | } |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1292 | 1292 | // expects certain field array items to be set. |
| 1293 | 1293 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1294 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1294 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1305,61 +1305,61 @@ discard block |
||
| 1305 | 1305 | */ |
| 1306 | 1306 | case 'fileupload': |
| 1307 | 1307 | |
| 1308 | - // Set the previous value |
|
| 1309 | - $entry = $this->get_entry(); |
|
| 1308 | + // Set the previous value |
|
| 1309 | + $entry = $this->get_entry(); |
|
| 1310 | 1310 | |
| 1311 | - $input_name = 'input_'.$field->id; |
|
| 1312 | - $form_id = $form['id']; |
|
| 1311 | + $input_name = 'input_'.$field->id; |
|
| 1312 | + $form_id = $form['id']; |
|
| 1313 | 1313 | |
| 1314 | - $value = NULL; |
|
| 1314 | + $value = NULL; |
|
| 1315 | 1315 | |
| 1316 | - // Use the previous entry value as the default. |
|
| 1317 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1318 | - $value = $entry[ $field->id ]; |
|
| 1319 | - } |
|
| 1316 | + // Use the previous entry value as the default. |
|
| 1317 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1318 | + $value = $entry[ $field->id ]; |
|
| 1319 | + } |
|
| 1320 | 1320 | |
| 1321 | - // If this is a single upload file |
|
| 1322 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1323 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1324 | - $value = $file_path['url']; |
|
| 1321 | + // If this is a single upload file |
|
| 1322 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1323 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1324 | + $value = $file_path['url']; |
|
| 1325 | 1325 | |
| 1326 | - } else { |
|
| 1326 | + } else { |
|
| 1327 | 1327 | |
| 1328 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1329 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1330 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1328 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1329 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1330 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1331 | 1331 | |
| 1332 | - } |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1334 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1335 | 1335 | |
| 1336 | - // If there are fresh uploads, process and merge them. |
|
| 1337 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1338 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1339 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1340 | - $value = stripslashes_deep( $value ); |
|
| 1341 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1342 | - } |
|
| 1336 | + // If there are fresh uploads, process and merge them. |
|
| 1337 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1338 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1339 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1340 | + $value = stripslashes_deep( $value ); |
|
| 1341 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1342 | + } |
|
| 1343 | 1343 | |
| 1344 | - } else { |
|
| 1344 | + } else { |
|
| 1345 | 1345 | |
| 1346 | - // A file already exists when editing an entry |
|
| 1347 | - // We set this to solve issue when file upload fields are required. |
|
| 1348 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1346 | + // A file already exists when editing an entry |
|
| 1347 | + // We set this to solve issue when file upload fields are required. |
|
| 1348 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1349 | 1349 | |
| 1350 | - } |
|
| 1350 | + } |
|
| 1351 | 1351 | |
| 1352 | - $this->entry[ $input_name ] = $value; |
|
| 1353 | - $_POST[ $input_name ] = $value; |
|
| 1352 | + $this->entry[ $input_name ] = $value; |
|
| 1353 | + $_POST[ $input_name ] = $value; |
|
| 1354 | 1354 | |
| 1355 | - break; |
|
| 1355 | + break; |
|
| 1356 | 1356 | |
| 1357 | 1357 | case 'number': |
| 1358 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1359 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1360 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1361 | - } |
|
| 1362 | - break; |
|
| 1358 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1359 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1360 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1361 | + } |
|
| 1362 | + break; |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | } |
@@ -1444,42 +1444,42 @@ discard block |
||
| 1444 | 1444 | case 'fileupload' : |
| 1445 | 1445 | case 'post_image': |
| 1446 | 1446 | |
| 1447 | - // in case nothing is uploaded but there are already files saved |
|
| 1448 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1449 | - $field->failed_validation = false; |
|
| 1450 | - unset( $field->validation_message ); |
|
| 1451 | - } |
|
| 1447 | + // in case nothing is uploaded but there are already files saved |
|
| 1448 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1449 | + $field->failed_validation = false; |
|
| 1450 | + unset( $field->validation_message ); |
|
| 1451 | + } |
|
| 1452 | 1452 | |
| 1453 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1454 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1453 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1454 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1455 | 1455 | |
| 1456 | - $input_name = 'input_' . $field->id; |
|
| 1457 | - //uploaded |
|
| 1458 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1456 | + $input_name = 'input_' . $field->id; |
|
| 1457 | + //uploaded |
|
| 1458 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1459 | 1459 | |
| 1460 | - //existent |
|
| 1461 | - $entry = $this->get_entry(); |
|
| 1462 | - $value = NULL; |
|
| 1463 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1464 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1465 | - } |
|
| 1460 | + //existent |
|
| 1461 | + $entry = $this->get_entry(); |
|
| 1462 | + $value = NULL; |
|
| 1463 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1464 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | - // count uploaded files and existent entry files |
|
| 1468 | - $count_files = count( $file_names ) + count( $value ); |
|
| 1467 | + // count uploaded files and existent entry files |
|
| 1468 | + $count_files = count( $file_names ) + count( $value ); |
|
| 1469 | 1469 | |
| 1470 | - if( $count_files > $field->maxFiles ) { |
|
| 1471 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1472 | - $field->failed_validation = 1; |
|
| 1473 | - $gv_valid = false; |
|
| 1470 | + if( $count_files > $field->maxFiles ) { |
|
| 1471 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1472 | + $field->failed_validation = 1; |
|
| 1473 | + $gv_valid = false; |
|
| 1474 | 1474 | |
| 1475 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1476 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1477 | - } |
|
| 1475 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1476 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1477 | + } |
|
| 1478 | 1478 | |
| 1479 | - } |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | |
| 1482 | - break; |
|
| 1482 | + break; |
|
| 1483 | 1483 | |
| 1484 | 1484 | } |
| 1485 | 1485 | |
@@ -1490,47 +1490,47 @@ discard block |
||
| 1490 | 1490 | |
| 1491 | 1491 | switch ( $field_type ) { |
| 1492 | 1492 | |
| 1493 | - // Captchas don't need to be re-entered. |
|
| 1494 | - case 'captcha': |
|
| 1493 | + // Captchas don't need to be re-entered. |
|
| 1494 | + case 'captcha': |
|
| 1495 | 1495 | |
| 1496 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1497 | - case 'post_image': |
|
| 1498 | - $field->failed_validation = false; |
|
| 1499 | - unset( $field->validation_message ); |
|
| 1500 | - break; |
|
| 1496 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1497 | + case 'post_image': |
|
| 1498 | + $field->failed_validation = false; |
|
| 1499 | + unset( $field->validation_message ); |
|
| 1500 | + break; |
|
| 1501 | 1501 | |
| 1502 | 1502 | } |
| 1503 | 1503 | |
| 1504 | 1504 | // You can't continue inside a switch, so we do it after. |
| 1505 | 1505 | if( empty( $field->failed_validation ) ) { |
| 1506 | - continue; |
|
| 1506 | + continue; |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1510 | 1510 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1511 | 1511 | if( !empty( $field->noDuplicates ) ) { |
| 1512 | 1512 | |
| 1513 | - $entry = $this->get_entry(); |
|
| 1513 | + $entry = $this->get_entry(); |
|
| 1514 | 1514 | |
| 1515 | - // If the value of the entry is the same as the stored value |
|
| 1516 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1517 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1518 | - //if value submitted was not changed, then don't validate |
|
| 1519 | - $field->failed_validation = false; |
|
| 1515 | + // If the value of the entry is the same as the stored value |
|
| 1516 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1517 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1518 | + //if value submitted was not changed, then don't validate |
|
| 1519 | + $field->failed_validation = false; |
|
| 1520 | 1520 | |
| 1521 | - unset( $field->validation_message ); |
|
| 1521 | + unset( $field->validation_message ); |
|
| 1522 | 1522 | |
| 1523 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1523 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1524 | 1524 | |
| 1525 | - continue; |
|
| 1526 | - } |
|
| 1525 | + continue; |
|
| 1526 | + } |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1530 | 1530 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1531 | - unset( $field->validation_message ); |
|
| 1532 | - $field->validation_message = false; |
|
| 1533 | - continue; |
|
| 1531 | + unset( $field->validation_message ); |
|
| 1532 | + $field->validation_message = false; |
|
| 1533 | + continue; |
|
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | 1536 | $gv_valid = false; |
@@ -1594,8 +1594,8 @@ discard block |
||
| 1594 | 1594 | // Hide fields depending on admin settings |
| 1595 | 1595 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1596 | 1596 | |
| 1597 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1598 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1597 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1598 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1599 | 1599 | |
| 1600 | 1600 | /** |
| 1601 | 1601 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1655,11 +1655,11 @@ discard block |
||
| 1655 | 1655 | // The edit tab has been configured, so we loop through to configured settings |
| 1656 | 1656 | foreach ( $configured_fields as $configured_field ) { |
| 1657 | 1657 | |
| 1658 | - /** @var GF_Field $field */ |
|
| 1659 | - foreach ( $fields as $field ) { |
|
| 1658 | + /** @var GF_Field $field */ |
|
| 1659 | + foreach ( $fields as $field ) { |
|
| 1660 | 1660 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1661 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1662 | - break; |
|
| 1661 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1662 | + break; |
|
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | 1665 | } |
@@ -1715,28 +1715,28 @@ discard block |
||
| 1715 | 1715 | */ |
| 1716 | 1716 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1717 | 1717 | |
| 1718 | - /** |
|
| 1718 | + /** |
|
| 1719 | 1719 | * @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 |
| 1720 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1721 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1722 | - * @since 1.9.1 |
|
| 1723 | - * @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. |
|
| 1724 | - * @param array $form GF Form array |
|
| 1725 | - * @param int $view_id View ID |
|
| 1726 | - */ |
|
| 1727 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1728 | - |
|
| 1729 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1720 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1721 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1722 | + * @since 1.9.1 |
|
| 1723 | + * @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. |
|
| 1724 | + * @param array $form GF Form array |
|
| 1725 | + * @param int $view_id View ID |
|
| 1726 | + */ |
|
| 1727 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1728 | + |
|
| 1729 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1730 | 1730 | foreach( $fields as $k => $field ) { |
| 1731 | 1731 | if( $field->adminOnly ) { |
| 1732 | - unset( $fields[ $k ] ); |
|
| 1732 | + unset( $fields[ $k ] ); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | } |
| 1735 | 1735 | return $fields; |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | - foreach( $fields as &$field ) { |
|
| 1739 | - $field->adminOnly = false; |
|
| 1738 | + foreach( $fields as &$field ) { |
|
| 1739 | + $field->adminOnly = false; |
|
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | return $fields; |
@@ -1756,13 +1756,13 @@ discard block |
||
| 1756 | 1756 | */ |
| 1757 | 1757 | private function unselect_default_values( $form ) { |
| 1758 | 1758 | |
| 1759 | - foreach ( $form['fields'] as &$field ) { |
|
| 1759 | + foreach ( $form['fields'] as &$field ) { |
|
| 1760 | 1760 | |
| 1761 | 1761 | if ( empty( $field->choices ) ) { |
| 1762 | - continue; |
|
| 1762 | + continue; |
|
| 1763 | 1763 | } |
| 1764 | 1764 | |
| 1765 | - foreach ( $field->choices as &$choice ) { |
|
| 1765 | + foreach ( $field->choices as &$choice ) { |
|
| 1766 | 1766 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1767 | 1767 | $choice['isSelected'] = false; |
| 1768 | 1768 | } |
@@ -1799,36 +1799,36 @@ discard block |
||
| 1799 | 1799 | |
| 1800 | 1800 | if( 'checkbox' === $field->type ) { |
| 1801 | 1801 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1802 | - $input_id = $input['id']; |
|
| 1803 | - $choice = $field->choices[ $key ]; |
|
| 1804 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1805 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1806 | - if( $match ) { |
|
| 1807 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1808 | - } |
|
| 1802 | + $input_id = $input['id']; |
|
| 1803 | + $choice = $field->choices[ $key ]; |
|
| 1804 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1805 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1806 | + if( $match ) { |
|
| 1807 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1808 | + } |
|
| 1809 | 1809 | } |
| 1810 | 1810 | } else { |
| 1811 | 1811 | |
| 1812 | 1812 | // We need to run through each field to set the default values |
| 1813 | 1813 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1814 | 1814 | |
| 1815 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1815 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1816 | 1816 | |
| 1817 | - if( 'list' === $field->type ) { |
|
| 1818 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1817 | + if( 'list' === $field->type ) { |
|
| 1818 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1819 | 1819 | |
| 1820 | - $list_field_value = array(); |
|
| 1821 | - foreach ( (array) $list_rows as $row ) { |
|
| 1822 | - foreach ( (array) $row as $column ) { |
|
| 1823 | - $list_field_value[] = $column; |
|
| 1824 | - } |
|
| 1825 | - } |
|
| 1820 | + $list_field_value = array(); |
|
| 1821 | + foreach ( (array) $list_rows as $row ) { |
|
| 1822 | + foreach ( (array) $row as $column ) { |
|
| 1823 | + $list_field_value[] = $column; |
|
| 1824 | + } |
|
| 1825 | + } |
|
| 1826 | 1826 | |
| 1827 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1828 | - } else { |
|
| 1829 | - $field->defaultValue = $field_value; |
|
| 1830 | - } |
|
| 1831 | - } |
|
| 1827 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1828 | + } else { |
|
| 1829 | + $field->defaultValue = $field_value; |
|
| 1830 | + } |
|
| 1831 | + } |
|
| 1832 | 1832 | } |
| 1833 | 1833 | } |
| 1834 | 1834 | } |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | return $has_conditional_logic; |
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1888 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1889 | 1889 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 1890 | 1890 | } |
| 1891 | 1891 | |
@@ -1952,14 +1952,14 @@ discard block |
||
| 1952 | 1952 | |
| 1953 | 1953 | if( $echo && $error !== true ) { |
| 1954 | 1954 | |
| 1955 | - $error = esc_html( $error ); |
|
| 1955 | + $error = esc_html( $error ); |
|
| 1956 | 1956 | |
| 1957 | - /** |
|
| 1958 | - * @since 1.9 |
|
| 1959 | - */ |
|
| 1960 | - if ( ! empty( $this->entry ) ) { |
|
| 1961 | - $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;" ) ); |
|
| 1962 | - } |
|
| 1957 | + /** |
|
| 1958 | + * @since 1.9 |
|
| 1959 | + */ |
|
| 1960 | + if ( ! empty( $this->entry ) ) { |
|
| 1961 | + $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;" ) ); |
|
| 1962 | + } |
|
| 1963 | 1963 | |
| 1964 | 1964 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 1965 | 1965 | } |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function add_downloads_data_filters() { |
| 68 | 68 | |
| 69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
| 70 | 70 | |
| 71 | - if ( ! $downloads_data ) { |
|
| 71 | + if ( ! $downloads_data ) { |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function add_admin_menu() { |
| 99 | 99 | |
| 100 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 100 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
| 101 | 101 | |
| 102 | 102 | $menu_text = sprintf( '<span title="%s">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
| 103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | - * |
|
| 115 | + * When on the Installer page, show a different notice than on the Settings page |
|
| 116 | + * |
|
| 117 | 117 | * @param array $notice |
| 118 | 118 | * |
| 119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
| 122 | 122 | |
| 123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
| 124 | - return $notice; |
|
| 125 | - } |
|
| 124 | + return $notice; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -162,43 +162,43 @@ discard block |
||
| 162 | 162 | * Get downloads data from transient or from API; save transient after getting data from API |
| 163 | 163 | * |
| 164 | 164 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
| 165 | - * @type array $info { |
|
| 166 | - * @type string $id int 17 |
|
| 167 | - * @type string $slug Extension slug |
|
| 168 | - * @type string $title Extension title |
|
| 169 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | - * @type string $modified_date |
|
| 171 | - * @type string $status |
|
| 172 | - * @type string $link URL to public plugin page |
|
| 173 | - * @type string $content |
|
| 174 | - * @type string $excerpt |
|
| 175 | - * @type string $thumbnail URL to thumbnail |
|
| 176 | - * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | - * @type int $term_id => int 30 |
|
| 178 | - * @type string $name => string 'Plugins' (length=7) |
|
| 179 | - * @type string $slug => string 'plugins' (length=7) |
|
| 180 | - * @type int $term_group => int 0 |
|
| 181 | - * @type int $term_taxonomy_id => int 30 |
|
| 182 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | - * @type string $description => string '' (length=0) |
|
| 184 | - * @type int $parent => int 0 |
|
| 185 | - * @type int $count => int 4 |
|
| 186 | - * @type string $filter => string 'raw' (length=3) |
|
| 187 | - * } |
|
| 188 | - * @type array $tags {see $category above} |
|
| 189 | - * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | - * } |
|
| 191 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | - * @type array $licensing { |
|
| 193 | - * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | - * @type string $version Version number |
|
| 195 | - * @type string $exp_unit Expiration unit ('years') |
|
| 196 | - * @type string $exp_length Expiration length ('1') |
|
| 197 | - * } |
|
| 198 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | - * @type string $file string URL of the file download |
|
| 200 | - * } |
|
| 201 | - * } |
|
| 165 | + * @type array $info { |
|
| 166 | + * @type string $id int 17 |
|
| 167 | + * @type string $slug Extension slug |
|
| 168 | + * @type string $title Extension title |
|
| 169 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
| 170 | + * @type string $modified_date |
|
| 171 | + * @type string $status |
|
| 172 | + * @type string $link URL to public plugin page |
|
| 173 | + * @type string $content |
|
| 174 | + * @type string $excerpt |
|
| 175 | + * @type string $thumbnail URL to thumbnail |
|
| 176 | + * @type array $category Taxonomy details for the plugin's category { |
|
| 177 | + * @type int $term_id => int 30 |
|
| 178 | + * @type string $name => string 'Plugins' (length=7) |
|
| 179 | + * @type string $slug => string 'plugins' (length=7) |
|
| 180 | + * @type int $term_group => int 0 |
|
| 181 | + * @type int $term_taxonomy_id => int 30 |
|
| 182 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
| 183 | + * @type string $description => string '' (length=0) |
|
| 184 | + * @type int $parent => int 0 |
|
| 185 | + * @type int $count => int 4 |
|
| 186 | + * @type string $filter => string 'raw' (length=3) |
|
| 187 | + * } |
|
| 188 | + * @type array $tags {see $category above} |
|
| 189 | + * @type string $textdomain string 'gravityview' (length=11) |
|
| 190 | + * } |
|
| 191 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
| 192 | + * @type array $licensing { |
|
| 193 | + * @type bool $enabled Is licensing enabled for the extension |
|
| 194 | + * @type string $version Version number |
|
| 195 | + * @type string $exp_unit Expiration unit ('years') |
|
| 196 | + * @type string $exp_length Expiration length ('1') |
|
| 197 | + * } |
|
| 198 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
| 199 | + * @type string $file string URL of the file download |
|
| 200 | + * } |
|
| 201 | + * } |
|
| 202 | 202 | */ |
| 203 | 203 | public function get_downloads_data() { |
| 204 | 204 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | ) ); |
| 227 | 227 | |
| 228 | 228 | if ( is_wp_error( $response ) ) { |
| 229 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 229 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
| 230 | 230 | return $response; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | <div class="gv-admin-installer-notice notice inline error"> |
| 280 | 280 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
| 281 | 281 | <?php |
| 282 | - if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | - } |
|
| 285 | - ?> |
|
| 282 | + if ( is_wp_error( $downloads_data ) ) { |
|
| 283 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
| 284 | + } |
|
| 285 | + ?> |
|
| 286 | 286 | </div> |
| 287 | 287 | </div> |
| 288 | 288 | <?php |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | protected function render_download( $download, $wp_plugins ) { |
| 339 | 339 | |
| 340 | 340 | |
| 341 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 341 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
| 342 | 342 | |
| 343 | - $download_info = $details['download_info']; |
|
| 343 | + $download_info = $details['download_info']; |
|
| 344 | 344 | |
| 345 | 345 | ?> |
| 346 | 346 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -362,43 +362,43 @@ discard block |
||
| 362 | 362 | |
| 363 | 363 | <div class="addon-excerpt"><?php |
| 364 | 364 | |
| 365 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 365 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
| 366 | 366 | |
| 367 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 367 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
| 368 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
| 369 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
| 370 | 370 | |
| 371 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 371 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
| 372 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
| 373 | 373 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
| 374 | 374 | |
| 375 | 375 | echo wpautop( $excerpt ); |
| 376 | - ?></div> |
|
| 376 | + ?></div> |
|
| 377 | 377 | </div> |
| 378 | 378 | </div> |
| 379 | 379 | <?php |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | - * |
|
| 383 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
| 384 | + * |
|
| 385 | 385 | * @param array $download Single download, as returned by {@see get_downloads_data} |
| 386 | 386 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
| 387 | 387 | * |
| 388 | 388 | * @return array { |
| 389 | - * @type array $download_info |
|
| 390 | - * @type string $plugin_path |
|
| 391 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | - * @type string $status_label |
|
| 393 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | - * @type string $button_class CSS class to use for the button |
|
| 395 | - * @type string $button_label Text to use for the download's anchor link |
|
| 396 | - * @type string $href URL for the download's button |
|
| 397 | - * @type bool $spinner Whether to show the spinner icon |
|
| 398 | - * @type string $item_class CSS class for the download container |
|
| 399 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | - * } |
|
| 389 | + * @type array $download_info |
|
| 390 | + * @type string $plugin_path |
|
| 391 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
| 392 | + * @type string $status_label |
|
| 393 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
| 394 | + * @type string $button_class CSS class to use for the button |
|
| 395 | + * @type string $button_label Text to use for the download's anchor link |
|
| 396 | + * @type string $href URL for the download's button |
|
| 397 | + * @type bool $spinner Whether to show the spinner icon |
|
| 398 | + * @type string $item_class CSS class for the download container |
|
| 399 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
| 400 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
| 401 | + * } |
|
| 402 | 402 | */ |
| 403 | 403 | private function get_download_display_details( $download, $wp_plugins ) { |
| 404 | 404 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | 'slug' => '', |
| 410 | 410 | 'excerpt' => '', |
| 411 | 411 | 'link' => '', |
| 412 | - 'coming_soon' => false, |
|
| 412 | + 'coming_soon' => false, |
|
| 413 | 413 | 'installer_title' => null, // May not be defined |
| 414 | 414 | 'installer_excerpt' => null, // May not be defined |
| 415 | 415 | ) ); |
@@ -451,14 +451,14 @@ discard block |
||
| 451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | - $spinner = false; |
|
| 456 | - $status = 'notinstalled'; |
|
| 457 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | - $button_class = 'button-primary button-large'; |
|
| 460 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | - } |
|
| 454 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
| 455 | + $spinner = false; |
|
| 456 | + $status = 'notinstalled'; |
|
| 457 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
| 458 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
| 459 | + $button_class = 'button-primary button-large'; |
|
| 460 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | 463 | // Access but the plugin is not installed |
| 464 | 464 | elseif ( ! $wp_plugin ) { |
@@ -498,18 +498,18 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Returns the base price for an extension |
|
| 505 | - * |
|
| 504 | + * Returns the base price for an extension |
|
| 505 | + * |
|
| 506 | 506 | * @param array $download |
| 507 | 507 | * |
| 508 | 508 | * @return float Base price for an extension. If not for sale separately, returns 0 |
| 509 | 509 | */ |
| 510 | 510 | private function get_download_base_price( $download ) { |
| 511 | 511 | |
| 512 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 512 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
| 513 | 513 | $base_price = \GFCommon::to_number( $base_price ); |
| 514 | 514 | |
| 515 | 515 | unset( $download['pricing']['amount'] ); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | return floatval( $base_price ); |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | 526 | * Handle AJAX request to activate extension |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
| 540 | 540 | wp_send_json_error( array( |
| 541 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | - ) ); |
|
| 541 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
| 542 | + ) ); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | wp_send_json_success(); |
@@ -560,10 +560,10 @@ discard block |
||
| 560 | 560 | deactivate_plugins( $data['path'] ); |
| 561 | 561 | |
| 562 | 562 | if( is_plugin_active( $data['path'] ) ) { |
| 563 | - wp_send_json_error( array( |
|
| 564 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | - ) ); |
|
| 566 | - } |
|
| 563 | + wp_send_json_error( array( |
|
| 564 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
| 565 | + ) ); |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | wp_send_json_success(); |
| 569 | 569 | } |