Last active
November 8, 2022 13:56
-
-
Save KaineLabs/d77f92b659500bbf3125278d7e6b7d34 to your computer and use it in GitHub Desktop.
Enable Youzer Actions Buddypress Group Email Subscription
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
<?php | |
/** | |
* Enable Youzer Actions. | |
*/ | |
function yzc_add_youzer_actions_support( $retval, $type ) { | |
// Get Youzer Actions. | |
$custom_actions = array( 'activity_link', 'activity_link', 'activity_status', 'activity_file', 'activity_audio', 'activity_photo', 'activity_quote', 'activity_slideshow', 'new_cover', 'new_avatar' ); | |
// Enable Youzer Actions | |
if ( in_array( $type, $custom_actions, true ) ) { | |
$retval = true; | |
} | |
return $retval; | |
} | |
add_filter( 'ass_this_activity_is_important', 'yzc_add_youzer_actions_support', 20, 2 ); | |
add_filter( 'ass_digest_format_item', 'yzc_allow_youzer_activities', 10, 6 ); | |
function yzc_allow_youzer_activities( $item_message, $item, $action, $timestamp, $type, $replies = null ) { | |
$time_posted = date( get_option( 'time_format' ), $timestamp ); | |
$date_posted = date( get_option( 'date_format' ), $timestamp ); | |
$item_message = "<div class=\"digest-item\" {$ass_email_css['item_div']}>"; | |
$item_message .= "<span class=\"digest-item-action\" {$ass_email_css['item_action']}>" . $action . ": "; | |
$item_message .= "<span class=\"digest-item-timestamp\" {$ass_email_css['item_date']}>" . sprintf( __('at %s, %s', 'buddypress-group-email-subscription'), $time_posted, $date_posted ) ."</span>"; | |
$item_message .= "</span>\n"; | |
// activity content | |
if ( ! empty( $item->content ) ) | |
$item_message .= "<br><span class=\"digest-item-content\" {$ass_email_css['item_content']}>" . apply_filters( 'ass_digest_content', $item->content, $item, $type ) . "</span>"; | |
$allowed_activities = array( 'activity_update', 'activity_comment', 'activity_link', 'activity_status', 'activity_file', 'activity_audio', 'activity_photo', 'activity_quote', 'activity_slideshow' ); | |
if ( in_array( $item->type, $allowed_activities ) ) { | |
$view_link = bp_activity_get_permalink( $item->id, $item ); | |
} else { | |
$view_link = $item->primary_link; | |
} | |
$item_message .= ' - <a class="digest-item-view-link" href="' . ass_get_login_redirect_url( $view_link ) .'">' . __( 'View', 'buddypress-group-email-subscription' ) . '</a>'; | |
$item_message .= "</div>\n\n"; | |
return $item_message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case anyone needs it, you may want to add 'activity_poll' in order to have them included as well :)