<?php
/**
 * Basho theme template tags.
 */

if ( ! function_exists( 'basho_body_open' ) ) {
	/**
	 * Shim for wp_body_open, ensuring backwards compatibility with versions of WordPress older than 5.2.
	 */
	function basho_body_open() {
		/**
		 * Functions hooked into wp_body_open action
		 *
		 * @hooked basho_skip_link                    - 0
		 */
		do_action( 'wp_body_open' );
	}
}

if ( ! function_exists( 'basho_get_sticky_header_attribute' ) ) {
	/**
	 * Check if site header is set to be sticky to the top of the screen in the Customzier and output certain data attriubte if so.
	 */
	function basho_get_sticky_header_attribute() {

		/**
		 * Get 'basho_sticky_header' option value from the Customizer.
		 */
		$is_sticky = get_theme_mod( 'basho_sticky_header', false );

		if ( $is_sticky ) {
			return apply_filters( 'basho_sticky_header_attribute', " data-uk-sticky='cls-active: uk-background-default'" );
		}

	}
}

if ( ! function_exists( 'basho_get_container_width_class' ) ) {
	/**
	 * Generate header, footer, loop container classes based on Customzier option.
	 */
	function basho_get_container_width_class( $id ) {

		$width_class = '';

		if ( 'header' === $id ) {

			/**
	    	 * Get 'basho_site_header_width' option value from the Customizer.
	         */
	    	$header_width = get_theme_mod( 'basho_site_header_width', 'wide' );

	        if ( 'small' === $header_width ) {
	            $width_class = ' uk-container-small';
	        } else if ( 'medium' === $header_width ) {
	            $width_class = '';
	        } else if ( 'wide' === $header_width ) {
	            $width_class = ' uk-container-large';
	        } else if ( 'full-width' === $header_width ) {
	            $width_class = ' uk-container-expand';
	        }

		}

		if ( 'archive-header' === $id ) {

			/**
	    	 * Get 'basho_archive_header_width' option value from the Customizer.
	         */
	    	$loop_container_width = get_theme_mod( 'basho_archive_header_width', 'medium' );

	        if ( 'small' === $loop_container_width ) {
	            $width_class = ' uk-container-small';
	        } else if ( 'medium' === $loop_container_width ) {
	            $width_class = '';
	        } else if ( 'wide' === $loop_container_width ) {
	            $width_class = ' uk-container-large';
	        } else if ( 'full-width' === $loop_container_width ) {
	            $width_class = ' uk-container-expand';
	        }

			$width_class .= ' archive-header-margin';

		}

		if ( 'entry-header' === $id ) {

			if ( is_page() ) {
				return ' uk-container-xsmall';
			}

			/**
	    	 * Get 'basho_post_header_width' option value from the Customizer.
	         */
	    	$loop_container_width = get_theme_mod( 'basho_post_header_width', 'small' );

	        if ( 'small' === $loop_container_width ) {
	            $width_class = ' uk-container-small';
	        } else if ( 'medium' === $loop_container_width ) {
	            $width_class = '';
	        } else if ( 'wide' === $loop_container_width ) {
	            $width_class = ' uk-container-large';
	        } else if ( 'full-width' === $loop_container_width ) {
	            $width_class = ' uk-container-expand';
	        }

		}

		if ( 'loop' === $id ) {

			/**
	    	 * Get 'basho_loop_container_width' option value from the Customizer.
	         */
	    	$loop_container_width = get_theme_mod( 'basho_loop_container_width', 'full-width' );

	        if ( 'small' === $loop_container_width ) {
	            $width_class = ' uk-container-small';
	        } else if ( 'medium' === $loop_container_width ) {
	            $width_class = '';
	        } else if ( 'wide' === $loop_container_width ) {
	            $width_class = ' uk-container-large';
	        } else if ( 'full-width' === $loop_container_width ) {
	            $width_class = ' uk-container-expand';
	        }

		}

		if ( 'footer' === $id ) {

			/**
	    	 * Get 'basho_site_footer_width' option value from the Customizer.
	         */
	    	$footer_width = get_theme_mod( 'basho_site_footer_width', 'wide' );

	        if ( 'small' === $footer_width ) {
	            $width_class = ' uk-container-small';
	        } else if ( 'medium' === $footer_width ) {
	            $width_class = '';
	        } else if ( 'wide' === $footer_width ) {
	            $width_class = ' uk-container-large';
	        } else if ( 'full-width' === $footer_width ) {
	            $width_class = ' uk-container-expand';
	        }

		}

		return $width_class;

	}
}

