<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
if ( ! class_exists( 'Draly_Dropshipping_Starter_Helper' ) ) {
	class Draly_Dropshipping_Starter_Helper {
		public static function get_option( $key, $default = '' ) {
			global $draly;
			if ( empty( $draly ) ) {
				$draly             = get_option( 'villco', true );
				$GLOBALS['villco'] = $draly;
			}
			$value = $default;
			if ( isset( $_GET[ $key ] ) ) {
				if ( is_array( $_GET[ $key ] ) ) {
					$value = array_map( 'sanitize_text_field', $_GET[ $key ] );
				} else {
					$value = sanitize_text_field( $_GET[ $key ] );
				}

				return $value;
			}
			if ( isset( $draly[ $key ] ) && $draly[ $key ] != '' ) {
				if ( is_array( $draly[ $key ] ) ) {
					$value = array_map( 'sanitize_text_field', $draly[ $key ] );
				} else {
					$value = sanitize_text_field( $draly[ $key ] );
				}
			}

			return apply_filters( 'draly_get_option', $value, $key );
		}

		public static function get_logo() {
			$logo = self::get_option( 'logo' );
			$html = '<a href="' . esc_url( home_url( '/' ) ) . '">' . esc_html( get_bloginfo( 'name' ) ) . '</a>';
			if ( ! empty( $logo['id'] ) ) {
				$html = '<a href="' . esc_url( home_url( '/' ) ) . '">' . wp_get_attachment_image( $logo['id'], 'full' ) . '</a>';
			}
			echo apply_filters( 'draly_site_logo', $html );
		}

		public static function get_attachment_image( $attachment_id, $src, $width, $height ) {
			$html = '';
			if ( $src ) {
				$hwstring   = image_hwstring( $width, $height );
				$size_class = $width . 'x' . $height;
				$attachment = get_post( $attachment_id );
				$attr       = array(
					'src'   => $src,
					'class' => "attachment-$size_class size-$size_class",
					'alt'   => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ),
				);
				// Generate 'srcset' and 'sizes' if not already present.
				/**
				 * Filters the list of attachment image attributes.
				 *
				 * @param array $attr Attributes for the image markup.
				 * @param WP_Post $attachment Image attachment post.
				 * @param string|array $size Requested size. Image size or array of width and height values (in that order). Default 'thumbnail'.
				 *
				 * @since 2.8.0
				 *
				 */
				$attr = apply_filters( 'draly_get_attachment_image_attributes', $attr, $attachment );
				$attr = array_map( 'esc_attr', $attr );
				$html = rtrim( "<img $hwstring" );
				foreach ( $attr as $name => $value ) {
					$html .= " $name=" . '"' . $value . '"';
				}
				$html .= ' />';
			}

			return $html;
		}

		public static function resize_image( $attachment_id = null, $width = false, $height = false, $crop = false ) {
			$original  = false;
			$image_src = array();
			$vt_image  = '';
			if ( is_singular() && ! $attachment_id ) {
				if ( has_post_thumbnail() && ! post_password_required() ) {
					$attachment_id = get_post_thumbnail_id();
				}
			}
			if ( $attachment_id ) {
				$image_src        = wp_get_attachment_image_src( $attachment_id, 'full' );
				$actual_file_path = get_attached_file( $attachment_id );
			}
			if ( $width == false && $height == false ) {
				$original = true;
			}
			if ( ! empty( $actual_file_path ) && file_exists( $actual_file_path ) ) {
				if ( $original == false && ( $image_src[1] > $width || $image_src[2] > $height ) ) {
					$file_info        = pathinfo( $actual_file_path );
					$extension        = '.' . $file_info['extension'];
					$no_ext_path      = $file_info['dirname'] . '/' . $file_info['filename'];
					$cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . $extension;
					/* start */
					if ( file_exists( $cropped_img_path ) ) {
						$cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
						$vt_image        = array(
							'url'    => $cropped_img_url,
							'width'  => $width,
							'height' => $height,
							'img'    => self::get_attachment_image( $attachment_id, $cropped_img_url, $width, $height ),
						);

						return $vt_image;
					}
					if ( $crop == false ) {
						$proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
						$resized_img_path  = $no_ext_path . '-' . $proportional_size[0] . 'x' . $proportional_size[1] . $extension;
						if ( file_exists( $resized_img_path ) ) {
							$resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
							$vt_image        = array(
								'url'    => $resized_img_url,
								'width'  => $proportional_size[0],
								'height' => $proportional_size[1],
								'img'    => self::get_attachment_image( $attachment_id, $resized_img_url, $proportional_size[0], $proportional_size[1] ),
							);

							return $vt_image;
						}
					}
					/*no cache files - let's finally resize it*/
					$img_editor = wp_get_image_editor( $actual_file_path );
					if ( is_wp_error( $img_editor ) || is_wp_error( $img_editor->resize( $width, $height, $crop ) ) ) {
						return array(
							'url'    => '',
							'width'  => '',
							'height' => '',
							'img'    => '',
						);
					}
					$new_img_path = $img_editor->generate_filename();
					if ( is_wp_error( $img_editor->save( $new_img_path ) ) ) {
						return array(
							'url'    => '',
							'width'  => '',
							'height' => '',
							'img'    => '',
						);
					}
					if ( ! is_string( $new_img_path ) ) {
						return array(
							'url'    => '',
							'width'  => '',
							'height' => '',
							'img'    => '',
						);
					}
					$new_img_size = getimagesize( $new_img_path );
					$new_img      = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
					$vt_image     = array(
						'url'    => $new_img,
						'width'  => $new_img_size[0],
						'height' => $new_img_size[1],
						'img'    => self::get_attachment_image( $attachment_id, $new_img, $new_img_size[0], $new_img_size[1] ),
					);

					return $vt_image;
				}
				$vt_image = array(
					'url'    => $image_src[0],
					'width'  => $image_src[1],
					'height' => $image_src[2],
					'img'    => self::get_attachment_image( $attachment_id, $image_src[0], $image_src[1], $image_src[2] ),
				);
			}

			return $vt_image;
		}

		public static function carousel_data_attributes( $prefix = '', $atts = [] ) {
			$responsive = array();
			$slick      = array();
			$results    = '';
			if ( isset( $atts[ $prefix . 'autoplay' ] ) && $atts[ $prefix . 'autoplay' ] == 'true' ) {
				$slick['autoplay'] = true;
			}
			if ( isset( $atts[ $prefix . 'autoplayspeed' ] ) && $atts[ $prefix . 'autoplay' ] == 'true' ) {
				$slick['autoplaySpeed'] = intval( $atts[ $prefix . 'autoplayspeed' ] );
			}
			if ( isset( $atts[ $prefix . 'navigation' ] ) ) {
				$slick['arrows'] = $atts[ $prefix . 'navigation' ] == 'true' ? true : false;
			}
			if ( isset( $atts[ $prefix . 'slide_margin' ] ) ) {
				$slick['slidesMargin'] = intval( $atts[ $prefix . 'slide_margin' ] );
			}
			if ( isset( $atts[ $prefix . 'dots' ] ) ) {
				$slick['dots'] = $atts[ $prefix . 'dots' ] == 'true' ? true : false;
			}
			if ( isset( $atts[ $prefix . 'loop' ] ) ) {
				$slick['infinite'] = $atts[ $prefix . 'loop' ] == 'true' ? true : false;
			}
			if ( isset( $atts[ $prefix . 'fade' ] ) ) {
				$slick['fade'] = $atts[ $prefix . 'fade' ] == 'true' ? true : false;
			}
			if ( isset( $atts[ $prefix . 'slidespeed' ] ) ) {
				$slick['speed'] = intval( $atts[ $prefix . 'slidespeed' ] );
			}
			if ( isset( $atts[ $prefix . 'ls_items' ] ) ) {
				$slick['slidesToShow'] = intval( $atts[ $prefix . 'ls_items' ] );
			}
			if ( isset( $atts[ $prefix . 'slidestoscroll' ] ) ) {
				$slick['slidesToScroll'] = intval( $atts[ $prefix . 'slidestoscroll' ] );
			}
			if ( isset( $atts[ $prefix . 'vertical' ] ) && $atts[ $prefix . 'vertical' ] == 'true' ) {
				$slick['vertical'] = true;
			}
			if ( isset( $atts[ $prefix . 'center_mode' ] ) && $atts[ $prefix . 'center_mode' ] == 'true' ) {
				$slick['centerMode'] = true;
			}
			if ( isset( $atts[ $prefix . 'focus_select' ] ) && $atts[ $prefix . 'focus_select' ] == 'true' ) {
				$slick['focusOnSelect'] = true;
			}
			if ( isset( $atts[ $prefix . 'verticalswiping' ] ) && $atts[ $prefix . 'verticalswiping' ] == 'true' ) {
				$slick['verticalSwiping'] = true;
			}
			if ( isset( $atts[ $prefix . 'number_row' ] ) ) {
				$slick['rows'] = intval( $atts[ $prefix . 'number_row' ] );
			}
			$results .= ' data-slick = ' . json_encode( $slick ) . ' ';
			if ( isset( $atts[ $prefix . 'ts_items' ] ) ) {
				$responsive[] = array(
					'breakpoint' => 576,
					'settings'   => array(
						'slidesToShow' => intval( $atts[ $prefix . 'ts_items' ] ),
					),
				);
			}
			if ( isset( $atts[ $prefix . 'xs_items' ] ) ) {
				$responsive[] = array(
					'breakpoint' => 768,
					'settings'   => array(
						'slidesToShow' => intval( $atts[ $prefix . 'xs_items' ] ),
					),
				);
			}
			if ( isset( $atts[ $prefix . 'sm_items' ] ) ) {
				$responsive[] = array(
					'breakpoint' => 992,
					'settings'   => array(
						'slidesToShow' => intval( $atts[ $prefix . 'sm_items' ] ),
					),
				);
			}
			if ( isset( $atts[ $prefix . 'md_items' ] ) ) {
				$responsive[] = array(
					'breakpoint' => 1200,
					'settings'   => array(
						'slidesToShow' => intval( $atts[ $prefix . 'md_items' ] ),
					),
				);
			}
			if ( isset( $atts[ $prefix . 'lg_items' ] ) ) {
				$responsive[] = array(
					'breakpoint' => 1400,
					'settings'   => array(
						'slidesToShow' => intval( $atts[ $prefix . 'lg_items' ] ),
					),
				);
			}
			if ( isset( $atts[ $prefix . 'responsive_vertical' ] ) && $atts[ $prefix . 'responsive_vertical' ] >= 576 ) {
				$responsive[0]['settings']['vertical'] = false;
			}
			if ( isset( $atts[ $prefix . 'responsive_vertical' ] ) && $atts[ $prefix . 'responsive_vertical' ] >= 768 ) {
				$responsive[1]['settings']['vertical'] = false;
			}
			if ( isset( $atts[ $prefix . 'responsive_vertical' ] ) && $atts[ $prefix . 'responsive_vertical' ] >= 992 ) {
				$responsive[2]['settings']['vertical'] = false;
			}
			if ( isset( $atts[ $prefix . 'responsive_vertical' ] ) && $atts[ $prefix . 'responsive_vertical' ] >= 1200 ) {
				$responsive[3]['settings']['vertical'] = false;
			}
			if ( isset( $atts[ $prefix . 'responsive_vertical' ] ) && $atts[ $prefix . 'responsive_vertical' ] >= 1400 ) {
				$responsive[4]['settings']['vertical'] = false;
			}
			if ( isset( $atts[ $prefix . 'responsive_rows' ] ) && $atts[ $prefix . 'responsive_rows' ] >= 576 ) {
				$responsive[0]['settings']['rows'] = 2;
			}
			if ( isset( $atts[ $prefix . 'responsive_rows' ] ) && $atts[ $prefix . 'responsive_rows' ] >= 768 ) {
				$responsive[1]['settings']['rows'] = 2;
			}
			if ( isset( $atts[ $prefix . 'responsive_rows' ] ) && $atts[ $prefix . 'responsive_rows' ] >= 992 ) {
				$responsive[2]['settings']['rows'] = 2;
			}
			if ( isset( $atts[ $prefix . 'responsive_rows' ] ) && $atts[ $prefix . 'responsive_rows' ] >= 1200 ) {
				$responsive[3]['settings']['rows'] = 2;
			}
			if ( isset( $atts[ $prefix . 'responsive_rows' ] ) && $atts[ $prefix . 'responsive_rows' ] >= 1400 ) {
				$responsive[4]['settings']['rows'] = 2;
			}
			if ( isset( $atts[ $prefix . 'ts_slide_margin' ] ) ) {
				$responsive[0]['settings']['slidesMargin'] = $atts[ $prefix . 'ts_slide_margin' ];
			}
			if ( isset( $atts[ $prefix . 'xs_slide_margin' ] ) ) {
				$responsive[1]['settings']['slidesMargin'] = $atts[ $prefix . 'xs_slide_margin' ];
			}
			if ( isset( $atts[ $prefix . 'sm_slide_margin' ] ) ) {
				$responsive[2]['settings']['slidesMargin'] = $atts[ $prefix . 'sm_slide_margin' ];
			}
			if ( isset( $atts[ $prefix . 'md_slide_margin' ] ) ) {
				$responsive[3]['settings']['slidesMargin'] = $atts[ $prefix . 'md_slide_margin' ];
			}
			if ( isset( $atts[ $prefix . 'lg_slide_margin' ] ) ) {
				$responsive[4]['settings']['slidesMargin'] = $atts[ $prefix . 'lg_slide_margin' ];
			}
			$results .= 'data-responsive = ' . json_encode( $responsive ) . ' ';
			$results = apply_filters( 'draly_filter_carousel_data_attributes', $results, $prefix, $atts );

			return htmlspecialchars( $results, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' );
		}

		public static function post_format() {
			$thumb_classes = 'post-thumb';
			if ( has_post_thumbnail() ) : ?>
                <div class="<?php echo esc_attr( $thumb_classes ); ?>">
					<?php
					if ( is_single() ) {
						if ( ! empty( get_the_post_thumbnail() ) ) {
							the_post_thumbnail( 'full' );
						} else { ?>
                            <img src="<?php echo esc_url( get_theme_file_uri( '/assets/images/placeholder.jpg' ) ) ?>"
                                 alt="<?php echo esc_attr__( 'placeholder', 'draly-dropshipping-starter' ); ?>">
						<?php }
					} else {
						echo '<a href="' . get_permalink() . '" tabindex="-1">';
						if ( ! empty( get_the_post_thumbnail() ) ) {
							the_post_thumbnail( 'full' );
						} else { ?>
                            <img src="<?php echo esc_url( get_theme_file_uri( '/assets/images/placeholder.jpg' ) ) ?>"
                                 alt="<?php echo esc_attr__( 'placeholder', 'draly-dropshipping-starter' ); ?>">
						<?php }
						echo '</a>';
					}
					?>
                </div>
			<?php
			endif;
		}

		public static function post_title() {
			?>
            <h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
			<?php
		}

		public static function post_readmore() {
			?>
            <a href="<?php the_permalink(); ?>"
               class="readmore"><?php echo esc_html__( 'Read more', 'draly-dropshipping-starter' ); ?>
                <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <g>
                        <path d="M15.931 7.95017C15.936 7.32197 15.942 6.69449 15.9492 6.06773L15.9908 1.83494C15.9908 1.72701 15.9908 1.61529 15.9945 1.50519C15.9977 1.30119 16.001 1.09071 15.9994 0.881313V0.863504C15.9993 0.658008 15.9196 0.460713 15.7773 0.31385C15.6351 0.166988 15.4416 0.0822286 15.2383 0.0777153L8.40629 0.0102541L8.1083 0.00593659C7.89521 0 7.67465 0 7.45569 0H7.44554C7.33982 6.74099e-05 7.23518 0.0215996 7.13785 0.0633185C7.04051 0.105037 6.95246 0.166093 6.87892 0.24286C6.80877 0.314342 6.75367 0.399446 6.71696 0.493037C6.68024 0.586628 6.66267 0.686765 6.6653 0.787407C6.66798 0.990785 6.74832 1.18525 6.88954 1.33018C7.03076 1.4751 7.22193 1.55927 7.42312 1.5651L13.3457 1.62339L4.23059 10.6605C4.15572 10.736 4.0967 10.8261 4.05706 10.9252C4.01742 11.0243 3.99797 11.1305 3.99988 11.2374C3.99985 11.3383 4.02009 11.4382 4.05938 11.531C4.09867 11.6237 4.15619 11.7075 4.22846 11.7771C4.37267 11.92 4.56621 12.0005 4.76815 12.0017C4.97008 12.0029 5.16456 11.9247 5.31043 11.7836L14.4309 2.74162L14.4015 5.78871L14.3855 7.74779C14.3855 7.85302 14.3828 7.9588 14.3812 8.06458C14.378 8.2729 14.3743 8.48824 14.3759 8.7025V8.71869C14.376 8.82549 14.3974 8.93116 14.4388 9.02943C14.4802 9.1277 14.5407 9.21657 14.6167 9.29076C14.6872 9.36162 14.7713 9.41729 14.8637 9.4544C14.9561 9.4915 15.0551 9.50927 15.1545 9.50663C15.3564 9.50431 15.5495 9.4229 15.6931 9.27954C15.8368 9.13619 15.9198 8.94208 15.9246 8.73812L15.931 7.95017Z"
                              fill="currentColor"/>
                    </g>
                    <defs>
                        <filter id="filter0_d_97_139" x="0" y="0" width="20" height="20" filterUnits="userSpaceOnUse"
                                color-interpolation-filters="sRGB">
                            <feFlood flood-opacity="0" result="BackgroundImageFix"/>
                            <feColorMatrix in="SourceAlpha" type="matrix"
                                           values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
                            <feOffset dy="4"/>
                            <feGaussianBlur stdDeviation="2"/>
                            <feComposite in2="hardAlpha" operator="out"/>
                            <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
                            <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_97_139"/>
                            <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_97_139" result="shape"/>
                        </filter>
                        <clipPath>
                            <rect width="12" height="12" fill="white" transform="translate(4)"/>
                        </clipPath>
                    </defs>
                </svg>
            </a>
			<?php
		}

		public static function post_excerpt() {
			$post_excerpt_num_words = apply_filters( 'draly_post_excerpt_num_words', 50 );
			$post_excerpt_more      = apply_filters( 'draly_post_excerpt_more', '...' );
			?>
            <div class="post-content">
				<?php echo esc_html( wp_trim_words( apply_filters( 'the_excerpt', get_the_excerpt() ), esc_attr( $post_excerpt_num_words ), esc_html( $post_excerpt_more ) ) ); ?>
            </div>
			<?php
		}

		public static function post_full_content() {
			?>
            <div class="post-content">
				<?php
				/* translators: %s: Name of current post */
				the_content( sprintf(
						esc_html__( 'Continue reading %s', 'draly-dropshipping-starter' ),
						the_title( '<span class="screen-reader-text">', '</span>', false )
					)
				);
				wp_link_pages( array(
						'before'      => '<div class="post-pagination"><span class="title">' . esc_html__( 'Pages:', 'draly-dropshipping-starter' ) . '</span>',
						'after'       => '</div>',
						'link_before' => '<span>',
						'link_after'  => '</span>',
					)
				);
				?>
            </div>
			<?php
		}

		public static function post_author() {
			$option_key    = is_single() ? 'enable_post_author' : 'enable_blog_author';
			$enable_author = self::get_option( $option_key, true );
			if ( empty( $enable_author ) ) {
				return;
			}
			?>
            <div class="post-author">
                <span><?php echo esc_html__( 'By:', 'draly-dropshipping-starter' ); ?></span>
                <svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M8.49961 7.1252C10.0182 7.1252 11.2492 5.89416 11.2492 4.3756C11.2492 2.85703 10.0182 1.62599 8.49961 1.62599C6.98104 1.62599 5.75 2.85703 5.75 4.3756C5.75 5.89416 6.98104 7.1252 8.49961 7.1252Z"
                          stroke="currentColor" stroke-width="1.2"/>
                    <path d="M14.0004 12.2807C14.0004 13.9889 14.0004 15.374 8.50117 15.374C3.00195 15.374 3.00195 13.9889 3.00195 12.2807C3.00195 10.5725 5.46423 9.18741 8.50117 9.18741C11.5381 9.18741 14.0004 10.5725 14.0004 12.2807Z"
                          stroke="currentColor" stroke-width="1.2"/>
                </svg>
                <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) ); ?>"><?php the_author(); ?></a>
            </div>
			<?php
		}

		public static function post_date() {
			$option_key  = is_single() ? 'enable_post_date' : 'enable_blog_date';
			$enable_date = self::get_option( $option_key, true );
			if ( empty( $enable_date ) ) {
				return;
			}
			?>
            <div class="date">
                <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <g>
                        <path d="M15.9979 7.61088C15.9884 7.53428 15.9796 7.45767 15.9708 7.38107C15.9518 7.21363 15.9321 7.04212 15.9084 6.8706C15.7066 5.39659 15.0894 4.01048 14.129 2.87433C12.9515 1.46971 11.4358 0.56063 9.62582 0.172867C9.39534 0.123379 9.16215 0.096263 8.93574 0.0698246C8.82931 0.0576222 8.72288 0.0454199 8.61713 0.0311838C8.58392 0.0264384 8.54934 0.0196594 8.51681 0.0135582L8.46257 0.00338954L7.52032 0L7.50066 0.00406745L7.45118 0.014914C7.42271 0.0210152 7.39491 0.0271163 7.36712 0.0311838C7.26002 0.0460978 7.15359 0.0589781 7.04648 0.0711804C6.82143 0.0976188 6.58824 0.125413 6.35911 0.1749C4.40614 0.597238 2.81448 1.60325 1.637 3.16516C0.187016 5.08838 -0.303091 7.27125 0.17956 9.65342C0.519838 11.4001 1.45949 12.973 2.83617 14.1005C4.35259 15.3648 6.05068 15.9986 7.90265 15.9986C8.4813 15.9974 9.05844 15.9395 9.62582 15.8258C11.4019 15.4733 12.9115 14.573 14.1127 13.1501C15.084 12.0096 15.7085 10.6149 15.9125 9.13075C15.9362 8.95992 15.9559 8.78705 15.9748 8.62029C15.9837 8.54368 15.9925 8.46708 16.002 8.39048V7.63528L15.9979 7.61088ZM14.7452 7.99932C14.7452 11.7102 11.7218 14.735 8.00704 14.7432H7.9928C6.20394 14.7432 4.48835 14.0325 3.22344 12.7675C1.95852 11.5026 1.2479 9.7869 1.2479 7.99797C1.2479 6.20903 1.95852 4.49336 3.22344 3.2284C4.48835 1.96343 6.20394 1.25278 7.9928 1.25278H7.99891C8.88496 1.25233 9.76242 1.42653 10.5811 1.76542C11.3998 2.10431 12.1437 2.60124 12.7702 3.2278C13.3968 3.85436 13.8937 4.59827 14.2325 5.417C14.5714 6.23573 14.7456 7.11323 14.7452 7.99932Z"
                              fill="currentColor"/>
                        <path d="M11.707 7.93651C11.6563 7.93169 11.6054 7.9301 11.5545 7.93177H8.30743V3.59315C8.30952 3.51895 8.30453 3.44472 8.29251 3.37147C8.26729 3.2255 8.18983 3.09369 8.07458 3.00064C7.95932 2.90758 7.81415 2.85964 7.66615 2.86575C7.29671 2.87253 7.05606 3.14234 7.05606 3.55315C7.05606 4.86107 7.05606 6.16853 7.05606 7.47553V8.45647C7.05606 8.93914 7.30281 9.18386 7.78817 9.18386H11.6026C11.6381 9.18422 11.6737 9.18264 11.709 9.17912C11.8635 9.16339 12.0066 9.09079 12.1105 8.97543C12.2144 8.86007 12.2718 8.71019 12.2713 8.55492C12.2709 8.39966 12.2128 8.25009 12.1082 8.1353C12.0037 8.02051 11.8602 7.94869 11.7056 7.9338L11.707 7.93651Z"
                              fill="currentColor"/>
                    </g>
                    <defs>
                        <clipPath>
                            <rect width="16" height="16" fill="white"/>
                        </clipPath>
                    </defs>
                </svg>
				<?php echo esc_html( get_the_date() ); ?>
            </div>
			<?php
		}

		public static function post_comment() {
			$option_key     = is_single() ? 'enable_post_comment' : 'enable_blog_comment';
			$enable_comment = self::get_option( $option_key, true );
			if ( empty( $enable_comment ) ) {
				return;
			}
			?>
            <div class="post-comment">
                <svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <g>
                        <path d="M8.49972 16.0019C10.1359 16.0016 11.7271 15.4663 13.0309 14.4777C14.3346 13.489 15.2794 12.1013 15.7213 10.5259C16.1631 8.95045 16.0778 7.27378 15.4783 5.75136C14.8788 4.22894 13.798 2.94425 12.4007 2.09308C11.0033 1.2419 9.36595 0.870911 7.73817 1.03664C6.11038 1.20238 4.58141 1.89574 3.38426 3.01108C2.1871 4.12641 1.38741 5.60256 1.10705 7.21456C0.826693 8.82656 1.08104 10.486 1.83133 11.9401L0.997777 16.0019L5.05966 15.1684C6.08993 15.701 7.26023 16.0019 8.49972 16.0019Z"
                              stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
                        <path d="M5 8.5H5.00834V8.50834H5V8.5ZM8.75097 8.5H8.75931V8.50834H8.75097V8.5ZM12.5019 8.5H12.5103V8.50834H12.5019V8.5Z"
                              stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
                    </g>
                    <defs>
                        <clipPath>
                            <rect width="17" height="17" fill="white"/>
                        </clipPath>
                    </defs>
                </svg>
                <a href="<?php esc_url( the_permalink() ); ?>#comments">
					<?php
					$count = get_comments_number();
					$label = ( $count === 1 ) ? esc_html__( 'Comment', 'draly-dropshipping-starter' ) : esc_html__( 'Comments', 'draly-dropshipping-starter' );
					printf(
						'%1$s <span>%2$s</span>',
						esc_html( number_format_i18n( $count ) ),
						esc_html( $label )
					);
					?>
                </a>
            </div>
			<?php
		}

		public static function post_category() {
			if ( is_single() && ! self::get_option( 'enable_post_category', true ) ) {
				return;
			}
			$terms = get_the_terms( get_the_ID(), 'category' );
			if ( is_wp_error( $terms ) || empty( $terms ) ) {
				return;
			}
			echo '<div class="categories">';

			$term_links = array();
			foreach ( $terms as $term ) {
				$link = get_term_link( $term );
				if ( ! is_wp_error( $link ) ) {
					$term_links[] = sprintf(
						'<a href="%s">%s</a>',
						esc_url( $link ),
						esc_html( $term->name )
					);
				}
			}
			echo wp_kses_post( implode( ', ', $term_links ) );

			echo '</div>';
		}

		public static function post_tags() {
			if ( is_single() && ! self::get_option( 'enable_post_tags', true ) ) {
				return;
			}
			$tags_list = get_the_tag_list( '', '', '' );
			if ( ! empty( $tags_list ) ) {
				echo '<div class="tags"><span>' . esc_html__( 'Tags: ', 'draly-dropshipping-starter' ) . '</span>' . wp_kses_post( $tags_list ) . '</div>';
			}
		}

		public static function callback_comment( $comment, $args, $depth ) {
			if ( 'div' == $args['style'] ) {
				$tag       = 'div ';
				$add_below = 'comment';
			} else {
				$tag       = 'li ';
				$add_below = 'div-comment';
			}
			?>
            <<?php echo esc_attr( $tag ); ?><?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php echo esc_attr( get_comment_ID() ); ?>">
            <div class="comment_container">
                <div class="comment-avatar">
					<?php
					$width = apply_filters( 'draly_dropshipping_starter_avatar_width', 120 );
					echo get_avatar( $comment, $width );
					?>
                </div>
                <div class="comment-text commentmetadata">
                    <strong class="comment-author vcard">
						<?php printf( esc_html__( 'By %s', 'draly-dropshipping-starter' ), wp_kses_post( get_comment_author_link() ) ); ?>
                    </strong>
					<?php if ( '0' == $comment->comment_approved ) : ?>
                        <em class="comment-awaiting-moderation"><?php esc_html_e( 'Your comment is awaiting moderation.', 'draly-dropshipping-starter' ); ?></em>
                        <br/>
					<?php endif; ?>
                    <a href="<?php echo esc_url( htmlspecialchars( get_comment_link( get_comment_ID() ) ), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8' );; ?>"
                       class="comment-date">
						<?php echo '<time datetime="' . esc_attr( get_comment_date( 'c' ) ) . '">' . esc_html( get_comment_date() ) . '</time>'; ?>
                    </a>
					<?php edit_comment_link( __( 'Edit', 'draly-dropshipping-starter' ), '  ', '' ); ?>
					<?php comment_reply_link( array_merge( $args, array(
						'add_below' => $add_below,
						'depth'     => $depth,
						'max_depth' => $args['max_depth']
					) ) ); ?>
					<?php echo ( 'div' != $args['style'] ) ? '<div id="div-comment-' . esc_attr( get_comment_ID() ) . '" class="comment-content">' : '' ?>
					<?php comment_text(); ?>
					<?php echo 'div' != $args['style'] ? '</div>' : ''; ?>
                </div>
            </div>
			<?php
		}
	}
}
