%s', esc_url( $settings_url ), __( 'Settings', 'ai-featured-image' ) ); array_unshift( $links, $settings_link ); return $links; } // Add meta links --------------> function aifi_add_metalinks_to_plugins_page( $links, $file ) { $plugin = plugin_basename( AIFI_PLUGIN_DIR . 'ai-featured-image.php' ); if ($file == $plugin) { $donation_url = 'https://alternatives-manifest.de/wordpress'; $donation_link = sprintf( '%s', esc_url($donation_url), __( 'Donation', 'ai-featured-image' ) ); array_unshift( $links, $donation_link ); $rating_url = 'https://wordpress.org/support/plugin/ai-featured-image/reviews/?rate=5#new-post'; $rating_link = sprintf( '%s', esc_url($rating_url), __( 'Rate', 'ai-featured-image' ) ); array_unshift( $links, $rating_link ); $support_url = 'https://wordpress.org/support/plugin/ai-featured-image/#new-topic-0'; $support_link = sprintf( '%s', esc_url($support_url), __( 'Support', 'ai-featured-image' ) ); array_unshift( $links, $support_link ); } return $links; } // Stelle sicher, dass AIFI_PLUGIN_DIR definiert ist (aus der Hauptdatei) if (defined('AIFI_PLUGIN_DIR')) { $plugin_basename = plugin_basename( AIFI_PLUGIN_DIR . 'ai-featured-image.php' ); add_filter( 'plugin_action_links_' . $plugin_basename, 'aifi_add_settings_link_to_plugins_page' ); add_filter( 'plugin_row_meta', 'aifi_add_metalinks_to_plugins_page', 10, 2 ); } class AIFI_Settings { private static $options; public static function init() { add_action( 'admin_menu', [ self::class, 'add_settings_page' ] ); add_action( 'admin_init', [ self::class, 'register_settings' ] ); // Optionen nur einmal laden, wenn benötigt // self::$options = get_option( 'aifi_settings' ); // Besser erst laden, wenn gebraucht } public static function add_settings_page() { add_options_page( 'AI Featured Image - ' . __( 'Settings', 'ai-featured-image' ), 'AIFI - ' . __( 'Settings', 'ai-featured-image' ), 'manage_options', 'aifi-settings', [ self::class, 'create_settings_page' ] ); } public static function register_settings() { // Registriert die Einstellungs-Gruppe und die Option selbst mit Sanitization Callback register_setting( 'aifi_settings_group', 'aifi_settings', [ self::class, 'sanitize_settings' ] ); // Fügt einen Abschnitt zur Seite hinzu add_settings_section( 'aifi_api_settings_section', __( 'API Settings', 'ai-featured-image' ), null, // Callback für Sektions-Beschreibung (optional) 'aifi-settings' // Slug der Seite, zu der die Section gehört ); // --- Registriert die einzelnen Felder --- // Feld für Dienstauswahl add_settings_field( 'aifi_api_service', // Eindeutige ID des Feldes __( 'AI-Service', 'ai-featured-image' ), // Label für das Feld (wird im angezeigt) [ self::class, 'render_api_service_field' ], // Callback-Funktion zum Rendern des Feld-Inhalts () 'aifi-settings', // Slug der Seite 'aifi_api_settings_section', // ID der Sektion, zu der das Feld gehört ['label_for' => 'aifi_api_service'] // Verknüpft das Label mit dem Input-Element ); // Feld für ClipDrop Key (wird durch die Render-Funktion selbst hinzugefügt) // Hier registrieren, damit WordPress es kennt: add_settings_field( 'aifi_clipdrop_api_key', 'ClipDrop - ' . __( 'API Key', 'ai-featured-image' ), [ self::class, 'render_clipdrop_api_key_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_clipdrop_api_key', 'class' => 'aifi-service-field-row aifi-clipdrop-field' // Klassen für die TR-Zeile ] ); // Feld für Stability AI Key (wird durch die Render-Funktion selbst hinzugefügt) add_settings_field( 'aifi_stabilityai_api_key', 'Stability AI - ' . __( 'API Key', 'ai-featured-image' ), [ self::class, 'render_stabilityai_api_key_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_stabilityai_api_key', 'class' => 'aifi-service-field-row aifi-stabilityai-field' // Klassen für die TR-Zeile ] ); // Feld für Stability AI Engine ID (wird durch die Render-Funktion selbst hinzugefügt) add_settings_field( 'aifi_stabilityai_engine_id', 'Stability AI - ' . __( 'Engine ID', 'ai-featured-image' ), [ self::class, 'render_stabilityai_engine_id_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_stabilityai_engine_id', 'class' => 'aifi-service-field-row aifi-stabilityai-field' // Klassen für die TR-Zeile ] ); // NEU: Feld für Stability AI Dimensionen registrieren (nutzt einen Callback für beide Controls) add_settings_field( 'aifi_stabilityai_dimensions', // Eine ID für die Gruppe von Controls 'Stability AI - ' . __( 'Image dimensions', 'ai-featured-image' ), // Label [ self::class, 'render_stabilityai_dimensions_controls' ], // Neuer Callback 'aifi-settings', // Page 'aifi_api_settings_section', // Zur API Sektion hinzufügen [ 'class' => 'aifi-service-field-row aifi-stabilityai-field' ] // Wird mit Stability AI ein/ausgeblendet ); // Feld für Google Gemini API Key (wird durch die Render-Funktion selbst hinzugefügt) add_settings_field( 'aifi_google_api_key', // ID des Feldes 'Google API(AI Studio) - ' . __( 'API Key', 'ai-featured-image' ), // Label [ self::class, 'render_google_api_key_field' ], // Callback 'aifi-settings', // Page Slug 'aifi_api_settings_section', // Section [ 'label_for' => 'aifi_google_api_key', // Verknüpfung Label -> Input 'class' => 'aifi-service-field-row aifi-google-field' // Klassen für die TR-Zeile ] ); // Pollinations.ai add_settings_field( 'aifi_pollinations_model', 'Pollinations.ai - ' . __( 'Model Identifier', 'ai-featured-image' ), [ self::class, 'render_pollinations_model_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_pollinations_model', 'class' => 'aifi-service-field-row aifi-pollinations-field' ] ); // NEU: Pollinations Dimensionen add_settings_field( 'aifi_pollinations_width', 'Pollinations.ai - ' . __( 'Width', 'ai-featured-image' ), [ self::class, 'render_pollinations_width_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_pollinations_width', 'class' => 'aifi-service-field-row aifi-pollinations-field' ] ); add_settings_field( 'aifi_pollinations_height', 'Pollinations.ai - ' . __( 'Height', 'ai-featured-image' ), [ self::class, 'render_pollinations_height_field' ], 'aifi-settings', 'aifi_api_settings_section', [ 'label_for' => 'aifi_pollinations_height', 'class' => 'aifi-service-field-row aifi-pollinations-field' ] ); // --- NEU: Prompt Einstellungen Sektion --- add_settings_section( 'aifi_prompt_settings_section', // Neue Sektions-ID __( 'AI-Prompt Settings', 'ai-featured-image' ), // Titel der Sektion function() { // Optional: Beschreibung für die Sektion echo '

