Deactivate Tribe Taxonomy

Home Forums Calendar Products Events Calendar PRO Deactivate Tribe Taxonomy

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1308473
    Carsten
    Participant

    Hi,

    we tried to deavtivate the Tribe-Main-Taxonomy with the following Code:

    ## Remove EventCategory
    add_action( ‘wp_loaded’, ‘szs_remove_events_taxonomy’, 100 );
    function szs_remove_events_taxonomy(){
    if(class_exists(‘Tribe__Events__Main’)){
    unregister_taxonomy(Tribe__Events__Main::TAXONOMY);
    }
    }

    But this results in a lot of php-warnings, cause the post_class-Function in the Tribe__Events__Main Claas (Line 1552) does not verify if the term exists and the get_the_terms results in a WP-Error-Object, that isn’t processed properly and results in a php-warning.

    Any idea how to prevent this?

    Thanks a lot!
    Carsten

    #1311122
    Cliff
    Member

    Hi, Carsten.

    You might want to reference a snippet like this: http://w4dev.com/wp/unregister-wordpress-taxonomy — except use Tribe__Events__Main::TAXONOMY in place of ‘taxonomy_to_remove’

    Additionally/Alternatively, you may want to use the tribe_events_register_event_cat_type_args filter that allows you to modify what gets sent to register_taxonomy()

    Please let me know how this goes for you.

    #1311600
    Carsten
    Participant

    Hi Cliff,

    my Code for removing the Tribe__Events__Main::TAXONOMY was alright. I tried your Snippet, but it is the same overall. The Problem is in the Tribe__Events__Main Claas (Line 1552)

    public function post_class( $classes ) {
    	global $post;
    	if ( is_object( $post ) && isset( $post->post_type ) && $post->post_type == self::POSTTYPE && $terms = get_the_terms( $post->ID, self::TAXONOMY ) ) {
    		foreach ( $terms as $term ) {
    			$classes[] = 'cat_' . sanitize_html_class( $term->slug, $term->term_taxonomy_id );
    		}
    	}
    
    	return $classes;
    }

    get_the_terms( $post->ID, self::TAXONOMY ) results in a php-warning because the Taxonomy was already deleted.

    So if you added something like taxonomy_exists( self::TAXONOMY ) in the if-Statement:

    public function post_class( $classes ) {
    	global $post;
    	if ( is_object( $post ) && isset( $post->post_type ) && $post->post_type == self::POSTTYPE && taxonomy_exists( self::TAXONOMY ) && $terms = get_the_terms( $post->ID, self::TAXONOMY ) ) {
    		foreach ( $terms as $term ) {
    			$classes[] = 'cat_' . sanitize_html_class( $term->slug, $term->term_taxonomy_id );
    		}
    	}
    
    	return $classes;
    }

    It would resolve my problem.

    Or do you have an alternative idea to achieve this?

    Thanks & Best Regards,
    Carsten

    #1312591
    Cliff
    Member

    Carsten, thanks for your thorough reply.

    I spoke with our developers and it seems the preferable route here would be to use the filter to just make the taxonomy essentially in existence but not usable/visible.

    This is because the taxonomy_exists() check would likely be needed in more than just this location throughout all our plugins, and we don’t have other users asking to implement the ability to remove the taxonomy.

    Please share your thoughts on this.

    Thank you.

    #1314214
    Carsten
    Participant

    Hi,

    of course. Seems to work.

    But one thought: Just because of my Support-Ticket here, i was contacted by 2 Users via WordPress-Slack asking how i removed the tribe-event-category. So it seems to me not just me 😉

    But my case is perfectly solved i think!

    Carsten

    #1314851
    Cliff
    Member

    Great, thanks for confirming, Carsten.

    You could request this as a new feature (or maybe search to see if the idea was already posted by someone else) at our plugins’ UserVoice page.

    This allows others who are interested in that feature to easily voice their support. We frequently review suggestions there to find out which ones are popular, then we implement as many of them as we can.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Deactivate Tribe Taxonomy’ is closed to new replies.