<?php /** * Plugin Name: Image-Rights HTML-Generator * Description: WordPress Plugin, Fügt einen Button hinzu, um Bildrechte zu bearbeiten und als HTML-Snippet in die Bildbeschriftung einzufügen. * Version: 1.1 * Author: Joachim Happel * Author URI: https://codeberg.org/johappel */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } function irhg_enqueue_scripts($hook) { // Enqueue script and style on all admin pages for testing wp_enqueue_script( 'irhg-script', plugin_dir_url( __FILE__ ) . 'js/image-rights-html-generator.js','jquery', '1.0', true ); wp_enqueue_style( 'irhg-style', plugin_dir_url( __FILE__ ) . 'css/style.css' ); } add_action( 'admin_enqueue_scripts', 'irhg_enqueue_scripts' ); function irhg_add_modal() { ?> <div id="modal" class="hidden"> <div class="modal-content bg-white"> <form id="metaDataForm"> <label for="imageTitle">Bildtitel</label> <input type="text" id="imageTitle" name="imageTitle"> <label for="imageSourceUrl">Bildquelle URL</label> <input type="url" id="imageSourceUrl" name="imageSourceUrl"> <label for="imageAuthor">Autor</label> <input type="text" id="imageAuthor" name="imageAuthor"> <label for="authorImageUrl">Autor Bild URL</label> <input type="url" id="authorImageUrl" name="authorImageUrl"> <label for="imageLicense">Lizenz/Rechte</label> <input type="text" id="imageLicense" name="imageLicense"> <label for="licenseUrl">Lizenz URL</label> <input type="url" id="licenseUrl" name="licenseUrl"> <div class="btn-container"> <button type="submit">Speichern</button> <button type="button" id="closeModal">Schließen</button> </div> </form> </div> </div> <button id="openModal">Bildrechte</button> <?php } add_action( 'admin_footer', 'irhg_add_modal' ); function add_custom_button_to_attachment_fields($form_fields, $post) { // Fügen Sie das HTML-Snippet für den Button hinzu $form_fields['open_modal_button'] = array( 'label' => '', 'input' => 'html', 'html' => '<div style="margin-top: 20px;"> <button id="openModal" class="button button-primary">Nutzungsrechte</button> </div>', ); return $form_fields; } add_filter('attachment_fields_to_edit', 'add_custom_button_to_attachment_fields', 10, 2); ?>