← All changes
|
features/email-confirmation/email-confirmation.php
+26
-14
3.16.0
→
4.0.3
View file →
| @@ -16,8 +16,21 @@ | ||
| 16 | 16 | if ( ! empty( $wpdb->collate ) ) |
| 17 | 17 | $charset_collate .= " COLLATE ".$wpdb->collate; |
| 18 | 18 | $tableName = $wpdb->prefix.'signups'; |
| 19 | 19 | |
| 20 | + // If a legacy signups table exists without the signup_id column, add the | |
| 21 | + // AUTO_INCREMENT column and PRIMARY KEY together. dbDelta would otherwise | |
| 22 | + // split this into two ALTER statements and MySQL rejects an AUTO_INCREMENT | |
| 23 | + // column that isn't simultaneously declared a key. | |
| 24 | + $table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $tableName ) ); | |
| 25 | + if ( $table_exists ) { | |
| 26 | + $column_exists = $wpdb->get_results( "SHOW COLUMNS FROM `{$tableName}` LIKE 'signup_id'" ); | |
| 27 | + if ( empty( $column_exists ) ) { | |
| 28 | + $wpdb->query( "ALTER TABLE `{$tableName}` ADD COLUMN signup_id bigint(20) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (signup_id)" ); | |
| 29 | + update_option( 'wppb_signups_table_updated', 'yes' ); | |
| 30 | + } | |
| 31 | + } | |
| 32 | + | |
| 20 | 33 | $sql = " |
| 21 | 34 | CREATE TABLE $tableName ( |
| 22 | 35 | signup_id bigint(20) NOT NULL AUTO_INCREMENT, |
| 23 | 36 | domain varchar(191) NOT NULL default '', |
| @@ -129,8 +142,19 @@ | ||
| 129 | 142 | alert( response.trim() ); |
| 130 | 143 | }); |
| 131 | 144 | } |
| 132 | 145 | } |
| 146 | + | |
| 147 | + jQuery(document).on('click', 'a.wppb-ec-action', function(e) { | |
| 148 | + e.preventDefault(); | |
| 149 | + var link = jQuery(this); | |
| 150 | + confirmECAction( | |
| 151 | + link.attr('data-url'), | |
| 152 | + link.attr('data-todo'), | |
| 153 | + link.attr('data-email'), | |
| 154 | + link.attr('data-message') | |
| 155 | + ); | |
| 156 | + }); | |
| 133 | 157 | </script> |
| 134 | 158 | <?php |
| 135 | 159 | } |
| 136 | 160 | |
| @@ -285,15 +309,9 @@ | ||
| 285 | 309 | case 'Upload':{ |
| 286 | 310 | if ( isset( $meta[$value['meta-name']] ) ){ |
| 287 | 311 | if( !empty( $meta[$value['meta-name']] ) ) { |
| 288 | 312 | if (is_numeric($meta[$value['meta-name']])) { |
| 289 | - update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); | |
| 290 | - | |
| 291 | - // use this to update the post author to the correct user | |
| 292 | - wp_update_post( array( | |
| 293 | - 'ID' => trim( $meta[$value['meta-name']] ), | |
| 294 | - 'post_author' => $user_id | |
| 295 | - ) ); | |
| 313 | + wppb_save_attachment_id( trim( $meta[$value['meta-name']] ), $value, $user_id ); | |
| 296 | 314 | } else { |
| 297 | 315 | $wp_upload_array = wp_upload_dir(); // Array of key => value pairs |
| 298 | 316 | |
| 299 | 317 | $file = trim($meta[$value['meta-name']]); |
| @@ -322,15 +340,9 @@ | ||
| 322 | 340 | case 'Avatar':{ |
| 323 | 341 | if ( isset( $meta[$value['meta-name']] ) ) { |
| 324 | 342 | if( !empty( $meta[$value['meta-name']] ) ) { |
| 325 | 343 | if (is_numeric($meta[$value['meta-name']])) { |
| 326 | - update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); | |
| 327 | - | |
| 328 | - // use this to update the post author to the correct user | |
| 329 | - wp_update_post( array( | |
| 330 | - 'ID' => trim( $meta[$value['meta-name']] ), | |
| 331 | - 'post_author' => $user_id | |
| 332 | - ) ); | |
| 344 | + wppb_save_attachment_id( trim( $meta[$value['meta-name']] ), $value, $user_id ); | |
| 333 | 345 | } else { |
| 334 | 346 | $wp_upload_array = wp_upload_dir(); // Array of key => value pairs |
| 335 | 347 | |
| 336 | 348 | $file = trim($meta[$value['meta-name']]); |