#", '', $text); echo $wp_tags->parse($text); } else { echo 'try this file url + "?source=true"'; } class Tags { var $current_tag; var $namespace; var $tags; var $specials; // Hi! I am stolen from TextPattern. Go GPL! function parse($text) { $f = '/<'.$this->namespace.':(\S+)\b(.*)(?:(?](?(3)|(.+)<\/'.$this->namespace.':\1>)/sU'; //$f = '/)/sU'; return preg_replace_callback($f, array(&$this, 'process_tags'), $text); } function process_tags($matches) { $tag = $matches[1]; $atts = (isset($matches[2])) ? $this->get_attributes($matches[2]) : ''; $thing = (isset($matches[4])) ? $matches[4] : ''; $old_tag = @$this->current_tag; $this->current_tag = '' : '/>'); $out = ''; $out = $this->tag($tag, $atts, $thing, $matches[0]); $this->current_tag = $old_tag; return $out; } function get_attributes($text) { $atts = array(); if (preg_match_all('/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)/', $text, $match, PREG_SET_ORDER)) { foreach ($match as $m) { if (!empty($m[1])) $atts[strtolower($m[1])] = stripcslashes($m[2]); elseif (!empty($m[3])) $atts[strtolower($m[3])] = stripcslashes($m[4]); elseif (!empty($m[5])) $atts[strtolower($m[5])] = stripcslashes($m[6]); } } return $atts; } // function tag($tag_name, $attributes, $thing, $raw_tag) { if (isset($this->specials[$tag_name])) { return $tag_name($thing); } elseif (isset($this->tags[$tag_name])) { $tag = $this->tags[$tag_name]; if (is_string($tag)) { return $this->tag_no_args($tag); } else { $out_args = array(); $args = $tag[1]; $func = $tag[0]; foreach ($args as $arg) { if (!isset($attributes[$arg])) { return $this->tag_with_args($func, $out_args); } else { $out_args[] = addslashes($attributes[$arg]); } } return $this->tag_with_args($func, $out_args); } } else { return false; } } function tag_no_args($func) { return ""; } function tag_with_args($func, $out_args) { if (0 == count($out_args)) $args = ''; else $args = "'" . implode("','", $out_args) . "'"; return ""; } } class WP_Tags extends Tags { var $namespace = 'wp'; // These tags map to WP template functions. There are a lot of them. var $tags = array( // // template-functions general // 'get_header' => 'get_header', 'get_footer' => 'get_footer', 'get_sidebar' => 'get_sidebar', 'wp_loginout' => 'wp_loginout', 'wp_register' => array('wp_register', array('before', 'after')), 'wp_meta' => 'wp_meta', 'bloginfo' => array('bloginfo', array('show')), 'wp_title' => array('wp_title', array('sep')), 'single_post_title' => array('single_post_title', array('prefix')), 'single_cat_title' => array('single_cat_title', array('prefix')), 'single_month_title' => array('single_month_title', array('prefix')), 'wp_get_archives' => array('wp_get_archives', array('args')), 'get_archives' => array('get_archives', array('type', 'limit', 'format', 'before', 'after', 'show_post_count')), 'get_calendar' => array('get_calendar', array('daylength')), 'the_date_xml' => 'the_date_xml', 'the_date' => array('the_date', array('d', 'before', 'after')), 'the_time' => array('the_time', array('d')), 'the_modified_time' => array('the_modified_time', array('d')), 'the_weekday' => 'the_weekday', 'the_weekday_date' => array('the_weekday_date', array('before', 'after')), 'rsd_link' => 'rsd_link', // // template-functions-post // 'the_ID' => 'the_ID', 'the_title' => array('the_title', array('d', 'before', 'after')), 'the_guid' => 'the_guid', /**/ 'the_content' => array('the_content', array('more_link_text', 'stripteaser', 'more_file')), 'the_excerpt' => 'the_excerpt', 'wp_link_pages' => array('wp_link_pages', array('args')), /**/'link_pages' => array('link_pages', array('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file')), 'the_meta' => 'the_meta', 'wp_list_pages' => array('wp_list_pages', array('args')), 'the_attachment_link' => array('the_attachment_link', array('id', 'fullsize', 'max_dims')), // // template-functions-author // 'the_author' => 'the_author', 'the_author_description' => 'the_author_description', 'the_author_login' => 'the_author_login', 'the_author_firstname' => 'the_author_firstname', 'the_author_lastname' => 'the_author_lastname', 'the_author_nickname' => 'the_author_nickname', 'the_author_ID' => 'the_author_ID', 'the_author_email' => 'the_author_email', 'the_author_url' => 'the_author_url', 'the_author_icq' => 'the_author_icq', 'the_author_aim' => 'the_author_aim', 'the_author_yim' => 'the_author_yim', 'the_author_msn' => 'the_author_msn', 'the_author_posts' => 'the_author_posts', 'the_author_posts_link' => array('the_author_posts_link', array('idmode')), 'wp_list_authors' => array('wp_list_authors', array('args')), 'list_authors' => array('list_authors', array('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image')), // // template-functions-category // 'the_category' => array('the_category', array('separator', 'parents')), 'dropdown_cats' => array('dropdown_cats', array('optionall', 'all', 'sort_column', 'sort_order', 'optiondates', 'optioncount', 'hide_empty', 'optionnone', 'selected', 'hide')), 'wp_list_cats' => array('wp_list_cats', array('args')), /**/'list_cats' => array('list_cats', array('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical')), // // template-functions-links // 'the_permalink' => 'the_permalink', 'permalink_anchor' => array('the_permalink', array('mode')), 'edit_post_link' => array('edit_post_link', array('link', 'before', 'after')), 'edit_comment_link' => array('edit_comment_link', array('link', 'before', 'after')), 'previous_post_link' => array('previous_post_link', array('format', 'link', 'in_same_cat', 'excluded_categories')), 'next_post_link' => array('next_post_link', array('format', 'link', 'in_same_cat', 'excluded_categories')), 'next_posts' => array('next_posts', array('max_page')), 'next_posts_link' => array('next_posts_link', array('label', 'max_page')), 'previous_posts' => 'next_posts', 'previous_posts_link' => array('next_posts_link', array('label')), 'posts_nav_link' => array('posts_nav_link', array('sep', 'prelabel', 'nxtlabel')), // // comment-functions // /**/'comments_template' => array('comments_template', array('file')), 'comments_number' => array('comments_number', array('zero', 'one', 'more', 'number')), 'comments_link' => 'comments_link', 'comments_popup_script' => array('comments_popup_script', array('width', 'height', 'file')), 'comments_popup_link' => array('comments_popup_link', array('zero', 'one', 'more', 'CSSclass', 'none')), 'comment_ID' => 'comment_ID', 'comment_author' => 'comment_author', 'comment_author_email' => 'comment_author_email', 'comment_author_link' => 'comment_author_link', 'comment_type' => array('comment_type', array('commenttxt', 'trackbacktxt', 'pingbacktxt')), 'comment_author_url' => 'comment_author_url', 'comment_author_email_link' => array('comment_author_email_link', array('linktext', 'before', 'after')), 'comment_author_url_link' => array('comment_author_url_link', array('linktext', 'before', 'after')), 'comment_author_IP' => 'comment_author_IP', 'comment_text' => 'comment_text', 'comment_excerpt' => 'comment_excerpt', 'comment_date' => array('comment_date', array('d')), 'comment_time' => array('comment_time', array('d')), 'trackback_url' => 'trackback_url', 'trackback_rdf' => 'trackback_rdf' ); // These tags call functions defined in this file. // var $specials = array( 'if_have_posts' => 'if_have_posts', 'if_not_have_posts' => 'if_not_have_posts', 'if_pings_open' => 'if_pings_open', 'if_pings_not_open' => 'if_pings_not_open', 'if_comments_open' => 'if_comments_open', 'if_comments_not_open' => 'if_comments_not_open', 'start_loop' => 'start_loop', 'end_loop' => 'tag_endwhile', 'else' => 'tag_else', 'end_if' => 'tag_endif', 'the_loop' => 'the_loop', 'searchform' => 'searchform' ); function __construct() { // Plugin extensible. //$this->tags = apply_filters('template_tags', $this->tags); } //PHP4 style constructor function WP_Tags() { $this->__construct(); } } /* tag functions */ function searchform() { return '' . "\n"; } function if_have_posts($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function if_not_have_posts($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function if_pings_open($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function if_pings_not_open($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function if_comments_open($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function if_comments_not_open($inside) { global $wp_tags; return "\n" . $wp_tags->parse($inside) . "\n"; } function start_loop() { return "\n"; } function tag_while() { return "\n"; } function tag_else() { return "\n"; } function tag_endif() { return "\n"; } function the_loop($inside) { global $wp_tags; $out = "\n"; if ($inside) $out .= $wp_tags->parse($inside); $out .= "\n"; return $out; } ?>