array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean' ) ); } /** * Output our custom embed template part. * * @since 2.6.0 */ protected function content() { bp_get_asset_template_part( 'embeds/activity' ); } /** * Check if we're on our single activity page. * * @since 2.6.0 * * @return bool */ protected function is_page() { return bp_is_single_activity(); } /** * Validates the URL to determine if the activity item is valid. * * @since 2.6.0 * * @param string $url The URL to check. * @return int|bool Activity ID on success; boolean false on failure. */ protected function validate_url_to_item_id( $url ) { if ( bp_core_enable_root_profiles() ) { $domain = bp_get_root_domain(); } else { $domain = bp_get_members_directory_permalink(); } // Check the URL to see if this is a single activity URL. if ( is_array( $url ) || 0 !== strpos( $url, $domain ) ) { return false; } // Check for activity slug. if ( false === strpos( $url, '/' . bp_get_activity_slug() . '/' ) ) { return false; } // Do more checks. $url = trim( untrailingslashit( $url ) ); // Grab the activity ID. $activity_id = (int) substr( $url, strrpos( $url, '/' ) + 1 ); if ( ! empty( $activity_id ) ) { // Check if activity item still exists. $activity = new BP_Activity_Activity( $activity_id ); // Okay, we're good to go! if ( ! empty( $activity->component ) && 0 === (int) $activity->is_spam ) { return $activity_id; } } return false; } /** * Sets the oEmbed response data for our activity item. * * @since 2.6.0 * * @param int $item_id The activity ID. * @return array */ protected function set_oembed_response_data( $item_id ) { $activity = new BP_Activity_Activity( $item_id ); return array( 'content' => $activity->content, 'title' => __( 'Activity', 'buddypress' ), 'author_name' => bp_core_get_user_displayname( $activity->user_id ), 'author_url' => bp_core_get_user_domain( $activity->user_id ), // Custom identifier. 'x_buddypress' => 'activity' ); } /** * Sets a custom
for our oEmbed fallback HTML. * * @since 2.6.0 * * @param int $item_id The activity ID. * @return string */ protected function set_fallback_html( $item_id ) { $activity = new BP_Activity_Activity( $item_id ); $mentionname = bp_activity_do_mentions() ? ' (@' . bp_activity_get_user_mentionname( $activity->user_id ) . ')' : ''; $date = date_i18n( get_option( 'date_format' ), strtotime( $activity->date_recorded ) ); // Make sure we can use some activity functions that depend on the loop. $GLOBALS['activities_template'] = new stdClass; $GLOBALS['activities_template']->activity = $activity; // 'wp-embedded-content' CSS class is necessary due to how the embed JS works. $blockquote = sprintf( '
%1$s%2$s %3$s
', bp_activity_get_embed_excerpt( $activity->content ), '- ' . bp_core_get_user_displayname( $activity->user_id ) . $mentionname, '' . $date . '' ); // Clean up. unset( $GLOBALS['activities_template'] ); /** * Filters the fallback HTML used when embedding a BP activity item. * * @since 2.6.0 * * @param string $blockquote Current fallback HTML * @param BP_Activity_Activity $activity Activity object */ return apply_filters( 'bp_activity_embed_fallback_html', $blockquote, $activity ); } /** * Sets a custom