Viewing File: /home/maglabs/2vsa/wp-content/themes/cargohub/functions.php
<?php
/**
* CargoHub functions and definitions
*
* @package CargoHub
*/
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* @since 1.0
*
* @return void
*/
function cargohub_setup() {
// Sets the content width in pixels, based on the theme's design and stylesheet.
$GLOBALS['content_width'] = apply_filters( 'cargohub_content_width', 840 );
// Make theme available for translation.
load_theme_textdomain( 'cargohub', get_template_directory() . '/lang' );
// Theme supports
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
add_theme_support(
'html5', array(
'comment-list',
'search-form',
'comment-form',
'gallery',
)
);
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors.
*/
add_editor_style( 'css/editor-style.css' );
// Load regular editor styles into the new block-based editor.
add_theme_support( 'editor-styles' );
// Load default block styles.
add_theme_support( 'wp-block-styles' );
// Add support for responsive embeds.
add_theme_support( 'responsive-embeds' );
add_theme_support( 'align-wide' );
add_theme_support( 'align-full' );
add_post_type_support( 'page', 'excerpt' );
add_image_size( 'cargohub-blog-thumb', 1170, 646, true );
add_image_size( 'cargohub-blog-grid-thumb', 570, 300, true );
add_image_size( 'cargohub-blog-grid-thumb-2', 555, 300, true );
add_image_size( 'cargohub-blog-grid-thumb-3', 540, 360, true );
add_image_size( 'cargohub-widget-thumb', 75, 75, true );
add_image_size( 'cargohub-single-project-thumb', 1170, 500, true );
add_image_size( 'cargohub-project-grid-thumb', 675, 550, true );
add_image_size( 'cargohub-service-thumb', 530, 300, true );
add_image_size( 'cargohub-testimonial-thumb', 80, 80, true );
// Register theme nav menu
register_nav_menus(
array(
'primary' => esc_html__( 'Primary Menu', 'cargohub' ),
'footer' => esc_html__( 'Footer Menu', 'cargohub' ),
)
);
}
add_action( 'after_setup_theme', 'cargohub_setup' );
/**
* Register widgetized area and update sidebar with default widgets.
*
* @since 1.0
*
* @return void
*/
function cargohub_register_sidebar() {
$sidebars = array(
'blog-sidebar' => esc_html__( 'Blog Sidebar', 'cargohub' ),
'service-sidebar' => esc_html__( 'Service Sidebar', 'cargohub' ),
'page-sidebar' => esc_html__( 'Page Sidebar', 'cargohub' ),
);
$widget = array(
'header' => esc_html__( 'Header', 'cargohub' ),
'topbar-left' => esc_html__( 'Topbar Left', 'cargohub' ),
'topbar-right' => esc_html__( 'Topbar Right', 'cargohub' ),
);
// Register sidebars
foreach ( $sidebars as $id => $name ) {
register_sidebar(
array(
'name' => $name,
'id' => $id,
'description' => esc_html__( 'Add widgets here in order to display on pages', 'cargohub' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
}
// Register other widget
foreach ( $widget as $id => $name ) {
register_sidebar(
array(
'name' => $name,
'id' => $id,
'description' => esc_html__( 'Add widgets here in order to display on header', 'cargohub' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
}
// Register footer sidebars
for ( $i = 1; $i <= 4; $i ++ ) {
register_sidebar(
array(
'name' => esc_html__( 'Footer', 'cargohub' ) . " $i",
'id' => "footer-sidebar-$i",
'description' => esc_html__( 'Add widgets here in order to display on footer', 'cargohub' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
}
}
add_action( 'widgets_init', 'cargohub_register_sidebar' );
/**
* Load theme
*/
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/backend/customizer.php';
require get_template_directory() . '/inc/backend/editor.php';
// Frontend functions and shortcodes
require get_template_directory() . '/inc/functions/nav.php';
require get_template_directory() . '/inc/functions/entry.php';
require get_template_directory() . '/inc/functions/comments.php';
require get_template_directory() . '/inc/functions/options.php';
require get_template_directory() . '/inc/functions/breadcrumbs.php';
require get_template_directory() . '/inc/functions/footer.php';
require get_template_directory() . '/inc/functions/media.php';
// Frontend hooks
require get_template_directory() . '/inc/frontend/layout.php';
require get_template_directory() . '/inc/frontend/header.php';
require get_template_directory() . '/inc/frontend/footer.php';
require get_template_directory() . '/inc/frontend/nav.php';
require get_template_directory() . '/inc/frontend/entry.php';
if ( is_admin() ) {
require get_template_directory() . '/inc/libs/class-tgm-plugin-activation.php';
require get_template_directory() . '/inc/backend/plugins.php';
require get_template_directory() . '/inc/backend/meta-boxes.php';
}
Back to Directory
File Manager