. === This plugin includes code based on WordPress. WordPress licensing and copyright information is included in ./license/wp-license.txt. */ class WpzAiImageLab { const VERSION = '0.1.2'; const KEY_ISSUE_URL = 'https://wpzone.co/connect-ai/?keyTarget=30037105'; const API_URL = 'https://api.aiimagelab.com/api.php'; const REQUESTS_BASE_URL = 'https://api.aiimagelab.com/get/'; const PROMPT_MODIFIERS = [ 'type' => [ 'label' => 'Type', 'values' => [ 'photo' => [ 'label' => 'Photo', 'sample-image' => 'type-photo.jpg', 'default' => true ], 'painting' => [ 'label' => 'Painting', 'sample-image' => 'type-painting.jpg' ], 'illustration' => [ 'label' => 'Illustration', 'sample-image' => 'type-illustration.jpg' ], 'pencil-drawing' => [ 'label' => 'Pencil Drawing', 'sample-image' => 'type-pencil-drawing.jpg' ], 'digital-art' => [ 'label' => 'Digital Art', 'sample-image' => 'type-digital-art.jpg' ], ], ], 'photo-lens' => [ 'label' => 'Camera Lens', 'values' => [ 'wide-angle' => [ 'label' => 'Wide Angle', 'sample-image' => 'lens-wide-angle.jpg', ], 'macro' => [ 'label' => 'Macro', 'sample-image' => 'lens-macro.jpg' ] ], 'showIfCondition' => 'type', 'showIfValue' => 'photo' ], 'photo-effect' => [ 'label' => 'Photo Effect', 'values' => [ 'grayscale' => [ 'label' => 'Grayscale', 'sample-image' => 'effect-grayscale.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'photo' ], 'photo-lighting' => [ 'label' => 'Lighting', 'values' => [ 'other' => [ 'bioluminescent' => 'Bioluminescent', 'cinematic-lighting' => 'Cinematic Lighting', 'dark' => 'Dark', 'diffuse-lighting' => 'Diffuse Lighting', 'dramatic-lighting' => 'Dramatic Lighting', 'global-illumination' => 'Global Illumination', 'glowing-lights' => 'Glowing Lights', 'god-rays' => 'God Rays', 'hard-shadows' => 'Hard Shadows', 'long-exposure' => 'Long Exposure', 'luminescence' => 'Luminescence', 'natural-lighting' => 'Natural lighting', 'neon' => 'Neon', 'radiant-light-rays' => 'Radiant Light Rays', 'rim-lighting' => 'Rim Lighting', 'soft-box-lighting' => 'Soft Box Lighting', 'studio-lighting' => 'Studio Lighting', 'sunlight' => 'Sunlight', 'translucent' => 'Translucent', 'volumetric-lighting' => 'Volumetric Lighting' ] ], 'showIfCondition' => 'type', 'showIfValue' => 'photo', 'class'=> 'wpz-form-row' ], 'painting-style' => [ 'label' => 'Painting Style', 'values' => [ 'impressionism' => [ 'label' => 'Impressionism', 'sample-image' => 'painting-impressionism.jpg', ], 'expressionism' => [ 'label' => 'Expressionism', 'sample-image' => 'painting-expressionism.jpg', ], 'abstract' => [ 'label' => 'Abstract', 'sample-image' => 'painting-abstract.jpg', ], 'realistic' => [ 'label' => 'Realistic', 'sample-image' => 'painting-realistic.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'painting' ], 'painting-medium' => [ 'label' => 'Painting Medium', 'values' => [ 'oil-on-canvas' => [ 'label' => 'Oil on Canvas', 'sample-image' => 'painting-oil-on-canvas.jpg', ], 'watercolor' => [ 'label' => 'Watercolor', 'sample-image' => 'painting-watercolor.jpg', ], 'graffiti' => [ 'label' => 'Graffiti', 'sample-image' => 'painting-graffiti.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'painting' ], 'illustration-style' => [ 'label' => 'Illustration Style', 'values' => [ 'comic-book' => [ 'label' => 'Comic Book', 'sample-image' => 'illustration-comic-book.jpg', ], 'childrens-book' => [ 'label' => 'Children\'s Book', 'sample-image' => 'illustration-childrens-book.jpg', ], 'outline' => [ 'label' => 'Outline', 'sample-image' => 'illustration-outline.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'illustration' ], 'pencil-drawing-style' => [ 'label' => 'Pencil Drawing Style', 'values' => [ 'comic-book' => [ 'label' => 'Monochrome', 'sample-image' => 'pencil-drawing-monochrome.jpg', ], 'pencil-crayon' => [ 'label' => 'Pencil Crayon', 'sample-image' => 'pencil-drawing-pencil-crayon.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'pencil-drawing' ], 'digital-art-style' => [ 'label' => 'Digital Art Style', 'values' => [ '3d-render' => [ 'label' => '3D Render', 'sample-image' => 'digital-art-3d-render.jpg', ], '8-bit' => [ 'label' => '8-Bit', 'sample-image' => 'digital-art-8-bit.jpg', ], ], 'showIfCondition' => 'type', 'showIfValue' => 'digital-art' ], '3d-art-style' => [ 'label' => 'Advanced', 'values' => [ 'other' => [ 'dreamworks' => 'Disney Style', 'pixar' => 'Pixar Style', 'polygon-art' => 'Made with shapes and polygons' ] ], 'showIfCondition' => 'type', 'showIfValue' => 'digital-art', 'class' => 'wpz-form-row' ], 'artist' => [ 'label' => 'Artist', 'values' => [ 'other' => [ 'Brad-Rigney' => 'Brad Rigney - Dark, surreal fantasy landscapes', 'David-Cronenberg' => 'David Cronenberg - Realistic, cinematic character design', 'Dave-Rapoza' => 'Dave Rapoza - Body horror, sci-fi surrealism', 'Edwin-Deakin' => 'Edwin Deakin - Luminous, atmospheric California landscape', 'Frida-Kahlo' => 'Frida Kahlo - Intensely personal, surreal self-portraiture', 'Greg-Rutkowski' => 'Greg Rutkowski - Moody, ethereal fantasy environments', 'Henry-Asencio' => 'Henry Asencio - Dynamic, textured figurative painting', 'Huang-Guangjian' => 'Huang Guangjian - Colorful, playful pop art characters', 'Ilya-Kuvshinov' => 'Ilya Kuvshinov - Dreamy, anime-inspired digital portraits', 'Jackson-Pollock' => 'Jackson Pollock - Abstract expressionist drip painting', 'JB-Monge' => 'JB Monge - Whimsical, detailed fantasy creature design', 'John-Collier' => 'John Collier - Realistic, haunting figurative painting', 'John-Singer-Sargent' => 'John Singer Sargent - Elegant, impressionistic portrait painting', 'Josephine-Wall' => 'Josephine Wall - Mystical, romantic fantasy illustration', 'Kilian-Eng' => 'Kilian Eng - Retro-futuristic sci-fi digital art', 'Kim-Jung-Gi' => 'Kim Jung Gi - Hyper-detailed, surreal pen and ink drawings', 'Krenz-Cushart' => 'Krenz Cushart - Cute, whimsical character design', 'Milo-Manara' => 'Milo Manara - Sensual, erotic comic book art', 'Mort-Kunstler' => 'Mort Kunstler - Historical, narrative figurative painting', 'Otto-Dix' => 'Otto Dix - Expressionist, socially critical figurative painting', 'Pablo-Picasso' => 'Pablo Picasso - Inventive, groundbreaking modern art', 'Ross-Tran' => 'Ross Tran - Loose, expressive digital character sketches', 'russ-mills' => 'Russ Mills - Collage-like mixed media portrait art', 'Salvador-Dali' => 'Salvador Dali - Surrealist, dreamlike imagery', 'Stanley-Artgerm-Lau' => 'Stanley Artgerm Lau - Gorgeous, glamorous comic book covers', 'Takashi-Murakami' => 'Takashi Murakami - Colorful, playful pop art sculpture', 'Tooth-Wu' => 'Tooth Wu - Dynamic, stylized character illustration', 'Vincent-van-Gogh ' => 'Vincent van Gogh - Vibrant, emotional post-impressionist painting', 'Yoshitaka-Amano' => 'Yoshitaka Amano - Elaborate, ornate fantasy illustration', 'Zdzisław-Beksiński' => 'Zdzisław Beksiński -Dark, surreal gothic painting', ] ], 'class' => 'wpz-form-row' ], 'website' => [ 'label' => 'Website', 'values' => [ 'other' => [ 'ArtStation'=>'ArtStation - Digital concept art and 3D modeling', 'Behance'=>'Behance - Graphic design, branding, and typography', 'CGSociety'=>'DCGSociety - igital animation and visual effects', 'DeviantArt'=>'DeviantArt - Fan art, anime/manga, and surrealism', 'Dribbble'=>'Dribbble - UI/UX design and illustration', 'iStock'=>'iStock - Stock photography and vector illustrations', 'Pixabay'=>'Pixabay - Wide range of stock photos and videos', 'Pixiv'=>'Pixiv - Anime and manga fan art, illustrations', 'Zerochan'=>'Zerochan - Anime and manga fan art, illustrations', ] ], 'class' => 'wpz-form-row' ], 'color' => [ 'label' => 'Color', 'values' => [ 'other' => [ 'aesthetic' => 'Aesthetic', 'colorful' => 'Colorful', 'color-grading' => 'Color Grading', 'ektachrome' => 'Ektachrome', 'enamelled' => 'Enamelled', 'iridescent-accents' => 'Iridescent Accents', 'iridescent-gold' => 'Iridescent Gold', 'muted-colors' => 'Muted Colors', 'neon' => 'Neon', 'silver' => 'Silver', 'tone-mapping' => 'Tone Mapping', 'vibrant-color' => 'Vibrant Color', 'vintage' => 'Vintage', 'vivid' => 'Vivid', ] ], 'class' => 'wpz-form-row' ], ]; const SAMPLE_PROMPTS = [ 'snowy rocky mountains, low clouds', 'red car, city street, at night', 'a frog, on a lilypad, in a pond' ]; public static $pluginUrl; public static $pluginDir; function __construct() { self::$pluginUrl = plugin_dir_url(__FILE__); self::$pluginDir = __DIR__ . '/'; add_action('admin_menu', [$this, 'adminMenu']); add_action('admin_init', [$this, 'adminInit']); add_action('post-upload-ui', function () { include_once self::$pluginDir . 'includes/upload-ui.php'; }); add_action('wp_enqueue_media', [$this, 'mediaScripts']); add_action('wp_ajax_wpz-ai-images-upload', [$this, 'ajaxUpload']); add_action('admin_enqueue_scripts', [$this, 'adminScripts']); } function mediaScripts() { wp_enqueue_script('wpz-ai-images-media', self::$pluginUrl.'assets/js/media.min.js', ['jquery'], self::VERSION); wp_localize_script('wpz-ai-images-media', 'wpzAiImagesConfig', [ 'ajaxurl' => admin_url('admin-ajax.php') ]); wp_enqueue_style('wpz-ai-images-media', self::$pluginUrl.'assets/css/media.min.css', null); } function adminScripts($hook) { global $pagenow; wp_enqueue_style('wpz-ai-images-wp-styles', self::$pluginUrl.'assets/css/wp-styles.min.css', null, self::VERSION); wp_enqueue_script('wpz-ai-images-wp-script', self::$pluginUrl.'assets/js/wp-script.min.js', ['jquery'], self::VERSION); if ( 'toplevel_page_wpz-ai-images' === $hook ) { wp_enqueue_style('wpz-ai-images-addons-admin', self::$pluginUrl.'includes/admin/addons/css/admin.min.css', null, self::VERSION); wp_enqueue_style('wpz-ai-images-admin', self::$pluginUrl.'assets/css/admin.min.css', null, self::VERSION); wp_enqueue_script('wpz-ai-images-admin', self::$pluginUrl.'assets/js/admin.min.js', ['jquery'], self::VERSION); } if (isset($pagenow) && $pagenow == 'media-new.php') { $this->mediaScripts(); } } function adminInit() { if ( is_admin() ) { include_once self::$pluginDir . 'includes/admin/addons/addons.php'; if ( current_user_can( 'manage_options' ) ) { include_once self::$pluginDir . 'includes/admin/notices/admin-notices.php'; } } } function ajaxUpload() { if (empty($_POST['url']) || substr($_POST['url'], 0, strlen(self::REQUESTS_BASE_URL)) !== self::REQUESTS_BASE_URL) { status_header(400); exit; } $attachmentId = media_sideload_image(add_query_arg('key', get_option('wpz_ai_images_key'), $_POST['url']), isset($_POST['postId']) ? (int) $_POST['postId'] : 0, isset($_POST['prompt']) ? $_POST['prompt'] : null, 'id'); if (!is_wp_error($attachmentId)) { wp_send_json_success( wp_prepare_attachment_for_js( $attachmentId ) ); } } function adminMenu() { add_menu_page('AI Image Lab', 'AI Image Lab', 'manage_options', 'wpz-ai-images', function () { include_once self::$pluginDir . 'includes/admin/admin-page.php'; }, '', 600); } } new WpzAiImageLab();