esc_html__( 'Primary', 'authorpreneur' ),
'footer' => esc_html__( 'Footer', 'authorpreneur' ),
) );
/*
* 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',
) );
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'authorpreneur_custom_background_args', array(
'default-color' => 'f5f9f8',
'default-image' => '',
) ) );
add_theme_support( 'custom-logo', array(
'height' => 80,
'width' => 200,
'flex-height' => true,
) );
}
endif;
add_action( 'after_setup_theme', 'authorpreneur_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 authorpreneur_content_width() {
$GLOBALS['content_width'] = apply_filters( 'authorpreneur_content_width', 640 );
}
add_action( 'after_setup_theme', 'authorpreneur_content_width', 0 );
function authorpreneur_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'authorpreneur' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Sidebar Post page', 'authorpreneur' ),
'id' => 'sidebar-single',
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
//Register widget areas for the Widgetized page template
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-templates/page_widgetized.php',
));
foreach($pages as $page){
register_sidebar( array(
'name' => esc_html__( 'Page - ', 'authorpreneur' ) . $page->post_title,
'id' => 'widget-area-' . strtolower($page->post_name),
'description' => esc_html__( 'Use this widget area to build content for the page: ', 'authorpreneur' ) . $page->post_title,
'before_widget' => '',
'before_title' => '',
) );
}
//Footer widget areas
$widget_areas = get_theme_mod('footer_widget_areas', '3');
for ($i=1; $i<=$widget_areas; $i++) {
register_sidebar( array(
'name' => __( 'Footer ', 'authorpreneur' ) . $i,
'id' => 'footer-' . $i,
'description' => '',
'before_widget' => '',
'before_title' => '',
) );
}
}
add_action( 'widgets_init', 'Authorpreneur_widgets_init' );
function authorpreneur_scripts() {
wp_enqueue_style( 'authorpreneur-style', get_stylesheet_uri() );
$body_font = get_theme_mod('body_font_name', '//fonts.googleapis.com/css?family=Open+Sans:300,300italic,600,600italic');
$headings_font = get_theme_mod('headings_font_name', '//fonts.googleapis.com/css?family=Josefin+Sans:300italic,300');
$remove = array("", "https:", "http:");
$body_url = str_replace($remove, '', $body_font);
$headings_url = str_replace($remove, '', $headings_font);
wp_enqueue_style( 'authorpreneur-body-fonts', esc_url($body_url) );
wp_enqueue_style( 'authorpreneur-headings-fonts', esc_url($headings_url) );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/fonts/font-awesome.min.css' );
wp_enqueue_script( 'authorpreneur-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '', true );
wp_enqueue_script( 'authorpreneur-owl', get_template_directory_uri() . '/js/owl.carousel.js', array('jquery'), '', true );
wp_enqueue_script( 'authorpreneur-matchHeight', get_template_directory_uri() . '/js/jquery.matchHeight-min.js', array('jquery'), '', true );
wp_enqueue_script( 'wow', get_template_directory_uri() . '/js/wow.js', array('jquery'), '', true );
wp_enqueue_script( 'authorpreneur-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( authorpreneur_blog_layout() == 'masonry-layout' && (is_home() || is_archive()) ) {
wp_enqueue_script( 'authorpreneur-masonry-init', get_template_directory_uri() . '/js/masonry-init.js', array('masonry'), '', true );
}
wp_enqueue_script( 'authorpreneur-html5shiv', get_template_directory_uri() . '/js/html5shiv.js', array(), '', true );
wp_script_add_data( 'authorpreneur-html5shiv', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'authorpreneur_scripts',20 );
/**
* Enqueue Bootstrap
*/
function authorpreneur_enqueue_bootstrap() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), true );
wp_enqueue_style( 'style_other', get_template_directory_uri() . '/css/style.css', array(), time() );
wp_enqueue_style( 'carousel', get_template_directory_uri() . '/css/owl.carousel.css', array(), true );
wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.min.css', array(), true );
}
add_action( 'wp_enqueue_scripts', 'authorpreneur_enqueue_bootstrap', 9 );
/**
* Customizer styles
*/
function authorpreneur_customizer_styles($hook) {
if ( ( 'customize.php' != $hook ) && ( 'widgets.php' != $hook ) ) {
return;
}
wp_enqueue_style( 'authorpreneur-customizer-styles', get_template_directory_uri() . '/inc/framework/css/customizer.css' );
}
add_action( 'admin_enqueue_scripts', 'authorpreneur_customizer_styles' );
/**
* Blog layout
*/
function authorpreneur_blog_layout() {
$layout = get_theme_mod('blog_layout','list');
return $layout;
}
/**
* Remove archives labels
*/
function authorpreneur_category_label($title) {
if ( is_category() ) {
$title = '' . single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = '' . single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '';
}
return $title;
}
add_filter('get_the_archive_title', 'authorpreneur_category_label');
/**
* Header image check
*/
function authorpreneur_has_header() {
$front_header = get_theme_mod('front_header_type' ,'image');
$site_header = get_theme_mod('site_header_type', 'nothing');
global $post;
if ( is_page() ) {
$single_toggle = get_post_meta( get_the_ID(), '_authorpreneur_single_header_shortcode', true );
} else {
$single_toggle = false;
}
if ($single_toggle != '') {
return 'has-single';
} else {
if ( get_header_image() && ( $front_header == 'image' && is_front_page() ) || ( $site_header == 'image' && !is_front_page() ) ) {
return 'has-header';
} elseif ( ($front_header == 'shortcode' && is_front_page()) || ($site_header == 'shortcode' && !is_front_page()) ) {
return 'has-shortcode';
} elseif ( ($front_header == 'video' && is_front_page()) || ($site_header == 'video' && !is_front_page()) ) {
return 'has-video';
}
}
}
/**
* Full width single posts
*/
function authorpreneur_fullwidth_singles($classes) {
if ( function_exists('is_woocommerce') ) {
$woocommerce = is_woocommerce();
} else {
$woocommerce = false;
}
$single_layout = get_theme_mod('fullwidth_single', 0);
if ( is_single() && !$woocommerce && $single_layout ) {
$classes[] = 'fullwidth-single';
}
return $classes;
}
add_filter('body_class', 'authorpreneur_fullwidth_singles');
/**
* Polylang compatibility
*/
if ( function_exists('pll_register_string') ) :
function authorpreneur_polylang() {
pll_register_string('Header text', get_theme_mod('header_text'), 'authorpreneur');
pll_register_string('Header subtext', get_theme_mod('header_subtext'), 'authorpreneur');
pll_register_string('Header button', get_theme_mod('header_button'), 'authorpreneur');
}
add_action( 'admin_init', 'authorpreneur_polylang' );
endif;
/**
* Header text
*/
function authorpreneur_header_text() {
if ( !function_exists('pll_register_string') ) {
$header_text = get_theme_mod('header_text');
$header_subtext = get_theme_mod('header_subtext');
$header_button = get_theme_mod('header_button');
} else {
$header_text = pll__(get_theme_mod('header_text'));
$header_subtext = pll__(get_theme_mod('header_subtext'));
$header_button = pll__(get_theme_mod('header_button'));
}
$header_button_url = get_theme_mod('header_button_url');
echo '';
}
/**
* Site branding
*/
if ( ! function_exists( 'authorpreneur_branding' ) ) :
function authorpreneur_branding() {
$site_logo = get_theme_mod('site_logo');
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
the_custom_logo();
} elseif ( $site_logo ) {
echo '
';
} else {
if ( is_front_page() && is_home() ) {
echo '';
} else {
echo '';
}
echo '' . esc_html(get_bloginfo( 'description' )) . '
';
}
}
endif;
/**
* Footer site branding
*/
if ( ! function_exists( 'authorpreneur_footer_branding' ) ) :
function authorpreneur_footer_branding() {
$footer_logo = get_theme_mod('footer_logo');
echo '';
}
endif;
/**
* Footer contact
*/
if ( ! function_exists( 'authorpreneur_footer_contact' ) ) :
function authorpreneur_footer_contact() {
$footer_contact_address = get_theme_mod('footer_contact_address');
$footer_contact_email = antispambot(get_theme_mod('footer_contact_email'));
$footer_contact_phone = get_theme_mod('footer_contact_phone');
echo '';
}
endif;
/**
* Clearfix posts
*/
function authorpreneur_clearfix_posts( $classes ) {
$classes[] = 'clearfix';
return $classes;
}
add_filter( 'post_class', 'authorpreneur_clearfix_posts' );
/**
* Excerpt length
*/
function authorpreneur_excerpt_length( $length ) {
$excerpt = get_theme_mod('exc_length', '40');
return absint($excerpt);
}
add_filter( 'excerpt_length', 'authorpreneur_excerpt_length', 99 );
function authorpreneur_remove_page_template() {
if ( !function_exists('authorpreneur_pro_load_widgets') ) {
global $pagenow;
if ( in_array( $pagenow, array( 'post-new.php', 'post.php') ) && get_post_type() == 'page' ) { ?>
theme_location == 'primary') {
if(is_woocommerce_activated()){
$items .='";
}
$items .= '
';
}else{
return $items;
}
return $items;
else:
return $items;
endif;
return $items;
}
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
function authorpreneur_search_form( $form ) {
$form = '';
return $form;
}
add_filter( 'get_search_form', 'authorpreneur_search_form' );
function authorpreneur_remove_sidebar(){
if( is_checkout() || is_cart() || is_product() ){
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
}
add_action('woocommerce_before_main_content', 'authorpreneur_remove_sidebar' );
add_filter( 'woocommerce_add_to_cart_fragments', 'authorpreneur_header_add_to_cart_fragment' );
function authorpreneur_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
cart->cart_contents_count, 'authorpreneur'), $woocommerce->cart->cart_contents_count);?>
'authorpreneur-columns-overlap',
'label' => esc_html__( 'Overlap', 'authorpreneur' ),
)
);
}
add_action( 'init', 'authorpreneur_block_styles' );
}
if ( function_exists( 'register_block_pattern' ) ) {
register_block_pattern(
'authorpreneur/large-text',
array(
'title' => esc_html__( 'Large text', 'authorpreneur' ),
'categories' => array( 'authorpreneur' ),
'viewportWidth' => 1440,
'content' => '' . esc_html__( 'A new portfolio default theme for WordPress', 'authorpreneur' ) . '
',
)
);
}
add_editor_style('editor-style.css');
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}
}