$result = $app->get_animation( $data, $context, $request_ids );
$this->throw_on_error( $result );
return [
'text' => $result['text'],
'response_id' => $result['responseId'],
'usage' => $result['usage'],
];
}
/**
* @param mixed $result
*/
private function throw_on_error( $result ): void {
if ( is_wp_error( $result ) ) {
wp_send_json_error( [
'message' => esc_html( $result->get_error_message() ),
'extra_data' => $result->get_error_data(),
] );
}
}
/**
* @return void
*/
public function add_wc_scripts(): void {
wp_enqueue_script( 'elementor-ai-unify-product-images',
$this->get_js_assets_url( 'ai-unify-product-images' ),
[
'jquery',
'elementor-v2-ui',
'elementor-v2-icons',
'wp-components',
'elementor-common',
],
ELEMENTOR_VERSION,
true
);
wp_localize_script(
'elementor-ai-unify-product-images',
'UnifyProductImagesConfig',
[
'get_product_images_url' => admin_url( 'admin-ajax.php' ),
'set_product_images_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'elementor-ai-unify-product-images_nonce' ),
'placeholder' => ELEMENTOR_ASSETS_URL . 'images/app/ai/product-image-unification-example.gif?' . ELEMENTOR_VERSION,
'is_get_started' => User::get_introduction_meta( 'ai_get_started' ),
'connect_url' => $this->get_ai_connect_url(),
]
);
add_filter( 'bulk_actions-edit-product', function ( $data ) {
return $this->add_products_bulk_action( $data );
});
wp_set_script_translations( 'elementor-ai-unify-product-images', 'elementor' );
}
/**
* @param $product
* @param int|null $image_to_remove
* @param int|null $image_to_add
* @return void
*/
private function update_product_gallery( $product, ?int $image_to_remove, ?int $image_to_add ): void {
$gallery_image_ids = $product->get_gallery_image_ids();
$index = array_search( $image_to_remove, $gallery_image_ids, true );
if ( false !== $index ) {
unset( $gallery_image_ids[ $index ] );
}
if ( ! in_array( $image_to_add, $gallery_image_ids, true ) ) {
$gallery_image_ids[] = $image_to_add;
}
$product->set_gallery_image_ids( $gallery_image_ids );
$product->save();
}
private function should_display_create_with_ai_banner() {
$elementor_pages = new \WP_Query( [
'post_type' => 'page',
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => self::MIN_PAGES_FOR_CREATE_WITH_AI_BANNER + 1,
] );
if ( $elementor_pages->post_count > self::MIN_PAGES_FOR_CREATE_WITH_AI_BANNER ) {
return false;
}
if ( Utils::is_custom_kit_applied() ) {
return false;
}
return true;
}
private function get_create_with_ai_banner_data() {
return [
'title' => 'Create and launch your site faster with AI',
'description' => 'Share your vision with our AI Chat and watch as it becomes a brief, sitemap, and wireframes in minutes:',
'input_placeholder' => 'Start describing the site you want to create...',
'button_title' => 'Create with AI',
'button_cta_url' => 'http://planner.elementor.com/chat.html',
'background_image' => ELEMENTOR_ASSETS_URL . 'images/app/ai/ai-site-creator-homepage-bg.svg',
'utm_source' => 'editor-home',
'utm_medium' => 'wp-dash',
'utm_campaign' => 'generate-with-ai',
];
}
public function add_create_with_ai_banner_to_homescreen( $home_screen_data ) {
if ( $this->should_display_create_with_ai_banner() ) {
$home_screen_data['create_with_ai'] = $this->get_create_with_ai_banner_data();
} else {
$home_screen_data['create_with_ai'] = null;
}
return $home_screen_data;
}
}
Fatal error: Uncaught Error: Class "Elementor\Modules\Ai\Module" not found in /home/hexcom/public_html/digikids/wp-content/plugins/elementor/core/modules-manager.php:53
Stack trace:
#0 /home/hexcom/public_html/digikids/wp-content/plugins/elementor/includes/plugin.php(705): Elementor\Core\Modules_Manager->__construct()
#1 /home/hexcom/public_html/digikids/wp-content/plugins/elementor/includes/plugin.php(623): Elementor\Plugin->init_components()
#2 /home/hexcom/public_html/digikids/wp-includes/class-wp-hook.php(353): Elementor\Plugin->init()
#3 /home/hexcom/public_html/digikids/wp-includes/class-wp-hook.php(377): WP_Hook->apply_filters()
#4 /home/hexcom/public_html/digikids/wp-includes/plugin.php(523): WP_Hook->do_action()
#5 /home/hexcom/public_html/digikids/wp-settings.php(779): do_action()
#6 /home/hexcom/public_html/digikids/wp-config.php(98): require_once('/home/hexcom/pu...')
#7 /home/hexcom/public_html/digikids/wp-load.php(50): require_once('/home/hexcom/pu...')
#8 /home/hexcom/public_html/digikids/wp-blog-header.php(13): require_once('/home/hexcom/pu...')
#9 /home/hexcom/public_html/digikids/index.php(17): require('/home/hexcom/pu...')
#10 {main}
thrown in /home/hexcom/public_html/digikids/wp-content/plugins/elementor/core/modules-manager.php on line 53