@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'WPINC' ) ) { |
| 14 | - die; |
|
| 14 | + die; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -22,104 +22,104 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @var GravityView_Edit_Entry |
| 24 | 24 | */ |
| 25 | - protected $loader; |
|
| 25 | + protected $loader; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var WP_User|null Temporary storage used by restore_user_details() |
|
| 29 | - */ |
|
| 30 | - private $_user_before_update = null; |
|
| 27 | + /** |
|
| 28 | + * @var WP_User|null Temporary storage used by restore_user_details() |
|
| 29 | + */ |
|
| 30 | + private $_user_before_update = null; |
|
| 31 | 31 | |
| 32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
| 33 | - $this->loader = $loader; |
|
| 34 | - } |
|
| 32 | + function __construct( GravityView_Edit_Entry $loader ) { |
|
| 33 | + $this->loader = $loader; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @since 1.11 |
| 38 | 38 | */ |
| 39 | 39 | public function load() { |
| 40 | 40 | add_action( 'wp', array( $this, 'add_hooks' ), 10 ); |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Add hooks to trigger updating the user |
| 45 | 45 | * |
| 46 | 46 | * @since 1.18 |
| 47 | 47 | */ |
| 48 | - public function add_hooks() { |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
| 52 | - * @since 1.11 |
|
| 53 | - * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
| 54 | - */ |
|
| 55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 56 | - |
|
| 57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 58 | - |
|
| 59 | - // last resort in case the current user display name don't match any of the defaults |
|
| 60 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Update the WordPress user profile based on the GF User Registration create feed |
|
| 66 | - * |
|
| 67 | - * @since 1.11 |
|
| 68 | - * |
|
| 69 | - * @param array $form Gravity Forms form array |
|
| 70 | - * @param string $entry_id Gravity Forms entry ID |
|
| 71 | - * @return void |
|
| 72 | - */ |
|
| 73 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
| 74 | - |
|
| 75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
| 76 | - do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' ); |
|
| 77 | - return; |
|
| 78 | - } elseif( empty( $entry_id ) ) { |
|
| 79 | - do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id ); |
|
| 80 | - return; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** @var GF_User_Registration $gf_user_registration */ |
|
| 84 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 85 | - |
|
| 86 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 90 | - * @since 1.11 |
|
| 91 | - * @param array $entry Gravity Forms entry |
|
| 92 | - * @param array $form Gravity Forms form |
|
| 93 | - */ |
|
| 94 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 95 | - |
|
| 96 | - $config = $this->get_feed_configuration( $entry, $form ); |
|
| 97 | - |
|
| 98 | - // Make sure the feed is active |
|
| 99 | - if ( ! rgar( $config, 'is_active', false ) ) { |
|
| 48 | + public function add_hooks() { |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated? |
|
| 52 | + * @since 1.11 |
|
| 53 | + * @param boolean $boolean Whether to trigger update on user registration (default: true) |
|
| 54 | + */ |
|
| 55 | + if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 56 | + |
|
| 57 | + add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 58 | + |
|
| 59 | + // last resort in case the current user display name don't match any of the defaults |
|
| 60 | + add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Update the WordPress user profile based on the GF User Registration create feed |
|
| 66 | + * |
|
| 67 | + * @since 1.11 |
|
| 68 | + * |
|
| 69 | + * @param array $form Gravity Forms form array |
|
| 70 | + * @param string $entry_id Gravity Forms entry ID |
|
| 71 | + * @return void |
|
| 72 | + */ |
|
| 73 | + public function update_user( $form = array(), $entry_id = 0 ) { |
|
| 74 | + |
|
| 75 | + if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
| 76 | + do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' ); |
|
| 100 | 77 | return; |
| 101 | - } |
|
| 78 | + } elseif( empty( $entry_id ) ) { |
|
| 79 | + do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id ); |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** @var GF_User_Registration $gf_user_registration */ |
|
| 84 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 85 | + |
|
| 86 | + $entry = GFAPI::get_entry( $entry_id ); |
|
| 102 | 87 | |
| 103 | - // If an Update feed, make sure the conditions are met. |
|
| 104 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
| 105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - } |
|
| 88 | + /** |
|
| 89 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 90 | + * @since 1.11 |
|
| 91 | + * @param array $entry Gravity Forms entry |
|
| 92 | + * @param array $form Gravity Forms form |
|
| 93 | + */ |
|
| 94 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 95 | + |
|
| 96 | + $config = $this->get_feed_configuration( $entry, $form ); |
|
| 97 | + |
|
| 98 | + // Make sure the feed is active |
|
| 99 | + if ( ! rgar( $config, 'is_active', false ) ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 109 | 102 | |
| 110 | - // The priority is set to 3 so that default priority (10) will still override it |
|
| 111 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 112 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 103 | + // If an Update feed, make sure the conditions are met. |
|
| 104 | + if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
| 105 | + if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + } |
|
| 113 | 109 | |
| 114 | - // Trigger the User Registration update user method |
|
| 115 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 110 | + // The priority is set to 3 so that default priority (10) will still override it |
|
| 111 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 112 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 116 | 113 | |
| 117 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 118 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 114 | + // Trigger the User Registration update user method |
|
| 115 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 119 | 116 | |
| 120 | - // Prevent double-triggering by removing the hook |
|
| 121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
| 122 | - } |
|
| 117 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 118 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 119 | + |
|
| 120 | + // Prevent double-triggering by removing the hook |
|
| 121 | + remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Get the User Registration feed configuration for the entry & form |
@@ -134,185 +134,185 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | - public function get_feed_configuration( $entry, $form ) { |
|
| 138 | - |
|
| 139 | - /** @var GF_User_Registration $gf_user_registration */ |
|
| 140 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 141 | - |
|
| 142 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 146 | - * @since 1.15 |
|
| 147 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 148 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 149 | - * @param[in] array $form Gravity Forms form array |
|
| 150 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 151 | - */ |
|
| 152 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 153 | - |
|
| 154 | - if( $preserve_role ) { |
|
| 155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Make sure the current display name is not changed with the update user method. |
|
| 162 | - * @since 1.15 |
|
| 163 | - */ |
|
| 164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 168 | - * @since 1.14 |
|
| 169 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 170 | - * @param[in] array $form Gravity Forms form array |
|
| 171 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 172 | - */ |
|
| 173 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 174 | - |
|
| 175 | - return $config; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Calculate the user display name format |
|
| 180 | - * |
|
| 181 | - * @since 1.15 |
|
| 182 | - * @since 1.20 Returns false if user not found at $user_id |
|
| 183 | - * |
|
| 184 | - * @param int $user_id WP User ID |
|
| 185 | - * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 186 | - */ |
|
| 187 | - public function match_current_display_name( $user_id ) { |
|
| 188 | - |
|
| 189 | - $user = get_userdata( $user_id ); |
|
| 190 | - |
|
| 191 | - if( ! $user ) { |
|
| 192 | - return false; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $names = $this->generate_display_names( $user ); |
|
| 196 | - |
|
| 197 | - $format = array_search( $user->display_name, $names, true ); |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 201 | - * @see restore_display_name |
|
| 202 | - */ |
|
| 203 | - if( false === $format ) { |
|
| 204 | - $this->_user_before_update = $user; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $format; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Generate an array of all the user display names possibilities |
|
| 212 | - * |
|
| 213 | - * @since 1.15 |
|
| 214 | - * |
|
| 215 | - * @param object $profileuser WP_User object |
|
| 216 | - * @return array List all the possible display names for a certain User object |
|
| 217 | - */ |
|
| 218 | - public function generate_display_names( $profileuser ) { |
|
| 219 | - |
|
| 220 | - $public_display = array(); |
|
| 221 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 222 | - $public_display['username'] = $profileuser->user_login; |
|
| 223 | - |
|
| 224 | - if ( !empty($profileuser->first_name) ) { |
|
| 225 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if ( !empty($profileuser->last_name) ) { |
|
| 229 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - $public_display = array_map( 'trim', $public_display ); |
|
| 238 | - $public_display = array_unique( $public_display ); |
|
| 239 | - |
|
| 240 | - return $public_display; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 246 | - * |
|
| 247 | - * @see GFUser::update_user() |
|
| 248 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 249 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 250 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 251 | - * @param string $password User password |
|
| 252 | - * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
| 253 | - */ |
|
| 254 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 258 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 259 | - * @since 1.14.4 |
|
| 260 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 261 | - */ |
|
| 262 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 263 | - |
|
| 264 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Don't restore display name: |
|
| 268 | - * - either disabled, |
|
| 269 | - * - or it is an Update feed (we only care about Create feed) |
|
| 270 | - * - or we don't need as we found the correct format before updating user. |
|
| 271 | - * @since 1.14.4 |
|
| 272 | - */ |
|
| 273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 274 | - return null; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - $user_after_update = get_userdata( $user_id ); |
|
| 278 | - |
|
| 279 | - // User not found |
|
| 280 | - if ( ! $user_after_update ) { |
|
| 281 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 282 | - return false; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - $restored_user = $user_after_update; |
|
| 286 | - |
|
| 287 | - // Restore previous display_name |
|
| 288 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 289 | - |
|
| 290 | - // Don't have WP update the password. |
|
| 291 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 295 | - * @since 1.14 |
|
| 296 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 297 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 298 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 299 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 300 | - */ |
|
| 301 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 302 | - |
|
| 303 | - $updated = wp_update_user( $restored_user ); |
|
| 304 | - |
|
| 305 | - if( is_wp_error( $updated ) ) { |
|
| 306 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 307 | - } else { |
|
| 308 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - $this->_user_before_update = null; |
|
| 312 | - |
|
| 313 | - unset( $restored_user, $user_after_update ); |
|
| 314 | - |
|
| 315 | - return $updated; |
|
| 316 | - } |
|
| 137 | + public function get_feed_configuration( $entry, $form ) { |
|
| 138 | + |
|
| 139 | + /** @var GF_User_Registration $gf_user_registration */ |
|
| 140 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 141 | + |
|
| 142 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 146 | + * @since 1.15 |
|
| 147 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 148 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 149 | + * @param[in] array $form Gravity Forms form array |
|
| 150 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 151 | + */ |
|
| 152 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 153 | + |
|
| 154 | + if( $preserve_role ) { |
|
| 155 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Make sure the current display name is not changed with the update user method. |
|
| 162 | + * @since 1.15 |
|
| 163 | + */ |
|
| 164 | + $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 168 | + * @since 1.14 |
|
| 169 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 170 | + * @param[in] array $form Gravity Forms form array |
|
| 171 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 172 | + */ |
|
| 173 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 174 | + |
|
| 175 | + return $config; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Calculate the user display name format |
|
| 180 | + * |
|
| 181 | + * @since 1.15 |
|
| 182 | + * @since 1.20 Returns false if user not found at $user_id |
|
| 183 | + * |
|
| 184 | + * @param int $user_id WP User ID |
|
| 185 | + * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 186 | + */ |
|
| 187 | + public function match_current_display_name( $user_id ) { |
|
| 188 | + |
|
| 189 | + $user = get_userdata( $user_id ); |
|
| 190 | + |
|
| 191 | + if( ! $user ) { |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $names = $this->generate_display_names( $user ); |
|
| 196 | + |
|
| 197 | + $format = array_search( $user->display_name, $names, true ); |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 201 | + * @see restore_display_name |
|
| 202 | + */ |
|
| 203 | + if( false === $format ) { |
|
| 204 | + $this->_user_before_update = $user; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $format; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Generate an array of all the user display names possibilities |
|
| 212 | + * |
|
| 213 | + * @since 1.15 |
|
| 214 | + * |
|
| 215 | + * @param object $profileuser WP_User object |
|
| 216 | + * @return array List all the possible display names for a certain User object |
|
| 217 | + */ |
|
| 218 | + public function generate_display_names( $profileuser ) { |
|
| 219 | + |
|
| 220 | + $public_display = array(); |
|
| 221 | + $public_display['nickname'] = $profileuser->nickname; |
|
| 222 | + $public_display['username'] = $profileuser->user_login; |
|
| 223 | + |
|
| 224 | + if ( !empty($profileuser->first_name) ) { |
|
| 225 | + $public_display['firstname'] = $profileuser->first_name; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if ( !empty($profileuser->last_name) ) { |
|
| 229 | + $public_display['lastname'] = $profileuser->last_name; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 233 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + $public_display = array_map( 'trim', $public_display ); |
|
| 238 | + $public_display = array_unique( $public_display ); |
|
| 239 | + |
|
| 240 | + return $public_display; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 246 | + * |
|
| 247 | + * @see GFUser::update_user() |
|
| 248 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 249 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 250 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 251 | + * @param string $password User password |
|
| 252 | + * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
| 253 | + */ |
|
| 254 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 258 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 259 | + * @since 1.14.4 |
|
| 260 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 261 | + */ |
|
| 262 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 263 | + |
|
| 264 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Don't restore display name: |
|
| 268 | + * - either disabled, |
|
| 269 | + * - or it is an Update feed (we only care about Create feed) |
|
| 270 | + * - or we don't need as we found the correct format before updating user. |
|
| 271 | + * @since 1.14.4 |
|
| 272 | + */ |
|
| 273 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 274 | + return null; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + $user_after_update = get_userdata( $user_id ); |
|
| 278 | + |
|
| 279 | + // User not found |
|
| 280 | + if ( ! $user_after_update ) { |
|
| 281 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) ); |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + $restored_user = $user_after_update; |
|
| 286 | + |
|
| 287 | + // Restore previous display_name |
|
| 288 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 289 | + |
|
| 290 | + // Don't have WP update the password. |
|
| 291 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 295 | + * @since 1.14 |
|
| 296 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 297 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 298 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 299 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 300 | + */ |
|
| 301 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 302 | + |
|
| 303 | + $updated = wp_update_user( $restored_user ); |
|
| 304 | + |
|
| 305 | + if( is_wp_error( $updated ) ) { |
|
| 306 | + do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 307 | + } else { |
|
| 308 | + do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + $this->_user_before_update = null; |
|
| 312 | + |
|
| 313 | + unset( $restored_user, $user_after_update ); |
|
| 314 | + |
|
| 315 | + return $updated; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | } //end class |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | // Call the custom API. |
| 117 | 117 | $response = wp_remote_post( self::url, array( |
| 118 | 118 | 'timeout' => 15, |
| 119 | - 'sslverify' => false, |
|
| 120 | - 'body' => array( |
|
| 121 | - 'edd_action' => 'check_license', |
|
| 122 | - 'license' => trim( $this->Addon->get_app_setting( 'license_key' ) ), |
|
| 123 | - 'item_name' => self::name, |
|
| 124 | - 'url' => home_url(), |
|
| 125 | - 'site_data' => $this->get_site_data(), |
|
| 126 | - ), |
|
| 119 | + 'sslverify' => false, |
|
| 120 | + 'body' => array( |
|
| 121 | + 'edd_action' => 'check_license', |
|
| 122 | + 'license' => trim( $this->Addon->get_app_setting( 'license_key' ) ), |
|
| 123 | + 'item_name' => self::name, |
|
| 124 | + 'url' => home_url(), |
|
| 125 | + 'site_data' => $this->get_site_data(), |
|
| 126 | + ), |
|
| 127 | 127 | )); |
| 128 | 128 | |
| 129 | 129 | // make sure the response came back okay |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | 'author' => self::author, |
| 386 | 386 | 'language' => get_locale(), |
| 387 | 387 | 'url' => home_url(), |
| 388 | - 'beta' => $this->Addon->get_app_setting( 'beta' ), |
|
| 388 | + 'beta' => $this->Addon->get_app_setting( 'beta' ), |
|
| 389 | 389 | ); |
| 390 | 390 | |
| 391 | 391 | if( !empty( $action ) ) { |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | // Update option with passed data license |
| 679 | 679 | $settings = $this->Addon->get_app_settings(); |
| 680 | 680 | |
| 681 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 681 | + $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 682 | 682 | $settings['license_key_status'] = $license_data->license; |
| 683 | 683 | $settings['license_key_response'] = (array)$license_data; |
| 684 | 684 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | protected $script_handles = array( |
| 25 | 25 | 'rcp-admin-scripts', |
| 26 | - 'bbq', |
|
| 26 | + 'bbq', |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | if( empty( $connected_views ) ) { |
| 138 | 138 | |
| 139 | - $menu_items['gravityview'] = array( |
|
| 139 | + $menu_items['gravityview'] = array( |
|
| 140 | 140 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
| 141 | 141 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 142 | 142 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | // If there were no items added, then let's create the parent menu |
| 168 | 168 | if( $sub_menu_items ) { |
| 169 | 169 | |
| 170 | - $sub_menu_items[] = array( |
|
| 171 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 172 | - 'link_class' => 'gv-create-view', |
|
| 173 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 174 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 175 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 176 | - ); |
|
| 170 | + $sub_menu_items[] = array( |
|
| 171 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
| 172 | + 'link_class' => 'gv-create-view', |
|
| 173 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
| 174 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
| 175 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | 178 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
| 179 | 179 | $sub_menu_items[] = array( |
@@ -549,12 +549,12 @@ discard block |
||
| 549 | 549 | * Render html for displaying available fields based on a Form ID |
| 550 | 550 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
| 551 | 551 | * |
| 552 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 552 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
| 553 | 553 | * @access public |
| 554 | - * |
|
| 554 | + * |
|
| 555 | 555 | * @param int $form Gravity Forms Form ID (default: '') |
| 556 | 556 | * @param string $context (default: 'single') |
| 557 | - * |
|
| 557 | + * |
|
| 558 | 558 | * @return void |
| 559 | 559 | */ |
| 560 | 560 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | |
| 569 | 569 | if ( ! is_array( $blacklist_field_types ) ) { |
| 570 | 570 | |
| 571 | - do_action( 'gravityview_log_error', __METHOD__ . ': $blacklist_field_types is not an array', print_r( $blacklist_field_types, true ) ); |
|
| 571 | + do_action( 'gravityview_log_error', __METHOD__ . ': $blacklist_field_types is not an array', print_r( $blacklist_field_types, true ) ); |
|
| 572 | 572 | |
| 573 | 573 | $blacklist_field_types = array(); |
| 574 | 574 | } |
@@ -700,12 +700,12 @@ discard block |
||
| 700 | 700 | /** |
| 701 | 701 | * @since 1.7.2 |
| 702 | 702 | */ |
| 703 | - 'other_entries' => array( |
|
| 704 | - 'label' => __('Other Entries', 'gravityview'), |
|
| 705 | - 'type' => 'other_entries', |
|
| 706 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 707 | - ), |
|
| 708 | - ); |
|
| 703 | + 'other_entries' => array( |
|
| 704 | + 'label' => __('Other Entries', 'gravityview'), |
|
| 705 | + 'type' => 'other_entries', |
|
| 706 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
| 707 | + ), |
|
| 708 | + ); |
|
| 709 | 709 | |
| 710 | 710 | if( 'single' !== $zone) { |
| 711 | 711 | |
@@ -1016,59 +1016,59 @@ discard block |
||
| 1016 | 1016 | |
| 1017 | 1017 | // Don't process any scripts below here if it's not a GravityView page. |
| 1018 | 1018 | if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
| 1019 | - return; |
|
| 1019 | + return; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1023 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 1024 | - |
|
| 1025 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1026 | - |
|
| 1027 | - //enqueue scripts |
|
| 1028 | - 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' ), GravityView_Plugin::version ); |
|
| 1029 | - |
|
| 1030 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1031 | - 'cookiepath' => COOKIEPATH, |
|
| 1032 | - 'passed_form_id' => (bool) rgget( 'form_id' ), |
|
| 1033 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1034 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1035 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1036 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1037 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1038 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1039 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1040 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1041 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1042 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1043 | - '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' ), |
|
| 1044 | - )); |
|
| 1045 | - |
|
| 1046 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1047 | - |
|
| 1048 | - // Enqueue scripts needed for merge tags |
|
| 1049 | - self::enqueue_gravity_forms_scripts(); |
|
| 1022 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 1023 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 1024 | + |
|
| 1025 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 1026 | + |
|
| 1027 | + //enqueue scripts |
|
| 1028 | + 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' ), GravityView_Plugin::version ); |
|
| 1029 | + |
|
| 1030 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
| 1031 | + 'cookiepath' => COOKIEPATH, |
|
| 1032 | + 'passed_form_id' => (bool) rgget( 'form_id' ), |
|
| 1033 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1034 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1035 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1036 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1037 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1038 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1039 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1040 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1041 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1042 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1043 | + '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' ), |
|
| 1044 | + )); |
|
| 1045 | + |
|
| 1046 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1047 | + |
|
| 1048 | + // Enqueue scripts needed for merge tags |
|
| 1049 | + self::enqueue_gravity_forms_scripts(); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | /** |
| 1053 | 1053 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
| 1054 | - * |
|
| 1055 | - * @since 1.0.5-beta |
|
| 1056 | - * |
|
| 1057 | - * @return void |
|
| 1054 | + * |
|
| 1055 | + * @since 1.0.5-beta |
|
| 1056 | + * |
|
| 1057 | + * @return void |
|
| 1058 | 1058 | */ |
| 1059 | 1059 | static function enqueue_gravity_forms_scripts() { |
| 1060 | 1060 | GFForms::register_scripts(); |
| 1061 | 1061 | |
| 1062 | 1062 | $scripts = array( |
| 1063 | - 'sack', |
|
| 1064 | - 'gform_gravityforms', |
|
| 1065 | - 'gform_forms', |
|
| 1066 | - 'gform_form_admin', |
|
| 1067 | - 'jquery-ui-autocomplete' |
|
| 1063 | + 'sack', |
|
| 1064 | + 'gform_gravityforms', |
|
| 1065 | + 'gform_forms', |
|
| 1066 | + 'gform_form_admin', |
|
| 1067 | + 'jquery-ui-autocomplete' |
|
| 1068 | 1068 | ); |
| 1069 | 1069 | |
| 1070 | 1070 | if ( wp_is_mobile() ) { |
| 1071 | - $scripts[] = 'jquery-touch-punch'; |
|
| 1071 | + $scripts[] = 'jquery-touch-punch'; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | wp_enqueue_script( $scripts ); |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | add_action( 'gravityview_log_debug', array( $this, 'log_debug'), 10, 2 ); |
| 13 | 13 | |
| 14 | 14 | // Enable debug with Gravity Forms Logging Add-on |
| 15 | - add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
|
| 15 | + add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
|
| 16 | 16 | |
| 17 | - // Load Debug Bar integration |
|
| 18 | - add_filter( 'debug_bar_panels', array( $this, 'add_debug_bar' ) ); |
|
| 17 | + // Load Debug Bar integration |
|
| 18 | + add_filter( 'debug_bar_panels', array( $this, 'add_debug_bar' ) ); |
|
| 19 | 19 | |
| 20 | 20 | } |
| 21 | 21 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * @param array $supported_plugins List of plugins |
| 45 | 45 | */ |
| 46 | 46 | public function enable_gform_logging( $supported_plugins ) { |
| 47 | - $supported_plugins['gravityview'] = 'GravityView'; |
|
| 48 | - return $supported_plugins; |
|
| 47 | + $supported_plugins['gravityview'] = 'GravityView'; |
|
| 48 | + return $supported_plugins; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | if ( class_exists("GFLogging") ) { |
| 98 | 98 | GFLogging::include_logger(); |
| 99 | - GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
| 100 | - } |
|
| 99 | + GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
| 100 | + } |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | static function log_error( $message = '', $data = null ) { |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ( class_exists("GFLogging") ) { |
| 118 | - GFLogging::include_logger(); |
|
| 119 | - GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ( $error, true), KLogger::ERROR ); |
|
| 118 | + GFLogging::include_logger(); |
|
| 119 | + GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ( $error, true), KLogger::ERROR ); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * Uninstall all traces of GravityView |
|
| 126 | - * |
|
| 127 | - * Note: method is public because parent method is public |
|
| 128 | - * |
|
| 125 | + * Uninstall all traces of GravityView |
|
| 126 | + * |
|
| 127 | + * Note: method is public because parent method is public |
|
| 128 | + * |
|
| 129 | 129 | * @return bool |
| 130 | 130 | */ |
| 131 | 131 | public function uninstall() { |
@@ -137,53 +137,53 @@ discard block |
||
| 137 | 137 | $uninstaller->fire_everything(); |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | - * Set the path so that Gravity Forms can de-activate GravityView |
|
| 141 | - * @see GFAddOn::uninstall_addon |
|
| 142 | - * @uses deactivate_plugins() |
|
| 143 | - */ |
|
| 140 | + * Set the path so that Gravity Forms can de-activate GravityView |
|
| 141 | + * @see GFAddOn::uninstall_addon |
|
| 142 | + * @uses deactivate_plugins() |
|
| 143 | + */ |
|
| 144 | 144 | $this->_path = GRAVITYVIEW_FILE; |
| 145 | 145 | |
| 146 | 146 | return true; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get an array of reasons why the plugin might be uninstalled |
|
| 151 | - * |
|
| 152 | - * @since 1.17.5 |
|
| 153 | - * |
|
| 150 | + * Get an array of reasons why the plugin might be uninstalled |
|
| 151 | + * |
|
| 152 | + * @since 1.17.5 |
|
| 153 | + * |
|
| 154 | 154 | * @return array Array of reasons with the label and followup questions for each uninstall reason |
| 155 | 155 | */ |
| 156 | 156 | private function get_uninstall_reasons() { |
| 157 | 157 | |
| 158 | 158 | $reasons = array( |
| 159 | 159 | 'will-continue' => array( |
| 160 | - 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 161 | - ), |
|
| 160 | + 'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ), |
|
| 161 | + ), |
|
| 162 | 162 | 'no-longer-need' => array( |
| 163 | - 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 164 | - ), |
|
| 163 | + 'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ), |
|
| 164 | + ), |
|
| 165 | 165 | 'doesnt-work' => array( |
| 166 | - 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 167 | - ), |
|
| 166 | + 'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ), |
|
| 167 | + ), |
|
| 168 | 168 | 'found-other' => array( |
| 169 | - 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 170 | - 'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'), |
|
| 171 | - ), |
|
| 169 | + 'label' => esc_html__( 'I found a better plugin', 'gravityview' ), |
|
| 170 | + 'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'), |
|
| 171 | + ), |
|
| 172 | 172 | 'other' => array( |
| 173 | - 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 174 | - ), |
|
| 173 | + 'label' => esc_html__( 'Other', 'gravityview' ), |
|
| 174 | + ), |
|
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | 177 | shuffle( $reasons ); |
| 178 | 178 | |
| 179 | 179 | return $reasons; |
| 180 | - } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * Display a feedback form when the plugin is uninstalled |
|
| 184 | - * |
|
| 185 | - * @since 1.17.5 |
|
| 186 | - * |
|
| 183 | + * Display a feedback form when the plugin is uninstalled |
|
| 184 | + * |
|
| 185 | + * @since 1.17.5 |
|
| 186 | + * |
|
| 187 | 187 | * @return string HTML of the uninstallation form |
| 188 | 188 | */ |
| 189 | 189 | public function uninstall_form() { |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | <h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2> |
| 264 | 264 | <ul> |
| 265 | 265 | <?php |
| 266 | - $reasons = $this->get_uninstall_reasons(); |
|
| 266 | + $reasons = $this->get_uninstall_reasons(); |
|
| 267 | 267 | foreach ( $reasons as $reason ) { |
| 268 | 268 | printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', rgar( $reason, 'followup' ), rgar( $reason, 'label' ) ); |
| 269 | 269 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $license_key = self::getSetting('license_key'); |
| 427 | 427 | if( '' === $license_key ) { |
| 428 | 428 | $license_status = 'inactive'; |
| 429 | - } |
|
| 429 | + } |
|
| 430 | 430 | $license_id = empty( $license_key ) ? 'license' : $license_key; |
| 431 | 431 | |
| 432 | 432 | $message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview'); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $update_below = false; |
| 442 | 442 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
| 443 | 443 | |
| 444 | - switch ( $license_status ) { |
|
| 444 | + switch ( $license_status ) { |
|
| 445 | 445 | /** @since 1.17 */ |
| 446 | 446 | case 'expired': |
| 447 | 447 | $title = __('Expired License', 'gravityview'); |
@@ -487,12 +487,12 @@ discard block |
||
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | - * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 491 | - * |
|
| 492 | - * @since 1.21.5 |
|
| 493 | - * |
|
| 494 | - * @see GFAddOn::scripts() |
|
| 495 | - * |
|
| 490 | + * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason. |
|
| 491 | + * |
|
| 492 | + * @since 1.21.5 |
|
| 493 | + * |
|
| 494 | + * @see GFAddOn::scripts() |
|
| 495 | + * |
|
| 496 | 496 | * @return array Array of scripts |
| 497 | 497 | */ |
| 498 | 498 | public function scripts() { |
@@ -501,10 +501,10 @@ discard block |
||
| 501 | 501 | $scripts[] = array( |
| 502 | 502 | 'handle' => 'gform_tooltip_init', |
| 503 | 503 | 'enqueue' => array( |
| 504 | - array( |
|
| 505 | - 'admin_page' => array( 'app_settings' ) |
|
| 506 | - ) |
|
| 507 | - ) |
|
| 504 | + array( |
|
| 505 | + 'admin_page' => array( 'app_settings' ) |
|
| 506 | + ) |
|
| 507 | + ) |
|
| 508 | 508 | ); |
| 509 | 509 | |
| 510 | 510 | return $scripts; |
@@ -523,10 +523,10 @@ discard block |
||
| 523 | 523 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
| 524 | 524 | 'version' => GravityView_Plugin::version, |
| 525 | 525 | "deps" => array( |
| 526 | - 'gform_admin', |
|
| 526 | + 'gform_admin', |
|
| 527 | 527 | 'gaddon_form_settings_css', |
| 528 | - 'gform_tooltip', |
|
| 529 | - 'gform_font_awesome', |
|
| 528 | + 'gform_tooltip', |
|
| 529 | + 'gform_font_awesome', |
|
| 530 | 530 | ), |
| 531 | 531 | 'enqueue' => array( |
| 532 | 532 | array( 'admin_page' => array( |
@@ -592,12 +592,12 @@ discard block |
||
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | public function app_settings_tab() { |
| 595 | - parent::app_settings_tab(); |
|
| 595 | + parent::app_settings_tab(); |
|
| 596 | 596 | |
| 597 | 597 | if ( $this->maybe_uninstall() ) { |
| 598 | - echo $this->uninstall_form(); |
|
| 598 | + echo $this->uninstall_form(); |
|
| 599 | 599 | } |
| 600 | - } |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | /** |
| 603 | 603 | * Make protected public |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | */ |
| 634 | 634 | public function get_app_settings() { |
| 635 | 635 | |
| 636 | - $settings = get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() ); |
|
| 636 | + $settings = get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() ); |
|
| 637 | 637 | |
| 638 | 638 | if( defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) { |
| 639 | 639 | $settings['license_key'] = GRAVITYVIEW_LICENSE_KEY; |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | */ |
| 675 | 675 | protected function settings_edd_license( $field, $echo = true ) { |
| 676 | 676 | |
| 677 | - if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 678 | - $field['input_type'] = 'password'; |
|
| 679 | - } |
|
| 677 | + if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
|
| 678 | + $field['input_type'] = 'password'; |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | 681 | $text = $this->settings_text( $field, false ); |
| 682 | 682 | |
@@ -731,8 +731,8 @@ discard block |
||
| 731 | 731 | type="' . $field['type'] . '" |
| 732 | 732 | name="' . esc_attr( $name ) . '" |
| 733 | 733 | value="' . $value . '" ' . |
| 734 | - implode( ' ', $attributes ) . |
|
| 735 | - ' />'; |
|
| 734 | + implode( ' ', $attributes ) . |
|
| 735 | + ' />'; |
|
| 736 | 736 | |
| 737 | 737 | if ( $echo ) { |
| 738 | 738 | echo $html; |
@@ -773,19 +773,19 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | |
| 775 | 775 | /** |
| 776 | - * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 777 | - * |
|
| 778 | - * Converts `$field['description']` to `$field['gv_description']` |
|
| 779 | - * Converts `$field['subtitle']` to `$field['description']` |
|
| 780 | - * |
|
| 781 | - * @see GravityView_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 782 | - * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 783 | - * |
|
| 784 | - * @since 1.21.5.2 |
|
| 785 | - * |
|
| 776 | + * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it |
|
| 777 | + * |
|
| 778 | + * Converts `$field['description']` to `$field['gv_description']` |
|
| 779 | + * Converts `$field['subtitle']` to `$field['description']` |
|
| 780 | + * |
|
| 781 | + * @see GravityView_Settings::single_setting_label Converts `gv_description` back to `description` |
|
| 782 | + * @see http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description |
|
| 783 | + * |
|
| 784 | + * @since 1.21.5.2 |
|
| 785 | + * |
|
| 786 | 786 | * @param array $field |
| 787 | - * |
|
| 788 | - * @return void |
|
| 787 | + * |
|
| 788 | + * @return void |
|
| 789 | 789 | */ |
| 790 | 790 | public function single_setting_row( $field ) { |
| 791 | 791 | |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | array( |
| 981 | 981 | 'label' => _x('Show me beta versions if they are available.', 'gravityview'), |
| 982 | 982 | 'value' => '1', |
| 983 | - 'name' => 'beta', |
|
| 983 | + 'name' => 'beta', |
|
| 984 | 984 | ), |
| 985 | 985 | ), |
| 986 | 986 | 'description' => __( 'You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview'), |
@@ -1005,39 +1005,39 @@ discard block |
||
| 1005 | 1005 | |
| 1006 | 1006 | if( empty( $field['disabled'] ) ) { |
| 1007 | 1007 | unset( $field['disabled'] ); |
| 1008 | - } |
|
| 1008 | + } |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - $sections = array( |
|
| 1012 | - array( |
|
| 1013 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
| 1014 | - 'fields' => $fields, |
|
| 1015 | - ) |
|
| 1016 | - ); |
|
| 1011 | + $sections = array( |
|
| 1012 | + array( |
|
| 1013 | + 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
| 1014 | + 'fields' => $fields, |
|
| 1015 | + ) |
|
| 1016 | + ); |
|
| 1017 | 1017 | |
| 1018 | - // custom 'update settings' button |
|
| 1019 | - $button = array( |
|
| 1020 | - 'class' => 'button button-primary button-hero', |
|
| 1021 | - 'type' => 'save', |
|
| 1022 | - ); |
|
| 1018 | + // custom 'update settings' button |
|
| 1019 | + $button = array( |
|
| 1020 | + 'class' => 'button button-primary button-hero', |
|
| 1021 | + 'type' => 'save', |
|
| 1022 | + ); |
|
| 1023 | 1023 | |
| 1024 | 1024 | if( $disabled_attribute ) { |
| 1025 | 1025 | $button['disabled'] = $disabled_attribute; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | |
| 1029 | - /** |
|
| 1030 | - * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 1031 | - * Extensions can tap in here to insert their own section and settings. |
|
| 1032 | - * <code> |
|
| 1033 | - * $sections[] = array( |
|
| 1034 | - * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 1035 | - * 'fields' => $settings, |
|
| 1036 | - * ); |
|
| 1037 | - * </code> |
|
| 1038 | - * @param array $extension_settings Empty array, ready for extension settings! |
|
| 1039 | - */ |
|
| 1040 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 1029 | + /** |
|
| 1030 | + * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page |
|
| 1031 | + * Extensions can tap in here to insert their own section and settings. |
|
| 1032 | + * <code> |
|
| 1033 | + * $sections[] = array( |
|
| 1034 | + * 'title' => __( 'GravityView My Extension Settings', 'gravityview' ), |
|
| 1035 | + * 'fields' => $settings, |
|
| 1036 | + * ); |
|
| 1037 | + * </code> |
|
| 1038 | + * @param array $extension_settings Empty array, ready for extension settings! |
|
| 1039 | + */ |
|
| 1040 | + $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
| 1041 | 1041 | |
| 1042 | 1042 | // If there are extensions, add a section for them |
| 1043 | 1043 | if ( ! empty( $extension_sections ) ) { |
@@ -1050,13 +1050,13 @@ discard block |
||
| 1050 | 1050 | } |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - $k = count( $extension_sections ) - 1 ; |
|
| 1054 | - $extension_sections[ $k ]['fields'][] = $button; |
|
| 1053 | + $k = count( $extension_sections ) - 1 ; |
|
| 1054 | + $extension_sections[ $k ]['fields'][] = $button; |
|
| 1055 | 1055 | $sections = array_merge( $sections, $extension_sections ); |
| 1056 | 1056 | } else { |
| 1057 | - // add the 'update settings' button to the general section |
|
| 1058 | - $sections[0]['fields'][] = $button; |
|
| 1059 | - } |
|
| 1057 | + // add the 'update settings' button to the general section |
|
| 1058 | + $sections[0]['fields'][] = $button; |
|
| 1059 | + } |
|
| 1060 | 1060 | |
| 1061 | 1061 | return $sections; |
| 1062 | 1062 | } |