Merge pull request #19271 from woocommerce/fix/includes-admin-plugin-updates-phpcs-violations
PHPCS fixes for includes/admin/plugin-updates directory
This commit is contained in:
commit
266b362d7e
|
@ -2,11 +2,10 @@
|
|||
/**
|
||||
* Class for displaying plugin warning notifications and determining 3rd party plugin compatibility.
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -174,7 +173,7 @@ class WC_Plugin_Updates {
|
|||
/**
|
||||
* Get active plugins that have a tested version lower than the input version.
|
||||
*
|
||||
* @param string $new_version
|
||||
* @param string $new_version WooCommerce version to test against.
|
||||
* @param string $release 'major' or 'minor'.
|
||||
* @return array of plugin info arrays
|
||||
*/
|
||||
|
@ -229,8 +228,8 @@ class WC_Plugin_Updates {
|
|||
/**
|
||||
* Get plugins that have a valid value for a specific header.
|
||||
*
|
||||
* @param string $header
|
||||
* @return array of plugin info arrays
|
||||
* @param string $header Plugin header to search for.
|
||||
* @return array Array of plugins that contain the searched header.
|
||||
*/
|
||||
protected function get_plugins_with_header( $header ) {
|
||||
$plugins = get_plugins();
|
||||
|
@ -255,7 +254,7 @@ class WC_Plugin_Updates {
|
|||
$matches = array();
|
||||
|
||||
foreach ( $plugins as $file => $plugin ) {
|
||||
if ( $plugin['Name'] !== 'WooCommerce' && ( stristr( $plugin['Name'], 'woocommerce' ) || stristr( $plugin['Description'], 'woocommerce' ) ) ) {
|
||||
if ( 'WooCommerce' !== $plugin['Name'] && ( stristr( $plugin['Name'], 'woocommerce' ) || stristr( $plugin['Description'], 'woocommerce' ) ) ) {
|
||||
$matches[ $file ] = $plugin;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* Manages WooCommerce plugin updating on the Plugins screen.
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
@ -16,6 +14,9 @@ if ( ! class_exists( 'WC_Plugin_Updates' ) ) {
|
|||
include_once dirname( __FILE__ ) . '/class-wc-plugin-updates.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WC_Plugins_Screen_Updates
|
||||
*/
|
||||
class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
|
||||
|
||||
/**
|
||||
|
@ -35,7 +36,8 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
|
|||
/**
|
||||
* Show plugin changes on the plugins screen. Code adapted from W3 Total Cache.
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $args Unused parameter.
|
||||
* @param stdClass $response Plugin update response.
|
||||
*/
|
||||
public function in_plugin_update_message( $args, $response ) {
|
||||
$this->new_version = $response->new_version;
|
||||
|
@ -64,19 +66,20 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
|
|||
add_action( 'admin_print_footer_scripts', array( $this, 'plugin_screen_modal_js' ) );
|
||||
}
|
||||
|
||||
echo apply_filters( 'woocommerce_in_plugin_update_message', $this->upgrade_notice ? '</p>' . wp_kses_post( $this->upgrade_notice ) . '<p class="dummy">' : '' );
|
||||
echo apply_filters( 'woocommerce_in_plugin_update_message', $this->upgrade_notice ? '</p>' . wp_kses_post( $this->upgrade_notice ) . '<p class="dummy">' : '' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade notice from WordPress.org.
|
||||
*
|
||||
* @param string $version
|
||||
* @param string $version WooCommerce new version.
|
||||
* @return string
|
||||
*/
|
||||
protected function get_upgrade_notice( $version ) {
|
||||
$transient_name = 'wc_upgrade_notice_' . $version;
|
||||
$upgrade_notice = get_transient( $transient_name );
|
||||
|
||||
if ( false === ( $upgrade_notice = get_transient( $transient_name ) ) ) {
|
||||
if ( false === $upgrade_notice ) {
|
||||
$response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/woocommerce/trunk/readme.txt' );
|
||||
|
||||
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
|
||||
|
@ -90,17 +93,17 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
|
|||
/**
|
||||
* Parse update notice from readme file.
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $new_version
|
||||
* @param string $content WooCommerce readme file content.
|
||||
* @param string $new_version WooCommerce new version.
|
||||
* @return string
|
||||
*/
|
||||
private function parse_update_notice( $content, $new_version ) {
|
||||
$version_parts = explode( '.', $new_version );
|
||||
$check_for_notices = array(
|
||||
$version_parts[0] . '.0', // Major
|
||||
$version_parts[0] . '.0.0', // Major
|
||||
$version_parts[0] . '.' . $version_parts[1], // Minor
|
||||
$version_parts[0] . '.' . $version_parts[1] . '.' . $version_parts[2], // Patch
|
||||
$version_parts[0] . '.0', // Major.
|
||||
$version_parts[0] . '.0.0', // Major.
|
||||
$version_parts[0] . '.' . $version_parts[1], // Minor.
|
||||
$version_parts[0] . '.' . $version_parts[1] . '.' . $version_parts[2], // Patch.
|
||||
);
|
||||
$notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
|
||||
$upgrade_notice = '';
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
/**
|
||||
* Manages WooCommerce plugin updating on the Updates screen.
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
@ -15,6 +14,9 @@ if ( ! class_exists( 'WC_Plugin_Updates' ) ) {
|
|||
include_once dirname( __FILE__ ) . '/class-wc-plugin-updates.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WC_Updates_Screen_Updates
|
||||
*/
|
||||
class WC_Updates_Screen_Updates extends WC_Plugin_Updates {
|
||||
|
||||
/**
|
||||
|
@ -39,7 +41,7 @@ class WC_Updates_Screen_Updates extends WC_Plugin_Updates {
|
|||
$this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, 'major' );
|
||||
|
||||
if ( ! empty( $this->major_untested_plugins ) ) {
|
||||
echo $this->get_extensions_modal_warning();
|
||||
echo $this->get_extensions_modal_warning(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
|
||||
$this->update_screen_modal_js();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin View: Notice - Untested extensions.
|
||||
*
|
||||
* @package WooCommerce\Admin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin View: Notice - Untested extensions.
|
||||
*
|
||||
* @package WooCommerce\Admin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$untested_plugins_msg = sprintf(
|
||||
/* translators: %s: version number */
|
||||
__( 'The following active plugin(s) have not declared compatibility with WooCommerce %s yet and should be updated and examined further before you proceed:', 'woocommerce' ),
|
||||
$new_version
|
||||
);
|
||||
|
||||
?>
|
||||
<div id="wc_untested_extensions_modal">
|
||||
<div class="wc_untested_extensions_modal--content">
|
||||
<h1><?php _e( "This is a major update, are you sure you're ready?", 'woocommerce' ); ?></h1>
|
||||
<h1><?php esc_html_e( "This is a major update, are you sure you're ready?", 'woocommerce' ); ?></h1>
|
||||
<div class="wc_plugin_upgrade_notice extensions_warning">
|
||||
<p>
|
||||
<?php
|
||||
/* translators: %s: version number */
|
||||
printf(
|
||||
__( 'The following active plugin(s) have not declared compatibility with WooCommerce %s yet and should be updated and examined further before you proceed:', 'woocommerce' ),
|
||||
esc_html( $new_version )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<p><?php echo esc_html( $untested_plugins_msg ); ?></p>
|
||||
|
||||
<div class="plugin-details-table-container">
|
||||
<table class="plugin-details-table" cellspacing="0">
|
||||
|
@ -39,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<p><?php esc_html_e( 'As this is a major update, we strongly recommend creating a backup of your site before updating.', 'woocommerce' ); ?> <a href="https://woocommerce.com/2017/05/create-use-backups-woocommerce/" target="_blank"><?php _e( 'Learn more', 'woocommerce' ); ?></a></p>
|
||||
<p><?php esc_html_e( 'As this is a major update, we strongly recommend creating a backup of your site before updating.', 'woocommerce' ); ?> <a href="https://woocommerce.com/2017/05/create-use-backups-woocommerce/" target="_blank"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a></p>
|
||||
|
||||
<?php if ( current_user_can( 'update_plugins' ) ) : ?>
|
||||
<div class="actions">
|
||||
|
|
Loading…
Reference in New Issue