PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-beta1
Elementor Website Builder – more than just a page builder v3.28.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 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 All 457 releases
← All changes | modules/ai/module.php +8 -21 4.3.3 → 3.28.0-beta1 View file →
@@ -4,8 +4,9 @@
4 4 use Elementor\Controls_Manager;
5 5 use Elementor\Core\Base\Module as BaseModule;
6 6 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
7 7 use Elementor\Element_Base;
8 +use Elementor\Modules\Ai\Feature_Intro\Product_Image_Unification_Intro;
8 9 use Elementor\Plugin;
9 10 use Elementor\Core\Utils\Collection;
10 11 use Elementor\Modules\Ai\Connect\Ai;
11 12 use Elementor\User;
@@ -27,8 +28,9 @@
27 28 self::HISTORY_TYPE_CODE,
28 29 self::HISTORY_TYPE_IMAGE,
29 30 self::HISTORY_TYPE_BLOCK,
30 31 ];
32 +
31 33 public function get_name() {
32 34 return 'ai';
33 35 }
34 36
@@ -79,9 +81,8 @@
79 81 'ai_delete_history_item' => [ $this, 'ajax_ai_delete_history_item' ],
80 82 'ai_toggle_favorite_history_item' => [ $this, 'ajax_ai_toggle_favorite_history_item' ],
81 83 'ai_get_product_image_unification' => [ $this, 'ajax_ai_get_product_image_unification' ],
82 84 'ai_get_animation' => [ $this, 'ajax_ai_get_animation' ],
83 - 'ai_get_image_to_image_isolate_objects' => [ $this, 'ajax_ai_get_product_image_unification' ],
84 85 ];
85 86
86 87 foreach ( $handlers as $tag => $callback ) {
87 88 $ajax->register_ajax_action( $tag, $callback );
@@ -119,8 +120,9 @@
119 120 add_action( 'admin_init', [ $this, 'enqueue_ai_products_page_scripts' ] );
120 121 add_action( 'current_screen', [ $this, 'enqueue_ai_single_product_page_scripts' ] );
121 122 add_action( 'wp_ajax_elementor-ai-get-product-images', [ $this, 'get_product_images_ajax' ] );
122 123 add_action( 'wp_ajax_elementor-ai-set-product-images', [ $this, 'set_product_images_ajax' ] );
124 + Product_Image_Unification_Intro::add_hooks();
123 125 }
124 126 }
125 127
126 128 add_action( 'enqueue_block_editor_assets', function() {
@@ -1014,8 +1016,12 @@
1014 1016 if ( empty( $data['payload']['settings'] ) ) {
1015 1017 throw new \Exception( 'Missing prompt settings' );
1016 1018 }
1017 1019
1020 + if ( ! $app->is_connected() ) {
1021 + throw new \Exception( 'not_connected' );
1022 + }
1023 +
1018 1024 if ( empty( $data['payload']['mask'] ) ) {
1019 1025 throw new \Exception( 'Missing Mask' );
1020 1026 }
1021 1027
@@ -1105,10 +1111,8 @@
1105 1111 ];
1106 1112 }
1107 1113
1108 1114 public function ajax_ai_upload_image( $data ) {
1109 - $this->verify_upload_permissions( $data );
1110 -
1111 1115 if ( empty( $data['image'] ) ) {
1112 1116 throw new \Exception( 'Missing image data' );
1113 1117 }
1114 1118
@@ -1306,24 +1310,10 @@
1306 1310 if ( ! current_user_can( 'upload_files' ) ) {
1307 1311 throw new \Exception( 'Not Allowed to Upload images' );
1308 1312 }
1309 1313
1310 - $uploads_manager = new \Elementor\Core\Files\Uploads_Manager();
1311 - if ( $uploads_manager::are_unfiltered_uploads_enabled() ) {
1312 - Plugin::$instance->uploads_manager->set_elementor_upload_state( true );
1313 - add_filter( 'wp_handle_sideload_prefilter', [ Plugin::$instance->uploads_manager, 'handle_elementor_upload' ] );
1314 - add_filter( 'image_sideload_extensions', function( $extensions ) {
1315 - $extensions[] = 'svg';
1316 - return $extensions;
1317 - });
1318 - }
1319 -
1320 1314 $attachment_id = media_sideload_image( $image_url, $parent_post_id, $image_title, 'id' );
1321 1315
1322 - if ( is_wp_error( $attachment_id ) ) {
1323 - return new \WP_Error( 'upload_error', $attachment_id->get_error_message() );
1324 - }
1325 -
1326 1316 if ( ! empty( $attachment_id['error'] ) ) {
1327 1317 return new \WP_Error( 'upload_error', $attachment_id['error'] );
1328 1318 }
1329 1319
@@ -1406,11 +1396,9 @@
1406 1396 return [];
1407 1397 }
1408 1398
1409 1399 public function ajax_ai_get_product_image_unification( $data ): array {
1410 - if ( ! empty( $data['payload']['postId'] ) ) {
1411 - $data['editor_post_id'] = $data['payload']['postId'];
1412 - }
1400 + $data['editor_post_id'] = $data['payload']['postId'];
1413 1401 $this->verify_upload_permissions( $data );
1414 1402
1415 1403 $app = $this->get_ai_app();
1416 1404
@@ -1431,9 +1419,8 @@
1431 1419
1432 1420 $result = $app->get_unify_product_images( [
1433 1421 'promptSettings' => $data['payload']['settings'],
1434 1422 'attachment_id' => $data['payload']['image']['id'],
1435 - 'featureIdentifier' => $data['payload']['featureIdentifier'] ?? '',
1436 1423 ], $context, $request_ids );
1437 1424
1438 1425 $this->throw_on_error( $result );
1439 1426