PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / trunk
Secure Custom Fields vtrunk
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / admin / views / upgrade / network.php
secure-custom-fields / includes / admin / views / upgrade Last commit date
index.php 1 year ago network.php 7 months ago notice.php 7 months ago upgrade.php 1 year ago
network.php
205 lines
1 <?php
2 /**
3 * Network Admin Database Upgrade
4 *
5 * Shows the database upgrade process.
6 *
7 * @package wordpress/secure-custom-fields
8 */
9
10 ?>
11 <style type="text/css">
12
13 /* hide steps */
14 .show-on-complete {
15 display: none;
16 }
17
18 </style>
19 <div id="acf-upgrade-wrap" class="wrap">
20
21 <h1><?php esc_html_e( 'Upgrade Database', 'secure-custom-fields' ); ?></h1>
22
23 <?php // translators: %s The button label name, translated separately ?>
24 <p><?php printf( esc_html__( 'The following sites require a DB upgrade. Check the ones you want to update and then click %s.', 'secure-custom-fields' ), '"' . esc_html__( 'Upgrade Sites', 'secure-custom-fields' ) . '"' ); ?></p>
25 <p><input type="submit" name="upgrade" value="<?php esc_attr_e( 'Upgrade Sites', 'secure-custom-fields' ); ?>" class="button" id="upgrade-sites"></p>
26
27 <table class="wp-list-table widefat">
28 <thead>
29 <tr>
30 <td class="manage-column check-column" scope="col">
31 <input type="checkbox" id="sites-select-all">
32 </td>
33 <th class="manage-column" scope="col" style="width:33%;">
34 <label for="sites-select-all"><?php esc_html_e( 'Site', 'secure-custom-fields' ); ?></label>
35 </th>
36 <th><?php esc_html_e( 'Description', 'secure-custom-fields' ); ?></th>
37 </tr>
38 </thead>
39 <tfoot>
40 <tr>
41 <td class="manage-column check-column" scope="col">
42 <input type="checkbox" id="sites-select-all-2">
43 </td>
44 <th class="manage-column" scope="col">
45 <label for="sites-select-all-2"><?php esc_html_e( 'Site', 'secure-custom-fields' ); ?></label>
46 </th>
47 <th><?php esc_html_e( 'Description', 'secure-custom-fields' ); ?></th>
48 </tr>
49 </tfoot>
50 <tbody id="the-list">
51 <?php
52
53 $sites = acf_get_sites();
54 if ( $sites ) :
55 foreach ( $sites as $i => $site ) :
56
57 // switch blog
58 switch_to_blog( $site['blog_id'] );
59
60 ?>
61 <tr
62 <?php
63 if ( 0 === $i % 2 ) :
64 ?>
65 class="alternate"<?php endif; ?>>
66 <th class="check-column" scope="row">
67 <?php if ( acf_has_upgrade() ) : ?>
68 <input type="checkbox" value="<?php echo esc_attr( $site['blog_id'] ); ?>" name="checked[]">
69 <?php endif; ?>
70 </th>
71 <td>
72 <strong><?php echo esc_html( get_bloginfo( 'name' ) ); ?></strong><br /><?php echo esc_url( home_url() ); ?>
73 </td>
74 <td>
75 <?php if ( acf_has_upgrade() ) : ?>
76 <span class="response">
77 <?php
78 printf(
79 /* translators: %1$s current db version, %2$s available db version */
80 esc_html__( 'Site requires database upgrade from %1$s to %2$s', 'secure-custom-fields' ),
81 esc_html( acf_get_db_version() ),
82 esc_html( ACF_VERSION )
83 );
84 ?>
85 </span>
86 <?php else : ?>
87 <?php esc_html_e( 'Site is up to date', 'secure-custom-fields' ); ?>
88 <?php endif; ?>
89 </td>
90 </tr>
91 <?php
92
93 // restore
94 restore_current_blog();
95 endforeach;
96 endif;
97
98 ?>
99 </tbody>
100 </table>
101
102 <p><input type="submit" name="upgrade" value="<?php esc_attr_e( 'Upgrade Sites', 'secure-custom-fields' ); ?>" class="button" id="upgrade-sites-2"></p>
103 <?php // translators: %s admin dashboard url page ?>
104 <p class="show-on-complete"><?php echo acf_esc_html( sprintf( __( 'Database Upgrade complete. <a href="%s">Return to network dashboard</a>', 'secure-custom-fields' ), esc_url( network_admin_url() ) ) ); ?></p>
105
106 <script type="text/javascript">
107 (function($) {
108
109 var upgrader = new acf.Model({
110 events: {
111 'click #upgrade-sites': 'onClick',
112 'click #upgrade-sites-2': 'onClick'
113 },
114 $inputs: function(){
115 return $('#the-list input:checked');
116 },
117 onClick: function( e, $el ){
118
119 // prevent default
120 e.preventDefault();
121
122 // bail early if no selection
123 if( !this.$inputs().length ) {
124 return alert('<?php esc_attr_e( 'Please select at least one site to upgrade.', 'secure-custom-fields' ); ?>');
125 }
126
127 // confirm action
128 if( !confirm("<?php esc_attr_e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'secure-custom-fields' ); ?>") ) {
129 return;
130 }
131
132 // upgrade
133 this.upgrade();
134 },
135 upgrade: function(){
136
137 // vars
138 var $inputs = this.$inputs();
139
140 // bail early if no sites selected
141 if( !$inputs.length ) {
142 return this.complete();
143 }
144
145 // disable buttons
146 $('.button').prop('disabled', true);
147
148 // vars
149 var $input = $inputs.first();
150 var $row = $input.closest('tr');
151 var text = '';
152 var success = false;
153
154 // show loading
155 <?php // translators: %s the version being upgraded to. ?>
156 $row.find('.response').html('<i class="acf-loading"></i></span> <?php printf( esc_attr__( 'Upgrading data to version %s', 'secure-custom-fields' ), esc_attr( ACF_VERSION ) ); ?>');
157
158 // send ajax request to upgrade DB
159 $.ajax({
160 url: acf.get('ajaxurl'),
161 dataType: 'json',
162 type: 'post',
163 data: acf.prepareForAjax({
164 action: 'acf/ajax/upgrade',
165 blog_id: $input.val()
166 }),
167 success: function( json ){
168 success = true;
169 $input.remove();
170 text = '<?php esc_attr_e( 'Upgrade complete.', 'secure-custom-fields' ); ?>';
171 },
172 error: function( jqXHR, textStatus, errorThrown ){
173 text = '<?php esc_attr_e( 'Upgrade failed.', 'secure-custom-fields' ); ?>';
174 if( error = acf.getXhrError(jqXHR) ) {
175 text += ' <code>' + error + '</code>';
176 }
177 },
178 complete: this.proxy(function(){
179
180 // display text
181 $row.find('.response').html( text );
182
183 // if successful upgrade, proceed to next site. Otherwise, skip to complete.
184 if( success ) {
185 this.upgrade();
186 } else {
187 this.complete();
188 }
189 })
190 });
191 },
192 complete: function(){
193
194 // enable buttons
195 $('.button').prop('disabled', false);
196
197 // show message
198 $('.show-on-complete').show();
199 }
200 });
201
202 })(jQuery);
203 </script>
204 </div>
205