get_type() !== Site_Type::SITE_TEMPLATE && $site->get_type() !== Site_Type::CUSTOMER_OWNED)) { $this->message = __('The Template ID does not correspond to a valid Template', 'wp-ultimo'); return false; } // end if; if ($site->get_type() === Site_Type::CUSTOMER_OWNED) { if (!wu_get_setting('allow_own_site_as_template')) { $this->message = __('You can not use your sites as template', 'wp-ultimo'); return false; } // end if; $customer = wu_get_current_customer(); if (!$customer || $site->get_customer_id() !== $customer->get_id()) { $this->message = __('The selected template is not available.', 'wp-ultimo'); return false; } // end if; return true; } // end if; $allowed_templates = false; $product_ids_or_slugs = Checkout::get_instance()->request_or_session('products', array()); $product_ids_or_slugs = array_unique($product_ids_or_slugs); if ($product_ids_or_slugs) { $products = array_map('wu_get_product', $product_ids_or_slugs); $limits = new \WP_Ultimo\Objects\Limitations(); list($plan, $additional_products) = wu_segregate_products($products); $products = array_merge(array($plan), $additional_products); foreach ($products as $product) { $limits = $limits->merge($product->get_limitations()); } // end foreach; $allowed_templates = $limits->site_templates->get_available_site_templates(); } // end if; if (is_array($allowed_templates) && !in_array($template_id, $allowed_templates)) { // phpcs:ignore $this->message = __('The selected template is not available for this product.', 'wp-ultimo'); return false; } // end if; return true; } // end check; } // end class Site_Template;