PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.0-beta1
Elementor Website Builder – more than just a page builder v3.13.0-beta1
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / ai / connect / ai.php

ai.php in Elementor Website Builder – more than just a page builder 3.13.0-beta1, at modules/ai/connect/ai.php

119 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Ai\Connect;
3
4 use Elementor\Core\Common\Modules\Connect\Apps\Library;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 class Ai extends Library {
11 const API_URL = 'https://my.elementor.com/api/v2/ai/';
12
13 public function get_title() {
14 return esc_html__( 'AI', 'elementor' );
15 }
16
17 protected function get_api_url() {
18 return static::API_URL . '/';
19 }
20
21 public function get_usage() {
22 return $this->request(
23 'status/check',
24 [
25 'api_version' => ELEMENTOR_VERSION,
26 'site_lang' => get_bloginfo( 'language' ),
27 ],
28 true
29 );
30 }
31
32 public function set_get_started() {
33 return $this->request( 'status/get-started',
34 [
35 'api_version' => ELEMENTOR_VERSION,
36 'site_lang' => get_bloginfo( 'language' ),
37 ],
38 true
39 );
40 }
41
42 public function set_status_feedback( $response_id ) {
43 return $this->request(
44 'status/feedback/' . $response_id,
45 [
46 'api_version' => ELEMENTOR_VERSION,
47 'site_lang' => get_bloginfo( 'language' ),
48 ],
49 true
50 );
51 }
52
53 public function get_completion_text( $prompt ) {
54 return $this->request(
55 'text/completion',
56 [
57 'prompt' => $prompt,
58 'api_version' => ELEMENTOR_VERSION,
59 'site_lang' => get_bloginfo( 'language' ),
60 ],
61 true
62 );
63 }
64
65 public function get_edit_text( $input, $instruction ) {
66 return $this->request(
67 'text/edit',
68 [
69 'input' => $input,
70 'instruction' => $instruction,
71 'api_version' => ELEMENTOR_VERSION,
72 'site_lang' => get_bloginfo( 'language' ),
73 ],
74 true
75 );
76 }
77
78 public function get_custom_code( $prompt, $language ) {
79 return $this->request(
80 'text/custom-code',
81 [
82 'prompt' => $prompt,
83 'language' => $language,
84 'api_version' => ELEMENTOR_VERSION,
85 'site_lang' => get_bloginfo( 'language' ),
86 ],
87 true
88 );
89 }
90
91 public function get_custom_css( $prompt, $html_markup, $element_id ) {
92 return $this->request(
93 'text/custom-css',
94 [
95 'prompt' => $prompt,
96 'html_markup' => $html_markup,
97 'element_id' => $element_id,
98 'api_version' => ELEMENTOR_VERSION,
99 'site_lang' => get_bloginfo( 'language' ),
100 ],
101 true
102 );
103 }
104
105 public function create_images( $prompt ) {
106 return $this->request(
107 'image/generations',
108 [
109 'prompt' => $prompt,
110 'api_version' => ELEMENTOR_VERSION,
111 'site_lang' => get_bloginfo( 'language' ),
112 ],
113 true
114 );
115 }
116
117 protected function init() {}
118 }
119