'posts', 'footer' => false, 'posts_per_page' => 6, 'render' => 'wm_jetpack_is_render', 'type' => 'scroll', 'wrapper' => false, ) ) ); // Featured content add_theme_support( 'featured-content', apply_filters( 'wmhook_wm_jetpack_featured_content', array( 'featured_content_filter' => 'wm_get_banner_posts', 'max_posts' => 6, 'post_types' => array( 'post' ), ) ) ); // Food menu support if ( ! get_theme_mod( 'disable-food-menu', false ) ) { add_theme_support( 'nova_menu_item' ); add_post_type_support( 'nova_menu_item', array( 'comments' ) ); // Food Menu output if ( class_exists( 'WM_Nova_Restaurant' ) ) { // Remove original Food Menu class as we replace it with enhanced one remove_action( 'init', array( 'Nova_Restaurant', 'init' ) ); WM_Nova_Restaurant::init( array( 'menu_title_tag' => 'h2', ) ); } } } } // /wm_jetpack add_action( 'after_setup_theme', 'wm_jetpack', 30 ); /** * Accessibility fixes */ /** * Level up heading tags * * Levels up the HTML headings in single post/page view. * Transforms H3 to H2 and H4 to H3. * * @since 2.0 * @version 2.0 * * @param string $html */ if ( ! function_exists( 'wm_headings_level_up' ) ) { function wm_headings_level_up( $html ) { // Helper variables $post_id = get_the_ID(); // Requirements check if ( ! is_page( $post_id ) && ! is_single( $post_id ) ) { return $html; } // Processing switch ( $html ) { case 'h3': $html = tag_escape( 'h2' ); break; case 'h4': $html = tag_escape( 'h3' ); break; default: $html = str_replace( array( 'id ) || 'nova_menu_item_page_add_many_nova_items' !== $current_screen->id ) { return $data; } if ( ! empty( $_POST['ajax'] ) ) { check_ajax_referer( 'nova_many_items' ); } else { check_admin_referer( 'nova_many_items' ); } // Processing if ( $postarr['post_content'] && empty( $postarr['post_excerpt'] ) ) { $data['post_excerpt'] = $data['post_content']; $data['post_content'] = ''; } // Output return $data; } } // /wm_jetpack_add_many_food_menus add_filter( 'wp_insert_post_data', 'wm_jetpack_add_many_food_menus', 10, 2 ); /** * Jetpack food menus Add Many Items styles * * @since 1.0 * @version 1.3 */ if ( ! function_exists( 'wm_jetpack_styles_admin' ) ) { function wm_jetpack_styles_admin() { // Helper variables global $current_screen; $styles = '.many-items-table input[name="nova_title[]"], .many-items-table textarea { width: 360px; max-width: 100%; }'; $styles .= '.many-items-table textarea { height: 50px; }'; // Processing if ( isset( $current_screen->id ) && 'nova_menu_item_page_add_many_nova_items' === $current_screen->id ) { wp_add_inline_style( 'nova-font', apply_filters( 'wmhook_esc_css', $styles ) ); } } } // /wm_jetpack_styles_admin add_action( 'admin_enqueue_scripts', 'wm_jetpack_styles_admin', 100 ); /** * Jetpack food menus taxonomy body class * * @since 2.0 * @version 2.0.1 * * @param array $classes */ if ( ! function_exists( 'wm_jetpack_food_menu_body_class' ) ) { function wm_jetpack_food_menu_body_class( $classes = array() ) { // Requirements check if ( ! class_exists( 'WM_Nova_Restaurant' ) ) { return $classes; } // Helper variables $classes = (array) $classes; $taxonomy = WM_Nova_Restaurant::MENU_TAX; // Processing if ( is_tax( $taxonomy ) ) { $term = get_term_by( 'slug', get_query_var( 'term' ), $taxonomy ); $children = get_term_children( (int) $term->term_id, $taxonomy ); if ( empty( $children ) ) { $classes[] = 'no-tax-children'; } else { $classes[] = 'has-tax-children'; } } // Output return $classes; } } // /wm_jetpack_food_menu_body_class add_action( 'body_class', 'wm_jetpack_food_menu_body_class' ); /** * Jetpack food menus loop content type * * @since 2.0 * @version 2.0 * * @param string $content_type */ if ( ! function_exists( 'wm_jetpack_food_menu_loop_content_type' ) ) { function wm_jetpack_food_menu_loop_content_type( $content_type = '' ) { // Processing if ( 'nova_menu_item' === get_post_type() ) { $content_type = 'food-menu'; } // Output return $content_type; } } // /wm_jetpack_food_menu_loop_content_type add_action( 'wmhook_loop_content_type', 'wm_jetpack_food_menu_loop_content_type' ); /** * Query args: Food menu section archive * * @since 2.0 * @version 2.1.1 * * @param obj $query */ if ( ! function_exists( 'wm_jetpack_food_menu_section_query' ) ) { function wm_jetpack_food_menu_section_query( $query ) { // Requirements check if ( ! is_tax( 'nova_menu' ) ) { return; } // Processing if ( $query->is_main_query() ) { $query->set( 'nopaging', true ); $query->set( 'orderby', 'menu_order' ); $query->set( 'order', 'ASC' ); } } } // /wm_jetpack_food_menu_section_query add_filter( 'pre_get_posts', 'wm_jetpack_food_menu_section_query' ); /** * Query args: Food menu page template * * @since 2.0 * @version 2.0 * * @param array $query */ if ( ! function_exists( 'wm_jetpack_food_menu_query' ) ) { function wm_jetpack_food_menu_query( $query ) { // Requirements check if ( ! is_page_template( 'page-template/_menu.php' ) ) { return $query; } // Helper variables $food_menu_section = get_post_meta( get_the_ID(), 'food_menu_section', true ); // Processing if ( $food_menu_section ) { $query['tax_query'] = array( array( 'taxonomy' => 'nova_menu', 'field' => ( is_numeric( $food_menu_section ) ) ? ( 'term_id' ) : ( 'slug' ), 'terms' => esc_html( $food_menu_section ), ), ); } // Output return $query; } } // /wm_jetpack_food_menu_query add_filter( 'wmhook_loop_food_menu_query', 'wm_jetpack_food_menu_query' ); /** * Display only parent food menu sections: Food Menu page template * * @since 2.0 * @version 2.0.1 */ if ( ! function_exists( 'wm_jetpack_food_menu_loop_section_display_menu_page' ) ) { function wm_jetpack_food_menu_loop_section_display_menu_page() { // Requirements check if ( ! is_page_template( 'page-template/_menu.php' ) ) { return; } // Processing if ( ! get_post_meta( get_the_ID(), 'food_menu_section', true ) ) { add_filter( 'jetpack_food_section_parent_only', '__return_true' ); } } } // /wm_jetpack_food_menu_loop_section_display_menu_page add_action( 'wmhook_loop_food_menu_postslist_before', 'wm_jetpack_food_menu_loop_section_display_menu_page' ); /** * Display only parent food menu sections: Front page * * @since 2.0 * @version 2.0 */ if ( ! function_exists( 'wm_jetpack_food_menu_loop_section_display_front_page' ) ) { function wm_jetpack_food_menu_loop_section_display_front_page() { // Processing if ( is_front_page() ) { add_filter( 'jetpack_food_section_parent_only', '__return_true' ); } } } // /wm_jetpack_food_menu_loop_section_display_front_page add_action( 'wmhook_loop_food_menu_postslist_before', 'wm_jetpack_food_menu_loop_section_display_front_page' ); /** * Disable food menu section archive links * * @since 2.2.0 * @version 2.2.0 * * @param bool $enabled */ if ( ! function_exists( 'wm_food_menu_section_archive_link' ) ) { function wm_food_menu_section_archive_link( $enabled ) { // Output return ! get_theme_mod( 'food-menu-section-archive-link-disable', false ); } } // /wm_food_menu_section_archive_link add_filter( 'jetpack_food_section_archive_link', 'wm_food_menu_section_archive_link' ); } else { /** * Remove obsolete page templates when Food Menu is disabled * * @since 2.2.0 * @version 2.2.0 * * @param array $page_templates */ if ( ! function_exists( 'wm_page_templates_remove_menu' ) ) { function wm_page_templates_remove_menu( $page_templates ) { // Processing unset( $page_templates['page-template/_menu.php'] ); // Output return $page_templates; } } // /wm_page_templates_remove_menu add_filter( 'theme_page_templates', 'wm_page_templates_remove_menu' ); } // /disable-food-menu?