@@ -10,42 +10,42 @@ discard block |
||
| 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() { |
|
| 25 | + function load() { |
|
| 26 | 26 | |
| 27 | - if( !is_admin() ) { |
|
| 28 | - return; |
|
| 29 | - } |
|
| 27 | + if( !is_admin() ) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | 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 ); |
|
| 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 | 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 ); |
|
| 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') ); |
|
| 40 | + // add tooltips |
|
| 41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
| 42 | 42 | |
| 43 | - // custom fields' options for zone EDIT |
|
| 44 | - add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
| 43 | + // custom fields' options for zone EDIT |
|
| 44 | + add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
| 45 | 45 | |
| 46 | - // Add Edit Entry settings to View Settings |
|
| 47 | - add_action( 'gravityview/metaboxes/edit_entry', array( $this, 'view_settings_metabox' ) ); |
|
| 48 | - } |
|
| 46 | + // Add Edit Entry settings to View Settings |
|
| 47 | + add_action( 'gravityview/metaboxes/edit_entry', array( $this, 'view_settings_metabox' ) ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Render Edit Entry View metabox settings |
@@ -69,101 +69,101 @@ discard block |
||
| 69 | 69 | GravityView_Render_Settings::render_setting_row( 'edit_redirect_url', $current_settings ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
| 74 | - * @param array $entry_default_fields Existing fields |
|
| 75 | - * @param string|array $form form_ID or form object |
|
| 76 | - * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
| 77 | - */ |
|
| 78 | - function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
| 79 | - |
|
| 80 | - if( $zone !== 'edit' ) { |
|
| 81 | - |
|
| 82 | - $entry_default_fields['edit_link'] = array( |
|
| 83 | - 'label' => __('Edit Entry', 'gravityview'), |
|
| 84 | - 'type' => 'edit_link', |
|
| 85 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
| 86 | - 'icon' => 'dashicons-welcome-write-blog', |
|
| 87 | - ); |
|
| 88 | - |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return $entry_default_fields; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Change wording for the Edit context to read Entry Creator |
|
| 96 | - * |
|
| 97 | - * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
| 98 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
| 99 | - * @param string $template_id Table slug |
|
| 100 | - * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
| 101 | - * @param string $context What context are we in? Example: `single` or `directory` |
|
| 102 | - * @param string $input_type (textarea, list, select, etc.) |
|
| 103 | - * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
| 104 | - */ |
|
| 105 | - function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
| 106 | - |
|
| 107 | - $caps = $visibility_caps; |
|
| 108 | - |
|
| 109 | - // If we're configuring fields in the edit context, we want a limited selection |
|
| 110 | - if( $context === 'edit' ) { |
|
| 111 | - |
|
| 112 | - // Remove other built-in caps. |
|
| 113 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
| 114 | - |
|
| 115 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - return $caps; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Add "Edit Link Text" setting to the edit_link field settings |
|
| 123 | - * |
|
| 124 | - * @param array $field_options |
|
| 125 | - * @param string $template_id |
|
| 126 | - * @param string $field_id |
|
| 127 | - * @param string $context |
|
| 128 | - * @param string $input_type |
|
| 129 | - * |
|
| 130 | - * @return array $field_options, with "Edit Link Text" field option |
|
| 131 | - */ |
|
| 132 | - function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
| 133 | - |
|
| 134 | - // Always a link, never a filter |
|
| 135 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
| 136 | - |
|
| 137 | - // Edit Entry link should only appear to visitors capable of editing entries |
|
| 138 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 139 | - |
|
| 140 | - $add_option['edit_link'] = array( |
|
| 141 | - 'type' => 'text', |
|
| 142 | - 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
| 143 | - 'desc' => NULL, |
|
| 144 | - 'value' => __('Edit Entry', 'gravityview'), |
|
| 145 | - 'merge_tags' => true, |
|
| 146 | - ); |
|
| 147 | - |
|
| 148 | - return array_merge( $add_option, $field_options ); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Add tooltips |
|
| 153 | - * @param array $tooltips Existing tooltips |
|
| 154 | - * @return array Modified tooltips |
|
| 155 | - */ |
|
| 156 | - function tooltips( $tooltips ) { |
|
| 157 | - |
|
| 158 | - $return = $tooltips; |
|
| 159 | - |
|
| 160 | - $return['allow_edit_cap'] = array( |
|
| 161 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
| 162 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
| 163 | - ); |
|
| 164 | - |
|
| 165 | - return $return; |
|
| 166 | - } |
|
| 72 | + /** |
|
| 73 | + * Add Edit Link as a default field, outside those set in the Gravity Form form |
|
| 74 | + * @param array $entry_default_fields Existing fields |
|
| 75 | + * @param string|array $form form_ID or form object |
|
| 76 | + * @param string $zone Either 'single', 'directory', 'header', 'footer' |
|
| 77 | + */ |
|
| 78 | + function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
| 79 | + |
|
| 80 | + if( $zone !== 'edit' ) { |
|
| 81 | + |
|
| 82 | + $entry_default_fields['edit_link'] = array( |
|
| 83 | + 'label' => __('Edit Entry', 'gravityview'), |
|
| 84 | + 'type' => 'edit_link', |
|
| 85 | + 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
| 86 | + 'icon' => 'dashicons-welcome-write-blog', |
|
| 87 | + ); |
|
| 88 | + |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return $entry_default_fields; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Change wording for the Edit context to read Entry Creator |
|
| 96 | + * |
|
| 97 | + * @param array $visibility_caps Array of capabilities to display in field dropdown. |
|
| 98 | + * @param string $field_type Type of field options to render (`field` or `widget`) |
|
| 99 | + * @param string $template_id Table slug |
|
| 100 | + * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
|
| 101 | + * @param string $context What context are we in? Example: `single` or `directory` |
|
| 102 | + * @param string $input_type (textarea, list, select, etc.) |
|
| 103 | + * @return array Array of field options with `label`, `value`, `type`, `default` keys |
|
| 104 | + */ |
|
| 105 | + function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
| 106 | + |
|
| 107 | + $caps = $visibility_caps; |
|
| 108 | + |
|
| 109 | + // If we're configuring fields in the edit context, we want a limited selection |
|
| 110 | + if( $context === 'edit' ) { |
|
| 111 | + |
|
| 112 | + // Remove other built-in caps. |
|
| 113 | + unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
| 114 | + |
|
| 115 | + $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + return $caps; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Add "Edit Link Text" setting to the edit_link field settings |
|
| 123 | + * |
|
| 124 | + * @param array $field_options |
|
| 125 | + * @param string $template_id |
|
| 126 | + * @param string $field_id |
|
| 127 | + * @param string $context |
|
| 128 | + * @param string $input_type |
|
| 129 | + * |
|
| 130 | + * @return array $field_options, with "Edit Link Text" field option |
|
| 131 | + */ |
|
| 132 | + function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
| 133 | + |
|
| 134 | + // Always a link, never a filter |
|
| 135 | + unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
| 136 | + |
|
| 137 | + // Edit Entry link should only appear to visitors capable of editing entries |
|
| 138 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 139 | + |
|
| 140 | + $add_option['edit_link'] = array( |
|
| 141 | + 'type' => 'text', |
|
| 142 | + 'label' => __( 'Edit Link Text', 'gravityview' ), |
|
| 143 | + 'desc' => NULL, |
|
| 144 | + 'value' => __('Edit Entry', 'gravityview'), |
|
| 145 | + 'merge_tags' => true, |
|
| 146 | + ); |
|
| 147 | + |
|
| 148 | + return array_merge( $add_option, $field_options ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Add tooltips |
|
| 153 | + * @param array $tooltips Existing tooltips |
|
| 154 | + * @return array Modified tooltips |
|
| 155 | + */ |
|
| 156 | + function tooltips( $tooltips ) { |
|
| 157 | + |
|
| 158 | + $return = $tooltips; |
|
| 159 | + |
|
| 160 | + $return['allow_edit_cap'] = array( |
|
| 161 | + 'title' => __('Limiting Edit Access', 'gravityview'), |
|
| 162 | + 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
| 163 | + ); |
|
| 164 | + |
|
| 165 | + return $return; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Add "Edit Link Text" setting to the edit_link field settings |
@@ -179,37 +179,37 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
| 181 | 181 | |
| 182 | - // We only want to modify the settings for the edit context |
|
| 183 | - if( 'edit' !== $context ) { |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @since 1.8.4 |
|
| 187 | - */ |
|
| 188 | - $field_options['new_window'] = array( |
|
| 189 | - 'type' => 'checkbox', |
|
| 190 | - 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
|
| 191 | - 'value' => false, |
|
| 192 | - ); |
|
| 193 | - |
|
| 194 | - return $field_options; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - // Entry field is only for logged in users |
|
| 198 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 199 | - |
|
| 200 | - $add_options = array( |
|
| 201 | - 'allow_edit_cap' => array( |
|
| 202 | - 'type' => 'select', |
|
| 203 | - 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
| 204 | - 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
| 205 | - 'tooltip' => 'allow_edit_cap', |
|
| 206 | - 'class' => 'widefat', |
|
| 207 | - 'value' => 'read', // Default: entry creator |
|
| 208 | - ), |
|
| 209 | - ); |
|
| 210 | - |
|
| 211 | - return array_merge( $field_options, $add_options ); |
|
| 212 | - } |
|
| 182 | + // We only want to modify the settings for the edit context |
|
| 183 | + if( 'edit' !== $context ) { |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @since 1.8.4 |
|
| 187 | + */ |
|
| 188 | + $field_options['new_window'] = array( |
|
| 189 | + 'type' => 'checkbox', |
|
| 190 | + 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
|
| 191 | + 'value' => false, |
|
| 192 | + ); |
|
| 193 | + |
|
| 194 | + return $field_options; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + // Entry field is only for logged in users |
|
| 198 | + unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 199 | + |
|
| 200 | + $add_options = array( |
|
| 201 | + 'allow_edit_cap' => array( |
|
| 202 | + 'type' => 'select', |
|
| 203 | + 'label' => __( 'Make field editable to:', 'gravityview' ), |
|
| 204 | + 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
| 205 | + 'tooltip' => 'allow_edit_cap', |
|
| 206 | + 'class' => 'widefat', |
|
| 207 | + 'value' => 'read', // Default: entry creator |
|
| 208 | + ), |
|
| 209 | + ); |
|
| 210 | + |
|
| 211 | + return array_merge( $field_options, $add_options ); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | |
| 215 | 215 | } // end class |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
| 272 | 272 | * |
| 273 | - * @since 1.17 |
|
| 273 | + * @since 1.17 |
|
| 274 | 274 | * |
| 275 | 275 | * @see process_delete_notes |
| 276 | 276 | * |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | 'subject-label' => __( 'Subject', 'gravityview' ), |
| 424 | 424 | 'subject' => __( 'Email subject', 'gravityview' ), |
| 425 | 425 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
| 426 | - 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 426 | + 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 427 | 427 | 'also-email' => __( 'Also email this note to', 'gravityview' ), |
| 428 | 428 | 'error-add-note' => __( 'There was an error adding the note.', 'gravityview' ), |
| 429 | 429 | 'error-invalid' => __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ), |
@@ -493,11 +493,11 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | if ( $context instanceof \GV\Template_Context ) { |
| 495 | 495 | |
| 496 | - ob_start(); |
|
| 497 | - $context->template->get_template_part( 'note', 'detail', true ); |
|
| 498 | - $note_detail_html = ob_get_clean(); |
|
| 496 | + ob_start(); |
|
| 497 | + $context->template->get_template_part( 'note', 'detail', true ); |
|
| 498 | + $note_detail_html = ob_get_clean(); |
|
| 499 | 499 | |
| 500 | - ob_start(); |
|
| 500 | + ob_start(); |
|
| 501 | 501 | $context->template->get_template_part( 'note', $note_row_template, true ); |
| 502 | 502 | $note_row = ob_get_clean(); |
| 503 | 503 | } else { |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | 'gv-note-to-custom' => '', |
| 757 | 757 | 'gv-note-subject' => '', |
| 758 | 758 | 'gv-note-content' => '', |
| 759 | - 'current-url' => '', |
|
| 759 | + 'current-url' => '', |
|
| 760 | 760 | ); |
| 761 | 761 | |
| 762 | 762 | $current_user = wp_get_current_user(); |
@@ -808,9 +808,9 @@ discard block |
||
| 808 | 808 | $message .= $this->get_email_footer( $email_footer, $is_html, $email_data ); |
| 809 | 809 | |
| 810 | 810 | /** |
| 811 | - * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 811 | + * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 812 | 812 | * @since 1.18 |
| 813 | - * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 813 | + * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 814 | 814 | */ |
| 815 | 815 | $wpautop_email = apply_filters( 'gravityview/field/notes/wpautop_email', true ); |
| 816 | 816 | |
@@ -830,12 +830,12 @@ discard block |
||
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | /** |
| 833 | - * Get the footer for Entry Note emails |
|
| 834 | - * |
|
| 835 | - * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 836 | - * |
|
| 837 | - * @since 1.18 |
|
| 838 | - * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 833 | + * Get the footer for Entry Note emails |
|
| 834 | + * |
|
| 835 | + * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 836 | + * |
|
| 837 | + * @since 1.18 |
|
| 838 | + * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 839 | 839 | * |
| 840 | 840 | * @param string $email_footer The message footer value |
| 841 | 841 | * @param bool $is_html True: Email is being sent as HTML; False: sent as text |
@@ -844,10 +844,10 @@ discard block |
||
| 844 | 844 | */ |
| 845 | 845 | private function get_email_footer( $email_footer = '', $is_html = true, $email_data = array() ) { |
| 846 | 846 | |
| 847 | - $output = ''; |
|
| 847 | + $output = ''; |
|
| 848 | 848 | |
| 849 | 849 | if( ! empty( $email_footer ) ) { |
| 850 | - $url = \GV\Utils::get( $email_data, 'current-url' ); |
|
| 850 | + $url = \GV\Utils::get( $email_data, 'current-url' ); |
|
| 851 | 851 | $url = html_entity_decode( $url ); |
| 852 | 852 | $url = site_url( $url ); |
| 853 | 853 | |
@@ -196,7 +196,7 @@ |
||
| 196 | 196 | |
| 197 | 197 | $parent_label = ''; |
| 198 | 198 | |
| 199 | - if ( ! empty( $this->item['parent'] ) ) { |
|
| 199 | + if ( ! empty( $this->item['parent'] ) ) { |
|
| 200 | 200 | $parent_label = ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>'; |
| 201 | 201 | } |
| 202 | 202 | |