post_excerpt;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
//I'm checking for my own conatct-pizazz plug-in here so that you can include the shortcodes I know about.
if (function_exists('content_pizazz_list_func()')) {
$text = do_shortcode($text);
} else {
strip_shortcodes($text);
}
$text = strip_tags($text,'
');
$output = strlen($text);
if($output > $length ) {
$break_pos = strpos($text, ' ', $length);//find next space after desired length
if($break_pos == '')$break_pos = $length;
$text = substr($text,0,$break_pos);
$text = $text.' [...]';
$text = force_balance_tags($text);
}
echo apply_filters('the_excerpt',$text);
}
}
if ( !function_exists ('blogBox_portfolio_titles')){//function to limit characters in portfolio titles
function blogBox_portfolio_titles($content,$limit){
$content = strip_tags($content);
if(strlen($content) > $limit){
$visible = substr($content, 0, $limit);
$visible = $visible.' ...';
} else {
$visible = $content;
}
//return $visible;
echo strip_tags(apply_filters('the_excerpt',$visible));
}
}
if ( !function_exists ('blogBox_portfolio_feature_description')){//function to limit characters in portfolio titles
function blogBox_portfolio_feature_description($content,$limit){
$content = do_shortcode($content);
$content = strip_tags($content,'
');
if(strlen($content) > $limit){
$break_pos = strpos($content, ' ', $limit);//find next space after desired length
if($break_pos == '')$break_pos = $limit;
$visible = substr($content, 0, $break_pos);
$visible = $visible.' ...';
$visible = force_balance_tags($visible);
} else {
$visible = $content;
}
echo apply_filters('the_content',$visible);
}
}
/*
* --------------------HTML Validation Filters ------------------------
* the rel tag does not validate it says it does not like the term category
* Discussion at wordpess.org suggests it is an HTML/W#C issue.Browsers do
* not use this attribute in any way. However, search engines can use this
* attribute to get more information about a link.
*/
if ( !function_exists ('blogBox_html5_fix_the_category')){//rel tag validation fix
function blogBox_html5_fix_the_category($content) {
$pattern = '/rel="category tag"/';
$replacement = 'rel="tag"';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_category','blogBox_html5_fix_the_category');
}
/*
* Plugin Name: Shortcode Empty Paragraph Fix
* Plugin URI: http://www.johannheyne.de/wordpress/shortcode-empty-paragraph-fix/
* Description: Fix issues when shortcodes are embedded in a block of content that is filtered by wpautop.
* Author URI: http://www.johannheyne.de
* Version: 0.1
* Put this in /wp-content/plugins/ of your Wordpress installation
*/
if ( !function_exists ('blogBox_shortcode_paragraph_insertion_fix')){//Empty Paragraph Fix
function blogBox_shortcode_paragraph_insertion_fix($content) {
$array = array (
'
[' => '[',
']
' => ']',
'] ' => ']',
'] ' => ']'
);
$content = strtr($content, $array);
return $content;
}
add_filter('the_content', 'blogBox_shortcode_paragraph_insertion_fix');
}
add_filter('widget_text', 'do_shortcode');// Allows shortcodes to be displayed in sidebar widgets
/* ========================================================================================================
* Miscelaneous
* ======================================================================================================== */
if ( !function_exists ('blogBox_validEmail')){
function blogBox_validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
}
/**
* blogBox exclude categories
*
* This helper function is used in page-home-blog.php and index.php.
* It returns an exclusion string for $wp-query, and is based on user settings to
* eclude the Feature and Portfolio categories.
*
* @return $exclude_categories
*/
if ( !function_exists ('blogBox_exclude_categories')){//Exclude categories helper
function blogBox_exclude_categories () {
$blogBox_option = blogBox_get_options();
$exclude_categories = "'";
$feature_cat_ID = get_cat_ID('Feature');
$portfolioA_cat_ID = get_cat_ID(sanitize_text_field($blogBox_option['bB_portfolioA_category']));
$portfolioB_cat_ID = get_cat_ID(sanitize_text_field($blogBox_option['bB_portfolioB_category']));
$portfolioC_cat_ID = get_cat_ID(sanitize_text_field($blogBox_option['bB_portfolioC_category']));
$portfolioD_cat_ID = get_cat_ID(sanitize_text_field($blogBox_option['bB_portfolioD_category']));
$portfolioE_cat_ID = get_cat_ID(sanitize_text_field($blogBox_option['bB_portfolioE_category']));
if ($feature_cat_ID !== 0 && $blogBox_option['bB_showfeaturepost'] == 0) $exclude_categories = $exclude_categories . "-" . $feature_cat_ID;
if ($portfolioA_cat_ID !== 0 && $blogBox_option['bB_showfeatureApost'] == 0 && $exclude_categories !== "'") {
$exclude_categories = $exclude_categories . ",-" . $portfolioA_cat_ID;
}
elseif ($portfolioA_cat_ID !== 0 && $blogBox_option['bB_showfeatureApost'] == 0 && $exclude_categories == "'") {
$exclude_categories = $exclude_categories . "-" . $portfolioA_cat_ID;
}
if ($portfolioB_cat_ID !== 0 && $blogBox_option['bB_showfeatureBpost'] == 0 && $exclude_categories !== "'") {
$exclude_categories = $exclude_categories . ",-" . $portfolioB_cat_ID;
}
elseif ($portfolioB_cat_ID !== 0 && $blogBox_option['bB_showfeatureBpost'] == 0 && $exclude_categories == "'") {
$exclude_categories = $exclude_categories . "-" . $portfolioB_cat_ID;
}
if ($portfolioC_cat_ID !== 0 && $blogBox_option['bB_showfeatureCpost'] == 0 && $exclude_categories !== "'") {
$exclude_categories = $exclude_categories . ",-" . $portfolioC_cat_ID;
}
elseif ($portfolioC_cat_ID !== 0 && $blogBox_option['bB_showfeatureCpost'] == 0 && $exclude_categories == "'") {
$exclude_categories = $exclude_categories . "-" . $portfolioC_cat_ID;
}
if ($portfolioD_cat_ID !== 0 && $blogBox_option['bB_showfeatureDpost'] == 0 && $exclude_categories !== "'") {
$exclude_categories = $exclude_categories . ",-" . $portfolioD_cat_ID;
}
elseif ($portfolioD_cat_ID !== 0 && $blogBox_option['bB_showfeatureDpost'] == 0 && $exclude_categories == "'") {
$exclude_categories = $exclude_categories . "-" . $portfolioD_cat_ID;
}
if ($portfolioE_cat_ID !==0 && $blogBox_option['bB_showfeatureEpost'] == 0 && $exclude_categories !== "'") {
$exclude_categories = $exclude_categories . ",-" . $portfolioE_cat_ID;
}
elseif ($portfolioE_cat_ID !== 0 && $blogBox_option['bB_showfeatureEpost'] == 0 && $exclude_categories == "'") {
$exclude_categories = $exclude_categories . "-" . $portfolioE_cat_ID;
}
$exclude_categories = $exclude_categories . "'" ;
return $exclude_categories;
}
}
/**
* Custom WordPress Gallery code
*
* Remove Wordpress gallery shortcode and add our own. The purpose is to remove the css from
* being injected into the post, and to fix the dd error.
* Basis is from @link http://wpengineer.com/1802/a-solution-for-the-wordpress-gallery/
*
* Note : This is not set up as a conditional load because it will not work. Therefore you can't
* modify this function in a child theme
*
*/
//deactivate WordPress function
remove_shortcode('gallery', 'gallery_shortcode');
//activate own function
add_shortcode('gallery', 'blogBox_gallery_shortcode');
//the own renamed function
function blogBox_gallery_shortcode($attr) {
$post = get_post();
static $instance = 0;
$instance++;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if ( empty( $attr['orderby'] ) )
$attr['orderby'] = 'post__in';
$attr['include'] = $attr['ids'];
}
// Allow plugins/themes to override the default gallery template.
$output = apply_filters('post_gallery', '', $attr);
if ( $output != '' )
return $output;
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] )
unset( $attr['orderby'] );
}
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr));
$id = intval($id);
if ( 'RAND' == $order )
$orderby = 'none';
if ( !empty($include) ) {
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
if ( empty($attachments) )
return '';
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
return $output;
}
$itemtag = tag_escape($itemtag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
//$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
$float = is_rtl() ? 'right' : 'left';
$selector = "gallery-{$instance}";
$output = apply_filters('gallery_style', "
';
}
if( $feature_option == "Small slides and feature text box" || $feature_option == "Small slides and feature text box-thumbnails" || $feature_option == "Small single image and feature text box" ) {
echo '