Completed
Pull Request — master (#5)
by Rufus
01:18
created

helper-functions.php ➔ dnh_is_dismissed()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Dismissible Notices Handler.
4
 *
5
 * LICENSE: This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6
 * General Public License as published by the Free Software Foundation; either version 3 of the License, or (at
7
 * your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
8
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9
 * General Public License for more details. You should have received a copy of the GNU General Public License along
10
 * with this program. If not, see <http://opensource.org/licenses/gpl-license.php>
11
 *
12
 * @package   Dismissible Notices Handler/Helper Functions
13
 * @author    Julien Liabeuf <[email protected]>
14
 * @version   1.0
15
 * @license   GPL-2.0+
16
 * @link      https://julienliabeuf.com
17
 * @copyright 2016 Julien Liabeuf
18
 */
19
20
// If this file is called directly, abort.
21
if ( ! defined( 'WPINC' ) ) {
22
	die;
23
}
24
25
/**
26
 * Register a new notice
27
 *
28
 * @since 1.0
29
 *
30
 * @param string $id      Notice ID, used to identify it
31
 * @param string $type    Type of notice to display
32
 * @param string $content Notice content
33
 * @param array  $args    Additional parameters
34
 *
35
 * @return bool
36
 */
37
function dnh_register_notice( $id, $type, $content, $args = array() ) {
38
39
	if ( ! function_exists( 'DNH' ) ) {
40
		return false;
41
	}
42
43
	return DNH()->register_notice( $id, $type, $content, $args );
44
45
}
46
47
/**
48
 * Restore a previously dismissed notice
49
 *
50
 * @since 1.0
51
 *
52
 * @param string $id ID of the notice to restore
53
 *
54
 * @return bool
55
 */
56
function dnh_restore_notice( $id ) {
57
58
	if ( ! function_exists( 'DNH' ) ) {
59
		return false;
60
	}
61
62
	return DNH()->restore_notice( $id );
63
64
}
65
66
/**
67
 * Check if a notice has been dismissed
68
 *
69
 * @since 1.0
70
 *
71
 * @param string $id ID of the notice to check
72
 *
73
 * @return bool
74
 */
75
function dnh_is_dismissed( $id ) {
76
77
	if ( ! function_exists( 'DNH' ) ) {
78
		return false;
79
	}
80
81
	return DNH()->is_dismissed( $id );
82
83
}