Skip to content

Commit

Permalink
Version 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrommen committed Mar 16, 2021
1 parent b5dd6ca commit bd05c17
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 79 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

-

## [1.4.0] - 2021-03-16

### Changed

- Update development dependencies.
- Bump "Tested up to" header, see [issue #12](https://github.com/tfrommen/Dobby/issues/12).

## [1.3.0] - 2017-09-20

### Added
Expand Down Expand Up @@ -86,7 +93,8 @@ Initial release.

----

[Unreleased]: https://github.com/tfrommen/Dobby/compare/v1.3.0...HEAD
[Unreleased]: https://github.com/tfrommen/Dobby/compare/v1.4.0...HEAD
[1.4.0]: https://github.com/tfrommen/Dobby/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/tfrommen/Dobby/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/tfrommen/Dobby/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/tfrommen/Dobby/compare/v1.1.1...v1.2.0
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Install with [Composer](https://getcomposer.org):

```sh
$ composer require tfrommen/dobby
composer require tfrommen/dobby
```

Or:
Expand Down Expand Up @@ -49,7 +49,7 @@ The default value is `1`.
```php
<?php
/**
* Filters the minimum number of admin notices required for Dobby to take action.
* Filter the minimum number of admin notices required for Dobby to take action.
*
* @param int $threshold Required minimum number of admin notices.
*/
Expand All @@ -58,9 +58,3 @@ add_filter( \tfrommen\Dobby\FILTER_THRESHOLD, function () {
return 3;
} );
```

## License

Copyright (c) 2017 Thorsten Frommen

This code is licensed under the [MIT License](LICENSE).
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"name": "Thorsten Frommen",
"email": "info@tfrommen.de",
"homepage": "https://twitter.com/thorstenfrommen",
"homepage": "https://tfrommen.de",
"role": "Developer"
}
],
Expand All @@ -25,14 +25,17 @@
"php": ">=5.4"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
"squizlabs/php_codesniffer": "^3.0",
"wimg/php-compatibility": "^8.0",
"wp-coding-standards/wpcs": "^0.13.1"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"phpcompatibility/php-compatibility": "^9.0",
"squizlabs/php_codesniffer": "^3.5",
"wp-coding-standards/wpcs": "^2.3"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
"dev-master": "1.4.x-dev"
}
}
}
136 changes: 79 additions & 57 deletions dobby.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
<?php # -*- coding: utf-8 -*-

/*
* Plugin Name: Dobby
* Plugin URI: https://wordpress.org/plugins/wp-dobby/
* Description: Dobby, the friendly Admin Elf, takes care of all your (unwanted) admin notices.
* Author: Thorsten Frommen
* Author URI: https://tfrommen.de
* Version: 1.3.0
* Text Domain: wp-dobby
* License: MIT
<?php
/**
* Dobby
*
* @package tfrommen\Dobby
* @author Thorsten Frommen
* @license MIT
*
* @wordpress-plugin
* Plugin Name: Dobby
* Plugin URI: https://wordpress.org/plugins/wp-dobby/
* Description: Dobby, the friendly Admin Elf, takes care of all your (unwanted) admin notices.
* Version: 1.4.0
* Requires at least: 3.1
* Requires PHP: 5.4
* Author: Thorsten Frommen
* Author URI: https://tfrommen.de
* License: MIT
* Text Domain: wp-dobby
*/

namespace tfrommen\Dobby;
Expand All @@ -29,7 +37,7 @@
const FILTER_THRESHOLD = 'dobby.threshold';

