Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/wp-db.php on line 668 Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/wp-db.php on line 668 Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/wp-db.php on line 668 Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-theme.php on line 554 Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-theme.php on line 595 Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-theme.php on line 535 Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-theme.php on line 544 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/comment-template.php on line 1739 Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/rest-api/class-wp-rest-request.php on line 952 Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/rest-api/class-wp-rest-request.php on line 972 Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/rest-api/class-wp-rest-request.php on line 984 Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/rest-api/class-wp-rest-request.php on line 995 Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 151 Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 175 Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 164 Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 186 Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 138 Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 75 Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 89 Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 110 Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 127 Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-block-list.php on line 199 Deprecated: Optional parameter $type declared before required parameter $wrapper is implicitly treated as a required parameter in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/class-fs-logger.php on line 145 Deprecated: Return type of FS_Key_Value_Storage::offsetExists($k) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 309 Deprecated: Return type of FS_Key_Value_Storage::offsetGet($k) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 317 Deprecated: Return type of FS_Key_Value_Storage::offsetSet($k, $v) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 301 Deprecated: Return type of FS_Key_Value_Storage::offsetUnset($k) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 313 Deprecated: Return type of FS_Key_Value_Storage::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 328 Deprecated: Return type of FS_Key_Value_Storage::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 339 Deprecated: Return type of FS_Key_Value_Storage::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 350 Deprecated: Return type of FS_Key_Value_Storage::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 362 Deprecated: Return type of FS_Key_Value_Storage::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 375 Deprecated: Return type of FS_Key_Value_Storage::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/freemius/includes/managers/class-fs-key-value-storage.php on line 389 Deprecated: Return type of WPCF7_FormTag::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 395 Deprecated: Return type of WPCF7_FormTag::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 387 Deprecated: Return type of WPCF7_FormTag::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 381 Deprecated: Return type of WPCF7_FormTag::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/contact-form-7/includes/form-tag.php on line 399 Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/contact-form-7/includes/mail.php on line 162 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: Optional parameter $errors declared before required parameter $instance is implicitly treated as a required parameter in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/so-widgets-bundle/widgets/contact/contact.php on line 916 Deprecated: Creation of dynamic property Elementor\Plugin::$icons_manager is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/elementor/includes/plugin.php on line 605 Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/script-loader.php on line 331 Deprecated: Creation of dynamic property POMO_FileReader::$is_overloaded is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 21 Deprecated: Creation of dynamic property POMO_FileReader::$_pos is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 22 Deprecated: Creation of dynamic property POMO_FileReader::$_f is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/streams.php on line 153 Deprecated: Creation of dynamic property MO::$_gettext_select_plural_form is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/pomo/translations.php on line 293 Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp.php on line 173 Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-term.php on line 198 Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-term.php on line 198 Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-term.php on line 198 Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class-wp-term.php on line 198 PlugIn für WordPress erstellen – Will Maquire Warning: Only the first byte will be assigned to the string offset in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/class.wp-scripts.php on line 492

PlugIn für WordPress erstellen

Deprecated: Optional parameter $content declared before required parameter $tag is implicitly treated as a required parameter in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-content/plugins/addons-for-elementor/includes/widgets/pricing-table.php on line 33

Am Ende wird alles gut. Wenn es nicht gut wird, ist es noch nicht das Ende.

Oscar Fingal O Flahertie Wills Wilde (*1854 †1900)

Das WordPress-Plugin Trancelantic Random Citation zeigt ein Zufallszitat aus der Trancelantic Zitate Datenbank mit Hilfe eines Shortcodes auf einer WordPress-Webseite an. Es ist einfach und übersichtlich aufgebaut mit einer klaren Schichtentrennung und einer interessante Datenhaltung. Alles selbsterklärend kommentiert. Einfach mal ein kurzes Statement anzeigen. Oder als Blaupause für den eigenen kleinen Helfer benutzen.
Als Datenquelle nutze ich unsere Trancelantic Zitate Datenbank. Die Sammlung wurde bereits über mehrere Jahre von uns gefuttert. Und sie wächst und wächst und wächst. Über sie erhalten wir ein JSON-String mit einem Zufallszitat. Realisiert ist diese API übrigens unserem Trancelantic Corinth Framework. Wer seine eigene Datenbank mit API aufbauen will sollte sich das mal genauer anschauen.

Aufbau des Plugins

Das Plugin besteht aus den nötigsten Dateien. Wichtig ist (für mich) eine klare Trennung der Views vom Controller. Damit ist der ganze HTML und CSS-Code jeweils separat in einer Datei. Die Logik übernimmt die übergeordnete PHP-Datei.

