SHOW:
|
|
- or go back to the newest paste.
1 | function pm_is_excluded($post) { | |
2 | $excluded_taxonomies = array('category2', 'post_tag'); | |
3 | ||
4 | foreach($excluded_taxonomies as $taxonomy) { | |
5 | $terms = get_the_terms($post, $taxonomy); | |
6 | ||
7 | if(!empty($terms) && !is_wp_error($terms)) { | |
8 | return true; | |
9 | } | |
10 | } | |
11 | ||
12 | return false; | |
13 | } | |
14 | ||
15 | function pm_do_not_detect_custom_permalinks($element_id, $uri_parts) { | |
16 | global $permalink_manager_uris; | |
17 | ||
18 | if(is_numeric($element_id) && !empty($uri_parts['uri'])) { | |
19 | $is_excluded = pm_is_excluded($element_id); | |
20 | ||
21 | unset($permalink_manager_uris[$element_id]); | |
22 | } | |
23 | ||
24 | return (!empty($is_excluded)) ? false : $element_id; | |
25 | } | |
26 | add_filter('permalink_manager_detected_element_id', 'pm_do_not_detect_custom_permalinks', 99, 2); | |
27 | ||
28 | function pm_do_not_change_permalink($permalink, $post, $old_permalink) { | |
29 | return (pm_is_excluded($post)) ? $old_permalink : $permalink; | |
30 | } | |
31 | add_filter('permalink_manager_filter_final_post_permalink', 'pm_do_not_change_permalink', 99, 3); | |
32 | ||
33 | function pm_hide_uri_editor() { | |
34 | global $post, $current_screen, $permalink_manager; | |
35 | ||
36 | if(!empty($current_screen) && $current_screen->base == 'post') { | |
37 | if(pm_is_excluded($post)) { | |
38 | remove_filter('wpseo_breadcrumb_links', array($permalink_manager->functions['third-parties'], 'filter_breadcrumbs'), 9); | |
39 | } | |
40 | } | |
41 | } | |
42 | add_action('add_meta_boxes', 'pm_hide_uri_editor'); |