PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.2
Secure Custom Fields v6.4.2
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 1 year ago notice.php 1 year ago upgrade.php 1 year ago
network.php
197 lines
1 <?php
2 /**
3 * Network Admin Database Upgrade
4 *
5 * Shows the databse 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 seperately ?>
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 ( $i % 2 == 0 ) :
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 <?php // translators: %1 current db version, %2 available db version ?>
77 <span class="response"><?php echo esc_html( printf( __( 'Site requires database upgrade from %1$s to %2$s', 'secure-custom-fields' ), acf_get_db_version(), ACF_VERSION ) ); ?></span>
78 <?php else : ?>
79 <?php esc_html_e( 'Site is up to date', 'secure-custom-fields' ); ?>
80 <?php endif; ?>
81 </td>
82 </tr>
83 <?php
84
85 // restore
86 restore_current_blog();
87 endforeach;
88 endif;
89
90 ?>
91 </tbody>
92 </table>
93
94 <p><input type="submit" name="upgrade" value="<?php esc_attr_e( 'Upgrade Sites', 'secure-custom-fields' ); ?>" class="button" id="upgrade-sites-2"></p>
95 <?php // translators: %s admin dashboard url page ?>
96 <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>
97
98 <script type="text/javascript">
99 (function($) {
100
101 var upgrader = new acf.Model({
102 events: {
103 'click #upgrade-sites': 'onClick',
104 'click #upgrade-sites-2': 'onClick'
105 },
106 $inputs: function(){
107 return $('#the-list input:checked');
108 },
109 onClick: function( e, $el ){
110
111 // prevent default
112 e.preventDefault();
113
114 // bail early if no selection
115 if( !this.$inputs().length ) {
116 return alert('<?php esc_attr_e( 'Please select at least one site to upgrade.', 'secure-custom-fields' ); ?>');
117 }
118
119 // confirm action
120 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' ); ?>") ) {
121 return;
122 }
123
124 // upgrade
125 this.upgrade();
126 },
127 upgrade: function(){
128
129 // vars
130 var $inputs = this.$inputs();
131
132 // bail early if no sites selected
133 if( !$inputs.length ) {
134 return this.complete();
135 }
136
137 // disable buttons
138 $('.button').prop('disabled', true);
139
140 // vars
141 var $input = $inputs.first();
142 var $row = $input.closest('tr');
143 var text = '';
144 var success = false;
145
146 // show loading
147 <?php // translators: %s the version being upgraded to. ?>
148 $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 ) ); ?>');
149
150 // send ajax request to upgrade DB
151 $.ajax({
152 url: acf.get('ajaxurl'),
153 dataType: 'json',
154 type: 'post',
155 data: acf.prepareForAjax({
156 action: 'acf/ajax/upgrade',
157 blog_id: $input.val()
158 }),
159 success: function( json ){
160 success = true;
161 $input.remove();
162 text = '<?php esc_attr_e( 'Upgrade complete.', 'secure-custom-fields' ); ?>';
163 },
164 error: function( jqXHR, textStatus, errorThrown ){
165 text = '<?php esc_attr_e( 'Upgrade failed.', 'secure-custom-fields' ); ?>';
166 if( error = acf.getXhrError(jqXHR) ) {
167 text += ' <code>' + error + '</code>';
168 }
169 },
170 complete: this.proxy(function(){
171
172 // display text
173 $row.find('.response').html( text );
174
175 // if successful upgrade, proceed to next site. Otherwise, skip to complete.
176 if( success ) {
177 this.upgrade();
178 } else {
179 this.complete();
180 }
181 })
182 });
183 },
184 complete: function(){
185
186 // enable buttons
187 $('.button').prop('disabled', false);
188
189 // show message
190 $('.show-on-complete').show();
191 }
192 });
193
194 })(jQuery);
195 </script>
196 </div>
197