PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 4.0.7 All 451 releases
← All changes | modules/ai/module.php +5 -67 4.0.73.28.0-dev2 View file →
@@ -28,9 +28,8 @@
28 28 self::HISTORY_TYPE_CODE,
29 29 self::HISTORY_TYPE_IMAGE,
30 30 self::HISTORY_TYPE_BLOCK,
31 31 ];
32 - const MIN_PAGES_FOR_CREATE_WITH_AI_BANNER = 10;
33 32
34 33 public function get_name() {
35 34 return 'ai';
36 35 }
@@ -48,10 +47,8 @@
48 47 if ( ! $this->is_ai_enabled() ) {
49 48 return;
50 49 }
51 50
52 - add_filter( 'elementor/core/admin/homescreen', [ $this, 'add_create_with_ai_banner_to_homescreen' ] );
53 -
54 51 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
55 52 $connect_module->register_app( 'ai', Ai::get_class_name() );
56 53 } );
57 54
@@ -84,9 +81,8 @@
84 81 'ai_delete_history_item' => [ $this, 'ajax_ai_delete_history_item' ],
85 82 'ai_toggle_favorite_history_item' => [ $this, 'ajax_ai_toggle_favorite_history_item' ],
86 83 'ai_get_product_image_unification' => [ $this, 'ajax_ai_get_product_image_unification' ],
87 84 'ai_get_animation' => [ $this, 'ajax_ai_get_animation' ],
88 - 'ai_get_image_to_image_isolate_objects' => [ $this, 'ajax_ai_get_product_image_unification' ],
89 85 ];
90 86
91 87 foreach ( $handlers as $tag => $callback ) {
92 88 $ajax->register_ajax_action( $tag, $callback );
@@ -1020,8 +1016,12 @@
1020 1016 if ( empty( $data['payload']['settings'] ) ) {
1021 1017 throw new \Exception( 'Missing prompt settings' );
1022 1018 }
1023 1019
1020 + if ( ! $app->is_connected() ) {
1021 + throw new \Exception( 'not_connected' );
1022 + }
1023 +
1024 1024 if ( empty( $data['payload']['mask'] ) ) {
1025 1025 throw new \Exception( 'Missing Mask' );
1026 1026 }
1027 1027
@@ -1111,10 +1111,8 @@
1111 1111 ];
1112 1112 }
1113 1113
1114 1114 public function ajax_ai_upload_image( $data ) {
1115 - $this->verify_upload_permissions( $data );
1116 -
1117 1115 if ( empty( $data['image'] ) ) {
1118 1116 throw new \Exception( 'Missing image data' );
1119 1117 }
1120 1118
@@ -1312,24 +1310,10 @@
1312 1310 if ( ! current_user_can( 'upload_files' ) ) {
1313 1311 throw new \Exception( 'Not Allowed to Upload images' );
1314 1312 }
1315 1313
1316 - $uploads_manager = new \Elementor\Core\Files\Uploads_Manager();
1317 - if ( $uploads_manager::are_unfiltered_uploads_enabled() ) {
1318 - Plugin::$instance->uploads_manager->set_elementor_upload_state( true );
1319 - add_filter( 'wp_handle_sideload_prefilter', [ Plugin::$instance->uploads_manager, 'handle_elementor_upload' ] );
1320 - add_filter( 'image_sideload_extensions', function( $extensions ) {
1321 - $extensions[] = 'svg';
1322 - return $extensions;
1323 - });
1324 - }
1325 -
1326 1314 $attachment_id = media_sideload_image( $image_url, $parent_post_id, $image_title, 'id' );
1327 1315
1328 - if ( is_wp_error( $attachment_id ) ) {
1329 - return new \WP_Error( 'upload_error', $attachment_id->get_error_message() );
1330 - }
1331 -
1332 1316 if ( ! empty( $attachment_id['error'] ) ) {
1333 1317 return new \WP_Error( 'upload_error', $attachment_id['error'] );
1334 1318 }
1335 1319
@@ -1412,11 +1396,9 @@
1412 1396 return [];
1413 1397 }
1414 1398
1415 1399 public function ajax_ai_get_product_image_unification( $data ): array {
1416 - if ( ! empty( $data['payload']['postId'] ) ) {
1417 - $data['editor_post_id'] = $data['payload']['postId'];
1418 - }
1400 + $data['editor_post_id'] = $data['payload']['postId'];
1419 1401 $this->verify_upload_permissions( $data );
1420 1402
1421 1403 $app = $this->get_ai_app();
1422 1404
@@ -1437,9 +1419,8 @@
1437 1419
1438 1420 $result = $app->get_unify_product_images( [
1439 1421 'promptSettings' => $data['payload']['settings'],
1440 1422 'attachment_id' => $data['payload']['image']['id'],
1441 - 'featureIdentifier' => $data['payload']['featureIdentifier'] ?? '',
1442 1423 ], $context, $request_ids );
1443 1424
1444 1425 $this->throw_on_error( $result );
1445 1426
@@ -1549,49 +1530,6 @@
1549 1530 }
1550 1531
1551 1532 $product->set_gallery_image_ids( $gallery_image_ids );
1552 1533 $product->save();
1553 - }
1554 -
1555 - private function should_display_create_with_ai_banner() {
1556 - $elementor_pages = new \WP_Query( [
1557 - 'post_type' => 'page',
1558 - 'post_status' => 'publish',
1559 - 'fields' => 'ids',
1560 - 'posts_per_page' => self::MIN_PAGES_FOR_CREATE_WITH_AI_BANNER + 1,
1561 - ] );
1562 -
1563 - if ( $elementor_pages->post_count > self::MIN_PAGES_FOR_CREATE_WITH_AI_BANNER ) {
1564 - return false;
1565 - }
1566 -
1567 - if ( Utils::is_custom_kit_applied() ) {
1568 - return false;
1569 - }
1570 -
1571 - return true;
1572 - }
1573 -
1574 - private function get_create_with_ai_banner_data() {
1575 - return [
1576 - 'title' => 'Create and launch your site faster with AI',
1577 - 'description' => 'Share your vision with our AI Chat and watch as it becomes a brief, sitemap, and wireframes in minutes:',
1578 - 'input_placeholder' => 'Start describing the site you want to create...',
1579 - 'button_title' => 'Create with AI',
1580 - 'button_cta_url' => 'http://planner.elementor.com/chat.html',
1581 - 'background_image' => ELEMENTOR_ASSETS_URL . 'images/app/ai/ai-site-creator-homepage-bg.svg',
1582 - 'utm_source' => 'editor-home',
1583 - 'utm_medium' => 'wp-dash',
1584 - 'utm_campaign' => 'generate-with-ai',
1585 - ];
1586 - }
1587 -
1588 - public function add_create_with_ai_banner_to_homescreen( $home_screen_data ) {
1589 - if ( $this->should_display_create_with_ai_banner() ) {
1590 - $home_screen_data['create_with_ai'] = $this->get_create_with_ai_banner_data();
1591 - } else {
1592 - $home_screen_data['create_with_ai'] = null;
1593 - }
1594 -
1595 - return $home_screen_data;
1596 1534 }
1597 1535 }