' . esc_html__( 'Specify which text should be used as the basis for the automatically generated prompt if no manual prompt is entered in the editor.', 'ai-featured-image' ) . '

'; }, 'aifi-settings' // Gehört zur gleichen Seite ); // NEU: Feld für Prompt-Quelle add_settings_field( 'aifi_prompt_source', // ID des Feldes __( 'Source for auto-prompt', 'ai-featured-image' ), // Label [ self::class, 'render_prompt_source_field' ], // Callback-Funktion 'aifi-settings', // Page Slug 'aifi_prompt_settings_section', // ID der neuen Sektion ['label_for' => 'aifi_prompt_source'] // Für das Label-Tag ); } /** * NEU: Rendert die Steuerelemente für Stability AI Dimensionen (XL Select + v1.6 Inputs). * Enthält auch die versteckten Felder zum Speichern. */ public static function render_stabilityai_dimensions_controls( $args ) { // Aktuell gespeicherte Werte holen (oder Defaults) // Defaults werden jetzt besser im JS und im API Handler gesetzt, hier nur laden, was da ist. $current_width = self::get_option_value('stabilityai_width', 0); $current_height = self::get_option_value('stabilityai_height', 0); $current_engine = self::get_option_value('stabilityai_engine_id', 'stable-diffusion-v1-6'); // Definiere die XL Dimensionen $xl_dimensions = [ "1024x1024" => "1024 x 1024 (Default)", "1152x896" => "1152 x 896", "1216x832" => "1216 x 832", "1344x768" => "1344 x 768", "1536x640" => "1536 x 640" // keine Hochformate ]; $current_xl_dim_key = $current_width . 'x' . $current_height; ?> __( 'Page - or Post title', 'ai-featured-image' ), 'excerpt' => __( 'Excerpt (preferred)', 'ai-featured-image' ), 'content' => __( 'Page - or Post content', 'ai-featured-image' ), // Hier könnten später leicht weitere Quellen hinzugefügt werden ]; ?>



