author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3 |
* A simple set of functions to check the WordPress.org Version Update service. |
0 | 4 |
* |
5 |
* @package WordPress |
|
6 |
* @since 2.3.0 |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
* Checks WordPress version against the newest version. |
0 | 11 |
* |
16 | 12 |
* The WordPress version, PHP version, and locale is sent. |
13 |
* |
|
14 |
* Checks against the WordPress server at api.wordpress.org. Will only check |
|
15 |
* if WordPress isn't installing. |
|
0 | 16 |
* |
17 |
* @since 2.3.0 |
|
16 | 18 |
* |
19 |
* @global string $wp_version Used to check against the newest WordPress version. |
|
20 |
* @global wpdb $wpdb WordPress database abstraction object. |
|
21 |
* @global string $wp_local_package Locale code of the package. |
|
0 | 22 |
* |
23 |
* @param array $extra_stats Extra statistics to report to the WordPress.org API. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
24 |
* @param bool $force_check Whether to bypass the transient cache and force a fresh update check. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
* Defaults to false, true if $extra_stats is set. |
0 | 26 |
*/ |
5 | 27 |
function wp_version_check( $extra_stats = array(), $force_check = false ) { |
16 | 28 |
global $wpdb, $wp_local_package; |
29 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
if ( wp_installing() ) { |
0 | 31 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
} |
0 | 33 |
|
16 | 34 |
// Include an unmodified $wp_version. |
35 |
require ABSPATH . WPINC . '/version.php'; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
36 |
$php_version = PHP_VERSION; |
0 | 37 |
|
9 | 38 |
$current = get_site_transient( 'update_core' ); |
0 | 39 |
$translations = wp_get_installed_translations( 'core' ); |
40 |
||
16 | 41 |
// Invalidate the transient when $wp_version changes. |
42 |
if ( is_object( $current ) && $wp_version !== $current->version_checked ) { |
|
5 | 43 |
$current = false; |
9 | 44 |
} |
5 | 45 |
|
9 | 46 |
if ( ! is_object( $current ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
$current = new stdClass(); |
9 | 48 |
$current->updates = array(); |
0 | 49 |
$current->version_checked = $wp_version; |
50 |
} |
|
51 |
||
9 | 52 |
if ( ! empty( $extra_stats ) ) { |
5 | 53 |
$force_check = true; |
9 | 54 |
} |
5 | 55 |
|
16 | 56 |
// Wait 1 minute between multiple version check requests. |
57 |
$timeout = MINUTE_IN_SECONDS; |
|
0 | 58 |
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
16 | 59 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
if ( ! $force_check && $time_not_changed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
} |
0 | 63 |
|
64 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* Filters the locale requested for WordPress core translations. |
0 | 66 |
* |
67 |
* @since 2.8.0 |
|
68 |
* |
|
69 |
* @param string $locale Current locale. |
|
70 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
$locale = apply_filters( 'core_version_check_locale', get_locale() ); |
0 | 72 |
|
16 | 73 |
// Update last_checked for current to prevent multiple blocking requests if request hangs. |
0 | 74 |
$current->last_checked = time(); |
75 |
set_site_transient( 'update_core', $current ); |
|
76 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
77 |
if ( method_exists( $wpdb, 'db_server_info' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
$mysql_version = $wpdb->db_server_info(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
79 |
} elseif ( method_exists( $wpdb, 'db_version' ) ) { |
9 | 80 |
$mysql_version = preg_replace( '/[^0-9.].*/', '', $wpdb->db_version() ); |
81 |
} else { |
|
0 | 82 |
$mysql_version = 'N/A'; |
9 | 83 |
} |
0 | 84 |
|
85 |
if ( is_multisite() ) { |
|
9 | 86 |
$num_blogs = get_blog_count(); |
87 |
$wp_install = network_site_url(); |
|
0 | 88 |
$multisite_enabled = 1; |
89 |
} else { |
|
90 |
$multisite_enabled = 0; |
|
9 | 91 |
$num_blogs = 1; |
92 |
$wp_install = home_url( '/' ); |
|
0 | 93 |
} |
94 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
$extensions = get_loaded_extensions(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
sort( $extensions, SORT_STRING | SORT_FLAG_CASE ); |
0 | 97 |
$query = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
'version' => $wp_version, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
'php' => $php_version, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
'locale' => $locale, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
'mysql' => $mysql_version, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
'local_package' => isset( $wp_local_package ) ? $wp_local_package : '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
'blogs' => $num_blogs, |
19 | 104 |
'users' => get_user_count(), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
'multisite_enabled' => $multisite_enabled, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
'initial_db_version' => get_site_option( 'initial_db_version' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
107 |
'extensions' => array_combine( $extensions, array_map( 'phpversion', $extensions ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
108 |
'platform_flags' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
'os' => PHP_OS, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
110 |
'bits' => PHP_INT_SIZE === 4 ? 32 : 64, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
111 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
112 |
'image_support' => array(), |
0 | 113 |
); |
114 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
115 |
if ( function_exists( 'gd_info' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
$gd_info = gd_info(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
117 |
// Filter to supported values. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
118 |
$gd_info = array_filter( $gd_info ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
119 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
120 |
// Add data for GD WebP and AVIF support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
121 |
$query['image_support']['gd'] = array_keys( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
122 |
array_filter( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
'webp' => isset( $gd_info['WebP Support'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
125 |
'avif' => isset( $gd_info['AVIF Support'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
126 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
127 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
128 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
129 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
130 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
if ( class_exists( 'Imagick' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
// Add data for Imagick WebP and AVIF support. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
$query['image_support']['imagick'] = array_keys( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
134 |
array_filter( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
135 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
136 |
'webp' => ! empty( Imagick::queryFormats( 'WEBP' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
137 |
'avif' => ! empty( Imagick::queryFormats( 'AVIF' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
138 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
139 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
140 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
141 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
142 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
/** |
18 | 144 |
* Filters the query arguments sent as part of the core version check. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* WARNING: Changing this data may result in your site not receiving security updates. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* Please exercise extreme caution. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* @param array $query { |
9 | 152 |
* Version check query arguments. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
* @type string $version WordPress version number. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
* @type string $php PHP version number. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
* @type string $locale The locale to retrieve updates for. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
* @type string $mysql MySQL version number. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
* @type string $local_package The value of the $wp_local_package global, when set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
* @type int $blogs Number of sites on this WordPress installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
* @type int $users Number of users on this WordPress installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
* @type int $multisite_enabled Whether this WordPress installation uses Multisite. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
* @type int $initial_db_version Database version of WordPress at time of installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
$query = apply_filters( 'core_version_check_query_args', $query ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
|
0 | 167 |
$post_body = array( |
5 | 168 |
'translations' => wp_json_encode( $translations ), |
0 | 169 |
); |
170 |
||
9 | 171 |
if ( is_array( $extra_stats ) ) { |
0 | 172 |
$post_body = array_merge( $post_body, $extra_stats ); |
9 | 173 |
} |
0 | 174 |
|
18 | 175 |
// Allow for WP_AUTO_UPDATE_CORE to specify beta/RC/development releases. |
176 |
if ( defined( 'WP_AUTO_UPDATE_CORE' ) |
|
177 |
&& in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true ) |
|
178 |
) { |
|
179 |
$query['channel'] = WP_AUTO_UPDATE_CORE; |
|
180 |
} |
|
181 |
||
19 | 182 |
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, '', '&' ); |
16 | 183 |
$http_url = $url; |
184 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
|
185 |
||
186 |
if ( $ssl ) { |
|
0 | 187 |
$url = set_url_scheme( $url, 'https' ); |
9 | 188 |
} |
0 | 189 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
$doing_cron = wp_doing_cron(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
|
0 | 192 |
$options = array( |
9 | 193 |
'timeout' => $doing_cron ? 30 : 3, |
0 | 194 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
9 | 195 |
'headers' => array( |
0 | 196 |
'wp_install' => $wp_install, |
9 | 197 |
'wp_blog' => home_url( '/' ), |
0 | 198 |
), |
9 | 199 |
'body' => $post_body, |
0 | 200 |
); |
201 |
||
202 |
$response = wp_remote_post( $url, $options ); |
|
16 | 203 |
|
0 | 204 |
if ( $ssl && is_wp_error( $response ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
205 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
206 |
__FUNCTION__, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
207 |
sprintf( |
16 | 208 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), |
16 | 210 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
); |
0 | 214 |
$response = wp_remote_post( $http_url, $options ); |
215 |
} |
|
216 |
||
16 | 217 |
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
} |
0 | 220 |
|
221 |
$body = trim( wp_remote_retrieve_body( $response ) ); |
|
222 |
$body = json_decode( $body, true ); |
|
223 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
if ( ! is_array( $body ) || ! isset( $body['offers'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
} |
0 | 227 |
|
228 |
$offers = $body['offers']; |
|
229 |
||
230 |
foreach ( $offers as &$offer ) { |
|
231 |
foreach ( $offer as $offer_key => $value ) { |
|
16 | 232 |
if ( 'packages' === $offer_key ) { |
9 | 233 |
$offer['packages'] = (object) array_intersect_key( |
234 |
array_map( 'esc_url', $offer['packages'] ), |
|
235 |
array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) |
|
236 |
); |
|
16 | 237 |
} elseif ( 'download' === $offer_key ) { |
0 | 238 |
$offer['download'] = esc_url( $value ); |
9 | 239 |
} else { |
0 | 240 |
$offer[ $offer_key ] = esc_html( $value ); |
9 | 241 |
} |
0 | 242 |
} |
9 | 243 |
$offer = (object) array_intersect_key( |
244 |
$offer, |
|
245 |
array_fill_keys( |
|
246 |
array( |
|
247 |
'response', |
|
248 |
'download', |
|
249 |
'locale', |
|
250 |
'packages', |
|
251 |
'current', |
|
252 |
'version', |
|
253 |
'php_version', |
|
254 |
'mysql_version', |
|
255 |
'new_bundled', |
|
256 |
'partial_version', |
|
257 |
'notify_email', |
|
258 |
'support_email', |
|
259 |
'new_files', |
|
260 |
), |
|
261 |
'' |
|
262 |
) |
|
263 |
); |
|
0 | 264 |
} |
265 |
||
9 | 266 |
$updates = new stdClass(); |
267 |
$updates->updates = $offers; |
|
268 |
$updates->last_checked = time(); |
|
0 | 269 |
$updates->version_checked = $wp_version; |
270 |
||
9 | 271 |
if ( isset( $body['translations'] ) ) { |
0 | 272 |
$updates->translations = $body['translations']; |
9 | 273 |
} |
0 | 274 |
|
5 | 275 |
set_site_transient( 'update_core', $updates ); |
276 |
||
277 |
if ( ! empty( $body['ttl'] ) ) { |
|
278 |
$ttl = (int) $body['ttl']; |
|
16 | 279 |
|
5 | 280 |
if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { |
281 |
// Queue an event to re-run the update check in $ttl seconds. |
|
282 |
wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); |
|
283 |
} |
|
284 |
} |
|
285 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
// Trigger background updates if running non-interactively, and we weren't called from the update handler. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
if ( $doing_cron && ! doing_action( 'wp_maybe_auto_update' ) ) { |
9 | 288 |
/** |
16 | 289 |
* Fires during wp_cron, starting the auto-update process. |
9 | 290 |
* |
291 |
* @since 3.9.0 |
|
292 |
*/ |
|
5 | 293 |
do_action( 'wp_maybe_auto_update' ); |
294 |
} |
|
0 | 295 |
} |
296 |
||
297 |
/** |
|
16 | 298 |
* Checks for available updates to plugins based on the latest versions hosted on WordPress.org. |
299 |
* |
|
300 |
* Despite its name this function does not actually perform any updates, it only checks for available updates. |
|
0 | 301 |
* |
16 | 302 |
* A list of all plugins installed is sent to WP, along with the site locale. |
303 |
* |
|
304 |
* Checks against the WordPress server at api.wordpress.org. Will only check |
|
305 |
* if WordPress isn't installing. |
|
0 | 306 |
* |
307 |
* @since 2.3.0 |
|
16 | 308 |
* |
309 |
* @global string $wp_version The WordPress version string. |
|
0 | 310 |
* |
5 | 311 |
* @param array $extra_stats Extra statistics to report to the WordPress.org API. |
0 | 312 |
*/ |
5 | 313 |
function wp_update_plugins( $extra_stats = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
if ( wp_installing() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
} |
0 | 317 |
|
16 | 318 |
// Include an unmodified $wp_version. |
319 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 320 |
|
16 | 321 |
// If running blog-side, bail unless we've not checked in the last 12 hours. |
9 | 322 |
if ( ! function_exists( 'get_plugins' ) ) { |
16 | 323 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
9 | 324 |
} |
0 | 325 |
|
9 | 326 |
$plugins = get_plugins(); |
0 | 327 |
$translations = wp_get_installed_translations( 'plugins' ); |
328 |
||
329 |
$active = get_option( 'active_plugins', array() ); |
|
330 |
$current = get_site_transient( 'update_plugins' ); |
|
16 | 331 |
|
9 | 332 |
if ( ! is_object( $current ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
$current = new stdClass(); |
9 | 334 |
} |
0 | 335 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
$updates = new stdClass(); |
18 | 337 |
$updates->last_checked = time(); |
338 |
$updates->response = array(); |
|
339 |
$updates->translations = array(); |
|
340 |
$updates->no_update = array(); |
|
0 | 341 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
$doing_cron = wp_doing_cron(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
|
0 | 344 |
// Check for update on a different schedule, depending on the page. |
345 |
switch ( current_filter() ) { |
|
9 | 346 |
case 'upgrader_process_complete': |
0 | 347 |
$timeout = 0; |
348 |
break; |
|
9 | 349 |
case 'load-update-core.php': |
0 | 350 |
$timeout = MINUTE_IN_SECONDS; |
351 |
break; |
|
9 | 352 |
case 'load-plugins.php': |
353 |
case 'load-update.php': |
|
0 | 354 |
$timeout = HOUR_IN_SECONDS; |
355 |
break; |
|
9 | 356 |
default: |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
if ( $doing_cron ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
$timeout = 2 * HOUR_IN_SECONDS; |
5 | 359 |
} else { |
360 |
$timeout = 12 * HOUR_IN_SECONDS; |
|
361 |
} |
|
0 | 362 |
} |
363 |
||
364 |
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); |
|
365 |
||
5 | 366 |
if ( $time_not_changed && ! $extra_stats ) { |
0 | 367 |
$plugin_changed = false; |
16 | 368 |
|
0 | 369 |
foreach ( $plugins as $file => $p ) { |
18 | 370 |
$updates->checked[ $file ] = $p['Version']; |
0 | 371 |
|
18 | 372 |
if ( ! isset( $current->checked[ $file ] ) || (string) $current->checked[ $file ] !== (string) $p['Version'] ) { |
0 | 373 |
$plugin_changed = true; |
9 | 374 |
} |
0 | 375 |
} |
376 |
||
9 | 377 |
if ( isset( $current->response ) && is_array( $current->response ) ) { |
0 | 378 |
foreach ( $current->response as $plugin_file => $update_details ) { |
9 | 379 |
if ( ! isset( $plugins[ $plugin_file ] ) ) { |
0 | 380 |
$plugin_changed = true; |
381 |
break; |
|
382 |
} |
|
383 |
} |
|
384 |
} |
|
385 |
||
16 | 386 |
// Bail if we've checked recently and if nothing has changed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
if ( ! $plugin_changed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
} |
0 | 390 |
} |
391 |
||
16 | 392 |
// Update last_checked for current to prevent multiple blocking requests if request hangs. |
0 | 393 |
$current->last_checked = time(); |
394 |
set_site_transient( 'update_plugins', $current ); |
|
395 |
||
396 |
$to_send = compact( 'plugins', 'active' ); |
|
397 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
$locales = array_values( get_available_languages() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
|
0 | 400 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
* Filters the locales requested for plugin translations. |
0 | 402 |
* |
403 |
* @since 3.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
* @since 4.5.0 The default value of the `$locales` parameter changed to include all locales. |
0 | 405 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
406 |
* @param string[] $locales Plugin locales. Default is all available locales of the site. |
0 | 407 |
*/ |
408 |
$locales = apply_filters( 'plugins_update_check_locales', $locales ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
$locales = array_unique( $locales ); |
0 | 410 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
if ( $doing_cron ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
412 |
$timeout = 30; // 30 seconds. |
5 | 413 |
} else { |
16 | 414 |
// Three seconds, plus one extra second for every 10 plugins. |
5 | 415 |
$timeout = 3 + (int) ( count( $plugins ) / 10 ); |
416 |
} |
|
417 |
||
0 | 418 |
$options = array( |
9 | 419 |
'timeout' => $timeout, |
420 |
'body' => array( |
|
5 | 421 |
'plugins' => wp_json_encode( $to_send ), |
422 |
'translations' => wp_json_encode( $translations ), |
|
423 |
'locale' => wp_json_encode( $locales ), |
|
424 |
'all' => wp_json_encode( true ), |
|
0 | 425 |
), |
9 | 426 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
0 | 427 |
); |
428 |
||
5 | 429 |
if ( $extra_stats ) { |
430 |
$options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
431 |
} |
|
432 |
||
16 | 433 |
$url = 'http://api.wordpress.org/plugins/update-check/1.1/'; |
434 |
$http_url = $url; |
|
435 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
|
436 |
||
437 |
if ( $ssl ) { |
|
0 | 438 |
$url = set_url_scheme( $url, 'https' ); |
9 | 439 |
} |
0 | 440 |
|
441 |
$raw_response = wp_remote_post( $url, $options ); |
|
16 | 442 |
|
0 | 443 |
if ( $ssl && is_wp_error( $raw_response ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
444 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
445 |
__FUNCTION__, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
sprintf( |
16 | 447 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), |
16 | 449 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
); |
0 | 453 |
$raw_response = wp_remote_post( $http_url, $options ); |
454 |
} |
|
455 |
||
16 | 456 |
if ( is_wp_error( $raw_response ) || 200 !== wp_remote_retrieve_response_code( $raw_response ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
} |
0 | 459 |
|
460 |
$response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
|
16 | 461 |
|
18 | 462 |
if ( $response && is_array( $response ) ) { |
463 |
$updates->response = $response['plugins']; |
|
464 |
$updates->translations = $response['translations']; |
|
465 |
$updates->no_update = $response['no_update']; |
|
466 |
} |
|
467 |
||
468 |
// Support updates for any plugins using the `Update URI` header field. |
|
469 |
foreach ( $plugins as $plugin_file => $plugin_data ) { |
|
470 |
if ( ! $plugin_data['UpdateURI'] || isset( $updates->response[ $plugin_file ] ) ) { |
|
471 |
continue; |
|
472 |
} |
|
473 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
474 |
$hostname = wp_parse_url( sanitize_url( $plugin_data['UpdateURI'] ), PHP_URL_HOST ); |
16 | 475 |
|
18 | 476 |
/** |
477 |
* Filters the update response for a given plugin hostname. |
|
478 |
* |
|
479 |
* The dynamic portion of the hook name, `$hostname`, refers to the hostname |
|
480 |
* of the URI specified in the `Update URI` header field. |
|
481 |
* |
|
482 |
* @since 5.8.0 |
|
483 |
* |
|
484 |
* @param array|false $update { |
|
485 |
* The plugin update data with the latest details. Default false. |
|
486 |
* |
|
487 |
* @type string $id Optional. ID of the plugin for update purposes, should be a URI |
|
488 |
* specified in the `Update URI` header field. |
|
489 |
* @type string $slug Slug of the plugin. |
|
490 |
* @type string $version The version of the plugin. |
|
491 |
* @type string $url The URL for details of the plugin. |
|
492 |
* @type string $package Optional. The update ZIP for the plugin. |
|
493 |
* @type string $tested Optional. The version of WordPress the plugin is tested against. |
|
494 |
* @type string $requires_php Optional. The version of PHP which the plugin requires. |
|
495 |
* @type bool $autoupdate Optional. Whether the plugin should automatically update. |
|
496 |
* @type array $icons Optional. Array of plugin icons. |
|
497 |
* @type array $banners Optional. Array of plugin banners. |
|
498 |
* @type array $banners_rtl Optional. Array of plugin RTL banners. |
|
499 |
* @type array $translations { |
|
500 |
* Optional. List of translation updates for the plugin. |
|
501 |
* |
|
502 |
* @type string $language The language the translation update is for. |
|
503 |
* @type string $version The version of the plugin this translation is for. |
|
504 |
* This is not the version of the language file. |
|
505 |
* @type string $updated The update timestamp of the translation file. |
|
506 |
* Should be a date in the `YYYY-MM-DD HH:MM:SS` format. |
|
507 |
* @type string $package The ZIP location containing the translation update. |
|
508 |
* @type string $autoupdate Whether the translation should be automatically installed. |
|
509 |
* } |
|
510 |
* } |
|
511 |
* @param array $plugin_data Plugin headers. |
|
512 |
* @param string $plugin_file Plugin filename. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
* @param string[] $locales Installed locales to look up translations for. |
18 | 514 |
*/ |
515 |
$update = apply_filters( "update_plugins_{$hostname}", false, $plugin_data, $plugin_file, $locales ); |
|
16 | 516 |
|
18 | 517 |
if ( ! $update ) { |
518 |
continue; |
|
519 |
} |
|
520 |
||
521 |
$update = (object) $update; |
|
522 |
||
523 |
// Is it valid? We require at least a version. |
|
524 |
if ( ! isset( $update->version ) ) { |
|
525 |
continue; |
|
526 |
} |
|
527 |
||
528 |
// These should remain constant. |
|
529 |
$update->id = $plugin_data['UpdateURI']; |
|
530 |
$update->plugin = $plugin_file; |
|
531 |
||
532 |
// WordPress needs the version field specified as 'new_version'. |
|
533 |
if ( ! isset( $update->new_version ) ) { |
|
534 |
$update->new_version = $update->version; |
|
535 |
} |
|
536 |
||
537 |
// Handle any translation updates. |
|
538 |
if ( ! empty( $update->translations ) ) { |
|
539 |
foreach ( $update->translations as $translation ) { |
|
540 |
if ( isset( $translation['language'], $translation['package'] ) ) { |
|
541 |
$translation['type'] = 'plugin'; |
|
542 |
$translation['slug'] = isset( $update->slug ) ? $update->slug : $update->id; |
|
543 |
||
544 |
$updates->translations[] = $translation; |
|
545 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
} |
18 | 548 |
|
549 |
unset( $updates->no_update[ $plugin_file ], $updates->response[ $plugin_file ] ); |
|
550 |
||
551 |
if ( version_compare( $update->new_version, $plugin_data['Version'], '>' ) ) { |
|
552 |
$updates->response[ $plugin_file ] = $update; |
|
553 |
} else { |
|
554 |
$updates->no_update[ $plugin_file ] = $update; |
|
555 |
} |
|
0 | 556 |
} |
16 | 557 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
558 |
$sanitize_plugin_update_payload = static function ( &$item ) { |
18 | 559 |
$item = (object) $item; |
16 | 560 |
|
18 | 561 |
unset( $item->translations, $item->compatibility ); |
0 | 562 |
|
18 | 563 |
return $item; |
564 |
}; |
|
0 | 565 |
|
18 | 566 |
array_walk( $updates->response, $sanitize_plugin_update_payload ); |
567 |
array_walk( $updates->no_update, $sanitize_plugin_update_payload ); |
|
568 |
||
569 |
set_site_transient( 'update_plugins', $updates ); |
|
0 | 570 |
} |
571 |
||
572 |
/** |
|
16 | 573 |
* Checks for available updates to themes based on the latest versions hosted on WordPress.org. |
574 |
* |
|
575 |
* Despite its name this function does not actually perform any updates, it only checks for available updates. |
|
0 | 576 |
* |
16 | 577 |
* A list of all themes installed is sent to WP, along with the site locale. |
578 |
* |
|
579 |
* Checks against the WordPress server at api.wordpress.org. Will only check |
|
580 |
* if WordPress isn't installing. |
|
0 | 581 |
* |
582 |
* @since 2.7.0 |
|
583 |
* |
|
16 | 584 |
* @global string $wp_version The WordPress version string. |
585 |
* |
|
5 | 586 |
* @param array $extra_stats Extra statistics to report to the WordPress.org API. |
0 | 587 |
*/ |
5 | 588 |
function wp_update_themes( $extra_stats = array() ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
if ( wp_installing() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
} |
0 | 592 |
|
16 | 593 |
// Include an unmodified $wp_version. |
594 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 595 |
|
596 |
$installed_themes = wp_get_themes(); |
|
9 | 597 |
$translations = wp_get_installed_translations( 'themes' ); |
0 | 598 |
|
599 |
$last_update = get_site_transient( 'update_themes' ); |
|
16 | 600 |
|
9 | 601 |
if ( ! is_object( $last_update ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
602 |
$last_update = new stdClass(); |
9 | 603 |
} |
0 | 604 |
|
16 | 605 |
$themes = array(); |
606 |
$checked = array(); |
|
607 |
$request = array(); |
|
0 | 608 |
|
19 | 609 |
// Put slug of active theme into request. |
0 | 610 |
$request['active'] = get_option( 'stylesheet' ); |
611 |
||
612 |
foreach ( $installed_themes as $theme ) { |
|
9 | 613 |
$checked[ $theme->get_stylesheet() ] = $theme->get( 'Version' ); |
0 | 614 |
|
615 |
$themes[ $theme->get_stylesheet() ] = array( |
|
9 | 616 |
'Name' => $theme->get( 'Name' ), |
617 |
'Title' => $theme->get( 'Name' ), |
|
618 |
'Version' => $theme->get( 'Version' ), |
|
619 |
'Author' => $theme->get( 'Author' ), |
|
620 |
'Author URI' => $theme->get( 'AuthorURI' ), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
621 |
'UpdateURI' => $theme->get( 'UpdateURI' ), |
0 | 622 |
'Template' => $theme->get_template(), |
623 |
'Stylesheet' => $theme->get_stylesheet(), |
|
624 |
); |
|
625 |
} |
|
626 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
$doing_cron = wp_doing_cron(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
|
0 | 629 |
// Check for update on a different schedule, depending on the page. |
630 |
switch ( current_filter() ) { |
|
9 | 631 |
case 'upgrader_process_complete': |
0 | 632 |
$timeout = 0; |
633 |
break; |
|
9 | 634 |
case 'load-update-core.php': |
0 | 635 |
$timeout = MINUTE_IN_SECONDS; |
636 |
break; |
|
9 | 637 |
case 'load-themes.php': |
638 |
case 'load-update.php': |
|
0 | 639 |
$timeout = HOUR_IN_SECONDS; |
640 |
break; |
|
9 | 641 |
default: |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
if ( $doing_cron ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
$timeout = 2 * HOUR_IN_SECONDS; |
5 | 644 |
} else { |
645 |
$timeout = 12 * HOUR_IN_SECONDS; |
|
646 |
} |
|
0 | 647 |
} |
648 |
||
649 |
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked ); |
|
650 |
||
5 | 651 |
if ( $time_not_changed && ! $extra_stats ) { |
0 | 652 |
$theme_changed = false; |
16 | 653 |
|
0 | 654 |
foreach ( $checked as $slug => $v ) { |
18 | 655 |
if ( ! isset( $last_update->checked[ $slug ] ) || (string) $last_update->checked[ $slug ] !== (string) $v ) { |
0 | 656 |
$theme_changed = true; |
9 | 657 |
} |
0 | 658 |
} |
659 |
||
9 | 660 |
if ( isset( $last_update->response ) && is_array( $last_update->response ) ) { |
0 | 661 |
foreach ( $last_update->response as $slug => $update_details ) { |
9 | 662 |
if ( ! isset( $checked[ $slug ] ) ) { |
0 | 663 |
$theme_changed = true; |
664 |
break; |
|
665 |
} |
|
666 |
} |
|
667 |
} |
|
668 |
||
16 | 669 |
// Bail if we've checked recently and if nothing has changed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
if ( ! $theme_changed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
} |
0 | 673 |
} |
674 |
||
16 | 675 |
// Update last_checked for current to prevent multiple blocking requests if request hangs. |
0 | 676 |
$last_update->last_checked = time(); |
677 |
set_site_transient( 'update_themes', $last_update ); |
|
678 |
||
679 |
$request['themes'] = $themes; |
|
680 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
$locales = array_values( get_available_languages() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
|
0 | 683 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
684 |
* Filters the locales requested for theme translations. |
0 | 685 |
* |
686 |
* @since 3.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
* @since 4.5.0 The default value of the `$locales` parameter changed to include all locales. |
0 | 688 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
689 |
* @param string[] $locales Theme locales. Default is all available locales of the site. |
0 | 690 |
*/ |
691 |
$locales = apply_filters( 'themes_update_check_locales', $locales ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
$locales = array_unique( $locales ); |
0 | 693 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
if ( $doing_cron ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
695 |
$timeout = 30; // 30 seconds. |
5 | 696 |
} else { |
16 | 697 |
// Three seconds, plus one extra second for every 10 themes. |
5 | 698 |
$timeout = 3 + (int) ( count( $themes ) / 10 ); |
699 |
} |
|
700 |
||
0 | 701 |
$options = array( |
9 | 702 |
'timeout' => $timeout, |
703 |
'body' => array( |
|
5 | 704 |
'themes' => wp_json_encode( $request ), |
705 |
'translations' => wp_json_encode( $translations ), |
|
706 |
'locale' => wp_json_encode( $locales ), |
|
0 | 707 |
), |
9 | 708 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
0 | 709 |
); |
710 |
||
5 | 711 |
if ( $extra_stats ) { |
712 |
$options['body']['update_stats'] = wp_json_encode( $extra_stats ); |
|
713 |
} |
|
714 |
||
16 | 715 |
$url = 'http://api.wordpress.org/themes/update-check/1.1/'; |
716 |
$http_url = $url; |
|
717 |
$ssl = wp_http_supports( array( 'ssl' ) ); |
|
718 |
||
719 |
if ( $ssl ) { |
|
0 | 720 |
$url = set_url_scheme( $url, 'https' ); |
9 | 721 |
} |
0 | 722 |
|
723 |
$raw_response = wp_remote_post( $url, $options ); |
|
16 | 724 |
|
0 | 725 |
if ( $ssl && is_wp_error( $raw_response ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
726 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
727 |
__FUNCTION__, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
sprintf( |
16 | 729 |
/* translators: %s: Support forums URL. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), |
16 | 731 |
__( 'https://wordpress.org/support/forums/' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
); |
0 | 735 |
$raw_response = wp_remote_post( $http_url, $options ); |
736 |
} |
|
737 |
||
16 | 738 |
if ( is_wp_error( $raw_response ) || 200 !== wp_remote_retrieve_response_code( $raw_response ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
} |
0 | 741 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
742 |
$new_update = new stdClass(); |
0 | 743 |
$new_update->last_checked = time(); |
9 | 744 |
$new_update->checked = $checked; |
0 | 745 |
|
746 |
$response = json_decode( wp_remote_retrieve_body( $raw_response ), true ); |
|
747 |
||
748 |
if ( is_array( $response ) ) { |
|
749 |
$new_update->response = $response['themes']; |
|
16 | 750 |
$new_update->no_update = $response['no_update']; |
0 | 751 |
$new_update->translations = $response['translations']; |
752 |
} |
|
753 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
754 |
// Support updates for any themes using the `Update URI` header field. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
755 |
foreach ( $themes as $theme_stylesheet => $theme_data ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
756 |
if ( ! $theme_data['UpdateURI'] || isset( $new_update->response[ $theme_stylesheet ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
757 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
758 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
759 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
760 |
$hostname = wp_parse_url( sanitize_url( $theme_data['UpdateURI'] ), PHP_URL_HOST ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
761 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
762 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
763 |
* Filters the update response for a given theme hostname. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
764 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
765 |
* The dynamic portion of the hook name, `$hostname`, refers to the hostname |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
766 |
* of the URI specified in the `Update URI` header field. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
767 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
768 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
769 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
770 |
* @param array|false $update { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
771 |
* The theme update data with the latest details. Default false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
772 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
773 |
* @type string $id Optional. ID of the theme for update purposes, should be a URI |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
774 |
* specified in the `Update URI` header field. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
775 |
* @type string $theme Directory name of the theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
776 |
* @type string $version The version of the theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
777 |
* @type string $url The URL for details of the theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
778 |
* @type string $package Optional. The update ZIP for the theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
779 |
* @type string $tested Optional. The version of WordPress the theme is tested against. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
780 |
* @type string $requires_php Optional. The version of PHP which the theme requires. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
781 |
* @type bool $autoupdate Optional. Whether the theme should automatically update. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
782 |
* @type array $translations { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
783 |
* Optional. List of translation updates for the theme. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
784 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
785 |
* @type string $language The language the translation update is for. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
786 |
* @type string $version The version of the theme this translation is for. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
787 |
* This is not the version of the language file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
788 |
* @type string $updated The update timestamp of the translation file. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
789 |
* Should be a date in the `YYYY-MM-DD HH:MM:SS` format. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
790 |
* @type string $package The ZIP location containing the translation update. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
791 |
* @type string $autoupdate Whether the translation should be automatically installed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
792 |
* } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
793 |
* } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
794 |
* @param array $theme_data Theme headers. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
795 |
* @param string $theme_stylesheet Theme stylesheet. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
796 |
* @param string[] $locales Installed locales to look up translations for. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
797 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
798 |
$update = apply_filters( "update_themes_{$hostname}", false, $theme_data, $theme_stylesheet, $locales ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
799 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
800 |
if ( ! $update ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
801 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
802 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
803 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
804 |
$update = (object) $update; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
805 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
806 |
// Is it valid? We require at least a version. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
807 |
if ( ! isset( $update->version ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
808 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
809 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
810 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
811 |
// This should remain constant. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
812 |
$update->id = $theme_data['UpdateURI']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
813 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
814 |
// WordPress needs the version field specified as 'new_version'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
815 |
if ( ! isset( $update->new_version ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
816 |
$update->new_version = $update->version; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
817 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
818 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
819 |
// Handle any translation updates. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
820 |
if ( ! empty( $update->translations ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
821 |
foreach ( $update->translations as $translation ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
822 |
if ( isset( $translation['language'], $translation['package'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
823 |
$translation['type'] = 'theme'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
824 |
$translation['slug'] = isset( $update->theme ) ? $update->theme : $update->id; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
825 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
826 |
$new_update->translations[] = $translation; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
827 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
828 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
829 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
830 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
831 |
unset( $new_update->no_update[ $theme_stylesheet ], $new_update->response[ $theme_stylesheet ] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
832 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
833 |
if ( version_compare( $update->new_version, $theme_data['Version'], '>' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
834 |
$new_update->response[ $theme_stylesheet ] = (array) $update; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
835 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
836 |
$new_update->no_update[ $theme_stylesheet ] = (array) $update; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
837 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
838 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
839 |
|
0 | 840 |
set_site_transient( 'update_themes', $new_update ); |
841 |
} |
|
842 |
||
843 |
/** |
|
844 |
* Performs WordPress automatic background updates. |
|
845 |
* |
|
16 | 846 |
* Updates WordPress core plus any plugins and themes that have automatic updates enabled. |
847 |
* |
|
0 | 848 |
* @since 3.7.0 |
849 |
*/ |
|
850 |
function wp_maybe_auto_update() { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
851 |
require_once ABSPATH . 'wp-admin/includes/admin.php'; |
16 | 852 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
0 | 853 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
854 |
$upgrader = new WP_Automatic_Updater(); |
0 | 855 |
$upgrader->run(); |
856 |
} |
|
857 |
||
858 |
/** |
|
859 |
* Retrieves a list of all language updates available. |
|
860 |
* |
|
861 |
* @since 3.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
* |
9 | 863 |
* @return object[] Array of translation objects that have available updates. |
0 | 864 |
*/ |
865 |
function wp_get_translation_updates() { |
|
9 | 866 |
$updates = array(); |
867 |
$transients = array( |
|
868 |
'update_core' => 'core', |
|
869 |
'update_plugins' => 'plugin', |
|
870 |
'update_themes' => 'theme', |
|
871 |
); |
|
16 | 872 |
|
0 | 873 |
foreach ( $transients as $transient => $type ) { |
874 |
$transient = get_site_transient( $transient ); |
|
16 | 875 |
|
9 | 876 |
if ( empty( $transient->translations ) ) { |
0 | 877 |
continue; |
9 | 878 |
} |
0 | 879 |
|
880 |
foreach ( $transient->translations as $translation ) { |
|
881 |
$updates[] = (object) $translation; |
|
882 |
} |
|
883 |
} |
|
16 | 884 |
|
0 | 885 |
return $updates; |
886 |
} |
|
887 |
||
5 | 888 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
889 |
* Collects counts and UI strings for available updates. |
0 | 890 |
* |
891 |
* @since 3.3.0 |
|
892 |
* |
|
893 |
* @return array |
|
894 |
*/ |
|
895 |
function wp_get_update_data() { |
|
9 | 896 |
$counts = array( |
897 |
'plugins' => 0, |
|
898 |
'themes' => 0, |
|
899 |
'wordpress' => 0, |
|
900 |
'translations' => 0, |
|
901 |
); |
|
0 | 902 |
|
16 | 903 |
$plugins = current_user_can( 'update_plugins' ); |
904 |
||
905 |
if ( $plugins ) { |
|
0 | 906 |
$update_plugins = get_site_transient( 'update_plugins' ); |
16 | 907 |
|
9 | 908 |
if ( ! empty( $update_plugins->response ) ) { |
0 | 909 |
$counts['plugins'] = count( $update_plugins->response ); |
9 | 910 |
} |
0 | 911 |
} |
912 |
||
16 | 913 |
$themes = current_user_can( 'update_themes' ); |
914 |
||
915 |
if ( $themes ) { |
|
0 | 916 |
$update_themes = get_site_transient( 'update_themes' ); |
16 | 917 |
|
9 | 918 |
if ( ! empty( $update_themes->response ) ) { |
0 | 919 |
$counts['themes'] = count( $update_themes->response ); |
9 | 920 |
} |
0 | 921 |
} |
922 |
||
16 | 923 |
$core = current_user_can( 'update_core' ); |
924 |
||
925 |
if ( $core && function_exists( 'get_core_updates' ) ) { |
|
9 | 926 |
$update_wordpress = get_core_updates( array( 'dismissed' => false ) ); |
16 | 927 |
|
928 |
if ( ! empty( $update_wordpress ) |
|
929 |
&& ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ), true ) |
|
930 |
&& current_user_can( 'update_core' ) |
|
931 |
) { |
|
0 | 932 |
$counts['wordpress'] = 1; |
9 | 933 |
} |
0 | 934 |
} |
935 |
||
9 | 936 |
if ( ( $core || $plugins || $themes ) && wp_get_translation_updates() ) { |
0 | 937 |
$counts['translations'] = 1; |
9 | 938 |
} |
0 | 939 |
|
940 |
$counts['total'] = $counts['plugins'] + $counts['themes'] + $counts['wordpress'] + $counts['translations']; |
|
9 | 941 |
$titles = array(); |
16 | 942 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
if ( $counts['wordpress'] ) { |
16 | 944 |
/* translators: %d: Number of available WordPress updates. */ |
9 | 945 |
$titles['wordpress'] = sprintf( __( '%d WordPress Update' ), $counts['wordpress'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
} |
16 | 947 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
if ( $counts['plugins'] ) { |
16 | 949 |
/* translators: %d: Number of available plugin updates. */ |
0 | 950 |
$titles['plugins'] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $counts['plugins'] ), $counts['plugins'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
} |
16 | 952 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
if ( $counts['themes'] ) { |
16 | 954 |
/* translators: %d: Number of available theme updates. */ |
0 | 955 |
$titles['themes'] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $counts['themes'] ), $counts['themes'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
} |
16 | 957 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
if ( $counts['translations'] ) { |
0 | 959 |
$titles['translations'] = __( 'Translation Updates' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
} |
0 | 961 |
|
962 |
$update_title = $titles ? esc_attr( implode( ', ', $titles ) ) : ''; |
|
963 |
||
9 | 964 |
$update_data = array( |
965 |
'counts' => $counts, |
|
966 |
'title' => $update_title, |
|
967 |
); |
|
0 | 968 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
* Filters the returned array of update data for plugins, themes, and WordPress core. |
0 | 970 |
* |
971 |
* @since 3.5.0 |
|
972 |
* |
|
973 |
* @param array $update_data { |
|
974 |
* Fetched update data. |
|
975 |
* |
|
976 |
* @type array $counts An array of counts for available plugin, theme, and WordPress updates. |
|
977 |
* @type string $update_title Titles of available updates. |
|
978 |
* } |
|
979 |
* @param array $titles An array of update counts and UI strings for available updates. |
|
980 |
*/ |
|
981 |
return apply_filters( 'wp_get_update_data', $update_data, $titles ); |
|
982 |
} |
|
983 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
* Determines whether core should be updated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
* |
16 | 989 |
* @global string $wp_version The WordPress version string. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
*/ |
0 | 991 |
function _maybe_update_core() { |
16 | 992 |
// Include an unmodified $wp_version. |
993 |
require ABSPATH . WPINC . '/version.php'; |
|
0 | 994 |
|
995 |
$current = get_site_transient( 'update_core' ); |
|
996 |
||
16 | 997 |
if ( isset( $current->last_checked, $current->version_checked ) |
998 |
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) |
|
999 |
&& $current->version_checked === $wp_version |
|
1000 |
) { |
|
0 | 1001 |
return; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
} |
16 | 1003 |
|
0 | 1004 |
wp_version_check(); |
1005 |
} |
|
1006 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1007 |
* Checks the last time plugins were run before checking plugin versions. |
0 | 1008 |
* |
1009 |
* This might have been backported to WordPress 2.6.1 for performance reasons. |
|
1010 |
* This is used for the wp-admin to check only so often instead of every page |
|
1011 |
* load. |
|
1012 |
* |
|
1013 |
* @since 2.7.0 |
|
1014 |
* @access private |
|
1015 |
*/ |
|
1016 |
function _maybe_update_plugins() { |
|
1017 |
$current = get_site_transient( 'update_plugins' ); |
|
16 | 1018 |
|
1019 |
if ( isset( $current->last_checked ) |
|
1020 |
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) |
|
1021 |
) { |
|
0 | 1022 |
return; |
9 | 1023 |
} |
16 | 1024 |
|
0 | 1025 |
wp_update_plugins(); |
1026 |
} |
|
1027 |
||
1028 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1029 |
* Checks themes versions only after a duration of time. |
0 | 1030 |
* |
1031 |
* This is for performance reasons to make sure that on the theme version |
|
1032 |
* checker is not run on every page load. |
|
1033 |
* |
|
1034 |
* @since 2.7.0 |
|
1035 |
* @access private |
|
1036 |
*/ |
|
1037 |
function _maybe_update_themes() { |
|
1038 |
$current = get_site_transient( 'update_themes' ); |
|
16 | 1039 |
|
1040 |
if ( isset( $current->last_checked ) |
|
1041 |
&& 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) |
|
1042 |
) { |
|
0 | 1043 |
return; |
9 | 1044 |
} |
16 | 1045 |
|
0 | 1046 |
wp_update_themes(); |
1047 |
} |
|
1048 |
||
1049 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1050 |
* Schedules core, theme, and plugin update checks. |
0 | 1051 |
* |
1052 |
* @since 3.1.0 |
|
1053 |
*/ |
|
1054 |
function wp_schedule_update_checks() { |
|
9 | 1055 |
if ( ! wp_next_scheduled( 'wp_version_check' ) && ! wp_installing() ) { |
1056 |
wp_schedule_event( time(), 'twicedaily', 'wp_version_check' ); |
|
1057 |
} |
|
0 | 1058 |
|
9 | 1059 |
if ( ! wp_next_scheduled( 'wp_update_plugins' ) && ! wp_installing() ) { |
1060 |
wp_schedule_event( time(), 'twicedaily', 'wp_update_plugins' ); |
|
1061 |
} |
|
0 | 1062 |
|
9 | 1063 |
if ( ! wp_next_scheduled( 'wp_update_themes' ) && ! wp_installing() ) { |
1064 |
wp_schedule_event( time(), 'twicedaily', 'wp_update_themes' ); |
|
1065 |
} |
|
0 | 1066 |
} |
1067 |
||
5 | 1068 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1069 |
* Clears existing update caches for plugins, themes, and core. |
5 | 1070 |
* |
1071 |
* @since 4.1.0 |
|
1072 |
*/ |
|
1073 |
function wp_clean_update_cache() { |
|
1074 |
if ( function_exists( 'wp_clean_plugins_cache' ) ) { |
|
1075 |
wp_clean_plugins_cache(); |
|
1076 |
} else { |
|
1077 |
delete_site_transient( 'update_plugins' ); |
|
1078 |
} |
|
16 | 1079 |
|
5 | 1080 |
wp_clean_themes_cache(); |
16 | 1081 |
|
5 | 1082 |
delete_site_transient( 'update_core' ); |
1083 |
} |
|
1084 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1085 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1086 |
* Schedules the removal of all contents in the temporary backup directory. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1087 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1088 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1089 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1090 |
function wp_delete_all_temp_backups() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1091 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1092 |
* Check if there is a lock, or if currently performing an Ajax request, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1093 |
* in which case there is a chance an update is running. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1094 |
* Reschedule for an hour from now and exit early. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1095 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1096 |
if ( get_option( 'core_updater.lock' ) || get_option( 'auto_updater.lock' ) || wp_doing_ajax() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1097 |
wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_delete_temp_updater_backups' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1098 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1099 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1100 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1101 |
// This action runs on shutdown to make sure there are no plugin updates currently running. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1102 |
add_action( 'shutdown', '_wp_delete_all_temp_backups' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1103 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1104 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1105 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1106 |
* Deletes all contents in the temporary backup directory. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1107 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1108 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1109 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1110 |
* @access private |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1111 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1112 |
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1113 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1114 |
* @return void|WP_Error Void on success, or a WP_Error object on failure. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1115 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1116 |
function _wp_delete_all_temp_backups() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1117 |
global $wp_filesystem; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1118 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1119 |
if ( ! function_exists( 'WP_Filesystem' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1120 |
require_once ABSPATH . '/wp-admin/includes/file.php'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1121 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1122 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1123 |
ob_start(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1124 |
$credentials = request_filesystem_credentials( '' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1125 |
ob_end_clean(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1126 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1127 |
if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1128 |
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1129 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1130 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1131 |
if ( ! $wp_filesystem->wp_content_dir() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1132 |
return new WP_Error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1133 |
'fs_no_content_dir', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1134 |
/* translators: %s: Directory name. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1135 |
sprintf( __( 'Unable to locate WordPress content directory (%s).' ), 'wp-content' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1136 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1137 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1138 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1139 |
$temp_backup_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1140 |
$dirlist = $wp_filesystem->dirlist( $temp_backup_dir ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1141 |
$dirlist = $dirlist ? $dirlist : array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1142 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1143 |
foreach ( array_keys( $dirlist ) as $dir ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1144 |
if ( '.' === $dir || '..' === $dir ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1145 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1146 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1147 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1148 |
$wp_filesystem->delete( $temp_backup_dir . $dir, true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1149 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1150 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1151 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) { |
0 | 1153 |
return; |
5 | 1154 |
} |
0 | 1155 |
|
1156 |
add_action( 'admin_init', '_maybe_update_core' ); |
|
1157 |
add_action( 'wp_version_check', 'wp_version_check' ); |
|
1158 |
||
1159 |
add_action( 'load-plugins.php', 'wp_update_plugins' ); |
|
1160 |
add_action( 'load-update.php', 'wp_update_plugins' ); |
|
1161 |
add_action( 'load-update-core.php', 'wp_update_plugins' ); |
|
1162 |
add_action( 'admin_init', '_maybe_update_plugins' ); |
|
1163 |
add_action( 'wp_update_plugins', 'wp_update_plugins' ); |
|
1164 |
||
1165 |
add_action( 'load-themes.php', 'wp_update_themes' ); |
|
1166 |
add_action( 'load-update.php', 'wp_update_themes' ); |
|
1167 |
add_action( 'load-update-core.php', 'wp_update_themes' ); |
|
1168 |
add_action( 'admin_init', '_maybe_update_themes' ); |
|
1169 |
add_action( 'wp_update_themes', 'wp_update_themes' ); |
|
5 | 1170 |
|
9 | 1171 |
add_action( 'update_option_WPLANG', 'wp_clean_update_cache', 10, 0 ); |
0 | 1172 |
|
1173 |
add_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); |
|
1174 |
||
5 | 1175 |
add_action( 'init', 'wp_schedule_update_checks' ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1176 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1177 |
add_action( 'wp_delete_temp_updater_backups', 'wp_delete_all_temp_backups' ); |