Das Plugin-Verzeichnis trancelantic_random_citation und die Haupt-Plugin-Datei trancelantic_random_citation.php haben den gleichen Namen. Aus diesem Verzeichnis später einfach eine Zip-Datei mit denselben Namen trancelantic_random_citation.zip als Installationspaket generieren. Abschließend die Zip-Datei im WordPress-Adminbereich hochladen und aktivieren.

Aufbau der Views und der CSS

Die Views werden von der Plugin-Steuerung programmatisch included. Die random.php zeigt nur den Inhalt des Arrays $citation an und packt ein bisschen HTML rings herum. Ist dieses Array leer, gibt es einen Hinweis. Bei Interesse bitte selber die Datei anschauen. Die css.php macht den ganzen Spaß noch ein bisschen schicker. Sie wird final am Ende des Skripts mit eingehängt. Interessant wird aber erst die Plugin-Steuerung.

Die Plugin-Steuerung

Die Datei trancelantic_random_citation.php übernimmt die Hauptsteuerung und wird von WordPress als einziges aufgerufen. Wenn mehr Dateien benötigt werden, muss man diese selber includen. WordPress benötigt ein paar Informationen, wie Name, Version und eine Beschreibung. Der Name der Haupt-Datei und der Eintrag Text Domain müssen identische sein: Text Domain: trancelantic_random_citation.
Eine große Sicherheitslücke besteht darin, dass jemand von Aussen dieses Plugin ausführen kann. Das wird mit defined('ABSPATH') or die verhindert. So kann nur WordPress die Plugin-Logik ausführen.
  
defined('ABSPATH') or die("Thanks for visting");

/*
* Plugin Name: Trancelantic Random Citation
* Plugin URI: http://www.trancelantic.com
* Description: WordPress plugin to show random citation provided by Trancelantic Citation Database.
* Version: 1.0
* Author: Wilfried Katschmarz
* Author URI: http://www.trancelantic.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: trancelantic_random_citation
*/
  

Datenhaltung nach Singleton-Art

Hier wird gewährleistet, das nur bei Zugriff auf die Daten diese von der URL geladen werden. Und das auch nur einmal. Danach werden die lokalen Daten benutzt. Ist das Daten-Array leer, dann ist irgendwo auf dem Weg ein Fehler aufgetreten. Ein weiteres Nachladen wird hier vermieden. Die View übernimmt später die Auswertung.
  
define('TLRC_URL', 'http://api.citations.trancelantic.com/');

/*
* Local stored random citation.
* Use always tlrc_get_random_citation() to trigger loading
*/
$tlrc_random_citation;
	
/*
* Will load random citation from url and store it local.
* If you have allready loaded a random citation you will get the local stored citation.
* On error you will get an empty array.
*/
function tlrc_get_random_citation() 
{
	global $tlrc_random_citation;

	if (is_null($tlrc_random_citation)) 
	{ 
		$tlrc_random_citation = array();
		$headers = @get_headers(TLRC_URL); 
		  
		// Use condition to check the existence of URL 
		if ($headers && strpos($headers[0], '200'))
		{ 
		    $json = file_get_contents(TLRC_URL);
			$rawData = json_decode($json, true);

			if (array_key_exists("Citation", $rawData))
			{
				$tlrc_random_citation = $rawData['Citation'];
			}
		} 
	} 

	return $tlrc_random_citation;
}
  

Views einbinden

Die Funktion tlrc_get_random_citation_view übernimmt die Anzeige des Zitats. Wenn keine Argumente übergeben worden sind, dann wird die View angezeigt. Ist in den Argumenten der Eintrag key vorhanden, wird der spezielle Wert ausgegeben (Zitat, Author oder Jahr).
  
/*
* Will show blockquote random citation view if no args defined.
* If arg contains key you will get specific citation data (citation, author or year).
*/ 
function tlrc_get_random_citation_view($arg) 
{
	$citation = tlrc_get_random_citation();

	// Looking for key in arguments with content
	if (is_array($arg) && array_key_exists('key', $arg) && $arg['key'] != '')
	{
		if (empty($citation))
		{
			return 'TLRC-Error: Cannot load random citation.';
		}
		else
		{
			$key = $arg['key'];

			if (array_key_exists($key, $citation))
			{
				return $citation[$key];
			}
			else
			{
				return 'TLRC-Error: Unknwon citation key ('.$key.').';
			}
		}
	}
	else
	{
		// No arguments or missing key or empty key
		ob_start();
		include 'views/random.php';
  		return ob_get_clean();
	}
}

