bp_nouveau_media_localize_scripts( array $params = array() )
Localize the strings needed for the messages UI
Description
Parameters
- $params
-
(Optional) Associative array containing the JS Strings needed by scripts
Default value: array()
Return
(array) The same array with specific strings for the messages UI if needed.
Source
File: bp-templates/bp-nouveau/includes/media/functions.php
function bp_nouveau_media_localize_scripts( $params = array() ) {
$params['media'] = array(
'max_upload_size' => bp_media_file_upload_max_size(),
'profile_media' => bp_is_profile_media_support_enabled(),
'profile_album' => bp_is_profile_albums_support_enabled(),
'group_media' => bp_is_group_media_support_enabled(),
'group_album' => bp_is_group_albums_support_enabled(),
'messages_media' => bp_is_messages_media_support_enabled(),
);
if ( bp_is_single_album() ) {
$params['media']['album_id'] = (int) bp_action_variable( 0 );
}
if ( bp_is_active( 'groups' ) && bp_is_group() ) {
$params['media']['group_id'] = bp_get_current_group_id();
}
$params['media']['emoji'] = array(
'profile' => bp_is_profiles_emoji_support_enabled(),
'groups' => bp_is_groups_emoji_support_enabled(),
'messages' => bp_is_messages_emoji_support_enabled(),
'forums' => bp_is_forums_emoji_support_enabled(),
);
$params['media']['emoji_filter_url'] = buddypress()->plugin_url . 'bp-core/images/emojifilter/';
$params['media']['gif'] = array(
'profile' => bp_is_profiles_gif_support_enabled(),
'groups' => bp_is_groups_gif_support_enabled(),
'messages' => bp_is_messages_gif_support_enabled(),
'forums' => bp_is_forums_gif_support_enabled(),
);
$params['media']['gif_api_key'] = bp_media_get_gif_api_key();
if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
// check if topic edit
if ( bbp_is_topic_edit() ) {
$params['media']['bbp_is_topic_edit'] = true;
$media_ids = get_post_meta( bbp_get_topic_id(), 'bp_media_ids', true );
if ( ! empty( $media_ids ) && bp_has_media(
array(
'include' => $media_ids,
'order_by' => 'menu_order',
'sort' => 'ASC'
) ) ) {
$params['media']['topic_edit_media'] = array();
$index = 0;
while ( bp_media() ) {
bp_the_media();
$params['media']['topic_edit_media'][] = array(
'id' => bp_get_media_id(),
'attachment_id' => bp_get_media_attachment_id(),
'name' => bp_get_media_title(),
'thumb' => bp_get_media_attachment_image_thumbnail(),
'url' => bp_get_media_attachment_image(),
'menu_order' => $index,
);
$index ++;
}
}
$gif_data = get_post_meta( bbp_get_topic_id(), '_gif_data', true );
if ( ! empty( $gif_data ) ) {
$preview_url = wp_get_attachment_url( $gif_data['still'] );
$video_url = wp_get_attachment_url( $gif_data['mp4'] );
$params['media']['topic_edit_gif_data'] = array(
'preview_url' => $preview_url,
'video_url' => $video_url,
'gif_raw_data' => get_post_meta( bbp_get_topic_id(), '_gif_raw_data', true ),
);
}
}
// check if reply edit
if ( bbp_is_reply_edit() ) {
$params['media']['bbp_is_reply_edit'] = true;
$media_ids = get_post_meta( bbp_get_reply_id(), 'bp_media_ids', true );
if ( ! empty( $media_ids ) && bp_has_media(
array(
'include' => $media_ids,
'order_by' => 'menu_order',
'sort' => 'ASC'
) ) ) {
$params['media']['reply_edit_media'] = array();
$index = 0;
while ( bp_media() ) {
bp_the_media();
$params['media']['reply_edit_media'][] = array(
'id' => bp_get_media_id(),
'attachment_id' => bp_get_media_attachment_id(),
'name' => bp_get_media_title(),
'thumb' => bp_get_media_attachment_image_thumbnail(),
'url' => bp_get_media_attachment_image(),
'menu_order' => $index,
);
$index ++;
}
}
$gif_data = get_post_meta( bbp_get_reply_id(), '_gif_data', true );
if ( ! empty( $gif_data ) ) {
$preview_url = wp_get_attachment_url( $gif_data['still'] );
$video_url = wp_get_attachment_url( $gif_data['mp4'] );
$params['media']['reply_edit_gif_data'] = array(
'preview_url' => $preview_url,
'video_url' => $video_url,
'gif_raw_data' => get_post_meta( bbp_get_reply_id(), '_gif_raw_data', true ),
);
}
}
// check if forum edit
if ( bbp_is_forum_edit() ) {
$params['media']['bbp_is_forum_edit'] = true;
$media_ids = get_post_meta( bbp_get_forum_id(), 'bp_media_ids', true );
if ( ! empty( $media_ids ) && bp_has_media(
array(
'include' => $media_ids,
'order_by' => 'menu_order',
'sort' => 'ASC'
) ) ) {
$params['media']['forum_edit_media'] = array();
$index = 0;
while ( bp_media() ) {
bp_the_media();
$params['media']['forum_edit_media'][] = array(
'id' => bp_get_media_id(),
'attachment_id' => bp_get_media_attachment_id(),
'name' => bp_get_media_title(),
'thumb' => bp_get_media_attachment_image_thumbnail(),
'url' => bp_get_media_attachment_image(),
'menu_order' => $index,
);
$index ++;
}
}
$gif_data = get_post_meta( bbp_get_forum_id(), '_gif_data', true );
if ( ! empty( $gif_data ) ) {
$preview_url = wp_get_attachment_url( $gif_data['still'] );
$video_url = wp_get_attachment_url( $gif_data['mp4'] );
$params['media']['forum_edit_gif_data'] = array(
'preview_url' => $preview_url,
'video_url' => $video_url,
'gif_raw_data' => get_post_meta( bbp_get_forum_id(), '_gif_raw_data', true ),
);
}
}
}
return $params;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.