';
}
}
/* ========================================================================================================
* Captcha
* ======================================================================================================== */
/*
* ------------------- Comment Captcha -------------------------
*
* Modified code from Chip Bennet's post
* at http://www.chipbennett.net/2010/07/29/using-really-simple-captcha-plugin-for-comments/
* Captcha from Book "Headfirst PHP & MYSQL"
*
* -------------Add Captcha to comment form -------------------*/
if ( !function_exists ('blogBox_comment_captcha')){//add comment captcha
function blogBox_comment_captcha () {
$blogBox_option = blogBox_get_options();
if (!is_user_logged_in() && $blogBox_option['bB_show_comment_captcha'] == 1) { ?>
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);
}
$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).' [...]';
}
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.' ...';
} 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
* ======================================================================================================== */
class blogBox_hermit_walker extends Walker_Nav_Menu
/*custom walker that only shows the menuitem's ID's (and active items get active classes), delevering clean menu code (in WordPress > 3.0)
*/
{
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$current_indicators = array('current-menu-item', 'current-menu-parent', 'current_page_item', 'current_page_parent');
$newClasses = array();
foreach($classes as $el){
//check if it's indicating the current page, otherwise we don't need the class
if (in_array($el, $current_indicators)){
array_push($newClasses, $el);
}
}
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $newClasses), $item ) );
if($class_names!='') $class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '
';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
if($depth != 0)
{
//children stuff, maybe you'd like to store the submenu's somewhere?
}
$item_output = $args->before;
$item_output .= '';
$item_output .= $args->link_before .apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= '';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
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;
}
}
?>