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