__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Templately\API;
use Templately\Builder\Types\BaseTemplate;
use WP_Error;
use WP_REST_Request;
class ThemeBuilderApi extends API {
public function permission_check( WP_REST_Request $request ) {
if ( $request->get_route() === '/templately/v1/create-template' ) {
return wp_verify_nonce( $request->get_param( 'nonce' ), 'templately_nonce' );
}
return parent::permission_check( $request );
}
public function register_routes() {
$this->post( 'create-template', [ $this, 'create' ], [
'platform' => [
'required' => true,
'validate_callback' => function ( $param ) {
return is_string( $param ) && ( $param == 'elementor' || 'gutenberg' == $param );
}
],
'type' => [
'required' => true,
'validate_callback' => function ( $param ) {
return is_string( $param ) && array_key_exists( $param, templately()->theme_builder::$templates_manager->get_template_types() );
}
],
'title' => [
'required' => true,
]
] );
}
public function create( WP_REST_Request $request ) {
$platform = $request->get_param( 'platform' );
$template_type = $request->get_param( 'type' );
$title = $request->get_param( 'title' );
if ( empty( $title ) ) {
$title = '';
}
$post_data = [
'post_title' => $title,
'post_status' => 'publish',
'post_type' => 'templately_library'
];
/**
* @var BaseTemplate $template
*/
$template = templately()->theme_builder::$templates_manager->create( $template_type, $post_data, [ 'platform' => $platform ] );
if ( is_wp_error( $template ) ) {
/**
* @var WP_Error $template ;
*/
return $this->error( 'failed_template_creation', sprintf( __( 'Something went wrong. %s', 'templately' ), $template->get_error_message() ) );
}
return $this->success( $template->get_edit_url() );
}
}| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AIContent.php | File | 25.11 KB | 0640 |
|
| API.php | File | 6.33 KB | 0640 |
|
| Categories.php | File | 1.06 KB | 0640 |
|
| Conditions.php | File | 3.87 KB | 0640 |
|
| Dependencies.php | File | 12.41 KB | 0640 |
|
| FullSiteImport.php | File | 252 B | 0640 |
|
| Import.php | File | 6.81 KB | 0640 |
|
| Items.php | File | 14.25 KB | 0640 |
|
| Login.php | File | 8.08 KB | 0640 |
|
| MyClouds.php | File | 7.71 KB | 0640 |
|
| Profile.php | File | 5.42 KB | 0640 |
|
| SavedTemplates.php | File | 1.73 KB | 0640 |
|
| SignUp.php | File | 2.64 KB | 0640 |
|
| Tags.php | File | 866 B | 0640 |
|
| TemplateTypes.php | File | 1.85 KB | 0640 |
|
| ThemeBuilderApi.php | File | 1.82 KB | 0640 |
|
| WorkSpaces.php | File | 9.79 KB | 0640 |
|