Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/23/2014 11:13:09 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Introduce Activity functions for getting and outputting the URL to delete a single activity stream item.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r8491 r8685  
    17901790        global $activities_template;
    17911791
    1792         return apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
     1792        return (bool) apply_filters( 'bp_get_activity_is_favorite', in_array( $activities_template->activity->id, (array) $activities_template->my_favs ) );
    17931793    }
    17941794
     
    25062506     */
    25072507    function bp_get_activity_delete_link() {
    2508         global $activities_template;
    2509 
    2510         $url   = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id;
     2508
     2509        $url   = bp_get_activity_delete_url();
    25112510        $class = 'delete-activity';
    25122511
    25132512        // Determine if we're on a single activity page, and customize accordingly
    25142513        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
    2515             $url   = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
    25162514            $class = 'delete-activity-single';
    25172515        }
    25182516
    2519         $link = '<a href="' . wp_nonce_url( $url, 'bp_activity_delete_link' ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
     2517        $link = '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow">' . __( 'Delete', 'buddypress' ) . '</a>';
     2518
    25202519        return apply_filters( 'bp_get_activity_delete_link', $link );
     2520    }
     2521
     2522/**
     2523 * Output the URL to delete a single activity stream item
     2524 *
     2525 * @since BuddyPress (2.1.0)
     2526 *
     2527 * @uses bp_get_activity_delete_link()
     2528 */
     2529function bp_activity_delete_url() {
     2530    echo esc_url( bp_get_activity_delete_url() );
     2531}
     2532    /**
     2533     * Return the URL to delete a single activity item
     2534     *
     2535     * @since BuddyPress (2.1.0)
     2536     *
     2537     * @global object $activities_template {@link BP_Activity_Template}
     2538     * @uses bp_get_root_domain()
     2539     * @uses bp_get_activity_root_slug()
     2540     * @uses bp_is_activity_component()
     2541     * @uses bp_current_action()
     2542     * @uses add_query_arg()
     2543     * @uses wp_get_referer()
     2544     * @uses wp_nonce_url()
     2545     * @uses apply_filters() To call the 'bp_get_activity_delete_link' hook.
     2546     *
     2547     * @return string $link Activity delete link. Contains $redirect_to arg
     2548     *         if on single activity page.
     2549     */
     2550    function bp_get_activity_delete_url() {
     2551        global $activities_template;
     2552
     2553        $url = trailingslashit( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/delete/' . $activities_template->activity->id );
     2554
     2555        // Determine if we're on a single activity page, and customize accordingly
     2556        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
     2557            $url = add_query_arg( array( 'redirect_to' => wp_get_referer() ), $url );
     2558        }
     2559
     2560        $url = wp_nonce_url( $url, 'bp_activity_delete_link' );
     2561               
     2562        return apply_filters( 'bp_get_activity_delete_url', $url );
    25212563    }
    25222564
Note: See TracChangeset for help on using the changeset viewer.