'Main Menu',
'footer' => 'Footer Menu'
));
/* ================================================================================== */
/* Theme Supports
/* ================================================================================== */
add_action('after_setup_theme', 'themewaves_setup');
if (!function_exists('themewaves_setup')) {
function themewaves_setup() {
add_editor_style();
add_theme_support('post-thumbnails');
add_theme_support( 'title-tag' );
add_theme_support('woocommerce');
add_theme_support('automatic-feed-links');
load_theme_textdomain('themewaves', THEME_PATH . '/languages/');
}
}
if (!isset($content_width))
$content_width = 960;
/* ================================================================================== */
/* Enqueue Scripts
/* ================================================================================== */
add_action('wp_enqueue_scripts', 'themewaves_scripts');
function themewaves_scripts() {
wp_enqueue_style('bootstrap', THEME_DIR . '/assets/css/bootstrap.min.css');
wp_enqueue_style('responsive', THEME_DIR . '/assets/css/bootstrap-responsive.min.css');
wp_enqueue_style('prettyphoto', THEME_DIR . '/assets/css/prettyPhoto.css');
wp_enqueue_style('animate', THEME_DIR . '/assets/css/animate-custom.css');
wp_enqueue_style('tw-fontawesome', THEME_DIR . '/assets/css/font-awesome/font-awesome.min.css');
if (woocommerce_enabled())
wp_enqueue_style('tw_woocommerce', THEME_DIR . '/woocommerce/tw_woocommerce.css');
wp_enqueue_style('mmenu', THEME_DIR . '/assets/css/mmenu.css');
wp_enqueue_style('themewaves', STYLESHEET_DIR . '/style.css');
wp_enqueue_style('tw-responsive', THEME_DIR . '/assets/css/responsive.css');
$protocol = is_ssl() ? 'https' : 'http';
global $tw_simplefonts;
$tw_googlefonts = array(
tw_option('body_text_font', 'face'),
tw_option('sidebar_widgets_title', 'face'),
tw_option('menu_font', 'face'),
tw_option('footer_widgets_title', 'face'),
tw_option('heading_font'),
);
$googlefont = '';
foreach ($tw_googlefonts as $font) {
if (!in_array($font, $tw_simplefonts)) {
$googlefont = str_replace(' ', '+', $font) . ':' . tw_option('google_font_weight') . '|' . $googlefont;
}
}
if ($googlefont != '')
wp_enqueue_style('google-font', "$protocol://fonts.googleapis.com/css?family=" . substr_replace($googlefont, "", -1) . "&subset=" . tw_option('google_font_subset'));
wp_enqueue_script('jquery');
if (is_single() && comments_open())
wp_enqueue_script('comment-reply');
wp_enqueue_script('scripts', THEME_DIR . '/assets/js/scripts.js', false, false, true);
wp_enqueue_script('mmenu', THEME_DIR . '/assets/js/jquery.mmenu.min.js', false, false, true);
wp_enqueue_script('themewaves', THEME_DIR . '/assets/js/themewaves.js', false, false, true);
if (woocommerce_enabled())
wp_enqueue_script('tw_woocommerce', THEME_DIR . '/woocommerce/tw_woocommerce.js', false, false, true);
if (tw_option('nicescroll'))
wp_enqueue_script('tw_scroll', THEME_DIR . '/assets/js/jquery.nicescroll.min.js', false, false, true);
if (tw_option('social_share')) {
if (tw_option('twitter_share'))
wp_enqueue_script('tw_share_twitter', $protocol . '://platform.twitter.com/widgets.js', '', '', true);
if (tw_option('googleplus_share'))
wp_enqueue_script('tw_share_google', $protocol . '://apis.google.com/js/plusone.js', '', '', true);
if (tw_option('linkedin_share'))
wp_enqueue_script('tw_share_linkedin', $protocol . '://platform.linkedin.com/in.js', '', '', true);
if (tw_option('pinterest_share'))
wp_enqueue_script('tw_share_pinterest', $protocol . '://assets.pinterest.com/js/pinit.js', '', '', true);
}
}
/* ================================================================================== */
/* Register Widget Sidebar
/* ================================================================================== */
if (!function_exists('theme_widgets_init')) {
function theme_widgets_init() {
register_sidebar(array(
'name' => 'Default sidebar',
'id' => 'default-sidebar',
'before_widget' => '
',
'before_title' => '
',
));
register_sidebar(array(
'name' => 'Top widget left',
'id' => 'top-widget-left',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '',
));
register_sidebar(array(
'name' => 'Top widget right',
'id' => 'top-widget-right',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '',
));
if (woocommerce_enabled()) {
register_sidebar(array(
'name' => 'Woocommerce shop page',
'id' => 'woocommerce-shop',
'before_widget' => '
',
'before_title' => '
',
));
register_sidebar(array(
'name' => 'Woocommerce product single',
'id' => 'woocommerce-single',
'before_widget' => '
',
'before_title' => '
',
));
}
/* footer sidebar */
$grid = tw_option('footer_layout') != "" ? tw_option('footer_layout') : '3-3-3-3';
$i = 1;
foreach (explode('-', $grid) as $g) {
register_sidebar(array(
'name' => __("Footer sidebar ", "themewaves") . $i,
'id' => "footer-sidebar-$i",
'description' => __('The footer sidebar widget area', 'themewaves'),
'before_widget' => '
',
'before_title' => '
',
));
$i++;
}
}
}
add_action('widgets_init', 'theme_widgets_init');
add_filter('widget_text', 'do_shortcode');
/* ================================================================================== */
/* Has more in post
/* ================================================================================== */
function has_more() {
global $post;
if (empty($post))
return;
return (bool) preg_match('//', $post->post_content);
}
/* ================================================================================== */
/* Exclude pages from search
/* ================================================================================== */
if (!function_exists('exclude_pages_from_search')) :
function exclude_pages_from_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'portfolio', 'page', 'product'));
}
return $query;
}
if(!is_admin())add_filter('pre_get_posts', 'exclude_pages_from_search');
endif;
/* ================================================================================== */
/* Support upload .ico file
/* ================================================================================== */
if (!function_exists('custom_upload_mimes')) {
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes($existing_mimes = array()) {
$existing_mimes['ico'] = "image/x-icon";
return $existing_mimes;
}
}
/* ================================================================================== */
/* ThemeWaves Search Form Customize
/* ================================================================================== */
function my_search_form() {
$form = '
';
return $form;
}
add_filter('get_search_form', 'my_search_form');
/* Wordpress Edit Gallery */
add_filter('use_default_gallery_style', '__return_false');
add_filter('wp_get_attachment_link', 'tw_pretty_gallery', 10, 5);
function tw_pretty_gallery($content, $id, $size, $permalink) {
if (!$permalink)
$content = preg_replace("/
ID)) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$image = isset($image[0]) ? $image[0] : '';
if (!$image) {
$image = tw_option("theme_logo");
};
if (is_single()) {
?>