Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_is_excluded($post) {
- $excluded_taxonomies = array('category2', 'post_tag');
- foreach($excluded_taxonomies as $taxonomy) {
- $terms = get_the_terms($post, $taxonomy);
- if(!empty($terms) && !is_wp_error($terms)) {
- return true;
- }
- }
- return false;
- }
- function pm_do_not_detect_custom_permalinks($element_id, $uri_parts) {
- global $permalink_manager_uris;
- if(is_numeric($element_id) && !empty($uri_parts['uri'])) {
- $is_excluded = pm_is_excluded($element_id);
- unset($permalink_manager_uris[$element_id]);
- }
- return (!empty($is_excluded)) ? false : $element_id;
- }
- add_filter('permalink_manager_detected_element_id', 'pm_do_not_detect_custom_permalinks', 99, 2);
- function pm_do_not_change_permalink($permalink, $post, $old_permalink) {
- return (pm_is_excluded($post)) ? $old_permalink : $permalink;
- }
- add_filter('permalink_manager_filter_final_post_permalink', 'pm_do_not_change_permalink', 99, 3);
- function pm_hide_uri_editor() {
- global $post, $current_screen, $permalink_manager;
- if(!empty($current_screen) && $current_screen->base == 'post') {
- if(pm_is_excluded($post)) {
- remove_filter('wpseo_breadcrumb_links', array($permalink_manager->functions['third-parties'], 'filter_breadcrumbs'), 9);
- }
- }
- }
- add_action('add_meta_boxes', 'pm_hide_uri_editor');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement