PluginProbe
BeyondWords – AI audio for publishers / 4.5.1
BeyondWords – AI audio for publishers v4.5.1
7.2.0 7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 All 44 releases
speechkit / src / Component / Posts / BulkEdit / Notices.php

Notices.php in BeyondWords – AI audio for publishers 4.5.1, at src/Component/Posts/BulkEdit/Notices.php

169 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * BeyondWords Bulk Edit.
7 *
8 * Text Domain: beyondwords
9 *
10 * @package Beyondwords\Wordpress
11 * @author Stuart McAlpine <[email protected]>
12 * @since 3.0.0
13 */
14
15 namespace Beyondwords\Wordpress\Component\Posts\BulkEdit;
16
17 /**
18 * BulkEdit setup
19 *
20 * @since 4.5.0
21 */
22 class Notices
23 {
24 /**
25 * Constructor
26 */
27 public function init()
28 {
29 add_action('admin_notices', array($this, 'generatedNotice'));
30 add_action('admin_notices', array($this, 'deletedNotice'));
31 add_action('admin_notices', array($this, 'failedNotice'));
32 add_action('admin_notices', array($this, 'errorNotice'));
33 }
34
35 /**
36 * @since 4.1.0
37 */
38 public function generatedNotice()
39 {
40 if (! isset($_GET['beyondwords_bulk_edit_result_nonce'])) {
41 return;
42 }
43
44 if (! wp_verify_nonce(sanitize_text_field($_GET['beyondwords_bulk_edit_result_nonce']), 'beyondwords_bulk_edit_result')) { // phpcs:ignore Generic.Files.LineLength.TooLong
45 wp_nonce_ays('');
46 }
47
48 $count = intval(sanitize_text_field($_GET['beyondwords_bulk_generated'] ?? ''));
49
50 if ($count) {
51 $message = sprintf(
52 /* translators: %d is replaced with the number of posts processed */
53 _n(
54 'Audio was requested for %d post.',
55 'Audio was requested for %d posts.',
56 $count,
57 'speechkit'
58 ),
59 $count
60 );
61 ?>
62 <div id="beyondwords-bulk-edit-notice-generated" class="notice notice-info is-dismissible">
63 <p>
64 <?php echo esc_html($message); ?>
65 </p>
66 </div>
67 <?php
68 }
69 }
70
71 /**
72 *
73 */
74 public function deletedNotice()
75 {
76 if (! isset($_GET['beyondwords_bulk_edit_result_nonce'])) {
77 return;
78 }
79
80 if (! wp_verify_nonce(sanitize_text_field($_GET['beyondwords_bulk_edit_result_nonce']), 'beyondwords_bulk_edit_result')) { // phpcs:ignore Generic.Files.LineLength.TooLong
81 wp_nonce_ays('');
82 }
83
84 $count = intval(sanitize_text_field($_GET['beyondwords_bulk_deleted'] ?? ''));
85
86 if ($count) {
87 $message = sprintf(
88 /* translators: %d is replaced with the number of posts processed */
89 _n(
90 'Audio was deleted for %d post.',
91 'Audio was deleted for %d posts.',
92 $count,
93 'speechkit'
94 ),
95 $count
96 );
97 ?>
98 <div id="beyondwords-bulk-edit-notice-deleted" class="notice notice-info is-dismissible">
99 <p>
100 <?php echo esc_html($message); ?>
101 </p>
102 </div>
103 <?php
104 }
105 }
106
107 /**
108 *
109 */
110 public function failedNotice()
111 {
112 if (! isset($_GET['beyondwords_bulk_edit_result_nonce'])) {
113 return;
114 }
115
116 if (! wp_verify_nonce(sanitize_text_field($_GET['beyondwords_bulk_edit_result_nonce']), 'beyondwords_bulk_edit_result')) { // phpcs:ignore Generic.Files.LineLength.TooLong
117 wp_nonce_ays('');
118 }
119
120 $count = intval(sanitize_text_field($_GET['beyondwords_bulk_failed'] ?? ''));
121
122 if ($count) {
123 $message = sprintf(
124 /* translators: %d is replaced with the number of posts that were skipped */
125 _n(
126 '%d post failed, check for errors in the BeyondWords column below.',
127 '%d posts failed, check for errors in the BeyondWords column below.',
128 $count,
129 'speechkit'
130 ),
131 $count
132 );
133 ?>
134 <div id="beyondwords-bulk-edit-notice-failed" class="notice notice-error is-dismissible">
135 <p>
136 <?php echo esc_html($message); ?>
137 </p>
138 </div>
139 <?php
140 }
141 }
142
143 /**
144 *
145 */
146 public function errorNotice()
147 {
148 if (! isset($_GET['beyondwords_bulk_edit_result_nonce'])) {
149 return;
150 }
151
152 if (! wp_verify_nonce(sanitize_text_field($_GET['beyondwords_bulk_edit_result_nonce']), 'beyondwords_bulk_edit_result')) { // phpcs:ignore Generic.Files.LineLength.TooLong
153 wp_nonce_ays('');
154 }
155
156 $message = sanitize_text_field($_GET['beyondwords_bulk_error'] ?? '');
157
158 if ($message) {
159 ?>
160 <div id="beyondwords-bulk-edit-notice-error" class="notice notice-error is-dismissible">
161 <p>
162 <?php echo esc_html($message); ?>
163 </p>
164 </div>
165 <?php
166 }
167 }
168 }
169