if ( ! function_exists( 'basho_show_blog_categories' ) ) {
    /**
     * Output blog categories.
     */
    function basho_show_blog_categories() {

        if ( ! taxonomy_exists( 'category' ) ) {
            return;
        }

		?>

		<ul class="archive-categories uk-list uk-margin-remove uk-padding-remove uk-clearfix">
            <?php
			$blog_page_id 	= get_option( 'page_for_posts', true );
			$blog_link		= ( $blog_page_id ) ? get_page_link( $blog_page_id ) : get_home_url();
            $blog_title 	= ( $blog_page_id ) ? get_the_title( $blog_page_id ) : __( 'All posts', 'basho' );

            // Output first list item with a blog page title.
            if ( is_home() ) {
                global $wp_query;

                $post_count = $wp_query->found_posts;

                $cat_item = '<li class="cat-item current-cat">';
                $cat_item .= '<span class="uk-margin-remove">';
                $cat_item .= $blog_title . '<span class="post-count">' . $post_count . '</span>';
                $cat_item .= '</span>';
                $cat_item .= '</li>';

                echo wp_kses_post( $cat_item );
            } else {
                $cat_item = '<li class="cat-item">';
                $cat_item .= '<a class="uk-link-text uk-margin-remove" href="' . esc_url( $blog_link ) . '">';
                $cat_item .= $blog_title;
                $cat_item .= '</a>';
                $cat_item .= '</li>';

                echo wp_kses_post( $cat_item );
            }

            /*
             * Allow child themes and plugins to filter the arguments of the get_categories function.
             *
             * @param array Arguments, passed to get_categories and then to get_terms functions, Default array().
             */
            $args = apply_filters( 'basho_blog_categories_args', array() );

            $categories = get_categories( $args );

            // Output remaining list items with categories.
            if ( ! empty( $categories ) ) {
                foreach ( $categories as $category ) {
                    $id         = $category->term_id;
                    $name       = $category->name;
                    $post_count = $category->category_count;

                    // For current category item add a .current-cat class and output h1 tag instead of a link.
                    if ( $id === get_queried_object_id() ) {
                        $cat_item  = '<li class="cat-item current-cat">';
                        $cat_item .= '<span class="uk-margin-remove">';
                        $cat_item .= $name . '<span class="post-count">' . $post_count . '</span>';
                        $cat_item .= '</span>';
                        $cat_item .= '</li>';

                        echo wp_kses_post( $cat_item );
                    } else {
                        $cat_item  = '<li class="cat-item">';
                        $cat_item .= '<a class="uk-link-text uk-margin-remove" href="' . esc_url( get_term_link( $id ) ) . '">';
                        $cat_item .= $name;
                        $cat_item .= '</a>';
                        $cat_item .= '</li>';

                        echo wp_kses_post( $cat_item );
                    }
                }
            }

            ?>

        </ul> <!-- .archive-categories -->

        <?php
    }
}

