PluginProbe
Elementor Website Builder – more than just a page builder / 3.27.4
Elementor Website Builder – more than just a page builder v3.27.4
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
← All changes | modules/ai/connect/ai.php +28 -47 4.0.73.27.4 View file →
@@ -6,9 +6,9 @@
6 6 use Elementor\Utils as ElementorUtils;
7 7 use Elementor\Plugin;
8 8
9 9 if ( ! defined( 'ABSPATH' ) ) {
10 - exit; // Exit if accessed directly.
10 + exit; // Exit if accessed directly
11 11 }
12 12
13 13 class Ai extends Library {
14 14 const API_URL = 'https://my.elementor.com/api/v2/ai/';
@@ -81,9 +81,9 @@
81 81 * @type string $session_id
82 82 * }
83 83 * }
84 84 */
85 - public function send_event( array $event_data ): void {
85 + public function send_event( array $event_data ) : void {
86 86 $this->ai_request(
87 87 'POST',
88 88 'client-events/events',
89 89 [
@@ -97,10 +97,9 @@
97 97 );
98 98 }
99 99
100 100 /**
101 - * Get file upload get_file_payload
102 - *
101 + * get_file_payload
103 102 * @param $filename
104 103 * @param $file_type
105 104 * @param $file_path
106 105 * @param $boundary
@@ -253,10 +252,9 @@
253 252 );
254 253 }
255 254
256 255 /**
257 - * Get Image Prompt Enhanced get_image_prompt_enhanced
258 - *
256 + * get_image_prompt_enhanced
259 257 * @param $prompt
260 258 *
261 259 * @return mixed|\WP_Error
262 260 */
@@ -329,10 +327,9 @@
329 327 );
330 328 }
331 329
332 330 /**
333 - * Get text to image get_text_to_image
334 - *
331 + * get_text_to_image
335 332 * @param $prompt
336 333 * @param $prompt_settings
337 334 *
338 335 * @return mixed|\WP_Error
@@ -356,13 +353,12 @@
356 353 );
357 354 }
358 355
359 356 /**
360 - * Get_Featured_Image get_featured_image
357 + * get_featured_image
358 + * @param $prompt
359 + * @param $prompt_settings
361 360 *
362 - * @param $data
363 - * @param $context
364 - * @param $request_ids
365 361 * @return mixed|\WP_Error
366 362 */
367 363 public function get_featured_image( $data, $context, $request_ids ) {
368 364 return $this->ai_request(
@@ -383,15 +379,13 @@
383 379 );
384 380 }
385 381
386 382 /**
387 - * Get Image To Image get_image_to_image
383 + * get_image_to_image
384 + * @param $image_data
388 385 *
389 - * @param $image_data
390 - * @param $context
391 - * @param $request_ids
392 386 * @return mixed|\WP_Error
393 - * @throws \Exception If image file not found.
387 + * @throws \Exception
394 388 */
395 389 public function get_image_to_image( $image_data, $context, $request_ids ) {
396 390 $image_file = get_attached_file( $image_data['attachment_id'] );
397 391
@@ -470,9 +464,8 @@
470 464 'image/image-to-image/unify-product-images',
471 465 [
472 466 'aspectRatio' => $image_data['promptSettings'][ self::ASPECT_RATIO ],
473 467 'backgroundColor' => $image_data['promptSettings'][ self::IMAGE_BACKGROUND_COLOR ],
474 - 'featureIdentifier' => $image_data['featureIdentifier'],
475 468 'context' => wp_json_encode( $context ),
476 469 'ids' => $request_ids,
477 470 'api_version' => ELEMENTOR_VERSION,
478 471 'site_lang' => get_bloginfo( 'language' ),
@@ -488,15 +481,13 @@
488 481 return $result;
489 482 }
490 483
491 484 /**
492 - * Get Image To Image Upscale get_image_to_image_upscale
485 + * get_image_to_image_upscale
486 + * @param $image_data
493 487 *
494 - * @param $image_data
495 - * @param $context
496 - * @param $request_ids
497 488 * @return mixed|\WP_Error
498 - * @throws \Exception If image file not found.
489 + * @throws \Exception
499 490 */
500 491 public function get_image_to_image_upscale( $image_data, $context, $request_ids ) {
501 492 $image_file = get_attached_file( $image_data['attachment_id'] );
502 493
@@ -521,15 +512,13 @@
521 512 return $result;
522 513 }
523 514
524 515 /**
525 - * Get Image To Image Remove Background get_image_to_image_remove_background
516 + * get_image_to_image_remove_background
517 + * @param $image_data
526 518 *
527 - * @param $image_data
528 - * @param $context
529 - * @param $request_ids
530 519 * @return mixed|\WP_Error
531 - * @throws \Exception If image file not found.
520 + * @throws \Exception
532 521 */
533 522 public function get_image_to_image_remove_background( $image_data, $context, $request_ids ) {
534 523 $image_file = get_attached_file( $image_data['attachment_id'] );
535 524
@@ -553,15 +542,13 @@
553 542 return $result;
554 543 }
555 544
556 545 /**
557 - * Get Image To Image Remove Text get_image_to_image_remove_text
546 + * get_image_to_image_remove_text
547 + * @param $image_data
558 548 *
559 - * @param $image_data
560 - * @param $context
561 - * @param $request_ids
562 549 * @return mixed|\WP_Error
563 - * @throws \Exception If image file not found.
550 + * @throws \Exception
564 551 */
565 552 public function get_image_to_image_replace_background( $image_data, $context, $request_ids ) {
566 553 $image_file = get_attached_file( $image_data['attachment_id'] );
567 554
@@ -586,11 +573,10 @@
586 573 return $result;
587 574 }
588 575
589 576 /**
590 - * Store Temp File store_temp_file
577 + * store_temp_file
591 578 * used to store a temp file for the AI request and deletes it once the request is done
592 - *
593 579 * @param $file_content
594 580 * @param $file_ext
595 581 *
596 582 * @return string
@@ -607,15 +593,13 @@
607 593 return $temp_file;
608 594 }
609 595
610 596 /**
611 - * Get Image To Image Out Painting get_image_to_image_out_painting
597 + * get_image_to_image_out_painting
598 + * @param $image_data
612 599 *
613 - * @param $image_data
614 - * @param $context
615 - * @param $request_ids
616 600 * @return mixed|\WP_Error
617 - * @throws \Exception If image file not found.
601 + * @throws \Exception
618 602 */
619 603 public function get_image_to_image_out_painting( $image_data, $context, $request_ids ) {
620 604 $img_content = str_replace( ' ', '+', $image_data['mask'] );
621 605 $img_content = substr( $img_content, strpos( $img_content, ',' ) + 1 );
@@ -651,15 +635,13 @@
651 635 return $result;
652 636 }
653 637
654 638 /**
655 - * Get Image To Image Mask get_image_to_image_mask
639 + * get_image_to_image_mask
640 + * @param $image_data
656 641 *
657 - * @param $image_data
658 - * @param $context
659 - * @param $request_ids
660 642 * @return mixed|\WP_Error
661 - * @throws \Exception If image file not found.
643 + * @throws \Exception
662 644 */
663 645 public function get_image_to_image_mask( $image_data, $context, $request_ids ) {
664 646 $image_file = get_attached_file( $image_data['attachment_id'] );
665 647 $mask_file = $this->store_temp_file( $image_data['mask'], '.svg' );
@@ -872,11 +854,10 @@
872 854 );
873 855 }
874 856
875 857 public function toggle_favorite_history_item( $id, $context = [] ) {
876 - $sanitized_id = str_replace( '%', '%%', $id );
877 858 return $this->ai_request(
878 - 'POST', sprintf( 'history/%s/favorite', $sanitized_id ),
859 + 'POST', sprintf( 'history/%s/favorite', $id ),
879 860 [
880 861 'context' => wp_json_encode( $context ),
881 862 'api_version' => ELEMENTOR_VERSION,
882 863 'site_lang' => get_bloginfo( 'language' ),