ID, 'blog-expert-meta-select-layout', true ); if ( empty( $post_options ) ) { $global_layout = esc_attr( blog_expert_get_option('global_layout') ); } else{ $global_layout = esc_attr($post_options); } } if ($global_layout == 'left-sidebar') { $blog_expert_body_class[]= 'left-sidebar ' . esc_attr( $input ); } elseif ($global_layout == 'no-sidebar') { $blog_expert_body_class[]= 'no-sidebar ' . esc_attr( $input ); } else{ $blog_expert_body_class[]= 'right-sidebar ' . esc_attr( $input ); } return $blog_expert_body_class; } endif; add_action( 'body_class', 'blog_expert_body_class' ); add_action( 'blog_expert_action_sidebar', 'blog_expert_add_sidebar' ); /** * Returns word count of the sentences. * * @since Blog Expert 1.0.0 */ if ( ! function_exists( 'blog_expert_words_count' ) ) : function blog_expert_words_count( $length = 25, $blog_expert_content = null ) { $length = absint( $length ); $source_content = preg_replace( '`\[[^\]]*\]`', '', $blog_expert_content ); $trimmed_content = wp_trim_words( $source_content, $length, '' ); return $trimmed_content; } endif; if ( ! function_exists( 'blog_expert_simple_breadcrumb' ) ) : /** * Simple breadcrumb. * * @since 1.0.0 */ function blog_expert_simple_breadcrumb() { if ( ! function_exists( 'breadcrumb_trail' ) ) { require_once get_template_directory() . '/assets/libraries/breadcrumbs/breadcrumbs.php'; } $breadcrumb_args = array( 'container' => 'div', 'show_browse' => false, ); breadcrumb_trail( $breadcrumb_args ); } endif; if ( ! function_exists( 'blog_expert_custom_posts_navigation' ) ) : /** * Posts navigation. * * @since 1.0.0 */ function blog_expert_custom_posts_navigation() { $pagination_type = blog_expert_get_option( 'pagination_type' ); switch ( $pagination_type ) { case 'default': the_posts_navigation(); break; case 'numeric': the_posts_pagination(); break; default: break; } } endif; add_action( 'blog_expert_action_posts_navigation', 'blog_expert_custom_posts_navigation' ); if( ! function_exists( 'blog_expert_excerpt_length' )) : /** * Excerpt length * * @since Blog Expert 1.0.0 * * @param null * @return int */ function blog_expert_excerpt_length( $length ){ if ( is_admin() ) { return $length; } $excerpt_length = blog_expert_get_option( 'excerpt_length_global' ); if ( absint( $excerpt_length ) > 0 ) { $length = absint( $excerpt_length ); } return $length; } add_filter( 'excerpt_length', 'blog_expert_excerpt_length', 999 ); endif; if ( ! function_exists( 'blog_expert_excerpt_more' ) ) : /** * Implement read more in excerpt. * * @since 1.0.0 * * @param string $more The string shown within the more link. * @return string The excerpt. */ function blog_expert_excerpt_more( $more ) { if ( is_admin() ) { return $more; } $flag_apply_excerpt_read_more = apply_filters( 'blog_expert_filter_excerpt_read_more', true ); if ( true !== $flag_apply_excerpt_read_more ) { return $more; } $output = $more; $read_more_text = esc_html__('Continue Reading','blog-expert'); if ( ! empty( $read_more_text ) ) { $output = ' ' . esc_html( $read_more_text ) . '' . ''; $output = apply_filters( 'blog_expert_filter_read_more_link' , $output ); } return $output; } add_filter('excerpt_more', 'blog_expert_excerpt_more'); endif; if ( ! function_exists( 'blog_expert_get_link_url' ) ) : /** * Return the post URL. * * Falls back to the post permalink if no URL is found in the post. * * @since 1.0.0 * * @return string The Link format URL. */ function blog_expert_get_link_url() { $content = get_the_content(); $has_url = get_url_in_content( $content ); return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } endif; if( ! function_exists( 'blog_expert_recommended_plugins' ) ) : /** * Recommended plugins * */ function blog_expert_recommended_plugins(){ $blog_expert_plugins = array( array( 'name' => esc_html__( 'One Click Demo Import', 'blog-expert' ), 'slug' => 'one-click-demo-import', 'required' => false, ), ); $blog_expert_plugins_config = array( 'dismissable' => true, ); tgmpa( $blog_expert_plugins, $blog_expert_plugins_config ); } endif; add_action( 'tgmpa_register', 'blog_expert_recommended_plugins' ); /** * OCDI support. * * @package Bizprime */ // Disable PT branding. add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' ); /** * OCDI after import. * * @since 1.0.0 */ function blog_expert_ocdi_after_import() { // Assign front page and posts page (blog page). $front_page_id = null; $blog_page_id = null; $front_page = get_page_by_title( 'Homepage' ); if ( $front_page ) { if ( is_array( $front_page ) ) { $first_page = array_shift( $front_page ); $front_page_id = $first_page->ID; } else { $front_page_id = $front_page->ID; } } $blog_page = get_page_by_title( 'Blog' ); if ( $blog_page ) { if ( is_array( $blog_page ) ) { $first_page = array_shift( $blog_page ); $blog_page_id = $first_page->ID; } else { $blog_page_id = $blog_page->ID; } } if ( $front_page_id && $blog_page_id ) { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $front_page_id ); update_option( 'page_for_posts', $blog_page_id ); } // Assign navigation menu locations. $menu_location_details = array( 'top' => 'Short', 'primary' => 'primary-menu', 'social' => 'social-menu', ); if ( ! empty( $menu_location_details ) ) { $navigation_settings = array(); $current_navigation_menus = wp_get_nav_menus(); if ( ! empty( $current_navigation_menus ) && ! is_wp_error( $current_navigation_menus ) ) { foreach ( $current_navigation_menus as $menu ) { foreach ( $menu_location_details as $location => $menu_slug ) { if ( $menu->slug === $menu_slug ) { $navigation_settings[ $location ] = $menu->term_id; } } } } set_theme_mod( 'nav_menu_locations', $navigation_settings ); } } add_action( 'pt-ocdi/after_import', 'blog_expert_ocdi_after_import' );