| Server IP : 104.21.28.229 / Your IP : 216.73.216.142 Web Server : Apache/2 System : Linux hosting8537.lvs 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : mienphi ( 1014) PHP Version : 8.2.14 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/mienphi/public_html/wp-content/plugins/buddypress/bp-activity/actions/ |
Upload File : |
<?php
/**
* Activity: Post action
*
* @package BuddyPress
* @subpackage ActivityActions
* @since 3.0.0
*/
/**
* Post user/group activity update.
*
* @since 1.2.0
*
* @return bool False on failure.
*/
function bp_activity_action_post_update() {
// Do not proceed if user is not logged in, not viewing activity, or not posting.
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
return false;
// Check the nonce.
check_admin_referer( 'post_update', '_wpnonce_post_update' );
/**
* Filters the content provided in the activity input field.
*
* @since 1.2.0
*
* @param string $value Activity message being posted.
*/
$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
if ( ! empty( $_POST['whats-new-post-object'] ) ) {
/**
* Filters the item type that the activity update should be associated with.
*
* @since 1.2.0
*
* @param string $value Item type to associate with.
*/
$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
}
if ( ! empty( $_POST['whats-new-post-in'] ) ) {
/**
* Filters what component the activity is being to.
*
* @since 1.2.0
*
* @param string $value Chosen component to post activity to.
*/
$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );
}
// No activity content so provide feedback and redirect.
if ( empty( $content ) ) {
bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
bp_core_redirect( wp_get_referer() );
}
// No existing item_id.
if ( empty( $item_id ) ) {
$activity_id = bp_activity_post_update( array( 'content' => $content ) );
// Post to groups object.
} elseif ( 'groups' == $object && bp_is_active( 'groups' ) ) {
if ( (int) $item_id ) {
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
}
} else {
/**
* Filters activity object for BuddyPress core and plugin authors before posting activity update.
*
* @since 1.2.0
* @since 5.0.0 Fixed filter signature to match other instances of filter,
* with $activity_id as the first param.
*
* @param int $activity_id ID of the activity item.
* @param string $object Activity item being associated to.
* @param string $item_id Component ID being posted to.
* @param string $content Activity content being posted.
*/
$activity_id = apply_filters( 'bp_activity_custom_update', 0, $object, $item_id, $content );
}
// Provide user feedback.
if ( !empty( $activity_id ) )
bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
else
bp_core_add_message( __( 'There was an error when posting your update. Please try again.', 'buddypress' ), 'error' );
// Redirect.
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'bp_activity_action_post_update' );