2016-05-10 13:11:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2016-05-10 13:31:28 +02:00
|
|
|
* Upgrader API: WP_Upgrader_Skin class
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Upgrader
|
2016-05-10 13:31:28 +02:00
|
|
|
* @since 4.6.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-13 22:59:27 +02:00
|
|
|
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
Code Modernization: Add `AllowDynamicProperties` attribute to all (parent) classes.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.
Trac ticket #56034 is open to investigate and handle the third and fourth type of situations, however it has become clear this will need more time and will not be ready in time for WP 6.1.
To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP.
The logic used for this commit is as follows:
* If a class already has the attribute: no action needed.
* If a class does not `extend`: add the attribute.
* If a class does `extend`:
- If it extends `stdClass`: no action needed (as `stdClass` supports dynamic properties).
- If it extends a PHP native class: add the attribute.
- If it extends a class from one of WP's external dependencies: add the attribute.
* In all other cases: no action — the attribute should not be needed as child classes inherit from the parent.
Whether or not a class contains magic methods has not been taken into account, as a review of the currently existing magic methods has shown that those are generally not sturdy enough and often even set dynamic properties (which they should not). See the [https://www.youtube.com/watch?v=vDZWepDQQVE live stream from August 16, 2022] for more details.
This commit only affects classes in the `src` directory of WordPress core.
* Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033.
* While a number bundled themes (2014, 2019, 2020, 2021) contain classes, they are not a part of this commit and may be updated separately.
Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].
Follow-up to [53922].
Props jrf, hellofromTonya, markjaquith, peterwilsoncc, costdev, knutsp, aristath.
See #56513, #56034.
Built from https://develop.svn.wordpress.org/trunk@54133
git-svn-id: http://core.svn.wordpress.org/trunk@53692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-12 17:47:14 +02:00
|
|
|
#[AllowDynamicProperties]
|
2016-05-10 13:11:30 +02:00
|
|
|
class WP_Upgrader_Skin {
|
|
|
|
|
2020-07-28 13:57:03 +02:00
|
|
|
/**
|
|
|
|
* Holds the upgrader data.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
2020-10-10 21:14:04 +02:00
|
|
|
* @var WP_Upgrader
|
2020-07-28 13:57:03 +02:00
|
|
|
*/
|
2016-05-10 13:11:30 +02:00
|
|
|
public $upgrader;
|
2020-07-28 13:57:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether header is done.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
2016-05-10 13:11:30 +02:00
|
|
|
public $done_header = false;
|
2020-07-28 13:57:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether footer is done.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
2016-05-10 13:11:30 +02:00
|
|
|
public $done_footer = false;
|
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
|
|
|
|
|
|
|
/**
|
2016-07-22 12:43:29 +02:00
|
|
|
* Holds the result of an upgrade.
|
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
|
|
|
*
|
2016-07-22 12:43:29 +02:00
|
|
|
* @since 2.8.0
|
2020-07-28 13:57:03 +02:00
|
|
|
*
|
2016-07-22 12:43:29 +02:00
|
|
|
* @var string|bool|WP_Error
|
Update/Install: Shiny Updates v2.
Gone are the days of isolation and feelings of "meh", brought on by The Bleak Screen of Sadness. For a shiny knight has arrived to usher our plugins and themes along their arduous journey of installation, updates, and the inevitable fate of ultimate deletion.
Props swissspidy, adamsilverstein, mapk, afragen, ocean90, ryelle, j-falk, michael-arestad, melchoyce, DrewAPicture, AdamSoucie, ethitter, pento, dd32, kraftbj, Ipstenu, jorbin, afercia, stephdau, paulwilde, jipmoors, khag7, svovaf, jipmoors, obenland.
Fixes #22029, #25828, #31002, #31529, #31530, #31773, #33637, #35032.
Built from https://develop.svn.wordpress.org/trunk@37714
git-svn-id: http://core.svn.wordpress.org/trunk@37680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 18:37:29 +02:00
|
|
|
*/
|
2020-07-28 13:57:03 +02:00
|
|
|
public $result = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds the options of an upgrade.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-05-10 13:11:30 +02:00
|
|
|
public $options = array();
|
|
|
|
|
|
|
|
/**
|
2020-07-28 13:57:03 +02:00
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* Sets up the generic skin for the WordPress Upgrader classes.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
|
|
|
* @param array $args Optional. The WordPress upgrader skin arguments to
|
|
|
|
* override default options. Default empty array.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
public function __construct( $args = array() ) {
|
|
|
|
$defaults = array(
|
|
|
|
'url' => '',
|
|
|
|
'nonce' => '',
|
|
|
|
'title' => '',
|
|
|
|
'context' => false,
|
|
|
|
);
|
|
|
|
$this->options = wp_parse_args( $args, $defaults );
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 2.8.0
|
|
|
|
*
|
2016-05-10 13:11:30 +02:00
|
|
|
* @param WP_Upgrader $upgrader
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
public function set_upgrader( &$upgrader ) {
|
|
|
|
if ( is_object( $upgrader ) ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
$this->upgrader =& $upgrader;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
$this->add_strings();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 3.0.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function add_strings() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-07-22 12:43:29 +02:00
|
|
|
* Sets the result of an upgrade.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
2016-07-22 12:43:29 +02:00
|
|
|
* @param string|bool|WP_Error $result The result of an upgrade.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
2016-07-22 12:43:29 +02:00
|
|
|
public function set_result( $result ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
$this->result = $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-07-22 14:10:27 +02:00
|
|
|
* Displays a form to the user to request for their FTP/SSH details in order
|
|
|
|
* to connect to the filesystem.
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
2016-07-22 14:10:27 +02:00
|
|
|
* @since 2.8.0
|
|
|
|
* @since 4.6.0 The `$context` parameter default changed from `false` to an empty string.
|
|
|
|
*
|
|
|
|
* @see request_filesystem_credentials()
|
|
|
|
*
|
2019-10-27 01:16:04 +02:00
|
|
|
* @param bool|WP_Error $error Optional. Whether the current request has failed to connect,
|
|
|
|
* or an error object. Default false.
|
|
|
|
* @param string $context Optional. Full path to the directory that is tested
|
|
|
|
* for being writable. Default empty.
|
|
|
|
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
|
2020-01-11 19:32:05 +01:00
|
|
|
* @return bool True on success, false on failure.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
2016-07-22 14:10:27 +02:00
|
|
|
public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
$url = $this->options['url'];
|
|
|
|
if ( ! $context ) {
|
|
|
|
$context = $this->options['context'];
|
|
|
|
}
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $this->options['nonce'] ) ) {
|
|
|
|
$url = wp_nonce_url( $url, $this->options['nonce'] );
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$extra_fields = array();
|
|
|
|
|
|
|
|
return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 2.8.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function header() {
|
|
|
|
if ( $this->done_header ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->done_header = true;
|
|
|
|
echo '<div class="wrap">';
|
|
|
|
echo '<h1>' . $this->options['title'] . '</h1>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 2.8.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function footer() {
|
|
|
|
if ( $this->done_footer ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->done_footer = true;
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 2.8.0
|
|
|
|
*
|
2021-09-09 15:59:56 +02:00
|
|
|
* @param string|WP_Error $errors Errors.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
public function error( $errors ) {
|
|
|
|
if ( ! $this->done_header ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
$this->header();
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
|
|
|
if ( is_string( $errors ) ) {
|
|
|
|
$this->feedback( $errors );
|
2018-02-27 03:31:31 +01:00
|
|
|
} elseif ( is_wp_error( $errors ) && $errors->has_errors() ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
foreach ( $errors->get_error_messages() as $message ) {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
|
|
|
|
$this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
|
|
|
|
} else {
|
|
|
|
$this->feedback( $message );
|
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 2.8.0
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
* @since 5.9.0 Renamed `$string` (a PHP reserved keyword) to `$feedback` for PHP 8 named parameter support.
|
2020-11-21 13:08:05 +01:00
|
|
|
*
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
* @param string $feedback Message data.
|
|
|
|
* @param mixed ...$args Optional text replacements.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
public function feedback( $feedback, ...$args ) {
|
|
|
|
if ( isset( $this->upgrader->strings[ $feedback ] ) ) {
|
|
|
|
$feedback = $this->upgrader->strings[ $feedback ];
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
|
Code Modernization: Replace usage of `strpos()` with `str_contains()`.
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].
Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988
git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 16:36:26 +02:00
|
|
|
if ( str_contains( $feedback, '%' ) ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
if ( $args ) {
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
$args = array_map( 'strip_tags', $args );
|
|
|
|
$args = array_map( 'esc_html', $args );
|
|
|
|
$feedback = vsprintf( $feedback, $args );
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
}
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
if ( empty( $feedback ) ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
return;
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `WP_Upgrader_Skin::feedback()`.
In the parent class, renames the parameter `$string` to `$feedback`.
Why? `string` is a PHP reserved keyword.
In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
Changes for readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.
Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51781
git-svn-id: http://core.svn.wordpress.org/trunk@51388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 15:48:56 +02:00
|
|
|
show_message( $feedback );
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 08:34:27 +02:00
|
|
|
* Performs an action before an update.
|
2020-07-28 13:57:03 +02:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function before() {}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 08:34:27 +02:00
|
|
|
* Performs and action following an update.
|
2020-07-28 13:57:03 +02:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function after() {}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 08:34:27 +02:00
|
|
|
* Outputs JavaScript that calls function to decrement the update counts.
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
|
|
|
* @since 3.9.0
|
|
|
|
*
|
|
|
|
* @param string $type Type of update count to decrement. Likely values include 'plugin',
|
|
|
|
* 'theme', 'translation', etc.
|
|
|
|
*/
|
|
|
|
protected function decrement_update_count( $type ) {
|
|
|
|
if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( defined( 'IFRAME_REQUEST' ) ) {
|
|
|
|
echo '<script type="text/javascript">
|
|
|
|
if ( window.postMessage && JSON ) {
|
2023-12-01 02:35:28 +01:00
|
|
|
window.parent.postMessage(
|
|
|
|
JSON.stringify( {
|
|
|
|
action: "decrementUpdateCount",
|
|
|
|
upgradeType: "' . $type . '"
|
|
|
|
} ),
|
|
|
|
window.location.protocol + "//" + window.location.hostname
|
|
|
|
+ ( "" !== window.location.port ? ":" + window.location.port : "" )
|
|
|
|
);
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
</script>';
|
|
|
|
} else {
|
|
|
|
echo '<script type="text/javascript">
|
|
|
|
(function( wp ) {
|
2019-03-21 19:03:51 +01:00
|
|
|
if ( wp && wp.updates && wp.updates.decrementCount ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
wp.updates.decrementCount( "' . $type . '" );
|
|
|
|
}
|
|
|
|
})( window.wp );
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 3.0.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function bulk_header() {}
|
|
|
|
|
|
|
|
/**
|
2020-11-21 13:08:05 +01:00
|
|
|
* @since 3.0.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
public function bulk_footer() {}
|
Upgrade/install: Allow plugin and theme updates from a uploaded .zip file.
Props mariovalney, cyberhobo, imath, shaunandrews, mariovalney, earnjam, desrosj, dd32, folletto, swissspidy, melchoyce, pento, joshuawold, psykro, clorith, ahortin, galbaras, pingram3541, joyously, doobeedoo, karmatosed, poena, whyisjake, earnjam, sergeybiryukov, audrasjb, azaozz.
Fixes #9757.
Built from https://develop.svn.wordpress.org/trunk@48390
git-svn-id: http://core.svn.wordpress.org/trunk@48159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 19:49:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the `process_failed` error message when updating by uploading a zip file.
|
|
|
|
*
|
|
|
|
* @since 5.5.0
|
|
|
|
*
|
2020-11-21 13:08:05 +01:00
|
|
|
* @param WP_Error $wp_error WP_Error object.
|
2023-03-27 17:11:20 +02:00
|
|
|
* @return bool True if the error should be hidden, false otherwise.
|
Upgrade/install: Allow plugin and theme updates from a uploaded .zip file.
Props mariovalney, cyberhobo, imath, shaunandrews, mariovalney, earnjam, desrosj, dd32, folletto, swissspidy, melchoyce, pento, joshuawold, psykro, clorith, ahortin, galbaras, pingram3541, joyously, doobeedoo, karmatosed, poena, whyisjake, earnjam, sergeybiryukov, audrasjb, azaozz.
Fixes #9757.
Built from https://develop.svn.wordpress.org/trunk@48390
git-svn-id: http://core.svn.wordpress.org/trunk@48159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 19:49:05 +02:00
|
|
|
*/
|
|
|
|
public function hide_process_failed( $wp_error ) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|