d images' );
}
$attachment_id = media_sideload_image( $image_url, $parent_post_id, $image_title, 'id' );
if ( ! empty( $attachment_id['error'] ) ) {
return new \WP_Error( 'upload_error', $attachment_id['error'] );
}
return [
'id' => $attachment_id,
'url' => wp_get_attachment_image_url( $attachment_id, 'full' ),
'alt' => $image_title,
'source' => 'library',
];
}
public function ajax_ai_get_history( $data ): array {
$type = $data['type'] ?? self::HISTORY_TYPE_ALL;
if ( ! in_array( $type, self::VALID_HISTORY_TYPES, true ) ) {
throw new \Exception( 'Invalid history type' );
}
$page = sanitize_text_field( $data['page'] ?? 1 );
$limit = sanitize_text_field( $data['limit'] ?? 10 );
$app = $this->get_ai_app();
if ( ! $app->is_connected() ) {
throw new \Exception( 'not_connected' );
}
$context = $this->get_request_context( $data );
$result = $app->get_history_by_type( $type, $page, $limit, $context );
if ( is_wp_error( $result ) ) {
throw new \Exception( $result->get_error_message() );
}
return $result;
}
public function ajax_ai_delete_history_item( $data ): array {
if ( empty( $data['id'] ) || ! wp_is_uuid( $data['id'] ) ) {
throw new \Exception( 'Missing id parameter' );
}
$app = $this->get_ai_app();
if ( ! $app->is_connected() ) {
throw new \Exception( 'not_connected' );
}
$context = $this->get_request_context( $data );
$result = $app->delete_history_item( $data['id'], $context );
if ( is_wp_error( $result ) ) {
throw new \Exception( $result->get_error_message() );
}
return [];
}
public function ajax_ai_toggle_favorite_history_item( $data ): array {
if ( empty( $data['id'] ) || ! wp_is_uuid( $data['id'] ) ) {
throw new \Exception( 'Missing id parameter' );
}
$app = $this->get_ai_app();
if ( ! $app->is_connected() ) {
throw new \Exception( 'not_connected' );
}
$context = $this->get_request_context( $data );
$result = $app->toggle_favorite_history_item( $data['id'], $context );
if ( is_wp_error( $result ) ) {
throw new \Exception( $result->get_error_message() );
}
return [];
}
/**
* @param mixed $result
*/
private function throw_on_error( $result ): void {
if ( is_wp_error( $result ) ) {
wp_send_json_error( [
'message' => $result->get_error_message(),
'extra_data' => $result->get_error_data(),
] );
}
}
}
Fatal error: Uncaught Error: Class 'Elementor\Modules\Ai\Module' not found in /home/sportuga/public_html/wp-content/plugins/elementor/core/modules-manager.php:53
Stack trace:
#0 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(730): Elementor\Core\Modules_Manager->__construct()
#1 /home/sportuga/public_html/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components()
#2 /home/sportuga/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('')
#3 /home/sportuga/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#4 /home/sportuga/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#5 /home/sportuga/public_html/wp-settings.php(695): do_action('init')
#6 /home/sportuga/public_html/wp-config.php(102): require_once('/home/sportuga/...')
#7 /home/sportuga/public_html/wp-load.php(50): require_once('/home/sportuga/...')
#8 /home/sportuga/public_html/wp-blog-header.php(13): require_once('/home/sportuga/...')
#9 / in /home/sportuga/public_html/wp-content/plugins/elementor/core/modules-manager.php on line 53