How to check if a taxonomy not exists in a plugin

You will either need to do two things

  • Check for an empty array AND a WP_Error object

  • Check if the taxonomy exists (which get_categories() and get_terms() already does) before your execute your code and still check for an empty array

FEW NOTES TO CONSIDER

  • get_categories() uses get_terms(), you you could use get_terms()

  • You do not need to set arguments if you use it’s default values

  • date is not a valid value for orderby in get_terms(). Valid values are name, slug, term_group, term_id, id, description and count

  • The type parameter in get_categories() does not relate to the post type, but to the taxonomy type. This parameter used to accept link as value and where used before the introduction of custom taxonomies in WordPress 3.0. Before WordPress 3.0, you could set type to link to return terms from the link_category taxonomy. This parameter was depreciated in WordPress 3.0 in favor of the taxonomy parameter

SOLUTION

//Get all EVENT categories
$categories_event = get_terms( 'catevent' );

$option_value_event = array();  

// Check for empty array and WP_Error
if (    $categories_event
     && !is_wp_error( $categories_event )
) {
    //Extract all EVENT categories
    foreach ( $categories_event as $cat ){ 
        $option_value_event[] = $cat->name;
    }
}

EDIT

I cannot see why the above code would not work. You can try the following as a test

if ( taxonomy_exists( 'catevent' ) ) {
    //Get all EVENT categories
    $categories_event = get_terms( 'catevent' );

    $option_value_event = array();  

    // Check for empty array and WP_Error
    if (    $categories_event
         && !is_wp_error( $categories_event )
    ) {
        //Extract all EVENT categories
        foreach ( $categories_event as $cat ){ 
            $option_value_event[] = $cat->name;
        }
    }
}

That should work, if not, then you have a serious error somewhere in one of your plugins