Hallo,
zunächst zur Funktionsweise des zukünftigen Plugins:
wenn in einem Beitrag beispielsweise der Kommentar
zufinden ist, dann soll das Plugin diesen Kommentar mit HTML-Code ersetzen.
Soweit so gut.
Nun zu meinem Problem:
Wenn innerhalb des selben Beitrags mehrere solcher Kommentare stehen, dann tauscht er nur den zuletzt angegebenen Kommentar aus, die anderen werden nicht ausgetauscht, selbst dann, wenn ich in der Funktion eb_cycle_the_content die Funktion eb_cycle_content mehrfach aufrufe.
Auch der Aufruf innerhalb der Funktion führt maximal zum Abbruch (je nachdem wie ich es programmiert habe).
Kann mir jemand weiterhelfen und mir sagen, was ich falsch mache?
Über Eure Hilfe wäre ich sehr dankbar.
Vielen Dank im Voraus.
VG Elke
PHP
<?php
add_action('wp_head', 'eb_cycle_wp_head',99);
add_action('the_content', 'eb_cycle_the_content');
function eb_cycle_wp_head() {
?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('url'); ?>/wp-content/plugins/eb_cycle/cycle.css" />
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/eb_cycle/jquery-1.2.6.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/eb_cycle/chili-1.7.pack.js"></script>
<script type="text/javascript" src="<?php bloginfo('url'); ?>/wp-content/plugins/eb_cycle/jquery.cycle.all.js?v2.11"></script>
<script type="text/javascript">
$(function() {
// run the code in the markup!
$('div pre code').each(function() {
eval($(this).text());
});
});
</script>
<?php
}
function eb_cycle_the_content($content) {
$content=eb_cycle_content($content);
//if (strpos($content,'<!-- ebcycle')!==false) {
$content=eb_cycle_content($content);
//}
return $content;
}
function eb_cycle_content($content) {
$ebpos= strripos($content, '<p><!-- ebcycle');
if ($ebpos !== false) {
$newcontent=substr($content,trim($ebpos));
$string = preg_replace('/<p>\s*<!-- ebcycle:s(.*)-->\s*<\/p>/i', "s$1", $newcontent);
$string2=trim(substr($string,1));
$string_array=explode(';',$string2);
if (empty($string_array[1])) $string_array[1]='images'; // Verzeichnis
if (empty($string_array[2])) $string_array[2]='fade'; // Art des Uebergangs
if (empty($string_array[4])) $string_array[4]='252'; // Breite der Bilder (max)
if (empty($string_array[5])) $string_array[5]='330'; // Höhe der Bilder (max)
if (empty($string_array[6])) $string_array[6]='px'; // Masseinheit
if (empty($string_array[7])) $string_array[7]=default_bild_auslesen(); // Bild das angezeigt wird, wenn javascript ausgeschaltet ist
if (!empty($string_array[3])) $string_array[3]=','.$string_array[3];
$url=get_bloginfo('url');
$pfad=$url.'/wp-content/uploads/'.$string_array[1].'/';
$style1=' width="'.$string_array[4].'" height="'.$string_array[5].'" ';
$style=' width="'.$string_array[4].'" height="auto" ';
$str1='<!-- ebcycle:s'.$string2.' -->';
$str2='<noscript><style type="text/css">#eb_diashow {display:none;}</style></noscript>';
$str2.='<div id="eb_diashow"><div id="s'.$string_array[0].'" class="pics" style="display:block;width:'.$string_array[4].$string_array[6].';height:'.$string_array[5].$string_array[6].';">';
$str2.=ordner_auslesen('wp-content/uploads/images', $style1, $style);
$str2.='</div><pre><code class="mix" style="display:none;">';
$str2.="$('#s".$string_array[0]."').cycle({fx:'".$string_array[2]."'".$string_array[3]."});";
$str2.='</code></pre></div>';
$str2.='<noscript><div class="pics"><img src="'.$pfad.$string_array[7].'"'.$style.' /></div></noscript>';
$content=str_replace($str1,$str2,$content);
}
return $content;
}
Alles anzeigen