Skip to:
Content

BuddyPress.org

Changeset 8666


Ignore:
Timestamp:
07/22/2014 08:31:45 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Introduce bp_the_notification_delete_url() and bp_get_the_notification_delete_url() for more easily making custom notification delete links.

File:
1 edited

Legend:

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

    r8578 r8666  
    811811        function bp_get_the_notification_delete_link() {
    812812
     813                // Start the output buffer
     814                ob_start(); ?>
     815
     816                <a href="<?php bp_the_notification_delete_url(); ?>" class="delete secondary confirm"><?php _e( 'Delete', 'buddypress' ); ?></a>
     817
     818                <?php $retval = ob_get_clean();
     819
     820                return apply_filters( 'bp_get_the_notification_delete_link', $retval );
     821        }
     822
     823/**
     824 * Output the URL used for deleting a single notification
     825 *
     826 * Since this function directly outputs a URL, it is escaped.
     827 *
     828 * @since BuddyPress (2.1.0)
     829 *
     830 * @uses esc_url()
     831 * @uses bp_get_the_notification_delete_url()
     832 */
     833function bp_the_notification_delete_url() {
     834        echo esc_url( bp_get_the_notification_delete_url() );
     835}
     836        /**
     837         * Return the URL used for deleting a single notification
     838         *
     839         * @since BuddyPress (2.1.0)
     840         *
     841         * @return string
     842         */
     843        function bp_get_the_notification_delete_url() {
     844
    813845                // URL to add nonce to
    814846                if ( bp_is_current_action( 'unread' ) ) {
     
    818850                }
    819851
    820                 // Get the URL with nonce, action, and id
    821                 $url = wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'notification_id' => bp_get_the_notification_id() ), $link ), 'bp_notification_delete_' . bp_get_the_notification_id() );
    822 
    823                 // Start the output buffer
    824                 ob_start(); ?>
    825 
    826                 <a href="<?php echo esc_url( $url ); ?>" class="delete secondary confirm"><?php _e( 'Delete', 'buddypress' ); ?></a>
    827 
    828                 <?php $retval = ob_get_clean();
    829 
    830                 return apply_filters( 'bp_get_the_notification_delete_link', $retval );
     852                // Args to add to the link
     853                $args = array(
     854                        'action'          => 'delete',
     855                        'notification_id' => bp_get_the_notification_id()
     856                );
     857
     858                // Add the args
     859                $url = add_query_arg( $args, $link );
     860
     861                // Add the nonce
     862                $url = wp_nonce_url( $url, 'bp_notification_delete_' . bp_get_the_notification_id() );
     863
     864                // Filter and return
     865                return apply_filters( 'bp_get_the_notification_delete_url', $url );
    831866        }
    832867
Note: See TracChangeset for help on using the changeset viewer.