if ( ! function_exists( 'basho_the_post_meta' ) ) {
    /**
     * Get and Output Post Meta.
     * If it's a single post, output the post meta values specified in the Customizer settings.
     * Found this approach in TwentyTwenty WordPress theme.
	 *
	 * @param integer Post ID.
	 * @param string Location where post meta will be shown.
     */
    function basho_the_post_meta( $post_id = null, $location = 'entry-header' ) {

        echo basho_get_post_meta( $post_id, $location ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in basho_get_post_meta().

    }
}

if ( ! function_exists( 'basho_get_post_meta' ) ) {
    /**
     * Get and Output Post Meta.
     * If it's a single post, output the post meta values specified in the Customizer settings.
	 * Post meta includes: 'categories', 'sticky', 'post-date', 'comments', 'author' or 'tags'.
     */
    function basho_get_post_meta( $post_id = null, $location = 'entry-header' ) {

		// Post ID is required.
    	if ( ! $post_id ) {
    		return;
    	}

		/**
    	 * Filters post types array
    	 *
    	 * This filter can be used to hide post meta information of post, page or custom post type registerd by child themes or plugins.
    	 *
    	 * @param array Array of post types
    	 */
    	$disallowed_post_types = apply_filters( 'basho_disallowed_post_types_for_meta_output', array( 'page' ) );

		// Check whether the post type is allowed to output post meta.
    	if ( in_array( get_post_type( $post_id ), $disallowed_post_types, true ) ) {
    		return;
    	}

		$post_meta_wrapper_classes = '';

    	// Get the post meta settings for the location specified.
    	if ( 'archive-entry-header' === $location ) {

    		/**
    		 * Set archive entry header post meta visibility based on Customizer options.
    		 */
    		$post_meta = [];

			if ( get_theme_mod( 'basho_show_categories_in_archive_entry_header', true ) ) {
				$post_meta[] = 'categories';
			}

			if ( get_theme_mod( 'basho_show_tags_in_archive_entry_header', false ) ) {
				$post_meta[] = 'tags';
			}

			if ( get_theme_mod( 'basho_show_post_date_in_archive_entry_header', false ) ) {
				$post_meta[] = 'post-date';
			}

			if ( get_theme_mod( 'basho_show_author_in_archive_entry_header', false ) ) {
				$post_meta[] = 'author';
			}

			if ( get_theme_mod( 'basho_show_comments_in_archive_entry_header', false ) ) {
				$post_meta[] = 'comments';
			}

    		$post_meta_wrapper_classes = ' post-meta-archive post-meta-archive-entry-header';

    	} else if ( 'archive-entry-footer' === $location ) {

			/**
    		 * Set archive entry footer post meta visibility based on Customizer options.
    		 */
    		$post_meta = [];

			if ( get_theme_mod( 'basho_show_categories_in_archive_entry_footer', false ) ) {
				$post_meta[] = 'categories';
			}

			if ( get_theme_mod( 'basho_show_tags_in_archive_entry_footer', false ) ) {
				$post_meta[] = 'tags';
			}

			if ( get_theme_mod( 'basho_show_post_date_in_archive_entry_footer', true ) ) {
				$post_meta[] = 'post-date';
			}

			if ( get_theme_mod( 'basho_show_author_in_archive_entry_footer', false ) ) {
				$post_meta[] = 'author';
			}

			if ( get_theme_mod( 'basho_show_comments_in_archive_entry_footer', false ) ) {
				$post_meta[] = 'comments';
			}

    		$post_meta_wrapper_classes = ' post-meta-archive post-meta-archive-entry-footer';

		} else if ( 'entry-header-top' === $location ) {

			/**
    		 * Set post meta visibility in 'entry-header-top' location (above entry title) based on Customizer options.
    		 */
    		$post_meta = [];

			if ( get_theme_mod( 'basho_show_categories_in_entry_header_top', true ) ) {
				$post_meta[] = 'categories';
			}

			if ( get_theme_mod( 'basho_show_tags_in_entry_header_top', false ) ) {
				$post_meta[] = 'tags';
			}

			if ( get_theme_mod( 'basho_show_post_date_in_entry_header_top', false ) ) {
				$post_meta[] = 'post-date';
			}

			if ( get_theme_mod( 'basho_show_author_in_entry_header_top', false ) ) {
				$post_meta[] = 'author';
			}

			if ( get_theme_mod( 'basho_show_comments_in_entry_header_top', false ) ) {
				$post_meta[] = 'comments';
			}

			if ( get_theme_mod( 'basho_show_sticky_in_entry_header_top', false ) ) {
				$post_meta[] = 'sticky';
			}

    		$post_meta_wrapper_classes = ' post-meta-singular post-meta-singular-entry-header-top';

		} else if ( 'entry-header-bottom' === $location ) {

			/**
    		 * Set post meta visibility in 'entry-header-bottom' location (below entry title) based on Customizer options.
    		 */
    		$post_meta = [];

			if ( get_theme_mod( 'basho_show_categories_in_entry_header_bottom', false ) ) {
				$post_meta[] = 'categories';
			}

			if ( get_theme_mod( 'basho_show_tags_in_entry_header_bottom', false ) ) {
				$post_meta[] = 'tags';
			}

			if ( get_theme_mod( 'basho_show_post_date_in_entry_header_bottom', true ) ) {
				$post_meta[] = 'post-date';
			}

			if ( get_theme_mod( 'basho_show_author_in_entry_header_bottom', true ) ) {
				$post_meta[] = 'author';
			}

			if ( get_theme_mod( 'basho_show_comments_in_entry_header_bottom', true ) ) {
				$post_meta[] = 'comments';
			}

			if ( get_theme_mod( 'basho_show_sticky_in_entry_header_bottom', true ) ) {
				$post_meta[] = 'sticky';
			}

    		$post_meta_wrapper_classes = ' post-meta-singular post-meta-singular-entry-header-bottom';

		} else if ( 'entry-footer' === $location ) {

			/**
    		 * Set post meta visibility in 'entry-footer' location based on Customizer options.
    		 */
    		$post_meta = [];

			if ( get_theme_mod( 'basho_show_categories_in_entry_footer', false ) ) {
				$post_meta[] = 'categories';
			}

			if ( get_theme_mod( 'basho_show_tags_in_entry_footer', true ) ) {
				$post_meta[] = 'tags';
			}

			if ( get_theme_mod( 'basho_show_post_date_in_entry_footer', false ) ) {
				$post_meta[] = 'post-date';
			}

			if ( get_theme_mod( 'basho_show_author_in_entry_footer', true ) ) {
				$post_meta[] = ''; // Because we will display info about author in entry-author-bio parial.
			}

    		$post_meta_wrapper_classes = ' post-meta-singular post-meta-singular-entry-footer';

		}

		// Check if we have some post meta to display.
        if ( ! empty( $post_meta ) ) {

            // Make sure we don't output an empty container.
            $has_meta = false;

            global $post;
    		$the_post = get_post( $post_id );
    		setup_postdata( $the_post );

    		ob_start();

    		?>

			<div class="post-meta-wrapper<?php echo esc_attr( $post_meta_wrapper_classes ); ?>">

				<?php

				// Categories.
				if ( in_array( 'categories', $post_meta, true ) && has_category() ) {

					$has_meta = true;
					?>
					<div class="post-categories meta-wrapper">
						<?php the_category( ', ' ); ?>
					</div>
					<?php

				}

				// Tags.
				if ( in_array( 'tags', $post_meta, true ) && has_tag() ) {

					$has_meta = true;

					/**
		    		 * Filters the_tags() function parameters. I like to use '#' symbol before hashtags. That's why I added this filter.
		    		 */
					list( $before, $sep, $after ) = apply_filters( 'basho_the_tags_post_meta_filter', array( '<ul><li>', '</li><li>', '</li></ul>' ) );

					?>
					<div class="post-tags meta-wrapper">
						<?php the_tags( $before, $sep, $after ); ?>
					</div>
					<?php

				}

				// Post date & author.
				$display_post_date 	= in_array( 'post-date', $post_meta, true );
				$display_author 	= in_array( 'author', $post_meta, true );

				if ( $display_post_date || $display_author ) {

					$has_meta = true;
					?>
					<div class="post-date-author meta-wrapper">
						<?php

						if ( $display_post_date ) {
							printf( '<a class="date" href="%s">%s</a> ', esc_url( get_the_permalink()), esc_html( get_the_time( get_option( 'date_format' ) ) ) );
						}

						if ( $display_author ) {
							printf(
								/* translators: %s: Author name */
								esc_html__( 'by %s', 'basho' ),
								'<a class="author" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a>'
							);
						}

						?>
					</div>
					<?php

				}

				// Comments link.
				if ( in_array( 'comments', $post_meta, true ) && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {

					$has_meta = true;
					?>
					<div class="post-comment-link meta-wrapper">
						<?php comments_popup_link(); ?>
					</div>
					<?php

				}

				// Sticky.
				if ( in_array( 'sticky', $post_meta, true ) && is_sticky() ) {

					$has_meta = true;
					?>
					<div class="post-sticky meta-wrapper">
						<?php esc_html_e( 'Featured', 'basho' ); ?>
					</div>
					<?php

				}

				?>

			</div>

			<?php

			wp_reset_postdata();

    		$meta_output = ob_get_clean();

    		// If there is meta to output, return it.
    		if ( $has_meta && $meta_output ) {

    			return $meta_output;

    		}

		}

	}
}

if ( ! function_exists( 'eisai_the_post_meta' ) ) {
    /**
     * Get and Output Post Meta.
     * If it's a single post, output the post meta values specified in the Customizer settings.
     * Found this approach in TwentyTwenty WordPress theme.
     */
    function eisai_the_post_meta( $post_id = null, $location = 'entry-header' ) {

        echo eisai_get_post_meta( $post_id, $location ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in basho_get_post_meta().

    }
}

if ( ! function_exists( 'eisai_get_post_meta' ) ) {
    /**
     * Get and Output Post Meta.
     * If it's a single post, output the post meta values specified in the Customizer settings.
     */
    function eisai_get_post_meta( $post_id = null, $location = 'entry-header' ) {

        // Require post ID.
    	if ( ! $post_id ) {
    		return;
    	}

        /**
    	 * Filters post types array
    	 *
    	 * This filter can be used to hide post meta information of post, page or custom post type registerd by child themes or plugins.
    	 *
    	 * @param array Array of post types
    	 */
    	$disallowed_post_types = apply_filters( 'basho_disallowed_post_types_for_meta_output', array( 'page' ) );

		// Check whether the post type is allowed to output post meta.
    	if ( in_array( get_post_type( $post_id ), $disallowed_post_types, true ) ) {
    		return;
    	}

        $post_meta_wrapper_classes = '';
    	$post_meta_classes         = '';

    	// Get the post meta settings for the location specified.
    	if ( 'entry-header' === $location ) {
    		/**
    		* Filters post meta info visibility
    		*
    		* Use this filter to hide post meta information like Author, Post date, Comments, Is sticky status
    		*
    		* @param array $args {
    		*  @type string 'author'
    		*  @type string 'post-date'
    		*  @type string 'comments'
    		*  @type string 'sticky'
    		* }
    		*/
    		$post_meta = apply_filters(
    			'basho_post_meta_location_entry_header',
    			array(
    				'author',
    				'post-date',
    				'comments',
    				'sticky',
    			)
    		);
    		$post_meta_wrapper_classes = ' post-meta-single post-meta-entry-header';

    	} elseif ( 'entry-footer' === $location ) {

    		/**
    		* Filters post tags visibility
    		*
    		* Use this filter to hide post tags
    		*
    		* @param array $args {
    		*   @type string 'tags'
    		* }
    		*/
    		$post_meta = apply_filters(
    			'basho_post_meta_location_entry_footer',
    			array(
    				'tags',
    			)
    		);
    		$post_meta_wrapper_classes = ' post-meta-single post-meta-entry-footer';

    	} elseif ( 'archive' === $location ) {

			/**
    		* Filters post categories visibility
    		*
    		* Use this filter to hide post categories
    		*
    		* @param array $args {
    		*   @type string 'categories'
    		* }
    		*/
    		$post_meta = apply_filters(
    			'basho_post_meta_location_archive',
    			array(
    				'author',
					'categories',
    				'post-date',
    				'comments',
					'sticky',
					'tags',
    			)
    		);
    		$post_meta_wrapper_classes = ' post-meta-archive';

		}

        // If the post meta setting has the value 'empty', it's explicitly empty and the default post meta shouldn't be output.
        if ( $post_meta && ! in_array( 'empty', $post_meta, true ) ) {

            // Make sure we don't output an empty container.
            $has_meta = false;

            global $post;
    		$the_post = get_post( $post_id );
    		setup_postdata( $the_post );

    		ob_start();

    		?>

            <div class="post-meta-wrapper<?php echo esc_attr( $post_meta_wrapper_classes ); ?>">
                <ul class="post-meta uk-clearfix<?php echo esc_attr( $post_meta_classes ); ?>">

                    <?php

                    /**
    				 * Fires before post meta html display.
    				 *
    				 * Allow output of additional post meta info to be added by child themes and plugins.
    				 *
    				 * @param int   $post_ID Post ID.
    				 */
    				do_action( 'basho_before_post_meta_list', $post_id );

                    // Author.
    				if ( in_array( 'author', $post_meta, true ) ) {

    					$has_meta = true;
    					?>
    					<li class="post-author meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php esc_html_e( 'Post Author', 'basho' ); ?></span>
                                <span data-uk-icon="icon: basho-user; ratio: .6"></span>
    						</span>
    						<span class="meta-text">
    							<?php
    							printf(
    								/* translators: %s: Author name */
    								esc_html__( 'by %s', 'basho' ),
    								'<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a>'
    							);
    							?>
    						</span>
    					</li>
    					<?php

    				}

    				// Post date.
    				if ( in_array( 'post-date', $post_meta, true ) ) {

    					$has_meta = true;
    					?>
    					<li class="post-date meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php esc_html_e( 'Post date', 'basho' ); ?></span>
                                <span data-uk-icon="icon: basho-calendar; ratio: .55"></span>
    						</span>
    						<span class="meta-text">
    							<a href="<?php the_permalink(); ?>"><?php the_time( get_option( 'date_format' ) ); ?></a>
    						</span>
    					</li>
    					<?php

    				}

    				// Categories.
    				if ( in_array( 'categories', $post_meta, true ) && has_category() ) {

    					$has_meta = true;
    					?>
    					<li class="post-categories meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php esc_html_e( 'Categories', 'basho' ); ?></span>
                                <span data-uk-icon="icon: basho-tag; ratio: .55"></span>
    						</span>
    						<span class="meta-text">
    							<?php the_category( ', ' ); ?>
    						</span>
    					</li>
    					<?php

    				}

    				// Comments link.
    				if ( in_array( 'comments', $post_meta, true ) && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {

    					$has_meta = true;
    					?>
    					<li class="post-comment-link meta-wrapper">
    						<span class="meta-icon">
                                <span data-uk-icon="icon: basho-message-square; ratio: .55"></span>
    						</span>
    						<span class="meta-text">
    							<?php comments_popup_link(); ?>
    						</span>
    					</li>
    					<?php

    				}

    				// Sticky.
    				if ( in_array( 'sticky', $post_meta, true ) && is_sticky() ) {

    					$has_meta = true;
    					?>
    					<li class="post-sticky meta-wrapper">
    						<span class="meta-icon">
                                <span data-uk-icon="icon: basho-award; ratio: .55"></span>
    						</span>
    						<span class="meta-text">
    							<?php esc_html_e( 'Featured', 'basho' ); ?>
    						</span>
    					</li>
    					<?php

    				}

    				// Tags.
    				if ( in_array( 'tags', $post_meta, true ) && has_tag() ) {

    					$has_meta = true;
    					?>
    					<li class="post-tags meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php esc_html_e( 'Tags', 'basho' ); ?></span>
                                <span data-uk-icon="icon: basho-hash; ratio: .55"></span>
    						</span>
    						<span class="meta-text">
    							<?php the_tags( '', ' ', '' ); ?>
    						</span>
    					</li>
    					<?php

    				}

                    /**
    				 * Fires after post meta html display.
    				 *
    				 * Allow output of additional post meta info to be added by child themes and plugins.
    				 *
    				 * @param int   $post_ID Post ID.
    				 */
    				do_action( 'basho_after_post_meta_list', $post_id );

                    ?>

                </ul>
            </div>

            <?php

            wp_reset_postdata();

    		$meta_output = ob_get_clean();

    		// If there is meta to output, return it.
    		if ( $has_meta && $meta_output ) {

    			return $meta_output;

    		}

        }

    }
}

if ( ! function_exists( 'basho_get_blog_grid_columns_classes' ) ) {
    /**
     * Get blog grid classes based on Customizer options.
     */
    function basho_get_blog_grid_columns_classes() {

        $classes = '';

        // Number of columns on extra small screens (phones in portrait mode, small smartphones).
        $columns_xs  = get_theme_mod( 'basho_blog_grid_columns_xs', 2 );

        switch ( $columns_xs ) {
        	case 1:
        		$classes .= ' uk-child-width-1-1';
        		break;
        	case 2:
        		$classes .= ' uk-child-width-1-2';
        		break;
        	default:
        		$classes .= ' uk-child-width-1-2';
        }

        // Number of columns on small screens (phones in a landscape mode).
        $columns_s  = get_theme_mod( 'basho_blog_grid_columns_s', 3 );

        switch ( $columns_s ) {
        	case 1:
        		$classes .= ' uk-child-width-1-1@s';
        		break;
        	case 2:
        		$classes .= ' uk-child-width-1-2@s';
        		break;
        	case 3:
        		$classes .= ' uk-child-width-1-3@s';
        		break;
        	default:
        		$classes .= ' uk-child-width-1-3@s';
        }

        // Number of columns on medium screens (tablets).
        $columns_m  = get_theme_mod( 'basho_blog_grid_columns_m', 4 );

        switch ( $columns_m ) {
        	case 1:
        		$classes .= ' uk-child-width-1-1@m';
        		break;
        	case 2:
        		$classes .= ' uk-child-width-1-2@m';
        		break;
        	case 3:
        		$classes .= ' uk-child-width-1-3@m';
        		break;
        	case 4:
        		$classes .= ' uk-child-width-1-4@m';
        		break;
        	case 5:
        		$classes .= ' uk-child-width-1-5@m';
        		break;
        	case 6:
        		$classes .= ' uk-child-width-1-6@m';
        		break;
        	default:
        		$classes .= ' uk-child-width-1-4@m';
        }

        // Number of columns on large screens (laptops).
        $columns_l  = get_theme_mod( 'basho_blog_grid_columns_l', 5 );

        switch ( $columns_l ) {
        	case 1:
        		$classes .= ' uk-child-width-1-1@l';
        		break;
        	case 2:
        		$classes .= ' uk-child-width-1-2@l';
        		break;
        	case 3:
        		$classes .= ' uk-child-width-1-3@l';
        		break;
        	case 4:
        		$classes .= ' uk-child-width-1-4@l';
        		break;
        	case 5:
        		$classes .= ' uk-child-width-1-5@l';
        		break;
        	case 6:
        		$classes .= ' uk-child-width-1-6@l';
        		break;
        	default:
        		$classes .= ' uk-child-width-1-5@l';
        }

        // Number of columns on extra large screens (large monitors).
        $columns_xl = get_theme_mod( 'basho_blog_grid_columns_xl', 6 );

        switch ( $columns_xl ) {
        	case 1:
        		$classes .= ' uk-child-width-1-1@xl';
        		break;
        	case 2:
        		$classes .= ' uk-child-width-1-2@xl';
        		break;
        	case 3:
        		$classes .= ' uk-child-width-1-3@xl';
        		break;
        	case 4:
        		$classes .= ' uk-child-width-1-4@xl';
        		break;
        	case 5:
        		$classes .= ' uk-child-width-1-5@xl';
        		break;
        	case 6:
        		$classes .= ' uk-child-width-1-6@xl';
        		break;
        	default:
        		$classes .= ' uk-child-width-1-6@xl';
        }

        return $classes;

    }
}
