';
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',
'colormag_social_vimeo' => 'Vimeo-Square',
'colormag_social_linkedin' => 'LinkedIn',
'colormag_social_delicious' => 'Delicious',
'colormag_social_flickr' => 'Flickr',
'colormag_social_skype' => 'Skype',
'colormag_social_soundcloud' => 'SoundCloud',
'colormag_social_vine' => 'Vine',
'colormag_social_stumbleupon' => 'StumbleUpon',
'colormag_social_tumblr' => 'Tumblr',
'colormag_social_reddit' => 'Reddit',
'colormag_social_xing' => 'Xing',
'colormag_social_vk' => 'VK',
);
$colormag_additional_social_link = array(
'user_custom_social_links_one' => __( 'Additional Social Link One', 'colormag' ),
'user_custom_social_links_two' => __( 'Additional Social Link Two', 'colormag' ),
'user_custom_social_links_three' => __( 'Additional Social Link Three', 'colormag' ),
'user_custom_social_links_four' => __( 'Additional Social Link Four', 'colormag' ),
'user_custom_social_links_five' => __( 'Additional Social Link Five', 'colormag' ),
'user_custom_social_links_six' => __( 'Additional Social Link Six', 'colormag' ),
);
?>
$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
/**
* Social links set which is dynamic via the theme customize option.
*/
$i = 0;
$colormag_additional_links_output = '';
foreach ( $colormag_additional_social_link as $key => $value ) {
$link = get_theme_mod( $key, '' );
$color = get_theme_mod( $key . '_color' );
if ( ! empty( $link ) ) {
$new_tab = '';
$color_code = '';
// For opening link in new tab.
if ( 1 == get_theme_mod( $key . '_checkbox', 0 ) ) {
$new_tab = 'target="_blank"';
}
// For color set in customize option.
if ( ! empty( $color ) ) {
$color_code = ' style="color:' . $color . '"';
}
$colormag_additional_links_output .= '
';
}
$i ++;
}
// Displays the social links which is set dynamic via theme customize option.
echo $colormag_additional_links_output; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
?>
id="li-comment-">
comment_approved ) : ?>
esc_html__( 'Reply', 'colormag' ),
'after' => '',
'depth' => $depth,
'max_depth' => $args['max_depth'],
)
)
);
?>
' . $icon . '' . esc_html__( '0 View', 'colormag' ) . '';
} else {
/* Translators: %s Post view count */
$output = '' . $icon . '' . sprintf( esc_html__( '%s Views', 'colormag' ), $count ) . '';
}
return $output;
}
endif;
if ( ! function_exists( 'colormag_post_view_setup' ) ) :
/**
* Function to count views for the posts
*
* @param int $post_id Post ID.
*/
function colormag_post_view_setup( $post_id ) {
$count_key = 'total_number_of_views';
$count = get_post_meta( $post_id, $count_key, true );
if ( '' === $count ) {
delete_post_meta( $post_id, $count_key );
add_post_meta( $post_id, $count_key, '0' );
} else {
$count ++;
update_post_meta( $post_id, $count_key, $count );
}
}
endif;
if ( ! function_exists( 'colormag_font_size_range_generator' ) ) :
/**
* Function to generate font size range for font size options.
*
* @param int $start_range Start range.
* @param int $end_range End range.
*
* @return array
*/
function colormag_font_size_range_generator( $start_range, $end_range ) {
$range_string = array();
for ( $i = $start_range; $i <= $end_range; $i ++ ) {
$range_string[ $i ] = $i;
}
return $range_string;
}
endif;
if ( ! function_exists( 'colormag_plugin_version_compare' ) ) :
/**
* Compare user's current version of plugin.
*
* @param string $plugin_slug The plugin slug.
* @param string $version_to_compare The plugin's version.
*
* @return bool
*/
function colormag_plugin_version_compare( $plugin_slug, $version_to_compare ) {
$installed_plugins = get_plugins();
// Plugin not installed.
if ( ! isset( $installed_plugins[ $plugin_slug ] ) ) {
return false;
}
$plugin_version = $installed_plugins[ $plugin_slug ]['Version'];
return version_compare( $plugin_version, $version_to_compare, '<' );
}
endif;
if ( ! function_exists( 'colormag_author_social_link' ) ) :
/**
* Function to show the profile field data.
*/
function colormag_author_social_link() {
?>
null );
} else {
return wp_get_attachment_image_src( attachment_url_to_postid( $image_url ), $image_size );
}
}
if ( ! function_exists( 'colormag_date_entry_meta_markup' ) ) :
/**
* Prints post meta markup for date of post published or updated.
*
* @return void
*/
function colormag_date_meta_markup() {
// Displays the same published and updated date if the post is never updated.
$time_string = '';
// Displays the different published and updated date if the post is updated.
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '';
}
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
printf(
/* Translators: 1. Post link, 2. Post time, 3. Post date */
__( '%3$s %4$s', 'colormag' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
colormag_get_icon( 'calendar-fill', false ),
$time_string
); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
}
endif;
if ( ! function_exists( 'colormag_author_meta_markup' ) ) :
/**
* Prints post meta markup for author.
*
* @return void
*/
function colormag_author_meta_markup() {
?>
', __( ', ', 'colormag' ), '' );
if ( $tags_list ) {
echo $tags_list; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
}
}
endif;
if ( ! function_exists( 'colormag_read_time_meta_markup' ) ) :
/**
* Undocumented function
*
* @param [boolean] $full_post_meta
* @param [boolean] $reading_time_display
* @return void
*/
function colormag_read_time_meta_markup( $full_post_meta, $reading_time_display ) {
if ( $full_post_meta || ( ! $full_post_meta && $reading_time_display ) ) {
?>