%2$s',
esc_url( get_the_permalink() ),
esc_html( bizsmart_get( 'read-more-text' ) )
);
}else{
$more = '';
}
return $more;
}
/**
* Adds prefix to the classes
*
* @static
* @access public
* @since 1.0.0
* @return string
*
* @package BizSmart WordPress Theme
*/
public static function get_class( $cls ){
if( is_array( $cls ) ){
foreach ($cls as $class) {
$prefix_cls[] = self::get_prefix() . '-' . $class;
}
return implode( ' ', $prefix_cls );
}else{
return self::get_prefix() . '-' . $cls;
}
}
/**
* Get the comment number of post
*
* @since 1.0.0
* @return void
*
* @package BizSmart WordPress Theme
*/
public static function get_comment_number(){
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '';
}
}
/**
* Setup Theme
*
* @static
* @access public
* @since 1.0.0
* @return void
*
* @package BizSmart WordPress Theme
*/
public static function setup(){
# header options
add_theme_support( 'custom-header', apply_filters( self::fn_prefix( 'custom_header_args' ) , array(
'default-text-color' => '000000',
'width' => 1366,
'height' => 400,
'flex-height' => true,
'wp-head-callback' => array( __CLASS__, 'header_style' ),
'default-image' => get_template_directory_uri(). '/assets/img/default-banner.jpg'
)));
}
/**
* Enqueue styles and scripts on admin end
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function admin_scripts(){
$scripts = array(
array(
'handler' => self::with_prefix( 'admin-css' ),
'style' => 'assets/css/admin.css',
'minified' => false
),
);
self::enqueue( $scripts );
}
/**
* Add custom header
*
* @static
* @access public
* @since 1.0.0
* @return void
*
* @package BizSmart WordPress Theme
*/
public static function header_style(){
$header_text_color = get_header_textcolor();
/*
* If no custom options for text are set, let's bail.
* get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
*/
if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
return;
}
$style = array();
if ( ! display_header_text() ){
$style[] = array(
'selector' => '.site-title, .site-description',
'props' => array(
'position' => array(
'value' => 'absolute',
'unit' => ''
),
'clip' => array(
'value' => 'rect(1px, 1px, 1px, 1px)',
'unit' => ''
)
)
);
}else{
$style[] = array(
'selector' => '.site-branding .site-title a, .site-branding .site-description',
'props' => array(
'color' => array(
'value' => '#' . esc_attr( $header_text_color ),
'unit' => ''
),
)
);
}
BizSmart_Css::add_styles( $style );
}
/**
* get post meta by Post ID
*
* @link https://developer.wordpress.org/reference/functions/get_post_meta/
* @return string || integer || array
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_meta( $meta_key = false, $post_id = null, $single = true ){
if( $meta_key ){
$meta_key = self::with_prefix( $meta_key );
if( self::is_static_blog_page() ){
$post_id = get_option( 'page_for_posts' );
}elseif( self::is_active_plugin( 'woocommerce' ) && is_shop() ){
$post_id = get_option( 'woocommerce_shop_page_id' );
}else{
$post_id = $post_id ? $post_id : get_the_ID();
}
return get_post_meta( $post_id, $meta_key, $single );
}
}
/**
* Get uri of given file
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_theme_uri( $file ){
return get_theme_file_uri( $file );
}
/**
* Get path of given file
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_theme_path( $file ){
return get_theme_file_path( $file );
}
/**
* Adds schema tags to the body classes.
*
* @static
* @access public
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function schema_body( $type ) {
switch ($type) {
case 'body' :
# Check conditions.
$is_blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
# Set up default itemtype.
$itemtype = 'WebPage';
# Get itemtype for the blog.
$itemtype = ( $is_blog ) ? 'Blog' : $itemtype;
# Get itemtype for search results.
$itemtype = ( is_search() ) ? 'SearchResultsPage' : $itemtype;
# Get the result.
$result = apply_filters( self::fn_prefix( 'schema_body_itemtype' ), $itemtype );
# Return our HTML.
echo apply_filters( self::fn_prefix( 'schema_body' ), "itemtype='https://schema.org/" . esc_attr( $result ) . "' itemscope='itemscope' " );
break;
case 'header' :
echo apply_filters( self::fn_prefix( 'schema_header' ), "itemtype='https://schema.org/WPHeader' itemscope='itemscope' role='banner' " );
break;
case 'footer' :
echo apply_filters( self::fn_prefix( 'schema_footer' ), "itemtype='https://schema.org/WPFooter' itemscope='itemscope' role='contentinfo'" );
break;
case 'article':
echo apply_filters( self::fn_prefix( 'schema_article' ), "itemtype='https://schema.org/CreativeWork' itemscope='itemscope'" );
break;
default :
}
}
/**
* Include given files
*
* @static
* @access public
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function include( $name, $dir="classes", $prefix="class" ){
$prefix = empty( $prefix ) ? '' : $prefix . '-';
$path = self::get_theme_path( '/' . $dir . '/' . $prefix );
if( is_array( $name ) ){
foreach( $name as $file ){
require_once $path . $file . '.php';
}
}else{
require_once $path . $name . '.php';
}
}
/**
* Enqueue scripts or styles
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function enqueue( $scripts ){
# Do not enqueue anything if no array is supplied.
if( ! is_array( $scripts ) ) return;
$scripts = apply_filters( self::fn_prefix( 'block_scripts' ) , $scripts );
foreach ( $scripts as $script ) {
# Do not try to enqueue anything if handler is not supplied.
if( ! isset( $script[ 'handler' ] ) )
continue;
$version = null;
if( isset( $script[ 'version' ] ) ){
$version = $script[ 'version' ];
}
$minified = isset( $script[ 'minified' ] ) ? $script[ 'minified' ] : true;
# Enqueue each vendor's style
if( isset( $script[ 'style' ] ) ){
$path = isset( $script[ 'absolute' ] ) ? $script[ 'style' ] : self::get_theme_uri( $script[ 'style' ] );
$dependency = array();
if( isset( $script[ 'dependency' ] ) ){
$dependency = $script[ 'dependency' ];
}
wp_enqueue_style( $script[ 'handler' ], $path, $dependency, $version );
}
# Enqueue each vendor's script
if( isset( $script[ 'script' ] ) ){
if( $script[ 'script' ] === true || $script[ 'script' ] === 1 ){
wp_enqueue_script( $script[ 'handler' ] );
}else{
$prefix = '';
if( isset( $script[ 'prefix' ] ) ){
$prefix = $script[ 'prefix' ];
}
$path = '';
if( isset( $script[ 'script' ] ) ){
$path = self::get_theme_uri( $script[ 'script' ] );
}
if( isset( $script[ 'absolute' ] ) ){
$path = $script[ 'script' ];
}
$dependency = array( 'jquery' );
if( isset( $script[ 'dependency' ] ) ){
$dependency = $script[ 'dependency' ];
}
$in_footer = true;
if( isset( $script[ 'in_footer' ] ) ){
$in_footer = $script[ 'in_footer' ];
}
wp_enqueue_script( $prefix . $script[ 'handler' ], $path, $dependency, $version, $in_footer );
if( isset( $script['localize'] ) && count( $script['localize'] ) > 0 ) {
wp_localize_script($prefix . $script[ 'handler' ] , $script['localize']['key'] , $script['localize']['data'] );
}
}
}
}
}
/**
* Get assets version (development || production)
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_assets_version(){
return bizsmart_get( 'assets-version' );
}
/**
* Creats slug of the text
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function uglify( $text, $condition = array() ){
$defaults = array(
'lowercase' => true,
'separator' => '-',
);
# Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $condition, $defaults );
$text = str_replace ( ' ', $args[ 'separator' ] , $text );
if( $args[ 'lowercase' ] ){
$text = strtolower( $text );
}
return $text;
}
/**
* Returns wp nav
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_menu( $location = 'primary', $echo = false ){
$menu = null;
switch( $location ){
case 'primary':
$menu = wp_nav_menu( array(
'menu_id' => 'primary-menu',
'theme_location' => $location,
'echo' => $echo,
'container' => false,
'menu_class' => 'navigation clearfix'
));
break;
case 'social-menu-footer':
$menu = wp_nav_menu( array(
'menu_id' => 'social-menu-footer',
'theme_location' => $location,
'fallback_cb' => false,
'echo' => $echo,
'container' => false,
'menu_class' => 'menu',
'link_before' => '',
'link_after' => '',
'depth' => 1
));
break;
case 'footer-menu':
$menu = wp_nav_menu( array(
'menu_id' => 'footer-menu',
'theme_location' => $location,
'fallback_cb' => false,
'echo' => $echo,
'container' => false,
'menu_class' => 'navigation clearfix',
'depth' => 1
));
break;
}
if( ! $echo ){
return $menu;
}
}
/**
* The post Navigation
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function posts_navigation( $echo = true ) {
$infinity_module_active = false;
if( get_option( 'jetpack_active_modules' ) ){
if( in_array( 'infinite-scroll', get_option( 'jetpack_active_modules' ) ) ){
$infinity_module_active = true;
}
}
# Previous/next page navigation.
if( !$infinity_module_active || !BizSmart_Helper::is_active_plugin( 'jetpack' ) ){
the_posts_pagination(
array(
'mid_size' => 2,
'prev_text' => esc_html__( 'Previous', 'bizsmart' ),
'next_text' => esc_html__( 'Next', 'bizsmart' ),
)
);
}
}
/**
* Pagination for the content seperated by page break.
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function post_content_navigation(){
wp_link_pages( array(
'before' => '' . esc_html__( 'Pages:', 'bizsmart' ),
'after' => '
',
'link_before' => '',
'link_after' => ''
) );
}
/**
* Pagination for single post in single page
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function single_post_navigation(){
the_post_navigation( array(
'prev_text' => '' . esc_html__( 'Previous Post', 'bizsmart' ) . '%title',
'next_text' => '' . esc_html__( 'Next Post', 'bizsmart' ) . '%title',
));
}
/**
* Displays an optional post thumbnail.
*
* Wraps the post thumbnail in an anchor element on index views, or a div
* element when on single views.
*
* @static
* @access public
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function post_thumbnail( $size = 'post-thumbnail' ) {
if ( has_post_thumbnail() ) { ?>
',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( get_avatar_url( $author_id, array( 'size'=> 40 ) ) )
);
}
}
/**
* Prints HTML with meta information about theme author.
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function posted_by(){
if( apply_filters( self::fn_prefix( 'show_post_author' ), true ) ):
printf(
/* translators:1-author link, 2-author image link,
* 3- author text, 4- author name.
*/
'
%2$s
%3$s
',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html__( 'By ', 'bizsmart' ),
esc_html( get_the_author() )
);
endif;
}
/**
* Prints HTML with meta information for the current post-date/time.
*
* @static
* @access public
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function the_date( $status = 'posted' ) {
$show = apply_filters( self::fn_prefix( 'show_post_date' ), true );
if( $show ):
$time_string = '';
if( $status == 'updated'){
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
}
$time_tag = sprintf(
$time_string,
esc_attr( get_the_date( DATE_W3C ) ),
esc_html( get_the_date( get_option('date_format') ) ),
esc_attr( get_the_modified_date( DATE_W3C ) ),
esc_html( get_the_modified_date() )
);
printf(
'
%2$s
%3$s
',
esc_url( self::get_day_link() ),
( 'posted' == $status ) ? esc_html__( 'On', 'bizsmart' ) : esc_html__( 'Updated on', 'bizsmart' ),
$time_tag
);
endif;
}
/**
* Prints the category of the posts
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function the_category(){
$show = apply_filters( self::fn_prefix( 'show_post_category' ), true );
if( $show ){
the_category();
}
}
/**
* edit link on post if user is logged in
*
* @return void
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function edit_link(){
edit_post_link(
sprintf(
'%1$s%2$s',
esc_html__( 'Edit', 'bizsmart' ),
get_the_title()
),
'',
''
);
}
/**
* modify category if SEO plugin is active
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function modify_catgories( $categories ){
# Check if Yoast Plugin is installed
# If yes then, get Primary category, set by Plugin
if ( self::is_active_plugin( 'yoast' ) ){
# Show the post's 'Primary' category, if this Yoast feature is available, & one is set
$wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_ID() );
$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
$cat[0] = get_term( $wpseo_primary_term );
if ( !is_wp_error( $cat[0] ) ) {
return $cat;
}
}
return $categories;
}
/**
* Get active class of the menu.
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_nav_active_class ( $classes ) {
if ( in_array( 'current-menu-item', $classes ) ){
$classes[] = 'active';
}
return $classes;
}
/**
* Add action to display breadcrumb.
*
* @static
* @access public
* @return void
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function the_breadcrumb(){
// Bail if Breadcrumb disabled
if( apply_filters( self::fn_prefix( 'show_breadcrumb' ), true ) ):
$breadcrumb_args = array(
'container' => 'div',
'show_browse' => false,
);
$classes = apply_filters( self::fn_prefix( 'breadcrumb_classes' ), array( 'wrapper', 'wrap-breadcrumb' ) );
$classes = array_unique( $classes );
$classes = join( ' ', $classes );
?>
%2$s %3$s',
esc_html__( 'Tags:', 'bizsmart' ),
esc_html( $tags_list )
); // WPCS: XSS OK.
}
}
/**
* Replace dash by space
*
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function beautify( $string ){
return ucwords( str_replace( '-', ' ', $string ) );
}
/**
* Check the plugin is active or not
*
* @static
* @access public
* @return boolean
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function is_active_plugin( $plugin_name ){
switch( $plugin_name ){
case 'woocommerce':
return class_exists( 'WooCommerce' );
break;
case 'yoast':
return class_exists( 'WPSEO_Primary_Term' );
break;
case 'jetpack':
return class_exists( 'Jetpack' );
break;
}
return false;
}
/**
* Get body font family.
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_font( $value ){
$fonts = self::get_font_family();
return $fonts[ $value ];
}
/**
* Font family used in BizSmart Theme
*
* @static
* @access public
* @return object
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_font_family( ){
return apply_filters( self::fn_prefix( 'standard_fonts_array' ), array(
'font-1' => esc_html__( 'Lato', 'bizsmart' ),
'font-2' => esc_html__( 'Oswald', 'bizsmart' ),
'font-3' => esc_html__( 'Montserrat', 'bizsmart' ),
'font-4' => esc_html__( 'Roboto', 'bizsmart' ),
'font-5' => esc_html__( 'Raleway', 'bizsmart' ),
'font-6' => esc_html__( 'Playfair Display', 'bizsmart' ),
'font-7' => esc_html__( 'Fjalla One', 'bizsmart' ),
'font-8' => esc_html__( 'Alegreya Sans', 'bizsmart' ),
'font-9' => esc_html__( 'PT Sans Narrow', 'bizsmart' ),
'font-10' => esc_html__( 'Open Sans', 'bizsmart' ),
'font-11' => esc_html__( 'Poppins', 'bizsmart' ),
));
}
/**
* Google font url
*
* @static
* @access public
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_google_font(){
$google_fonts = array();
$condition = array(
'lowercase' => false,
'separator' => '+',
);
$google_fonts[] = self::uglify( self::get_font( bizsmart_get( 'body-font' ) ), $condition );
$google_fonts[] = self::uglify( self::get_font( bizsmart_get( 'heading-font' ) ), $condition );
$google_fonts[] = self::uglify( self::get_font( bizsmart_get( 'site-info-font' ) ), $condition );
$fonts = array_unique( $google_fonts );
$fonts_weight = apply_filters( self::fn_prefix( 'standard_fonts_weight' ), array(
'Montserrat' => array( '100', '200', '300' ),
'Lato' => array( '100', '200', '300', '500' ),
'Open+Sans' => array( '100', '200', '300', '400' ),
'Poppins' => array( '400', '500', '600', '700', '800' )
));
foreach ( $fonts as $value ) {
if( isset( $fonts_weight[ $value ] ) ){
$font_wt[] = $value.':'.implode( ',', $fonts_weight[ $value ] );
}else{
$font_wt[] = $value;
}
}
if( $font_wt ){
$fonts_url = add_query_arg(
array(
'family' => implode( '|', $font_wt ),
), '//fonts.googleapis.com/css'
);
}
return $fonts_url;
}
/**
* Get the title
*
* @return string
* @since 1.0.0
*
* @package BizSmart WordPress Theme
*/
public static function get_title( $link = true ){ ?>