function myfossil_bp_wall_ajax_handler() { // -- begin buddypress code -- $bp = buddypress(); // Bail if not a POST action if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { return; } // Check the nonce check_admin_referer('post_update', '_wpnonce_post_update'); if (!is_user_logged_in()) { exit('-1'); } if (empty($_POST['content'])) { exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>'); } // -- end buddypress code -- $wall_user_id = bp_displayed_user_id(); $logged_in_user_id = bp_loggedin_user_id(); // Check if posting user is friend of the wall owner... if (!bp_are_friends($wall_user_id, $logged_in_user_id)) { // User should not be able to post to wall, bail out! exit('-1'); } // Setup Activity post... $action = sprintf("%s posted on %s's wall", bp_core_get_userlink($logged_in_user_id), bp_core_get_userlink($wall_user_id)); if ($logged_in_user_id == $wall_user_id) { $action = sprintf("%s posted on their own wall", bp_core_get_userlink($logged_in_user_id)); } $content = $_POST['content']; $component = 'activity'; $type = 'wall_post'; $item_id = $logged_in_user_id; $secondary_item_id = $wall_user_id; $hide_sitewide = true; $activity_args = array('type' => $type, 'action' => $action, 'content' => $content, 'component' => $component, 'user_id' => $wall_user_id, 'item_id' => $logged_in_user_id); $activity_id = bp_activity_add($activity_args); // -- begin buddypress code -- if (empty($activity_id)) { exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update; please try again.', 'buddypress') . '</p></div>'); } $last_recorded = !empty($_POST['since']) ? date('Y-m-d H:i:s', intval($_POST['since'])) : 0; if ($last_recorded) { $activity_args = array('since' => $last_recorded); $bp->activity->last_recorded = $last_recorded; add_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1); } else { $activity_args = array('include' => $activity_id); } if (bp_has_activities($activity_args)) { while (bp_activities()) { bp_the_activity(); bp_get_template_part('activity/entry'); } } if (!empty($last_recorded)) { remove_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1); } exit; }
/** * BuddyPress - Users Activity * * @package BuddyPress * @subpackage bp-legacy */ ?> <div class="row"> <div class="activity" role="main"> <?php do_action('bp_before_member_activity_post_form'); if (bp_are_friends(bp_displayed_user_id(), bp_loggedin_user_id())) { bp_get_template_part('activity/post-form'); } do_action('bp_after_member_activity_post_form'); ?> <?php if (bp_has_activities(array('scope' => 'activity', 'action' => 'wall_post'))) { ?> <?php if (empty($_POST['page'])) { ?> <ul id="activity-stream" class="activity-list item-list"> <?php } ?>