Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ifood-theme functions and definitions
- *
- * @link https://developer.wordpress.org/themes/basics/theme-functions/
- *
- * @package ifood-theme
- */
- if ( ! function_exists( 'ifood_theme_setup' ) ) :
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which
- * runs before the init hook. The init hook is too late for some features, such
- * as indicating support for post thumbnails.
- */
- function ifood_theme_setup() {
- /*
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory.
- * If you're building a theme based on ifood-theme, use a find and replace
- * to change 'ifood-theme' to the name of your theme in all the template files.
- */
- load_theme_textdomain( 'ifood-theme', get_template_directory() . '/languages' );
- // Add default posts and comments RSS feed links to head.
- add_theme_support( 'automatic-feed-links' );
- /*
- * Let WordPress manage the document title.
- * By adding theme support, we declare that this theme does not use a
- * hard-coded <title> tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
- /*
- * Enable support for Post Thumbnails on posts and pages.
- *
- * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
- */
- add_theme_support( 'post-thumbnails' );
- add_image_size( 'feature-post-thumbnail', 600, 600, true );// Hard Crop Mode
- add_image_size( 'regular-post-thumbnail', 560, 505, true );// Hard Crop Mode
- add_image_size( 'video-post-thumbnail', 426, 240, true );// Hard Crop Mode
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus( array(
- 'primary' => esc_html__( 'Primary', 'ifood-theme' ),
- 'top' => esc_html__( 'Top', 'ifood-theme' ),
- 'footer' => esc_html__( 'Footer', 'ifood-theme' ),
- 'responsive' => esc_html__( 'Responsive', 'ifood-theme' ),
- 'front' => esc_html__( 'Front', 'ifood-theme' ),
- 'indexfirst' => esc_html__( 'Index First', 'ifood-theme' ),
- 'indexsecond' => esc_html__( 'Index Second', 'ifood-theme' ),
- 'indexthird' => esc_html__( 'Index Third', 'ifood-theme' ),
- 'indexfourth' => esc_html__( 'Index Fourth', 'ifood-theme' ),
- 'indexfifth' => esc_html__( 'Index Fifth', 'ifood-theme' ),
- ) );
- /*
- * Switch default core markup for search form, comment form, and comments
- * to output valid HTML5.
- */
- add_theme_support( 'html5', array(
- 'search-form',
- 'comment-form',
- 'comment-list',
- 'gallery',
- 'caption',
- ) );
- // Set up the WordPress core custom background feature.
- add_theme_support( 'custom-background', apply_filters( 'ifood_theme_custom_background_args', array(
- 'default-color' => 'ffffff',
- 'default-image' => '',
- ) ) );
- // Add theme support for selective refresh for widgets.
- add_theme_support( 'customize-selective-refresh-widgets' );
- }
- endif;
- add_action( 'after_setup_theme', 'ifood_theme_setup' );
- /**
- * Set the content width in pixels, based on the theme's design and stylesheet.
- *
- * Priority 0 to make it available to lower priority callbacks.
- *
- * @global int $content_width
- */
- function ifood_theme_content_width() {
- $GLOBALS['content_width'] = apply_filters( 'ifood_theme_content_width', 640 );
- }
- add_action( 'after_setup_theme', 'ifood_theme_content_width', 0 );
- /**
- * Register widget area.
- *
- * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
- */
- function ifood_theme_widgets_init() {
- register_sidebar( array(
- 'name' => esc_html__( 'very-top-widget-mobile', 'ifood-theme' ),
- 'id' => 'very-top-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'very-top-widget-desktop', 'ifood-theme' ),
- 'id' => 'very-top-widget-desktop',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'header-widget-left', 'ifood-theme' ),
- 'id' => 'header-widget-left',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'header-widget-right', 'ifood-theme' ),
- 'id' => 'header-widget-right',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'header-hero-ad', 'ifood-theme' ),
- 'id' => 'header-hero-ad',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'top-hero-container-widget', 'ifood-theme' ),
- 'id' => 'top-hero-container-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-widget-feature-tower', 'ifood-theme' ),
- 'id' => 'front-widget-feature-tower',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-below-feature-tower-ad', 'ifood-theme' ),
- 'id' => 'front-page-add-top-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-video', 'ifood-theme' ),
- 'id' => 'front-widget-video',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-video-scroll', 'ifood-theme' ),
- 'id' => 'front-widget-video-scroll',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-video-scroll-mobile', 'ifood-theme' ),
- 'id' => 'front-widget-video-posts',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-new-recipes', 'ifood-theme' ),
- 'id' => 'front-widget-with-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-new-recipes-sidebar-ad', 'ifood-theme' ),
- 'id' => 'front-page-add-side-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-content-feature-1', 'ifood-theme' ),
- 'id' => 'front-widget-content-features',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-content-feature-2', 'ifood-theme' ),
- 'id' => 'front-widget-vertical-1',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-content-feature-3', 'ifood-theme' ),
- 'id' => 'front-widget-vertical-2',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-content-feature-4', 'ifood-theme' ),
- 'id' => 'front-widget-vertical-3',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-content-feature-5', 'ifood-theme' ),
- 'id' => 'front-widget-vertical-4',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-ad-middle', 'ifood-theme' ),
- 'id' => 'front-page-add-middle-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-ad-bottom', 'ifood-theme' ),
- 'id' => 'front-page-add-bottom-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'front-page-about', 'ifood-theme' ),
- 'id' => 'front-widget-about',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="display widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'sidebar-widget-about', 'ifood-theme' ),
- 'id' => 'sidebar-widget-about',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-1', 'ifood-theme' ),
- 'id' => 'all-recipes-1',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-2', 'ifood-theme' ),
- 'id' => 'all-recipes-2',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-3', 'ifood-theme' ),
- 'id' => 'all-recipes-3',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-4', 'ifood-theme' ),
- 'id' => 'all-recipes-4',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-5', 'ifood-theme' ),
- 'id' => 'all-recipes-5',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-6', 'ifood-theme' ),
- 'id' => 'all-recipes-6',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-7', 'ifood-theme' ),
- 'id' => 'all-recipes-7',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-ad-1', 'ifood-theme' ),
- 'id' => 'all-recipes-ad-1',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'all-recipes-ad-2', 'ifood-theme' ),
- 'id' => 'all-recipes-ad-2',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'category-horizontal-widget-1', 'ifood-theme' ),
- 'id' => 'category-horizontal-widget-1',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'category-horizontal-widget-2', 'ifood-theme' ),
- 'id' => 'category-horizontal-widget-2',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'category-sidebar', 'ifood-theme' ),
- 'id' => 'category-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'page-sidebar', 'ifood-theme' ),
- 'id' => 'page-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'post-top-ad', 'ifood-theme' ),
- 'id' => 'post-add-top-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'post-sidebar', 'ifood-theme' ),
- 'id' => 'post-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title sidebar-widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'campaign-sidebar', 'ifood-theme' ),
- 'id' => 'campaign-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'before-comments', 'ifood-theme' ),
- 'id' => 'before-comments',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'dina-widget', 'ifood-theme' ),
- 'id' => 'dina-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'after-post-subscribe', 'ifood-theme' ),
- 'id' => 'after-post',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'after-post-content-feature', 'ifood-theme' ),
- 'id' => 'post-featured',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'video-category-featured-video', 'ifood-theme' ),
- 'id' => 'video-page-featured-video-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'video-category-sidebar', 'ifood-theme' ),
- 'id' => 'video-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'page-left-sidebar', 'ifood-theme' ),
- 'id' => 'page-left-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'post-left-sidebar', 'ifood-theme' ),
- 'id' => 'post-left-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h3 class="display widget-title">',
- 'after_title' => '</h3>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'page-left-sidebar-mobile', 'ifood-theme' ),
- 'id' => 'after-page',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'recipe-index', 'ifood-theme' ),
- 'id' => 'recipe-index',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'description-index', 'ifood-theme' ),
- 'id' => 'description-index',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'description-index-ingredients', 'ifood-theme' ),
- 'id' => 'description-index-ingredients',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'description-archive', 'ifood-theme' ),
- 'id' => 'description-archive',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'a-z-index', 'ifood-theme' ),
- 'id' => 'a-z-index',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'categories-index', 'ifood-theme' ),
- 'id' => 'categories-index',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'recipe-header-top', 'ifood-theme' ),
- 'id' => 'recipe-header-top',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'about-sidebar', 'ifood-theme' ),
- 'id' => 'about-sidebar',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- register_sidebar( array(
- 'name' => esc_html__( 'footer-widget', 'ifood-theme' ),
- 'id' => 'footer-widget',
- 'description' => esc_html__( 'Add widgets here.', 'ifood-theme' ),
- 'before_widget' => '<section id="%1$s" class="widget %2$s">',
- 'after_widget' => '</section>',
- 'before_title' => '<h2 class="widget-title">',
- 'after_title' => '</h2>',
- ) );
- }
- add_action( 'widgets_init', 'ifood_theme_widgets_init' );
- function theme_scripts() {
- wp_enqueue_script('jquery');
- }
- add_action('wp_enqueue_scripts', 'theme_scripts');
- // include custom jQuery
- if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
- function my_jquery_enqueue() {
- wp_deregister_script('jquery');
- wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://code.jquery.com/jquery-3.5.1.min.js", false, null);
- wp_enqueue_script('jquery');
- }
- /**
- * Enqueue scripts and styles.
- */
- function ifood_theme_scripts() {
- wp_enqueue_style( 'ifood-theme-style', get_stylesheet_uri() );
- wp_enqueue_script( 'ifood-theme-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
- wp_enqueue_script( 'ifood-theme-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
- wp_enqueue_script( 'ifood-theme-custom-script', get_template_directory_uri() . '/js/custom.js', array(), '20151215', true );
- if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
- wp_enqueue_script( 'comment-reply' );
- }
- }
- add_action( 'wp_enqueue_scripts', 'ifood_theme_scripts' );
- /**
- * Enqueue bootstrap styles and script.
- */
- function ifood_bootstrap_scripts() {
- wp_enqueue_style( 'bootstrap-theme-style', get_template_directory_uri() . '/bootstrap-4.0.0-alpha.6/scss/bootstrap.min.css' );
- wp_enqueue_style( 'bootstrap-reboot-style', get_template_directory_uri() . '/bootstrap-4.0.0-alpha.6/scss/bootstrap-reboot.min.css' );
- wp_enqueue_style( 'bootstrap-grid-style', get_template_directory_uri() . '/bootstrap-4.0.0-alpha.6/scss/bootstrap-grid.min.css' );
- wp_enqueue_script( 'bootstrap-tether', 'https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js' );
- wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/bootstrap-4.6.0/js/bootstrap.bundle.min.js' );
- }
- add_action( 'wp_enqueue_scripts', 'ifood_bootstrap_scripts' );
- /**
- * Enqueue overwrite bootstrap styles and script.
- */
- function ifood_bootstrap_overwrite_scripts() {
- wp_enqueue_style( 'bootstrap-overwrite-style', get_template_directory_uri() . '/style-overwrite.css' );
- }
- add_action( 'wp_enqueue_scripts', 'ifood_bootstrap_overwrite_scripts' );
- /**
- * Register a custom CSS file and enqueue it
- */
- function ifood_custom_print_css() {
- wp_enqueue_style( 'print-css', get_template_directory_uri() . '/print.css' );
- }
- add_action( 'wp_enqueue_scripts', 'ifood_custom_print_css' );
- /**
- * Implement the Custom Header feature.
- */
- require get_template_directory() . '/inc/custom-header.php';
- /**
- * Custom template tags for this theme.
- */
- require get_template_directory() . '/inc/template-tags.php';
- /**
- * Functions which enhance the theme by hooking into WordPress.
- */
- require get_template_directory() . '/inc/template-functions.php';
- /**
- * Customizer additions.
- */
- require get_template_directory() . '/inc/customizer.php';
- // Register Custom Navigation Walker
- require get_template_directory() . '/inc/nav-walker.php';
- /**
- * Load Jetpack compatibility file.
- */
- if ( defined( 'JETPACK__VERSION' ) ) {
- require get_template_directory() . '/inc/jetpack.php';
- }
- // /**
- // * Load font Awesome Icons.
- // */
- // add_action( 'wp_enqueue_scripts', 'enqueue_load_fa' );
- // function enqueue_load_fa() {
- // wp_enqueue_style( 'load-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
- // }
- /**
- * Add post formats.
- */
- function add_post_formats() {
- add_theme_support( 'post-formats', array( 'gallery', 'quote', 'video', 'aside', 'image', 'link' ) );
- }
- add_action( 'after_setup_theme', 'add_post_formats', 20 );
- /**
- * Add social to navigation.
- */
- add_filter('wp_nav_menu_items', 'add_social_responsive', 10, 2);
- function add_social_responsive($items, $args) {
- if( $args->theme_location == 'responsive' )
- $items .= '<li class="social-items d-flex justify-content-center nav-menu-social-items">' .
- '<a href="https://www.pinterest.ca/ifoodreal/" target="_blank" aria-label="pinterest" rel="noreferrer external"><div class="circle-social"><i class="fa fa-pinterest-p" aria-hidden="true"></i></div></a>
- <a href="https://www.instagram.com/ifoodreal/" target="_blank" aria-label="instagram" rel="noreferrer external"><div class="circle-social"><i class="fa fa-instagram" aria-hidden="true"></i></div></a>
- <a href="https://www.youtube.com/user/iFOODreal" target="_blank" aria-label="youtube" rel="noreferrer external"><div class="circle-social"><i class="fa fa-youtube" aria-hidden="true"></i></div></a>
- <a href="https://www.facebook.com/iFOODreal/" target="_blank" aria-label="facebook" rel="noreferrer external"><div class="circle-social"><i class="fa fa-facebook" aria-hidden="true"></i></div></a>' . '</li>';
- return $items;
- }
- /**
- * remove trackbacks.
- */
- function disable_self_trackback( &$links ) {
- foreach ( $links as $l => $link )
- if ( 0 === strpos( $link, get_option( 'home' ) ) )
- unset($links[$l]);
- }
- add_action( 'pre_ping', 'disable_self_trackback' );
- // postratings
- add_filter( 'wp_postratings_schema_itemtype', 'wp_postratings_schema_itemtype' );
- function wp_postratings_schema_itemtype( $itemtype ) {
- return 'itemscope itemtype="http://schema.org/Recipe"';
- }
- function custom_rating_image_extension() {
- return 'png';
- }
- add_filter( 'wp_postratings_image_extension', 'custom_rating_image_extension' );
- // remove url field from comments
- add_filter('comment_form_default_fields', 'unset_url_field');
- function unset_url_field($fields){
- if(isset($fields['url']))
- unset($fields['url']);
- return $fields;
- }
- // numeric posts navigation
- function numeric_posts_nav() {
- if( is_singular() )
- return;
- global $wp_query;
- /** Stop execution if there's only 1 page */
- if( $wp_query->max_num_pages <= 1 )
- return;
- $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
- $max = intval( $wp_query->max_num_pages );
- /** Add current page to the array */
- if ( $paged >= 1 )
- $links[] = $paged;
- /** Add the pages around the current page to the array */
- if ( $paged >= 3 ) {
- $links[] = $paged - 1;
- $links[] = $paged - 2;
- }
- if ( ( $paged + 2 ) <= $max ) {
- $links[] = $paged + 2;
- $links[] = $paged + 1;
- }
- echo '<div class="pagination-navigation col-md-12"><ul class="d-flex justify-content-center">' . "\n";
- /** Previous Post Link */
- if ( get_previous_posts_link() )
- printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
- /** Link to first page, plus ellipses if necessary */
- if ( ! in_array( 1, $links ) ) {
- $class = 1 == $paged ? ' class="active"' : '';
- printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
- if ( ! in_array( 2, $links ) )
- echo '<li>…</li>';
- }
- /** Link to current page, plus 2 pages in either direction if necessary */
- sort( $links );
- foreach ( (array) $links as $link ) {
- $class = $paged == $link ? ' class="active"' : '';
- printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
- }
- /** Link to last page, plus ellipses if necessary */
- if ( ! in_array( $max, $links ) ) {
- if ( ! in_array( $max - 1, $links ) )
- echo '<li>…</li>' . "\n";
- $class = $paged == $max ? ' class="active"' : '';
- printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
- }
- /** Next Post Link */
- if ( get_next_posts_link() )
- printf( '<li>%s</li>' . "\n", get_next_posts_link() );
- echo '</ul></div>' . "\n";
- }
- //add custom loading.gif icon
- add_filter( 'llc_loader_element_content', function () {
- // Use any html element.
- return '<p class="custom-loader"><img src="'.get_template_directory_uri().'/images/loading.gif" alt="loading-icon" height="32" width="32"></p>';
- });
- //Exclude pages from WordPress Search
- if (!is_admin()) {
- function wpb_search_filter($query) {
- if ($query->is_search) {
- $query->set('post_type', 'post');
- }
- return $query;
- }
- add_filter('pre_get_posts','wpb_search_filter');
- }
- //Get the first image from the post
- function get_first_image_url() {
- global $post, $posts;
- $first_img = '';
- ob_start();
- ob_end_clean();
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
- $first_img = $matches[1][0];
- // Defines a default image here
- if(empty($first_img)){
- $first_img = "/images/default.jpg";
- }
- return $first_img;
- }
- // Social sharing shortcode was here
- /**
- * Disable pinning of all featured images.
- */
- add_filter( 'post_thumbnail_html', function( $html ){
- // Something already has 'data-pin-nopin', so we don't need to modify.
- if ( false !== stripos( $html, 'data-pin-nopin' ) ) {
- return $html;
- }
- // Add 'data-pin-nopin' to the <img> HTML tag.
- $html = str_replace( '<img ', '<img data-pin-nopin="true" ', $html );
- return $html;
- });
- function my_searchwp_live_search_posts_per_page() {
- return 20; // return 20 results
- }
- add_filter( 'searchwp_live_search_posts_per_page', 'my_searchwp_live_search_posts_per_page' );
- function __search_by_title_only( $search, &$wp_query )
- {
- global $wpdb;
- if ( empty( $search ) )
- return $search; // skip processing – no search term in query
- $q = $wp_query->query_vars;
- $n = ! empty( $q['exact'] ) ? '' : '%';
- $search =
- $searchand = '';
- foreach ( (array) $q['search_terms'] as $term ) {
- $term = esc_sql( like_escape( $term ) );
- $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
- $searchand = ' AND ';
- }
- if ( ! empty( $search ) ) {
- $search = " AND ({$search}) ";
- if ( ! is_user_logged_in() )
- $search .= " AND ($wpdb->posts.post_password = '') ";
- }
- return $search; } add_filter( 'posts_search', '__search_by_title_only', 500, 2 );
- function widget_text_exec_php( $widget_text ) {
- if( strpos( $widget_text, '<' . '?' ) !== false ) {
- ob_start();
- eval( '?>' . $widget_text );
- $widget_text = ob_get_contents();
- ob_end_clean();
- }
- return $widget_text;
- }
- add_filter( 'widget_text', 'widget_text_exec_php', 99 );
- include('ratings-post-top.php');
- add_filter('body_class','add_category_to_single');
- function add_category_to_single($classes) {
- if (is_single() ) {
- global $post;
- foreach((get_the_category($post->ID)) as $category) {
- // add category slug to the $classes array
- $classes[] = $category->category_nicename;
- }
- }
- // return the $classes array
- return $classes;
- }
- // replace wordpress logo in login panel
- function my_login_logo() { ?>
- <style type="text/css">
- #login h1 a, .login h1 a {
- background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/ifoodreal-logo.png);
- height: 62px !important;
- width: 80% !important;
- background-size: 90% !important;
- line-height: inherit !important;
- margin: 0 auto 0 !important;
- }
- </style>
- <?php }
- add_action( 'login_enqueue_scripts', 'my_login_logo' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement