5
),
array(
'before_widget' => '',
'before_title' => '
',
)
);
// Display a friendly notice
if( $sidebar_name != '' ) {
echo '';
printf( __( 'This sidebar is empty, you should add some widgets (in %s). Until then we are showing some default widgets.', 'businessx' ), '' . esc_html( $sidebar_name ) . '' );
echo '
'; }
// Show Meta widget
the_widget( 'WP_Widget_Meta', array(),
array(
'before_widget' => '',
'before_title' => '',
) );
}
}
}
// Footer sidebars
if ( ! function_exists( 'businessx_footer_sidebars_demo_widgets' ) ) {
function businessx_footer_sidebars_demo_widgets( $sidebar_name = '' ) {
$disabled = get_theme_mod( 'sidebars_demo_disable', false );
if( ! $disabled ) {
switch( $sidebar_name ) :
case 'sidebar-footer-1' :
// Show Recent Posts widget
the_widget( 'WP_Widget_Recent_Posts',
array(
'number' => 6
),
array(
'before_widget' => '',
'before_title' => '',
)
);
break;
case 'sidebar-footer-2' :
// Show Calendar
the_widget( 'WP_Widget_Calendar',
array(
'title' => __( 'Calendar', 'businessx' ),
),
array(
'before_widget' => '',
'before_title' => '',
)
);
break;
case 'sidebar-footer-3' :
// Show Text Widget
the_widget( 'WP_Widget_Text',
array(
'title' => esc_html__( 'Demo Widgets', 'businessx' ),
'text' => __( 'These are demo widgets, you can add your own in this sidebars: Footer #1 Sidebar, Footer #2 Sidebar and Footer #3 Sidebar.
You can also disable this entire section (widgetized footer) from Customizer > Settings > Footer > Disable footer sidebars.
Simple stuff :D
', 'businessx' ),
'filter' => true
),
array(
'before_widget' => '',
'before_title' => '',
)
);
break;
default : '';
endswitch;
}
}
}
/* ------------------------------------------------------------------------- *
* Footer
/* ------------------------------------------------------------------------- */
/* -- Return copyright info */
if ( ! function_exists( 'businessx_return_copyright_templ' ) ) {
function businessx_return_copyright_templ() {
return '© ' . esc_html( get_bloginfo( 'name' ) ) . ' ' . date( 'Y' ) . '. ';
}
}
/* ------------------------------------------------------------------------- *
* Animations
/* ------------------------------------------------------------------------- */
if ( ! function_exists( 'businessx_anim_classes' ) ) {
function businessx_anim_classes( $return = false ) {
$enable = get_theme_mod( 'animations_enable', false );
$classes = array();
if( ! is_customize_preview() && $enable ) {
$classes[] = 'fader';
}
$classes = apply_filters( 'businessx_anim_classes___filter', $classes );
$classes = array_map( 'esc_attr', array_unique( $classes ) );
$output = join( ' ', $classes );
if( $return ) {
return $output; } else { echo $output; }
}
}
/* ------------------------------------------------------------------------- *
* Headings used with custom header images
/* ------------------------------------------------------------------------- */
/* -- Index
escape on output */
if ( ! function_exists( 'businessx_heading_title' ) ) {
function businessx_heading_title() {
global $wp_query;
$title = get_theme_mod( 'homepage_heading', __( 'Homepage Heading', 'businessx' ) );
if( ( is_front_page() || is_home() ) && ! is_paged() ) {
return $title;
}
if( is_paged() ) {
printf( __( 'Page #: %s of %s', 'businessx' ), businessx_get_paged(), intval( $wp_query->max_num_pages ) );
}
}
}
/* -- Portfolio
escape on output */
if ( ! function_exists( 'businessx_portfolio_heading_title' ) ) {
function businessx_portfolio_heading_title( $template = 'template-jetpack-portfolio.php' ) {
if( is_page_template( $template ) && ! is_paged() ) {
return get_the_title();
}
if( is_paged() ) {
printf( __( 'Portfolio Page #%s', 'businessx' ), businessx_get_paged() );
}
}
}
/* ------------------------------------------------------------------------- *
* JetPack Portfolio
/* ------------------------------------------------------------------------- */
/* -- Setup Masonry args */
if ( ! function_exists( 'businessx_portfolio_page_masonry_options' ) ) {
function businessx_portfolio_page_masonry_options() {
$options = apply_filters(
'businessx_portfolio_page_masonry___options',
'{ "columnWidth": ".sec-portfolio-grid-sizer", "gutter": ".sec-portfolio-gutter-sizer", "percentPosition": true, "itemSelector": ".grid-col" }' );
echo esc_attr( $options );
}
}
/* ------------------------------------------------------------------------- *
* Get featured image and set background
/* ------------------------------------------------------------------------- */
if ( ! function_exists( 'businessx_header_bg_options' ) ) {
function businessx_header_bg_options() {
global $post;
$css = '';
$size = apply_filters( 'businessx_header_bg_options___thumb_size', 'full' );
$ch = get_header_image();
$show_ch = false;
$px_index = get_theme_mod( 'enable_parallax_custom_headers', apply_filters( 'enable_parallax_custom_headers___filter', false ) );
$px_sp = get_theme_mod( 'enable_parallax_featured_images', apply_filters( 'enable_parallax_featured_images___filter', false ) );
// Post id
if( ! empty( $post ) ) { $pid = $post->ID; }
// Post thumbnail
if ( has_post_thumbnail() && ( is_page() || is_single() ) && ! $px_sp && ! empty( $post ) ) {
$large_image = wp_get_attachment_image_src( get_post_thumbnail_id( $pid ), $size );
if ( ! empty( $large_image[0] ) ) {
$large_image_url = $large_image[0];
$css .= ' #top-header-' . intval( $pid ) . ' { background-image: url("' . esc_url( $large_image_url ) . '"); }';
}
} else { $show_ch = true; }
// Custom header
if ( ! empty( $ch ) && ! businessx_front_pt() && $show_ch && ! ( is_page() || is_single() ) && ! $px_index ) {
$css .= ' #top-header { background-image: url("' . esc_url( $ch ) . '"); }';
}
// Output CSS
wp_add_inline_style( 'businessx-style', businessx_sanitize_css( $css ) );
}
}
add_action( 'wp_enqueue_scripts', 'businessx_header_bg_options', 101 );
/* ------------------------------------------------------------------------- *
* Excerpt options
/* ------------------------------------------------------------------------- */
/* -- Custom excerpt length */
if ( ! function_exists( 'businessx_custom_excerpt_length' ) ) {
function businessx_custom_excerpt_length( $length ) {
$custom = get_theme_mod( 'posts_index_excerpt_length' );
if( $custom != '' ) {
$length = $custom;
return intval( $length );
} else {
return $length;
}
}
}
add_filter( 'excerpt_length', 'businessx_custom_excerpt_length', 999 );
/* -- Custom excerpt ending */
if ( ! function_exists( 'businessx_excerpt_ending' ) ) {
function businessx_excerpt_ending( $more ) {
$custom = get_theme_mod( 'posts_index_excerpt_ending' );
if( $custom != '' ) {
$more = $custom;
return esc_html( $more );
} else {
return $more;
}
}
}
add_filter( 'excerpt_more', 'businessx_excerpt_ending', 999 );