. */ function GurkenStripper($text) { global $post; $admin = new GurkenStripper_Admin(); $delimiter = $admin->getOption("delimiter"); $display = false; $bit = $admin->getOption("display"); if (is_front_page() && $bit & 1) { $display = true; } if (is_paged() && $bit & 2) { $display = true; } if (is_category() && $bit & 4) { $display = true; } if (is_tag() && $bit & 8) { $display = true; } if (is_archive() && $bit & 16) { $display = true; } if (is_search() && $bit & 32) { $display = true; } if (is_404() && $bit & 64) { $display = true; } if ($display) { $text = get_the_content(NULL); $text = GurkenStripper_Text($text); } return $text; } function GurkenStripper_Text($text = NULL, $options = NULL) { global $post; if (!is_array($options)) { $options = array(); } $admin = new GurkenStripper_Admin(); $options = array_merge( array( "excerptLength" => $admin->getOption("excerptLength"), "delimiter" => $admin->getOption("delimiter") ), $options ); if (!$text) { $text = get_the_content(NULL); } $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $words = explode(' ', $text, $options["excerptLength"] + 1); if (count($words) > $options["excerptLength"]) { array_pop($words); $text = implode(' ', $words); } $text .= ' ' . $options["delimiter"] . ''; return $text; } function GurkenStripper_TextDisplay($text = NULL, $options = NULL) { print GurkenStripper_Text($text, $options); } add_action('the_content', "GurkenStripper"); class GurkenStripper_Admin { public function __construct() {} public function getOptions() { $defaultOptions = array( "excerptLength" => "55", "delimiter" => "[...]", "display" => 0 ); $options = get_option("GurkenStripper"); if (empty($options)) { foreach ($defaultOptions as $key => $option) { $options[$key] = $option; } update_option("GurkenStripper", $options); } return $options; } public function getOption($offset) { $options = $this->getOptions(); return isset($options[$offset]) ? $options[$offset] : NULL; } } function GurkenStripper_Admin() { $admin = new GurkenStripper_Admin(); $options = $admin->getOptions(); if (!empty($_POST["GurkenStripper"])) { $config = stripslashes_deep($_POST["GurkenStripper"]); if (!empty($_POST["display"]) && is_array($_POST["display"])) { $config["display"] = array_sum($_POST["display"]); } update_option("GurkenStripper", $config); } $display = $admin->getOption("display"); ?>

Gurken Stripper

Excerpt-Länge
Trenner (z.B. [...])
Ausführen in " value="1" /> Startseite
" value="2" /> Folgeseiten (Paged)
" value="4" /> Kategorie
" value="8" /> Tags
" value="16" /> Archiv
" value="32" /> Suche
" value="64" /> 404-Fehler