PluginProbe
Survey Maker by AYS / 5.2.2.2
Survey Maker by AYS v5.2.2.2
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / includes / lists / class-survey-maker-popup-survey-list-table.php

class-survey-maker-popup-survey-list-table.php in Survey Maker by AYS 5.2.2.2, at includes/lists/class-survey-maker-popup-survey-list-table.php

1,078 lines 48.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 ob_start();
3 class Popup_Survey_List_Table extends WP_List_Table {
4
5 /**
6 * The ID of this plugin.
7 *
8 * @since 1.0.0
9 * @access private
10 * @var string $plugin_name The ID of this plugin.
11 */
12 private $plugin_name;
13
14 /**
15 * The table name in database of the survey categories.
16 *
17 * @since 1.0.0
18 * @access private
19 * @var string $table_name The table name in database of the survey categories.
20 */
21 private $table_name;
22
23 private $title_length;
24
25 /** Class constructor */
26 public function __construct( $plugin_name ) {
27 global $wpdb;
28
29 $this->plugin_name = $plugin_name;
30
31 $this->table_name = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
32
33 $this->title_length = Survey_Maker_Data::get_listtables_title_length('popup_surveys');
34
35 parent::__construct( array(
36 'singular' => __( 'Popup Survey', "survey-maker" ), //singular name of the listed records
37 'plural' => __( 'Popup Surveys', "survey-maker" ), //plural name of the listed records
38 'ajax' => false //does this table support ajax?
39 ) );
40
41 add_action( 'admin_notices', array( $this, 'popup_survey_notices' ) );
42 }
43
44 protected function get_views() {
45 $published_count = $this->get_statused_record_count( 'published' );
46 $draft_count = $this->get_statused_record_count( 'draft' );
47 $trashed_count = $this->get_statused_record_count( 'trashed' );
48 $all_count = $this->all_record_count();
49 $selected_all = "";
50 $selected_published = "";
51 $selected_draft = "";
52 $selected_trashed = "";
53 if( isset( $_GET['fstatus'] ) ){
54 switch( sanitize_text_field( $_GET['fstatus'] ) ){
55 case "published":
56 $selected_published = " style='font-weight:bold;' ";
57 break;
58 case "draft":
59 $selected_draft = " style='font-weight:bold;' ";
60 break;
61 case "trashed":
62 $selected_trashed = " style='font-weight:bold;' ";
63 break;
64 default:
65 $selected_all = " style='font-weight:bold;' ";
66 break;
67 }
68 }else{
69 $selected_all = " style='font-weight:bold;' ";
70 }
71 $status_links = array(
72 "all" => "<a ".$selected_all." href='?page=".esc_attr( $_REQUEST['page'] )."'>" . __( "All", "survey-maker" ) . " (".$all_count.")</a>",
73 );
74 if( intval( $published_count ) > 0 ){
75 $status_links["published"] = "<a ".$selected_published." href='?page=".esc_attr( $_REQUEST['page'] )."&fstatus=published'>" . __( "Published", "survey-maker" ) . " (".$published_count.")</a>";
76 }
77 if( intval( $draft_count ) > 0 ){
78 $status_links["draft"] = "<a ".$selected_draft." href='?page=".esc_attr( $_REQUEST['page'] )."&fstatus=draft'>" . __( "Draft", "survey-maker" ) . " (".$draft_count.")</a>";
79 }
80 if( intval( $trashed_count ) > 0 ){
81 $status_links["trashed"] = "<a ".$selected_trashed." href='?page=".esc_attr( $_REQUEST['page'] )."&fstatus=trashed'>" . __( "Trash", "survey-maker" ) . " (".$trashed_count.")</a>";
82 }
83 return $status_links;
84 }
85
86
87 /**
88 * Retrieve customers data from the database
89 *
90 * @param int $per_page
91 * @param int $page_number
92 *
93 * @return mixed
94 */
95 public static function get_items( $per_page = 20, $page_number = 1 ) {
96
97 global $wpdb;
98
99 $sql = "SELECT * FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
100
101 $where = array();
102
103 if ( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != ''){
104 $where[] = ' status = "' . esc_sql( sanitize_text_field( $_GET['fstatus'] ) ) . '" ';
105 }else{
106 $where[] = ' status != "trashed" ';
107 }
108
109 // if( $search != '' ){
110 // $where[] = $search;
111 // }
112
113 // if( ! Survey_Maker_Data::survey_maker_capabilities_for_editing() ){
114 $current_user = get_current_user_id();
115 $where[] = " author_id = ".$current_user." ";
116 // }
117
118 if ( ! empty( $where ) ){
119 $sql .= ' WHERE ' . implode( ' AND ', $where );
120 }
121
122 if ( ! empty( $_REQUEST['orderby'] ) ) {
123 $order_by = ( isset( $_REQUEST['orderby'] ) && sanitize_text_field( $_REQUEST['orderby'] ) != '' ) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'id';
124 $order_by .= ( ! empty( $_REQUEST['order'] ) && strtolower( $_REQUEST['order'] ) == 'asc' ) ? ' ASC' : ' DESC';
125
126 $sql_orderby = sanitize_sql_orderby( $order_by );
127
128 if ( $sql_orderby ) {
129 $sql .= ' ORDER BY ' . $sql_orderby;
130 } else {
131 $sql .= ' ORDER BY ordering DESC';
132 }
133 }else{
134 $sql .= ' ORDER BY id DESC';
135 }
136
137 $sql .= " LIMIT $per_page";
138 $sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
139
140 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
141 return $result;
142 }
143
144 public static function get_item_by_id( $id ) {
145 global $wpdb;
146
147 $sql = "SELECT * FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys WHERE id=" . esc_sql( intval( $id ) );
148
149 $result = $wpdb->get_row( $sql, 'ARRAY_A' );
150
151
152
153 return $result;
154 }
155
156 public function get_surveys(){
157 global $wpdb;
158
159 $sql = "SELECT * FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "surveys WHERE status='published' ORDER BY id DESC";
160
161 $result = $wpdb->get_results($sql, 'ARRAY_A');
162
163 return $result;
164 }
165
166 public function add_or_edit_item(){
167 global $wpdb;
168 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
169
170 if( isset( $_POST["popup_survey_action"] ) && wp_verify_nonce( $_POST["popup_survey_action"], 'popup_survey_action' ) ){
171
172 $name_prefix = 'ays_';
173
174 // Save type
175 $save_type = (isset($_POST['save_type'])) ? $_POST['save_type'] : '';
176
177 // Id of item
178 $id = isset( $_POST['id'] ) ? absint( intval( $_POST['id'] ) ) : 0;
179
180 // Title
181 $title = isset( $_POST[ $name_prefix . 'title' ] ) && $_POST[ $name_prefix . 'title' ] != '' ? stripslashes( sanitize_text_field( $_POST[ $name_prefix . 'title' ] ) ) : 'Survey popup';
182
183 // Show popup title
184 $survey_popup_enable_show_title = isset( $_POST[ $name_prefix . 'survey_popup_enable_show_title' ] ) && $_POST[ $name_prefix . 'survey_popup_enable_show_title' ] == 'on' ? 'on' : 'off';
185
186 // Popup title font size
187 $survey_popup_title_font_size = isset( $_POST[ $name_prefix . 'survey_popup_title_font_size' ] ) && $_POST[ $name_prefix . 'survey_popup_title_font_size' ] != '' ? absint( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_font_size' ] ) ) : 25;
188
189 // Popup title font size on mobile
190 $survey_popup_title_mobile_font_size = isset( $_POST[ $name_prefix . 'survey_popup_title_mobile_font_size' ] ) && $_POST[ $name_prefix . 'survey_popup_title_mobile_font_size' ] != '' ? absint( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_mobile_font_size' ] ) ) : 25;
191
192 // Popup title bg color
193 $survey_popup_title_bg_color = (isset( $_POST[$name_prefix . 'survey_popup_title_bg_color'] ) && $_POST[$name_prefix . 'survey_popup_title_bg_color'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_bg_color' ] ) : '#00000000';
194 // Popup title bg color mobile
195 $survey_popup_title_bg_color_mobile = (isset( $_POST[$name_prefix . 'survey_popup_title_bg_color_mobile'] ) && $_POST[$name_prefix . 'survey_popup_title_bg_color_mobile'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_bg_color_mobile' ] ) : '#00000000';
196
197 // Popup title text color
198 $survey_popup_title_text_color = (isset( $_POST[$name_prefix . 'survey_popup_title_text_color'] ) && $_POST[$name_prefix . 'survey_popup_title_text_color'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_text_color' ] ) : '#ffffff';
199 // Popup title text color mobile
200 $survey_popup_title_text_color_mobile = (isset( $_POST[$name_prefix . 'survey_popup_title_text_color_mobile'] ) && $_POST[$name_prefix . 'survey_popup_title_text_color_mobile'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_text_color_mobile' ] ) : '#ffffff';
201
202 // Popup title alignment
203 $survey_popup_title_alignment = (isset( $_POST[$name_prefix . 'survey_popup_title_alignment'] ) && $_POST[$name_prefix . 'survey_popup_title_alignment'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_alignment' ] ) : 'left';
204
205 // Popup title alignment
206 $survey_popup_title_alignment_on_mobile = (isset( $_POST[$name_prefix . 'survey_popup_title_alignment_on_mobile'] ) && $_POST[$name_prefix . 'survey_popup_title_alignment_on_mobile'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_alignment_on_mobile' ] ) : 'left';
207
208 // Popup title transform
209 $survey_popup_title_transform = (isset( $_POST[$name_prefix . 'survey_popup_title_transform'] ) && $_POST[$name_prefix . 'survey_popup_title_transform'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_transform' ] ) : 'none';
210 // Popup title transform
211 $survey_popup_title_transform_mobile = (isset( $_POST[$name_prefix . 'survey_popup_title_transform_mobile'] ) && $_POST[$name_prefix . 'survey_popup_title_transform_mobile'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_transform_mobile' ] ) : 'none';
212
213 // Popup title letter spacing
214 $survey_popup_title_letter_spacing = (isset( $_POST[ $name_prefix . 'survey_popup_title_letter_spacing' ] ) && $_POST[ $name_prefix . 'survey_popup_title_letter_spacing' ] != '' && $_POST[ $name_prefix . 'survey_popup_title_letter_spacing' ] != '0' ) ? absint(intval(sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_letter_spacing' ] ))) : '0';
215
216 // Popup title letter spacing on mobile
217 $survey_popup_title_letter_spacing_on_mobile = (isset( $_POST[ $name_prefix . 'survey_popup_title_letter_spacing_on_mobile' ] ) && $_POST[ $name_prefix . 'survey_popup_title_letter_spacing_on_mobile' ] != '' && $_POST[ $name_prefix . 'survey_popup_title_letter_spacing_on_mobile' ] != '0' ) ? absint(intval(sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_letter_spacing_on_mobile' ] ))) : '0';
218
219 // Hide popup title on mobile
220 $survey_popup_hide_title_on_mobile = (isset( $_POST[$name_prefix . 'survey_popup_hide_title_on_mobile'] ) && $_POST[$name_prefix . 'survey_popup_hide_title_on_mobile'] == 'on') ? 'on' : 'off';
221
222 // Title border radius
223 $survey_popup_title_border_radius = isset( $_POST[ $name_prefix . 'survey_popup_title_border_radius' ] ) && $_POST[ $name_prefix . 'survey_popup_title_border_radius' ] != '' ? absint( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_border_radius' ] ) ) : 0;
224 // Title border radius mobile
225 $survey_popup_title_border_radius_mobile = isset( $_POST[ $name_prefix . 'survey_popup_title_border_radius_mobile' ] ) && $_POST[ $name_prefix . 'survey_popup_title_border_radius_mobile' ] != '' ? absint( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_title_border_radius_mobile' ] ) ) : 0;
226
227 if($title == ''){
228 $url = esc_url_raw( remove_query_arg( false ) );
229 wp_redirect( $url );
230 }
231
232 // Author ID
233 $user_id = get_current_user_id();
234 $author_id = isset( $_POST[ $name_prefix . 'author_id' ] ) && $_POST[ $name_prefix . 'author_id' ] != '' ? intval( sanitize_text_field( $_POST[ $name_prefix . 'author_id' ] ) ) : $user_id;
235
236 // Status
237 $status = isset( $_POST[ $name_prefix . 'status' ] ) && $_POST[ $name_prefix . 'status' ] == 'on' ? 'published' : 'unpublished';
238
239 // Trash status
240 $trash_status = '';
241
242 // Date created
243 $date_created = isset( $_POST[ $name_prefix . 'date_created' ] ) && Survey_Maker_Admin::validateDate( $_POST[ $name_prefix . 'date_created' ] ) ? sanitize_text_field( $_POST[ $name_prefix . 'date_created' ] ) : current_time( 'mysql' );
244
245 // Date modified
246 $date_modified = isset( $_POST[ $name_prefix . 'date_modified' ] ) && Survey_Maker_Admin::validateDate( $_POST[ $name_prefix . 'date_modified' ] ) ? sanitize_text_field( $_POST[ $name_prefix . 'date_modified' ] ) : current_time( 'mysql' );
247
248 // Survey_id
249 $survey_id = isset( $_POST[ $name_prefix . 'survey_id' ] ) && $_POST[ $name_prefix . 'survey_id' ] != '' ? sanitize_text_field( $_POST[ $name_prefix . 'survey_id' ] ) : '';
250
251 // Show All
252 $show_all = isset( $_POST[$name_prefix . 'survey_show_all'] ) && $_POST[$name_prefix . 'survey_show_all'] != '' ? sanitize_text_field( $_POST[ $name_prefix . 'survey_show_all' ] ) : 'all';
253
254 // Width
255 $survey_width = (isset( $_POST[ $name_prefix . 'popup_survey_width' ] ) && $_POST[ $name_prefix . 'popup_survey_width' ] != '') ? absint( sanitize_text_field( $_POST[ $name_prefix . 'popup_survey_width' ] ) ) : 800;
256 // Mobile width
257 $survey_width_mobile = (isset( $_POST[ $name_prefix . 'popup_survey_width_mobile' ] ) && $_POST[ $name_prefix . 'popup_survey_width_mobile' ] != '') ? absint( sanitize_text_field( $_POST[ $name_prefix . 'popup_survey_width_mobile' ] ) ) : 800;
258
259 // Height
260 $survey_heigth = (isset( $_POST[ $name_prefix . 'popup_survey_height' ] ) && $_POST[ $name_prefix . 'popup_survey_height' ] != '') ? absint( sanitize_text_field( $_POST[ $name_prefix . 'popup_survey_height' ] ) ) : 450;
261 // Height mobile
262 $survey_heigth_mobile = (isset( $_POST[ $name_prefix . 'popup_survey_height_mobile' ] ) && $_POST[ $name_prefix . 'popup_survey_height_mobile' ] != '') ? absint( sanitize_text_field( $_POST[ $name_prefix . 'popup_survey_height_mobile' ] ) ) : 450;
263
264 // popup_position
265 $popup_position = (isset( $_POST[$name_prefix . 'survey_popup_position'] ) && $_POST[$name_prefix . 'survey_popup_position'] != 'center-center') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_position' ] ) : 'center-center';
266
267 // popup_margin
268 $popup_margin = (isset( $_POST[$name_prefix . 'survey_popup_margin'] ) && $_POST[$name_prefix . 'survey_popup_margin'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_margin' ] ) : '';
269
270 // //Popup trigger
271 $popup_trigger = (isset( $_POST[$name_prefix . 'survey_popup_trigger'] ) && $_POST[$name_prefix . 'survey_popup_trigger'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_trigger' ] ) : 'on_load';
272
273 // Popup close after finish
274 $survey_enable_popup_close_after_finish = isset( $_POST[ $name_prefix . 'survey_enable_popup_close_after_finish' ] ) && $_POST[ $name_prefix . 'survey_enable_popup_close_after_finish' ] == 'on' ? 'on' : 'off';
275 $survey_popup_close_after_finish_delay = (isset($_POST[ $name_prefix . 'survey_popup_close_after_finish_delay' ]) && $_POST[ $name_prefix . 'survey_popup_close_after_finish_delay' ] != '') ? absint ( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_close_after_finish_delay' ] ) ) : '';
276
277 //Popup selector
278 $popup_selector = (isset( $_POST[$name_prefix . 'survey_popup_selector'] ) && $_POST[$name_prefix . 'survey_popup_selector'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_selector' ] ) : '';
279
280 // // Popup background color
281 $popup_bg_color = (isset( $_POST[$name_prefix . 'survey_popup_bg_color'] ) && $_POST[$name_prefix . 'survey_popup_bg_color'] != '') ? sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_bg_color' ] ) : '#ffffff';
282
283 // Popup background color | Mobile
284 $popup_bg_color_mobile = (isset( $_POST[$name_prefix . 'survey_popup_bg_color_mobile'] ) && $_POST[$name_prefix . 'survey_popup_bg_color_mobile'] != '') ? stripslashes( sanitize_text_field( $_POST[ $name_prefix . 'survey_popup_bg_color_mobile' ] ) ) : '#ffffff';
285
286 $hide_popup = isset( $_POST[ $name_prefix . 'survey_hide_popup' ] ) && $_POST[ $name_prefix . 'survey_hide_popup' ] == 'on' ? sanitize_text_field( $_POST[ $name_prefix . 'survey_hide_popup' ] ) : 'off';
287
288 // Hide Popup after close
289 $hide_popup_after_close = isset( $_POST[ $name_prefix . 'survey_hide_popup_after_close' ] ) && $_POST[ $name_prefix . 'survey_hide_popup_after_close' ] == 'on' ? sanitize_text_field( $_POST[ $name_prefix . 'survey_hide_popup_after_close' ] ) : 'off';
290
291 // Popup full screen mode
292 $survey_popup_full_screen = isset( $_POST[ $name_prefix . 'survey_enable_popup_full_screen_mode' ] ) && $_POST[ $name_prefix . 'survey_enable_popup_full_screen_mode' ] == 'on' ? 'on' : 'off';
293
294 // Close by pressing the ESC
295 $survey_popup_enable_close_by_esc = isset( $_POST[ $name_prefix . 'survey_popup_enable_close_by_esc' ] ) && $_POST[ $name_prefix . 'survey_popup_enable_close_by_esc' ] == 'on' ? 'on' : 'off';
296
297 // Options
298 $options = array(
299 "popup_enable_show_title" => $survey_popup_enable_show_title,
300 "popup_title_font_size" => $survey_popup_title_font_size,
301 "popup_title_mobile_font_size" => $survey_popup_title_mobile_font_size,
302 "popup_title_bg_color" => $survey_popup_title_bg_color,
303 "popup_title_bg_color_mobile" => $survey_popup_title_bg_color_mobile,
304 "popup_title_text_color" => $survey_popup_title_text_color,
305 "popup_title_text_color_mobile" => $survey_popup_title_text_color_mobile,
306 "popup_title_alignment" => $survey_popup_title_alignment,
307 "popup_title_alignment_on_mobile" => $survey_popup_title_alignment_on_mobile,
308 "popup_title_transform" => $survey_popup_title_transform,
309 "popup_title_transform_mobile" => $survey_popup_title_transform_mobile,
310 "popup_title_letter_spacing" => $survey_popup_title_letter_spacing,
311 "popup_title_letter_spacing_on_mobile" => $survey_popup_title_letter_spacing_on_mobile,
312 "popup_hide_title_on_mobile" => $survey_popup_hide_title_on_mobile,
313 "popup_title_border_radius" => $survey_popup_title_border_radius,
314 "popup_title_border_radius_mobile" => $survey_popup_title_border_radius_mobile,
315 "width" => $survey_width,
316 "width_mobile" => $survey_width_mobile,
317 "height" => $survey_heigth,
318 "height_mobile" => $survey_heigth_mobile,
319 "popup_position" => $popup_position,
320 "popup_margin" => $popup_margin,
321 "popup_trigger" => $popup_trigger,
322 "enable_popup_close_after_finish" => $survey_enable_popup_close_after_finish,
323 "popup_close_after_finish_delay" => $survey_popup_close_after_finish_delay,
324 "popup_selector" => $popup_selector,
325 'hide_popup' => $hide_popup,
326 'hide_popup_after_close' => $hide_popup_after_close,
327 'full_screen_mode' => $survey_popup_full_screen,
328 'popup_enable_close_by_esc' => $survey_popup_enable_close_by_esc,
329 'popup_bg_color' => $popup_bg_color,
330 'popup_bg_color_mobile' => $popup_bg_color_mobile,
331 );
332
333 $message = '';
334 if( $id == 0 ){
335 $result = $wpdb->insert(
336 $table,
337 array(
338 'survey_id' => $survey_id,
339 'title' => $title,
340 "show_all" => $show_all,
341 'status' => $status,
342 'trash_status' => $trash_status,
343 'author_id' => $author_id,
344 'date_created' => $date_created,
345 'date_modified' => $date_modified,
346 'options' => json_encode( $options ),
347 ),
348 array(
349 '%d', // survey_id
350 '%s', // title
351 '%s', // show_all
352 '%s', // status
353 '%s', // trash_status
354 '%d', // author_id
355 '%s', // date_created
356 '%s', // date_modified
357 '%s', // options
358 )
359 );
360
361 $inserted_id = $wpdb->insert_id;
362 $message = 'created';
363 }else{
364 $result = $wpdb->update(
365 $table,
366 array(
367 'survey_id' => $survey_id,
368 'title' => $title,
369 "show_all" => $show_all,
370 'status' => $status,
371 'trash_status' => $trash_status,
372 'author_id' => $author_id,
373 'date_created' => $date_created,
374 'date_modified' => $date_modified,
375 'options' => json_encode( $options ),
376 ),
377 array( 'id' => $id ),
378 array(
379 '%d', // survey_id
380 '%s', // title
381 '%s', // show_all
382 '%s', // status
383 '%s', // trash_status
384 '%d', // author_id
385 '%s', // date_created
386 '%s', // date_modified
387 '%s', // options
388 ),
389 array( '%d' )
390 );
391
392 $inserted_id = $id;
393 $message = 'updated';
394 }
395
396 if( $result >= 0 ) {
397 if($save_type == 'apply'){
398 if($id == 0){
399 $url = esc_url_raw( add_query_arg( array(
400 "action" => "edit",
401 "id" => $inserted_id,
402 "status" => $message
403 ) ) );
404 }else{
405 $url = esc_url_raw( add_query_arg( array(
406 "status" => $message
407 ) ) );
408 }
409 wp_redirect( $url );
410 }elseif($save_type == 'save_new'){
411 $url = remove_query_arg( array('id') );
412 $url = esc_url_raw( add_query_arg( array(
413 "action" => "add",
414 "status" => $message
415 ), $url ) );
416 wp_redirect( $url );
417 }else{
418 $url = remove_query_arg( array('action', 'id') );
419 $url = esc_url_raw( add_query_arg( array(
420 "status" => $message
421 ), $url ) );
422 wp_redirect( $url );
423 }
424 }
425 }
426 }
427
428 /**
429 * Delete a customer record.
430 *
431 * @param int $id customer ID
432 */
433 public static function delete_items( $id ) {
434 global $wpdb;
435
436 $wpdb->delete(
437 $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys",
438 array( 'id' => $id ),
439 array( '%d' )
440 );
441
442 }
443
444 /**
445 * Move to trash a customer record.
446 *
447 * @param int $id customer ID
448 */
449 public static function trash_items( $id ) {
450 global $wpdb;
451 $db_item = self::get_item_by_id( $id );
452
453 $wpdb->update(
454 $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys",
455 array(
456 'status' => 'trashed',
457 'trash_status' => $db_item['status'],
458 ),
459 array( 'id' => $id ),
460 array( '%s', '%s' ),
461 array( '%d' )
462 );
463
464 }
465
466 /**
467 * Restore a customer record.
468 *
469 * @param int $id customer ID
470 */
471 public static function restore_items( $id ) {
472 global $wpdb;
473 $db_item = self::get_item_by_id( $id );
474
475 $wpdb->update(
476 $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys",
477 array(
478 'status' => $db_item['trash_status'],
479 'trash_status' => '',
480 ),
481 array( 'id' => $id ),
482 array( '%s', '%s' ),
483 array( '%d' )
484 );
485 }
486
487 /*
488 * Returns the count of records in the database.
489 *
490 * @return null|string
491 */
492 public static function record_count() {
493 global $wpdb;
494 $filter = array();
495 $sql = "SELECT COUNT(*) FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
496
497 if( isset( $_REQUEST['fstatus'] ) ){
498 $fstatus = sanitize_text_field( $_REQUEST['fstatus'] );
499 if($fstatus !== null){
500 $filter[] = " status = '". esc_sql( $fstatus ) ."' ";
501 }
502 }else{
503 $filter[] = " status != 'trashed' ";
504 }
505
506 // if( ! Survey_Maker_Data::survey_maker_capabilities_for_editing() ){
507 $current_user = get_current_user_id();
508 $filter[] = " author_id = ".$current_user." ";
509 // }
510
511 if(count($filter) !== 0){
512 $sql .= " WHERE ".implode(" AND ", $filter);
513 }
514
515 return $wpdb->get_var( $sql );
516 }
517
518 public static function all_record_count() {
519 global $wpdb;
520
521 $sql = "SELECT COUNT(*) FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys WHERE status != 'trashed'";
522
523 // if( ! Survey_Maker_Data::survey_maker_capabilities_for_editing() ){
524 $current_user = get_current_user_id();
525 $sql .= " AND author_id = ".$current_user." ";
526 // }
527
528 return $wpdb->get_var( $sql );
529 }
530
531 public static function get_statused_record_count( $status ) {
532 global $wpdb;
533
534 $sql = "SELECT COUNT(*) FROM " . $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys WHERE status='" . esc_sql( $status ) . "'";
535
536 // if( ! Survey_Maker_Data::survey_maker_capabilities_for_editing() ){
537 $current_user = get_current_user_id();
538 $sql .= " AND author_id = ".$current_user." ";
539 // }
540
541 return $wpdb->get_var( $sql );
542 }
543
544 public function publish_unpublish_popup_survey( $id, $action ) {
545 global $wpdb;
546 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "popup_surveys";
547
548 if ( is_null($id) ) {
549 return false;
550 }
551
552 if ($action == 'unpublish') {
553 $status = 'unpublished';
554 $message = 'unpublished';
555 }else{
556 $status = 'published';
557 $message = 'published';
558 }
559
560 $pb_result = $wpdb->update(
561 $table,
562 array(
563 "status" => $status
564 ),
565 array( "id" => $id ),
566 array( "%s" ),
567 array( "%d" )
568 );
569
570 $url = esc_url_raw( remove_query_arg(array("action", "id", "_wpnonce")) ) . "&status=" . $message . "&type=success";
571 wp_redirect( $url );
572 }
573
574
575 /** Text displayed when no customer data is available */
576 public function no_items() {
577 Survey_Maker_Data::survey_no_items_list_tables('popup surveys');
578 }
579
580
581 /**
582 * Render a column when no column specific method exist.
583 *
584 * @param array $item
585 * @param string $column_name
586 *
587 * @return mixed
588 */
589 public function column_default( $item, $column_name ) {
590 switch ( $column_name ) {
591 case 'title':
592 case 'survey_id':
593 case 'id':
594 return $item[ $column_name ];
595 break;
596 default:
597 return print_r( $item, true ); //Show the whole array for troubleshooting purposes
598 }
599 }
600
601 /**
602 * Render the bulk edit checkbox
603 *
604 * @param array $item
605 *
606 * @return string
607 */
608 function column_cb( $item ) {
609
610 // if(intval($item['id']) === 1){
611 // return;
612 // }
613
614 return sprintf(
615 '<input type="checkbox" name="bulk-delete[]" value="%s" />', $item['id']
616 );
617 }
618
619
620 /**
621 * Method for name column
622 *
623 * @param array $item an array of DB data
624 *
625 * @return string
626 */
627 function column_title( $item ) {
628 $unpublish_nonce = wp_create_nonce( $this->plugin_name . "-unpublish-popup-survey" );
629 $publish_nonce = wp_create_nonce( $this->plugin_name . "-publish-popup-survey" );
630
631 if($item['status'] == 'trashed'){
632 $delete_nonce = wp_create_nonce( $this->plugin_name . '-delete-popup-survey' );
633 }else{
634 $delete_nonce = wp_create_nonce( $this->plugin_name . '-trash-popup-survey' );
635 }
636
637 if (isset($item['status']) && $item['status'] == 'published') {
638 $publish_button = 'unpublish';
639 $publish_button_val = sprintf( '<a href="?page=%s&action=%s&id=%d&_wpnonce=%s">'. __('Unpublish', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'unpublish', absint( $item['id'] ), $unpublish_nonce );
640 }else{
641 $publish_button = 'publish';
642 $publish_button_val = sprintf( '<a href="?page=%s&action=%s&id=%d&_wpnonce=%s">'. __('Publish', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'publish', absint( $item['id'] ), $publish_nonce );
643 }
644
645 $survey_title = stripcslashes( $item['title'] );
646
647 $q = esc_attr( $survey_title );
648
649 $restitle = Survey_Maker_Admin::ays_restriction_string( "word", $survey_title, $this->title_length );
650
651 $fstatus = '';
652 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
653 $fstatus = '&fstatus=' . sanitize_text_field( $_GET['fstatus'] );
654 }
655
656 $title = sprintf( '<a href="?page=%s&action=%s&id=%d" title="%s">%s</a>', esc_attr( $_REQUEST['page'] ), 'edit', absint( $item['id'] ), $q, stripcslashes($item['title']));
657
658 $actions = array();
659 if($item['status'] == 'trashed'){
660 $title = sprintf( '<strong><a>%s</a></strong>', $restitle );
661 $actions['restore'] = sprintf( '<a href="?page=%s&action=%s&id=%d&_wpnonce=%s'.$fstatus.'">'. __('Restore', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'restore', absint( $item['id'] ), $delete_nonce );
662 $actions['delete'] = sprintf( '<a class="ays_confirm_del" data-message="%s" href="?page=%s&action=%s&id=%s&_wpnonce=%s'.$fstatus.'">'. __('Delete Permanently', "survey-maker") .'</a>', $restitle, esc_attr( $_REQUEST['page'] ), 'delete', absint( $item['id'] ), $delete_nonce );
663 }else{
664 $draft_text = '';
665 if( $item['status'] == 'draft' && !( isset( $_GET['fstatus'] ) && $_GET['fstatus'] == 'draft' )){
666 $draft_text = ' — ' . '<span class="post-state">' . __( "Draft", "survey-maker" ) . '</span>';
667 }
668 $title = sprintf( '<strong><a href="?page=%s&action=%s&id=%d" title="%s">%s</a>%s</strong>', esc_attr( $_REQUEST['page'] ), 'edit', absint( $item['id'] ), $q, $restitle, $draft_text );
669
670 $actions['edit'] = sprintf( '<a href="?page=%s&action=%s&id=%d">'. __('Edit', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'edit', absint( $item['id'] ) );
671
672 $actions[$publish_button] = $publish_button_val;
673 // $actions['duplicate'] = sprintf( '<a href="?page=%s&action=%s&id=%d&_wpnonce=%s'.$fstatus.'">'. __('Duplicate', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'duplicate', absint( $item['id'] ), $delete_nonce );
674 $actions['trash'] = sprintf( '<a href="?page=%s&action=%s&id=%s&_wpnonce=%s'.$fstatus.'">'. __('Move to trash', "survey-maker") .'</a>', esc_attr( $_REQUEST['page'] ), 'trash', absint( $item['id'] ), $delete_nonce );
675 }
676
677 return $title . $this->row_actions( $actions );
678 }
679
680 function column_survey_id( $item ) {
681 global $wpdb;
682 $sql = "SELECT * FROM {$wpdb->prefix}ayssurvey_surveys WHERE id=" . absint( intval( $item["survey_id"] ) );
683
684 $survey = $wpdb->get_row( $sql );
685
686 if($survey !== null){
687 return $survey->title;
688 }else{
689 return '';
690 }
691
692 }
693
694 function column_status( $item ) {
695 global $wpdb;
696 $status = ucfirst( $item['status'] );
697 $date = date( 'Y/m/d', strtotime( $item['date_modified'] ) );
698 $title_date = date( 'l jS \of F Y h:i:s A', strtotime( $item['date_modified'] ) );
699 $html = "<p style='font-size:14px;margin:0;'>" . $status . "</p>";
700 $html .= "<p style=';font-size:14px;margin:0;text-decoration: dotted underline;' title='" . $title_date . "'>" . $date . "</p>";
701 return $html;
702 }
703
704 function column_author_id( $item ) {
705 $user = get_user_by( 'id', $item['author_id'] );
706 $author_name = '';
707 if($user->data->display_name == ''){
708 if($user->data->user_nicename == ''){
709 $author_name = $user->data->user_login;
710 }else{
711 $author_name = $user->data->user_nicename;
712 }
713 }else{
714 $author_name = $user->data->display_name;
715 }
716 return $author_name;
717 }
718
719
720
721 /**
722 * Associative array of columns
723 *
724 * @return array
725 */
726 function get_columns() {
727 $columns = array(
728 'cb' => '<input type="checkbox" />',
729 'title' => __( 'Title', "survey-maker" ),
730 );
731
732 // if( Survey_Maker_Data::survey_maker_capabilities_for_editing() ){
733 $columns['author_id'] = __( 'Author', "survey-maker" );
734 // }
735
736 $columns['survey_id'] = __( 'Survey', "survey-maker" );
737 $columns['status'] = __( 'Status', "survey-maker" );
738 $columns['id'] = __( 'ID', "survey-maker" );
739
740 if( isset( $_GET['action'] ) && ( $_GET['action'] == 'add' || $_GET['action'] == 'edit' ) ){
741 return array();
742 }
743
744 return $columns;
745 }
746
747
748 /**
749 * Columns to make sortable.
750 *
751 * @return array
752 */
753 public function get_sortable_columns() {
754 $sortable_columns = array(
755 'title' => array( 'title', true ),
756 'id' => array( 'id', true ),
757 );
758
759 return $sortable_columns;
760 }
761
762 /**
763 * Returns an associative array containing the bulk action
764 *
765 * @return array
766 */
767 public function get_bulk_actions() {
768 $actions = array(
769 // 'bulk-duplicate' => __( 'Duplicate', "survey-maker" ),
770 'bulk-trash' => __( 'Move to trash', "survey-maker" ),
771 );
772
773 if(isset($_GET['fstatus']) && sanitize_text_field( $_GET['fstatus'] ) == 'trashed'){
774 $actions = array(
775 'bulk-restore' => __( 'Restore', "survey-maker" ),
776 'bulk-delete' => __( 'Delete Permanently', "survey-maker" ),
777 );
778 }
779
780 return $actions;
781 }
782
783 /**
784 * Handles data query and filter, sorting, and pagination.
785 */
786 public function prepare_items() {
787
788 $this->_column_headers = $this->get_column_info();
789
790 /** Process bulk action */
791 $this->process_bulk_action();
792
793 $per_page = $this->get_items_per_page( 'popup_survey_per_page', 20 );
794 $current_page = $this->get_pagenum();
795 $total_items = self::record_count();
796
797 $this->set_pagination_args( array(
798 'total_items' => $total_items, //WE have to calculate the total number of items
799 'per_page' => $per_page //WE have to determine how many items to show on a page
800 ) );
801
802 $this->items = self::get_items( $per_page, $current_page );
803 }
804
805 public function process_bulk_action() {
806
807 //Detect when a bulk action is being triggered...
808 if ( 'delete' === $this->current_action() ) {
809
810 // In our file that handles the request, verify the nonce.
811 $nonce = esc_attr( $_REQUEST['_wpnonce'] );
812
813 if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-delete-popup-survey' ) ) {
814 die( 'Go get a life script kiddies' );
815 }
816 else {
817 self::delete_items( absint( $_GET['id'] ) );
818
819 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
820 // add_query_arg() return the current url
821
822 $add_query_args = array(
823 "status" => 'deleted'
824 );
825 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
826 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
827 }
828 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
829 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
830 wp_redirect( $url );
831 }
832
833 }
834
835 //Detect when a bulk action is being triggered...
836 if ( 'trash' === $this->current_action() ) {
837
838 // In our file that handles the request, verify the nonce.
839 $nonce = esc_attr( $_REQUEST['_wpnonce'] );
840
841 if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-trash-popup-survey' ) ) {
842 die( 'Go get a life script kiddies' );
843 }
844 else {
845 self::trash_items( absint( $_GET['id'] ) );
846
847 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
848 // add_query_arg() return the current url
849
850 $add_query_args = array(
851 "status" => 'trashed'
852 );
853 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
854 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
855 }
856 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
857 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
858 wp_redirect( $url );
859 }
860
861 }
862
863 //Detect when a bulk action is being triggered...
864 if ( 'restore' === $this->current_action() ) {
865
866 // In our file that handles the request, verify the nonce.
867 $nonce = esc_attr( $_REQUEST['_wpnonce'] );
868
869 if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-delete-popup-survey' ) ) {
870 die( 'Go get a life script kiddies' );
871 }
872 else {
873 self::restore_items( absint( $_GET['id'] ) );
874
875 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
876 // add_query_arg() return the current url
877
878 $add_query_args = array(
879 "status" => 'restored'
880 );
881 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
882 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
883 }
884 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
885 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
886 wp_redirect( $url );
887 }
888
889 }
890
891 //Detect when a bulk action is being triggered...
892 if ( 'duplicate' === $this->current_action() ) {
893
894 // In our file that handles the request, verify the nonce.
895 $nonce = esc_attr( $_REQUEST['_wpnonce'] );
896
897 if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-trash-popup-survey' ) ) {
898 die( 'Go get a life script kiddies' );
899 }
900 else {
901 self::duplicate_items( absint( $_GET['id'] ) );
902
903 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
904 // add_query_arg() return the current url
905
906 $add_query_args = array(
907 "status" => 'duplicated'
908 );
909 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
910 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
911 }
912 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
913 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
914 wp_redirect( $url );
915 }
916
917 }
918
919 // If the delete bulk action is triggered
920 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' ) || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-delete' ) ) {
921
922 $delete_ids = ( isset( $_POST['bulk-delete'] ) && ! empty( $_POST['bulk-delete'] ) ) ? esc_sql( $_POST['bulk-delete'] ) : array();
923
924 // loop over the array of record IDs and delete them
925 foreach ( $delete_ids as $id ) {
926 self::delete_items( $id );
927 }
928
929 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
930 // add_query_arg() return the current url
931 $add_query_args = array(
932 "status" => 'all-deleted'
933 );
934 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
935 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
936 }
937 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
938 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
939 wp_redirect( $url );
940 }
941
942 // If the delete bulk action is triggered
943 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-trash' ) || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-trash' ) ) {
944
945 $trash_ids = ( isset( $_POST['bulk-delete'] ) && ! empty( $_POST['bulk-delete'] ) ) ? esc_sql( $_POST['bulk-delete'] ) : array();
946
947 // loop over the array of record IDs and delete them
948 foreach ( $trash_ids as $id ) {
949 self::trash_items( $id );
950 }
951
952 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
953 // add_query_arg() return the current url
954 $add_query_args = array(
955 "status" => 'all-trashed'
956 );
957 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
958 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
959 }
960 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
961 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
962 wp_redirect( $url );
963 }
964
965 // If the delete bulk action is triggered
966 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-restore' ) || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-restore' ) ) {
967
968 $restore_ids = ( isset( $_POST['bulk-delete'] ) && ! empty( $_POST['bulk-delete'] ) ) ? esc_sql( $_POST['bulk-delete'] ) : array();
969
970 // loop over the array of record IDs and delete them
971 foreach ( $restore_ids as $id ) {
972 self::restore_items( $id );
973 }
974
975 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
976 // add_query_arg() return the current url
977 $add_query_args = array(
978 "status" => 'all-restored'
979 );
980 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
981 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
982 }
983 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
984 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
985 wp_redirect( $url );
986 }
987
988 // If the delete bulk action is triggered
989 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-duplicate' ) || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-duplicate' ) ) {
990
991 $restore_ids = ( isset( $_POST['bulk-delete'] ) && ! empty( $_POST['bulk-delete'] ) ) ? esc_sql( $_POST['bulk-delete'] ) : array();
992
993 // loop over the array of record IDs and delete them
994 foreach ( $restore_ids as $id ) {
995 self::duplicate_items( $id );
996 }
997
998 // esc_url_raw() is used to prevent converting ampersand in url to "#038;"
999 // add_query_arg() return the current url
1000 $add_query_args = array(
1001 "status" => 'all-duplicated'
1002 );
1003 if( isset( $_GET['fstatus'] ) && $_GET['fstatus'] != '' ){
1004 $add_query_args['fstatus'] = sanitize_text_field( $_GET['fstatus'] );
1005 }
1006 $url = remove_query_arg( array('action', 'id', '_wpnonce') );
1007 $url = esc_url_raw( add_query_arg( $add_query_args, $url ) );
1008 wp_redirect( $url );
1009 }
1010 }
1011
1012 public function popup_survey_notices(){
1013 $status = (isset($_REQUEST['status'])) ? sanitize_text_field( $_REQUEST['status'] ) : '';
1014
1015 if ( empty( $status ) )
1016 return;
1017
1018 $error = false;
1019 switch ( $status ) {
1020 case 'created':
1021 $updated_message = esc_html( __( 'Popup created.', "survey-maker" ) );
1022 break;
1023 case 'updated':
1024 $updated_message = esc_html( __( 'Popup saved.', "survey-maker" ) );
1025 break;
1026 case 'duplicated':
1027 $updated_message = esc_html( __( 'Popup duplicated.', "survey-maker" ) );
1028 break;
1029 case 'deleted':
1030 $updated_message = esc_html( __( 'Popup deleted.', "survey-maker" ) );
1031 break;
1032 case 'trashed':
1033 $updated_message = esc_html( __( 'Popup moved to trash.', "survey-maker" ) );
1034 break;
1035 case 'restored':
1036 $updated_message = esc_html( __( 'Popup restored.', "survey-maker" ) );
1037 break;
1038 case 'all-duplicated':
1039 $updated_message = esc_html( __( 'Popups are duplicated.', "survey-maker" ) );
1040 break;
1041 case 'all-deleted':
1042 $updated_message = esc_html( __( 'Popups are deleted.', "survey-maker" ) );
1043 break;
1044 case 'all-trashed':
1045 $updated_message = esc_html( __( 'Popups are moved to trash.', "survey-maker" ) );
1046 break;
1047 case 'all-restored':
1048 $updated_message = esc_html( __( 'Popups are restored.', "survey-maker" ) );
1049 break;
1050 case 'published':
1051 $updated_message = esc_html( __( 'Popups are published.', "survey-maker" ) );
1052 break;
1053 case 'unpublished':
1054 $updated_message = esc_html( __( 'Popups are unpublished.', "survey-maker" ) );
1055 break;
1056 case 'empty-title':
1057 $error = true;
1058 $updated_message = esc_html( __( 'Error: Popup title can not be empty.', "survey-maker" ) );
1059 break;
1060 default:
1061 break;
1062 }
1063
1064 if ( empty( $updated_message ) )
1065 return;
1066
1067 $notice_class = 'success';
1068 if( $error ){
1069 $notice_class = 'error';
1070 }
1071 ?>
1072 <div class="notice notice-<?php echo esc_attr($notice_class); ?> is-dismissible">
1073 <p> <?php echo esc_html($updated_message); ?> </p>
1074 </div>
1075 <?php
1076 }
1077 }
1078