Styling and unknown plugin detection

This commit is contained in:
Mike Jolley 2017-08-08 17:12:50 +01:00
parent c8a7ac8940
commit e82ca1c1a6
7 changed files with 113 additions and 63 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -133,57 +133,78 @@ span.mce_woocommerce_shortcodes_button {
}
.wc_untested_extensions_modal_container {
border-radius: 4px;
padding: 0;
#TB_closeAjaxWindow {
display: none;
}
#TB_title {
display: none;
}
#TB_ajaxContent {
height: 100% !important;
padding: 0;
margin: 0;
width: 100% !important;
// Hide extra paragraphs sanitizing might inject.
p:not(.woocommerce-actions) {
display: none;
p {
margin: 0 0 1em;
}
}
}
.wc_untested_extensions_modal--content {
h1 {
margin-top: 1em;
padding-bottom: 1.25em;
margin-bottom: 1.25em;
margin: 2px 2px 0.5em;
padding: 1em;
line-height: 1;
font-size: 2em;
border-bottom: 1px solid #eee;
color: #555;
color: #fff;
background: #96578A;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
text-shadow: none;
}
h4 {
margin-bottom: 2em;
.extensions_warning {
padding: 0 2em;
}
.plugin-details {
color: red;
font-weight: bold;
display: list-item;
margin-left: 1.5em;
.plugin-details-list {
li {
margin: 0 0 0 2em;
list-style: disc inside;
font-weight: bold;
}
}
.actions {
border-top: 1px solid #eee;
margin-top: 2.5em;
padding-top: 1em;
margin: 0;
padding: 1em 0 2em 0;
overflow: hidden;
.woocommerce-actions {
display: inline-block;
}
.update-anyways {
a.button-primary {
float: right;
}
background: #bb77ae;
border-color: #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
color: #fff;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
.cancel a {
display: inline-block;
margin-top: .5em;
color: #999;
&:hover, &:focus, &:active {
background: #a36597;
border-color: #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
}
}
}
}

View File

@ -174,7 +174,12 @@ class WC_Plugin_Updates {
* @return array of plugin info arrays
*/
public function get_untested_plugins( $version, $release ) {
$extensions = $this->get_plugins_with_header( self::VERSION_TESTED_HEADER );
$extensions = $this->get_plugins_with_header( self::VERSION_TESTED_HEADER );
if ( 'major' === $release ) {
$extensions = array_merge( $extensions, $this->get_plugins_for_woocommerce() );
}
$untested = array();
$version_parts = explode( '.', $version );
$version = $version_parts[0];
@ -184,22 +189,27 @@ class WC_Plugin_Updates {
}
foreach ( $extensions as $file => $plugin ) {
$plugin_version_parts = explode( '.', $plugin[ self::VERSION_TESTED_HEADER ] );
if ( ! empty( $plugin[ self::VERSION_TESTED_HEADER ] ) ) {
$plugin_version_parts = explode( '.', $plugin[ self::VERSION_TESTED_HEADER ] );
if ( ! is_numeric( $plugin_version_parts[0] )
|| ( 'minor' === $release && ! isset( $plugin_version_parts[1] ) )
|| ( 'minor' === $release && ! is_numeric( $plugin_version_parts[1] ) )
) {
continue;
}
if ( ! is_numeric( $plugin_version_parts[0] )
|| ( 'minor' === $release && ! isset( $plugin_version_parts[1] ) )
|| ( 'minor' === $release && ! is_numeric( $plugin_version_parts[1] ) )
) {
continue;
}
$plugin_version = $plugin_version_parts[0];
$plugin_version = $plugin_version_parts[0];
if ( 'minor' === $release ) {
$plugin_version .= '.' . $plugin_version_parts[1];
}
if ( 'minor' === $release ) {
$plugin_version .= '.' . $plugin_version_parts[1];
}
if ( version_compare( $plugin_version, $version, '<' ) && is_plugin_active( $file ) ) {
if ( version_compare( $plugin_version, $version, '<' ) && is_plugin_active( $file ) ) {
$untested[ $file ] = $plugin;
}
} else {
$plugin[ self::VERSION_TESTED_HEADER ] = __( 'unknown', 'woocommerce' );
$untested[ $file ] = $plugin;
}
}
@ -225,4 +235,22 @@ class WC_Plugin_Updates {
return apply_filters( 'woocommerce_get_plugins_with_header', $matches, $header, $plugins );
}
/**
* Get plugins which "maybe" are for WooCommerce.
*
* @return array of plugin info arrays
*/
protected function get_plugins_for_woocommerce() {
$plugins = get_plugins();
$matches = array();
foreach ( $plugins as $file => $plugin ) {
if ( $plugin['Name'] !== 'WooCommerce' && ( stristr( $plugin['Name'], 'woocommerce' ) || stristr( $plugin['Description'], 'woocommerce' ) ) ) {
$matches[ $file ] = $plugin;
}
}
return apply_filters( 'woocommerce_get_plugins_for_woocommerce', $matches, $plugins );
}
}

View File

@ -146,7 +146,7 @@ class WC_Plugins_Screen_Updates extends WC_Plugin_Updates {
$update_link.click();
});
$( '#wc_untested_extensions_modal .cancel a' ).on( 'click', function( evt ) {
$( '#wc_untested_extensions_modal .cancel' ).on( 'click', function( evt ) {
evt.preventDefault();
tb_remove();
});

View File

@ -80,7 +80,7 @@ class WC_Updates_Screen_Updates extends WC_Plugin_Updates {
});
// Uncheck the WC update checkbox if the modal is canceled.
$( '#wc_untested_extensions_modal .cancel a' ).on( 'click', function( evt ) {
$( '#wc_untested_extensions_modal .cancel' ).on( 'click', function( evt ) {
evt.preventDefault();
$( 'input[value="woocommerce/woocommerce.php"]' ).prop( 'checked', false );
tb_remove();

View File

@ -8,40 +8,41 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div id="wc_untested_extensions_modal">
<div class="wc_untested_extensions_modal--content">
<h1><?php _e( 'Are you sure you want to update?', 'woocommerce' ); ?></h1>
<div class="wc_plugin_upgrade_notice extensions_warning">
<h1><?php _e( 'Warning', 'woocommerce' ); ?></h1>
<h4>
<?php
<p><?php
/* translators: %s: version number */
printf(
__( 'These plugins are not listed compatible with WooCommerce %s yet. This is a major update. If you upgrade without updating these extensions first, you may experience issues:', 'woocommerce' ),
__( 'The following plugins have not declared compatibility with WooCommerce %s yet:', 'woocommerce' ),
esc_html( $new_version )
);
?>
</h4>
?></p>
<?php foreach ( $plugins as $plugin ): ?>
<div class="plugin-details">
<?php echo esc_html( $plugin['Name'] ); ?>
&mdash;
<?php
<ul class="plugin-details-list">
<?php foreach ( $plugins as $plugin ): ?>
<li class="plugin-details">
<?php echo esc_html( $plugin['Name'] ); ?>
&mdash;
<?php
/* translators: %s: version number */
echo esc_html( sprintf( __( 'Tested up to %s', 'woocommerce' ), wc_clean( $plugin['WC tested up to'] ) ) );
?>
</li>
<?php endforeach ?>
</ul>
<p><?php
/* translators: %s: version number */
echo esc_html( sprintf( __( 'Tested up to WooCommerce %s', 'woocommerce' ), wc_clean( $plugin['WC tested up to'] ) ) );
?>
</div>
<?php endforeach ?>
printf(
__( 'This is a major update. Please update these extensions before proceeding or you may experience issues. We also recommend making a site backup.', 'woocommerce' ),
esc_html( $new_version )
);
?></p>
<?php if ( current_user_can( 'update_plugins' ) ): ?>
<div class="actions">
<p class="woocommerce-actions cancel">
<a href="#"><?php _e( 'Cancel', 'woocommerce' ); ?></a>
</p>
<p class="woocommerce-actions update-anyways">
<a class="button-primary accept" href="#">
<?php _e( 'I understand and wish to update', 'woocommerce' ); ?>
</a>
</p>
<a href="#" class="button button-secondary cancel"><?php esc_html_e( 'Cancel update', 'woocommerce' ); ?></a>
<a class="button button-primary accept" href="#"><?php esc_html_e( 'Continue to update', 'woocommerce' ); ?></a>
</div>
<?php endif ?>
</div>