@@ -5,243 +5,243 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class GravityView_Change_Entry_Creator { |
| 7 | 7 | |
| 8 | - function __construct() { |
|
| 9 | - |
|
| 10 | - /** |
|
| 11 | - * @since 1.5.1 |
|
| 12 | - */ |
|
| 13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
| 14 | - |
|
| 15 | - // ONLY ADMIN FROM HERE ON. |
|
| 16 | - if( !is_admin() ) { return; } |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
| 20 | - * @since 1.7.4 |
|
| 21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
| 22 | - */ |
|
| 23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
| 24 | - return; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Use `init` to fix bbPress warning |
|
| 29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
| 30 | - */ |
|
| 31 | - add_action('init', array( $this, 'load'), 100 ); |
|
| 32 | - |
|
| 33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
| 34 | - |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
| 39 | - * |
|
| 40 | - * @since 1.5.1 |
|
| 41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
| 42 | - * @param int $user_id WordPress User ID |
|
| 43 | - * @param array $config User registration feed configuration |
|
| 44 | - * @param array $entry GF Entry array |
|
| 45 | - * @param string $password User password |
|
| 46 | - * @return void |
|
| 47 | - */ |
|
| 48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Disable assigning the new user to the entry by returning false. |
|
| 52 | - * @param int $user_id WordPress User ID |
|
| 53 | - * @param array $config User registration feed configuration |
|
| 54 | - * @param array $entry GF Entry array |
|
| 55 | - */ |
|
| 56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
| 57 | - |
|
| 58 | - // If filter returns false, do not process |
|
| 59 | - if( empty( $assign_to_lead ) ) { |
|
| 60 | - return; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
| 64 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
| 65 | - |
|
| 66 | - if ( false === $result ) { |
|
| 67 | - $status = __('Error', 'gravityview'); |
|
| 68 | - global $wpdb; |
|
| 69 | - $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
|
| 70 | - } else { |
|
| 71 | - $status = __('Success', 'gravityview'); |
|
| 72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
| 79 | - * @since 1.21.5 |
|
| 80 | - * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
| 81 | - */ |
|
| 82 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
| 87 | - |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Disable previous functionality; use this one as the canonical. |
|
| 92 | - * @return void |
|
| 93 | - */ |
|
| 94 | - function prevent_conflicts() { |
|
| 95 | - |
|
| 96 | - // Plugin that was provided here: |
|
| 97 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
| 98 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 99 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @since 3.6.3 |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - function load() { |
|
| 108 | - |
|
| 109 | - // Does GF exist? |
|
| 110 | - if( !class_exists('GFCommon') ) { |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // Can the user edit entries? |
|
| 115 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 116 | - return; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // If screen mode isn't set, then we're in the wrong place. |
|
| 120 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
| 121 | - return; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Now, no validation is required in the methods; let's hook in. |
|
| 125 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 126 | - |
|
| 127 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
| 128 | - |
|
| 129 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
| 130 | - |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
| 135 | - * @return void |
|
| 136 | - */ |
|
| 137 | - function set_screen_mode() { |
|
| 138 | - |
|
| 139 | - if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
| 140 | - return; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
| 144 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 145 | - $_POST["screen_mode"] = 'edit'; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * When the entry creator is changed, add a note to the entry |
|
| 152 | - * @param array $form GF entry array |
|
| 153 | - * @param int $entry_id Entry ID |
|
| 154 | - * @return void |
|
| 155 | - */ |
|
| 156 | - function update_entry_creator($form, $entry_id) { |
|
| 157 | - global $current_user; |
|
| 8 | + function __construct() { |
|
| 9 | + |
|
| 10 | + /** |
|
| 11 | + * @since 1.5.1 |
|
| 12 | + */ |
|
| 13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
| 14 | + |
|
| 15 | + // ONLY ADMIN FROM HERE ON. |
|
| 16 | + if( !is_admin() ) { return; } |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
| 20 | + * @since 1.7.4 |
|
| 21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
| 22 | + */ |
|
| 23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
| 24 | + return; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Use `init` to fix bbPress warning |
|
| 29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
| 30 | + */ |
|
| 31 | + add_action('init', array( $this, 'load'), 100 ); |
|
| 32 | + |
|
| 33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
| 34 | + |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
| 39 | + * |
|
| 40 | + * @since 1.5.1 |
|
| 41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
| 42 | + * @param int $user_id WordPress User ID |
|
| 43 | + * @param array $config User registration feed configuration |
|
| 44 | + * @param array $entry GF Entry array |
|
| 45 | + * @param string $password User password |
|
| 46 | + * @return void |
|
| 47 | + */ |
|
| 48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Disable assigning the new user to the entry by returning false. |
|
| 52 | + * @param int $user_id WordPress User ID |
|
| 53 | + * @param array $config User registration feed configuration |
|
| 54 | + * @param array $entry GF Entry array |
|
| 55 | + */ |
|
| 56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
| 57 | + |
|
| 58 | + // If filter returns false, do not process |
|
| 59 | + if( empty( $assign_to_lead ) ) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
| 64 | + $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
| 65 | + |
|
| 66 | + if ( false === $result ) { |
|
| 67 | + $status = __('Error', 'gravityview'); |
|
| 68 | + global $wpdb; |
|
| 69 | + $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
|
| 70 | + } else { |
|
| 71 | + $status = __('Success', 'gravityview'); |
|
| 72 | + $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
| 79 | + * @since 1.21.5 |
|
| 80 | + * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
| 81 | + */ |
|
| 82 | + if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
| 87 | + |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Disable previous functionality; use this one as the canonical. |
|
| 92 | + * @return void |
|
| 93 | + */ |
|
| 94 | + function prevent_conflicts() { |
|
| 95 | + |
|
| 96 | + // Plugin that was provided here: |
|
| 97 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
| 98 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
| 99 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @since 3.6.3 |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + function load() { |
|
| 108 | + |
|
| 109 | + // Does GF exist? |
|
| 110 | + if( !class_exists('GFCommon') ) { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // Can the user edit entries? |
|
| 115 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // If screen mode isn't set, then we're in the wrong place. |
|
| 120 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
| 121 | + return; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Now, no validation is required in the methods; let's hook in. |
|
| 125 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
| 126 | + |
|
| 127 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
| 128 | + |
|
| 129 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
| 130 | + |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
| 135 | + * @return void |
|
| 136 | + */ |
|
| 137 | + function set_screen_mode() { |
|
| 138 | + |
|
| 139 | + if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
| 144 | + if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
| 145 | + $_POST["screen_mode"] = 'edit'; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * When the entry creator is changed, add a note to the entry |
|
| 152 | + * @param array $form GF entry array |
|
| 153 | + * @param int $entry_id Entry ID |
|
| 154 | + * @return void |
|
| 155 | + */ |
|
| 156 | + function update_entry_creator($form, $entry_id) { |
|
| 157 | + global $current_user; |
|
| 158 | 158 | |
| 159 | - // Update the entry |
|
| 160 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
| 159 | + // Update the entry |
|
| 160 | + $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
| 161 | 161 | |
| 162 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
| 162 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
| 163 | 163 | |
| 164 | - // If the creator has changed, let's add a note about who it used to be. |
|
| 165 | - $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
| 164 | + // If the creator has changed, let's add a note about who it used to be. |
|
| 165 | + $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
| 166 | 166 | |
| 167 | - // If there's no owner and there didn't used to be, keep going |
|
| 168 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 169 | - return; |
|
| 170 | - } |
|
| 167 | + // If there's no owner and there didn't used to be, keep going |
|
| 168 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - // If the values have changed |
|
| 173 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 172 | + // If the values have changed |
|
| 173 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
| 174 | 174 | |
| 175 | - $user_data = get_userdata($current_user->ID); |
|
| 175 | + $user_data = get_userdata($current_user->ID); |
|
| 176 | 176 | |
| 177 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
| 177 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
| 178 | 178 | |
| 179 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
| 179 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
| 180 | 180 | |
| 181 | - if( !empty( $originally_created_by ) ) { |
|
| 182 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
| 183 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
| 184 | - } |
|
| 181 | + if( !empty( $originally_created_by ) ) { |
|
| 182 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
| 183 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - if( !empty( $created_by ) ) { |
|
| 187 | - $created_by_user_data = get_userdata($created_by); |
|
| 188 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
| 189 | - } |
|
| 186 | + if( !empty( $created_by ) ) { |
|
| 187 | + $created_by_user_data = get_userdata($created_by); |
|
| 188 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
| 192 | - } |
|
| 191 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Output the select to change the entry creator |
|
| 198 | - * @param int $form_id GF Form ID |
|
| 199 | - * @param array $entry GF entry array |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - function add_select($form_id, $entry ) { |
|
| 196 | + /** |
|
| 197 | + * Output the select to change the entry creator |
|
| 198 | + * @param int $form_id GF Form ID |
|
| 199 | + * @param array $entry GF entry array |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + function add_select($form_id, $entry ) { |
|
| 203 | 203 | |
| 204 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 205 | - return; |
|
| 206 | - } |
|
| 204 | + if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
| 208 | + $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
| 209 | 209 | |
| 210 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
| 210 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
| 211 | 211 | |
| 212 | - $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
| 212 | + $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
| 213 | 213 | |
| 214 | - // Make sure that the entry creator is included in the users list. If not, add them. |
|
| 215 | - if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
| 214 | + // Make sure that the entry creator is included in the users list. If not, add them. |
|
| 215 | + if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
| 216 | 216 | |
| 217 | - if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
| 218 | - $users = array_merge( $users, $created_by_user ); |
|
| 219 | - } |
|
| 220 | - } |
|
| 217 | + if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
| 218 | + $users = array_merge( $users, $created_by_user ); |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $output = '<label for="change_created_by">'; |
|
| 223 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
| 224 | - $output .= '</label>'; |
|
| 222 | + $output = '<label for="change_created_by">'; |
|
| 223 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
| 224 | + $output .= '</label>'; |
|
| 225 | 225 | |
| 226 | - // If there are users who are not being shown, show a warning. |
|
| 227 | - // TODO: Use AJAX instead of <select> |
|
| 228 | - $count_users = count_users(); |
|
| 229 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
| 230 | - $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
| 231 | - } |
|
| 226 | + // If there are users who are not being shown, show a warning. |
|
| 227 | + // TODO: Use AJAX instead of <select> |
|
| 228 | + $count_users = count_users(); |
|
| 229 | + if( sizeof( $users ) < $count_users['total_users'] ) { |
|
| 230 | + $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
| 234 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
| 235 | - foreach($users as $user) { |
|
| 236 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
| 237 | - } |
|
| 238 | - $output .= '</select>'; |
|
| 239 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
| 233 | + $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
| 234 | + $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
| 235 | + foreach($users as $user) { |
|
| 236 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
| 237 | + } |
|
| 238 | + $output .= '</select>'; |
|
| 239 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
| 240 | 240 | |
| 241 | - unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
| 241 | + unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
| 242 | 242 | |
| 243 | - echo $output; |
|
| 244 | - } |
|
| 243 | + echo $output; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | 246 | } |
| 247 | 247 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @return void |
| 93 | 93 | */ |
| 94 | 94 | public static function connected_form_warning( $form_id = 0 ) { |
| 95 | - global $pagenow; |
|
| 95 | + global $pagenow; |
|
| 96 | 96 | |
| 97 | 97 | if ( empty( $form_id ) || $pagenow === 'post-new.php' ) { |
| 98 | 98 | return; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | <?php |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - remove_action( 'gravityview/metaboxes/data-source/before', array( 'GravityView_Admin', 'connected_form_warning' ) ); |
|
| 122 | + remove_action( 'gravityview/metaboxes/data-source/before', array( 'GravityView_Admin', 'connected_form_warning' ) ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
| 242 | 242 | 8 => __( 'View submitted.', 'gravityview' ), |
| 243 | 243 | 9 => sprintf( |
| 244 | - /* translators: Date and time the View is scheduled to be published */ |
|
| 244 | + /* translators: Date and time the View is scheduled to be published */ |
|
| 245 | 245 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
| 246 | 246 | // translators: Publish box date format, see http://php.net/date |
| 247 | 247 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -298,7 +298,6 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @deprecated since 1.12 |
| 300 | 300 | * @see GravityView_Compatibility::get_plugin_status() |
| 301 | - |
|
| 302 | 301 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
| 303 | 302 | */ |
| 304 | 303 | static function get_plugin_status( $location = '' ) { |
@@ -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> |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
| 248 | 248 | |
| 249 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 249 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 250 | 250 | |
| 251 | 251 | if ( empty( $base ) ) { |
| 252 | 252 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | 'action' => 'duplicate', |
| 258 | 258 | 'entry_id' => $entry['id'], |
| 259 | 259 | 'gvid' => $view_id, |
| 260 | - 'view_id' => $view_id, |
|
| 260 | + 'view_id' => $view_id, |
|
| 261 | 261 | ), $base ); |
| 262 | 262 | |
| 263 | 263 | return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @since 2.5 |
| 461 | 461 | * @param array $duplicated_entry The duplicated entry |
| 462 | 462 | * @param array $entry The original entry |
| 463 | - */ |
|
| 463 | + */ |
|
| 464 | 464 | do_action( 'gravityview/duplicate-entry/duplicated', $duplicated_entry, $entry ); |
| 465 | 465 | |
| 466 | 466 | gravityview()->log->debug( 'Duplicate response: {duplicate_response}', array( 'duplicate_response' => $duplicate_response ) ); |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | <?php |
| 33 | 33 | |
| 34 | - do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
| 34 | + do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); |
|
| 35 | 35 | |
| 36 | - do_action('gravityview_render_field_pickers', 'directory' ); |
|
| 36 | + do_action('gravityview_render_field_pickers', 'directory' ); |
|
| 37 | 37 | |
| 38 | - ?> |
|
| 38 | + ?> |
|
| 39 | 39 | |
| 40 | 40 | <?php // list of available widgets to be shown in the popup ?> |
| 41 | 41 | <div id="directory-available-widgets" class="hide-if-js gv-tooltip"> |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | <div id="single-active-fields" class="gv-grid"> |
| 62 | 62 | <?php |
| 63 | - if(!empty( $curr_template ) ) { |
|
| 64 | - do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
| 65 | - } |
|
| 66 | - ?> |
|
| 63 | + if(!empty( $curr_template ) ) { |
|
| 64 | + do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
| 65 | + } |
|
| 66 | + ?> |
|
| 67 | 67 | </div> |
| 68 | 68 | <?php |
| 69 | - do_action('gravityview_render_field_pickers', 'single' ); |
|
| 69 | + do_action('gravityview_render_field_pickers', 'single' ); |
|
| 70 | 70 | ?> |
| 71 | 71 | </div> |
| 72 | 72 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | </div> |
| 86 | 86 | |
| 87 | 87 | <?php |
| 88 | - do_action('gravityview_render_field_pickers', 'edit' ); |
|
| 88 | + do_action('gravityview_render_field_pickers', 'edit' ); |
|
| 89 | 89 | ?> |
| 90 | 90 | |
| 91 | 91 | </div> |
@@ -63,28 +63,28 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
| 67 | - * |
|
| 66 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
| 67 | + * |
|
| 68 | 68 | * @param array $localization_data Data to be passed to the Support Port JS |
| 69 | 69 | * |
| 70 | 70 | * @return array |
| 71 | 71 | */ |
| 72 | 72 | function suggest_support_articles( $localization_data = array() ) { |
| 73 | 73 | |
| 74 | - if( ! gravityview()->request->is_view() ) { |
|
| 75 | - return $localization_data; |
|
| 76 | - } |
|
| 74 | + if( ! gravityview()->request->is_view() ) { |
|
| 75 | + return $localization_data; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | $localization_data['suggest'] = array( |
| 79 | - '57ef23539033602e61d4a560', |
|
| 80 | - '54c67bb9e4b0512429885513', |
|
| 81 | - '54c67bb9e4b0512429885512', |
|
| 82 | - '54c67bbbe4b07997ea3f3f6b', |
|
| 83 | - '54d1a33ae4b086c0c0964ce9', |
|
| 84 | - '57ef253c9033602e61d4a563', |
|
| 85 | - '552355bfe4b0221aadf2572b', |
|
| 86 | - '54c67bcde4b051242988553e', |
|
| 87 | - ); |
|
| 79 | + '57ef23539033602e61d4a560', |
|
| 80 | + '54c67bb9e4b0512429885513', |
|
| 81 | + '54c67bb9e4b0512429885512', |
|
| 82 | + '54c67bbbe4b07997ea3f3f6b', |
|
| 83 | + '54d1a33ae4b086c0c0964ce9', |
|
| 84 | + '57ef253c9033602e61d4a563', |
|
| 85 | + '552355bfe4b0221aadf2572b', |
|
| 86 | + '54c67bcde4b051242988553e', |
|
| 87 | + ); |
|
| 88 | 88 | |
| 89 | 89 | return $localization_data; |
| 90 | 90 | } |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | if( 'form_list' === GFForms::get_page() ) { |
| 177 | 177 | $priority = 790; |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | if( empty( $connected_views ) ) { |
| 181 | 181 | |
| 182 | - $menu_items['gravityview'] = array( |
|
| 182 | + $menu_items['gravityview'] = array( |
|
| 183 | 183 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
| 184 | 184 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 185 | 185 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | // If there were no items added, then let's create the parent menu |
| 211 | 211 | if( $sub_menu_items ) { |
| 212 | 212 | |
| 213 | - $sub_menu_items[] = array( |
|
| 214 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 215 | - 'link_class' => 'gv-create-view', |
|
| 216 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 217 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 218 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 219 | - ); |
|
| 213 | + $sub_menu_items[] = array( |
|
| 214 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 215 | + 'link_class' => 'gv-create-view', |
|
| 216 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 217 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 218 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
| 219 | + ); |
|
| 220 | 220 | |
| 221 | 221 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
| 222 | 222 | $sub_menu_items[] = array( |
@@ -599,17 +599,17 @@ discard block |
||
| 599 | 599 | * Render html for displaying available fields based on a Form ID |
| 600 | 600 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
| 601 | 601 | * |
| 602 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 602 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 603 | 603 | * @access public |
| 604 | - * |
|
| 604 | + * |
|
| 605 | 605 | * @param int $form Gravity Forms Form ID (default: '') |
| 606 | 606 | * @param string $context (default: 'single') |
| 607 | - * |
|
| 607 | + * |
|
| 608 | 608 | * @return void |
| 609 | 609 | */ |
| 610 | 610 | function render_available_fields( $form = 0, $context = 'single' ) { |
| 611 | 611 | |
| 612 | - // Determine if form is a preset and convert it to an array with fields |
|
| 612 | + // Determine if form is a preset and convert it to an array with fields |
|
| 613 | 613 | $form = ( is_string( $form ) && preg_match( '/^preset_/', $form ) ) ? GravityView_Ajax::pre_get_form_fields( $form ) : $form; |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | |
| 622 | 622 | if ( ! is_array( $blacklist_field_types ) ) { |
| 623 | 623 | |
| 624 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 624 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
| 625 | 625 | |
| 626 | 626 | $blacklist_field_types = array(); |
| 627 | 627 | } |
@@ -753,12 +753,12 @@ discard block |
||
| 753 | 753 | /** |
| 754 | 754 | * @since 1.7.2 |
| 755 | 755 | */ |
| 756 | - 'other_entries' => array( |
|
| 757 | - 'label' => __('Other Entries', 'gravityview'), |
|
| 758 | - 'type' => 'other_entries', |
|
| 759 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 760 | - ), |
|
| 761 | - ); |
|
| 756 | + 'other_entries' => array( |
|
| 757 | + 'label' => __('Other Entries', 'gravityview'), |
|
| 758 | + 'type' => 'other_entries', |
|
| 759 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 760 | + ), |
|
| 761 | + ); |
|
| 762 | 762 | |
| 763 | 763 | if( 'single' !== $zone) { |
| 764 | 764 | |
@@ -906,9 +906,9 @@ discard block |
||
| 906 | 906 | |
| 907 | 907 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
| 908 | 908 | |
| 909 | - foreach ( $joined_forms as $form ) { |
|
| 910 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
| 911 | - } |
|
| 909 | + foreach ( $joined_forms as $form ) { |
|
| 910 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
| 911 | + } |
|
| 912 | 912 | } else { |
| 913 | 913 | $available_items[ $form ] = \GV\Widget::registered(); |
| 914 | 914 | } |
@@ -936,9 +936,9 @@ discard block |
||
| 936 | 936 | |
| 937 | 937 | if ( $form_id ) { |
| 938 | 938 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
| 939 | - } else { |
|
| 939 | + } else { |
|
| 940 | 940 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
| 941 | - } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | 943 | if ( !$original_item ) { |
| 944 | 944 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | |
| 991 | 991 | /** |
| 992 | 992 | * Render the widget active areas |
| 993 | - * @param string $template_id The current slug of the selected View template |
|
| 993 | + * @param string $template_id The current slug of the selected View template |
|
| 994 | 994 | * @param string $zone Either 'header' or 'footer' |
| 995 | 995 | * @param string $post_id Current Post ID (view) |
| 996 | 996 | * @return string html |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | $is_widgets_page = ( $pagenow === 'widgets.php' ); |
| 1175 | 1175 | |
| 1176 | 1176 | // Add the GV font (with the Astronaut) |
| 1177 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
| 1177 | + wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
| 1178 | 1178 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
| 1179 | 1179 | |
| 1180 | 1180 | wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
@@ -1182,66 +1182,66 @@ discard block |
||
| 1182 | 1182 | if( GFForms::get_page() === 'form_list' ) { |
| 1183 | 1183 | wp_enqueue_style( 'gravityview_views_styles' ); |
| 1184 | 1184 | return; |
| 1185 | - } |
|
| 1185 | + } |
|
| 1186 | 1186 | |
| 1187 | 1187 | // Don't process any scripts below here if it's not a GravityView page. |
| 1188 | 1188 | if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
| 1189 | - return; |
|
| 1189 | + return; |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1193 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
| 1194 | - |
|
| 1195 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1196 | - |
|
| 1197 | - //enqueue scripts |
|
| 1198 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
| 1199 | - |
|
| 1200 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1201 | - 'cookiepath' => COOKIEPATH, |
|
| 1202 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1203 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1204 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1205 | - 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
| 1206 | - 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
| 1207 | - 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
| 1208 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1209 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1210 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1211 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1212 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1213 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1214 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1215 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1216 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1217 | - )); |
|
| 1192 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1193 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
| 1194 | + |
|
| 1195 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1196 | + |
|
| 1197 | + //enqueue scripts |
|
| 1198 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
|
| 1199 | + |
|
| 1200 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1201 | + 'cookiepath' => COOKIEPATH, |
|
| 1202 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
| 1203 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1204 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1205 | + 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
|
| 1206 | + 'label_add_search_field' => __( 'Add Search Field', 'gravityview' ), |
|
| 1207 | + 'label_remove_search_field' => __( 'Remove Search Field', 'gravityview' ), |
|
| 1208 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1209 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1210 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1211 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1212 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1213 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1214 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1215 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1216 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1217 | + )); |
|
| 1218 | 1218 | |
| 1219 | 1219 | wp_enqueue_style( 'gravityview_views_styles' ); |
| 1220 | 1220 | |
| 1221 | - // Enqueue scripts needed for merge tags |
|
| 1222 | - self::enqueue_gravity_forms_scripts(); |
|
| 1221 | + // Enqueue scripts needed for merge tags |
|
| 1222 | + self::enqueue_gravity_forms_scripts(); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | /** |
| 1226 | 1226 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
| 1227 | - * |
|
| 1228 | - * @since 1.0.5-beta |
|
| 1229 | - * |
|
| 1230 | - * @return void |
|
| 1227 | + * |
|
| 1228 | + * @since 1.0.5-beta |
|
| 1229 | + * |
|
| 1230 | + * @return void |
|
| 1231 | 1231 | */ |
| 1232 | 1232 | static function enqueue_gravity_forms_scripts() { |
| 1233 | 1233 | GFForms::register_scripts(); |
| 1234 | 1234 | |
| 1235 | 1235 | $scripts = array( |
| 1236 | - 'sack', |
|
| 1237 | - 'gform_gravityforms', |
|
| 1238 | - 'gform_forms', |
|
| 1239 | - 'gform_form_admin', |
|
| 1240 | - 'jquery-ui-autocomplete' |
|
| 1236 | + 'sack', |
|
| 1237 | + 'gform_gravityforms', |
|
| 1238 | + 'gform_forms', |
|
| 1239 | + 'gform_form_admin', |
|
| 1240 | + 'jquery-ui-autocomplete' |
|
| 1241 | 1241 | ); |
| 1242 | 1242 | |
| 1243 | 1243 | if ( wp_is_mobile() ) { |
| 1244 | - $scripts[] = 'jquery-touch-punch'; |
|
| 1244 | + $scripts[] = 'jquery-touch-punch'; |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | wp_enqueue_script( $scripts ); |
@@ -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 | 105 | * |
| 108 | - * @var int |
|
| 106 | + * @since 2.0.13 |
|
| 107 | + * |
|
| 108 | + * @var int |
|
| 109 | 109 | */ |
| 110 | 110 | public $post_id; |
| 111 | 111 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function prevent_maybe_process_form() { |
| 191 | 191 | |
| 192 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | + if( ! $this->is_edit_entry_submission() ) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | * When Edit entry view is requested setup the vars |
| 229 | 229 | */ |
| 230 | 230 | private function setup_vars() { |
| 231 | - global $post; |
|
| 231 | + global $post; |
|
| 232 | 232 | |
| 233 | 233 | $gravityview_view = GravityView_View::getInstance(); |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | $entries = $gravityview_view->getEntries(); |
| 237 | - self::$original_entry = $entries[0]; |
|
| 238 | - $this->entry = $entries[0]; |
|
| 237 | + self::$original_entry = $entries[0]; |
|
| 238 | + $this->entry = $entries[0]; |
|
| 239 | 239 | |
| 240 | 240 | self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
| 241 | 241 | $this->form = $gravityview_view->getForm(); |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | GFFormsModel::save_lead( $form, $this->entry ); |
| 379 | 379 | |
| 380 | - // Delete the values for hidden inputs |
|
| 381 | - $this->unset_hidden_field_values(); |
|
| 380 | + // Delete the values for hidden inputs |
|
| 381 | + $this->unset_hidden_field_values(); |
|
| 382 | 382 | |
| 383 | 383 | $this->entry['date_created'] = $date_created; |
| 384 | 384 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | // Perform actions normally performed after updating a lead |
| 392 | 392 | $this->after_update(); |
| 393 | 393 | |
| 394 | - /** |
|
| 394 | + /** |
|
| 395 | 395 | * Must be AFTER after_update()! |
| 396 | 396 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 397 | 397 | */ |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 402 | - * @since 2.1 Added $gv_data parameter |
|
| 402 | + * @since 2.1 Added $gv_data parameter |
|
| 403 | 403 | * @param array $form Gravity Forms form array |
| 404 | 404 | * @param string $entry_id Numeric ID of the entry that was updated |
| 405 | 405 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | * @return void |
| 424 | 424 | */ |
| 425 | 425 | private function unset_hidden_field_values() { |
| 426 | - global $wpdb; |
|
| 426 | + global $wpdb; |
|
| 427 | 427 | |
| 428 | 428 | /** |
| 429 | 429 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 450 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 451 | 451 | |
| 452 | 452 | if ( ! is_numeric( $input_id ) ) { |
| 453 | 453 | continue; |
@@ -457,8 +457,8 @@ discard block |
||
| 457 | 457 | continue; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - // Reset fields that are or would be hidden |
|
| 461 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 460 | + // Reset fields that are or would be hidden |
|
| 461 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), $this->entry ) ) { |
|
| 462 | 462 | |
| 463 | 463 | $empty_value = $field->get_value_save_entry( |
| 464 | 464 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | $empty_value = ''; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 473 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 474 | 474 | |
| 475 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 475 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 476 | 476 | |
| 477 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 477 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 478 | 478 | // after submission |
| 479 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 480 | - $_POST[ $post_input_id ] = ''; |
|
| 481 | - } |
|
| 482 | - } |
|
| 479 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 480 | + $_POST[ $post_input_id ] = ''; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | /** |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | $form = $this->filter_conditional_logic( $this->form ); |
| 636 | 636 | |
| 637 | - /** @var GF_Field $field */ |
|
| 637 | + /** @var GF_Field $field */ |
|
| 638 | 638 | foreach( $form['fields'] as $k => &$field ) { |
| 639 | 639 | |
| 640 | 640 | /** |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 652 | 652 | foreach( $field->inputs as $key => $input ) { |
| 653 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 653 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | } |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | |
| 691 | 691 | $inputs = $field->get_entry_inputs(); |
| 692 | 692 | if ( is_array( $inputs ) ) { |
| 693 | - foreach ( $inputs as $input ) { |
|
| 693 | + foreach ( $inputs as $input ) { |
|
| 694 | 694 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 695 | 695 | |
| 696 | 696 | if ( 'product' === $field->type ) { |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | } else { |
| 714 | 714 | // Set to what it previously was if it's not editable |
| 715 | 715 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 756 | 756 | |
| 757 | 757 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 758 | - $ary = stripslashes_deep( $ary ); |
|
| 758 | + $ary = stripslashes_deep( $ary ); |
|
| 759 | 759 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 760 | 760 | |
| 761 | 761 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | private function maybe_update_post_fields( $form ) { |
| 829 | 829 | |
| 830 | 830 | if( empty( $this->entry['post_id'] ) ) { |
| 831 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 831 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 832 | 832 | return; |
| 833 | 833 | } |
| 834 | 834 | |
@@ -863,49 +863,49 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | switch( $field->type ) { |
| 865 | 865 | |
| 866 | - case 'post_title': |
|
| 867 | - $post_title = $value; |
|
| 868 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 869 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 870 | - } |
|
| 871 | - $updated_post->post_title = $post_title; |
|
| 872 | - $updated_post->post_name = $post_title; |
|
| 873 | - unset( $post_title ); |
|
| 874 | - break; |
|
| 875 | - |
|
| 876 | - case 'post_content': |
|
| 877 | - $post_content = $value; |
|
| 878 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 879 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 880 | - } |
|
| 881 | - $updated_post->post_content = $post_content; |
|
| 882 | - unset( $post_content ); |
|
| 883 | - break; |
|
| 884 | - case 'post_excerpt': |
|
| 885 | - $updated_post->post_excerpt = $value; |
|
| 886 | - break; |
|
| 887 | - case 'post_tags': |
|
| 888 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 889 | - break; |
|
| 890 | - case 'post_category': |
|
| 891 | - break; |
|
| 892 | - case 'post_custom_field': |
|
| 866 | + case 'post_title': |
|
| 867 | + $post_title = $value; |
|
| 868 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 869 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 870 | + } |
|
| 871 | + $updated_post->post_title = $post_title; |
|
| 872 | + $updated_post->post_name = $post_title; |
|
| 873 | + unset( $post_title ); |
|
| 874 | + break; |
|
| 875 | + |
|
| 876 | + case 'post_content': |
|
| 877 | + $post_content = $value; |
|
| 878 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 879 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 880 | + } |
|
| 881 | + $updated_post->post_content = $post_content; |
|
| 882 | + unset( $post_content ); |
|
| 883 | + break; |
|
| 884 | + case 'post_excerpt': |
|
| 885 | + $updated_post->post_excerpt = $value; |
|
| 886 | + break; |
|
| 887 | + case 'post_tags': |
|
| 888 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 889 | + break; |
|
| 890 | + case 'post_category': |
|
| 891 | + break; |
|
| 892 | + case 'post_custom_field': |
|
| 893 | 893 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 894 | 894 | $value = $value[ $field_id ]; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 898 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 899 | - } |
|
| 897 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 898 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 899 | + } |
|
| 900 | 900 | |
| 901 | 901 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 902 | 902 | |
| 903 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 904 | - break; |
|
| 903 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 904 | + break; |
|
| 905 | 905 | |
| 906 | - case 'post_image': |
|
| 907 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 908 | - break; |
|
| 906 | + case 'post_image': |
|
| 907 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 908 | + break; |
|
| 909 | 909 | |
| 910 | 910 | } |
| 911 | 911 | |
@@ -1075,14 +1075,14 @@ discard block |
||
| 1075 | 1075 | ?><h2 class="gv-edit-entry-title"> |
| 1076 | 1076 | <span><?php |
| 1077 | 1077 | |
| 1078 | - /** |
|
| 1079 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 1080 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 1081 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 1082 | - */ |
|
| 1083 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1078 | + /** |
|
| 1079 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 1080 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 1081 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 1082 | + */ |
|
| 1083 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1084 | 1084 | |
| 1085 | - echo esc_attr( $edit_entry_title ); |
|
| 1085 | + echo esc_attr( $edit_entry_title ); |
|
| 1086 | 1086 | ?></span> |
| 1087 | 1087 | </h2> |
| 1088 | 1088 | |
@@ -1137,13 +1137,13 @@ discard block |
||
| 1137 | 1137 | ); |
| 1138 | 1138 | |
| 1139 | 1139 | /** |
| 1140 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1141 | - * @since 1.16.3 |
|
| 1142 | - * @param array $labels Default button labels associative array |
|
| 1143 | - * @param array $form The Gravity Forms form |
|
| 1144 | - * @param array $entry The Gravity Forms entry |
|
| 1145 | - * @param int $view_id The current View ID |
|
| 1146 | - */ |
|
| 1140 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1141 | + * @since 1.16.3 |
|
| 1142 | + * @param array $labels Default button labels associative array |
|
| 1143 | + * @param array $form The Gravity Forms form |
|
| 1144 | + * @param array $entry The Gravity Forms entry |
|
| 1145 | + * @param int $view_id The current View ID |
|
| 1146 | + */ |
|
| 1147 | 1147 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1148 | 1148 | |
| 1149 | 1149 | $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
@@ -1180,26 +1180,26 @@ discard block |
||
| 1180 | 1180 | |
| 1181 | 1181 | switch ( $edit_redirect ) { |
| 1182 | 1182 | |
| 1183 | - case '0': |
|
| 1184 | - $redirect_url = $back_link; |
|
| 1185 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1186 | - break; |
|
| 1187 | - |
|
| 1188 | - case '1': |
|
| 1189 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1190 | - $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>' ); |
|
| 1191 | - break; |
|
| 1192 | - |
|
| 1193 | - case '2': |
|
| 1194 | - $redirect_url = $edit_redirect_url; |
|
| 1195 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1196 | - $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>' ); |
|
| 1197 | - break; |
|
| 1198 | - |
|
| 1199 | - case '': |
|
| 1200 | - default: |
|
| 1201 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1202 | - break; |
|
| 1183 | + case '0': |
|
| 1184 | + $redirect_url = $back_link; |
|
| 1185 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1186 | + break; |
|
| 1187 | + |
|
| 1188 | + case '1': |
|
| 1189 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1190 | + $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>' ); |
|
| 1191 | + break; |
|
| 1192 | + |
|
| 1193 | + case '2': |
|
| 1194 | + $redirect_url = $edit_redirect_url; |
|
| 1195 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1196 | + $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>' ); |
|
| 1197 | + break; |
|
| 1198 | + |
|
| 1199 | + case '': |
|
| 1200 | + default: |
|
| 1201 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1202 | + break; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | if ( isset( $redirect_url ) ) { |
@@ -1265,13 +1265,13 @@ discard block |
||
| 1265 | 1265 | ); |
| 1266 | 1266 | |
| 1267 | 1267 | /** |
| 1268 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1269 | - * @since 1.16.3 |
|
| 1270 | - * @param array $labels Default button labels associative array |
|
| 1271 | - * @param array $form The Gravity Forms form |
|
| 1272 | - * @param array $entry The Gravity Forms entry |
|
| 1273 | - * @param int $view_id The current View ID |
|
| 1274 | - */ |
|
| 1268 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1269 | + * @since 1.16.3 |
|
| 1270 | + * @param array $labels Default button labels associative array |
|
| 1271 | + * @param array $form The Gravity Forms form |
|
| 1272 | + * @param array $entry The Gravity Forms entry |
|
| 1273 | + * @param int $view_id The current View ID |
|
| 1274 | + */ |
|
| 1275 | 1275 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1276 | 1276 | |
| 1277 | 1277 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1317,7 +1317,7 @@ discard block |
||
| 1317 | 1317 | |
| 1318 | 1318 | ob_get_clean(); |
| 1319 | 1319 | |
| 1320 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1320 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1321 | 1321 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1322 | 1322 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1323 | 1323 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | |
| 1378 | 1378 | // for now we don't support Save and Continue feature. |
| 1379 | 1379 | if( ! self::$supports_save_and_continue ) { |
| 1380 | - unset( $form['save'] ); |
|
| 1380 | + unset( $form['save'] ); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | $form = $this->unselect_default_values( $form ); |
@@ -1404,30 +1404,30 @@ discard block |
||
| 1404 | 1404 | return $field_content; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | - $message = null; |
|
| 1407 | + $message = null; |
|
| 1408 | 1408 | |
| 1409 | - // First, make sure they have the capability to edit the post. |
|
| 1410 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1409 | + // First, make sure they have the capability to edit the post. |
|
| 1410 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1411 | 1411 | |
| 1412 | - /** |
|
| 1413 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1414 | - * @param string $message The existing "You don't have permission..." text |
|
| 1415 | - */ |
|
| 1416 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1412 | + /** |
|
| 1413 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1414 | + * @param string $message The existing "You don't have permission..." text |
|
| 1415 | + */ |
|
| 1416 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1417 | 1417 | |
| 1418 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1419 | - /** |
|
| 1420 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1421 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1422 | - */ |
|
| 1423 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1424 | - } |
|
| 1418 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1419 | + /** |
|
| 1420 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1421 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1422 | + */ |
|
| 1423 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - if( $message ) { |
|
| 1427 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1428 | - } |
|
| 1426 | + if( $message ) { |
|
| 1427 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1428 | + } |
|
| 1429 | 1429 | |
| 1430 | - return $field_content; |
|
| 1430 | + return $field_content; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1455,7 +1455,7 @@ discard block |
||
| 1455 | 1455 | || ! empty( $field_content ) |
| 1456 | 1456 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1457 | 1457 | ) { |
| 1458 | - return $field_content; |
|
| 1458 | + return $field_content; |
|
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | 1461 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1463,24 +1463,24 @@ discard block |
||
| 1463 | 1463 | |
| 1464 | 1464 | $field_value = $this->get_field_value( $field ); |
| 1465 | 1465 | |
| 1466 | - // Prevent any PHP warnings, like undefined index |
|
| 1467 | - ob_start(); |
|
| 1466 | + // Prevent any PHP warnings, like undefined index |
|
| 1467 | + ob_start(); |
|
| 1468 | 1468 | |
| 1469 | - $return = null; |
|
| 1469 | + $return = null; |
|
| 1470 | 1470 | |
| 1471 | 1471 | /** @var GravityView_Field $gv_field */ |
| 1472 | 1472 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1473 | 1473 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1474 | 1474 | } else { |
| 1475 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1476 | - } |
|
| 1475 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1476 | + } |
|
| 1477 | 1477 | |
| 1478 | - // If there was output, it's an error |
|
| 1479 | - $warnings = ob_get_clean(); |
|
| 1478 | + // If there was output, it's an error |
|
| 1479 | + $warnings = ob_get_clean(); |
|
| 1480 | 1480 | |
| 1481 | - if( !empty( $warnings ) ) { |
|
| 1482 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1483 | - } |
|
| 1481 | + if( !empty( $warnings ) ) { |
|
| 1482 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1483 | + } |
|
| 1484 | 1484 | |
| 1485 | 1485 | return $return; |
| 1486 | 1486 | } |
@@ -1515,8 +1515,8 @@ discard block |
||
| 1515 | 1515 | $input_id = strval( $input['id'] ); |
| 1516 | 1516 | |
| 1517 | 1517 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1518 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1519 | - $allow_pre_populated = false; |
|
| 1518 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1519 | + $allow_pre_populated = false; |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | } |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1541 | 1541 | $categories = array(); |
| 1542 | 1542 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1543 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1543 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1544 | 1544 | } |
| 1545 | 1545 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1546 | 1546 | } |
@@ -1550,25 +1550,25 @@ discard block |
||
| 1550 | 1550 | // if value is empty get the default value if defined |
| 1551 | 1551 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1552 | 1552 | |
| 1553 | - /** |
|
| 1554 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1555 | - * @since 1.11 |
|
| 1556 | - * @since 1.20 Added third param |
|
| 1557 | - * @param mixed $field_value field value used to populate the input |
|
| 1558 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1559 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1560 | - */ |
|
| 1561 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1562 | - |
|
| 1563 | - /** |
|
| 1564 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1565 | - * @since 1.17 |
|
| 1566 | - * @since 1.20 Added third param |
|
| 1567 | - * @param mixed $field_value field value used to populate the input |
|
| 1568 | - * @param GF_Field $field Gravity Forms field object |
|
| 1569 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1570 | - */ |
|
| 1571 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1553 | + /** |
|
| 1554 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1555 | + * @since 1.11 |
|
| 1556 | + * @since 1.20 Added third param |
|
| 1557 | + * @param mixed $field_value field value used to populate the input |
|
| 1558 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1559 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1560 | + */ |
|
| 1561 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1562 | + |
|
| 1563 | + /** |
|
| 1564 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1565 | + * @since 1.17 |
|
| 1566 | + * @since 1.20 Added third param |
|
| 1567 | + * @param mixed $field_value field value used to populate the input |
|
| 1568 | + * @param GF_Field $field Gravity Forms field object |
|
| 1569 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1570 | + */ |
|
| 1571 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1572 | 1572 | |
| 1573 | 1573 | return $field_value; |
| 1574 | 1574 | } |
@@ -1595,7 +1595,7 @@ discard block |
||
| 1595 | 1595 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1596 | 1596 | // expects certain field array items to be set. |
| 1597 | 1597 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1598 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1598 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1609,61 +1609,61 @@ discard block |
||
| 1609 | 1609 | */ |
| 1610 | 1610 | case 'fileupload': |
| 1611 | 1611 | |
| 1612 | - // Set the previous value |
|
| 1613 | - $entry = $this->get_entry(); |
|
| 1612 | + // Set the previous value |
|
| 1613 | + $entry = $this->get_entry(); |
|
| 1614 | 1614 | |
| 1615 | - $input_name = 'input_'.$field->id; |
|
| 1616 | - $form_id = $form['id']; |
|
| 1615 | + $input_name = 'input_'.$field->id; |
|
| 1616 | + $form_id = $form['id']; |
|
| 1617 | 1617 | |
| 1618 | - $value = NULL; |
|
| 1618 | + $value = NULL; |
|
| 1619 | 1619 | |
| 1620 | - // Use the previous entry value as the default. |
|
| 1621 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1622 | - $value = $entry[ $field->id ]; |
|
| 1623 | - } |
|
| 1620 | + // Use the previous entry value as the default. |
|
| 1621 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1622 | + $value = $entry[ $field->id ]; |
|
| 1623 | + } |
|
| 1624 | 1624 | |
| 1625 | - // If this is a single upload file |
|
| 1626 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1627 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1628 | - $value = $file_path['url']; |
|
| 1625 | + // If this is a single upload file |
|
| 1626 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1627 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1628 | + $value = $file_path['url']; |
|
| 1629 | 1629 | |
| 1630 | - } else { |
|
| 1630 | + } else { |
|
| 1631 | 1631 | |
| 1632 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1633 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1634 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1632 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1633 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1634 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1635 | 1635 | |
| 1636 | - } |
|
| 1636 | + } |
|
| 1637 | 1637 | |
| 1638 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1638 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1639 | 1639 | |
| 1640 | - // If there are fresh uploads, process and merge them. |
|
| 1641 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1642 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1643 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1644 | - $value = stripslashes_deep( $value ); |
|
| 1645 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1646 | - } |
|
| 1640 | + // If there are fresh uploads, process and merge them. |
|
| 1641 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1642 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1643 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1644 | + $value = stripslashes_deep( $value ); |
|
| 1645 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1646 | + } |
|
| 1647 | 1647 | |
| 1648 | - } else { |
|
| 1648 | + } else { |
|
| 1649 | 1649 | |
| 1650 | - // A file already exists when editing an entry |
|
| 1651 | - // We set this to solve issue when file upload fields are required. |
|
| 1652 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1650 | + // A file already exists when editing an entry |
|
| 1651 | + // We set this to solve issue when file upload fields are required. |
|
| 1652 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1653 | 1653 | |
| 1654 | - } |
|
| 1654 | + } |
|
| 1655 | 1655 | |
| 1656 | - $this->entry[ $input_name ] = $value; |
|
| 1657 | - $_POST[ $input_name ] = $value; |
|
| 1656 | + $this->entry[ $input_name ] = $value; |
|
| 1657 | + $_POST[ $input_name ] = $value; |
|
| 1658 | 1658 | |
| 1659 | - break; |
|
| 1659 | + break; |
|
| 1660 | 1660 | |
| 1661 | 1661 | case 'number': |
| 1662 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1663 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1664 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1665 | - } |
|
| 1666 | - break; |
|
| 1662 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1663 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1664 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1665 | + } |
|
| 1666 | + break; |
|
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | } |
@@ -1748,43 +1748,43 @@ discard block |
||
| 1748 | 1748 | case 'fileupload' : |
| 1749 | 1749 | case 'post_image': |
| 1750 | 1750 | |
| 1751 | - // in case nothing is uploaded but there are already files saved |
|
| 1752 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1753 | - $field->failed_validation = false; |
|
| 1754 | - unset( $field->validation_message ); |
|
| 1755 | - } |
|
| 1751 | + // in case nothing is uploaded but there are already files saved |
|
| 1752 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1753 | + $field->failed_validation = false; |
|
| 1754 | + unset( $field->validation_message ); |
|
| 1755 | + } |
|
| 1756 | 1756 | |
| 1757 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1758 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1757 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1758 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1759 | 1759 | |
| 1760 | - $input_name = 'input_' . $field->id; |
|
| 1761 | - //uploaded |
|
| 1762 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1760 | + $input_name = 'input_' . $field->id; |
|
| 1761 | + //uploaded |
|
| 1762 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1763 | 1763 | |
| 1764 | - //existent |
|
| 1765 | - $entry = $this->get_entry(); |
|
| 1766 | - $value = NULL; |
|
| 1767 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1768 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1769 | - } |
|
| 1764 | + //existent |
|
| 1765 | + $entry = $this->get_entry(); |
|
| 1766 | + $value = NULL; |
|
| 1767 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1768 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1769 | + } |
|
| 1770 | 1770 | |
| 1771 | - // count uploaded files and existent entry files |
|
| 1772 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1773 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1771 | + // count uploaded files and existent entry files |
|
| 1772 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1773 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1774 | 1774 | |
| 1775 | - if( $count_files > $field->maxFiles ) { |
|
| 1776 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1777 | - $field->failed_validation = 1; |
|
| 1778 | - $gv_valid = false; |
|
| 1775 | + if( $count_files > $field->maxFiles ) { |
|
| 1776 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1777 | + $field->failed_validation = 1; |
|
| 1778 | + $gv_valid = false; |
|
| 1779 | 1779 | |
| 1780 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1781 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1782 | - } |
|
| 1780 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1781 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1782 | + } |
|
| 1783 | 1783 | |
| 1784 | - } |
|
| 1784 | + } |
|
| 1785 | 1785 | |
| 1786 | 1786 | |
| 1787 | - break; |
|
| 1787 | + break; |
|
| 1788 | 1788 | |
| 1789 | 1789 | } |
| 1790 | 1790 | |
@@ -1795,47 +1795,47 @@ discard block |
||
| 1795 | 1795 | |
| 1796 | 1796 | switch ( $field_type ) { |
| 1797 | 1797 | |
| 1798 | - // Captchas don't need to be re-entered. |
|
| 1799 | - case 'captcha': |
|
| 1798 | + // Captchas don't need to be re-entered. |
|
| 1799 | + case 'captcha': |
|
| 1800 | 1800 | |
| 1801 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1802 | - case 'post_image': |
|
| 1803 | - $field->failed_validation = false; |
|
| 1804 | - unset( $field->validation_message ); |
|
| 1805 | - break; |
|
| 1801 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1802 | + case 'post_image': |
|
| 1803 | + $field->failed_validation = false; |
|
| 1804 | + unset( $field->validation_message ); |
|
| 1805 | + break; |
|
| 1806 | 1806 | |
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | // You can't continue inside a switch, so we do it after. |
| 1810 | 1810 | if( empty( $field->failed_validation ) ) { |
| 1811 | - continue; |
|
| 1811 | + continue; |
|
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1815 | 1815 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1816 | 1816 | if( !empty( $field->noDuplicates ) ) { |
| 1817 | 1817 | |
| 1818 | - $entry = $this->get_entry(); |
|
| 1818 | + $entry = $this->get_entry(); |
|
| 1819 | 1819 | |
| 1820 | - // If the value of the entry is the same as the stored value |
|
| 1821 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1822 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1823 | - //if value submitted was not changed, then don't validate |
|
| 1824 | - $field->failed_validation = false; |
|
| 1820 | + // If the value of the entry is the same as the stored value |
|
| 1821 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1822 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1823 | + //if value submitted was not changed, then don't validate |
|
| 1824 | + $field->failed_validation = false; |
|
| 1825 | 1825 | |
| 1826 | - unset( $field->validation_message ); |
|
| 1826 | + unset( $field->validation_message ); |
|
| 1827 | 1827 | |
| 1828 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1828 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1829 | 1829 | |
| 1830 | - continue; |
|
| 1831 | - } |
|
| 1830 | + continue; |
|
| 1831 | + } |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1835 | 1835 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1836 | - unset( $field->validation_message ); |
|
| 1837 | - $field->validation_message = false; |
|
| 1838 | - continue; |
|
| 1836 | + unset( $field->validation_message ); |
|
| 1837 | + $field->validation_message = false; |
|
| 1838 | + continue; |
|
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | $gv_valid = false; |
@@ -1899,8 +1899,8 @@ discard block |
||
| 1899 | 1899 | // Hide fields depending on admin settings |
| 1900 | 1900 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1901 | 1901 | |
| 1902 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1903 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1902 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1903 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1904 | 1904 | |
| 1905 | 1905 | /** |
| 1906 | 1906 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1991,11 +1991,11 @@ discard block |
||
| 1991 | 1991 | // The edit tab has been configured, so we loop through to configured settings |
| 1992 | 1992 | foreach ( $configured_fields as $configured_field ) { |
| 1993 | 1993 | |
| 1994 | - /** @var GF_Field $field */ |
|
| 1995 | - foreach ( $fields as $field ) { |
|
| 1994 | + /** @var GF_Field $field */ |
|
| 1995 | + foreach ( $fields as $field ) { |
|
| 1996 | 1996 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1997 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1998 | - break; |
|
| 1997 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1998 | + break; |
|
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | 2001 | } |
@@ -2051,28 +2051,28 @@ discard block |
||
| 2051 | 2051 | */ |
| 2052 | 2052 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 2053 | 2053 | |
| 2054 | - /** |
|
| 2054 | + /** |
|
| 2055 | 2055 | * @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 |
| 2056 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 2057 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 2058 | - * @since 1.9.1 |
|
| 2059 | - * @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. |
|
| 2060 | - * @param array $form GF Form array |
|
| 2061 | - * @param int $view_id View ID |
|
| 2062 | - */ |
|
| 2063 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 2064 | - |
|
| 2065 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2056 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 2057 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 2058 | + * @since 1.9.1 |
|
| 2059 | + * @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. |
|
| 2060 | + * @param array $form GF Form array |
|
| 2061 | + * @param int $view_id View ID |
|
| 2062 | + */ |
|
| 2063 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 2064 | + |
|
| 2065 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2066 | 2066 | foreach( $fields as $k => $field ) { |
| 2067 | 2067 | if( $field->adminOnly ) { |
| 2068 | - unset( $fields[ $k ] ); |
|
| 2068 | + unset( $fields[ $k ] ); |
|
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | return array_values( $fields ); |
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | - foreach( $fields as &$field ) { |
|
| 2075 | - $field->adminOnly = false; |
|
| 2074 | + foreach( $fields as &$field ) { |
|
| 2075 | + $field->adminOnly = false; |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | return $fields; |
@@ -2092,13 +2092,13 @@ discard block |
||
| 2092 | 2092 | */ |
| 2093 | 2093 | private function unselect_default_values( $form ) { |
| 2094 | 2094 | |
| 2095 | - foreach ( $form['fields'] as &$field ) { |
|
| 2095 | + foreach ( $form['fields'] as &$field ) { |
|
| 2096 | 2096 | |
| 2097 | 2097 | if ( empty( $field->choices ) ) { |
| 2098 | - continue; |
|
| 2098 | + continue; |
|
| 2099 | 2099 | } |
| 2100 | 2100 | |
| 2101 | - foreach ( $field->choices as &$choice ) { |
|
| 2101 | + foreach ( $field->choices as &$choice ) { |
|
| 2102 | 2102 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 2103 | 2103 | $choice['isSelected'] = false; |
| 2104 | 2104 | } |
@@ -2135,36 +2135,36 @@ discard block |
||
| 2135 | 2135 | |
| 2136 | 2136 | if( 'checkbox' === $field->type ) { |
| 2137 | 2137 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2138 | - $input_id = $input['id']; |
|
| 2139 | - $choice = $field->choices[ $key ]; |
|
| 2140 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2141 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2142 | - if( $match ) { |
|
| 2143 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2144 | - } |
|
| 2138 | + $input_id = $input['id']; |
|
| 2139 | + $choice = $field->choices[ $key ]; |
|
| 2140 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2141 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2142 | + if( $match ) { |
|
| 2143 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 2144 | + } |
|
| 2145 | 2145 | } |
| 2146 | 2146 | } else { |
| 2147 | 2147 | |
| 2148 | 2148 | // We need to run through each field to set the default values |
| 2149 | 2149 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2150 | 2150 | |
| 2151 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2151 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2152 | 2152 | |
| 2153 | - if( 'list' === $field->type ) { |
|
| 2154 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 2153 | + if( 'list' === $field->type ) { |
|
| 2154 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 2155 | 2155 | |
| 2156 | - $list_field_value = array(); |
|
| 2157 | - foreach ( (array) $list_rows as $row ) { |
|
| 2158 | - foreach ( (array) $row as $column ) { |
|
| 2159 | - $list_field_value[] = $column; |
|
| 2160 | - } |
|
| 2161 | - } |
|
| 2156 | + $list_field_value = array(); |
|
| 2157 | + foreach ( (array) $list_rows as $row ) { |
|
| 2158 | + foreach ( (array) $row as $column ) { |
|
| 2159 | + $list_field_value[] = $column; |
|
| 2160 | + } |
|
| 2161 | + } |
|
| 2162 | 2162 | |
| 2163 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 2164 | - } else { |
|
| 2165 | - $field->defaultValue = $field_value; |
|
| 2166 | - } |
|
| 2167 | - } |
|
| 2163 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 2164 | + } else { |
|
| 2165 | + $field->defaultValue = $field_value; |
|
| 2166 | + } |
|
| 2167 | + } |
|
| 2168 | 2168 | } |
| 2169 | 2169 | } |
| 2170 | 2170 | } |
@@ -2225,7 +2225,7 @@ discard block |
||
| 2225 | 2225 | foreach ( $form['fields'] as &$field ) { |
| 2226 | 2226 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2227 | 2227 | |
| 2228 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2228 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2229 | 2229 | |
| 2230 | 2230 | if ( $field['id'] == $rule_field_id ) { |
| 2231 | 2231 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | return $has_conditional_logic; |
| 2277 | 2277 | } |
| 2278 | 2278 | |
| 2279 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2279 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2280 | 2280 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2281 | 2281 | } |
| 2282 | 2282 | |
@@ -2343,14 +2343,14 @@ discard block |
||
| 2343 | 2343 | |
| 2344 | 2344 | if( $echo && $error !== true ) { |
| 2345 | 2345 | |
| 2346 | - $error = esc_html( $error ); |
|
| 2346 | + $error = esc_html( $error ); |
|
| 2347 | 2347 | |
| 2348 | - /** |
|
| 2349 | - * @since 1.9 |
|
| 2350 | - */ |
|
| 2351 | - if ( ! empty( $this->entry ) ) { |
|
| 2352 | - $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;" ) ); |
|
| 2353 | - } |
|
| 2348 | + /** |
|
| 2349 | + * @since 1.9 |
|
| 2350 | + */ |
|
| 2351 | + if ( ! empty( $this->entry ) ) { |
|
| 2352 | + $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;" ) ); |
|
| 2353 | + } |
|
| 2354 | 2354 | |
| 2355 | 2355 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2356 | 2356 | } |
@@ -18,83 +18,83 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class GravityView_Edit_Entry { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | 24 | static $file; |
| 25 | 25 | |
| 26 | 26 | static $instance; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Component instances. |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - public $instances = array(); |
|
| 28 | + /** |
|
| 29 | + * Component instances. |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + public $instances = array(); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | function __construct() { |
| 36 | 36 | |
| 37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
| 37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
| 38 | 38 | |
| 39 | - if( is_admin() ) { |
|
| 40 | - $this->load_components( 'admin' ); |
|
| 41 | - } |
|
| 39 | + if( is_admin() ) { |
|
| 40 | + $this->load_components( 'admin' ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | $this->load_components( 'locking' ); |
| 44 | 44 | |
| 45 | - $this->load_components( 'render' ); |
|
| 45 | + $this->load_components( 'render' ); |
|
| 46 | 46 | |
| 47 | - // If GF User Registration Add-on exists |
|
| 48 | - $this->load_components( 'user-registration' ); |
|
| 47 | + // If GF User Registration Add-on exists |
|
| 48 | + $this->load_components( 'user-registration' ); |
|
| 49 | 49 | |
| 50 | - $this->add_hooks(); |
|
| 50 | + $this->add_hooks(); |
|
| 51 | 51 | |
| 52 | 52 | // Process hooks for addons that may or may not be present |
| 53 | 53 | $this->addon_specific_hooks(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - static function getInstance() { |
|
| 57 | + static function getInstance() { |
|
| 58 | 58 | |
| 59 | - if( empty( self::$instance ) ) { |
|
| 60 | - self::$instance = new GravityView_Edit_Entry; |
|
| 61 | - } |
|
| 59 | + if( empty( self::$instance ) ) { |
|
| 60 | + self::$instance = new GravityView_Edit_Entry; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return self::$instance; |
|
| 64 | - } |
|
| 63 | + return self::$instance; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - private function load_components( $component ) { |
|
| 67 | + private function load_components( $component ) { |
|
| 68 | 68 | |
| 69 | - $dir = trailingslashit( self::$file ); |
|
| 69 | + $dir = trailingslashit( self::$file ); |
|
| 70 | 70 | |
| 71 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 71 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 73 | 73 | |
| 74 | - // Loads component and pass extension's instance so that component can |
|
| 75 | - // talk each other. |
|
| 76 | - require_once $filename; |
|
| 77 | - $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | - $this->instances[ $component ]->load(); |
|
| 74 | + // Loads component and pass extension's instance so that component can |
|
| 75 | + // talk each other. |
|
| 76 | + require_once $filename; |
|
| 77 | + $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | + $this->instances[ $component ]->load(); |
|
| 79 | 79 | |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - private function add_hooks() { |
|
| 82 | + private function add_hooks() { |
|
| 83 | 83 | |
| 84 | - // Add front-end access to Gravity Forms delete file action |
|
| 85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 84 | + // Add front-end access to Gravity Forms delete file action |
|
| 85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 86 | 86 | |
| 87 | - // Make sure this hook is run for non-admins |
|
| 88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 87 | + // Make sure this hook is run for non-admins |
|
| 88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 89 | 89 | |
| 90 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 90 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 91 | 91 | |
| 92 | - // add template path to check for field |
|
| 93 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 92 | + // add template path to check for field |
|
| 93 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 94 | 94 | |
| 95 | 95 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
| 96 | 96 | |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -149,74 +149,74 @@ discard block |
||
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Include this extension templates path |
|
| 154 | - * @param array $file_paths List of template paths ordered |
|
| 155 | - */ |
|
| 156 | - public function add_template_path( $file_paths ) { |
|
| 157 | - |
|
| 158 | - // Index 100 is the default GravityView template path. |
|
| 159 | - $file_paths[ 110 ] = self::$file; |
|
| 160 | - |
|
| 161 | - return $file_paths; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * |
|
| 166 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 167 | - * |
|
| 168 | - * @param $view_id int GravityView view id |
|
| 169 | - * @param $form_id int Gravity Forms form id |
|
| 170 | - * @param $entry_id int Gravity Forms entry id |
|
| 171 | - * @return string |
|
| 172 | - */ |
|
| 173 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 174 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * The edit entry link creates a secure link with a nonce |
|
| 180 | - * |
|
| 181 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 182 | - * it formats the display of the edit form like it does in the backend, like |
|
| 183 | - * "You can edit this post from the post page" fields, for example. |
|
| 184 | - * |
|
| 185 | - * @param $entry array Gravity Forms entry object |
|
| 186 | - * @param $view_id int GravityView view id |
|
| 187 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 188 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 189 | - * @return string |
|
| 190 | - */ |
|
| 191 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 192 | - |
|
| 193 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 194 | - |
|
| 195 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 196 | - |
|
| 197 | - $url = add_query_arg( array( |
|
| 198 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
| 199 | - ), $base ); |
|
| 200 | - |
|
| 201 | - if( $post_id ) { |
|
| 202 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Allow passing params to dynamically populate entry with values |
|
| 207 | - * @since 1.9.2 |
|
| 208 | - */ |
|
| 209 | - if( !empty( $field_values ) ) { |
|
| 210 | - |
|
| 211 | - if( is_array( $field_values ) ) { |
|
| 212 | - // If already an array, no parse_str() needed |
|
| 213 | - $params = $field_values; |
|
| 214 | - } else { |
|
| 215 | - parse_str( $field_values, $params ); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $url = add_query_arg( $params, $url ); |
|
| 219 | - } |
|
| 152 | + /** |
|
| 153 | + * Include this extension templates path |
|
| 154 | + * @param array $file_paths List of template paths ordered |
|
| 155 | + */ |
|
| 156 | + public function add_template_path( $file_paths ) { |
|
| 157 | + |
|
| 158 | + // Index 100 is the default GravityView template path. |
|
| 159 | + $file_paths[ 110 ] = self::$file; |
|
| 160 | + |
|
| 161 | + return $file_paths; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * |
|
| 166 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 167 | + * |
|
| 168 | + * @param $view_id int GravityView view id |
|
| 169 | + * @param $form_id int Gravity Forms form id |
|
| 170 | + * @param $entry_id int Gravity Forms entry id |
|
| 171 | + * @return string |
|
| 172 | + */ |
|
| 173 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 174 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * The edit entry link creates a secure link with a nonce |
|
| 180 | + * |
|
| 181 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 182 | + * it formats the display of the edit form like it does in the backend, like |
|
| 183 | + * "You can edit this post from the post page" fields, for example. |
|
| 184 | + * |
|
| 185 | + * @param $entry array Gravity Forms entry object |
|
| 186 | + * @param $view_id int GravityView view id |
|
| 187 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 188 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 189 | + * @return string |
|
| 190 | + */ |
|
| 191 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 192 | + |
|
| 193 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 194 | + |
|
| 195 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 196 | + |
|
| 197 | + $url = add_query_arg( array( |
|
| 198 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
| 199 | + ), $base ); |
|
| 200 | + |
|
| 201 | + if( $post_id ) { |
|
| 202 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Allow passing params to dynamically populate entry with values |
|
| 207 | + * @since 1.9.2 |
|
| 208 | + */ |
|
| 209 | + if( !empty( $field_values ) ) { |
|
| 210 | + |
|
| 211 | + if( is_array( $field_values ) ) { |
|
| 212 | + // If already an array, no parse_str() needed |
|
| 213 | + $params = $field_values; |
|
| 214 | + } else { |
|
| 215 | + parse_str( $field_values, $params ); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $url = add_query_arg( $params, $url ); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param \GV\View $view The View. |
| 226 | 226 | */ |
| 227 | 227 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Edit mode doesn't allow certain field types. |
@@ -280,19 +280,19 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * checks if user has permissions to edit a specific entry |
|
| 285 | - * |
|
| 286 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 287 | - * |
|
| 288 | - * @param array $entry Gravity Forms entry array |
|
| 289 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 290 | - * @return bool |
|
| 291 | - */ |
|
| 292 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 283 | + /** |
|
| 284 | + * checks if user has permissions to edit a specific entry |
|
| 285 | + * |
|
| 286 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 287 | + * |
|
| 288 | + * @param array $entry Gravity Forms entry array |
|
| 289 | + * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 290 | + * @return bool |
|
| 291 | + */ |
|
| 292 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 293 | 293 | |
| 294 | - // No permission by default |
|
| 295 | - $user_can_edit = false; |
|
| 294 | + // No permission by default |
|
| 295 | + $user_can_edit = false; |
|
| 296 | 296 | |
| 297 | 297 | // get user_edit setting |
| 298 | 298 | if ( empty( $view ) ) { |
@@ -310,60 +310,60 @@ discard block |
||
| 310 | 310 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - // If they can edit any entries (as defined in Gravity Forms) |
|
| 314 | - // Or if they can edit other people's entries |
|
| 315 | - // Then we're good. |
|
| 316 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 313 | + // If they can edit any entries (as defined in Gravity Forms) |
|
| 314 | + // Or if they can edit other people's entries |
|
| 315 | + // Then we're good. |
|
| 316 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 317 | 317 | |
| 318 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 318 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 319 | 319 | |
| 320 | - $user_can_edit = true; |
|
| 320 | + $user_can_edit = true; |
|
| 321 | 321 | |
| 322 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 322 | + } else if( !isset( $entry['created_by'] ) ) { |
|
| 323 | 323 | |
| 324 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 324 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 325 | 325 | |
| 326 | - $user_can_edit = false; |
|
| 326 | + $user_can_edit = false; |
|
| 327 | 327 | |
| 328 | - } else { |
|
| 328 | + } else { |
|
| 329 | 329 | |
| 330 | - $current_user = wp_get_current_user(); |
|
| 330 | + $current_user = wp_get_current_user(); |
|
| 331 | 331 | |
| 332 | - // User edit is disabled |
|
| 333 | - if( empty( $user_edit ) ) { |
|
| 332 | + // User edit is disabled |
|
| 333 | + if( empty( $user_edit ) ) { |
|
| 334 | 334 | |
| 335 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 335 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 336 | 336 | |
| 337 | - $user_can_edit = false; |
|
| 338 | - } |
|
| 337 | + $user_can_edit = false; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 341 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 340 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 341 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 342 | 342 | |
| 343 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 343 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 344 | 344 | |
| 345 | - $user_can_edit = true; |
|
| 345 | + $user_can_edit = true; |
|
| 346 | 346 | |
| 347 | - } else if( ! is_user_logged_in() ) { |
|
| 347 | + } else if( ! is_user_logged_in() ) { |
|
| 348 | 348 | |
| 349 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 349 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 350 | 350 | |
| 351 | - $user_can_edit = false; // Here just for clarity |
|
| 352 | - } |
|
| 351 | + $user_can_edit = false; // Here just for clarity |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - /** |
|
| 357 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 358 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 359 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 360 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 361 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 362 | - */ |
|
| 363 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 356 | + /** |
|
| 357 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 358 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 359 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 360 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 361 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 362 | + */ |
|
| 363 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 364 | 364 | |
| 365 | - return (bool) $user_can_edit; |
|
| 366 | - } |
|
| 365 | + return (bool) $user_can_edit; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | |
| 369 | 369 | |