PluginProbe ʕ •ᴥ•ʔ
WP Job Manager / 2.4.6
WP Job Manager v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.11.0 1.11.1 1.12.0 1.12.1 1.13.0 1.14.0 1.15.0 1.16.0 1.16.1 1.17.0 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.21.0 1.21.1 1.21.2 1.21.3 1.21.4 1.22.0 1.22.1 1.22.2 1.22.3 1.23.0 1.23.1 1.23.10 1.23.11 1.23.12 1.23.13 1.23.2 1.23.3 1.23.4 1.23.5 1.23.6 1.23.7 1.23.8 1.23.9 1.24.0 1.24.0.1 1.25.0 1.25.0.1 1.25.1 1.25.1.1 1.25.2 1.25.2.1 1.25.3 1.25.3.1 1.26.0 1.26.0.1 1.26.1 1.26.1.1 1.26.2 1.26.2.1 1.27.0 1.27.0.1 1.28.0 1.28.0.1 1.29.0 1.29.0.1 1.29.1 1.29.1.1 1.29.2 1.29.2.1 1.29.3 1.29.3.1 1.3.0 1.3.1 1.30.0 1.30.0.1 1.30.1 1.30.1.1 1.30.2 1.30.2.1 1.31.0 1.31.0.1 1.31.1 1.31.1.1 1.31.2 1.31.3 1.32.0 1.32.1 1.32.2 1.32.3 1.33.0 1.33.1 1.33.2 1.33.3 1.33.4 1.33.5 1.34.0 1.34.1 1.34.2 1.34.3 1.34.4 1.34.5 1.35.0 1.35.1 1.35.2 1.35.3 1.36.0 1.36.1 1.36.2 1.37.0 1.38.0 1.38.1 1.39.0 1.4.0 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 1.9.2 1.9.3 2.0.0 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.4.1
wp-job-manager / includes / ui / class-notice.php
wp-job-manager / includes / ui Last commit date
class-modal-dialog.php 2 years ago class-notice.php 2 years ago class-redirect-message.php 2 years ago class-ui-elements.php 2 weeks ago class-ui-settings.php 2 years ago class-ui.php 2 years ago
class-notice.php
188 lines
1 <?php
2 /**
3 * Notice component for the frontend.
4 *
5 * @package wp-job-manager
6 * @since 2.2.0
7 */
8
9 namespace WP_Job_Manager\UI;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Notice component for the frontend.
17 *
18 * @since 2.2.0
19 *
20 * @internal This API is still under development and subject to change.
21 * @access private
22 */
23 class Notice {
24
25 /**
26 * A success message.
27 *
28 * @param string|array $args A message, or an array of options accepted by Notice::render.
29 */
30 public static function success( $args ) {
31 $args = is_array( $args ) ? $args : [ 'message' => $args ];
32
33 return self::render(
34 array_merge(
35 [ 'icon' => 'check-circle' ],
36 $args
37 )
38 );
39 }
40
41 /**
42 * An error message.
43 *
44 * @param string|array $args A message, or an array of options accepted by Notice::render.
45 */
46 public static function error( $args ) {
47 $args = is_array( $args ) ? $args : [ 'message' => $args ];
48
49 return self::render(
50 array_merge(
51 [ 'icon' => 'alert' ],
52 $args,
53 [
54 'classes' => array_merge( [ 'color-error' ], $args['classes'] ?? [] ),
55 ]
56 )
57 );
58 }
59
60 /**
61 * A permanent informational message.
62 *
63 * @param string|array $args A message, or an array of options accepted by Notice::render.
64 */
65 public static function hint( $args ) {
66 $args = is_array( $args ) ? $args : [ 'message' => $args ];
67
68 return self::render(
69 array_merge(
70 $args,
71 [
72 'classes' => array_merge( [ 'type-hint' ], $args['classes'] ?? [] ),
73 ],
74 )
75 );
76 }
77
78 /**
79 * A permanent message that requires action to proceed.
80 *
81 * @param string|array $args
82 */
83 public static function dialog( $args ) {
84 $args = is_array( $args ) ? $args : [ 'message' => $args ];
85
86 return self::render(
87 array_merge(
88 $args,
89 [
90 'classes' => array_merge( [ 'type-dialog' ], $args['classes'] ?? [] ),
91 ]
92 )
93 );
94 }
95
96 /**
97 * Notice element.
98 *
99 * @param array $options {
100 * Options for the notice.
101 *
102 * @type string $id Unique ID of the notice.
103 * @type string $title Optional title.
104 * @type string $icon Notice icon. Should be a supported icon name, or safe SVG code.
105 * @type string $message Main notice message.
106 * @type string $html Raw HTML content. User input must be escaped by the caller function.
107 * @type array $buttons Action links styled as buttons.
108 * @type array $links Action links.
109 * @type array $classes Additional classes for the notice. Possible options:
110 * color-error: Error-style coloring.
111 * color-success: Green highlight.
112 * color-info: Blue highlight.
113 * color-strong: Stronger border opacity highlight.
114 * type-hint: Variation for a persistent hint.
115 * message-icon: Show the icon next to the message instead of the title.
116 * alignwide: Wide notice, with actions on the side.
117 * }
118 *
119 * @return string HTML.
120 */
121 public static function render( $options ) {
122
123 UI::ensure_styles();
124
125 $options = wp_parse_args(
126 $options,
127 [
128 'id' => '',
129 'title' => '',
130 'icon' => '',
131 'message' => '',
132 'html' => '',
133 'buttons' => [],
134 'links' => [],
135 'classes' => [],
136 ]
137 );
138
139 $actions = UI_Elements::actions( $options['buttons'], $options['links'] );
140
141 $icon = UI_Elements::icon( $options['icon'] );
142
143 ob_start();
144
145 $template_options = [
146 'options' => $options,
147 'title' => $options['title'],
148 'classes' => $options['classes'] ?? [],
149 'message' => $options['message'],
150 'content_html' => $options['html'],
151 'icon_html' => $icon,
152 'actions_html' => $actions,
153 ];
154
155 get_job_manager_template(
156 'notice.php',
157 $template_options
158 );
159
160 $notice_html = ob_get_clean();
161
162 /**
163 * Filters notices. Return false to disable the notice.
164 *
165 * @since 2.2.0
166 *
167 * @param string $notice_html Generated HTML for the notice.
168 * @param array $options Notice template options.
169 */
170 $notice_html = apply_filters( 'wpjm_notice', $notice_html, $template_options );
171
172 if ( ! empty( $options['id'] ) ) {
173 /**
174 * Filters an individual notice. Return false to disable the notice.
175 *
176 * @since 2.2.0
177 *
178 * @param string $notice_html Generated HTML for the notice.
179 * @param array $options Notice template options.
180 */
181 $notice_html = apply_filters( 'wpjm_notice_' . $options['id'], $notice_html, $template_options );
182 }
183
184 return is_string( $notice_html ) ? $notice_html : '';
185 }
186
187 }
188