TrashConfirmation.php
| 1 | <?php |
| 2 | namespace NestedPages\Entities\Confirmation; |
| 3 | |
| 4 | /** |
| 5 | * Confirm page(s) moved to trash |
| 6 | */ |
| 7 | class TrashConfirmation implements ConfirmationInterface |
| 8 | { |
| 9 | public function setMessage() |
| 10 | { |
| 11 | $out = ''; |
| 12 | |
| 13 | // Show number of Links (np-redirect) Deleted if applicable |
| 14 | if ( isset($_GET['link_ids']) ) : |
| 15 | $links_trashed = ( explode(',', $_GET['link_ids']) ); |
| 16 | $number_trashed = count($links_trashed); |
| 17 | $out .= ( $number_trashed > 1 ) |
| 18 | ? ' ' . $number_trashed . ' ' . __('Links Removed.', 'wp-nested-pages') . ' ' |
| 19 | : ' ' . $number_trashed . ' ' . __('Link Removed.', 'wp-nested-pages') . ' '; |
| 20 | endif; |
| 21 | |
| 22 | // Post(s) Moved to Trash |
| 23 | if ( isset($_GET['ids']) ) : |
| 24 | $trashed = ( explode(',', $_GET['ids']) ); |
| 25 | $post_type = get_post_type($trashed[0]); |
| 26 | $post_type_object = get_post_type_object($post_type); |
| 27 | $out .= ( count($trashed) > 1 ) |
| 28 | ? count($trashed) . ' ' . esc_html($post_type_object->labels->name) . ' ' . __('moved to the Trash.', 'wp-nested-pages') |
| 29 | : '<strong>' . get_the_title($trashed[0]) . ' </strong>' . __('moved to the Trash.', 'wp-nested-pages'); |
| 30 | // Undo Link |
| 31 | if ( current_user_can('delete_pages') ) { |
| 32 | $ids = preg_replace( '/[^0-9,]/', '', $_GET['ids'] ); |
| 33 | $out .= ' <a href="' . wp_nonce_url( admin_url( 'edit.php?&post_type=' . esc_attr($post_type) . '&doaction=undo'. '&action=untrash&ids=' . esc_attr($ids) ), 'bulk-posts') . '">' . __( 'Undo' ) . "</a>"; |
| 34 | } |
| 35 | endif; |
| 36 | |
| 37 | return $out; |
| 38 | } |
| 39 | } |