tags, and undoes the HTML * line break conversion for content within
 tags.
 * 
 * @access public
 * @static
 * @param string $body The comment body to process.
 * @return string The formatted comment body.
 */
	public static function format_comment_body ($body) {
		// Convert line breaks to 
tags. $body = str_replace("\n", '
', $body); // Check whether a
 tag exists.
		if (preg_match_all('#]*?)>(.*?)
#i', $body, $m)) { $numMatches = count($m[0]); for ($i = 0; $i < $numMatches; $i++) { $code = $m[2][$i]; $code = str_replace('
', "\n", $code); $code = htmlentities($code); $body = str_replace($m[0][$i], "{$code}
", $body); } } return $body; } /** * Provides comment formatting to each individual comment. * @access public * @static * @return void */ public static function format_comment ($comment) { ?>
>
$unix_date) { $difference = $now - $unix_date; $tense = "ago"; } else { $difference = $unix_date - $now; $tense = "from now"; } for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if ($difference != 1) { $periods[$j].= "s"; } return "{$difference} {$periods[$j]} {$tense}"; } /** * Returns a boolean value indicating whether or not the theme currently has a sidebar. * @access public * @static * @return boolean */ public static function has_sidebar () { return is_active_sidebar('main'); } /** * Builds up the HTML title of the current page. * @access public * @static * @return string */ public static function page_title () { // Get initial title. $title = wp_title('|', false, 'right'); if (!$title) { $title = get_bloginfo('title'); } else { $title .= get_bloginfo('title'); } if ($desc = get_bloginfo('description')) { $title .= ' - ' . $desc; } return $title; } /** * Builds the HTML used to generate and show the related posts. * @access public * @static * @param WP_Post|integer $post Optional post to use for getting the related posts. * @return boolean|string Boolean false on no related posts, otherwise a string containing the HTML for it. */ public static function related_posts ($post = null) { // Get the categories. Return false if there are no assigned categories. $categories = get_the_category($post); if (!$categories) { return false; } // Fetch IDs. $ids = ''; foreach ($categories as $category) { $ids .= $category->cat_ID . ','; } $ids = rtrim($ids, ','); // Find the related posts. $params = array(); $params['numberposts'] = (int)get_option('blocked.num_related_posts', 5); $params['category'] = $ids; $params['exclude'] = get_the_ID(); $posts = get_posts($params); // If there's nothing, then return nothing. if (!$posts) { return false; } // Right. So we have related posts. Let's format the response. $return = ''; return $return; } /** * Adds the two widgets to the theme support. * @access public * @static * @return void */ public static function hook_widgets_init () { register_sidebar('id=main&name=Main sidebar'); register_sidebar('id=foot&name=Footer'); } /** * Displays the post tags, if there are any. If the theme option 'show_tags' is * set to false, the tags are also not populated. * @access public * @static * @return void */ public static function format_post_tags () { if (get_option('blocked.show_tags', false) && $tags = get_the_tags()) { echo '
Tagged in '; $i = 1; $count = count($tags); foreach ($tags as $tag) { echo sprintf('%s', get_term_link($tag->slug, $tag->taxonomy), $tag->slug); echo ($i++ == $count - 1) ? ' and ' : ', '; } echo '
'; global $wp_query; if (!$wp_query->is_single) { echo '
'; } } } /** * Hook used to add the theme options page to the menu in the admin section. * @access public * @static * @return void */ public static function hook_admin_menu () { add_theme_page('Manage options for Blocked theme', 'Theme options', 'edit_theme_options', 'blocked-theme-options', 'Blocked::hook_options_page'); } /** * Generates the options page for the theme. * @access public * @static * @return void */ public static function hook_options_page () { // Set defaults. $options = array( 'show_related_posts' => 1, 'num_related_posts' => 5, 'show_flickr_footer' => 0, 'flickr_id' => '', 'tracking_code' => '', 'custom_css' => '', 'show_tags' => 0, ); // Process form POST. if (!empty($_POST)) { $_POST = stripslashes_deep($_POST); foreach ($_POST as $optionName => $optionValue) { update_option("blocked.{$optionName}", $optionValue); $options[$optionName] = $optionValue; } } else { foreach ($options as $name => $value) { $options[$name] = get_option("blocked.{$name}", $value); } } // Include the template page. ?>

Blocked 1.0

Theme settings updated.

The settings for your installed version of Blocked are shown below. Use the provided form to update these settings, and enhance the appearance of your theme.

Display related posts />
Limit the number of related that show next to the individual post.
Display tags? />
Post your Google Analytics (or other) tracking code here.
Quickly alter some CSS in your theme by adding it to this block.

Messed up your settings? Reset them here.

'; echo $customCss; echo ''; } } /** * Outputs the tracking code. * @access public * @static * @return void */ public static function hook_wp_footer () { // Output analytics if supplied. if ($analytics = trim(get_option('blocked.tracking_code', ''))) { echo $analytics; } } /** * Includes the admin CSS file. * @access public * @static * @return void */ public static function hook_admin_head () { if (isset($_GET['page']) && $_GET['page'] == 'blocked-theme-options') { echo ''; } } }