__('Main Menu', 'beautymatters'),
'footer-menu' => __('Footer Menu', 'beautymatters'),
'header-menu' => __('Header Menu', 'beautymatters'),
'home-menu' => __('Home Menu', 'beautymatters'),
));
// Register Custom Navigation Walker
require_once ( get_template_directory() . '/framework/includes/menu-walker.php');
}
endif;
add_action('after_setup_theme', 'beautymatters_theme_setup');
/** adds asynch loading * */
function add_async_forscript($url) {
if (strpos($url, '#asyncload') === false)
return $url;
else if (is_admin())
return str_replace('#asyncload', '', $url);
else
return str_replace('#asyncload', '', $url) . "' async='async";
}
//add_filter('clean_url', 'add_async_forscript', 11, 1);
/**
* Define post thumbnail size.
* Add two additional image sizes.
*
*/
if (function_exists('add_image_size')) {
add_image_size('bootstrap-small', 260, 180); // 260 pixels wide by 180 pixels high
add_image_size('bootstrap-medium', 360, 268); // 360 pixels wide by 268 pixels high
}
/**
* Load JavaScript and jQuery files for theme.
*
*/
function default_scripts_loader() {
wp_enqueue_script('theme-js', get_template_directory_uri() . '/assets/js/custom.js', array('jquery'));
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/assets/libs/bootstrap/js/bootstrap.min.js', array('jquery'), '1.0', true);
wp_enqueue_script('wow-js', get_template_directory_uri() . '/assets/libs/wow/wow.min.js#asyncload', array('jquery'), '1.0', true);
/**
* lightbox
*/
wp_enqueue_script('lightbox-js', get_template_directory_uri() . '/assets/libs/lightbox2/js/lightbox.js#asyncload', array('jquery'), '1.0', true);
wp_register_style('bootstrap-lightbox', get_template_directory_uri() . "/assets/libs/lightbox2/css/lightbox.css#asyncload");
wp_enqueue_style('bootstrap-lightbox');
wp_register_style('bootstrap', get_template_directory_uri() . '/assets/libs/bootstrap/css/bootstrap.min.css', array(), '1.0', 'screen');
wp_enqueue_style('bootstrap');
}
add_action('wp_enqueue_scripts', 'default_scripts_loader');
/**
* Load JavaScript in Admin
*/
function bmatters_scripts_loader() {
wp_enqueue_script('beautymatters-admin', get_template_directory_uri() . '/assets/js/beautymatters-admin.js#asyncload', array('jquery'), '1.0', true);
}
add_action('admin_enqueue_scripts', 'bmatters_scripts_loader');
/**
* Define theme's widget areas.
*
*/
function bootstrapwp_widgets_init() {
register_sidebar(
array(
'name' => __('Landingpage Sidebar', 'beautymatters'),
'id' => 'sidebar-startpage',
'before_widget' => '",
'before_title' => '
',
)
);
register_sidebar(
array(
'name' => __('Archive Sidebar', 'beautymatters'),
'id' => 'sidebar-archive',
'before_widget' => '",
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __('Page Sidebar', 'beautymatters'),
'id' => 'sidebar-page',
'before_widget' => '",
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __('Post Sidebar', 'beautymatters'),
'id' => 'sidebar-post',
'before_widget' => '",
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __('Shop Sidebar', 'beautymatters'),
'id' => 'sidebar-shop',
'before_widget' => '",
'before_title' => '',
)
);
register_sidebar(
array(
'name' => __('Home Left', 'beautymatters'),
'id' => 'home-left',
'description' => __('Left textbox on homepage', 'beautymatters'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
)
);
register_sidebar(
array(
'name' => __('Home Middle', 'beautymatters'),
'id' => 'home-middle',
'description' => __('Middle textbox on homepage', 'beautymatters'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
)
);
register_sidebar(
array(
'name' => __('Home Right', 'beautymatters'),
'id' => 'home-right',
'description' => __('Right textbox on homepage', 'beautymatters'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
'
)
);
for ($i = 1; $i <= get_theme_mod("footer-default-layout", "4"); $i++) {
register_sidebar(
array(
'name' => sprintf(__('Footer Column %s', 'beautymatters'), $i),
'id' => 'footer-column-' . $i,
'description' => sprintf(__('Footer Column %s', 'beautymatters'), $i),
'before_widget' => '',
'before_title' => '',
'after_title' => '
'
)
);
}
//load customized sidebars
$customizer_sidebars = get_theme_mod('sidebar-name-box', '');
if ($customizer_sidebars != "") {
$customizer_sidebars_array = preg_split('/\r\n|[\r\n]/', $customizer_sidebars);
foreach ($customizer_sidebars_array as $c_sidebar) {
$c_parts = explode("=", $c_sidebar);
if (count($c_parts) == 2) {
// validates if syntax is really name=id
register_sidebar(
array(
'name' => $c_parts[0],
'id' => $c_parts[1],
'description' => sprintf(__('Customizer dynamic Sidebar %s', 'beautymatters'), $c_parts[0]),
'before_widget' => '",
'before_title' => '',
)
);
}
}
}
}
// header widget sidebar
add_action('init', 'bootstrapwp_widgets_init');
/* Replaces the excerpt "more" text by a link */
function new_excerpt_more($more) {
return ' ... ' . __('Read More', 'beautymatters') . '';
//return '';
}
add_filter('excerpt_more', 'new_excerpt_more');
/**
* adds span to widget title
*/
add_filter('widget_title', 'my_title');
function my_title($title) {
if (isset($title) && !empty($title))
return "$title";
}
/* prevent scrolling when using more-tag */
function remove_more_link_scroll($link) {
$link = preg_replace('|#more-[0-9]+|', '', $link);
return $link;
}
add_filter('the_content_more_link', 'remove_more_link_scroll');
/**
* Display template for post meta information.
*
*/
if (!function_exists('bootstrapwp_posted_on')) :
function bootstrapwp_posted_on() {
printf(__('Posted on by %7$s', 'beautymatters'), esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'beautymatters'), get_the_author())), esc_html(get_the_author())
);
}
endif;
/**
*
* Returns the Tags List (Bootstrap compatible)
*/
function bbwsp_get_tags() {
$posttags = get_the_tags();
if ($posttags) {
echo 'Tags: ';
foreach ($posttags as $tag) {
echo '' . $tag->name . ' ';
}
}
}
/**
* Comment Template Form
*
*/
add_filter('comment_form_default_fields', 'bootstrap3_comment_form_fields');
function bootstrap3_comment_form_fields($fields) {
$commenter = wp_get_current_commenter();
$req = get_option('require_name_email');
$aria_req = ( $req ? " aria-required='true'" : '' );
$html5 = current_theme_supports('html5', 'comment-form') ? 1 : 0;
$fields = array(
'author' => '',
'email' => '',
'url' => ''
);
return $fields;
}
add_filter('comment_form_defaults', 'bootstrap3_comment_form');
function bootstrap3_comment_form($args) {
$args['comment_field'] = '';
$args['class_submit'] = 'btn btn-default'; // since WP 4.1
return $args;
}
/**
* Define default page titles.
*
*/
function bootstrapwp_wp_title($title, $sep) {
global $paged, $page;
if (is_feed()) {
return $title;
}
// Add the site name.
$title .= get_bloginfo('name');
// Add the site description for the home/front page.
$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_home() || is_front_page())) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ($paged >= 2 || $page >= 2) {
$title = "$title $sep " . sprintf(__('Page %s', 'beautymatters'), max($paged, $page));
}
return $title;
}
add_filter('wp_title', 'bootstrapwp_wp_title', 10, 2);
function my_remove_rel_attr($content) {
return preg_replace('/\s+rel="attachment wp-att-[0-9]+"/i', '', $content);
}
add_filter('the_content', 'my_remove_rel_attr');
/**
* hook to recommend plugins
*/
add_action('tgmpa_register', 'bmatters_register_required_plugins');
function bmatters_register_required_plugins() {
$plugins = array(
array(
'name' => 'Instagram Feed',
'slug' => 'instagram-feed',
),
array(
'name' => 'Recent Posts Extended',
'slug' => 'recent-posts-widget-extended'
)
, array(
'name' => 'Contact Form 7',
'slug' => 'contact-form-7'
), array(
'name' => 'WooCommerce',
'slug' => 'woocommerce'
), array(
'name' => 'WooCommerce Twitter\'s Bootstrap',
'slug' => 'woocommerce-twitterbootstrap'
), array(
'name' => 'Easy Bootstrap Shortcode',
'slug' => 'easy-bootstrap-shortcodes'
), array(
'name' => 'Simple Amazon',
'slug' => 'simple-amazon',
'source' => get_stylesheet_directory() . '/framework/lib/plugins/simple-amazon.zip',
'required' => false,
), array(
'name' => 'Very simple Slider',
'slug' => 'very-simple-slider',
// 'source' => get_stylesheet_directory() . '/framework/lib/plugins/very-simple-slider.zip',
'required' => true,
), array(
'name' => 'Simple Facebook',
'slug' => 'simple-facebook',
'source' => get_stylesheet_directory() . '/framework/lib/plugins/simple-facebook.zip',
'required' => false,
), array(
'name' => 'Simple Team',
'slug' => 'simple-team',
'source' => get_stylesheet_directory() . '/framework/lib/plugins/simple-team.zip',
'required' => true,
), array(
'name' => 'Super Simple Google Maps',
'slug' => 'simplesuper-simple-gmaps',
'source' => get_stylesheet_directory() . '/framework/lib/plugins/super-simple-gmaps.zip',
'required' => true,
)
);
$config = array(
'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => true, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa($plugins, $config);
}
/** adds to category count * */
add_filter('wp_list_categories', 'add_span_cat_count');
function add_span_cat_count($links) {
$links = str_replace(' (', ' ', $links);
$links = str_replace(')', '', $links);
return $links;
}
/** hooks css from custmizer and insert it * */
function customizer_insert_custom_css() {
$default_font = get_theme_mod("design-font-default");
$design_font_header_title = get_theme_mod("design-font-header-title");
$color_header_background = get_theme_mod("color-header-background");
$color_top_header_background = get_theme_mod("color-top-header-background");
$color_top_header_text = get_theme_mod("color-top-header-text");
$color_footer_background = get_theme_mod("color-footer-background");
$color_footer_copyright_background = get_theme_mod("color-footer-copyright-background");
$color_content_background = get_theme_mod("color-content-background");
$color_widget_background = get_theme_mod("color-widget-background");
$color_content_text = get_theme_mod("color-content-text");
$color_widget_text = get_theme_mod("color-widget-text");
$css_custom_textarea = get_theme_mod("css-custom-textarea");
$layout_header_navbar_position = get_theme_mod("layout-header-navbar-position");
$fontUtil = new BeautyMatters_Font_Utils();
if ($fontUtil->is_google_font($default_font)) {
$fontUtil->add_google_font_queue($default_font);
}
if ($fontUtil->is_google_font($design_font_header_title)) {
$fontUtil->add_google_font_queue($design_font_header_title);
}
if ($fontUtil->get_google_font_queue_parsed() != "") {
//load the google fonts
echo "";
}
?>