'; if ( 'post' === get_post_type() ) : foreach ( $meta_orders as $key => $meta_order ) { if ( 'date' === $meta_order ) { colormag_date_meta_markup(); } if ( 'author' === $meta_order ) { colormag_author_meta_markup(); } if ( 'views' === $meta_order && $full_post_meta ) { echo colormag_post_view_display( get_the_ID() ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped } if ( 'comments' === $meta_order ) { colormag_comment_meta_markup( $full_post_meta ); } if ( 'tags' === $meta_order && $full_post_meta ) { colormag_tags_meta_markup(); } if ( 'read-time' === $meta_order ) { colormag_read_time_meta_markup( $full_post_meta, $reading_time_display ); } } // Edit button remove option add. if ( $full_post_meta ) { edit_post_link( __( 'Edit', 'colormag' ), '' . colormag_get_icon( 'edit', false ) . ' ', '' ); } echo ''; endif; } endif; if ( ! function_exists( 'wp_body_open' ) ) : /** * Adds backwards compatibility for wp_body_open() introduced with WordPress 5.2. * * @return void * @see https://developer.wordpress.org/reference/functions/wp_body_open/ */ function wp_body_open() { do_action( 'wp_body_open' ); } endif; if ( ! function_exists( 'colormag_reading_time' ) ) : /** * Displays the reading time in post meta. * * Since we were using JS for this feature, we were compromising site speed since it checks every link when loaded, * for displaying the time taken, and hence, we are opting for this function instead for this feature to fix site speed. * * @return string Reading time taken for post. */ function colormag_reading_time() { global $post; $post_content = get_post_field( 'post_content', $post->ID ); $word_count = count( preg_split( '/\s+/', $post_content ) ); $reading_time = floor( $word_count / 200 ); $reading_time_suffix = esc_html__( 'min read', 'colormag' ); $total_reading_time = $reading_time . ' ' . $reading_time_suffix; return $total_reading_time; } endif; if ( ! function_exists( 'colormag_category_color' ) ) : /** * Getting Category Color. * * @param int $wp_category_id Category id. * * @return string The category color. */ function colormag_category_color( $wp_category_id ) { $args = array( 'orderby' => 'id', 'hide_empty' => 0, ); $category = get_categories( $args ); foreach ( $category as $category_list ) { $color = get_theme_mod( 'colormag_category_color_' . $wp_category_id ); return $color; } } endif; if ( ! function_exists( 'colormag_colored_category' ) ) : /** * Category Color for widgets and other * * @param bool $echo Boolean value to echo or just return. * * @return mixed */ function colormag_colored_category( $echo = true ) { global $post; $meta_structure = array( 'categories', 'date', 'author', 'views', 'comments', 'tags', 'read-time', ); $categories = get_the_category(); $output = ''; if ( in_array( 'categories', $meta_structure, true ) && $categories ) { $output .= '
'; foreach ( $categories as $category ) { $color_code = colormag_category_color( get_cat_id( $category->cat_name ) ); if ( ! empty( $color_code ) ) { $output .= '' . $category->cat_name . ''; } else { $output .= '' . $category->cat_name . ''; } } $output .= '
'; 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', ); ?>
$weather_code ) { $output = '##628EFB'; } return $output; } endif; if ( ! function_exists( 'colormag_get_available_currencies' ) ) : /** * Get available currencies for fixer.io API. * * @return array */ function colormag_get_available_currencies() { $available_currencies = array( 'eur' => esc_html__( 'Euro Member Countries', 'colormag' ), 'aud' => esc_html__( 'Australian Dollar', 'colormag' ), 'bgn' => esc_html__( 'Bulgarian Lev', 'colormag' ), 'brl' => esc_html__( 'Brazilian Real', 'colormag' ), 'cad' => esc_html__( 'Canadian Dollar', 'colormag' ), 'chf' => esc_html__( 'Swiss Franc', 'colormag' ), 'cny' => esc_html__( 'Chinese Yuan Renminbi', 'colormag' ), 'czk' => esc_html__( 'Czech Republic Koruna', 'colormag' ), 'dkk' => esc_html__( 'Danish Krone', 'colormag' ), 'gbp' => esc_html__( 'British Pound', 'colormag' ), 'hkd' => esc_html__( 'Hong Kong Dollar', 'colormag' ), 'hrk' => esc_html__( 'Croatian Kuna', 'colormag' ), 'huf' => esc_html__( 'Hungarian Forint', 'colormag' ), 'idr' => esc_html__( 'Indonesian Rupiah', 'colormag' ), 'ils' => esc_html__( 'Israeli Shekel', 'colormag' ), 'inr' => esc_html__( 'Indian Rupee', 'colormag' ), 'jpy' => esc_html__( 'Japanese Yen', 'colormag' ), 'krw' => esc_html__( 'Korean (South) Won', 'colormag' ), 'mxn' => esc_html__( 'Mexican Peso', 'colormag' ), 'myr' => esc_html__( 'Malaysian Ringgit', 'colormag' ), 'nok' => esc_html__( 'Norwegian Krone', 'colormag' ), 'nzd' => esc_html__( 'New Zealand Dollar', 'colormag' ), 'php' => esc_html__( 'Philippine Peso', 'colormag' ), 'pln' => esc_html__( 'Polish Zloty', 'colormag' ), 'ron' => esc_html__( 'Romanian (New) Leu', 'colormag' ), 'rub' => esc_html__( 'Russian Ruble', 'colormag' ), 'sek' => esc_html__( 'Swedish Krona', 'colormag' ), 'sgd' => esc_html__( 'Singapore Dollar', 'colormag' ), 'thb' => esc_html__( 'Thai Baht', 'colormag' ), 'try' => esc_html__( 'Turkish Lira', 'colormag' ), 'usd' => esc_html__( 'United States Dollar', 'colormag' ), 'zar' => esc_html__( 'South African Rand', 'colormag' ), ); return $available_currencies; } endif; if ( ! function_exists( 'colormag_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. * * @param WP_Comment $comment Comment to display. * @param array $args An array of arguments. * @param int $depth Depth of the current comment. */ function colormag_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback': case 'trackback': // Display trackbacks differently than normal comments. ?>
  • id="comment-">

    ', '' ); ?>

  • id="li-comment-">
    user_id === $post->post_author ) ? '' . esc_html__( 'Post author', 'colormag' ) . '' : '' ); ?> ', sprintf( /* Translators: 1. Comment date, 2. Comment time */ esc_html__( '%1$s at %2$s', 'colormag' ), esc_html( get_comment_date() ), esc_html( get_comment_time() ) ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped printf( '' . colormag_get_icon( 'permalink', false ) . esc_html__( 'Permalink', 'colormag' ) . '', esc_url( get_comment_link( $comment->comment_ID ) ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped edit_comment_link(); ?>
    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() { ?>
    'list', 'prev_text' => '', 'next_text' => '', ); the_posts_pagination( $args ); ?>
    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_get_icon( 'tag', false ) . ' ', __( ', ', '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 ) ) { ?>