Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2023 10:41:34 PM (7 months ago)
Author:
imath
Message:

Improve the favorites management using the WP Meta API

  • Introduce bp_activity_register_user_favorites_meta() to register the user meta and define sanitization callback.
  • Introduce bp_activity_sanitize_user_favorites_meta() to do the sanitization job.
  • Improve Ajax callbacks about favoriting/unfavoriting activities in template packs.

Props emaralive, dcavins

Fixes #9021
Closes https://github.com/buddypress/buddypress/pull/189

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/activity/ajax.php

    r13503 r13636  
    104104    $activity_id   = (int) $_POST['id'];
    105105    $activity_item = new BP_Activity_Activity( $activity_id );
    106     if ( ! bp_activity_user_can_read( $activity_item, bp_loggedin_user_id() ) ) {
    107         wp_send_json_error();
    108     }
    109 
    110     if ( bp_activity_add_user_favorite( $_POST['id'] ) ) {
     106    if ( empty( $activity_item->id ) || ! bp_activity_user_can_read( $activity_item, bp_loggedin_user_id() ) ) {
     107        wp_send_json_error();
     108    }
     109
     110    if ( bp_activity_add_user_favorite( $activity_id ) ) {
    111111        $response = array( 'content' => __( 'Remove Favorite', 'buddypress' ) );
    112112
     
    150150    }
    151151
    152     if ( bp_activity_remove_user_favorite( $_POST['id'] ) ) {
     152    $activity_id = (int) $_POST['id'];
     153
     154    if ( bp_activity_remove_user_favorite( $activity_id ) ) {
    153155        $response = array( 'content' => __( 'Mark as Favorite', 'buddypress' ) );
    154156
Note: See TracChangeset for help on using the changeset viewer.