';
}
}
endif;
/**
* Flush out the transients used in blogbend_categorized_blog.
*/
function blogbend_category_transient_flusher()
{
// Like, beat it. Dig?
delete_transient('blogbend_categories');
}
add_action('edit_category', 'blogbend_category_transient_flusher');
add_action('save_post', 'blogbend_category_transient_flusher');
if (!function_exists('blogbend_get_rendered_content')) :
/**
* Return the rendered post content.
*
* This is the same as the_content() except for the fact that it doesn't display the content, but returns it.
* Do make sure not to use this function twice for a post inside the loop, because it would defeat the purpose.
*
* @param string $more_link_text Optional. Content for when there is more text.
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
* @return string
*/
function blogbend_get_rendered_content($more_link_text = null, $strip_teaser = false)
{
$content = get_the_content($more_link_text, $strip_teaser);
/**
* Filters the post content.
*
* @param string $content Content of the current post.
* @since 0.71
*
*/
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
endif;
if (!function_exists('blogbend_first_content_character')) :
/**
* Returns the first UTF-8 character of the content
* returns empty string if nothing found
*
* @param string $content The content to extract the first character from.
* @return string
*/
function blogbend_first_content_character($content = '')
{
//no need for this when a password is required
if (post_password_required()) {
return '';
}
// By default we have no first letter
$first_letter = '';
if (empty($content)) {
// If we haven't been provided with a rendered content (with all shortcodes run, etc),
// we need to get our own.
$content = get_the_content();
// remove [caption] shortcode
// because if it is the first part of the content we don't need the caption
$content = trim(preg_replace("/\[caption.*\[\/caption\]/si", '', $content));
//now apply the regular filters, without the captions
$content = apply_filters('the_content', $content);
}
// Bail if we have no content to work with
if (empty($content)) {
return $first_letter;
}
// We need to make sure that we don't look at strings inside s - those are probably captions -
// or embeds - Twitter (usually inside divs with some embed class)
// This is why we want to remove the tags and their content
// We are only interested in the beginning of the the content, not the whole
// This is why we are using preg_replace, not preg_replace_all
$content = preg_replace("//siU", '', $content);
$content = preg_replace("//siU", '', $content);
// Strip all the tags that are left and use what we are left with
$content = wp_strip_all_tags(html_entity_decode($content));
// Find the first alphanumeric character - multibyte
preg_match('/[\p{Xan}]/u', $content, $results);
if (!empty($results)) {
$first_letter = reset($results);
} else {
// Lets try the old fashion way
// Find the first alphanumeric character - non-multibyte
preg_match('/[a-zA-Z\d]/', $content, $results);
if (!empty($results)) {
$first_letter = reset($results);
}
};
return $first_letter;
}
endif;
if (!function_exists('blogbend_get_post_format_first_image')) :
function blogbend_get_post_format_first_image()
{
global $post;
$output = preg_match('//i', $post->post_content, $matches);
if (empty($matches[0])) {
return '';
}
return $matches[0];
}
endif;
if (!function_exists('blogbend_get_post_format_link_url')) :
/**
* Returns the URL to use for the link post format.
*
* First it tries to get the first URL in the content; if not found it uses the permalink instead
*
* @return string URL
*/
function blogbend_get_post_format_link_url()
{
$content = get_the_content();
$has_url = get_url_in_content($content);
return ($has_url) ? $has_url : apply_filters('the_permalink', esc_url(get_permalink()));
}
endif;
/**
* Handles the output of the media for audio attachment posts. This should be used within The Loop.
*
* @return string
*/
function blogbend_audio_attachment()
{
return blogbend_hybrid_media_grabber(array('type' => 'audio', 'split_media' => true));
}
/**
* Handles the output of the media for video attachment posts. This should be used within The Loop.
*
* @return string
*/
function blogbend_video_attachment()
{
return blogbend_hybrid_media_grabber(array('type' => 'video', 'split_media' => true));
}
if (!function_exists('blogbend_get_rendered_content')) :
/**
* Return the rendered post content.
*
* This is the same as the_content() except for the fact that it doesn't display the content, but returns it.
* Do make sure not to use this function twice for a post inside the loop, because it would defeat the purpose.
*
* @param string $more_link_text Optional. Content for when there is more text.
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
* @return string
*/
function blogbend_get_rendered_content($more_link_text = null, $strip_teaser = false)
{
$content = get_the_content($more_link_text, $strip_teaser);
/**
* Filters the post content.
*
* @param string $content Content of the current post.
* @since 0.71
*
*/
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
endif;
if (!function_exists('wp_body_open')) :
/**
* Fire the wp_body_open action.
*
* Added for backwards compatibility to support pre 5.2.0 WordPress versions.
*
* @since BlogBend 1.0.0
*/
function wp_body_open()
{
/**
* Triggered after the opening tag.
*
* @since BlogBend 1.0.0
*/
do_action('wp_body_open');
}
endif;
function blogbend_excerpt_more($more) {
return ' ' . __('Continue reading', 'blogbend') . '';
}
add_filter('excerpt_more', 'blogbend_excerpt_more');
if (!function_exists('blogbend_get_page_layout')) :
/**
* Get Page Layout based on the post meta or customizer value
*
* @return string Page Layout.
* @since 1.0.0
*
*/
function blogbend_get_page_layout()
{
global $post;
$page_layout = '';
// Fetch from Post Meta on single posts or pages.
if ($post && is_singular()) {
$page_layout = get_post_meta($post->ID, 'blogbend_page_layout', true);
if (empty($page_layout) && is_single()) {
$page_layout = get_theme_mod('select_single_sidebar','right_sidebar');
}
}
// Fetch from customizer if everything else fails.
if (empty($page_layout)) {
$page_layout = get_theme_mod('select_single_sidebar','right_sidebar');
}
return $page_layout;
}
endif;