<?php 

include 'contact form.php';
//include 'googdocs.php';

//jQuery UI Autocomplete 	jquery-ui-autocomplete 
wp_enqueue_script( 'jquery-ui-autocomplete');

add_image_size( 'project_gallery', 175, 175, true ); 

function filter_likeratingextra($str, $m){// 'themefiles/footeroverride-testiform.php' ;
	//d($m);	
	//d(getGalleryPics($m->postID));
	//d(count(getGalleryPics($m->postID)));
	$num = count(getGalleryPics($m->post->ID));
	$r = wdiv($num.' photos', 'class="likeratingextra"');
	return $r;
}add_filter( 'likeratingextra', 'filter_likeratingextra', 1,2 );

function filter_likeratingpageheader($str){// 'themefiles/footeroverride-testiform.php' ;
	return pathtothemefiles.'likeratingpageheader.php';
}add_filter( 'likeratingpageheader', 'filter_likeratingpageheader', 1,1 );
//$header = apply_filters('likeratingpageheader', 'header.php');


function filter_loopoverride($f,$post){// 'themefiles/footeroverride-testiform.php' ;
//	d(is_category());
//	d(get_query_var('cat'));
	if(is_category() and get_query_var('cat') == 33)
		redirect(getperma(129));
	if(is_category() and get_query_var('cat') == 40)
		redirect(getperma(1230));
	return $f;
}add_filter( 'loopoverride', 'filter_loopoverride', 1,2 );

function action_after_header_301loopsingle( $post ) {
   if($post->ID != 129)return;//dp($post);
   		echo div('id="likeratingpageheader_pic"');
   		include pathtothemefiles.'likeratingpageheader_pic.php';
		echo div(0);
}
//add_action( 'after_header_301loopsingle', 'action_after_header_301loopsingle', 1, 1 );
add_action( 'in_header_301loopsingle', 'action_after_header_301loopsingle', 1, 1 );


function filter_kk_star_ratings($bool, $post ) {
   if($post->ID == 129)
   		return false; 
   return $f;
}add_filter( 'kk_star_ratings', 'filter_kk_star_ratings', 1,2 );



function filter_postArgs($args){//d('filter_postArgs begin');//this filter only runs on our loopquery filter, not category; it is not a wp filter
	
	if(isset($args['cat']))
		$args['cat'] = $args['cat'].',-43';
	else
		$args['cat'] = '-43';
	$args['posts_per_page'] = 3;
	//d($args, 'custfunds');
	return $args;					
}
add_filter( 'postArgs',  'filter_postArgs' , 8,1 );


function filter_rmenuextra($f,$post){ 
	return pathtothemefiles.'rmenuextra.php';
}add_filter( 'rmenuextra', 'filter_rmenuextra', 1,2 );
//apply_filters('rmenuextra', false, $post)

function filter_show_bigtestibutt($f,$post){ 
	if($post->post_name == testimonialFormPageSlug)
		$f =  'honey';

return $f;
}add_filter( 'show_bigtestibutt', 'filter_show_bigtestibutt', 1,2 );


function filter_searchandpagenav_search($f,$post){ 
	return false;
}add_filter( 'searchandpagenav_search', 'filter_searchandpagenav_search', 1,2 );

function filter_loop_multi_post_meta($bool = true,$post){ 
	return false;
}add_filter( 'loop_multi_post_meta', 'filter_loop_multi_post_meta', 1,2 );

function action_afterTopDiv(){
	echo '<div id="sliderbg"></div>';
	echo '<div id="ctabg"></div>';
	echo '<div id="interiorheaderbg"></div>';
}
add_action('afterTopDiv', 'action_afterTopDiv');

function filter_displayCommentsSidebar_args($args = array(),$post){
	$args['blocknonfb'] = false;
	return $args;
}add_filter( 'displayCommentsSidebar_args', 'filter_displayCommentsSidebar_args', 1,2 );




function filter_fblikeboxargs($args){
 $args['width'] = '341';
 //$args['header'] = 'true';
 return $args;
}add_filter( 'fblikeboxargs', 'filter_fblikeboxargs');


//$b = "<span style='display:none'>";
//$a = "</span>";
$b = "<!-- ";
$a = " -->";

register_sidebar(array(
	'name' => 'Homepage Side Bar',
	'id' => 'home-side-bar',
	'before_widget' => '',
	'after_widget' => "",
	'before_title' => $b,
	'after_title' => $a
));
register_sidebar( array(
	'name'          => 'Page Side Bar',
	'id'            => 'page-side-bar',
	'description'   => '',
	'before_widget' => '',
	'after_widget'  => '',
	'before_title'  => $b,
	'after_title'   => $a
));
register_sidebar( array(
	'name'          => 'Post Side Bar',
	'id'            => 'post-side-bar',
	'description'   => '',
	'before_widget' => '',
	'after_widget'  => '',
	'before_title'  => $b,
	'after_title'   => $a
));
register_sidebar( array(
	'name'          => 'contact Side Bar',
	'id'            => 'contact-side-bar',
	'description'   => '',
	'before_widget' => '',
	'after_widget'  => '',
	'before_title'  => $b,
	'after_title'   => $a
));


