Home › Forums › Calendar Products › Events Calendar PRO › Deactivate Tribe Taxonomy
- This topic has 6 replies, 3 voices, and was last updated 8 years, 10 months ago by
Cliff.
-
AuthorPosts
-
June 27, 2017 at 6:52 am #1308473
Carsten
ParticipantHi,
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!
CarstenJune 28, 2017 at 9:36 pm #1311122Cliff
MemberHi, 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.
June 29, 2017 at 4:09 am #1311600Carsten
ParticipantHi 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,
CarstenJune 29, 2017 at 1:23 pm #1312591Cliff
MemberCarsten, 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.
June 30, 2017 at 6:01 am #1314214Carsten
ParticipantHi,
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
June 30, 2017 at 8:41 pm #1314851Cliff
MemberGreat, 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.
-
AuthorPosts
- The topic ‘Deactivate Tribe Taxonomy’ is closed to new replies.
