$slider_controls, 'slider_pager' => $slider_pager, ) ); } endif; /****************************************************************************************/ if ( ! function_exists( 'foodhunt_header_title' ) ) : /** * Function to display Header Title bar. */ function foodhunt_header_title() { if ( is_archive() ) { if ( function_exists( 'foodhunt_is_in_woocommerce_page' ) && foodhunt_is_in_woocommerce_page() ) { echo '

'; woocommerce_page_title( true ); echo '

'; } else { the_archive_title( '

', '

' ); the_archive_description( '
', '
' ); } } elseif ( is_page() ) { the_title( '

', '

' ); } elseif ( is_home() ) { $queried_id = get_option( 'page_for_posts' ); echo '

' . get_the_title( $queried_id ) . '

'; } } endif; /****************************************************************************************/ if ( ! function_exists( 'foodhunt_header_news' ) ) : /** * Header News/Latest Posts ticker section */ function foodhunt_header_news() { if ( false === ( $get_featured_posts = get_transient( 'foodhunt_cached_breaking_news' ) ) ) { $get_featured_posts = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => 'post', 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); set_transient( 'foodhunt_cached_breaking_news', $get_featured_posts, DAY_IN_SECONDS ); } ?>
'social', 'container_class' => 'social-icons-wrapper', 'depth' => - 1, 'fallback_cb' => false, ) ); ?> %2$s'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $post_date = sprintf( '%1$s %2$s %3$s ', esc_html( get_the_time( 'j' ) ), esc_html( get_the_time( 'F' ) ), esc_html( get_the_time( 'Y' ) ) ); $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), $post_date, esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( '%2$s', esc_url( get_permalink() ), $time_string ); echo '' . $posted_on . ''; } if ( get_theme_mod( 'foodhunt_hide_author', 0 ) != '1' ) { $byline = sprintf( '%2$s', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); echo ' ' . $byline . ''; } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && get_theme_mod( 'foodhunt_hide_comment', 0 ) != '1' ) { echo ' '; comments_popup_link( esc_html__( 'Leave a comment', 'foodhunt' ), esc_html__( 'Comment (1)', 'foodhunt' ), esc_html__( 'Comments (%)', 'foodhunt' ) ); echo ''; } if ( get_theme_mod( 'foodhunt_hide_cat', 0 ) != '1' ) { $categories_list = get_the_category_list( esc_html__( ', ', 'foodhunt' ) ); if ( $categories_list ) { printf( '%1$s', $categories_list ); } } if ( get_theme_mod( 'foodhunt_hide_tags', 0 ) != '1' ) { $tags_list = get_the_tag_list( '', ', ', '' ); if ( $tags_list ) { echo $tags_list; } } } endif; /****************************************************************************************/ if ( ! function_exists( 'foodhunt_sidebar_select' ) ) : /** * Function to select the sidebar */ function foodhunt_sidebar_select() { $foodhunt_layout = foodhunt_layout_class(); if ( $foodhunt_layout == 'right-sidebar' ) { get_sidebar(); } elseif ( $foodhunt_layout == 'left-sidebar' ) { get_sidebar( 'left' ); } } endif; /****************************************************************************************/ if ( ! function_exists( 'foodhunt_layout_class' ) ) : /** * Return the layout as selected by user */ function foodhunt_layout_class() { global $post; $classes = ''; if ( $post ) { $layout_meta = get_post_meta( $post->ID, 'foodhunt_page_layout', true ); } if ( is_home() ) { $queried_id = get_option( 'page_for_posts' ); $layout_meta = get_post_meta( $queried_id, 'foodhunt_page_layout', true ); } if ( empty( $layout_meta ) || is_archive() || is_search() ) { $layout_meta = 'default_layout'; } $foodhunt_default_layout = get_theme_mod( 'foodhunt_default_layout', 'right-sidebar' ); $foodhunt_default_page_layout = get_theme_mod( 'foodhunt_default_page_layout', 'right-sidebar' ); $foodhunt_default_post_layout = get_theme_mod( 'foodhunt_default_single_posts_layout', 'right-sidebar' ); if ( $layout_meta == 'default_layout' ) { if ( is_page() ) { $classes = $foodhunt_default_page_layout; } elseif ( is_single() ) { $classes = $foodhunt_default_post_layout; } else { $classes = $foodhunt_default_layout; } } else { $classes = $layout_meta; } return $classes; } endif; /****************************************************************************************/ add_filter( 'body_class', 'foodhunt_body_class' ); /* * Filter the body_class * * Throwing different class in the body tag */ function foodhunt_body_class( $foodhunt_header_class ) { if ( get_theme_mod( 'foodhunt_non_sticky', 0 ) == 1 ) { $foodhunt_header_class[] = 'non-stick'; } else { $foodhunt_header_class[] = 'stick'; } return $foodhunt_header_class; } /**************************************************************************************/ /** * Change hex code to RGB * Source: https://css-tricks.com/snippets/php/convert-hex-to-rgb/#comment-1052011 */ function foodhunt_hex2rgb( $hexstr ) { $int = hexdec( $hexstr ); $rgb = array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int ); $r = $rgb['red']; $g = $rgb['green']; $b = $rgb['blue']; return "rgba($r,$g,$b, 0.85)"; } /** * Generate darker color * Source: http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php */ function foodhunt_darkcolor( $hex, $steps ) { // Steps should be between -255 and 255. Negative = darker, positive = lighter $steps = max( - 255, min( 255, $steps ) ); // Normalize into a six character long hex string $hex = str_replace( '#', '', $hex ); if ( strlen( $hex ) == 3 ) { $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); } // Split into three parts: R, G and B $color_parts = str_split( $hex, 2 ); $return = '#'; foreach ( $color_parts as $color ) { $color = hexdec( $color ); // Convert to decimal $color = max( 0, min( 255, $color + $steps ) ); // Adjust color $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code } return $return; } add_action( 'wp_head', 'foodhunt_custom_css', 100 ); /** * Hooks the Custom Internal CSS to head section */ function foodhunt_custom_css() { $primary_color = get_theme_mod( 'foodhunt_primary_color', '#dd0103' );; $primary_opacity = foodhunt_hex2rgb( $primary_color ); $primary_dark = foodhunt_darkcolor( $primary_color, - 50 ); $foodhunt_internal_css = ''; if ( $primary_color != '#dd0103' ) { $foodhunt_internal_css = '.blog-btn,.blog-grid .entry-btn .btn:hover,.blog-grid .entry-thumbnail a,.blog-grid .more-link .entry-btn:hover,.blog-img,.chef-content-wrapper,.comment-list .comment-body,.contact-map,.header-titlebar-wrapper,.page-header,.single-blog .entry-thumbnail a,.sub-toggle{border-color:' . $primary_color . '}#cancel-comment-reply-link,#cancel-comment-reply-link:before,#secondary .entry-title a,#secondary .widget a:hover,.blog-grid .byline:hover a,.blog-grid .byline:hover i,.blog-grid .cat-links:hover a,.blog-grid .cat-links:hover i,.blog-grid .comments-link:hover a,.blog-grid .comments-link:hover i,.blog-grid .entry-btn .btn:hover,.blog-grid .entry-month-year:hover i,.blog-grid .entry-month-year:hover span,.blog-grid .more-link .entry-btn:hover,.comment-author .fn .url:hover,.contact-title,.logged-in-as a,.single-blog .byline:hover a,.single-blog .byline:hover i,.single-blog .cat-links:hover a,.single-blog .cat-links:hover i,.single-blog .comments-link:hover a,.single-blog .comments-link:hover i,.single-blog .entry-month-year:hover i,.single-blog .entry-month-year:hover span,.ticker-title,a,.num-404{color:' . $primary_color . '}#secondary .widget-title span::after,#top-footer .widget-title span::after,.about-btn,.blog-grid .entry-title,.contact-icon,.single-blog .entry-title,.sub-toggle,.scrollup,.search-form-wrapper .close,.search-form-wrapper .search-submit,.widget_search .search-form button{background:' . $primary_color . '}#bottom-footer .copyright a:hover,#bottom-footer li a:hover,#site-navigation ul li:hover>a,#site-navigation ul li>a:after,#top-footer .footer-block li:hover a,#top-footer .footer-block li:hover:before,#top-footer .widget a:hover:before,#top-footer .widget_tag_cloud a:hover,.blog-title a:hover,.chef-btn:hover,.chef-social a:hover,.chef-title a:hover,.entry-meta span a:hover,.entry-meta span:hover i,.mobile-menu-wrapper ul li.current-menu-ancestor>a,.mobile-menu-wrapper ul li.current-menu-item>a,.mobile-menu-wrapper ul li:hover>a,.service-title a:hover,.social-icons-wrapper li a:hover::before,.widget_archive a:hover::before,.widget_archive li a:hover,.widget_categories a:hover:before,.widget_categories li a:hover,.widget_meta a:hover:before,.widget_meta li a:hover,.widget_nav_menu a:hover:before,.widget_nav_menu li a:hover,.widget_pages a:hover:before,.widget_pages li a:hover,.widget_recent_comments a:hover:before,.widget_recent_comments li a:hover,.widget_recent_entries a:hover:before,.widget_recent_entries li a:hover,.widget_rss a:hover:before,.widget_rss li a:hover,.widget_tag_cloud a:hover,.search-icon:hover,a:hover, a:focus, a:active{color:' . $primary_dark . '}#home-slider .bx-pager-item a.active,#home-slider .bx-pager-item a:hover,.blog-btn:hover,.bttn:hover,.gallery-wrapper li .gallery-zoom span:hover,.navigation .nav-links a:hover,.slider-btn:hover,button,input[type=button]:hover,input[type=reset]:hover,input[type=submit]:hover,#site-navigation ul li > a::after,.about-btn:hover,.cta-btn:hover,.scrollup:hover, .scrollup:focus,.search-box .search-form-wrapper,.widget_search .search-form button:hover{background:' . $primary_dark . '}.contact-form input:focus,.gallery-wrapper li .gallery-zoom span:hover,.slider-btn:hover,.widget_tag_cloud a:hover,#top-footer .widget_tag_cloud a:hover,.cta-btn:hover{border-color:' . $primary_dark . '}.num-404{text-shadow:13px 0 0 ' . $primary_dark . '}.search-box{background:' . $primary_opacity . '}'; } if ( ! empty( $foodhunt_internal_css ) ) { ?> '; ?> ' . get_bloginfo( 'name', 'display' ) . ''; $wp_link = '' . esc_html__( 'WordPress', 'foodhunt' ) . ''; $tg_link = ''; $default_footer_value = sprintf( esc_html__( 'Copyright © %1$s %2$s.', 'foodhunt' ), date( 'Y' ), $site_link ) . ' ' . sprintf( esc_html__( 'Theme: %1$s by %2$s.', 'foodhunt' ), 'FoodHunt', $tg_link ) . ' ' . sprintf( esc_html__( 'Powered by %s', 'foodhunt' ), $wp_link ); $foodhunt_footer_copyright = ''; echo $foodhunt_footer_copyright; } endif; /****************************************************************************************/ add_action( 'add_meta_boxes', 'foodhunt_add_custom_box' ); /** * Add Meta Boxes. */ function foodhunt_add_custom_box() { // Adding layout meta box for Page add_meta_box( 'page-layout', esc_html__( 'Select Layout', 'foodhunt' ), 'foodhunt_layout_call', 'page', 'side' ); // Adding layout meta box for Post add_meta_box( 'post-layout', esc_html__( 'Select Layout', 'foodhunt' ), 'foodhunt_layout_call', 'post', 'side' ); //Adding designation meta box add_meta_box( 'team-designation', esc_html__( 'Our Team Designation', 'foodhunt' ), 'foodhunt_designation_call', 'page', 'side' ); } /****************************************************************************************/ global $foodhunt_page_layout, $foodhunt_metabox_field_designation; $foodhunt_page_layout = array( 'default-layout' => array( 'id' => 'foodhunt_page_layout', 'value' => 'default_layout', 'label' => esc_html__( 'Default Layout', 'foodhunt' ), ), 'right-sidebar' => array( 'id' => 'foodhunt_page_layout', 'value' => 'right-sidebar', 'label' => esc_html__( 'Right Sidebar', 'foodhunt' ), ), 'left-sidebar' => array( 'id' => 'foodhunt_page_layout', 'value' => 'left-sidebar', 'label' => esc_html__( 'Left Sidebar', 'foodhunt' ), ), 'no-sidebar-full-width' => array( 'id' => 'foodhunt_page_layout', 'value' => 'no-sidebar-full-width', 'label' => esc_html__( 'No Sidebar Full Width', 'foodhunt' ), ), 'no-sidebar-content-centered' => array( 'id' => 'foodhunt_page_layout', 'value' => 'no-sidebar-content-centered', 'label' => esc_html__( 'No Sidebar Content Centered', 'foodhunt' ), ), ); $foodhunt_metabox_field_designation = array( array( 'id' => 'foodhunt_designation', 'label' => esc_html__( 'team designation', 'foodhunt' ), ), ); /****************************************************************************************/ function foodhunt_layout_call() { global $foodhunt_page_layout; foodhunt_meta_form( $foodhunt_page_layout ); } function foodhunt_designation_call() { global $foodhunt_metabox_field_designation; foodhunt_meta_form( $foodhunt_metabox_field_designation ); } /** * Displays metabox to for select layout option */ function foodhunt_meta_form( $foodhunt_metabox_field ) { global $post; // Use nonce for verification wp_nonce_field( basename( __FILE__ ), 'custom_meta_box_nonce' ); foreach ( $foodhunt_metabox_field as $field ) { $layout_meta = get_post_meta( $post->ID, $field['id'], true ); switch ( $field['id'] ) { // Layout case 'foodhunt_page_layout': if ( empty( $layout_meta ) ) { $layout_meta = 'default_layout'; } ?> />
'; echo '
'; break; } } } /****************************************************************************************/ add_action( 'save_post', 'foodhunt_save_custom_meta' ); /** * save the custom metabox data * * @hooked to save_post hook */ function foodhunt_save_custom_meta( $post_id ) { global $foodhunt_page_layout, $post, $foodhunt_metabox_field_designation, $post;; // Verify the nonce before proceeding. if ( ! isset( $_POST['custom_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['custom_meta_box_nonce'], basename( __FILE__ ) ) ) { return; } // Stop WP from clearing custom fields on autosave if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; } } elseif ( ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; } foreach ( $foodhunt_page_layout as $field ) { //Execute this saving function $old = get_post_meta( $post_id, $field['id'], true ); $new = sanitize_key( $_POST[ $field['id'] ] ); if ( $new && $new != $old ) { update_post_meta( $post_id, $field['id'], $new ); } elseif ( '' == $new && $old ) { delete_post_meta( $post_id, $field['id'], $old ); } } // end foreach if ( 'page' == $_POST['post_type'] ) { // loop through fields and save the data foreach ( $foodhunt_metabox_field_designation as $field ) { $old = get_post_meta( $post_id, $field['id'], true ); $new = sanitize_key( $_POST[ $field['id'] ] ); if ( $new && $new != $old ) { update_post_meta( $post_id, $field['id'], $new ); } elseif ( '' == $new && $old ) { delete_post_meta( $post_id, $field['id'], $old ); } } // end foreach } } /****************************************************************************************/ add_filter( 'restaurantpress_widget_menu_settings', 'foodhunt_rp_widget_menu_settings' ); add_action( 'restaurantpress_widget_menu_before', 'foodhunt_rp_widget_menu_before', 10, 2 ); add_action( 'restaurantpress_widget_menu_after', 'foodhunt_rp_widget_menu_after' ); function foodhunt_rp_widget_menu_settings( $settings ) { $settings['background_color'] = array( 'type' => 'color', 'std' => '#F5F5F5', 'label' => esc_html__( 'Background Color', 'foodhunt' ), ); return $settings; } function foodhunt_rp_widget_menu_before( $args, $instance ) { echo '
'; } function foodhunt_rp_widget_menu_after() { echo '
'; } /****************************************************************************************/ /** * Making the theme Woocommrece compatible */ remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); add_filter( 'woocommerce_show_page_title', '__return_false' ); add_action( 'woocommerce_before_main_content', 'foodhunt_wrapper_start', 10 ); add_action( 'woocommerce_after_main_content', 'foodhunt_wrapper_end', 10 ); add_action( 'woocommerce_sidebar', 'foodhunt_get_sidebar', 20 ); function foodhunt_wrapper_start() { $foodhunt_layout = foodhunt_layout_class(); echo '
'; } function foodhunt_wrapper_end() { echo '
'; } function foodhunt_get_sidebar() { foodhunt_sidebar_select(); echo '
'; } if ( class_exists( 'woocommerce' ) && ! function_exists( 'foodhunt_is_in_woocommerce_page' ) ): /* * woocommerce - conditional to check if woocommerce related page showed */ function foodhunt_is_in_woocommerce_page() { return ( is_shop() || is_product_category() || is_product_tag() || is_product() || is_cart() || is_checkout() || is_account_page() ) ? true : false; } endif; // Displays the site logo if ( ! function_exists( 'foodhunt_the_custom_logo' ) ) { /** * Displays the optional custom logo. */ function foodhunt_the_custom_logo() { if ( function_exists( 'the_custom_logo' ) ) { the_custom_logo(); } } } /** * Migrate any existing theme CSS codes added in Customize Options to the core option added in WordPress 4.7 */ function foodhunt_custom_css_migrate() { if ( function_exists( 'wp_update_custom_css_post' ) ) { $custom_css = get_theme_mod( 'foodhunt_custom_css' ); if ( $custom_css ) { $core_css = wp_get_custom_css(); // Preserve any CSS already added to the core option. $return = wp_update_custom_css_post( $core_css . $custom_css ); if ( ! is_wp_error( $return ) ) { // Remove the old theme_mod, so that the CSS is stored in only one place moving forward. remove_theme_mod( 'foodhunt_custom_css' ); } } } } add_action( 'after_setup_theme', 'foodhunt_custom_css_migrate' ); if ( ! function_exists( 'foodhunt_related_posts_function' ) ) { /** * Display the related posts. */ function foodhunt_related_posts_function() { wp_reset_postdata(); global $post; // Define shared post arguments. $args = array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'post__not_in' => array( $post->ID ), 'posts_per_page' => 3, ); // Related by categories. if ( get_theme_mod( 'foodhunt_related_posts_display', 'categories' ) == 'categories' ) { $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'ids' ) ); $args['category__in'] = $cats; } // Related by tags. if ( get_theme_mod( 'foodhunt_related_posts_display', 'categories' ) == 'tags' ) { $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); $args['tag__in'] = $tags; // If no tags added, return if ( ! $tags ) { $break = true; } } $query = ! isset( $break ) ? new WP_Query( $args ) : new WP_Query; return $query; } } if ( ! function_exists( 'foodhunt_pingback_header' ) ) : /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. */ function foodhunt_pingback_header() { if ( is_singular() && pings_open() ) { printf( '', esc_url( get_bloginfo( 'pingback_url' ) ) ); } } endif; add_action( 'wp_head', 'foodhunt_pingback_header' );