# shopbuilder/1.0.0/app/Controllers/Admin/Ajax/DefaultTemplate.php

ShopBuilder – WooCommerce Builder For Elementor, version 1.0.0. 50 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/1.0.0/code/app/Controllers/Admin/Ajax/DefaultTemplate.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/1.0.0/raw/app/Controllers/Admin/Ajax/DefaultTemplate.php
- Modified: 2023-03-09T09:36:06+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/shopbuilder/1.0.0/code/app/Controllers/Admin/Ajax/DefaultTemplate.php#L10-L20`.

```php
<?php

namespace RadiusTheme\SB\Controllers\Admin\Ajax;

use RadiusTheme\SB\Helpers\BuilderFns;
use RadiusTheme\SB\Helpers\Fns;
use RadiusTheme\SB\Traits\SingletonTrait;

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
	exit( 'This script cannot be accessed directly.' );
}
/**
 * Default Template Switch.
 */
class DefaultTemplate {
	/**
	 * Singleton Trait.
	 */
	use SingletonTrait;
	/**
	 * Construct function
	 */
	private function __construct() {
		add_action( 'wp_ajax_rtsb_default_template', [ $this, 'response' ] );
	}

	/**
	 * Set Default Template.
	 *
	 * @return void
	 */
	public function response() {
		if ( ! Fns::verify_nonce() ) {
			wp_send_json_error();
		}
		$page_type   = isset( $_POST['template_type'] ) ? sanitize_text_field( wp_unslash( $_POST['template_type'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
		$page_id     = isset( $_POST['page_id'] ) && 'publish' == get_post_status ( $_POST['page_id']) ? absint( wp_unslash( $_POST['page_id'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Missing
		$option_name = BuilderFns::option_name( $page_type );
		update_option( $option_name, $page_id );
		$return = [
			'post_id'   => $page_id,
			'page_type' => $page_type,
		];
		wp_send_json_success( $return );
		wp_die();
	}

}

```
