bp_media_import_buddyboss_topic_media ()
从BuddyBoss媒体插件导入主题媒体
描述
源
文件:bp-media / bp-media-functions.php
function bp_media_import_buddyboss_topic_media() {$topics_media_query = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'fields' => 'ids', 'posts_per_page' => -1, 'meta_query' => array(array('key' => 'bbm_bbpress_attachment_ids', 'compare' => 'EXISTS',),));如果(!$attachment_ids = get_post_meta($post_id, 'bbm_bbpress_attachment_ids', true); / /将bbm_bbpress_attachment_ids设置为true$main_activity_id = get_post_meta($post_id, '_bbp_activity_id', true);数组$ media_ids = ();如果(!$title = get_the_title($attachment_id); / /将$attachment_ids作为$attachment_id;$media_id = bp_media_add(array('attachment_id' => $attachment_id, 'title' => $title, 'album_id' => false, 'group_id' => false, 'error_type' => 'bool'));If ($media_ids[] = $ media__id; / /将media_ids赋值//保存媒体保存在附件update_post_meta($attachment_id, 'bp_media_saved', true); } } $media_ids = implode( ',', $media_ids ); //Save all attachment ids in forums post meta update_post_meta( $post_id, 'bp_media_ids', $media_ids ); //save media meta for activity if ( ! empty( $main_activity_id ) && bp_is_active( 'activity' ) ) { bp_activity_update_meta( $main_activity_id, 'bp_media_ids', $media_ids ); } } } } wp_reset_postdata(); }
更新日志
版本 | 描述 |
---|---|
BuddyBoss 1.0.5 | 介绍了。 |