-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow media upload without text from group activity
- Loading branch information
1 parent
b3ca591
commit da73b7e
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/main/controllers/group/RTMediaBuddyPressGroupActivity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Handle/change BuddyPress group activities behaviour. | ||
* | ||
* @package rtMedia | ||
*/ | ||
|
||
/** | ||
* Class to handle/change BuddyPress group activities behaviour. | ||
* | ||
* @author utsavladani | ||
*/ | ||
class RTMediaBuddyPressGroupActivity { | ||
|
||
/** | ||
* RTMediaBuddyPressGroupActivity constructor. | ||
*/ | ||
public function __construct() { | ||
// Allow only media uploading without text in activity. | ||
add_filter( 'bp_before_groups_post_update_parse_args', array( $this, 'bp_before_groups_post_update_parse_args' ) ); | ||
} | ||
|
||
/** | ||
* Filter content before processing in group activity. | ||
* It adds the ' ' if content is empty, when we are only uploading media from activity. | ||
* | ||
* @param array $args Activity arguments. | ||
* | ||
* @return array | ||
*/ | ||
public function bp_before_groups_post_update_parse_args( $args ) { | ||
// if content is non-breaking space then set it to empty. | ||
if ( isset( $args['content'] ) && '' === $args['content'] ) { | ||
|
||
// Nonce verification is not required here as it is already done in previously. | ||
if ( ! empty( $_POST['rtMedia_attached_files'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | ||
$args['content'] = ' '; | ||
} | ||
} | ||
|
||
return $args; | ||
} | ||
} |