/** * Filter to manage contents. Check for [sk-shoutbox] tags. * This function should be called by a filter. * * @access public * @param string content The content to change. * @return string The content with the changes the plugin have to do. */ function sk_content($content) { $content = skLegacy_content($content); //The chat box $search = "/(?:<p>)*\\s*\\[schreikasten:([^,]+),(\\d+),(true|false)\\]\\s*(?:<\\/p>)*/i"; if (preg_match_all($search, $content, $matches)) { if (is_array($matches)) { foreach ($matches[1] as $key => $title) { // Get the data from the tag $items = $matches[2][$key]; $rss_icon = $matches[3][$key]; if ($rss_icon == 'true') { $rss_icon = true; } else { $rss_icon = false; } $search = $matches[0][$key]; // Create the script to show the feed $replace = sk_codeShoutbox($items); $img_url = get_bloginfo('wpurl') . "/wp-includes/images/rss.png"; $feed_url = sk_plugin_url('/feed.php'); if (defined('SK_RSS')) { $feed_url = SK_RSS; } if ($rss_icon) { $title = "<a class='rsswidget' href='{$feed_url}' title='" . __('Subscribe', 'sk') . "'><img src='{$img_url}' alt='RSS' border='0' /></a> {$title}"; } $content = str_replace($search, $title . $replace, $content); } } } //The chat box $search = "/(?:<p>)*\\s*\\[schreikasten:(\\d+)\\]\\s*(?:<\\/p>)*/i"; if (preg_match_all($search, $content, $matches)) { if (is_array($matches)) { foreach ($matches[1] as $key => $items) { // Get the data from the tag $search = $matches[0][$key]; // Create the script to show the feed $replace = sk_codeShoutbox($items); $content = str_replace($search, $replace, $content); } } } //The chat box $search = "/(?:<p>)*\\s*\\[schreikasten\\]\\s*(?:<\\/p>)*/i"; $options = get_option('sk_options'); $items = $options['items']; if (strpos($content, '[schreikasten]') !== false) { $replace = sk_codeShoutbox($items); $content = preg_replace($search, $replace, $content); } //User messages $search = "/(?:<p>)*\\s*\\[schreikasten-user\\]\\s*(?:<\\/p>)*/i"; $options = get_option('sk_options'); $items = $options['items']; if (strpos($content, '[schreikasten-user]') !== false) { $replace = sk_userMessages(); $content = preg_replace($search, $replace, $content); } return $content; }
function skLegacy_content($content) { //The chat box $search = "/(?:<p>)*\\s*\\[sk-shoutbox\\]\\s*(?:<\\/p>)*/i"; if (preg_match($search, $content)) { $options = get_option('sk_options'); $args = array(); $args['items'] = $options['items']; $content = preg_replace($search, sk_codeShoutbox($args), $content); } //The feed icon $search = "/\\[sk-feed-icon\\]/i"; $img_url = get_bloginfo('wpurl') . "/wp-includes/images/rss.png"; $feed_url = sk_plugin_url('/ajax/feed.php'); $replace = "<a class='rsswidget' href='{$feed_url}' title='" . __('Subscribe', 'sk') . "'><img src='{$img_url}' alt='RSS' border='0' /></a>"; $content = preg_replace($search, $replace, $content); //Thed feed link $search = "/\\[sk-feed\\]([^\\[]+)\\[\\/sk-feed\\]/i"; $replace = "<a href='{$feed_url}'>\$1</a>"; $content = preg_replace($search, $replace, $content); return $content; }