Skip to content

Commit

Permalink
1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills authored Sep 5, 2022
1 parent fd9c6f6 commit c121799
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.5.0 - 2022-09-01

[Source code changes](https://github.com/luizbills/wp-plugin-base/compare/1.4.1...1.5.0)

- Fix and improve the missing dependencies notice.

## 1.4.1 - 2022-09-01

[Source code changes](https://github.com/luizbills/wp-plugin-base/compare/1.4.0...1.4.1)

- Fix: incorrect `h::log` output.
- Fix: incorrect `h::log` output.

## 1.4.0 - 2022-09-01

[Source code changes](https://github.com/luizbills/wp-plugin-base/compare/1.3.1...1.4.0)

- Feat: allow class instances in `loader.php`.
- Fix: remove *falsy* values from `loader.php`.
- Fix: remove *falsy* values from `loader.php`.

## 1.3.1 - 2022-08-19

Expand Down
40 changes: 22 additions & 18 deletions core/Dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,39 @@ protected static function handle_shortcut ( $shortcut ) {
protected static function display_notice_missing_deps ( $messages ) {
if ( ! \is_admin() ) return;
if ( ! \current_user_can( 'install_plugins' ) ) return;
if ( 0 === ( $messages ) ) return;
if ( 0 === count( $messages ) ) return;

\add_action( 'admin_notices', function () use ( $messages ) {
$allowed_html = [
'a' => [ 'href' => [], 'title' => [] ],
'span' => [ 'class' => [], 'style' => [] ],
'br' => [],
'em' => [],
'strong' => [],
];
\usort( $messages, function ( $a, $b ) {
return $b['is_error'] <=> $a['is_error'];
} );

\add_action( 'admin_notices', function () use ( $messages ) {
echo "<div class='notice notice-error'><p>";
echo sprintf(
/* translators: %s is replaced with plugin name */
__( 'Missing dependencies for %s:', 'wc-variations-table' ),
__( 'The %s plugin needs the following dependencies to work:', 'your-text-domain' ),
"<strong>" . Config::get( 'NAME' ) . "</strong>",
);

$indent = \str_repeat( '&nbsp;', 4 );
$missing = esc_html__( 'Missing', 'your-text-domain' );
$allowed_html = [
'a' => [ 'href' => [], 'target' => [] ],
'span' => [ 'class' => [], 'style' => [] ],
'em' => [],
'strong' => [],
'code' => [],
];
foreach ( $messages as $message ) {
$icon = $message['is_error'] ? 'no-alt' : 'yes';
$color = $message['is_error'] ? '#e03131' : '#2b8a3e';
$line = \sprintf(
'<br>%s<span style="color:%s"><span class="dashicons dashicons-%s"> </span>%s</span>',
\str_repeat( '&nbsp;', 4 ),
$color,
$icon,
$message['text']
'<span style="color:%s;"><span class="dashicons dashicons-%s">&nbsp;</span>%s%s</span>',
$message['is_error'] ? '#e03131' : '#2b8a3e',
$message['is_error'] ? 'minus' : 'yes',
$message['is_error'] ? "$missing: " : '',
\wp_kses( $message['text'], $allowed_html )
);
echo \wp_kses( $line, $allowed_html );
$line = $message['is_error'] ? $line : "<s>$line</s>";
echo "<br> {$indent} {$line}";
}

echo '</p></div>';
Expand Down
2 changes: 1 addition & 1 deletion core/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.5.0

0 comments on commit c121799

Please sign in to comment.