true ), 'objects' ) as $pt ) { if ( in_array( $pt->name, array( 'attachment', 'revision', 'nav_menu_item' ), true ) ) { continue; } $out[ $pt->name ] = (string) $pt->labels->name; } return (array) apply_filters( 'aieo_content_post_types', $out ); } public static function is_content_post_type( $post_type ) { $post_type = (string) $post_type; if ( '' === $post_type || in_array( $post_type, array( 'attachment', 'revision', 'nav_menu_item' ), true ) ) { return false; } $pto = get_post_type_object( $post_type ); return $pto && ! empty( $pto->public ); } public static function taxonomies() { $out = array(); foreach ( get_taxonomies( array( 'public' => true ), 'objects' ) as $tx ) { if ( 'post_format' === $tx->name || ! is_taxonomy_viewable( $tx ) ) { continue; } if ( 0 === strpos( $tx->name, 'pa_' ) && 'pa_need' !== $tx->name ) { continue; } $out[ $tx->name ] = (string) $tx->labels->name; } return (array) apply_filters( 'aieo_content_taxonomies', $out ); } public static function post_type_count( $post_type ) { $counts = wp_count_posts( (string) $post_type ); return ( is_object( $counts ) && isset( $counts->publish ) ) ? (int) $counts->publish : 0; } public static function taxonomy_count( $taxonomy ) { $n = wp_count_terms( array( 'taxonomy' => (string) $taxonomy, 'hide_empty' => false ) ); return is_wp_error( $n ) ? 0 : (int) $n; } public static function learning_post_types() { $types = array(); foreach ( array( 'rooster_course', 'rooster_lesson' ) as $t ) { if ( post_type_exists( $t ) ) { $types[] = $t; } } $types = (array) apply_filters( 'rooster/learning/chat_post_types', $types ); return array_values( array_unique( array_filter( array_map( 'sanitize_key', $types ) ) ) ); } public static function is_learning_post_type( $post_type ) { return in_array( (string) $post_type, self::learning_post_types(), true ); } public static function chat_post_types() { $learning = self::learning_post_types(); $saved = get_option( 'aieo_chat_enabled_post_types', null ); if ( is_array( $saved ) ) { $saved = array_values( array_filter( array_map( 'strval', $saved ), 'strlen' ) ); if ( array() !== $learning && array() === array_intersect( $learning, $saved ) && ! get_option( 'aieo_chat_learning_types_seen' ) ) { $saved = array_values( array_unique( array_merge( $saved, $learning ) ) ); update_option( 'aieo_chat_enabled_post_types', $saved ); update_option( 'aieo_chat_learning_types_seen', '1', false ); } return $saved; } $default = ( class_exists( 'WooCommerce' ) || post_type_exists( 'product' ) ) ? array( 'product' ) : array(); return array_values( array_unique( array_merge( $default, $learning ) ) ); } }