/** * Detect a change in post type status, and initiate an activity update if necessary. * * @since 2.2.0 * * @todo Support untrashing better. * * @param string $new_status New status for the post. * @param string $old_status Old status for the post. * @param object $post Post data. */ function bp_activity_catch_transition_post_type_status($new_status, $old_status, $post) { if (!post_type_supports($post->post_type, 'buddypress-activity')) { return; } // This is an edit. if ($new_status === $old_status) { // An edit of an existing post should update the existing activity item. if ($new_status == 'publish') { bp_activity_post_type_update($post); } return; } // Publishing a previously unpublished post. if ('publish' === $new_status) { // Untrashing the post type - nothing here yet. if ('trash' == $old_status) { /** * Fires if untrashing post in a post type. * * This is a variable filter that is dependent on the post type * being untrashed. * * @since 2.2.0 * * @param WP_Post $post Post data. */ do_action('bp_activity_post_type_untrash_' . $post->post_type, $post); } else { // Record the post. bp_activity_post_type_publish($post->ID, $post); } // Unpublishing a previously published post. } elseif ('publish' === $old_status) { // Some form of pending status - only remove the activity entry. bp_activity_post_type_unpublish($post->ID, $post); } }
/** * Updates a blog post's corresponding activity entry during a post edit. * * @since BuddyPress (2.0.0) * @deprecated BuddyPress (2.2.0) * * @see bp_blogs_catch_transition_post_status() * * @param WP_Post $post */ function bp_blogs_update_post($post) { _deprecated_function(__FUNCTION__, '2.2', 'bp_activity_post_type_update()'); bp_activity_post_type_update($post); }
/** * Detect a change in post type status, and initiate an activity update if necessary. * * @since 2.2.0 * * @todo Support untrashing better. * * @param string $new_status New status for the post. * @param string $old_status Old status for the post. * @param object $post Post data. */ function bp_activity_catch_transition_post_type_status($new_status, $old_status, $post) { if (!post_type_supports($post->post_type, 'buddypress-activity')) { return; } // This is an edit. if ($new_status === $old_status) { // An edit of an existing post should update the existing activity item. if ($new_status == 'publish') { $edit = bp_activity_post_type_update($post); // Post was never recorded into activity stream, so record it now! if (null === $edit) { bp_activity_post_type_publish($post->ID, $post); } // Allow plugins to eventually deal with other post statuses. } else { /** * Fires when editing the post and the new status is not 'publish'. * * This is a variable filter that is dependent on the post type * being untrashed. * * @since 2.5.0 * * @param WP_Post $post Post data. * @param string $new_status New status for the post. * @param string $old_status Old status for the post. */ do_action('bp_activity_post_type_edit_' . $post->post_type, $post, $new_status, $old_status); } return; } // Publishing a previously unpublished post. if ('publish' === $new_status) { // Untrashing the post type - nothing here yet. if ('trash' == $old_status) { /** * Fires if untrashing post in a post type. * * This is a variable filter that is dependent on the post type * being untrashed. * * @since 2.2.0 * * @param WP_Post $post Post data. */ do_action('bp_activity_post_type_untrash_' . $post->post_type, $post); } else { // Record the post. bp_activity_post_type_publish($post->ID, $post); } // Unpublishing a previously published post. } elseif ('publish' === $old_status) { // Some form of pending status - only remove the activity entry. bp_activity_post_type_unpublish($post->ID, $post); // For any other cases, allow plugins to eventually deal with it. } else { /** * Fires when the old and the new post status are not 'publish'. * * This is a variable filter that is dependent on the post type * being untrashed. * * @since 2.5.0 * * @param WP_Post $post Post data. * @param string $new_status New status for the post. * @param string $old_status Old status for the post. */ do_action('bp_activity_post_type_transition_status_' . $post->post_type, $post, $new_status, $old_status); } }