Skip to content

Commit

Permalink
Merge pull request #16 from julien731/release/1.2.2
Browse files Browse the repository at this point in the history
Release 1.2.2
  • Loading branch information
julien731 authored Feb 17, 2021
2 parents e5c11a5 + 75be646 commit 062b147
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 62 deletions.
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Purpose

_Describe the problem or feature in addition to a link to the issues._

## Approach

_How does this change address the problem?_

### Open Questions and Pre-Merge TODOs

- [ ] Use github checklists. When solved, check the box and explain the answer.
94 changes: 94 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

We Use [Gitflow](https://jeffkreeftmeijer.com/git-flow/) so all code changes happen through pull requests. We actively welcome your PRs:

1. Fork the repo and create your branch from `develop`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. Issue that pull request!
- **Make sure to use a descriptive title for your PR.**
- Make use of the available labels to identify the type of PR that you're opening

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The basics of it is to register a new admin notice. You really need 3 things for

There is a handy helper function available for notice registration: `dnh_register_notice()`

This function takes 3 parameters:
This function takes 4 parameters:

- `$id` *(string)*: the unique ID of the notice
- `$type` *(string)*: the type of notice you want to display. Currently it can be `error` for an error notice or `updated` for a success/update notice
Expand All @@ -43,7 +43,7 @@ dnh_register_notice( 'my_notice', 'updated', __( 'This is my notice' ) );

## Advanced Parameters

The function takes an array of optional parameters allowing more control over the notices and how they're dismissed. Only 2 parameters are available so far but hopefully more will be coming soon.
The function takes an array of optional parameters allowing more control over the notices and how they're dismissed. Only 3 parameters are available so far but hopefully more will be coming soon.

Hereafter is the list of available parameters to be passed in the `$args` array. Please note that the `$args` parameter is optional.

Expand Down
2 changes: 1 addition & 1 deletion handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Dismissible_Notices_Handler {
* @since 1.0
* @var string
*/
public $version = '1.2.1';
public $version = '1.2.2';

/**
* Required version of PHP.
Expand Down
122 changes: 63 additions & 59 deletions includes/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,85 +27,89 @@
* @return object Dismissible_Notices_Handler
*/

if ( function_exists( 'DNH' ) ) {
return;
}

function DNH() {
return Dismissible_Notices_Handler::instance();
}

/**
* Register a new notice
*
* @since 1.0
*
* @param string $id Notice ID, used to identify it
* @param string $type Type of notice to display
* @param string $content Notice content
* @param array $args Additional parameters
*
* @return bool
*/
function dnh_register_notice( $id, $type, $content, $args = array() ) {

if ( ! function_exists( 'DNH' ) ) {
return false;
if ( ! function_exists( 'DNH' ) ) {
function DNH() {
return Dismissible_Notices_Handler::instance();
}
}

if ( ! function_exists( 'dnh_register_notice' ) ) {
/**
* Get the library running
* Register a new notice
*
* @since 1.0
*
* @param string $id Notice ID, used to identify it
* @param string $type Type of notice to display
* @param string $content Notice content
* @param array $args Additional parameters
*
* @return bool
*/
DNH();
function dnh_register_notice( $id, $type, $content, $args = array() ) {

return DNH()->register_notice( $id, $type, $content, $args );
if ( ! function_exists( 'DNH' ) ) {
return false;
}

}
/**
* Get the library running
*/
DNH();

/**
* Restore a previously dismissed notice
*
* @since 1.0
*
* @param string $id ID of the notice to restore
*
* @return bool
*/
function dnh_restore_notice( $id ) {
return DNH()->register_notice( $id, $type, $content, $args );

if ( ! function_exists( 'DNH' ) ) {
return false;
}
}

if ( ! function_exists( 'dnh_restore_notice' ) ) {
/**
* Get the library running
* Restore a previously dismissed notice
*
* @since 1.0
*
* @param string $id ID of the notice to restore
*
* @return bool
*/
DNH();
function dnh_restore_notice( $id ) {

return DNH()->restore_notice( $id );
if ( ! function_exists( 'DNH' ) ) {
return false;
}

}
/**
* Get the library running
*/
DNH();

/**
* Check if a notice has been dismissed
*
* @since 1.0
*
* @param string $id ID of the notice to check
*
* @return bool
*/
function dnh_is_dismissed( $id ) {
return DNH()->restore_notice( $id );

if ( ! function_exists( 'DNH' ) ) {
return false;
}
}

if ( ! function_exists( 'dnh_is_dismissed' ) ) {
/**
* Get the library running
* Check if a notice has been dismissed
*
* @since 1.0
*
* @param string $id ID of the notice to check
*
* @return bool
*/
DNH();
function dnh_is_dismissed( $id ) {

return DNH()->is_dismissed( $id );
if ( ! function_exists( 'DNH' ) ) {
return false;
}

/**
* Get the library running
*/
DNH();

return DNH()->is_dismissed( $id );

}
}

0 comments on commit 062b147

Please sign in to comment.