<?php

function bp_dedication_directory_setup() {
	if ( bp_is_dedication_component() && !bp_current_action() && !bp_current_item() ) {
		// This wrapper function sets the $bp->is_directory flag to true, which help other
		// content to display content properly on your directory.
		bp_update_is_directory( true, BP_DEDICATION_SLUG );

		// Add an action so that plugins can add content or modify behavior
		do_action( 'bp_dedication_directory_setup' );

		bp_core_load_template( apply_filters( 'bp_dedication_template_index', 'dedications/index' ) );
	}
}
add_action( 'bp_screens', 'bp_dedication_directory_setup' );

function bp_dedication_index() {
	global $bp;

	do_action( 'bp_dedication_index' );
        
	add_action( 'bp_template_title', 'bp_dedication_index_title' );
	add_action( 'bp_template_content', 'bp_dedication_index_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'dedications/index' ) );
}

        function bp_dedication_index_title() {
	}

	function bp_dedication_index_content() {
                if (!locate_template( 'dedications/single/home.php', true )) {
                    die();
                }
                
		/**
		 * For security reasons, we MUST use the wp_nonce_url() function on any actions.
		 * This will stop naughty people from tricking users into performing actions without their
		 * knowledge or intent.
		 */
		//$send_link = wp_nonce_url( $bp->displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_example_send_high_five' );
        }


function bp_dedication_my_dedications() {
	global $bp;

	do_action( 'bp_dedication_my_dedications' );
        
	add_action( 'bp_template_title', 'bp_dedication_my_dedications_title' );
	add_action( 'bp_template_content', 'bp_dedication_my_dedications_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'dedications/index' ) );
}

        function bp_dedication_my_dedications_title() {
            ?>
            <h4><?php _e( 'My dedications', 'bp-dedication' ); ?>
            <?php
	}

	function bp_dedication_my_dedications_content() {
                if (!locate_template( 'dedications/single/my-dedications.php', true )) {
                    die();
                }
                
		/**
		 * For security reasons, we MUST use the wp_nonce_url() function on any actions.
		 * This will stop naughty people from tricking users into performing actions without their
		 * knowledge or intent.
		 */
		//$send_link = wp_nonce_url( $bp->displayed_user->domain . $bp->current_component . '/screen-one/send-h5', 'bp_example_send_high_five' );
        }

        
function bp_dedication_dedications_to_me() {
	global $bp;

	do_action( 'bp_dedication_dedications_to_me' );
        
	add_action( 'bp_template_title', 'bp_dedication_dedications_to_me_title' );
	add_action( 'bp_template_content', 'bp_dedication_dedications_to_me_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'dedications/index' ) );
}

        function bp_dedication_dedications_to_me_title() {
            ?>
            <h4><?php _e( 'Dedicated 2u', 'bp-dedication' ); ?>
            <?php
	}

	function bp_dedication_dedications_to_me_content() {
                if (!locate_template( 'dedications/single/dedicated-2-me.php', true )) {
                    die();
                }
        }
        
function bp_dedication_new_dedication() {
	global $bp;

	if ( bp_is_dedication_component() && bp_is_current_action( 'new-dedication' ) && bp_is_action_variable( 'create', 0 ) ) {
            
            if (bp_dedication_create_new_dedication()) {
                bp_core_add_message( __( 'Your dedication was created!', 'bp-dedication' ) );
                bp_core_redirect( bp_loggedin_user_domain() . bp_get_dedication_slug());
            } else {
                
            }
	}

	do_action( 'bp_dedication_new_dedication' );
        
	add_action( 'bp_template_title', 'bp_dedication_new_dedication_title' );
	add_action( 'bp_template_content', 'bp_dedication_new_dedication_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'dedications/index' ) );
}

	function bp_dedication_new_dedication_title() {
            ?>
            <h4><?php _e( 'New dedication', 'bp-dedication' ); ?>
            <?php
	}

	function bp_dedication_new_dedication_content() {
            locate_template( 'dedications/single/new-dedication.php', true );
	}
?>