Veröffentlichung 15. August 2018 @ 22:40
Letzte Änderung 15. August 2018 @ 22:40
Überblick
- „Primitives“ Plugin für Shortcodes für den Zeitpunkt der Veröffentlichung und der letzen Änderung eines WordPress-Beitrags
- Präfixe „self“ für PHP-Funktionen und „self-“ für Plugin-Verzeichnis, Plugin-Datei und Shortcodes
Voraussetzungen
Netzwerk
- Website https://wordpress.example.com
Software
- WordPress 4.9.8 #https://wordpress.example.com/wp-admin/update-core.php
Ordner und Dateien
- Installation /usr/share/wordpress/wp-content/plugins/self-shortcodes
Plugin-Verzeichnis anlegen
mkdir /usr/share/wordpress/wp-content/plugins/self-shortcodes
Plugin-Datei erstellen
<?php /* Plugin Name: SELF Shortcodes Description: Provide shortcodes 'self-modified' for last modification timestamp and 'self-published' for publishing timestamp Version: 2018-08-15 Author: Thomas Fabian Author URI: https://www.fabiblog.de License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html */ if (!function_exists ('selfShortcodeModified')) { function selfShortcodeModified () { return get_the_modified_date () . ' @ ' . get_the_modified_time (); } if (!shortcode_exists ('self-modified')) { add_shortcode ('self-modified', 'selfShortcodeModified'); } } if (!function_exists ('selfShortcodePublished')) { function selfShortcodePublished () { return get_the_date () . ' @ ' . get_the_time (); } if (!shortcode_exists ('self-published')) { add_shortcode ('self-published', 'selfShortcodePublished'); } } ?>
Zugriffsrechte setzen
chown --recursive www-data:www-data /usr/share/wordpress/wp-content/plugins/self-shortcodes
Plugin aktivieren
https://wordpress.example.com/wp-admin/plugins.php SELF Shortcodes - Aktivieren
Beispiel für Nutzung innerhalb eines Beitrags
... <i>Veröffentlichung [self-published]</i> <i>Letzte Änderung [self-modified]</i> ...
Quellen
https://codex.wordpress.org/shortcode
https://codex.wordpress.org/Writing_a_Plugin
https://developer.wordpress.org/plugins/
https://developer.wordpress.org/reference/