- This topic is empty.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
November 3, 2011 at 3:25 pm #35030gilgimechParticipant
I’m writing a plugin for my site that preserves html tags in the excerpt. I got it to work with a textfield. Where I manually put in the html tags, but I want to use checkbox’s instead.
I have an array of the html tags called $excerpt_tags and a foreach loop that outputs the array list with checkbox’s.
I just don’t know how to set the checkbox’s to my preserve html option
Here’s the code for the texfield
public function lz_excerpt($lz_text) {
$get_lz_funSettings = new FunctionSettings();
$lz_values = $get_lz_funSettings->lz_funcSettings();
$raw_excerpt = $lz_text;
if ( '' == $lz_text ) {
//Retrieve the post content.
$lz_text = get_the_content('');
//Delete all shortcode tags from the content.
$lz_text = strip_shortcodes( $lz_text );
$lz_text = apply_filters('the_content', $lz_text);
$lz_text = str_replace(']]>', ']]>', $lz_text);
$lz_allowed_tags = $lz_values;
$lz_text = strip_tags($lz_text, $lz_allowed_tags);
if ($lz_values == 'true') {
$lz_excerptlength = $lz_values;
$lz_set_excerpt_length = apply_filters('excerpt_length', $lz_excerptlength);
}
if ($lz_values == 'true') {
$lz_excerptMoreLink = $lz_values;
$lz_excerpt_more_link = apply_filters('excerpt_more', ' '. $lz_excerptMoreLink.' ');
}
$words = preg_split("/[nrt ]+/", $lz_text, $lz_set_excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $lz_set_excerpt_length ) {
array_pop($words);
$lz_text = implode(' ', $words);
$lz_text = $lz_text . $lz_excerpt_more_link;
} else {
$lz_text = implode(' ', $words);
}
}
return apply_filters('wp_trim_excerpt', $lz_text, $raw_excerpt);
}
}
if (!class_exists("functionSettings")) {
class functionSettings {
public $lz_adminOptionsName = "HeadCleanUpAdminOptions";
public function lz_funcSettings(){
$lz_adminOptions = array(
'ena_expLength' => 'false',
'set_expLength' => '10',
'ena_expMoreLink' => 'false',
'set_expMoreLink' => '',
'set_allowed_tags' => ''
);
$lz_settings = get_option($this->lz_adminOptionsName);
if (!empty($lz_settings)) {
foreach ($lz_settings as $key => $option)
$lz_adminOptions[$key] = $option;
}
update_option($this->lz_adminOptionsName, $lz_adminOptions);
return $lz_settings;
}
}
Preserved Tags
Like I said this works, so how can I do this but with checkbox’s?
-
AuthorPosts
Viewing 1 post (of 1 total)
- The forum ‘Other’ is closed to new topics and replies.