Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/brizy-pro   php

Repository URL to install this package:

Version: 2.3.7 

/ placeholders / simple-product-aware.php

<?php

use BrizyPlaceholders\ContentPlaceholder;
use BrizyPlaceholders\ContextInterface;

class BrizyPro_Content_Placeholders_SimpleProductAware extends Brizy_Content_Placeholders_Simple {

    /**
     * @param ContextInterface $context
     * @param ContentPlaceholder $contentPlaceholder
     * @return false|mixed|string
     */
    public function getValue( ContextInterface $context, ContentPlaceholder $contentPlaceholder )  {

		global $product;

		if ( ! $product ) {
			return '';
		}

		add_action( 'woocommerce_locate_template', [ $this, 'woocommerce_locate_template' ], 9999, 3 );

		ob_start(); ob_clean();
		parent::getValue( $context, $contentPlaceholder );
		$html = ob_get_clean();

		remove_action( 'woocommerce_locate_template', [ $this, 'woocommerce_locate_template' ], 9999 );

		return $html;
	}

	public function woocommerce_locate_template( $template, $template_name, $template_path ) {
		return WC()->plugin_path() . '/templates/' . $template_name;
	}
}