', '', false ) ); return $continue_reading; } /** * Determines if post thumbnail can be displayed. * * @since 1.0.0 * * @return bool */ function best_minimal_restaurant_can_show_post_thumbnail() { /** * Filters whether post thumbnail can be displayed. * * @since 1.0.0 * * @param bool $show_post_thumbnail Whether to show post thumbnail. */ return apply_filters( 'best_minimal_restaurant_can_show_post_thumbnail', ! post_password_required() && ! is_attachment() && has_post_thumbnail() ); } /** * Adds custom classes to the array of body classes. * * @param array $classes Classes for the body element. * @return array */ function best_minimal_restaurant_body_classes( $classes ) { // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; } // Adds a class of no-sidebar when there is no sidebar present. if ( ! is_active_sidebar( 'sidebar-1' ) ) { $classes[] = 'no-sidebar'; } // Custom template pages. $page_templates = apply_filters( 'best_minimal_restaurant_custom_page_templates', array( 'home' => 'template-home.php', 'about' => 'template-about.php', 'contact' => 'template-contact.php', 'menu' => 'template-menu.php', 'location' => 'template-location.php', ) ); // Get current active template name. $template_name = best_minimal_restaurant_get_active_theme_template(); // Adds a class of current active template. if ( is_page_template( $page_templates ) ) { $classes[] = $template_name; } return $classes; } add_filter( 'body_class', 'best_minimal_restaurant_body_classes' ); /** * Adds custom classes to nav menu. * * @param array $classes Classes for the nav menu. * @param object $item The item object. * @param array $args The nav args. * * @return array */ function best_minimal_restaurant_menu_css_classes( $classes, $item, $args ) { if ( 'best_minimal_restaurant_top_right_menu' === $args->theme_location || 'best_minimal_restaurant_top_left_menu' === $args->theme_location ) { $classes[] = 'nav-item'; } if ( in_array( 'current-menu-item', $classes ) ) { $classes[] = 'active'; } return $classes; } add_filter( 'nav_menu_css_class', 'best_minimal_restaurant_menu_css_classes', 10, 3 ); /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. * * @since 1.0.0 * * @return void */ function best_minimal_restaurant_pingback_header() { if ( is_singular() && pings_open() ) { printf( '', esc_url( get_bloginfo( 'pingback_url' ) ) ); } } add_action( 'wp_head', 'best_minimal_restaurant_pingback_header' ); /** * Filters the custom logo HTML. * * @param string $html The logo HTML. * * @since 1.0.0 * * @return string $html The filtered logo html */ function best_minimal_restaurant_get_custom_logo( $html ) { $custom_logo_id = get_theme_mod( 'custom_logo' ); if ( $custom_logo_id ) { $html = sprintf( '', esc_url( home_url( '/' ) ), 300, 100, wp_get_attachment_image_src( $custom_logo_id, 'full' )[0] ); } return $html; } add_filter( 'get_custom_logo', 'best_minimal_restaurant_get_custom_logo', 10, 2 ); /** * Gets the SVG code for a given icon. * * @since 1.0.0 * * @param string $icon The icon. * * @return string */ function best_minimal_restaurant_get_icon_svg( $icon ) { $icons = array( 'arrow_right' => '', 'arrow_left' => '', ); if ( isset( $icon ) && isset( $icons[ $icon ] ) ) { return $icons[ $icon ]; } return ''; } /** * Add a button to top-level menu items that has sub-menus. * An icon is added using CSS depending on the value of aria-expanded. * * @since 1.0.5 * * @param string $output Nav menu item start element. * @param object $item Nav menu item. * @param int $depth Depth. * @param object $args Nav menu args. * * @return string Nav menu item start element. */ function best_minimal_restaurant_add_sub_menu_toggle( $output, $item, $depth, $args ) { if ( 0 === $depth && in_array( 'menu-item-has-children', $item->classes, true ) ) { // Add toggle button. $output .= ''; $output .= '' . best_minimal_restaurant_get_svg( 'plus', 18 ) . ''; $output .= '' . best_minimal_restaurant_get_svg( 'minus', 18 ) . ''; $output .= '' . esc_html__( 'Open menu', 'best-minimal-restaurant' ) . ''; $output .= ''; } return $output; } add_filter( 'walker_nav_menu_start_el', 'best_minimal_restaurant_add_sub_menu_toggle', 10, 4 ); /** * Gets the icon svg code. * * @param string $icon The icon. * @param int $size The icon-size in pixels. * * @return string $svg */ function best_minimal_restaurant_get_svg( $icon, $size ) { $icons = array( 'plus' => '', 'minus' => '', ); /** * Filters array of icons. * * @since 1.0.5 * * @param array $icons Array of icons. */ $icons = apply_filters( 'best_minimal_restaurant_svg_icons', $icons ); $svg = ''; if ( array_key_exists( $icon, $icons ) ) { $repl = sprintf( ' element is here for styling purposes: Allows the description to not be underlined on hover. $args->after = ''; } return $args; } add_filter( 'nav_menu_item_args', 'best_minimal_restaurant_add_menu_description_args', 10, 3 );