/**
* Bootstraps the plugin.
* Bootstrap the plugin.
*
* @since 1.0.0
* @wp-hook plugins_loaded
Expand All @@ -45,59 +53,73 @@ function bootstrap() {
} else {
$action = 'admin_notices';
}
add_action( $action, function () {

ob_start();
}, (int) ( PHP_INT_MAX + 1 ) );
add_action(
$action,
function () {

add_action( 'all_admin_notices', function () {
ob_start();
},
(int) ( PHP_INT_MAX + 1 )
);

$contents = trim( ob_get_clean() );
if ( '' === $contents ) {
return;
}
add_action(
'all_admin_notices',
function () {

load_plugin_textdomain( 'wp-dobby' );
$contents = trim( ob_get_clean() );
if ( '' === $contents ) {
return;
}

$dobby_id = 'dobby';
load_plugin_textdomain( 'wp-dobby' );

$closet_id = 'dobby-closet';
?>
<div id="<?php echo esc_attr( $dobby_id ); ?>" class="notice hide-if-js">
<p>
<span>&#x2728;</span>
<?php esc_html_e( 'Dobby took care of your admin notices.', 'wp-dobby' ); ?>
<button class="button"><?php esc_html_e( 'Reveal', 'wp-dobby' ); ?></button>
</p>
</div>
<div id="<?php echo esc_attr( $closet_id ); ?>" class="hide-if-js">
<?php
// @codingStandardsIgnoreLine
echo $contents;
$dobby_id = 'dobby';

$closet_id = 'dobby-closet';
?>
</div>
<?php
wp_enqueue_script(
'dobby',
plugin_dir_url( __FILE__ ) . 'assets/js/dobby.js',
[ 'jquery' ],
filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/dobby.js' )
);
<div id="<?php echo esc_attr( $dobby_id ); ?>" class="notice hide-if-js">
<p>
<span>&#x2728;</span>
<?php esc_html_e( 'Dobby took care of your admin notices.', 'wp-dobby' ); ?>
<button class="button"><?php esc_html_e( 'Reveal', 'wp-dobby' ); ?></button>
</p>
</div>
<div id="<?php echo esc_attr( $closet_id ); ?>" class="hide-if-js">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $contents;
?>
</div>
<?php
wp_enqueue_script(
'dobby',
plugin_dir_url( __FILE__ ) . 'assets/js/dobby.js',
[ 'jquery' ],
filemtime( plugin_dir_path( __FILE__ ) . 'assets/js/dobby.js' ),
[ 'in_footer' => true ]
);

/**
* Filters the minimum number of admin notices required for Dobby to take action.
*
* @since 1.1.0
*
* @param int $threshold Required minimum number of admin notices.
*/
$threshold = (int) apply_filters( FILTER_THRESHOLD, 1 );
wp_localize_script( 'dobby', 'dobbySettings', [
'selectorCloset' => "#{$closet_id}",
'selectorDobby' => "#{$dobby_id}",
'threshold' => max( 1, $threshold ),
] );
}, PHP_INT_MAX );
/**
* Filter the minimum number of admin notices required for Dobby to take action.
*
* @since 1.1.0
*
* @param int $threshold Required minimum number of admin notices.
*/
$threshold = (int) apply_filters( FILTER_THRESHOLD, 1 );
wp_localize_script(
'dobby',
'dobbySettings',
[
'selectorCloset' => "#{$closet_id}",
'selectorDobby' => "#{$dobby_id}",
'threshold' => max( 1, $threshold ),
]
);
},
PHP_INT_MAX
);
}

add_action( 'plugins_loaded', __NAMESPACE__ . '\\bootstrap' );
7 changes: 2 additions & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
<rule ref="PHPCompatibility"/>

<rule ref="WordPress">

<!-- Exclude to be able to include an encoding cookie. -->
<exclude name="Squiz.Commenting.FileComment.WrongStyle"/>
<exclude name="Squiz.Commenting.InlineComment.WrongStyle"/>

<!-- Allow short array syntax. -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
</rule>

</ruleset>
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: tfrommen
Tags: admin, notices
Requires at least: 3.1.0
Tested up to: 4.8
Stable tag: v1.3.0
Tested up to: 5.7
Stable tag: 1.4.0
Requires PHP: 5.4

Dobby, the friendly Admin Elf, takes care of all your (unwanted) admin notices.
Expand All @@ -30,6 +30,9 @@ This plugin requires **PHP 5.4**.

== Changelog ==

= 1.4.0 =
* Bump "Tested up to" header, see [issue #12](https://github.com/tfrommen/Dobby/issues/12).

= 1.3.0 =
* Fix dismissible notices not being able to get dismissed, see [issue #9](https://github.com/tfrommen/Dobby/issues/9).
* Add PHP_CodeSniffer, and adapt code.
Expand Down

0 comments on commit bd05c17

Please sign in to comment.