# ultimate-store-kit/2.0.1/includes/builder/builder-widget-base.php

Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder, version 2.0.1. 72 lines.

- Page: https://pluginprobe.com/plugins/ultimate-store-kit/2.0.1/code/includes/builder/builder-widget-base.php
- Raw: https://pluginprobe.com/plugins/ultimate-store-kit/2.0.1/raw/includes/builder/builder-widget-base.php
- Modified: 2024-08-15T09:47:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ultimate-store-kit/2.0.1/code/includes/builder/builder-widget-base.php#L10-L20`.

```php
<?php

namespace UltimateStoreKit\Includes\Builder;

use Elementor\Widget_Base;



if ( ! defined( 'ABSPATH' ) ) {
	exit;
} // Exit if accessed directly

abstract class Builder_Widget_Base extends Widget_Base {

	public $__temp_query = null;
	public $__product_data = false;


	/**
	 * Check if we currently in Elementor mode
	 *
	 * @return void
	 */
	public function in_elementor() {
		$result = false;

		if ( wp_doing_ajax() ) {
			$result = isset($this->is_elementor_ajax);
		} elseif (
			\Elementor\Plugin::instance()->editor->is_edit_mode()
			|| \Elementor\Plugin::instance()->preview->is_preview_mode()
		) {
			$result = true;
		}

		return apply_filters( 'ultimate-store-kit-builder/in-elementor', $result );
	}

	protected function is_ultimate_builder_editor() {

		if ( ! $this->in_elementor() && ! wp_doing_ajax() )
			return;
		if ( get_post_type() !== Meta::POST_TYPE )
			return;

		return true;
	}


	/**
	 * Set editor data for ajax save only
	 */
	public function usk_set_single_post_preview_data() {

		if ( ! $this->is_ultimate_builder_editor() ) {
			return;
		}

		global $post;

		$templateId = get_transient( 'ultimate_store_template_id_' . get_current_user_id() );
		$posts      = get_transient( 'ultimate_store_template_sample_post_' . get_current_user_id() );

		if ( $posts instanceof \WP_Query && $posts->have_posts() && $templateId == $post->ID ) {
			foreach ( $posts->posts as $post ) {
				$GLOBALS['post'] = $post;
				setup_postdata( $post );
			}
		}
	}
}

```
