5 ) ); break; default: break; } } endif; add_action( 'business_center_pro_pagination', 'business_center_pro_pagination', 10 ); if ( ! function_exists( 'business_center_pro_post_pagination' ) ) : /** * post pagination. * * @since Business Center Pro 2.0.0 */ function business_center_pro_post_pagination() { the_post_navigation(); } endif; add_action( 'business_center_pro_action_post_pagination', 'business_center_pro_post_pagination', 10 ); /** * long excerpt * * @since Business Center Pro 2.0.0 * @return long excerpt value */ function business_center_pro_excerpt_length( $length ){ if( is_admin() ) { return $length; } $options = business_center_pro_get_theme_options(); $length = $options['excerpt_length']; return (int)$length; } add_filter( 'excerpt_length', 'business_center_pro_excerpt_length', 999 ); /** * Excerpt read more text * * @since Business Center Pro 2.0.0 * @return string Excerpt read more string */ function business_center_pro_excerpt_more( $more ){ $options = business_center_pro_get_theme_options(); $more = $options['read_more_text']; return '... ' . esc_html( $more ) . ''; } add_filter( 'excerpt_more', 'business_center_pro_excerpt_more' ); /** * custom excerpt function * * @since Business Center Pro 2.0.0 * @return no of words to display */ function business_center_pro_trim_content( $length = 40, $post_obj = null ) { global $post; if ( is_null( $post_obj ) ) { $post_obj = $post; } $length = absint( $length ); if ( $length < 1 ) { $length = 40; } $source_content = $post_obj->post_content; if ( ! empty( $post_obj->post_excerpt ) ) { $source_content = $post_obj->post_excerpt; } $source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content ); $trimmed_content = wp_trim_words( $source_content, $length, '...' ); return apply_filters( 'business_center_pro_trim_content', $trimmed_content ); } if ( ! function_exists( 'business_center_pro_is_jetpack_cpt_module_enable' ) ) : /** * Check if JetPack module is enabled * * @since Business Center Pro 2.0.0 * * @param string $jetpack_cpt_option Jetpack enable checkbox value */ function business_center_pro_is_jetpack_cpt_module_enable( $jetpack_cpt_option ) { if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'custom-content-types' ) && get_option( $jetpack_cpt_option ) ) : return true; endif; return false; } endif; add_action( 'plugins_loaded', 'business_center_pro_is_jetpack_cpt_module_enable' ); add_filter( 'business_center_pro_filter_is_jetpack_cpt_module_enable', 'business_center_pro_is_jetpack_cpt_module_enable' ); if ( ! function_exists( 'business_center_pro_footer_sidebar_class' ) ) : /** * Count the number of footer sidebars to enable dynamic classes for the footer * * @since Business Center Pro 2.0.0 */ function business_center_pro_footer_sidebar_class() { $data = array(); $active_id = array(); $count = 0; if ( is_active_sidebar( 'footer-1' ) ) { $active_id[] = '1'; $count++; } if ( is_active_sidebar( 'footer-2' ) ){ $active_id[] = '2'; $count++; } if ( is_active_sidebar( 'footer-3' ) ){ $active_id[] = '3'; $count++; } $class = ''; switch ( $count ) { case '1': $class = 'one'; break; case '2': $class = 'two'; break; case '3': $class = 'three'; break; default: $class = 'one'; break; } $data['active_id'] = $active_id; $data['class'] = $class; return $data; } endif; if ( ! function_exists( 'business_center_pro_custom_content_width' ) ) : /** * Custom content width. * * @since 1.0 */ function business_center_pro_custom_content_width() { global $content_width; $sidebar_position = business_center_pro_layout(); switch ( $sidebar_position ) { case 'no-sidebar': $content_width = 1170; break; case 'right-sidebar': $content_width = 819; break; default: break; } if ( ! is_active_sidebar( 'sidebar-1' ) ) { $content_width = 1170; } } endif; add_action( 'template_redirect', 'business_center_pro_custom_content_width' ); if ( ! function_exists( 'business_center_pro_layout' ) ) : /** * Check home page layout option * * @since Business Center Pro 2.0.0 * * @return string Layout value */ function business_center_pro_layout() { $options = business_center_pro_get_theme_options(); $sidebar_position = $options['sidebar_position']; $sidebar_position = apply_filters( 'business_center_pro_sidebar_position', $sidebar_position ); // Check if single and static blog page if ( is_singular() || is_home() ) { if ( is_home() ) { $post_sidebar_position = get_post_meta( get_option( 'page_for_posts' ), 'business-center-pro-sidebar-position', true ); } else { $post_sidebar_position = get_post_meta( get_the_ID(), 'business-center-pro-sidebar-position', true ); } if ( isset( $post_sidebar_position ) && ! empty( $post_sidebar_position ) ) { $sidebar_position = $post_sidebar_position; } } return $sidebar_position; } endif; if ( ! function_exists( 'business_center_pro_title_as_per_template' ) ) : /** * Return title as per template rendered * * @since Business Center Pro 1.0.0 * * @return string Template title */ function business_center_pro_title_as_per_template() { if ( is_single() ) { $categories_list = get_the_category_list( esc_html__( ', ', 'business-center-pro' ) ); if ( $categories_list && business_center_pro_categorized_blog() ) { printf( '

%s

', $categories_list ); // WPCS: XSS OK. } } elseif ( is_archive() ) { echo '

'.esc_html__( 'Archive', 'business-center-pro' ).'

'; } if ( is_singular() ) { the_title( '

', '

' ); } elseif ( is_archive() ) { the_archive_title( '

', '

' ); } elseif( is_404() ) { echo '

' . esc_html__( '404 Page', 'business-center-pro' ) . '

'; } elseif( is_search() ){ echo '

' . esc_html__( 'Search Page', 'business-center-pro' ) . '

'; } elseif ( is_home() ) { echo '

' . esc_html__( 'Blog Page', 'business-center-pro' ) . '

'; } } endif; if ( ! function_exists( 'business_center_pro_column_number' ) ) : /** * Return column string number as per the column number * * @since Business Center Pro 1.0.0 * * @return string Column number */ function business_center_pro_column_number( $column_number = 4 ) { if ( $column_number == 1 ) { return 'one'; } elseif ( $column_number == 2 ) { return 'two'; } elseif( $column_number == 3 ) { return 'three'; } elseif($column_number == 4 ){ return 'four'; } } endif; if ( ! function_exists( 'business_center_pro_blog_layout' ) ) : /** * Return column number on the basis of value from customizer * * @since Business Center Pro 1.0.0 * * @return string Column number */ function business_center_pro_blog_layout() { $options = business_center_pro_get_theme_options(); if ( isset( $options['blog_layout'] ) ) { return $options['blog_layout']; } else { return "three"; } } endif; if ( ! function_exists( 'business_center_pro_portfolio_ajax_handler' ) ) : /** * ajax handler * * @since Business Center Pro 1.0 */ function business_center_pro_portfolio_ajax_handler(){ $portfolio_ids = ( isset( $_POST['category'] ) ) ? $_POST['category'] : array(); $page = ( isset( $_POST['pageNumber'] ) ) ? $_POST['pageNumber'] : 1; header("Content-Type: text/html"); $portfolio_args = array( 'post_type' => 'post', 'posts_per_page' => absint( get_option( 'posts_per_page', 7 ) ), 'category__in' => $portfolio_ids, 'paged' => $page, ); $portfolio_posts = get_posts( $portfolio_args ); if( !empty( $portfolio_posts ) ) : $index = 1; foreach ( $portfolio_posts as $key => $portfolio_post ) { if( ( $index % 7 == 3 ) || ( $index % 7 == 0 ) ) { $item = 2; } else{ $item = 1; } $portfolio_post_id = $portfolio_post->ID; if ( has_post_thumbnail( $portfolio_post_id ) ) { $featured_img = wp_get_attachment_image_src( get_post_thumbnail_id( $portfolio_post->ID ), 'large' ); $img_array = $featured_img[0]; } else { $img_array = get_template_directory_uri() . '/assets/uploads/no-featured-image-1300x600.jpg'; } if ( isset( $img_array ) ) { $post_image['img_array'][0] = $img_array; } $post_title = get_the_title( $portfolio_post_id ); $post_url = get_the_permalink( $portfolio_post_id ); $post_categories = get_the_category( $portfolio_post_id ); $post_category_list = ''; $post_category_name = ''; foreach ( $post_categories as $key => $post_category ) { $post_category_name .= $post_category->name . ' '; $post_category_list .= $post_category->slug . ' '; } ?>
post_content; if ( ! empty( $post_obj->post_excerpt ) ) { $source_content = $post_obj->post_excerpt; } $source_content = preg_replace( '`\[[^\]]*\]`', '', $source_content ); $trimmed_content = wp_trim_words( $source_content, $length, '...' ); return apply_filters( 'business_center_pro_trim_content', $trimmed_content ); } endif;