PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.6.0
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.6.0
3.53.0 3.52.0 3.51.0 3.50.0 3.45.0 3.38.0 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.40.0 3.40.1 3.41.0 3.42.0 3.43.0 3.44.0 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 All 177 releases
simple-tags / inc / terms-functions.php

terms-functions.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.6.0, at inc/terms-functions.php

68 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Handle the save and deletion of terms data.
5 */
6 function taxopress_process_terms()
7 {
8
9 if (wp_doing_ajax()) {
10 return;
11 }
12
13 if (!is_admin()) {
14 return;
15 }
16
17 if(!current_user_can('simple_tags')){
18 return;
19 }
20
21 if (empty($_GET)) {
22 return;
23 }
24
25 if (!isset($_GET['page'])) {
26 return;
27 }
28 if ('st_terms' !== $_GET['page']) {
29 return;
30 }
31
32 if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'taxopress-delete-terms') {
33 $nonce = sanitize_text_field($_REQUEST['_wpnonce']);
34 if (wp_verify_nonce($nonce, 'terms-action-request-nonce')) {
35 $term = get_term(sanitize_text_field($_REQUEST['taxopress_terms']));
36 wp_delete_term( $term->term_id, $term->taxonomy );
37 }
38 add_action('admin_notices', "taxopress_term_delete_success_admin_notice");
39 add_filter('removable_query_args', 'taxopress_delete_terms_filter_removable_query_args');
40 }
41 }
42 add_action('admin_init', 'taxopress_process_terms', 8);
43
44 /**
45 * Successful deleted callback.
46 */
47 function taxopress_term_delete_success_admin_notice()
48 {
49 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
50 echo taxopress_admin_notices_helper(esc_html__('Term deleted successfully.', 'simple-tags'), false);
51 }
52
53 /**
54 * Filters the list of query arguments which get removed from admin area URLs in WordPress.
55 *
56 * @link https://core.trac.wordpress.org/ticket/23367
57 *
58 * @param string[] $args Array of removable query arguments.
59 * @return string[] Updated array of removable query arguments.
60 */
61 function taxopress_delete_terms_filter_removable_query_args(array $args)
62 {
63 return array_merge($args, [
64 'action',
65 'taxopress_terms',
66 '_wpnonce',
67 ]);
68 }