PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / trunk
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms vtrunk
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 / class.admin.post.php

class.admin.post.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms trunk, at inc/class.admin.post.php

108 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable WordPress.Security.NonceVerification.Missing -- Legacy TaxoPress file: keep behavior unchanged while documenting existing PHPCS exceptions.
4
5 class SimpleTags_Admin_Post_Settings
6 {
7 /**
8 * Constructor
9 *
10 * @return void
11 * @author WebFactory Ltd
12 */
13 public function __construct()
14 {
15
16 if ((1 === (int) SimpleTags_Plugin::get_option_value('active_auto_links')) || (1 === (int) SimpleTags_Plugin::get_option_value('active_auto_terms'))) {
17 // Save tags from advanced input
18 add_action('save_post', array( __CLASS__, 'save_post' ), 10, 1);
19 // Box for advanced tags
20 add_action('add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ), 10, 1);
21 }
22 }
23
24 /**
25 * Register a new box for TaxoPress settings
26 *
27 * @param string $post_type
28 *
29 * @return void
30 * @author WebFactory Ltd
31 */
32 public static function add_meta_boxes($post_type)
33 {
34
35 $autoterm = taxopress_post_type_autoterms();
36 $autolink = taxopress_post_type_autolink_autolink();
37
38 if (!is_array($autoterm) && !is_array($autolink)) {
39 return;
40 }
41
42 // Auto terms for this CPT ?
43 add_meta_box('simpletags-settings', __('TaxoPress', 'simple-tags'), array(
44 __CLASS__,
45 'metabox'
46 ), $post_type, 'side', 'low');
47 }
48
49 /**
50 * Build HTML of form
51 *
52 * @param object $post
53 *
54 * @return void
55 * @author WebFactory Ltd
56 */
57 public static function metabox($post)
58 {
59 if (! isset($post->post_type)) {
60 return;
61 }
62
63 // Auto terms for this CPT ?
64 if (1 === (int) SimpleTags_Plugin::get_option_value('active_auto_terms')) {
65 $meta_value = get_post_meta($post->ID, '_exclude_autotags', true);
66 echo '<p>' . "\n";
67 echo '<label><input type="checkbox" name="exclude_autotags" value="true" ' . checked(esc_attr($meta_value), true, false) . ' /> ' . esc_html__('Disable Auto Terms', 'simple-tags') . '</label><br />' . "\n";
68 echo '</p>' . "\n";
69 echo '<input type="hidden" name="_meta_autotags" value="true" />';
70 }
71
72 if (1 === (int) SimpleTags_Plugin::get_option_value('active_auto_links')) {
73 $meta_value = get_post_meta($post->ID, '_exclude_autolinks', true);
74 echo '<p>' . "\n";
75 echo '<label><input type="checkbox" name="exclude_autolinks" value="true" ' . checked(esc_attr($meta_value), true, false) . ' /> ' . esc_html__('Disable Auto Links', 'simple-tags') . '</label><br />' . "\n";
76 echo '</p>' . "\n";
77 echo '<input type="hidden" name="_meta_autolink" value="true" />';
78 }
79 }
80
81 /**
82 * Save this settings in post meta, delete if no exclude, clean DB :)
83 *
84 * @param integer $object_id
85 *
86 * @return void
87 * @author WebFactory Ltd
88 */
89 public static function save_post($object_id = 0)
90 {
91 if (isset($_POST['_meta_autotags']) && 'true' === $_POST['_meta_autotags']) {
92 if (isset($_POST['exclude_autotags'])) {
93 update_post_meta($object_id, '_exclude_autotags', true);
94 } else {
95 delete_post_meta($object_id, '_exclude_autotags');
96 }
97 }
98
99 if (isset($_POST['_meta_autolink']) && 'true' === $_POST['_meta_autolink']) {
100 if (isset($_POST['exclude_autolinks'])) {
101 update_post_meta($object_id, '_exclude_autolinks', true);
102 } else {
103 delete_post_meta($object_id, '_exclude_autolinks');
104 }
105 }
106 }
107 }
108