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( 'somalite-blog-footer-thumb', 100, 65 );
add_image_size( 'somalite-blog-section-thumb', 360, 239 );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Primary', 'somalite' ),
'footer' => __( 'Footer Menu', 'somalite' ),
) );
/*
* 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',
) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* somalite theme info
*/
require get_template_directory() . '/inc/theme-info.php';
/**
* About page instance
*/
$config = array();
Somalite_About_Page::init( $config );
//woocommerce support
add_theme_support( 'woocommerce' );
}
endif;
add_action( 'after_setup_theme', 'somalite_setup' );
/**
* Custom Logo
*
*/
if ( ! function_exists( 'somalite_logo_setup' ) ) :
function somalite_logo_setup() {
add_theme_support( 'custom-logo', array(
'height' => 60,
'width' => 135,
'flex-height' => true,
'flex-width' => true,
));
}
endif;
add_action( 'after_setup_theme', 'somalite_logo_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
*/
if ( ! function_exists( 'somalite_content_width' ) ) :
function somalite_content_width() {
$GLOBALS['content_width'] = apply_filters( 'somalite_content_width', 640 );
}
endif;
add_action( 'after_setup_theme', 'somalite_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
if ( ! function_exists( 'somalite_widgets_init' ) ) :
function somalite_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'somalite' ),
'id' => 'primary',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Woocommerce Sidebar', 'somalite' ),
'id' => 'woosidebar',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Column1', 'somalite' ),
'id' => 'footer-column1',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Column2', 'somalite' ),
'id' => 'footer-column2',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Column3', 'somalite' ),
'id' => 'footer-column3',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => __( 'Footer Column4', 'somalite' ),
'id' => 'footer-column4',
'description' => __( 'Add widgets here.', 'somalite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
}
endif;
add_action( 'widgets_init', 'somalite_widgets_init' );
/**
* Display custom CSS.
*/
function somalite_custom_css_wrap() {
if ( ! is_customize_preview() ) {
return;
}
require_once( get_parent_theme_file_path( '/inc/custom-stylesheet.php' ) );
?>
urlencode( implode( '|', $fonts ) )
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
/**
* Soma Excerpt Length
*/
if ( !function_exists('somalite_excerpt_length') ) :
function somalite_excerpt_length($length) {
return 50;
}
endif;
add_filter('excerpt_length', 'somalite_excerpt_length');
/**
* Registers an editor stylesheet for the theme.
*/
if ( !function_exists('somalite_theme_add_editor_styles') ) :
function somalite_theme_add_editor_styles() {
add_editor_style(get_template_directory_uri() . '/css/custom-editor-style.css' );
}
endif;
add_action( 'admin_init', 'somalite_theme_add_editor_styles' );
/**
* Custom search form
*/
if ( !function_exists('somalite_search_form') ) :
function somalite_search_form( $form ) {
$form = '';
return $form;
}
endif;
add_filter( 'get_search_form', 'somalite_search_form', 100 );
/**
* Custom product search form
*/
if ( !function_exists('somalite_product_search_form') ) :
function somalite_product_search_form( $form ) {
$form = '';
return $form;
}
endif;
add_filter( 'get_product_search_form', 'somalite_product_search_form', 100 );
/**
* Search Filter
*/
if ( !function_exists('somalite_search_filter') ) :
function somalite_search_filter($query) {
if ($query->is_search && is_post_type_archive( 'product' )) {
$query->set('post_type', 'product');
}
return $query;
}
endif;
add_filter('pre_get_posts','somalite_search_filter');
/**
* Soma Excerpt More
*/
if ( !function_exists('somalite_excerpt_more') ) :
function somalite_excerpt_more( $more ) {
return ' …';
}
endif;
add_filter('excerpt_more', 'somalite_excerpt_more');
/**
* Add a pingback url auto-discovery header for singularly identifiable articles.
*/
function somalite_pingback_header() {
if ( is_singular() && pings_open() ) {
printf( '' . "\n", get_bloginfo( 'pingback_url' ) );
}
}
add_action( 'wp_head', 'somalite_pingback_header' );
/**
* Soma Moving Comment fields
*/
if ( !function_exists('somalite_move_comment_field_to_bottom') ) :
function somalite_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
endif;
add_filter( 'comment_form_fields', 'somalite_move_comment_field_to_bottom' );
/**
* Soma Add Widgets to Site Origin Page Builder Group
*/
if ( !function_exists('somalite_add_widget_tabs') ) :
function somalite_add_widget_tabs($tabs) {
$tabs[] = array(
'title' => __('Soma Widgets', 'somalite'),
'filter' => array(
'groups' => array('soma')
)
);
return $tabs;
}
endif;
add_filter('siteorigin_panels_widget_dialog_tabs', 'somalite_add_widget_tabs', 20);
/**
* Using home page title instead of site name
*/
if ( !function_exists('somalite_breadcrumb_title') ) :
function somalite_breadcrumb_title($title, $type, $id) {
if ($type[0] === 'home') {
$title = get_the_title(get_option('page_on_front'));
}
return $title;
}
endif;
add_filter('bcn_breadcrumb_title', 'somalite_breadcrumb_title', 42,3);
/**
* Set homepage and blog page after demo import
*/
function somalite_after_import_setup() {
//Assign menus to their locations
$main_menu = get_term_by( 'name', 'Primary', 'nav_menu' );
set_theme_mod( 'nav_menu_locations', array(
'primary' => $main_menu->term_id,
)
);
//Assign front page
$front_page = get_page_by_title( 'Home' );
$blog_page = get_page_by_title( 'Blog' );
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $front_page -> ID );
update_option( 'page_for_posts', $blog_page -> ID );
}
add_action( 'pt-ocdi/after_import', 'somalite_after_import_setup' );
/**
* Plugins Required
*/
if ( !function_exists('somalite_register_required_plugins') ) :
function somalite_register_required_plugins() {
$plugins = array(
array(
'name' => 'Contact Form 7',
'slug' => 'contact-form-7',
'source' => '',
'required' => false,
'external_url' => 'http://contactform7.com/',
'force_activation' => false,
),
array(
'name' => 'WP Google Maps',
'slug' => 'wp-google-maps',
'source' => '',
'required' => false,
'external_url' => 'http://www.wpgmaps.com/',
'force_activation' => false,
),
array(
'name' => 'Page Builder by SiteOrigin',
'slug' => 'siteorigin-panels',
'source' => '',
'required' => false,
'external_url' => 'https://siteorigin.com/page-builder/',
'force_activation' => false,
),
array(
'name' => 'WooCommerce',
'slug' => 'woocommerce',
'source' => '',
'required' => false,
'external_url' => 'https://woocommerce.com/',
'force_activation' => false,
),
array(
'name' => 'Breadcrumb NavXT',
'slug' => 'breadcrumb-navxt',
'source' => '',
'required' => false,
'external_url' => 'https://wordpress.org/plugins/breadcrumb-navxt/',
'force_activation' => false,
),
array(
'name' => 'One Click Demo Import',
'slug' => 'one-click-demo-import',
'source' => '',
'required' => false,
'external_url' => 'http://proteusthemes.github.io/one-click-demo-import/',
'force_activation' => false,
)
);
$config = array(
'id' => 'somalite',
'default_path' => '',
'menu' => 'tgmpa-install-plugins',
'has_notices' => true,
'dismissable' => true,
'dismiss_msg' => '',
'is_automatic' => false,
'message' => '',
'strings' => array()
);
tgmpa( $plugins, $config );
}
endif;
add_action( 'tgmpa_register', 'somalite_register_required_plugins' );
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer/customizer.php';
/**
* Different Header Styles.
*/
require get_template_directory() . '/inc/header-functions.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Load Widgets
*/
require get_template_directory() . '/inc/widgets.php';
/**
* Load Woocommerce functions
*/
require get_template_directory() . '/inc/woocommerce-functions.php';
/**
* Upgrade Pro
*/
require_once( trailingslashit( get_template_directory() ) . 'soma-pro/class-customize.php' );