Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.64.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : vc-ai-ajax.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	die( '-1' );
}

add_action( 'wp_ajax_wpb_ai_api_get_response', 'wpbGetAiApiResponse' );
add_action( 'wp_ajax_wpb_ai_generate_content_check_cache', 'wpbGetGenerateAiContentCheckCache' );
add_action( 'wp_ajax_wpb_ai_get_modal_data', 'wpbGetModalAiData' );

if ( ! function_exists( 'wpbGetAiApiResponse' ) ) {
	/**
	 * Get response from AI API.
	 *
	 * @sine 7.2
	 */
	function wpbGetAiApiResponse() {
		vc_user_access()->checkAdminNonce()->validateDie();

		require_once vc_path_dir( 'CORE_DIR', 'ai/class-vc-ai-api-connector.php' );
		$ai_api_connector = new Vc_Ai_Api_Connector();

		$content = $ai_api_connector->get_ai_content( vc_request_param( 'data' ) );

		if ( is_wp_error( $content ) ) {
			wp_send_json_error( $content );
		}

		wp_send_json_success( $content );
	}
}

if ( ! function_exists( 'wpbGetGenerateAiContentCheckCache' ) ) {
	/**
	 * Get content generated by AI.
	 *
	 * @sine 7.2
	 */
	function wpbGetGenerateAiContentCheckCache() {
		vc_user_access()->checkAdminNonce()->validateDie();

		require_once vc_path_dir( 'CORE_DIR', 'ai/class-vc-ai-api-connector.php' );
		$api_connector = new Vc_Ai_Api_Connector();

		$content = $api_connector->get_api_response_data_from_cache( vc_request_param( 'data' ) );
		if ( is_wp_error( $content ) ) {
			wp_send_json_error( $content );
		}

		wp_send_json_success( $content );
	}
}

if ( ! function_exists( 'wpbGetModalAiData' ) ) {
	/**
	 * Gen AI modal content.
	 *
	 * @sine 7.2
	 */
	function wpbGetModalAiData() {
		vc_user_access()->checkAdminNonce()->validateDie();

		require_once vc_path_dir( 'CORE_DIR', 'ai/class-vc-ai-modal-controller.php' );
		$modal_controller = new Vc_Ai_Modal_Controller();

		$data = $modal_controller->get_modal_data( vc_request_param( 'data' ) );

		// in case of error we should it inside modal content
		wp_send_json_success( $data );
	}
}
© 2025 XylotrechusZ