/** * Function to return the media for the ajax requests */ function bp_media_load_more() { global $bp, $bp_media_query; $page = isset($_POST['page']) ? $_POST['page'] : die; $current_action = isset($_POST['current_action']) ? $_POST['current_action'] : null; $action_variables = isset($_POST['action_variables']) ? $_POST['action_variables'] : null; $displayed_user = isset($_POST['displayed_user']) ? $_POST['displayed_user'] : null; $loggedin_user = isset($_POST['loggedin_user']) ? $_POST['loggedin_user'] : null; if (!$displayed_user || intval($displayed_user) == 0) { die; } $posts_per_page = 10; switch ($current_action) { case BP_MEDIA_IMAGES_SLUG: $args = array('post_type' => 'attachment', 'post_status' => 'any', 'post_mime_type' => 'image', 'author' => $bp->displayed_user->id, 'meta_key' => 'bp-media-key', 'meta_value' => $bp->displayed_user->id, 'meta_compare' => 'LIKE', 'paged' => $page, 'posts_per_page' => $posts_per_page); break; case BP_MEDIA_AUDIO_SLUG: $args = array('post_type' => 'attachment', 'post_status' => 'any', 'post_mime_type' => 'audio', 'author' => $bp->displayed_user->id, 'meta_key' => 'bp-media-key', 'meta_value' => $bp->displayed_user->id, 'meta_compare' => 'LIKE', 'paged' => $page, 'posts_per_page' => $posts_per_page); break; case BP_MEDIA_VIDEOS_SLUG: $args = array('post_type' => 'attachment', 'post_status' => 'any', 'post_mime_type' => 'video', 'author' => $bp->displayed_user->id, 'meta_key' => 'bp-media-key', 'meta_value' => $bp->displayed_user->id, 'meta_compare' => 'LIKE', 'paged' => $page, 'posts_per_page' => $posts_per_page); break; case BP_MEDIA_ALBUMS_SLUG: if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0]) && isset($action_variables[1])) { $args = array('post_type' => 'attachment', 'post_status' => 'any', 'author' => $displayed_user, 'post_parent' => $action_variables[1], 'paged' => $page); } else { $args = array('post_type' => 'bp_media_album', 'author' => $displayed_user, 'paged' => $page); } break; default: die; } $bp_media_query = new WP_Query($args); if (isset($bp_media_query->posts) && is_array($bp_media_query->posts) && count($bp_media_query->posts)) { foreach ($bp_media_query->posts as $attachment) { try { $media = new BP_Media_Host_Wordpress($attachment->ID); echo $media->get_media_gallery_content(); } catch (exception $e) { die; } } } die; }
function bp_media_the_content($id = 0) { if (is_object($id)) { $media = $id; } else { $media =& get_post($id); } if (empty($media->ID)) { return false; } if (!$media->post_type == 'bp_media') { return false; } $media = new BP_Media_Host_Wordpress($media->ID); echo $media->get_media_gallery_content(); }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Media', 'bp-media') : $instance['title'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 10; } echo $before_widget; echo $before_title . $title . $after_title; ?> <div id="popular-media-tabs" class="media-tabs-container"> <!-- <ul> <li><a href="#popular-media-tabs-comments"><?php _e('comments', 'bp-media'); ?> </a></li> <li><a href="#popular-media-tabs-views"><?php _e('Views', 'bp-media'); ?> </a></li> </ul>--> <div id="popular-media-tabs-comments" class="bp-media-tab-panel"> <?php $args = array('post_type' => 'attachment', 'post_status' => 'any', 'posts_per_page' => $number, 'meta_key' => 'bp-media-key', 'meta_value' => 0, 'meta_compare' => '>', 'orderby' => 'comment_count'); $bp_media_widget_query = new WP_Query($args); if ($bp_media_widget_query->have_posts()) { ?> <ul class="widget-item-listing"><?php while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post(); $entry = new BP_Media_Host_Wordpress(get_the_ID()); ?> <?php echo $entry->get_media_gallery_content(); } ?> </ul><!-- .widget-item-listing --><?php } else { _e('No popular media found', 'bp-media'); } wp_reset_query(); ?> </div><!-- #popular-media-tabs-comments --> </div> <?php echo $after_widget; }