Skip to content

Commit

Permalink
Merge pull request #35 from Immolare/upgrade_open_ai_library
Browse files Browse the repository at this point in the history
Bump 1.1.7
  • Loading branch information
Immolare authored Jun 29, 2024
2 parents 540b01f + bfd092c commit 974e34b
Show file tree
Hide file tree
Showing 6 changed files with 660 additions and 201 deletions.
428 changes: 414 additions & 14 deletions README.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions artist-image-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: Artist Image Generator
* Plugin URI: https://artist-image-generator.com/
* Description: Illustrate posts with Ai images (DALL·E). Text-to-Image, variation, editing. Public image generator & Ai avatars by topics.
* Version: 1.1.5.3
* Version: 1.1.7
* Author: Pierre Viéville
* Author URI: https://www.pierrevieville.fr
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'ARTIST_IMAGE_GENERATOR_VERSION', '1.1.5.3' );
define( 'ARTIST_IMAGE_GENERATOR_VERSION', '1.1.7' );

/**
* The code that runs during plugin activation.
Expand Down
3 changes: 2 additions & 1 deletion includes/class-artist-image-generator-dalle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class Artist_Image_Generator_Dalle
'quality',
'style',
'user_limit',
'user_limit_duration'
'user_limit_duration',
'id'
];
private const ERROR_MSG_PROMPT = 'The Prompt input must be filled in order to generate an image.';
private const ERROR_MSG_IMAGE = 'A .png square (1:1) image of maximum 4MB needs to be uploaded in order to generate a variation of this image.';
Expand Down
12 changes: 9 additions & 3 deletions public/class-artist-image-generator-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ private function include_required_files()
private function check_and_update_user_limit($post_data)
{
if (isset($post_data['user_limit']) && (int)$post_data['user_limit'] > 0) {
$form_id = $post_data['id'];
$user_id = get_current_user_id();
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_identifier = $user_id ? 'artist_image_generator_user_' . $user_id : 'artist_image_generator_ip_' . $user_ip;
$user_identifier = $user_id ? 'artist_image_generator_user_' . $form_id . '_' . $user_id : 'artist_image_generator_ip_' . $form_id . '_' . $user_ip;
$requests = get_transient($user_identifier);
$duration = isset($post_data['user_limit_duration']) && $post_data['user_limit_duration'] > 0 ? (int)$post_data['user_limit_duration'] : 0;
$expiration = get_option('_transient_timeout_' . $user_identifier);
Expand Down Expand Up @@ -128,7 +129,7 @@ public function generate_image()

$data = $dalle->prepare_data($images ?? [], $error ?? [], $post_data);

//$data = '{"error":[],"images":[{"url":"https://artist-image-generator.com/wp-content/uploads/img-rck1GT0eGIYLu4oAXFEMqsPT.png"},{"url":"https://artist-image-generator.com/wp-content/uploads/img-rck1GT0eGIYLu4oAXFEMqsPT.png"},{"url":"https://artist-image-generator.com/wp-content/uploads/img-rck1GT0eGIYLu4oAXFEMqsPT.png"}],"model_input":"dall-e-2","prompt_input":"Painting of a bird, including following criterias:","size_input":"1024x1024","n_input":"1","quality_input":"","style_input":""}';
//$data = '{"error":[],"images":[{"url":"https://artist-image-generator.com/wp-content/uploads/2024/02/img-IVzRVsywZyjaPiTbTnKfNbq6.png"},{"url":"https://artist-image-generator.com/wp-content/uploads/2024/03/screenshot-6-jpg"},{"url":"https://artist-image-generator.com/wp-content/uploads/img-rck1GT0eGIYLu4oAXFEMqsPT.png"}],"model_input":"dall-e-2","prompt_input":"Painting of a bird, including following criterias:","size_input":"1024x1024","n_input":"1","quality_input":"","style_input":""}';

//$array = json_decode($data, true);
wp_send_json($data);
Expand Down Expand Up @@ -199,6 +200,7 @@ private function get_default_atts($atts)
'user_limit_duration' => self::DEFAULT_LIMIT_PER_USER_REFRESH_DURATION,
'mask_url' => '',
'origin_url' => '',
'uniqid' => uniqid()
),
$atts
);
Expand All @@ -221,18 +223,21 @@ private function generate_shortcode_html($atts)
)
);

$toggle_label = esc_html('Image N°', 'artist-image-generator');

ob_start();

?>
<div class="aig-form-container">
<form method="post" class="aig-form"
<form method="post" class="aig-form" data-id="<?php echo esc_attr($atts['uniqid']); ?>"
data-action="<?php echo esc_attr($atts['action']); ?>"
data-n="<?php echo esc_attr($atts['n']); ?>"
data-size="<?php echo esc_attr($atts['size']); ?>"
data-quality="<?php echo esc_attr($atts['quality']); ?>"
data-style="<?php echo esc_attr($atts['style']); ?>"
data-model="<?php echo esc_attr($atts['model']); ?>"
data-download="<?php echo esc_attr($atts['download']); ?>"
data-toggle-label="<?php echo esc_attr($toggle_label); ?>"
action="<?php echo esc_url(admin_url('admin-ajax.php')); ?>"
<?php if (!empty($atts['mask_url']) && !empty($atts['origin_url'])) { ?>
data-origin-url="<?php echo esc_url($atts['origin_url']); ?>"
Expand All @@ -241,6 +246,7 @@ private function generate_shortcode_html($atts)
>
<input type="hidden" name="aig_prompt" value="<?php echo esc_attr($atts['prompt']); ?>" />
<input type="hidden" name="action" value="<?php echo esc_attr($atts['action']); ?>" />
<input type="hidden" name="id" value="<?php echo esc_attr($atts['uniqid']); ?>" />
<input type="hidden" name="user_limit" value="<?php echo esc_attr($atts['user_limit']); ?>" />
<input type="hidden" name="user_limit_duration" value="<?php echo esc_attr($atts['user_limit_duration']); ?>" />

Expand Down
19 changes: 19 additions & 0 deletions public/css/artist-image-generator-public.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.aig-form-title {
text-transform: uppercase;
font-weight: bold;
}
.aig-form-title:hover {
cursor: pointer;
}
.aig-form {
margin: 10px 0;
}

.aig-topic-buttons label {
display: inline-block;
}

.aig-image-container {
display: flex;
Expand All @@ -40,6 +54,7 @@
align-items: flex-start;
}


.aig-image {
max-width: 100%;
height: auto;
Expand All @@ -55,6 +70,10 @@
position: relative;
}

textarea[name="aig_public_prompt"] {
min-height: 100px;
}

.custom-col {
flex: 0 0 33.3333%;
max-width: 33.3333%;
Expand Down
Loading

0 comments on commit 974e34b

Please sign in to comment.