<?php
# Empty functions.php file for your childtheme
# The parents functions.php contents will be loaded.
# Add any additional or overwriting functions here.

/**

 * SALZMEDIA CUSTOM CODE - CHANGED LOGIN WP-ADMIN LINK CODE AND HOVER TITLE TOOL TIP ON LOGO

 */
 



function my_loginURL() {

    return 'mailto:support@salzmedia.com?subject=APGSA&nbsp;Support&nbsp;Request';

}

add_filter('login_headerurl', 'my_loginURL');





function my_loginURLtext() {

    return 'Click to Contact SalzMedia Support';

}

add_filter('login_headertitle', 'my_loginURLtext');





/* SALZMEDIA ADDED CUSTOM CODE FROM ROBIN WILSON FOR BBPRESS FORUM TO REMOVE THE WORD PRIVATE FROM THE FORUM PAGE DISPLAY ON EACH FORUM TITLE
FOUND THE CODE IN THIS BBPRESS WEB FORUM PAGE:  https://bbpress.org/forums/topic/created-private-forum-but-title-is-private-private-own-your-mission-forum/#post-131731
 */

add_filter('protected_title_format', 'remove_protected_title');
add_filter('private_title_format', 'remove_private_title');

//removes 'private' and protected prefix for forums
function remove_private_title($title) {
	return '%s';
	}

function remove_protected_title($title) {
	return '%s';
	}





/* SALZMEDIA ADDED CUSTOM CODE FROM: http://flashsolver.com/2011/10/24/how-to-add-bbpress-to-search-results/ TO MAKE BBPRESS SEARCH WORK WITH MYSITEMYWAY THEME.
 */
function my_add_bbp_to_search( $post_type ) {
     $post_type['exclude_from_search'] = false;

     return $post_type;
}
add_filter( 'bbp_register_forum_post_type', 'my_add_bbp_to_search' );
add_filter( 'bbp_register_topic_post_type', 'my_add_bbp_to_search' );
add_filter( 'bbp_register_reply_post_type', 'my_add_bbp_to_search' );



/* SALZMEDIA ADDED CUSTOM CODE FROM: http://wordpress.stackexchange.com/questions/5453/how-do-i-remove-pages-from-search TO remove posts from displaying in the search.
 */

function remove_posts_from_search() {
    global $wp_post_types;
    $wp_post_types['post']->exclude_from_search = true;
}
add_action('init', 'remove_posts_from_search');


//bbPress fix to send the logged out user to $url - in this case '/forums/'  
function rw_logout ($redirect_to) {
	$url='index.php' ;
	$redirect_to = '<a href="' . wp_logout_url( $url ) . '" class="button logout-link">' . esc_html__( 'Log Out', 'bbpress' ) . '</a>' ;
	return $redirect_to ;
	}
	
	add_filter ('bbp_get_logout_link', 'rw_logout') ;
	
	
	

/*  PRINT BUTTON - Custom shortcode for adding a print button to the APGSA Satate Contact Page List */
// [print_button]
function print_button_shortcode( $atts ){
return '<a class="print-link" href="javascript:window.print()" target="blank"><img src="http://www.apgsa.org/wp-content/uploads/2015/06/printer_icon.png" alt="" border="0" />
Print</a>';
}
add_shortcode( 'print_button', 'print_button_shortcode' );





//NEW CODE FROM ROBIN

function rew_date_topic_order( $args ) {
                //ENTER BELOW THE FORUM ID’s of any forums that you DO want to display only in original date order - if more than 1, then comma separated eg (16024,16025,16865)
                $include = array (1863) ;
                                if (in_array (bbp_get_forum_id(), $include )) {
                $args['orderby']='date';
                $args['order']='DESC';  //change to ASC to put oldest at top
                }
                return $args;
}
add_filter('bbp_before_has_topics_parse_args','rew_date_topic_order');







?>