/*
* Add Shortcode for tlrc_data.
*/
add_shortcode( 'tlrc_data', 'tlrc_show_random_citation' );
  

CSS-Datei einbinden

Ganz zum Schluss muss noch die CSS-Datei eingebunden werden. Das Einbinden eines Styles ist optional. Wenn die Style-Datei nicht eingebunden wird, dann wird das aktuelle WordPress-Template benutzt.
  
/*
* Will show css file for random citation.
*/
function tlrc_show_random_citation_css_view() 
{
	include 'views/css.php';
}

/*
* Hock css file on building header.
*/
add_action( 'wp_head', 'tlrc_show_random_citation_css_view' );
  

Shortcodes in WordPress veröffentlichen

Zum Anzeigen des Zitats auf der Webseite müssen noch die Shortcodes veröffentlicht werden. Dafür die Shortcodes in ein Shortcode-Widget oder ein Textfeld eintragen.
[tlrc_data key="Citation"] zeigt das Zitat.
[tlrc_data key="Author"] zeigt den Autor.
[tlrc_data key="Year"] zeigt zeigt das Jahr.
Am Ende wird alles gut. Wenn es nicht gut wird, ist es noch nicht das Ende.
Oscar Fingal O Flahertie Wills Wilde
*1854 †1900
Unser Plugin hat noch ein Widget und ist Mehrsprachig. Es ist dennoch ähnlich einfach aufgebaut. Teilweise objektorientiert Abstrahiert, aber immer noch einfach genug um die Grundfunktionen kennenzulernen. Einfach runterladen und anschauen..
[tlrc_citation] zeigt die View mit einfachen HTML-Blockquotes.

Am Ende wird alles gut. Wenn es nicht gut wird, ist es noch nicht das Ende.

Oscar Fingal O Flahertie Wills Wilde (*1854 †1900)

Das war’s.
Deprecated: Creation of dynamic property WP_Post::$db_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 809 Deprecated: Creation of dynamic property WP_Post::$menu_item_parent is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 810 Deprecated: Creation of dynamic property WP_Post::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 811 Deprecated: Creation of dynamic property WP_Post::$object is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 812 Deprecated: Creation of dynamic property WP_Post::$type is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 813 Deprecated: Creation of dynamic property WP_Post::$type_label is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 898 Deprecated: Creation of dynamic property WP_Post::$title is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 899 Deprecated: Creation of dynamic property WP_Post::$url is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 900 Deprecated: Creation of dynamic property WP_Post::$target is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 903 Deprecated: Creation of dynamic property WP_Post::$attr_title is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 912 Deprecated: Creation of dynamic property WP_Post::$description is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 922 Deprecated: Creation of dynamic property WP_Post::$classes is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 925 Deprecated: Creation of dynamic property WP_Post::$xfn is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 926 Deprecated: Creation of dynamic property WP_Post::$db_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 809 Deprecated: Creation of dynamic property WP_Post::$menu_item_parent is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 810 Deprecated: Creation of dynamic property WP_Post::$object_id is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 811 Deprecated: Creation of dynamic property WP_Post::$object is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 812 Deprecated: Creation of dynamic property WP_Post::$type is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 813 Deprecated: Creation of dynamic property WP_Post::$type_label is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 898 Deprecated: Creation of dynamic property WP_Post::$title is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 899 Deprecated: Creation of dynamic property WP_Post::$url is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 900 Deprecated: Creation of dynamic property WP_Post::$target is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 903 Deprecated: Creation of dynamic property WP_Post::$attr_title is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 912 Deprecated: Creation of dynamic property WP_Post::$description is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 922 Deprecated: Creation of dynamic property WP_Post::$classes is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 925 Deprecated: Creation of dynamic property WP_Post::$xfn is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu.php on line 926 Deprecated: Creation of dynamic property WP_Post::$current is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 386 Deprecated: Creation of dynamic property WP_Post::$current is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 386 Deprecated: Creation of dynamic property WP_Post::$current_item_ancestor is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 532 Deprecated: Creation of dynamic property WP_Post::$current_item_parent is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 533 Deprecated: Creation of dynamic property WP_Post::$current_item_ancestor is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 532 Deprecated: Creation of dynamic property WP_Post::$current_item_parent is deprecated in /mnt/web605/e0/76/51697076/htdocs/projects/maquire/wordpress/wp-includes/nav-menu-template.php on line 533