';
if ( $echo ) {
echo trim( $output ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} else {
return trim( $output );
}
}
}
endif;
/**
* Sets the post excerpt length to 20 words.
*
* Function tied to the excerpt_length filter hook.
*
* @param int $length The excerpt length.
*
* @return int The filtered excerpt length.
* @uses filter excerpt_length
*/
function colormag_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'colormag_excerpt_length' );
/**
* Returns a "Continue Reading" link for excerpts.
*/
function colormag_continue_reading() {
return '';
}
add_filter( 'excerpt_more', 'colormag_continue_reading' );
if ( ! function_exists( 'colormag_sidebar_select' ) ) :
/**
* Function to display the sidebar selected.
*/
function colormag_sidebar_select() {
if ( ( is_page_template( 'page-templates/page-builder.php' ) ) ) {
return;
}
global $post;
if ( $post ) {
$layout_meta = get_post_meta( $post->ID, 'colormag_page_layout', true );
}
if ( is_home() ) {
$queried_id = get_option( 'page_for_posts' );
$layout_meta = get_post_meta( $queried_id, 'colormag_page_layout', true );
}
if ( empty( $layout_meta ) || is_archive() || is_search() ) {
$layout_meta = 'default_layout';
}
$colormag_default_sidebar_layout = get_theme_mod( 'colormag_default_sidebar_layout', 'right_sidebar' );
$colormag_page_sidebar_layout = get_theme_mod( 'colormag_page_sidebar_layout', 'right_sidebar' );
$colormag_default_post_layout = get_theme_mod( 'colormag_post_sidebar_layout', 'right_sidebar' );
if ( 'default_layout' === $layout_meta ) {
if ( is_page() ) {
if ( 'right_sidebar' === $colormag_page_sidebar_layout || 'two_sidebars' === $colormag_page_sidebar_layout ) {
ColorMag_Utils::colormag_get_sidebar( $colormag_page_sidebar_layout );
} elseif ( 'left_sidebar' === $colormag_page_sidebar_layout ) {
ColorMag_Utils::colormag_get_sidebar( 'left' );
}
} elseif ( is_single() ) {
if ( 'right_sidebar' === $colormag_default_post_layout || 'two_sidebars' === $colormag_default_post_layout ) {
ColorMag_Utils::colormag_get_sidebar( $colormag_default_post_layout );
} elseif ( 'left_sidebar' === $colormag_default_post_layout ) {
ColorMag_Utils::colormag_get_sidebar( 'left' );
}
} elseif ( 'right_sidebar' === $colormag_default_sidebar_layout || 'two_sidebars' === $colormag_default_sidebar_layout ) {
ColorMag_Utils::colormag_get_sidebar( $colormag_default_sidebar_layout );
} elseif ( 'left_sidebar' === $colormag_default_sidebar_layout ) {
ColorMag_Utils::colormag_get_sidebar( 'left' );
}
} elseif ( 'right_sidebar' === $layout_meta || 'two_sidebars' === $layout_meta ) {
ColorMag_Utils::colormag_get_sidebar( $layout_meta );
} elseif ( 'left_sidebar' === $layout_meta ) {
ColorMag_Utils::colormag_get_sidebar( 'left' );
}
}
endif;
if ( ! function_exists( 'colormag_social_links' ) ) :
/**
* Displays the social links.
*/
function colormag_social_links() {
// Bail out if social links is not activated.
if ( 0 == get_theme_mod( 'colormag_enable_social_icons', 0 ) ) {
return;
}
$colormag_social_links = array(
'colormag_social_facebook' => 'Facebook',
'colormag_social_twitter' => 'Twitter',
'colormag_social_instagram' => 'Instagram',
'colormag_social_pinterest' => 'Pinterest',
'colormag_social_youtube' => 'YouTube',
);
?>
$value ) {
$link = get_theme_mod( $key, '' );
if ( ! empty( $link ) ) {
$new_tab = '';
// For opening link in new tab.
if ( 1 == get_theme_mod( $key . '_checkbox', 0 ) ) {
$new_tab = 'target="_blank"';
}
$colormag_links_output .= '
';
}
$i ++;
}
// Displays the social links which is set static via theme customize option.
echo $colormag_links_output; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
?>