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.2.1 4.2.2 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 5.10 5.10.1 5.10.2 5.11 5.11.1 5.11.2 5.11.3 5.11.4 5.12 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.6.10 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.10 5.7.12 5.7.13 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.7.9 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.2 5.8.3 5.8.4
advanced-custom-fields / includes / admin / admin-upgrade.php
advanced-custom-fields / includes / admin Last commit date
post-types 5 months ago tools 5 months ago views 1 month ago admin-email-opt-in-banner.php 1 month ago admin-internal-post-type-list.php 5 months ago admin-internal-post-type.php 5 months ago admin-notices.php 5 months ago admin-options-pages-preview.php 5 months ago admin-tools.php 5 months ago admin-upgrade.php 5 months ago admin.php 1 month ago index.php 2 years ago
admin-upgrade.php
303 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 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 if ( ! class_exists( 'ACF_Admin_Upgrade' ) ) :
17
18 class ACF_Admin_Upgrade {
19
20 /**
21 * The name of the transient to store the network update check status.
22 *
23 * @var string
24 */
25 public $network_upgrade_needed_transient;
26
27 /**
28 * __construct
29 *
30 * Sets up the class functionality.
31 *
32 * @date 31/7/18
33 * @since 5.7.2
34 *
35 * @param void
36 * @return void
37 */
38 function __construct() {
39
40 $this->network_upgrade_needed_transient = 'acf_network_upgrade_needed_' . ACF_UPGRADE_VERSION;
41
42 add_action( 'admin_menu', array( $this, 'admin_menu' ), 20 );
43 if ( is_multisite() ) {
44 add_action( 'network_admin_menu', array( $this, 'network_admin_menu' ), 20 );
45 }
46 }
47
48 /**
49 * admin_menu
50 *
51 * Setus up logic if DB Upgrade is needed on a single site.
52 *
53 * @date 24/8/18
54 * @since 5.7.4
55 *
56 * @param void
57 * @return void
58 */
59 function admin_menu() {
60
61 // check if upgrade is avaialble
62 if ( acf_has_upgrade() ) {
63
64 // add notice
65 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
66
67 // add page
68 $page = add_submenu_page( 'index.php', __( 'Upgrade Database', 'acf' ), __( 'Upgrade Database', 'acf' ), acf_get_setting( 'capability' ), 'acf-upgrade', array( $this, 'admin_html' ) );
69
70 // actions
71 add_action( 'load-' . $page, array( $this, 'admin_load' ) );
72 }
73 }
74
75 /**
76 * Displays a “Database Upgrade Required” network admin notice and adds
77 * the “Upgrade Database” submenu under the “Dashboard” network admin
78 * menu item if an ACF upgrade needs to run on any network site.
79 *
80 * @since 5.7.4
81 * @since 6.0.0 Reduce memory usage, cache network upgrade checks.
82 */
83 function network_admin_menu() {
84 $network_upgrade_needed = get_site_transient( $this->network_upgrade_needed_transient );
85
86 // No transient value exists, so run the upgrade check.
87 if ( $network_upgrade_needed === false ) {
88 $network_upgrade_needed = $this->check_for_network_upgrades();
89 }
90
91 if ( $network_upgrade_needed === 'no' ) {
92 return;
93 }
94
95 add_action( 'network_admin_notices', array( $this, 'network_admin_notices' ) );
96
97 $page = add_submenu_page(
98 'index.php',
99 __( 'Upgrade Database', 'acf' ),
100 __( 'Upgrade Database', 'acf' ),
101 acf_get_setting( 'capability' ),
102 'acf-upgrade-network',
103 array( $this, 'network_admin_html' )
104 );
105
106 add_action( "load-$page", array( $this, 'network_admin_load' ) );
107 }
108
109 /**
110 * Checks if an ACF database upgrade is required on any site in the
111 * multisite network.
112 *
113 * Stores the result in `$this->network_upgrade_needed_transient`,
114 * which is version-linked to ACF_UPGRADE_VERSION: the highest ACF
115 * version that requires an upgrade function to run. Bumping
116 * ACF_UPGRADE_VERSION will trigger new upgrade checks but incrementing
117 * ACF_VERSION alone will not.
118 *
119 * @since 6.0.0
120 * @return string 'yes' if any site in the network requires an upgrade,
121 * otherwise 'no'. String instead of boolean so that
122 * `false` returned from a get_site_transient check can
123 * denote that an upgrade check is needed.
124 */
125 public function check_for_network_upgrades() {
126 $network_upgrade_needed = 'no';
127
128 $sites = get_sites(
129 array(
130 'number' => 0,
131 'fields' => 'ids', // Reduces PHP memory usage.
132 )
133 );
134
135 if ( $sites ) {
136 // Reduces memory usage (same pattern used in wp-includes/ms-site.php).
137 remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 );
138
139 foreach ( $sites as $site_id ) {
140 switch_to_blog( $site_id );
141
142 $site_needs_upgrade = acf_has_upgrade();
143
144 restore_current_blog(); // Restores global vars.
145
146 if ( $site_needs_upgrade ) {
147 $network_upgrade_needed = 'yes';
148 break;
149 }
150 }
151
152 add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
153 }
154
155 set_site_transient(
156 $this->network_upgrade_needed_transient,
157 $network_upgrade_needed,
158 3 * MONTH_IN_SECONDS
159 );
160
161 return $network_upgrade_needed;
162 }
163
164 /**
165 * admin_load
166 *
167 * Runs during the loading of the admin page.
168 *
169 * @date 24/8/18
170 * @since 5.7.4
171 *
172 * @param type $var Description. Default.
173 * @return type Description.
174 */
175 function admin_load() {
176
177 add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
178
179 // remove prompt
180 remove_action( 'admin_notices', array( $this, 'admin_notices' ) );
181
182 // Enqueue core script.
183 acf_enqueue_script( 'acf' );
184 }
185
186 /**
187 * network_admin_load
188 *
189 * Runs during the loading of the network admin page.
190 *
191 * @date 24/8/18
192 * @since 5.7.4
193 *
194 * @param type $var Description. Default.
195 * @return type Description.
196 */
197 function network_admin_load() {
198
199 add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
200
201 // remove prompt
202 remove_action( 'network_admin_notices', array( $this, 'network_admin_notices' ) );
203
204 // Enqueue core script.
205 acf_enqueue_script( 'acf' );
206 }
207
208 /**
209 * Modifies the admin body class.
210 *
211 * @since 6.0.0
212 *
213 * @param string $classes Space-separated list of CSS classes.
214 * @return string
215 */
216 public function admin_body_class( $classes ) {
217 $classes .= ' acf-admin-page';
218 return $classes;
219 }
220
221 /**
222 * admin_notices
223 *
224 * Displays the DB Upgrade prompt.
225 *
226 * @date 23/8/18
227 * @since 5.7.3
228 *
229 * @param void
230 * @return void
231 */
232 function admin_notices() {
233
234 // vars
235 $view = array(
236 'button_text' => __( 'Upgrade Database', 'acf' ),
237 'button_url' => admin_url( 'index.php?page=acf-upgrade' ),
238 'confirm' => true,
239 );
240
241 // view
242 acf_get_view( 'upgrade/notice', $view );
243 }
244
245 /**
246 * network_admin_notices
247 *
248 * Displays the DB Upgrade prompt on a multi site.
249 *
250 * @date 23/8/18
251 * @since 5.7.3
252 *
253 * @param void
254 * @return void
255 */
256 function network_admin_notices() {
257
258 // vars
259 $view = array(
260 'button_text' => __( 'Review sites & upgrade', 'acf' ),
261 'button_url' => network_admin_url( 'index.php?page=acf-upgrade-network' ),
262 'confirm' => false,
263 );
264
265 // view
266 acf_get_view( 'upgrade/notice', $view );
267 }
268
269 /**
270 * admin_html
271 *
272 * Displays the HTML for the admin page.
273 *
274 * @date 24/8/18
275 * @since 5.7.4
276 *
277 * @param void
278 * @return void
279 */
280 function admin_html() {
281 acf_get_view( 'upgrade/upgrade' );
282 }
283
284 /**
285 * network_admin_html
286 *
287 * Displays the HTML for the network upgrade admin page.
288 *
289 * @date 24/8/18
290 * @since 5.7.4
291 *
292 * @param void
293 * @return void
294 */
295 function network_admin_html() {
296 acf_get_view( 'upgrade/network' );
297 }
298 }
299
300 // instantiate
301 acf_new_instance( 'ACF_Admin_Upgrade' );
302 endif; // class_exists check
303