image-rights-html-generator/image-rights-html-generator.php

81 lines
2.4 KiB
PHP
Raw Normal View History

2024-06-03 21:21:41 +00:00
<?php
/**
* Plugin Name: Image-Rights HTML-Generator
2024-06-04 16:41:52 +00:00
* Description: WordPress Plugin, Fügt einen Button hinzu, um Bildrechte zu bearbeiten und als HTML-Snippet in die Bildbeschriftung einzufügen.
2024-08-14 14:37:59 +00:00
* Version: 1.2
2024-06-04 16:41:52 +00:00
* Author: Joachim Happel
* Author URI: https://codeberg.org/johappel
2024-06-03 21:21:41 +00:00
*/
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() {
?>
2024-06-05 08:55:48 +00:00
<div id="modal" class="hidden">
<div class="modal-content bg-white">
2024-06-03 21:21:41 +00:00
<form id="metaDataForm">
2024-06-05 08:55:48 +00:00
<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>
2024-06-03 21:21:41 +00:00
</div>
</form>
</div>
</div>
<?php
}
add_action( 'admin_footer', 'irhg_add_modal' );
2024-06-05 08:55:48 +00:00
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);
2024-06-03 21:21:41 +00:00
?>