Skip to content

Instantly share code, notes, and snippets.

@nilshendriks
Created July 11, 2012 02:22
Show Gist options
  • Save nilshendriks/3087541 to your computer and use it in GitHub Desktop.
Save nilshendriks/3087541 to your computer and use it in GitHub Desktop.
kirbytext.extended.php with quote tag
<?php
/* This is Bastian's original file extended with the function for the quote tag. This file goes in the plugins folder */
class kirbytextExtended extends kirbytext {
function __construct($text, $markdown=true) {
parent::__construct($text, $markdown);
// define custom tags
$this->addTags('wikipedia');
$this->addTags('quote');
// define custom attributes
$this->addAttributes('language');
//$this->addAttributes('lang');
}
// define a function for each new tag you specify
function wikipedia($params) {
$search = $params['wikipedia'];
// define default values for attributes
$defaults = array(
'language' => 'en',
'text' => $search
);
// merge the given parameters with the default values
$options = array_merge($defaults, $params);
// build the final url
$url = 'http://' . $options['language'] . '.wikipedia.org/w/index.php?search=' . urlencode($search);
// build the link tag
return '<a class="wikipedia" href="' . $url . '">' . html($options['text']) . '</a>';
}
function quote($params) {
$search = $params['quote'];
// define default values for attributes
$defaults = array(
'language' => 'en',
'text' => $search
);
// merge the given parameters with the default values
$options = array_merge($defaults, $params);
// build tag
return '<blockquote lang="'.$options['language'].'"><p>'. html($options['text']) . '</p></blockquote>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment