@@ -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 |
@@ -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 | } |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * ID of the current post. May also be ID of the current View. |
| 105 | - * |
|
| 106 | - * @since 2.0.13 |
|
| 107 | - * |
|
| 108 | - * @var int |
|
| 105 | + * |
|
| 106 | + * @since 2.0.13 |
|
| 107 | + * |
|
| 108 | + * @var int |
|
| 109 | 109 | */ |
| 110 | 110 | public $post_id; |
| 111 | 111 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function prevent_maybe_process_form() { |
| 190 | 190 | |
| 191 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 191 | + if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | * When Edit entry view is requested setup the vars |
| 223 | 223 | */ |
| 224 | 224 | private function setup_vars() { |
| 225 | - global $post; |
|
| 225 | + global $post; |
|
| 226 | 226 | |
| 227 | 227 | $gravityview_view = GravityView_View::getInstance(); |
| 228 | 228 | |
| 229 | 229 | |
| 230 | 230 | $entries = $gravityview_view->getEntries(); |
| 231 | - self::$original_entry = $entries[0]; |
|
| 232 | - $this->entry = $entries[0]; |
|
| 231 | + self::$original_entry = $entries[0]; |
|
| 232 | + $this->entry = $entries[0]; |
|
| 233 | 233 | |
| 234 | 234 | self::$original_form = $gravityview_view->getForm(); |
| 235 | 235 | $this->form = $gravityview_view->getForm(); |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
| 373 | 373 | |
| 374 | - // Delete the values for hidden inputs |
|
| 375 | - $this->unset_hidden_field_values(); |
|
| 374 | + // Delete the values for hidden inputs |
|
| 375 | + $this->unset_hidden_field_values(); |
|
| 376 | 376 | |
| 377 | 377 | $this->entry['date_created'] = $date_created; |
| 378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | // Perform actions normally performed after updating a lead |
| 383 | 383 | $this->after_update(); |
| 384 | 384 | |
| 385 | - /** |
|
| 385 | + /** |
|
| 386 | 386 | * Must be AFTER after_update()! |
| 387 | 387 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 388 | 388 | */ |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 393 | - * @since 2.1 Added $gv_data parameter |
|
| 393 | + * @since 2.1 Added $gv_data parameter |
|
| 394 | 394 | * @param array $form Gravity Forms form array |
| 395 | 395 | * @param string $entry_id Numeric ID of the entry that was updated |
| 396 | 396 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | 416 | private function unset_hidden_field_values() { |
| 417 | - global $wpdb; |
|
| 417 | + global $wpdb; |
|
| 418 | 418 | |
| 419 | 419 | /** |
| 420 | 420 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 441 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 442 | 442 | |
| 443 | 443 | if ( ! is_numeric( $input_id ) ) { |
| 444 | 444 | continue; |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | continue; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - // Reset fields that are or would be hidden |
|
| 452 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 451 | + // Reset fields that are or would be hidden |
|
| 452 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 453 | 453 | |
| 454 | 454 | $empty_value = $field->get_value_save_entry( |
| 455 | 455 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -461,16 +461,16 @@ discard block |
||
| 461 | 461 | $empty_value = ''; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 464 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 465 | 465 | |
| 466 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 466 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 467 | 467 | |
| 468 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 468 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 469 | 469 | // after submission |
| 470 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 471 | - $_POST[ $post_input_id ] = ''; |
|
| 472 | - } |
|
| 473 | - } |
|
| 470 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 471 | + $_POST[ $post_input_id ] = ''; |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | $form = $this->filter_conditional_logic( $this->form ); |
| 566 | 566 | |
| 567 | - /** @var GF_Field $field */ |
|
| 567 | + /** @var GF_Field $field */ |
|
| 568 | 568 | foreach( $form['fields'] as $k => &$field ) { |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | |
| 581 | 581 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 582 | 582 | foreach( $field->inputs as $key => $input ) { |
| 583 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 583 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | } |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | $inputs = $field->get_entry_inputs(); |
| 622 | 622 | if ( is_array( $inputs ) ) { |
| 623 | - foreach ( $inputs as $input ) { |
|
| 623 | + foreach ( $inputs as $input ) { |
|
| 624 | 624 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 625 | 625 | |
| 626 | 626 | if ( 'product' === $field->type ) { |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 642 | - } |
|
| 642 | + } |
|
| 643 | 643 | } else { |
| 644 | 644 | // Set to what it previously was if it's not editable |
| 645 | 645 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 686 | 686 | |
| 687 | 687 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 688 | - $ary = stripslashes_deep( $ary ); |
|
| 688 | + $ary = stripslashes_deep( $ary ); |
|
| 689 | 689 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 690 | 690 | |
| 691 | 691 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | private function maybe_update_post_fields( $form ) { |
| 759 | 759 | |
| 760 | 760 | if( empty( $this->entry['post_id'] ) ) { |
| 761 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 761 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 762 | 762 | return; |
| 763 | 763 | } |
| 764 | 764 | |
@@ -793,49 +793,49 @@ discard block |
||
| 793 | 793 | |
| 794 | 794 | switch( $field->type ) { |
| 795 | 795 | |
| 796 | - case 'post_title': |
|
| 797 | - $post_title = $value; |
|
| 798 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 799 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 800 | - } |
|
| 801 | - $updated_post->post_title = $post_title; |
|
| 802 | - $updated_post->post_name = $post_title; |
|
| 803 | - unset( $post_title ); |
|
| 804 | - break; |
|
| 805 | - |
|
| 806 | - case 'post_content': |
|
| 807 | - $post_content = $value; |
|
| 808 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 809 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 810 | - } |
|
| 811 | - $updated_post->post_content = $post_content; |
|
| 812 | - unset( $post_content ); |
|
| 813 | - break; |
|
| 814 | - case 'post_excerpt': |
|
| 815 | - $updated_post->post_excerpt = $value; |
|
| 816 | - break; |
|
| 817 | - case 'post_tags': |
|
| 818 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 819 | - break; |
|
| 820 | - case 'post_category': |
|
| 821 | - break; |
|
| 822 | - case 'post_custom_field': |
|
| 796 | + case 'post_title': |
|
| 797 | + $post_title = $value; |
|
| 798 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 799 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 800 | + } |
|
| 801 | + $updated_post->post_title = $post_title; |
|
| 802 | + $updated_post->post_name = $post_title; |
|
| 803 | + unset( $post_title ); |
|
| 804 | + break; |
|
| 805 | + |
|
| 806 | + case 'post_content': |
|
| 807 | + $post_content = $value; |
|
| 808 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 809 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 810 | + } |
|
| 811 | + $updated_post->post_content = $post_content; |
|
| 812 | + unset( $post_content ); |
|
| 813 | + break; |
|
| 814 | + case 'post_excerpt': |
|
| 815 | + $updated_post->post_excerpt = $value; |
|
| 816 | + break; |
|
| 817 | + case 'post_tags': |
|
| 818 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 819 | + break; |
|
| 820 | + case 'post_category': |
|
| 821 | + break; |
|
| 822 | + case 'post_custom_field': |
|
| 823 | 823 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 824 | 824 | $value = $value[ $field_id ]; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 828 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 829 | - } |
|
| 827 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 828 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 829 | + } |
|
| 830 | 830 | |
| 831 | 831 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 832 | 832 | |
| 833 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 834 | - break; |
|
| 833 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 834 | + break; |
|
| 835 | 835 | |
| 836 | - case 'post_image': |
|
| 837 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 838 | - break; |
|
| 836 | + case 'post_image': |
|
| 837 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 838 | + break; |
|
| 839 | 839 | |
| 840 | 840 | } |
| 841 | 841 | |
@@ -992,14 +992,14 @@ discard block |
||
| 992 | 992 | ?><h2 class="gv-edit-entry-title"> |
| 993 | 993 | <span><?php |
| 994 | 994 | |
| 995 | - /** |
|
| 996 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 997 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 998 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 999 | - */ |
|
| 1000 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 995 | + /** |
|
| 996 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 997 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 998 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 999 | + */ |
|
| 1000 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1001 | 1001 | |
| 1002 | - echo esc_attr( $edit_entry_title ); |
|
| 1002 | + echo esc_attr( $edit_entry_title ); |
|
| 1003 | 1003 | ?></span> |
| 1004 | 1004 | </h2> |
| 1005 | 1005 | |
@@ -1054,13 +1054,13 @@ discard block |
||
| 1054 | 1054 | ); |
| 1055 | 1055 | |
| 1056 | 1056 | /** |
| 1057 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1058 | - * @since 1.16.3 |
|
| 1059 | - * @param array $labels Default button labels associative array |
|
| 1060 | - * @param array $form The Gravity Forms form |
|
| 1061 | - * @param array $entry The Gravity Forms entry |
|
| 1062 | - * @param int $view_id The current View ID |
|
| 1063 | - */ |
|
| 1057 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1058 | + * @since 1.16.3 |
|
| 1059 | + * @param array $labels Default button labels associative array |
|
| 1060 | + * @param array $form The Gravity Forms form |
|
| 1061 | + * @param array $entry The Gravity Forms entry |
|
| 1062 | + * @param int $view_id The current View ID |
|
| 1063 | + */ |
|
| 1064 | 1064 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1065 | 1065 | |
| 1066 | 1066 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1097,26 +1097,26 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | switch ( $edit_redirect ) { |
| 1099 | 1099 | |
| 1100 | - case '0': |
|
| 1101 | - $redirect_url = $back_link; |
|
| 1102 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1103 | - break; |
|
| 1104 | - |
|
| 1105 | - case '1': |
|
| 1106 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1107 | - $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>' ); |
|
| 1108 | - break; |
|
| 1109 | - |
|
| 1110 | - case '2': |
|
| 1111 | - $redirect_url = $edit_redirect_url; |
|
| 1112 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1113 | - $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>' ); |
|
| 1114 | - break; |
|
| 1115 | - |
|
| 1116 | - case '': |
|
| 1117 | - default: |
|
| 1118 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1119 | - break; |
|
| 1100 | + case '0': |
|
| 1101 | + $redirect_url = $back_link; |
|
| 1102 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1103 | + break; |
|
| 1104 | + |
|
| 1105 | + case '1': |
|
| 1106 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1107 | + $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>' ); |
|
| 1108 | + break; |
|
| 1109 | + |
|
| 1110 | + case '2': |
|
| 1111 | + $redirect_url = $edit_redirect_url; |
|
| 1112 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1113 | + $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>' ); |
|
| 1114 | + break; |
|
| 1115 | + |
|
| 1116 | + case '': |
|
| 1117 | + default: |
|
| 1118 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1119 | + break; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | if ( isset( $redirect_url ) ) { |
@@ -1182,13 +1182,13 @@ discard block |
||
| 1182 | 1182 | ); |
| 1183 | 1183 | |
| 1184 | 1184 | /** |
| 1185 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1186 | - * @since 1.16.3 |
|
| 1187 | - * @param array $labels Default button labels associative array |
|
| 1188 | - * @param array $form The Gravity Forms form |
|
| 1189 | - * @param array $entry The Gravity Forms entry |
|
| 1190 | - * @param int $view_id The current View ID |
|
| 1191 | - */ |
|
| 1185 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1186 | + * @since 1.16.3 |
|
| 1187 | + * @param array $labels Default button labels associative array |
|
| 1188 | + * @param array $form The Gravity Forms form |
|
| 1189 | + * @param array $entry The Gravity Forms entry |
|
| 1190 | + * @param int $view_id The current View ID |
|
| 1191 | + */ |
|
| 1192 | 1192 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1193 | 1193 | |
| 1194 | 1194 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | |
| 1231 | 1231 | ob_get_clean(); |
| 1232 | 1232 | |
| 1233 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1233 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1234 | 1234 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1235 | 1235 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1236 | 1236 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | |
| 1291 | 1291 | // for now we don't support Save and Continue feature. |
| 1292 | 1292 | if( ! self::$supports_save_and_continue ) { |
| 1293 | - unset( $form['save'] ); |
|
| 1293 | + unset( $form['save'] ); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | $form = $this->unselect_default_values( $form ); |
@@ -1317,30 +1317,30 @@ discard block |
||
| 1317 | 1317 | return $field_content; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - $message = null; |
|
| 1320 | + $message = null; |
|
| 1321 | 1321 | |
| 1322 | - // First, make sure they have the capability to edit the post. |
|
| 1323 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1322 | + // First, make sure they have the capability to edit the post. |
|
| 1323 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1324 | 1324 | |
| 1325 | - /** |
|
| 1326 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1327 | - * @param string $message The existing "You don't have permission..." text |
|
| 1328 | - */ |
|
| 1329 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1325 | + /** |
|
| 1326 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1327 | + * @param string $message The existing "You don't have permission..." text |
|
| 1328 | + */ |
|
| 1329 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1330 | 1330 | |
| 1331 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1332 | - /** |
|
| 1333 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1334 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1335 | - */ |
|
| 1336 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1337 | - } |
|
| 1331 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1332 | + /** |
|
| 1333 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1334 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1335 | + */ |
|
| 1336 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1337 | + } |
|
| 1338 | 1338 | |
| 1339 | - if( $message ) { |
|
| 1340 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1341 | - } |
|
| 1339 | + if( $message ) { |
|
| 1340 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1341 | + } |
|
| 1342 | 1342 | |
| 1343 | - return $field_content; |
|
| 1343 | + return $field_content; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | /** |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | || ! empty( $field_content ) |
| 1369 | 1369 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1370 | 1370 | ) { |
| 1371 | - return $field_content; |
|
| 1371 | + return $field_content; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1376,24 +1376,24 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | $field_value = $this->get_field_value( $field ); |
| 1378 | 1378 | |
| 1379 | - // Prevent any PHP warnings, like undefined index |
|
| 1380 | - ob_start(); |
|
| 1379 | + // Prevent any PHP warnings, like undefined index |
|
| 1380 | + ob_start(); |
|
| 1381 | 1381 | |
| 1382 | - $return = null; |
|
| 1382 | + $return = null; |
|
| 1383 | 1383 | |
| 1384 | 1384 | /** @var GravityView_Field $gv_field */ |
| 1385 | 1385 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1386 | 1386 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1387 | 1387 | } else { |
| 1388 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1389 | - } |
|
| 1388 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1389 | + } |
|
| 1390 | 1390 | |
| 1391 | - // If there was output, it's an error |
|
| 1392 | - $warnings = ob_get_clean(); |
|
| 1391 | + // If there was output, it's an error |
|
| 1392 | + $warnings = ob_get_clean(); |
|
| 1393 | 1393 | |
| 1394 | - if( !empty( $warnings ) ) { |
|
| 1395 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1396 | - } |
|
| 1394 | + if( !empty( $warnings ) ) { |
|
| 1395 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | 1398 | return $return; |
| 1399 | 1399 | } |
@@ -1428,8 +1428,8 @@ discard block |
||
| 1428 | 1428 | $input_id = strval( $input['id'] ); |
| 1429 | 1429 | |
| 1430 | 1430 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1431 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1432 | - $allow_pre_populated = false; |
|
| 1431 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1432 | + $allow_pre_populated = false; |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | } |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1454 | 1454 | $categories = array(); |
| 1455 | 1455 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1456 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1456 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1459 | 1459 | } |
@@ -1463,25 +1463,25 @@ discard block |
||
| 1463 | 1463 | // if value is empty get the default value if defined |
| 1464 | 1464 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1465 | 1465 | |
| 1466 | - /** |
|
| 1467 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1468 | - * @since 1.11 |
|
| 1469 | - * @since 1.20 Added third param |
|
| 1470 | - * @param mixed $field_value field value used to populate the input |
|
| 1471 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1472 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1473 | - */ |
|
| 1474 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1475 | - |
|
| 1476 | - /** |
|
| 1477 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1478 | - * @since 1.17 |
|
| 1479 | - * @since 1.20 Added third param |
|
| 1480 | - * @param mixed $field_value field value used to populate the input |
|
| 1481 | - * @param GF_Field $field Gravity Forms field object |
|
| 1482 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1483 | - */ |
|
| 1484 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1466 | + /** |
|
| 1467 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1468 | + * @since 1.11 |
|
| 1469 | + * @since 1.20 Added third param |
|
| 1470 | + * @param mixed $field_value field value used to populate the input |
|
| 1471 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1472 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1473 | + */ |
|
| 1474 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1475 | + |
|
| 1476 | + /** |
|
| 1477 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1478 | + * @since 1.17 |
|
| 1479 | + * @since 1.20 Added third param |
|
| 1480 | + * @param mixed $field_value field value used to populate the input |
|
| 1481 | + * @param GF_Field $field Gravity Forms field object |
|
| 1482 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1483 | + */ |
|
| 1484 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1485 | 1485 | |
| 1486 | 1486 | return $field_value; |
| 1487 | 1487 | } |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1509 | 1509 | // expects certain field array items to be set. |
| 1510 | 1510 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1511 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1511 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | 1514 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1522,61 +1522,61 @@ discard block |
||
| 1522 | 1522 | */ |
| 1523 | 1523 | case 'fileupload': |
| 1524 | 1524 | |
| 1525 | - // Set the previous value |
|
| 1526 | - $entry = $this->get_entry(); |
|
| 1525 | + // Set the previous value |
|
| 1526 | + $entry = $this->get_entry(); |
|
| 1527 | 1527 | |
| 1528 | - $input_name = 'input_'.$field->id; |
|
| 1529 | - $form_id = $form['id']; |
|
| 1528 | + $input_name = 'input_'.$field->id; |
|
| 1529 | + $form_id = $form['id']; |
|
| 1530 | 1530 | |
| 1531 | - $value = NULL; |
|
| 1531 | + $value = NULL; |
|
| 1532 | 1532 | |
| 1533 | - // Use the previous entry value as the default. |
|
| 1534 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1535 | - $value = $entry[ $field->id ]; |
|
| 1536 | - } |
|
| 1533 | + // Use the previous entry value as the default. |
|
| 1534 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1535 | + $value = $entry[ $field->id ]; |
|
| 1536 | + } |
|
| 1537 | 1537 | |
| 1538 | - // If this is a single upload file |
|
| 1539 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1540 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1541 | - $value = $file_path['url']; |
|
| 1538 | + // If this is a single upload file |
|
| 1539 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1540 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1541 | + $value = $file_path['url']; |
|
| 1542 | 1542 | |
| 1543 | - } else { |
|
| 1543 | + } else { |
|
| 1544 | 1544 | |
| 1545 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1546 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1547 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1545 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1546 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1547 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1548 | 1548 | |
| 1549 | - } |
|
| 1549 | + } |
|
| 1550 | 1550 | |
| 1551 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1551 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1552 | 1552 | |
| 1553 | - // If there are fresh uploads, process and merge them. |
|
| 1554 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1555 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1556 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1557 | - $value = stripslashes_deep( $value ); |
|
| 1558 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1559 | - } |
|
| 1553 | + // If there are fresh uploads, process and merge them. |
|
| 1554 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1555 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1556 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1557 | + $value = stripslashes_deep( $value ); |
|
| 1558 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1559 | + } |
|
| 1560 | 1560 | |
| 1561 | - } else { |
|
| 1561 | + } else { |
|
| 1562 | 1562 | |
| 1563 | - // A file already exists when editing an entry |
|
| 1564 | - // We set this to solve issue when file upload fields are required. |
|
| 1565 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1563 | + // A file already exists when editing an entry |
|
| 1564 | + // We set this to solve issue when file upload fields are required. |
|
| 1565 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1566 | 1566 | |
| 1567 | - } |
|
| 1567 | + } |
|
| 1568 | 1568 | |
| 1569 | - $this->entry[ $input_name ] = $value; |
|
| 1570 | - $_POST[ $input_name ] = $value; |
|
| 1569 | + $this->entry[ $input_name ] = $value; |
|
| 1570 | + $_POST[ $input_name ] = $value; |
|
| 1571 | 1571 | |
| 1572 | - break; |
|
| 1572 | + break; |
|
| 1573 | 1573 | |
| 1574 | 1574 | case 'number': |
| 1575 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1576 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1577 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1578 | - } |
|
| 1579 | - break; |
|
| 1575 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1576 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1577 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1578 | + } |
|
| 1579 | + break; |
|
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | } |
@@ -1661,43 +1661,43 @@ discard block |
||
| 1661 | 1661 | case 'fileupload' : |
| 1662 | 1662 | case 'post_image': |
| 1663 | 1663 | |
| 1664 | - // in case nothing is uploaded but there are already files saved |
|
| 1665 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1666 | - $field->failed_validation = false; |
|
| 1667 | - unset( $field->validation_message ); |
|
| 1668 | - } |
|
| 1664 | + // in case nothing is uploaded but there are already files saved |
|
| 1665 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1666 | + $field->failed_validation = false; |
|
| 1667 | + unset( $field->validation_message ); |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1671 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1670 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1671 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1672 | 1672 | |
| 1673 | - $input_name = 'input_' . $field->id; |
|
| 1674 | - //uploaded |
|
| 1675 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1673 | + $input_name = 'input_' . $field->id; |
|
| 1674 | + //uploaded |
|
| 1675 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1676 | 1676 | |
| 1677 | - //existent |
|
| 1678 | - $entry = $this->get_entry(); |
|
| 1679 | - $value = NULL; |
|
| 1680 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1681 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1682 | - } |
|
| 1677 | + //existent |
|
| 1678 | + $entry = $this->get_entry(); |
|
| 1679 | + $value = NULL; |
|
| 1680 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1681 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1682 | + } |
|
| 1683 | 1683 | |
| 1684 | - // count uploaded files and existent entry files |
|
| 1685 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1686 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1684 | + // count uploaded files and existent entry files |
|
| 1685 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1686 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1687 | 1687 | |
| 1688 | - if( $count_files > $field->maxFiles ) { |
|
| 1689 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1690 | - $field->failed_validation = 1; |
|
| 1691 | - $gv_valid = false; |
|
| 1688 | + if( $count_files > $field->maxFiles ) { |
|
| 1689 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1690 | + $field->failed_validation = 1; |
|
| 1691 | + $gv_valid = false; |
|
| 1692 | 1692 | |
| 1693 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1694 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1695 | - } |
|
| 1693 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1694 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1695 | + } |
|
| 1696 | 1696 | |
| 1697 | - } |
|
| 1697 | + } |
|
| 1698 | 1698 | |
| 1699 | 1699 | |
| 1700 | - break; |
|
| 1700 | + break; |
|
| 1701 | 1701 | |
| 1702 | 1702 | } |
| 1703 | 1703 | |
@@ -1708,47 +1708,47 @@ discard block |
||
| 1708 | 1708 | |
| 1709 | 1709 | switch ( $field_type ) { |
| 1710 | 1710 | |
| 1711 | - // Captchas don't need to be re-entered. |
|
| 1712 | - case 'captcha': |
|
| 1711 | + // Captchas don't need to be re-entered. |
|
| 1712 | + case 'captcha': |
|
| 1713 | 1713 | |
| 1714 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1715 | - case 'post_image': |
|
| 1716 | - $field->failed_validation = false; |
|
| 1717 | - unset( $field->validation_message ); |
|
| 1718 | - break; |
|
| 1714 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1715 | + case 'post_image': |
|
| 1716 | + $field->failed_validation = false; |
|
| 1717 | + unset( $field->validation_message ); |
|
| 1718 | + break; |
|
| 1719 | 1719 | |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | // You can't continue inside a switch, so we do it after. |
| 1723 | 1723 | if( empty( $field->failed_validation ) ) { |
| 1724 | - continue; |
|
| 1724 | + continue; |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1728 | 1728 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1729 | 1729 | if( !empty( $field->noDuplicates ) ) { |
| 1730 | 1730 | |
| 1731 | - $entry = $this->get_entry(); |
|
| 1731 | + $entry = $this->get_entry(); |
|
| 1732 | 1732 | |
| 1733 | - // If the value of the entry is the same as the stored value |
|
| 1734 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1735 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1736 | - //if value submitted was not changed, then don't validate |
|
| 1737 | - $field->failed_validation = false; |
|
| 1733 | + // If the value of the entry is the same as the stored value |
|
| 1734 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1735 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1736 | + //if value submitted was not changed, then don't validate |
|
| 1737 | + $field->failed_validation = false; |
|
| 1738 | 1738 | |
| 1739 | - unset( $field->validation_message ); |
|
| 1739 | + unset( $field->validation_message ); |
|
| 1740 | 1740 | |
| 1741 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1741 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1742 | 1742 | |
| 1743 | - continue; |
|
| 1744 | - } |
|
| 1743 | + continue; |
|
| 1744 | + } |
|
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | 1747 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1748 | 1748 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1749 | - unset( $field->validation_message ); |
|
| 1750 | - $field->validation_message = false; |
|
| 1751 | - continue; |
|
| 1749 | + unset( $field->validation_message ); |
|
| 1750 | + $field->validation_message = false; |
|
| 1751 | + continue; |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | $gv_valid = false; |
@@ -1812,8 +1812,8 @@ discard block |
||
| 1812 | 1812 | // Hide fields depending on admin settings |
| 1813 | 1813 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1814 | 1814 | |
| 1815 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1816 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1815 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1816 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1817 | 1817 | |
| 1818 | 1818 | /** |
| 1819 | 1819 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1892,11 +1892,11 @@ discard block |
||
| 1892 | 1892 | // The edit tab has been configured, so we loop through to configured settings |
| 1893 | 1893 | foreach ( $configured_fields as $configured_field ) { |
| 1894 | 1894 | |
| 1895 | - /** @var GF_Field $field */ |
|
| 1896 | - foreach ( $fields as $field ) { |
|
| 1895 | + /** @var GF_Field $field */ |
|
| 1896 | + foreach ( $fields as $field ) { |
|
| 1897 | 1897 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1898 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1899 | - break; |
|
| 1898 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1899 | + break; |
|
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | 1902 | } |
@@ -1952,28 +1952,28 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1954 | 1954 | |
| 1955 | - /** |
|
| 1955 | + /** |
|
| 1956 | 1956 | * @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 |
| 1957 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1958 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1959 | - * @since 1.9.1 |
|
| 1960 | - * @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. |
|
| 1961 | - * @param array $form GF Form array |
|
| 1962 | - * @param int $view_id View ID |
|
| 1963 | - */ |
|
| 1964 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1965 | - |
|
| 1966 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1957 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1958 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1959 | + * @since 1.9.1 |
|
| 1960 | + * @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. |
|
| 1961 | + * @param array $form GF Form array |
|
| 1962 | + * @param int $view_id View ID |
|
| 1963 | + */ |
|
| 1964 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1965 | + |
|
| 1966 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1967 | 1967 | foreach( $fields as $k => $field ) { |
| 1968 | 1968 | if( $field->adminOnly ) { |
| 1969 | - unset( $fields[ $k ] ); |
|
| 1969 | + unset( $fields[ $k ] ); |
|
| 1970 | 1970 | } |
| 1971 | 1971 | } |
| 1972 | 1972 | return array_values( $fields ); |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | - foreach( $fields as &$field ) { |
|
| 1976 | - $field->adminOnly = false; |
|
| 1975 | + foreach( $fields as &$field ) { |
|
| 1976 | + $field->adminOnly = false; |
|
| 1977 | 1977 | } |
| 1978 | 1978 | |
| 1979 | 1979 | return $fields; |
@@ -1993,13 +1993,13 @@ discard block |
||
| 1993 | 1993 | */ |
| 1994 | 1994 | private function unselect_default_values( $form ) { |
| 1995 | 1995 | |
| 1996 | - foreach ( $form['fields'] as &$field ) { |
|
| 1996 | + foreach ( $form['fields'] as &$field ) { |
|
| 1997 | 1997 | |
| 1998 | 1998 | if ( empty( $field->choices ) ) { |
| 1999 | - continue; |
|
| 1999 | + continue; |
|
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - foreach ( $field->choices as &$choice ) { |
|
| 2002 | + foreach ( $field->choices as &$choice ) { |
|
| 2003 | 2003 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 2004 | 2004 | $choice['isSelected'] = false; |
| 2005 | 2005 | } |
@@ -2036,36 +2036,36 @@ discard block |
||
| 2036 | 2036 | |
| 2037 | 2037 | if( 'checkbox' === $field->type ) { |
| 2038 | 2038 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2039 | - $input_id = $input['id']; |
|
| 2040 | - $choice = $field->choices[ $key ]; |
|
| 2041 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2042 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2043 | - if( $match ) { |
|
| 2044 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2045 | - } |
|
| 2039 | + $input_id = $input['id']; |
|
| 2040 | + $choice = $field->choices[ $key ]; |
|
| 2041 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2042 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2043 | + if( $match ) { |
|
| 2044 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 2045 | + } |
|
| 2046 | 2046 | } |
| 2047 | 2047 | } else { |
| 2048 | 2048 | |
| 2049 | 2049 | // We need to run through each field to set the default values |
| 2050 | 2050 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2051 | 2051 | |
| 2052 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2052 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2053 | 2053 | |
| 2054 | - if( 'list' === $field->type ) { |
|
| 2055 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 2054 | + if( 'list' === $field->type ) { |
|
| 2055 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 2056 | 2056 | |
| 2057 | - $list_field_value = array(); |
|
| 2058 | - foreach ( (array) $list_rows as $row ) { |
|
| 2059 | - foreach ( (array) $row as $column ) { |
|
| 2060 | - $list_field_value[] = $column; |
|
| 2061 | - } |
|
| 2062 | - } |
|
| 2057 | + $list_field_value = array(); |
|
| 2058 | + foreach ( (array) $list_rows as $row ) { |
|
| 2059 | + foreach ( (array) $row as $column ) { |
|
| 2060 | + $list_field_value[] = $column; |
|
| 2061 | + } |
|
| 2062 | + } |
|
| 2063 | 2063 | |
| 2064 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 2065 | - } else { |
|
| 2066 | - $field->defaultValue = $field_value; |
|
| 2067 | - } |
|
| 2068 | - } |
|
| 2064 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 2065 | + } else { |
|
| 2066 | + $field->defaultValue = $field_value; |
|
| 2067 | + } |
|
| 2068 | + } |
|
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | } |
@@ -2126,7 +2126,7 @@ discard block |
||
| 2126 | 2126 | foreach ( $form['fields'] as &$field ) { |
| 2127 | 2127 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2128 | 2128 | |
| 2129 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2129 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2130 | 2130 | |
| 2131 | 2131 | if ( $field['id'] == $rule_field_id ) { |
| 2132 | 2132 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2177,7 +2177,7 @@ discard block |
||
| 2177 | 2177 | return $has_conditional_logic; |
| 2178 | 2178 | } |
| 2179 | 2179 | |
| 2180 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2180 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2181 | 2181 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2182 | 2182 | } |
| 2183 | 2183 | |
@@ -2244,14 +2244,14 @@ discard block |
||
| 2244 | 2244 | |
| 2245 | 2245 | if( $echo && $error !== true ) { |
| 2246 | 2246 | |
| 2247 | - $error = esc_html( $error ); |
|
| 2247 | + $error = esc_html( $error ); |
|
| 2248 | 2248 | |
| 2249 | - /** |
|
| 2250 | - * @since 1.9 |
|
| 2251 | - */ |
|
| 2252 | - if ( ! empty( $this->entry ) ) { |
|
| 2253 | - $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;" ) ); |
|
| 2254 | - } |
|
| 2249 | + /** |
|
| 2250 | + * @since 1.9 |
|
| 2251 | + */ |
|
| 2252 | + if ( ! empty( $this->entry ) ) { |
|
| 2253 | + $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;" ) ); |
|
| 2254 | + } |
|
| 2255 | 2255 | |
| 2256 | 2256 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2257 | 2257 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
| 261 | 261 | self::getInstance()->set_entry( $entry ); |
| 262 | 262 | |
| 263 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 263 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 264 | 264 | |
| 265 | 265 | if ( empty( $base ) ) { |
| 266 | 266 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | 'action' => 'duplicate', |
| 272 | 272 | 'entry_id' => $entry['id'], |
| 273 | 273 | 'gvid' => $view_id, |
| 274 | - 'view_id' => $view_id, |
|
| 274 | + 'view_id' => $view_id, |
|
| 275 | 275 | ), $base ); |
| 276 | 276 | |
| 277 | 277 | return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * @since 2.5 |
| 471 | 471 | * @param array $duplicated_entry The duplicated entry |
| 472 | 472 | * @param array $entry The original entry |
| 473 | - */ |
|
| 473 | + */ |
|
| 474 | 474 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
| 475 | 475 | |
| 476 | 476 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |