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' );
// Used in archive content, featured content.
set_post_thumbnail_size( 825, 620, false );
// Used in slider.
add_image_size( 'business-class-slider', 1920, 900, false );
// Used in hero content.
add_image_size( 'business-class-hero', 600, 650, false );
// Used in portfolio, team.
add_image_size( 'business-class-news', 800, 450, false );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', 'business-class' ),
)
);
/*
* 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',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'business_class_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'business_class_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 business_class_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'business_class_content_width', 640 );
}
add_action( 'after_setup_theme', 'business_class_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function business_class_widgets_init() {
$footer_before_widget = '';
$footer_before_title = '
';
/**
* Theme Sidebar
*/
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'business-class' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets for theme sidebar.', 'business-class' ),
'before_widget' => '',
'before_title' => '',
)
);
/*
* Footer widget areas
*/
register_sidebar(
array(
'name' => esc_html__( 'Footer Widgets One', 'business-class' ),
'id' => 'footer-widgets-1',
'description' => esc_html__( 'Add footer widgets here.', 'business-class' ),
'before_widget' => $footer_before_widget,
'after_widget' => $footer_after_widget,
'before_title' => $footer_before_title,
'after_title' => $footer_after_title,
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widgets Two', 'business-class' ),
'id' => 'footer-widgets-2',
'description' => esc_html__( 'Add footer widgets here.', 'business-class' ),
'before_widget' => $footer_before_widget,
'after_widget' => $footer_after_widget,
'before_title' => $footer_before_title,
'after_title' => $footer_after_title,
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widgets Three', 'business-class' ),
'id' => 'footer-widgets-3',
'description' => esc_html__( 'Add footer widgets here.', 'business-class' ),
'before_widget' => $footer_before_widget,
'after_widget' => $footer_after_widget,
'before_title' => $footer_before_title,
'after_title' => $footer_after_title,
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widgets Four', 'business-class' ),
'id' => 'footer-widgets-4',
'description' => esc_html__( 'Add footer widgets here.', 'business-class' ),
'before_widget' => $footer_before_widget,
'after_widget' => $footer_after_widget,
'before_title' => $footer_before_title,
'after_title' => $footer_after_title,
)
);
}
add_action( 'widgets_init', 'business_class_widgets_init' );
if ( ! function_exists( 'business_class_get_newsletter_form' ) ) {
/**
* Prints the newsletter form.
*
* @uses mc4wp_show_form() - MailChimp for WordPress plugin
* @link https://www.mc4wp.com/
*
* @param int $form_id Form id of mc4wp.
* @param bool $echo Return or print the form html.
*/
function business_class_get_newsletter_form( $form_id = 0, $echo = true ) {
if ( ! function_exists( 'mc4wp_show_form' ) ) {
return;
}
if ( ! $echo ) {
return mc4wp_show_form( $form_id, array(), $echo );
}
mc4wp_show_form( $form_id, array(), $echo );
}
}
if ( ! function_exists( 'business_class_get_post_meta' ) ) {
/**
* Returns the custom post meta data.
*
* @param int $post_id Post ID.
* @param string $key Array key post saved meta data.
*/
function business_class_get_post_meta( $post_id, $key = '' ) {
if ( ! $post_id ) {
return;
}
$post_meta = get_post_meta( $post_id, 'business_class_metabox', true );
return $key && isset( $post_meta[ $key ] ) ? $post_meta[ $key ] : '';
}
}
if ( ! function_exists( 'business_class_menu_fallback' ) ) {
/**
* If no navigation menu is assigned, this function will be used for the fallback.
*
* @see https://developer.wordpress.org/reference/functions/wp_nav_menu/ for available $args arguments.
* @param mixed $args Menu arguments.
* @return string $output Return or echo the add menu link.
*/
function business_class_menu_fallback( $args ) {
if ( ! current_user_can( 'edit_theme_options' ) ) {
return;
}
$link = $args['link_before'];
$link .= '' . $args['before'] . esc_html__( 'Add a menu', 'business-class' ) . $args['after'] . '';
$link .= $args['link_after'];
if ( false !== stripos( $args['items_wrap'], '