Hallo zusammen!
Ich benutze in meinem Blog das Plugin Kommentar Quicktags. Nun habe ich versucht es um einen Bild-Button zu erweitern, damit in den Kommentaren Bilder eingefügt werden können. Der Plugincode sieht so aus (rot, das was ich nun ergänzt habe):
PHP
<?php
/*
Plugin Name: Kommentar Quicktags
Plugin URI: http://www.daniel-erb.de/2007-06/tutorial-kommentar-quicktags/
Description: Fügt Quicktags in das Kommentarformular ein. WP 2.2 Unterstützung von <a href="http://www.enblogopedia.com/">Ibrahim Faour</a>, Dt. Übersetzung von <a href="http://www.daniel-erb.de/2007-06/tutorial-kommentar-quicktags/"> Daniel Erb</a>
Version: 2.0DE
Author: Owen Winkler
Author URI: http://www.asymptomatic.net
*/
/*** Comments Quicktags Plugin ***
Deutsche Übersetzung von Daniel Erb
Support: http://www.daniel-erb.de/kategorie/wp-plugin-uebersetzungen/
*** Installation ***
- Zip-Datei extrahieren und die comment_quicktags.php in den Plugin-Ordner kopieren
- Plugin aktivieren
- CSS-Style anpassen
- Wenn Ihnen das Plugin gefällt, dann hinterlassen Sie doch bitte einen Kommentar in meinem Weblog:
*** Lizenz ***
Comment Quicktags - Inserts a quicktag toolbar on the blog comment form.
This code is licensed under the MIT License.
http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2005 Owen Winkler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***/
/*** Programmcode ***/
if(defined('ABSPATH')) :
function comment_quicktags($unused) {
if(file_exists(ABSPATH . 'wp-includes/js/quicktags.js'))
$scripturl = get_settings('siteurl') . '/wp-includes/js/quicktags.js';
else
$scripturl = get_settings('siteurl') . '/wp-admin/quicktags.js';
$thisurl = get_settings('siteurl') . '/wp-content/plugins/' . plugin_basename(__FILE__);
echo '<script src="' . $scripturl . '" type="text/javascript"></script>' . "\n";
echo '<script src="' . $thisurl . '" type="text/javascript"></script>' . "\n";
echo '<style type="text/css">/* To fix kubrick: */
#commentform #ed_toolbar input.ed_button {
width:auto;
}</style>
';
ob_start('comment_quicktags_ob');
}
function comment_quicktags_ob($content) {
$toolbar = '<script type=\'text/javascript\'>
quicktagsL10n = {
quickLinks: "(Quick Links)",
wordLookup: "Geben Sie ein Wort ein, das uebersetzt werden soll:",
dictionaryLookup: "Wörterbuch durchsuchen",
lookup: "Wörterbuch",
closeAllOpenTags: "Tags schließen",
closeTags: "Tags schließen",
enterURL: "Geben Sie die URL ein",
enterImageURL: "Geben Sie die Bild-URL ein",
enterImageDescription: "Geben Sie eine Bildbeschreibung ein"
}
</script>
<script type="text/javascript">edToolbar()</script>';
$activate = '<script type="text/javascript">var edCanvas = document.getElementById(\'\\2\');</script>';
$content = preg_replace('/<textarea(.*?)id="([^"]*)"(.*?)>(.*?)<\/textarea>/', $toolbar . '<textarea\\1id="\\2"\\3>\\4</textarea>'.$activate, $content);
return $content;
}
add_action('wp_head', 'comment_quicktags');
else :
?>
var edButtons = new Array();
edButtons[edButtons.length] =
new edButton('ed_strong'
,'Fett'
,'<strong>'
,'</strong>'
,'/Fett'
);
edButtons[edButtons.length] =
new edButton('ed_em'
,'Kursiv'
,'<em>'
,'</em>'
,'/Kursiv'
);
edButtons[edButtons.length] =
new edButton('ed_link'
,'Link'
,''
,'</a>'
,'/a'
); // special case
[B][COLOR=Red]edButtons[edButtons.length] =
new edButton('ed_img'
,'Bild'
,'<img>'
,'</img>'
,'/Bild'
);[/COLOR][/B]
edButtons[edButtons.length] =
new edButton('ed_block'
,'Zitat'
,'<blockquote>'
,'</blockquote>'
,'/Zitat Ende'
);
edButtons[edButtons.length] =
new edButton('ed_pre'
,'Code'
,'<code>'
,'</code>'
,'/Code Ende'
);
<?php
endif;
?>
Alles anzeigen
Im Default-Theme scheint dies zu auf Anhieb zu funktionieren. In meinem eigenen jedoch nicht. Dort werde ich zwar auch nach Bild-URL und Beschreibung gefragt, aber nach dem Absenden des Kommentars ist dieser leer (also ein Kommentar ohne Inhalt). Warum und wieso erschließt sich mir nicht. Vielleicht weiß jemand von euch warum das so ist...
Link zum Blog
Ggf. diesen Beitrag in ein anderes Forum schieben.
Danke!