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 = '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.
Messed up your settings? Reset them here.