__( 'ClipDrop', 'ai-featured-image' ), 'stabilityai' => __( 'Stability AI', 'ai-featured-image' ), // 'google' => __( 'Google Gemini', 'ai-featured-image' ), 'pollinations' => __( 'Pollinations.ai', 'ai-featured-image' ), ]; // Das $allowed_services Array aus deiner sanitize_settings Funktion // sollte idealerweise hier auch zugänglich sein oder direkt die Keys von $available_services verwendet werden. // Für dieses Beispiel nehmen wir an, dass die Keys von $available_services die erlaubten Dienste sind. $allowed_services = array_keys($available_services); ?>

'Stable Diffusion XL 1.0 (Default)', 'stable-diffusion-v1-6' => 'Stable Diffusion 1.6' // --- Füge hier bei Bedarf weitere Engine IDs hinzu --- ]; $custom_option_value = '_custom_'; // Interner Wert für manuelle Eingabe // Standard festlegen $default_engine = 'stable-diffusion-v1-6'; $current_engine_id = self::get_option_value('stabilityai_engine_id', $default_engine); // Prüfen, ob der gespeicherte Wert ein vordefinierter oder ein benutzerdefinierter ist $is_custom = !array_key_exists( $current_engine_id, $available_engines ); $select_value = $is_custom ? $custom_option_value : $current_engine_id; $custom_input_value = $is_custom ? $current_engine_id : ''; // Nur füllen, wenn custom aktiv war ?>



">



px

px

'; echo '

'; echo esc_html__('The AI Featured Image plugin (AIFI) generates featured images for each page or post if you want. The creation can be done as part of editing a post or page. The images are generated by AI based on the title, excerpt, or page content. Alternatively, you can define your own AI prompt for image generation.', 'ai-featured-image') . '

'; echo esc_html__('This is an experimental development. AIs are capricious and extremely volatile. I have had good experiences with Stability.AI and Pollutions.AI. Neither of them usually makes a fuss or complains. Clipdrop sometimes refuses to generate an image due to the text it reads from the website. Google refuses to generate practically any image due to some unknown rule. However, I am working on including Google and other AIs here. Perhaps a generic provider will be available in the future that will allow a wide variety of models to be selected. Pollutions.AI works without requiring an API key, so it works from scratch, so to speak. All other AIs require an account. Here, too, I am looking for solutions to circumvent the annoying logins and accounts. I would be grateful if you could give me any suggestions.', 'ai-featured-image') . '

'; echo ''; echo '
'; echo '

' . esc_html__('To use the AI service, select it and configure its settings. You must first create an account with the AI service and generate an API key. Use the links at the bottom of this page to do so.', 'ai-featured-image') . '

'; ?>



| | | Pollinations.ai API Docs