function shortcodeFacebook(){
	if(getThemeOption('sidebarfblikebox') )
		include getNormalOrCustomPath($f = '506-sidebar-fb.php').$f;
}add_shortcode( 'fbwidget', 'shortcodeFacebook' );

function contactpagesidebar_sc(){
	 ob_start();
	 include getNormalOrCustomPath($f = '503-sidebar-contact.php').$f;
	$ob = ob_get_clean();
return $ob;
		
		//echo 'contact iwdget';
}add_shortcode( 'contactpagesidebar', 'contactpagesidebar_sc' );

function addautocomplete($args = false){// http://api.jqueryui.com/autocomplete/#option-appendTo
	if(!$args){
		$makes = getPostContentRaw(106);
		$makes = explode(',',$makes);
		$makes = arraytrimelements($makes,$removeempty = true);//d($makes);
		$makes = '"'.implode('","',$makes). '"';//d($makes);
		$id = 'input#makemodel';
	}
	else{
		$makes = $args['list'];
		$id = $args['id'];
	}
	//d($makes);
 ob_start();?><span><script id="autocomplete_<?=$id?>">
        jQuery(function() {
        var availableTags = [
		<?=$makes?>
        ];
        jQuery( "<?=$id?>" ).autocomplete({
			source: availableTags
			<?php /*?>,appendTo: "#subbutt"<?php */?> 
        });
        });
    </script></span><?php $ob = ob_get_clean();
 return $ob;
}

//add_action( 'emuP_Contact_finished', 'action_emuP_Contact_finished', 1, 2 );
//	function action_emuP_Contact_finished($args, $log){
//	d($log);
//}

/*
function action_emuP_Contact_afterformmail($oContact='',$tags=''){ // this needs to check what form is subbed, it is firing on everything, testis and all that.
	global $emuTheme;
//	xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	d($oContact); object
//firstName 	adf
//email_address 	asdf@dsflkj.com
//requestconsult 	true
//frompageID 	5710
//frompage 	landingpage /brys_great_buys/100-off-coupon/
//maillist_list_id 	[empty string]
//forceemailsignup 	true
//maillist_list_name 	maillistname
//dateCreated 	2013-08-28 15:44:48
//dbID 	37
//	xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	d($tags); array
//from 	asdf@dsflkj.com
//emailto 	dougemailto@invalid.com
//cc 	dougcc@invalid.com
//bcc 	
//bool: FALSE
//subject 	Website Contact: adf - Form was filled out at page: landingpage /brys_great_buys/100-off-coupon/ page         //Brys-coupon-100-Dollar-Off.jpg
//body 	Greetings! adf has filled out your contact form on http://brys.target52.dev/.
$img = slashbetweennotend(gethost(),urltocustom.'coupon_100-off.jpg');//getDomain().urltocustom.'coupon_100-off.jpg';d($img);
$subject = "Here is the coupon for your BBQ!";

$body = '<p>We all here at Bry’s TV & Appliance would like to thank you for taking the time to request our $100 off coupon.</p>

<p>Please feel free to give us a call and arrange for an appointment ahead of time, so we can make sure to have someone available to demo the grills.
</p>
<p>We are really excited to offer these unique grills and can’t wait to fire one up for you.
</p>
<p>Here is your coupon:<BR>
Simply print the coupon below or bring it in on your phone to redeem!:<br><a href="'.$img.'" style="border:none;"><img src="'.$img.'" style="border:none;"></a>
</p>
<p><a href="'.$img.'" style="border:none;">Click here if you don\'t see the image.</a></p>
<p>Once again, Thank you very much<br>
Josh & Chad -Owners
</p>
';

  //$oEmuEmail = $emuTheme->mail( $tags['emailto'], $tags['from'], $tags['subject'], $body, 'html', $tags['cc'],  $tags['bcc'], $attachments = null, $important = true );//last param is importance
  //$to, $from = '', $subject=''  , $message=''  , $type = null, $cc = null, $bcc = null, $attachments = null, $important = false 
  $mailargs = array(
					'to'		=> $oContact->email_address
					, 'from'	=> getThemeOption('form_email_from')//$tags['emailto']
					, 'subject'	=>$subject
					, 'message'	=>$body
					, 'type'	=>'html'
					, 'cc'		=>$tags['cc']
					, 'bcc'		=>$tags['bcc']
					//, 'attachments'		=> pathtocustom.'Brys-coupon-100-Dollar-Off.pdf'
					, 'important'=>true				
					);
//d($mailargs);
$oEmuEmail = $emuTheme->mail( $mailargs );
//  d(file_exists(pathtocustom.'Brys-coupon-100-Dollar-Off.pdf'));
//  d($mailargs);
//  d($oEmuEmail);
}
*///add_action('emuP_Contact_afterformmail', 'action_emuP_Contact_afterformmail', 10, 2);
//do_action('emuP_Contact_afterformmail',$oContact,$tags);


// [mikesbigquote txt="I'm Real Special"]
function mikesbigquote_sc($atts){
 extract( shortcode_atts( array(
  'txt' => ''
 ), $atts) );

 return '<h1 class="bigolquotes">'.$txt.'</h1>';
}add_shortcode( 'mikesbigquote', 'mikesbigquote_sc' );

?>