\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /usr/local/sitepad/editor/site-data/plugins/kkart-pro/includes/

Viewing File: class-kkart-embed.php

<?php
/**
 * Kkart product embed
 *
 * @version  2.4.11
 * @package  Kkart\Classes\Embed
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Embed Class which handles any Kkart Products that are embedded on this site or another site.
 */
class KKART_Embed {

	/**
	 * Init embed class.
	 *
	 * @since 2.4.11
	 */
	public static function init() {

		// Filter all of the content that's going to be embedded.
		add_filter( 'the_excerpt_embed', array( __CLASS__, 'the_excerpt' ), 10 );

		// Make sure no comments display. Doesn't make sense for products.
		add_action( 'embed_content_meta', array( __CLASS__, 'remove_comments_button' ), 5 );

		// In the comments place let's display the product rating.
		add_action( 'embed_content_meta', array( __CLASS__, 'get_ratings' ), 5 );

		// Add some basic styles.
		add_action( 'embed_head', array( __CLASS__, 'print_embed_styles' ) );
	}

	/**
	 * Remove comments button on product embeds.
	 *
	 * @since 2.6.0
	 */
	public static function remove_comments_button() {
		if ( self::is_embedded_product() ) {
			remove_action( 'embed_content_meta', 'print_embed_comments_button' );
		}
	}

	/**
	 * Check if this is an embedded product - to make sure we don't mess up regular posts.
	 *
	 * @since 2.4.11
	 * @return bool
	 */
	public static function is_embedded_product() {
		if ( function_exists( 'is_embed' ) && is_embed() && is_product() ) {
			return true;
		}
		return false;
	}

	/**
	 * Create the excerpt for embedded products - we want to add the buy button to it.
	 *
	 * @since 2.4.11
	 * @param string $excerpt Embed short description.
	 * @return string
	 */
	public static function the_excerpt( $excerpt ) {
		global $post;

		// Get product.
		$_product = kkart_get_product( get_the_ID() );

		// Make sure we're only affecting embedded products.
		if ( self::is_embedded_product() ) {
			echo '<p><span class="kkart-embed-price">' . $_product->get_price_html() . '</span></p>'; // WPCS: XSS ok.

			if ( ! empty( $post->post_excerpt ) ) {
				ob_start();
				kkart_template_single_excerpt();
				$excerpt = ob_get_clean();
			}

			// Add the button.
			$excerpt .= self::product_buttons();
		}
		return $excerpt;
	}

	/**
	 * Create the button to go to the product page for embedded products.
	 *
	 * @since 2.4.11
	 * @return string
	 */
	public static function product_buttons() {
		$_product = kkart_get_product( get_the_ID() );
		$buttons  = array();
		$button   = '<a href="%s" class="wp-embed-more kkart-embed-button">%s</a>';

		if ( $_product->is_type( 'simple' ) && $_product->is_purchasable() && $_product->is_in_stock() ) {
			$buttons[] = sprintf( $button, esc_url( add_query_arg( 'add-to-cart', get_the_ID(), kkart_get_cart_url() ) ), esc_html__( 'Buy now', 'kkart' ) );
		}

		$buttons[] = sprintf( $button, get_the_permalink(), esc_html__( 'Read more', 'kkart' ) );

		return '<p>' . implode( ' ', $buttons ) . '</p>';
	}

	/**
	 * Prints the markup for the rating stars.
	 *
	 * @since 2.4.11
	 */
	public static function get_ratings() {
		// Make sure we're only affecting embedded products.
		if ( ! self::is_embedded_product() ) {
			return;
		}

		$_product = kkart_get_product( get_the_ID() );

		if ( $_product && $_product->get_average_rating() > 0 ) {
			?>
			<div class="kkart-embed-rating">
				<?php
					printf(
						/* translators: %s: average rating */
						esc_html__( 'Rated %s out of 5', 'kkart' ),
						esc_html( $_product->get_average_rating() )
					);
				?>
			</div>
			<?php
		}
	}

	/**
	 * Basic styling.
	 */
	public static function print_embed_styles() {
		if ( ! self::is_embedded_product() ) {
			return;
		}
		?>
		<style type="text/css">
			a.kkart-embed-button {
				border-radius: 4px;
				border: 1px solid #ddd;
				box-shadow: 0px 1px 0 0px rgba(0, 0, 0, 0.05);
				display:inline-block;
				padding: .5em;
			}
			a.kkart-embed-button:hover, a.kkart-embed-button:focus {
				border: 1px solid #ccc;
				box-shadow: 0px 1px 0 0px rgba(0, 0, 0, 0.1);
				color: #999;
				text-decoration: none;
			}
			.wp-embed-excerpt p {
				margin: 0 0 1em;
			}
			.kkart-embed-price {
				display: block;
				opacity: .75;
				font-weight: 700;
				margin-top: -.75em;
			}
			.kkart-embed-rating {
				display: inline-block;
			}
		</style>
		<?php
	}
}

KKART_Embed::init();