247 lines
9.3 KiB
PHP
247 lines
9.3 KiB
PHP
<?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_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', 'members/single/plugins' ) );
|
|
}
|
|
|
|
function bp_dedication_my_dedications_title() {
|
|
_e( 'My dedications', 'bp-dedication' );
|
|
}
|
|
|
|
function bp_dedication_my_dedications_content() {
|
|
global $bp;
|
|
|
|
$dedications = bp_dedication_get_dedications_from_user( $bp->displayed_user->id );
|
|
|
|
/**
|
|
* 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' );
|
|
?>
|
|
<h4><?php _e( 'Welcome to Screen One', 'bp-example' ) ?></h4>
|
|
<p><?php printf( __( 'Send %s a <a href="%s" title="Send high-five!">high-five!</a>', 'bp-example' ), $bp->displayed_user->fullname, $send_link ) ?></p>
|
|
|
|
<?php if ( $dedications ) : ?>
|
|
<h4><?php _e( 'Received High Fives!', 'bp-example' ) ?></h4>
|
|
|
|
<table id="high-fives">
|
|
<?php foreach ( $dedications as $dedication ) : ?>
|
|
<tr>
|
|
<td width="1%"></td>
|
|
<td> <a href="<?php echo get_post_permalink($dedication->ID); ?>"><?php echo apply_filters( 'the_title', $dedication->post_title, $dedication->ID ); ?></a></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
<?php
|
|
}
|
|
|
|
|
|
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', 'members/single/plugins' ) );
|
|
}
|
|
|
|
function bp_dedication_dedications_to_me_title() {
|
|
_e( 'Dedicated 2u', 'bp-dedication' );
|
|
}
|
|
|
|
function bp_dedication_dedications_to_me_content() {
|
|
global $bp;
|
|
|
|
$dedications = bp_dedication_get_dedications_to_user( $bp->displayed_user->id );
|
|
|
|
/**
|
|
* 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' );
|
|
?>
|
|
<h4><?php _e( 'Welcome to Screen One', 'bp-example' ) ?></h4>
|
|
<p><?php printf( __( 'Send %s a <a href="%s" title="Send high-five!">high-five!</a>', 'bp-example' ), $bp->displayed_user->fullname, $send_link ) ?></p>
|
|
|
|
<?php if ( $dedications ) : ?>
|
|
<h4><?php _e( 'Received High Fives!', 'bp-dedication' ) ?></h4>
|
|
|
|
<table id="high-fives">
|
|
<?php foreach ( $dedications as $dedication ) : ?>
|
|
<tr>
|
|
<td width="1%"></td>
|
|
<td> <a href="<?php echo get_post_permalink($dedication->ID); ?>"><?php echo apply_filters( 'the_title', $dedication->post_title, $dedication->ID ); ?></a></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
<?php
|
|
}
|
|
|
|
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());
|
|
}
|
|
|
|
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', 'members/single/plugins' ) );
|
|
}
|
|
|
|
function bp_dedication_new_dedication_title() {
|
|
_e( 'New dedication', 'bp-dedication' );
|
|
}
|
|
|
|
function bp_dedication_new_dedication_content() {
|
|
locate_template( 'dedication/new-dedication.php', true );
|
|
}
|
|
|
|
//function bp_example_screen_two() {
|
|
// global $bp;
|
|
//
|
|
// /**
|
|
// * On the output for this second screen, as an example, there are terms and conditions with an
|
|
// * "Accept" link (directs to http://example.org/members/andy/example/screen-two/accept)
|
|
// * and a "Reject" link (directs to http://example.org/members/andy/example/screen-two/reject)
|
|
// */
|
|
//
|
|
// if ( bp_is_example_component() && bp_is_current_action( 'screen-two' ) && bp_is_action_variable( 'accept', 0 ) ) {
|
|
// if ( bp_example_accept_terms() ) {
|
|
// /* Add a success message, that will be displayed in the template on the next page load */
|
|
// bp_core_add_message( __( 'Terms were accepted!', 'bp-example' ) );
|
|
// } else {
|
|
// /* Add a failure message if there was a problem */
|
|
// bp_core_add_message( __( 'Terms could not be accepted.', 'bp-example' ), 'error' );
|
|
// }
|
|
//
|
|
// /**
|
|
// * Now redirect back to the page without any actions set, so the user can't carry out actions multiple times
|
|
// * just by refreshing the browser.
|
|
// */
|
|
// bp_core_redirect( bp_loggedin_user_domain() . bp_get_example_slug() );
|
|
// }
|
|
//
|
|
// if ( bp_is_example_component() && bp_is_current_action( 'screen-two' ) && bp_is_action_variable( 'reject', 0 ) ) {
|
|
// if ( bp_example_reject_terms() ) {
|
|
// /* Add a success message, that will be displayed in the template on the next page load */
|
|
// bp_core_add_message( __( 'Terms were rejected!', 'bp-example' ) );
|
|
// } else {
|
|
// /* Add a failure message if there was a problem */
|
|
// bp_core_add_message( __( 'Terms could not be rejected.', 'bp-example' ), 'error' );
|
|
// }
|
|
//
|
|
// /**
|
|
// * Now redirect back to the page without any actions set, so the user can't carry out actions multiple times
|
|
// * just by refreshing the browser.
|
|
// */
|
|
// bp_core_redirect( bp_loggedin_user_domain() . bp_get_example_slug() );
|
|
// }
|
|
//
|
|
// /**
|
|
// * If the user has not Accepted or Rejected anything, then the code above will not run,
|
|
// * we can continue and load the template.
|
|
// */
|
|
// do_action( 'bp_example_screen_two' );
|
|
//
|
|
// add_action( 'bp_template_title', 'bp_example_screen_two_title' );
|
|
// add_action( 'bp_template_content', 'bp_example_screen_two_content' );
|
|
//
|
|
// /* Finally load the plugin template file. */
|
|
// bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
|
//}
|
|
|
|
|
|
|
|
/**
|
|
* The following screen functions are called when the Settings subpanel for this component is viewed
|
|
*/
|
|
function bp_example_screen_settings_menu() {
|
|
global $bp, $current_user, $bp_settings_updated, $pass_error;
|
|
|
|
if ( isset( $_POST['submit'] ) ) {
|
|
/* Check the nonce */
|
|
check_admin_referer('bp-example-admin');
|
|
|
|
$bp_settings_updated = true;
|
|
|
|
/**
|
|
* This is when the user has hit the save button on their settings.
|
|
* The best place to store these settings is in wp_usermeta.
|
|
*/
|
|
update_user_meta( $bp->loggedin_user->id, 'bp-example-option-one', attribute_escape( $_POST['bp-example-option-one'] ) );
|
|
}
|
|
|
|
add_action( 'bp_template_content_header', 'bp_example_screen_settings_menu_header' );
|
|
add_action( 'bp_template_title', 'bp_example_screen_settings_menu_title' );
|
|
add_action( 'bp_template_content', 'bp_example_screen_settings_menu_content' );
|
|
|
|
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
|
}
|
|
|
|
function bp_example_screen_settings_menu_header() {
|
|
_e( 'Example Settings Header', 'bp-example' );
|
|
}
|
|
|
|
function bp_example_screen_settings_menu_title() {
|
|
_e( 'Example Settings', 'bp-example' );
|
|
}
|
|
|
|
function bp_example_screen_settings_menu_content() {
|
|
global $bp, $bp_settings_updated; ?>
|
|
|
|
<?php if ( $bp_settings_updated ) { ?>
|
|
<div id="message" class="updated fade">
|
|
<p><?php _e( 'Changes Saved.', 'bp-example' ) ?></p>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<form action="<?php echo $bp->loggedin_user->domain . 'settings/example-admin'; ?>" name="bp-example-admin-form" id="account-delete-form" class="bp-example-admin-form" method="post">
|
|
|
|
<input type="checkbox" name="bp-example-option-one" id="bp-example-option-one" value="1"<?php if ( '1' == get_user_meta( $bp->loggedin_user->id, 'bp-example-option-one', true ) ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Do you love clicking checkboxes?', 'bp-example' ); ?>
|
|
<p class="submit">
|
|
<input type="submit" value="<?php _e( 'Save Settings', 'bp-example' ) ?> »" id="submit" name="submit" />
|
|
</p>
|
|
|
|
<?php
|
|
/* This is very important, don't leave it out. */
|
|
wp_nonce_field( 'bp-example-admin' );
|
|
?>
|
|
|
|
</form>
|
|
<?php
|
|
}
|
|
?>
|