ID, 'business_one_page_sidebar_layout', true );
if( $sidebar_layout == 'no-sidebar' )
$classes[] = 'full-width';
}
return $classes;
}
add_filter( 'body_class', 'business_one_page_body_classes' );
/**
* Callback function for Comment List *
*
* @link https://codex.wordpress.org/Function_Reference/wp_list_comments
*/
function business_one_page_theme_comment( $comment, $args, $depth ){
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
< id="comment-">
'post',
'post_status' => 'publish',
'posts_per_page'=> -1,
'post__in' => $slider_posts,
'orderby' => 'post__in',
'ignore_sticky_post' => true
) );
if( $qry->have_posts() ){?>
have_posts() ){
$qry->the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'business-one-page-slider' );
?>
-
$section,
'menu_text' => esc_attr( get_theme_mod( 'business_one_page_' . $section . '_section_menu_title','' ) ),
);
}
}
return $enabled_section;
}
/**
* Callback for Social Links
*/
function business_one_page_social_cb(){
$facebook = get_theme_mod( 'business_one_page_facebook' );
$twitter = get_theme_mod( 'business_one_page_twitter' );
$pinterest = get_theme_mod( 'business_one_page_pinterest' );
$linkedin = get_theme_mod( 'business_one_page_linkedin' );
$google_plus = get_theme_mod( 'business_one_page_google_plus' );
$instagram = get_theme_mod( 'business_one_page_instagram' );
$youtube = get_theme_mod( 'business_one_page_youtube' );
$ok = get_theme_mod( 'business_one_page_odnoklassniki' );
$vk = get_theme_mod( 'business_one_page_vk' );
$xing = get_theme_mod( 'business_one_page_xing' );
if( $facebook || $twitter || $pinterest || $linkedin || $google_plus || $ok || $vk || $xing ){ ?>
';
if( $twitter ) echo ' ';
if( $pinterest ) echo ' ';
if( $linkedin ) echo ' ';
if( $google_plus ) echo ' ';
if( $instagram ) echo ' ';
if( $youtube ) echo ' ';
if( $ok ) echo ' ';
if( $vk ) echo ' ';
if( $xing ) echo ' ';
?>
';
echo wp_strip_all_tags( $custom_css );
echo '';
}
}
add_action( 'wp_head', 'business_one_page_custom_css', 100 );
}
if ( ! function_exists( 'business_one_page_excerpt_more' ) ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... *
*/
function business_one_page_excerpt_more( $more ) {
return is_admin() ? $more : ' … ';
}
add_filter( 'excerpt_more', 'business_one_page_excerpt_more' );
endif;
if ( ! function_exists( 'business_one_page_excerpt_length' ) ) :
/**
* Changes the default 55 character in excerpt
*/
function business_one_page_excerpt_length( $length ) {
return is_admin() ? $length : 40;
}
add_filter( 'excerpt_length', 'business_one_page_excerpt_length' );
endif;
/**
* excerpt length for portfolio section
*/
function business_one_page_excerpt_length_alt( $length ){
return is_admin() ? $length : 12;
}
/**
* Footer Credits
*/
function business_one_page_footer_credit(){
$copyright_text = get_theme_mod( 'business_one_page_footer_copyright_text' );
$text = '';
if( $copyright_text ){
$text .= wp_kses_post( $copyright_text );
}else{
$text .= esc_html__( 'Copyright © ', 'business-one-page' ) . date_i18n( esc_html__( 'Y', 'business-one-page' ) );
$text .= ' ' . esc_html( get_bloginfo( 'name' ) ) . '. ';
}
if ( function_exists( 'the_privacy_policy_link' ) ) {
$text .= get_the_privacy_policy_link();
}
$text .= esc_html__( ' Business One Page | Developed By ', 'business-one-page' );
$text .= 'Rara Theme';
$text .= sprintf( esc_html__( ' Powered by: %s', 'business-one-page' ), 'WordPress' );
echo apply_filters( 'business_one_page_footer_text', $text );
}
add_action( 'business_one_page_footer', 'business_one_page_footer_credit' );
/**
* Return sidebar layouts for pages
*/
function business_one_page_sidebar_layout(){
global $post;
if( get_post_meta( $post->ID, 'business_one_page_sidebar_layout', true ) ){
return get_post_meta( $post->ID, 'business_one_page_sidebar_layout', true );
}else{
return 'right-sidebar';
}
}
/**
* Exclude post with Category from blog and archive page.
*/
function business_one_page_exclude_cat( $query ){
$cat = get_theme_mod( 'business_one_page_exclude_cat' );
$show_on_front = get_option( 'show_on_front' );
$ed_slider = get_theme_mod( 'business_one_page_ed_slider' );
$slider_post1 = get_theme_mod( 'business_one_page_slider_post_one' );
$slider_post2 = get_theme_mod( 'business_one_page_slider_post_two' );
$slider_post3 = get_theme_mod( 'business_one_page_slider_post_three' );
$slider_post4 = get_theme_mod( 'business_one_page_slider_post_four' );
$sliders = array( $slider_post1, $slider_post2, $slider_post3, $slider_post4 );
$sliders = array_diff( array_unique( $sliders ), array('') );
if( ! is_admin() && $query->is_main_query() ){
if( $cat ){
$cat = array_diff( array_unique( $cat ), array('') );
if( $query->is_home() || $query->is_archive() ) {
$query->set( 'category__not_in', $cat );
}
}
if( $sliders ){
if( $query->is_home() && $ed_slider && 'posts' == $show_on_front ){
$query->set( 'post__not_in', $sliders );
}
}
}
}
add_filter( 'pre_get_posts', 'business_one_page_exclude_cat' );
/**
* Exclude Categories from Category Widget
*/
function business_one_page_custom_category_widget( $arg ) {
$cat = get_theme_mod( 'business_one_page_exclude_cat' );
if( $cat ){
$cat = array_diff( array_unique( $cat ), array('') );
$arg["exclude"] = $cat;
}
return $arg;
}
add_filter( "widget_categories_args", "business_one_page_custom_category_widget" );
add_filter( "widget_categories_dropdown_args", "business_one_page_custom_category_widget" );
/**
* Exclude post from recent post widget of excluded catergory
*
* @link http://blog.grokdd.com/exclude-recent-posts-by-category/
*/
function business_one_page_exclude_posts_from_recentPostWidget_by_cat( $arg ){
$cat = get_theme_mod( 'business_one_page_exclude_cat' );
if( $cat ){
$cat = array_diff( array_unique( $cat ), array('') );
$arg["category__not_in"] = $cat;
}
return $arg;
}
add_filter( "widget_posts_args", "business_one_page_exclude_posts_from_recentPostWidget_by_cat" );
if( ! function_exists( 'business_one_page_single_post_schema' ) ) :
/**
* Single Post Schema
*
* @return string
*/
function business_one_page_single_post_schema() {
if ( is_singular( 'post' ) ) {
global $post;
$custom_logo_id = get_theme_mod( 'custom_logo' );
$site_logo = wp_get_attachment_image_src( $custom_logo_id , 'business-one-page-schema' );
$images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$excerpt = business_one_page_escape_text_tags( $post->post_excerpt );
$content = $excerpt === "" ? mb_substr( business_one_page_escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
$schema_type = ! empty( $custom_logo_id ) && has_post_thumbnail( $post->ID ) ? "BlogPosting" : "Blog";
$args = array(
"@context" => "http://schema.org",
"@type" => $schema_type,
"mainEntityOfPage" => array(
"@type" => "WebPage",
"@id" => esc_url( get_permalink( $post->ID ) )
),
"headline" => esc_html( get_the_title( $post->ID ) ),
"datePublished" => esc_html( get_the_time( DATE_ISO8601, $post->ID ) ),
"dateModified" => esc_html( get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ) ),
"author" => array(
"@type" => "Person",
"name" => business_one_page_escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
),
"description" => ( class_exists('WPSEO_Meta') ? WPSEO_Meta::get_value( 'metadesc' ) : $content )
);
if ( has_post_thumbnail( $post->ID ) ) :
$args['image'] = array(
"@type" => "ImageObject",
"url" => $images[0],
"width" => $images[1],
"height" => $images[2]
);
endif;
if ( ! empty( $custom_logo_id ) ) :
$args['publisher'] = array(
"@type" => "Organization",
"name" => esc_html( get_bloginfo( 'name' ) ),
"description" => wp_kses_post( get_bloginfo( 'description' ) ),
"logo" => array(
"@type" => "ImageObject",
"url" => $site_logo[0],
"width" => $site_logo[1],
"height" => $site_logo[2]
)
);
endif;
echo '';
}
}
endif;
add_action( 'wp_head', 'business_one_page_single_post_schema' );
if( ! function_exists( 'business_one_page_escape_text_tags' ) ) :
/**
* Remove new line tags from string
*
* @param $text
*
* @return string
*/
function business_one_page_escape_text_tags( $text ) {
return (string) str_replace( array( "\r", "\n" ), '', strip_tags( $text ) );
}
endif;
if( ! function_exists( 'business_one_page_change_comment_form_default_fields' ) ) :
/**
* Change Comment form default fields i.e. author, email & url.
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function business_one_page_change_comment_form_default_fields( $fields ){
// get the current commenter if available
$commenter = wp_get_current_commenter();
// core functionality
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$required = ( $req ? " required" : '' );
$author = ( $req ? __( 'Name*', 'business-one-page' ) : __( 'Name', 'business-one-page' ) );
$email = ( $req ? __( 'Email*', 'business-one-page' ) : __( 'Email', 'business-one-page' ) );
// Change just the author field
$fields['author'] = '';
$fields['email'] = '';
$fields['url'] = '';
return $fields;
}
endif;
add_filter( 'comment_form_default_fields', 'business_one_page_change_comment_form_default_fields' );
if( ! function_exists( 'business_one_page_change_comment_form_defaults' ) ) :
/**
* Change Comment Form defaults
* https://blog.josemcastaneda.com/2016/08/08/copy-paste-hurting-theme/
*/
function business_one_page_change_comment_form_defaults( $defaults ){
$defaults['comment_field'] = '';
return $defaults;
}
endif;
add_filter( 'comment_form_defaults', 'business_one_page_change_comment_form_defaults' );
if( ! function_exists( 'wp_body_open' ) ) :
/**
* Fire the wp_body_open action.
* Added for backwards compatibility to support pre 5.2.0 WordPress versions.
*/
function wp_body_open() {
/**
* Triggered after the opening tag.
*/
do_action( 'wp_body_open' );
}
endif;
if( ! function_exists( 'business_one_page_get_image_sizes' ) ) :
/**
* Get information about available image sizes
*/
function business_one_page_get_image_sizes( $size = '' ) {
global $_wp_additional_image_sizes;
$sizes = array();
$get_intermediate_image_sizes = get_intermediate_image_sizes();
// Create the full array with sizes and crop info
foreach( $get_intermediate_image_sizes as $_size ) {
if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
$sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
$sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
$sizes[ $_size ] = array(
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
'crop' => $_wp_additional_image_sizes[ $_size ]['crop']
);
}
}
// Get only 1 size if found
if ( $size ) {
if( isset( $sizes[ $size ] ) ) {
return $sizes[ $size ];
} else {
return false;
}
}
return $sizes;
}
endif;
if ( ! function_exists( 'business_one_page_get_fallback_svg' ) ) :
/**
* Get Fallback SVG
*/
function business_one_page_get_fallback_svg( $post_thumbnail ) {
if( ! $post_thumbnail ){
return;
}
$image_size = business_one_page_get_image_sizes( $post_thumbnail );
if( $image_size ){ ?>
urlencode( implode( '|', $font_families ) ),
'display' => urlencode( 'fallback' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return esc_url( $fonts_url );
}
endif;