PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.40.1
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.40.1
3.54.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 All 178 releases
simple-tags / inc / helper.options.admin.php

helper.options.admin.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.40.1, at inc/helper.options.admin.php

455 lines 21.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once STAGS_DIR . '/modules/taxopress-ai/classes/TaxoPressAiUtilities.php';
3
4 $current_screen = get_current_screen();
5 $is_fast_update = isset($_GET['page']) && $_GET['page'] === 'st_taxopress_ai';
6
7 $taxopress_ai_tabs = [];
8
9 $taxopress_posts_terms_label = get_option(
10 'taxopress_ai_post_terms_tab_label',
11 SimpleTags_Plugin::get_option_value('taxopress_ai_post_terms_tab_label')
12 );
13 $taxopress_existing_terms_label = get_option(
14 'taxopress_ai_existing_terms_tab_label',
15 SimpleTags_Plugin::get_option_value('taxopress_ai_existing_terms_tab_label')
16 );
17 $taxopress_suggest_local_terms_label = get_option(
18 'taxopress_ai_suggest_local_terms_tab_label',
19 SimpleTags_Plugin::get_option_value('taxopress_ai_suggest_local_terms_tab_label')
20 );
21 $taxopress_create_terms_label = get_option(
22 'taxopress_ai_create_terms_tab_label',
23 SimpleTags_Plugin::get_option_value('taxopress_ai_create_terms_tab_label')
24 );
25
26 if (empty($taxopress_existing_terms_label)) {
27 $taxopress_existing_terms_label = esc_html__('Show All Existing Terms', 'simple-tags');
28 }
29 if (empty($taxopress_posts_terms_label)) {
30 $taxopress_posts_terms_label = esc_html__('Manage Post Terms', 'simple-tags');
31 }
32 if (empty($taxopress_suggest_local_terms_label)) {
33 $taxopress_suggest_local_terms_label = esc_html__('Auto Terms', 'simple-tags');
34 }
35 if (empty($taxopress_create_terms_label)) {
36 $taxopress_create_terms_label = esc_html__('Create Terms', 'simple-tags');
37 }
38
39 $taxopress_ai_tabs['existing_terms'] = $taxopress_existing_terms_label;
40 $taxopress_ai_tabs['post_terms'] = $taxopress_posts_terms_label;
41 $taxopress_ai_tabs['suggest_local_terms'] = $taxopress_suggest_local_terms_label;
42 $taxopress_ai_tabs['create_terms'] = $taxopress_create_terms_label;
43
44 $taxopress_ai_fields = [];
45 $pt_index = 0;
46 foreach (TaxoPressAiUtilities::get_post_types_options() as $post_type => $post_type_object) {
47 $hidden_field = ($pt_index === 0) ? '' : 'st-hide-content';
48
49 $default_taxonomy_options = [];
50 foreach (get_object_taxonomies($post_type, 'objects') as $tax_key => $tax_object) {
51 if (!in_array($tax_key, ['post_format']) && (!empty($tax_object->show_ui) || !empty(SimpleTags_Plugin::get_option_value('taxopress_ai_' . $post_type . '_support_private_taxonomy')))) {
52 $default_taxonomy_options[$tax_key] = $tax_object->labels->name. ' ('.$tax_object->name.')';
53 }
54 }
55
56 if (empty($default_taxonomy_options)) {
57 // This feature only matter if a post has taxonomy
58 $taxopress_ai_fields[] = array(
59 'enable_taxopress_ai_' . $post_type . '_text',
60 '',
61 'helper',
62 '1',
63 esc_html__('This post type has no taxonomies.', 'simple-tags'),
64 'taxopress-ai-tab-content taxopress-ai-'. $post_type .'-content '. $hidden_field .''
65 );
66 } else {
67 $taxopress_ai_fields[] = array(
68 'enable_taxopress_ai_' . $post_type . '_metabox',
69 sprintf(esc_html__('%1s Metabox', 'simple-tags'), esc_html($post_type_object->labels->name)),
70 'checkbox',
71 '1',
72 sprintf(esc_html__('Enable the metabox on the %1s screen.', 'simple-tags'), esc_html($post_type_object->labels->name)),
73 'taxopress-ai-tab-content taxopress-ai-'. $post_type .'-content '. $hidden_field .''
74 );
75
76 // add feature tab
77 $tab_field_options = [];
78 foreach ($taxopress_ai_tabs as $taxopress_ai_tab => $taxopress_ai_tab_label) {
79 $tab_field_options['enable_taxopress_ai_' . $post_type . '_' . $taxopress_ai_tab . '_tab'] = [
80 'label' => $taxopress_ai_tab_label
81 ];
82 }
83 $taxopress_ai_fields[] = array(
84 'enable_taxopress_ai_' . $post_type . '_tab',
85 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_field st-subhide-content">' . esc_html__('Metabox Features', 'simple-tags') . '</div>',
86 'sub_multiple_checkbox',
87 $tab_field_options,
88 '',
89 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_field st-subhide-content'
90 );
91
92 $taxopress_ai_fields[] = array(
93 'taxopress_ai_' . $post_type . '_support_private_taxonomy',
94 sprintf(esc_html__('Show Private Taxonomies', 'simple-tags')),
95 'checkbox',
96 '1',
97 sprintf(esc_html__('Add support for private taxonomies.', 'simple-tags')),
98 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_post_terms_tab_field st-subhide-content'
99 );
100
101 // add taxonomy
102 $taxopress_ai_fields[] = array(
103 'taxopress_ai_' . $post_type . '_metabox_default_taxonomy',
104 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_post_terms_tab_field st-subhide-content">' . esc_html__('Default Taxonomy', 'simple-tags') . '</div>',
105 'select',
106 $default_taxonomy_options,
107 '',
108 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_post_terms_tab_field st-subhide-content'
109 );
110
111 $taxopress_ai_fields[] = array(
112 'taxopress_ai_' . $post_type . '_metabox_filters',
113 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content">' . sprintf(esc_html__('%1s Metabox Filters', 'simple-tags'), esc_html($post_type_object->labels->name)) . '</div>',
114 'checkbox',
115 '1',
116 sprintf(esc_html__('Enable filters in the %1s existing terms tab.', 'simple-tags'), esc_html($post_type_object->labels->name)),
117 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content'
118 );
119
120 // add _metabox_orderby
121 $taxopress_ai_fields[] = array(
122 'taxopress_ai_' . $post_type . '_metabox_orderby',
123 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content">' . esc_html__('Default Method for choosing terms', 'simple-tags') . '</div>',
124 'select',
125 TaxoPressAiUtilities::get_existing_terms_orderby(),
126 '',
127 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content'
128 );
129
130 // add _metabox_order
131 $taxopress_ai_fields[] = array(
132 'taxopress_ai_' . $post_type . '_metabox_order',
133 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content">' . esc_html__('Default Ordering for choosing terms', 'simple-tags') . '</div>',
134 'select',
135 TaxoPressAiUtilities::get_existing_terms_order(),
136 '',
137 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content'
138 );
139
140 // add _metabox_maximum_terms
141 $taxopress_ai_fields[] = array(
142 'taxopress_ai_' . $post_type . '_metabox_maximum_terms',
143 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content">' . esc_html__('Default maximum terms', 'simple-tags') . '</div>',
144 'number',
145 '',
146 '',
147 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_metabox_filters_field st-subhide-content',
148 0
149 );
150
151 // add _metabox_show_post_count
152 $taxopress_ai_fields[] = array(
153 'taxopress_ai_' . $post_type . '_metabox_show_post_count',
154 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content">' . esc_html__('Metabox Show Term Post Count', 'simple-tags') . '</div>',
155 'checkbox',
156 '1',
157 '',
158 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content'
159 );
160
161 // add _metabox_show_term_slug
162 $taxopress_ai_fields[] = array(
163 'taxopress_ai_' . $post_type . '_metabox_show_term_slug',
164 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content">' . esc_html__('Show Term Slug', 'simple-tags') . '</div>',
165 'checkbox',
166 '1',
167 '',
168 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_existing_terms_tab_field st-subhide-content'
169 );
170
171 //add minimum term length
172 $taxopress_ai_fields[] = array(
173 'taxopress_ai_' . $post_type . '_minimum_term_length',
174 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content">' . esc_html__('Minimum term length', 'simple-tags') . '</div>',
175 'number',
176 '',
177 '<p>' . esc_html__('Specify the minimum length for new terms when creating terms.', 'simple-tags') . '</p>',
178 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content',
179 1
180 );
181
182 //add maximum term length
183 $taxopress_ai_fields[] = array(
184 'taxopress_ai_' . $post_type . '_maximum_term_length',
185 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content">' . esc_html__('Maximum term length', 'simple-tags') . '</div>',
186 'number',
187 '',
188 '<p>' . esc_html__('Specify the maximum length for new terms when creating terms.', 'simple-tags') . '</p>',
189 'taxopress-ai-tab-content-sub taxopress-ai-'. $post_type .'-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content',
190 1
191 );
192
193 $taxopress_ai_fields[] = array(
194 'taxopress_ai_' . $post_type . '_exclusions',
195 '<div class="taxopress-ai-tab-content-sub taxopress-settings-subtab-title taxopress-ai-' . $post_type . '-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content">' . esc_html__('Prohibited Characters', 'simple-tags') . '</div>',
196 'textarea',
197 '',
198 '',
199 'taxopress-ai-tab-content-sub taxopress-ai-' . $post_type . '-content-sub enable_taxopress_ai_' . $post_type . '_create_terms_tab_field st-subhide-content',
200 '',
201 array(
202 'rows' => 6,
203 'placeholder' => esc_attr__('Enter characters that will be blocked when users add new terms inside the "Create Terms" box. For example: !@#$%&*()', 'simple-tags'),
204 'width' => '80%'
205 )
206 );
207 // allow to taxopress ai field for each post type
208 $taxopress_ai_fields = apply_filters('taxopress_settings_post_type_ai_fields', $taxopress_ai_fields, $post_type);
209 }
210 $pt_index++;
211 }
212
213 $all_taxonomies = get_taxonomies([], 'objects');
214 $all_taxonomy_options = [];
215 foreach ($all_taxonomies as $tax) {
216 if (in_array($tax->name, ['author', 'post_format', 'nav_menu', 'link_category', 'wp_theme', 'wp_template_part_area', 'wp_pattern_category'])) {
217 continue;
218 }
219 $all_taxonomy_options[$tax->name] = $tax->label;
220 }
221
222 $metabox_taxonomy_options = [];
223 foreach ($all_taxonomies as $tax) {
224 if (!empty($tax->public) && !empty($tax->show_ui)) {
225 $metabox_taxonomy_options[$tax->name] = $tax->label;
226 }
227 }
228
229
230 //metabox
231 $metabox_fields = [];
232 $pt_index = 0;
233 foreach (taxopress_get_all_wp_roles() as $role_name => $role_info) {
234 $hidden_field = ($pt_index === 0) ? '' : 'st-hide-content';
235 // add option to enable/disable access
236 $metabox_fields[] = array(
237 'enable_' . $role_name . '_metabox',
238 esc_html__('Metabox Access', 'simple-tags'),
239 'checkbox',
240 '1',
241 sprintf(esc_html__('Allow users in the %1s role to use the TaxoPress metabox.', 'simple-tags'), esc_html(translate_user_role($role_info['name']))),
242 'metabox-tab-content metabox-'. $role_name .'-content '. $hidden_field .''
243 );
244 // add option to manage terms per user role
245 $metabox_fields[] = array(
246 'enable_restrict' . $role_name . '_metabox',
247 esc_html__('Block Users from Creating New Terms', 'simple-tags'),
248 'checkbox',
249 '1',
250 sprintf(esc_html__('Prevent users in the %1$s role from creating new terms in the TaxoPress metabox.', 'simple-tags'), esc_html(translate_user_role($role_info['name']))),
251 'metabox-tab-content metabox-'. $role_name .'-content '. $hidden_field .''
252 );
253 // add metabox allowed taxonomies
254 $metabox_fields[] = array(
255 'enable_metabox_' . $role_name . '',
256 '<div class="metabox-tab-content taxopress-settings-subtab-title metabox-'. $role_name .'-content enable_' . $role_name . '_metabox_field '. $hidden_field .'">' . esc_html__('Taxonomies in Metabox', 'simple-tags') . '</div>',
257 'multiselect_with_desc_top',
258 $metabox_taxonomy_options,
259 '<p class="metabox-tab-content taxopress-settings-description metabox-'. $role_name .'-content enable_' . $role_name . '_metabox_field description '. $hidden_field .'">' . sprintf(esc_html__('Select the taxonomies that users in %1s role can manage in the TaxoPress metabox.', 'simple-tags'), esc_html(translate_user_role($role_info['name']))) . '</p>',
260 'metabox-tab-content metabox-'. $role_name .'-content enable_' . $role_name . '_metabox_field '. $hidden_field .''
261 );
262 // add core removed taxonomies
263 $metabox_fields[] = array(
264 'remove_taxonomy_metabox_' . $role_name . '',
265 '<div class="metabox-tab-content taxopress-settings-subtab-title metabox-'. $role_name .'-content '. $hidden_field .'">' . esc_html__('Remove Default Metaboxes', 'simple-tags') . '</div>',
266 'multiselect_with_desc_top',
267 $all_taxonomy_options,
268 '<p class="metabox-tab-content taxopress-settings-description metabox-'. $role_name .'-content description '. $hidden_field .'">' . sprintf(esc_html__('Remove default taxonomy metaboxes for users in the %1s role.', 'simple-tags'), esc_html(translate_user_role($role_info['name']))) . '</p>',
269 'metabox-tab-content metabox-'. $role_name .'-content '. $hidden_field .''
270 );
271
272 $pt_index++;
273 }
274
275 $options = array(
276 // post tab
277 'posts' => array(
278 array(
279 'post_terms_filter_format',
280 __('Terms Filter display:', 'simple-tags'),
281 'radio',
282 array(
283 'term_name' => __('Term Name', 'simple-tags'),
284 'term_name_taxonomy_name' => __('Term Name + Taxonomy Name', 'simple-tags'),
285 'term_name_taxonomy_slug' => __('Term Name + Taxonomy Slug', 'simple-tags'),
286 ),
287 __('This controls the details that appear in the "Terms Filter" display and can help if you have terms with similar names.', 'simple-tags'),
288 ''
289 ),
290 array(
291 'post_terms_taxonomy_type',
292 __('Terms Filter taxonomy:', 'simple-tags'),
293 'radio',
294 array(
295 'public' => __('Public Taxonomies', 'simple-tags'),
296 'private' => __('Private Taxonomies', 'simple-tags'),
297 'term_and_private' => __('Public Taxonomies and Private Taxonomies', 'simple-tags'),
298 ),
299 __('This controls the taxonomy terms that appear on the "Posts" screen.', 'simple-tags'),
300 ''
301 ),
302 ),
303
304
305 // linked terms tab
306 'linked_terms' => array(
307 array(
308 'linked_terms_description',
309 '',
310 'helper',
311 '',
312 __('This feature allows you to connect terms. When the primary or secondary term is added to a post, the other term can be added also.', 'simple-tags'),
313 ''
314 ),
315 array(
316 'linked_terms_type',
317 __('Linked Terms Type:', 'simple-tags'),
318 'radio',
319 array(
320 'main' => __('2-way relationship. When the main term or secondary term are added to the post, other term will be added also.', 'simple-tags'),
321 'primary' => __('Add the primary term, get the secondary term', 'simple-tags'),
322 'secondary' => __('Add the secondary term, get the primary term.', 'simple-tags'),
323 ),
324 '',
325 ''
326 ),
327 array(
328 'linked_terms_taxonomies',
329 __('Enable Taxonomies:', 'simple-tags'),
330 'multiselect',
331 $all_taxonomy_options,
332 __('This controls which taxonomies are available for the Linked Terms feature.', 'simple-tags'),
333 ''
334 )
335 ),
336
337 // term synonyms tab
338 'synonyms' => array(
339 array(
340 'synonyms_description',
341 '',
342 'helper',
343 '',
344 __('This feature allows you to have multiple words associated with a single term. If TaxoPress scans your content and finds a synonym, it will act as if it has found the main term.', 'simple-tags'),
345 ''
346 ),
347 array(
348 'synonyms_taxonomies',
349 __('Enable Taxonomies:', 'simple-tags'),
350 'multiselect',
351 $all_taxonomy_options,
352 __('This controls which taxonomies are available for the Term Synonyms feature.', 'simple-tags'),
353 ''
354 )
355 ),
356
357 // hidden terms tab
358 'hidden_terms' => array(
359 array(
360 'enable_hidden_terms',
361 __('Enable Hidden Terms:', 'simple-tags'),
362 'checkbox',
363 '1',
364 __('This feature will hide terms that are infrequently used. These terms will be visible inside the WordPress admin area, but not on the front of this site.', 'simple-tags'),
365 ''
366 ),
367 array(
368 'hide-rarely',
369 __('Minimum Usage for Hidden Terms:', 'simple-tags'),
370 'number',
371 '1',
372 __('Set the minimum number of posts a term must be attached to. If you enter 5, any term used in fewer than 5 posts will be hidden across the site, and its archive page will redirect to the homepage.', 'simple-tags'),
373 '',
374 1
375 )
376 ),
377
378 'core_linked_terms' => array(
379 array(
380 'linked_terms_pro_notice',
381 '',
382 'core_terms_promo',
383 '',
384 apply_filters('taxopress_settings_linked_terms_pro_notice', ''),
385 ''
386 )
387 ),
388
389 'core_synonyms_terms' => array(
390 array(
391 'synonyms_terms_pro_notice',
392 '',
393 'core_terms_promo',
394 '',
395 apply_filters('taxopress_settings_synonyms_terms_pro_notice', ''),
396 ''
397 )
398 ),
399
400 // Manage terms tab
401 'manage_terms' => array(
402 array(
403 'enable_add_terms_slug',
404 __('Add Terms:', 'simple-tags'),
405 'checkbox',
406 '1',
407 __('Enabling this will allow users to see the slug while adding terms', 'simple-tags'),
408 ''
409 ),
410 array(
411 'enable_remove_terms_slug',
412 __('Remove Terms:', 'simple-tags'),
413 'checkbox',
414 '1',
415 __('Enabling this will allow users to see the slug while removing terms', 'simple-tags'),
416 ''
417 ),
418 array(
419 'enable_rename_terms_slug',
420 __('Rename Terms:', 'simple-tags'),
421 'checkbox',
422 '1',
423 __('Enabling this will allow users to see the slug while Renaming terms', 'simple-tags'),
424 ''
425 ),
426 array(
427 'enable_merge_terms_slug',
428 __('Merge Terms:', 'simple-tags'),
429 'checkbox',
430 '1',
431 __('Enabling this will allow users to see the slug while merging terms', 'simple-tags'),
432 ''
433 ),
434 ),
435
436 'mass_edit_terms' => array(
437 array(
438 'enable_mass-edit_terms_slug',
439 __('Mass Edit Terms:', 'simple-tags'),
440 'checkbox',
441 '1',
442 __('Enabling this will allow users to see the slug in the Mass Edit Terms screen', 'simple-tags'),
443 ''
444 ),
445 )
446
447 );
448
449 if ($is_fast_update) {
450 $options['taxopress-ai'] = $taxopress_ai_fields;
451 $options['metabox'] = $metabox_fields;
452 }
453
454 return apply_filters('taxopress_admin_options', $options);
455