upgrade.php
98 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package ACF |
| 4 | * @author WP Engine |
| 5 | * |
| 6 | * © 2026 Advanced Custom Fields (ACF®). All rights reserved. |
| 7 | * "ACF" is a trademark of WP Engine. |
| 8 | * Licensed under the GNU General Public License v2 or later. |
| 9 | * https://www.gnu.org/licenses/gpl-2.0.html |
| 10 | */ |
| 11 | ?> |
| 12 | <style type="text/css"> |
| 13 | |
| 14 | /* hide steps */ |
| 15 | .step-1, |
| 16 | .step-2, |
| 17 | .step-3 { |
| 18 | display: none; |
| 19 | } |
| 20 | |
| 21 | </style> |
| 22 | <div id="acf-upgrade-wrap" class="wrap"> |
| 23 | |
| 24 | <h1><?php esc_html_e( 'Upgrade Database', 'acf' ); ?></h1> |
| 25 | |
| 26 | <?php if ( acf_has_upgrade() ) : ?> |
| 27 | |
| 28 | <p><?php esc_html_e( 'Reading upgrade tasks...', 'acf' ); ?></p> |
| 29 | <?php /* translators: %s the new ACF version */ ?> |
| 30 | <p class="step-1"><i class="acf-loading"></i> <?php echo esc_html( sprintf( __( 'Upgrading data to version %s', 'acf' ), ACF_VERSION ) ); ?></p> |
| 31 | <p class="step-2"></p> |
| 32 | <?php /* translators: %s the url to the field group page. */ ?> |
| 33 | <p class="step-3"><?php echo acf_esc_html( sprintf( __( 'Database upgrade complete. <a href="%s">See what\'s new</a>', 'acf' ), esc_url( admin_url( 'edit.php?post_type=acf-field-group' ) ) ) ); ?></p> |
| 34 | |
| 35 | <script type="text/javascript"> |
| 36 | (function($) { |
| 37 | |
| 38 | var upgrader = new acf.Model({ |
| 39 | initialize: function(){ |
| 40 | |
| 41 | // allow user to read message for 1 second |
| 42 | this.setTimeout( this.upgrade, 1000 ); |
| 43 | }, |
| 44 | upgrade: function(){ |
| 45 | |
| 46 | // show step 1 |
| 47 | $('.step-1').show(); |
| 48 | |
| 49 | // vars |
| 50 | var response = ''; |
| 51 | var success = false; |
| 52 | |
| 53 | // send ajax request to upgrade DB |
| 54 | $.ajax({ |
| 55 | url: acf.get('ajaxurl'), |
| 56 | dataType: 'json', |
| 57 | type: 'post', |
| 58 | data: acf.prepareForAjax({ |
| 59 | action: 'acf/ajax/upgrade' |
| 60 | }), |
| 61 | success: function( json ){ |
| 62 | success = true; |
| 63 | }, |
| 64 | error: function( jqXHR, textStatus, errorThrown ){ |
| 65 | response = '<?php esc_attr_e( 'Upgrade failed.', 'acf' ); ?>'; |
| 66 | if( error = acf.getXhrError(jqXHR) ) { |
| 67 | response += ' <code>' + error + '</code>'; |
| 68 | } |
| 69 | }, |
| 70 | complete: this.proxy(function(){ |
| 71 | |
| 72 | // remove spinner |
| 73 | $('.acf-loading').hide(); |
| 74 | |
| 75 | // display response |
| 76 | if( response ) { |
| 77 | $('.step-2').show().html( response ); |
| 78 | } |
| 79 | |
| 80 | // display success |
| 81 | if( success ) { |
| 82 | $('.step-3').show(); |
| 83 | } |
| 84 | }) |
| 85 | }); |
| 86 | } |
| 87 | }); |
| 88 | |
| 89 | })(jQuery); |
| 90 | </script> |
| 91 | |
| 92 | <?php else : ?> |
| 93 | |
| 94 | <p><?php esc_html_e( 'No updates available.', 'acf' ); ?></p> |
| 95 | |
| 96 | <?php endif; ?> |
| 97 | </div> |
| 98 |