Version Description
- Groups Media feature added
- Featured image selection in albums
Download this release
Release Info
Developer | gagan0123 |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2.8 to 2.3
- includes/bp-media-actions.php +55 -22
- includes/bp-media-class-album.php +52 -6
- includes/bp-media-class-wordpress.php +157 -75
- includes/bp-media-filters.php +0 -2
- includes/bp-media-functions.php +29 -0
- includes/bp-media-groups-actions.php +118 -0
- includes/bp-media-groups-loader.php +333 -0
- includes/bp-media-groups-screens.php +172 -0
- includes/bp-media-loader.php +3 -0
- includes/bp-media-screens.php +4 -0
- includes/bp-media-template-functions.php +35 -20
- includes/bp-media-widgets.php +115 -113
- includes/css/bp-media-style.css +1 -0
- includes/js/bp-media-uploader.js +3 -2
- includes/js/bp-media.js +34 -1
- loader.php +3 -2
- readme.txt +5 -1
includes/bp-media-actions.php
CHANGED
@@ -12,6 +12,12 @@ function bp_media_handle_uploads() {
|
|
12 |
'images_enabled' => true,
|
13 |
));
|
14 |
if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/* @var $bp_media_entry BP_Media_Host_Wordpress */
|
16 |
if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
|
17 |
if(!preg_match('/audio|video|image/i',$_FILES['bp_media_file']['type'],$result)||!isset($result[0])){
|
@@ -92,14 +98,14 @@ function bp_media_enqueue_scripts_styles() {
|
|
92 |
wp_enqueue_script('bp-media-mejs', plugins_url('includes/media-element/mediaelement-and-player.min.js', dirname(__FILE__)));
|
93 |
wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
94 |
global $bp;
|
95 |
-
|
96 |
$bp_media_vars = array(
|
97 |
'ajaxurl' => admin_url( 'admin-ajax.php'),
|
98 |
'page' => 1,
|
99 |
-
'current_action' => isset($bp->current_action)?$bp->current_action:false,
|
100 |
-
'action_variables' => isset($bp->action_variables)
|
101 |
'displayed_user' => bp_displayed_user_id(),
|
102 |
-
'loggedin_user' => bp_loggedin_user_id()
|
|
|
103 |
);
|
104 |
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
105 |
wp_enqueue_style('bp-media-mecss', plugins_url('includes/media-element/mediaelementplayer.min.css', dirname(__FILE__)));
|
@@ -188,7 +194,7 @@ function bp_media_set_query() {
|
|
188 |
'author' => $bp->displayed_user->id,
|
189 |
'meta_key' => 'bp-media-key',
|
190 |
'meta_value' => $bp->displayed_user->id,
|
191 |
-
'meta_compare' => '
|
192 |
'paged' => $paged,
|
193 |
'posts_per_page' => $bp_media_posts_per_page
|
194 |
);
|
@@ -209,12 +215,19 @@ function bp_media_action_buttons() {
|
|
209 |
global $bp_media_current_entry,$bp_media_options;
|
210 |
|
211 |
if($bp_media_current_entry!=NULL){
|
|
|
|
|
212 |
if(bp_displayed_user_id()== bp_loggedin_user_id())
|
213 |
echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action bp-media-edit" title="Edit Media">Edit</a>';
|
214 |
|
215 |
if($bp_media_options['download_enabled']==true)
|
216 |
echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action bp-media-download" title="Download">Download</a>';
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
add_action('bp_activity_entry_meta', 'bp_media_action_buttons');
|
220 |
|
@@ -281,7 +294,7 @@ function bp_media_upload_enqueue(){
|
|
281 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
282 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
283 |
'multi_selection' => true,
|
284 |
-
'multipart_params' => array('action'=>'wp_handle_upload')
|
285 |
);
|
286 |
wp_enqueue_script('bp-media-uploader',plugins_url('js/bp-media-uploader.js',__FILE__),array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4','plupload-handlers','jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-dialog'));
|
287 |
wp_localize_script('bp-media-uploader','bp_media_uploader_params',$params);
|
@@ -312,6 +325,9 @@ function bp_media_albums_set_query() {
|
|
312 |
'post_type' => 'bp_media_album',
|
313 |
'author' => $bp->displayed_user->id,
|
314 |
'paged' => $paged,
|
|
|
|
|
|
|
315 |
);
|
316 |
$bp_media_albums_query = new WP_Query($args);
|
317 |
}
|
@@ -331,7 +347,7 @@ function bp_media_albums_set_inner_query($album_id=0) {
|
|
331 |
if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0])) {
|
332 |
if($action_variables[0] == 'page' && isset($action_variables[1]) && is_numeric($action_variables[1]))
|
333 |
$paged = $action_variables[1];
|
334 |
-
else if($action_variables[1] == 'page' && isset($action_variables[2]) && is_numeric($action_variables[2]))
|
335 |
$paged = $action_variables[2];
|
336 |
}
|
337 |
if(!$paged)
|
@@ -339,7 +355,6 @@ function bp_media_albums_set_inner_query($album_id=0) {
|
|
339 |
$args = array(
|
340 |
'post_type' => 'attachment',
|
341 |
'post_status' => 'any',
|
342 |
-
'author' => $bp->displayed_user->id,
|
343 |
'post_parent'=>$album_id,
|
344 |
'paged' => $paged
|
345 |
);
|
@@ -356,7 +371,8 @@ function bp_media_load_more() {
|
|
356 |
$action_variables = isset($_POST['action_variables'])?$_POST['action_variables']:null;
|
357 |
$displayed_user = isset($_POST['displayed_user'])?$_POST['displayed_user']:null;
|
358 |
$loggedin_user = isset($_POST['loggedin_user'])?$_POST['loggedin_user']:null;
|
359 |
-
|
|
|
360 |
die();
|
361 |
}
|
362 |
switch($current_action){
|
@@ -365,10 +381,9 @@ function bp_media_load_more() {
|
|
365 |
'post_type' => 'attachment',
|
366 |
'post_status' => 'any',
|
367 |
'post_mime_type' => 'image',
|
368 |
-
'author' => $bp->displayed_user->id,
|
369 |
'meta_key' => 'bp-media-key',
|
370 |
-
'meta_value' => $bp->displayed_user->id,
|
371 |
-
'meta_compare' => '
|
372 |
'paged' => $page,
|
373 |
'posts_per_page' => $bp_media_posts_per_page
|
374 |
);
|
@@ -380,8 +395,8 @@ function bp_media_load_more() {
|
|
380 |
'post_mime_type' => 'audio',
|
381 |
'author' => $bp->displayed_user->id,
|
382 |
'meta_key' => 'bp-media-key',
|
383 |
-
'meta_value' => $bp->displayed_user->id,
|
384 |
-
'meta_compare' => '
|
385 |
'paged' => $page,
|
386 |
'posts_per_page' => $bp_media_posts_per_page
|
387 |
);
|
@@ -393,8 +408,8 @@ function bp_media_load_more() {
|
|
393 |
'post_mime_type' => 'video',
|
394 |
'author' => $bp->displayed_user->id,
|
395 |
'meta_key' => 'bp-media-key',
|
396 |
-
'meta_value' => $bp->displayed_user->id,
|
397 |
-
'meta_compare' => '
|
398 |
'paged' => $page,
|
399 |
'posts_per_page' => $bp_media_posts_per_page
|
400 |
);
|
@@ -478,12 +493,29 @@ add_action('delete_attachment','bp_media_delete_attachment_handler');
|
|
478 |
function bp_media_add_album() {
|
479 |
if(isset($_POST['bp_media_album_name'])&&$_POST['bp_media_album_name']!=''){
|
480 |
$album = new BP_Media_Album();
|
481 |
-
|
482 |
-
$
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
}
|
485 |
-
|
486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
}
|
488 |
}
|
489 |
else{
|
@@ -542,6 +574,7 @@ function bp_media_activity_create_after_add_media($media,$hidden=false){
|
|
542 |
'type' => 'media_upload',
|
543 |
'user_id' => $media->get_author()
|
544 |
);
|
|
|
545 |
if($hidden){
|
546 |
$args['secondary_item_id'] = -999;
|
547 |
do_action('bp_media_album_updated',$media->get_album_id());
|
12 |
'images_enabled' => true,
|
13 |
));
|
14 |
if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
|
15 |
+
/** This section can help in the group activity handling */
|
16 |
+
if(isset($_POST['bp_media_group_id'])&&intval($_POST['bp_media_group_id'])){
|
17 |
+
remove_action('bp_media_after_add_media','bp_media_activity_create_after_add_media',10,2);
|
18 |
+
add_action('bp_media_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
|
19 |
+
add_filter('bp_media_force_hide_activity','bp_media_groups_force_hide_activity');
|
20 |
+
}
|
21 |
/* @var $bp_media_entry BP_Media_Host_Wordpress */
|
22 |
if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
|
23 |
if(!preg_match('/audio|video|image/i',$_FILES['bp_media_file']['type'],$result)||!isset($result[0])){
|
98 |
wp_enqueue_script('bp-media-mejs', plugins_url('includes/media-element/mediaelement-and-player.min.js', dirname(__FILE__)));
|
99 |
wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
100 |
global $bp;
|
|
|
101 |
$bp_media_vars = array(
|
102 |
'ajaxurl' => admin_url( 'admin-ajax.php'),
|
103 |
'page' => 1,
|
104 |
+
'current_action' => bp_get_current_group_id()?(empty($bp->action_variables)?BP_MEDIA_IMAGES_SLUG:$bp->action_variables):(isset($bp->current_action)?$bp->current_action:false),
|
105 |
+
'action_variables' => isset($bp->action_variables)?(empty($bp->action_variables)?array(BP_MEDIA_IMAGES_SLUG):$bp->action_variables):array(BP_MEDIA_IMAGES_SLUG),
|
106 |
'displayed_user' => bp_displayed_user_id(),
|
107 |
+
'loggedin_user' => bp_loggedin_user_id(),
|
108 |
+
'current_group' => bp_get_current_group_id()
|
109 |
);
|
110 |
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
111 |
wp_enqueue_style('bp-media-mecss', plugins_url('includes/media-element/mediaelementplayer.min.css', dirname(__FILE__)));
|
194 |
'author' => $bp->displayed_user->id,
|
195 |
'meta_key' => 'bp-media-key',
|
196 |
'meta_value' => $bp->displayed_user->id,
|
197 |
+
'meta_compare' => '=',
|
198 |
'paged' => $paged,
|
199 |
'posts_per_page' => $bp_media_posts_per_page
|
200 |
);
|
215 |
global $bp_media_current_entry,$bp_media_options;
|
216 |
|
217 |
if($bp_media_current_entry!=NULL){
|
218 |
+
$featured_post = get_post_meta($bp_media_current_entry->get_id(),'featured',true);
|
219 |
+
|
220 |
if(bp_displayed_user_id()== bp_loggedin_user_id())
|
221 |
echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action bp-media-edit" title="Edit Media">Edit</a>';
|
222 |
|
223 |
if($bp_media_options['download_enabled']==true)
|
224 |
echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action bp-media-download" title="Download">Download</a>';
|
225 |
+
|
226 |
+
if(bp_displayed_user_id()== bp_loggedin_user_id() && $featured_post == '')
|
227 |
+
echo '<a href="'.$bp_media_current_entry->get_album_id().'" rel="" data-album-id="'.$bp_media_current_entry->get_album_id().'" data-post-id="'.$bp_media_current_entry->get_id().'" class="button item-button bp-secondary-action bp-media-featured" title="Featured Media">Featured</a>';
|
228 |
+
else
|
229 |
+
echo '<a href="'.$bp_media_current_entry->get_album_id().'" rel="" data-remove-featured="1" data-album-id="'.$bp_media_current_entry->get_album_id().'" data-post-id="'.$bp_media_current_entry->get_id().'" class="button item-button bp-secondary-action bp-media-featured" title="Featured Media">Remove Featured</a>';
|
230 |
+
}
|
231 |
}
|
232 |
add_action('bp_activity_entry_meta', 'bp_media_action_buttons');
|
233 |
|
294 |
'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
|
295 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
296 |
'multi_selection' => true,
|
297 |
+
'multipart_params' => apply_filters('bp_media_multipart_params_filter',array('action'=>'wp_handle_upload'))
|
298 |
);
|
299 |
wp_enqueue_script('bp-media-uploader',plugins_url('js/bp-media-uploader.js',__FILE__),array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4','plupload-handlers','jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-dialog'));
|
300 |
wp_localize_script('bp-media-uploader','bp_media_uploader_params',$params);
|
325 |
'post_type' => 'bp_media_album',
|
326 |
'author' => $bp->displayed_user->id,
|
327 |
'paged' => $paged,
|
328 |
+
'meta_key' => 'bp-media-key',
|
329 |
+
'meta_value' => $bp->displayed_user->id,
|
330 |
+
'meta_compare' => '='
|
331 |
);
|
332 |
$bp_media_albums_query = new WP_Query($args);
|
333 |
}
|
347 |
if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0])) {
|
348 |
if($action_variables[0] == 'page' && isset($action_variables[1]) && is_numeric($action_variables[1]))
|
349 |
$paged = $action_variables[1];
|
350 |
+
else if(isset($action_variables[1]) && $action_variables[1] == 'page' && isset($action_variables[2]) && is_numeric($action_variables[2]))
|
351 |
$paged = $action_variables[2];
|
352 |
}
|
353 |
if(!$paged)
|
355 |
$args = array(
|
356 |
'post_type' => 'attachment',
|
357 |
'post_status' => 'any',
|
|
|
358 |
'post_parent'=>$album_id,
|
359 |
'paged' => $paged
|
360 |
);
|
371 |
$action_variables = isset($_POST['action_variables'])?$_POST['action_variables']:null;
|
372 |
$displayed_user = isset($_POST['displayed_user'])?$_POST['displayed_user']:null;
|
373 |
$loggedin_user = isset($_POST['loggedin_user'])?$_POST['loggedin_user']:null;
|
374 |
+
$current_group = isset($_POST['current_group'])?$_POST['current_group']:null;
|
375 |
+
if((!$displayed_user||intval($displayed_user)==0)&&(!$current_group||intval($current_group)==0)){
|
376 |
die();
|
377 |
}
|
378 |
switch($current_action){
|
381 |
'post_type' => 'attachment',
|
382 |
'post_status' => 'any',
|
383 |
'post_mime_type' => 'image',
|
|
|
384 |
'meta_key' => 'bp-media-key',
|
385 |
+
'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
|
386 |
+
'meta_compare' => '=',
|
387 |
'paged' => $page,
|
388 |
'posts_per_page' => $bp_media_posts_per_page
|
389 |
);
|
395 |
'post_mime_type' => 'audio',
|
396 |
'author' => $bp->displayed_user->id,
|
397 |
'meta_key' => 'bp-media-key',
|
398 |
+
'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
|
399 |
+
'meta_compare' => '=',
|
400 |
'paged' => $page,
|
401 |
'posts_per_page' => $bp_media_posts_per_page
|
402 |
);
|
408 |
'post_mime_type' => 'video',
|
409 |
'author' => $bp->displayed_user->id,
|
410 |
'meta_key' => 'bp-media-key',
|
411 |
+
'meta_value' => $current_group>0?-$current_group:$bp->displayed_user->id,
|
412 |
+
'meta_compare' => '=',
|
413 |
'paged' => $page,
|
414 |
'posts_per_page' => $bp_media_posts_per_page
|
415 |
);
|
493 |
function bp_media_add_album() {
|
494 |
if(isset($_POST['bp_media_album_name'])&&$_POST['bp_media_album_name']!=''){
|
495 |
$album = new BP_Media_Album();
|
496 |
+
if(isset($_POST['bp_media_group_id'])&&intval($_POST['bp_media_group_id'])>0){
|
497 |
+
$group_id = intval($_POST['bp_media_group_id']);
|
498 |
+
if(bp_media_groups_user_can_create_album($group_id, get_current_user_id())){
|
499 |
+
try{
|
500 |
+
$album -> add_album($_POST['bp_media_album_name'], 0 ,$group_id);
|
501 |
+
echo $album->get_id();
|
502 |
+
}
|
503 |
+
catch(exception $e){
|
504 |
+
echo '0';
|
505 |
+
}
|
506 |
+
}
|
507 |
+
else{
|
508 |
+
echo '0';
|
509 |
+
}
|
510 |
}
|
511 |
+
else{
|
512 |
+
try{
|
513 |
+
$album -> add_album($_POST['bp_media_album_name']);
|
514 |
+
echo $album->get_id();
|
515 |
+
}
|
516 |
+
catch(exception $e){
|
517 |
+
echo '0';
|
518 |
+
}
|
519 |
}
|
520 |
}
|
521 |
else{
|
574 |
'type' => 'media_upload',
|
575 |
'user_id' => $media->get_author()
|
576 |
);
|
577 |
+
$hidden = apply_filters('bp_media_force_hide_activity',$hidden);
|
578 |
if($hidden){
|
579 |
$args['secondary_item_id'] = -999;
|
580 |
do_action('bp_media_album_updated',$media->get_album_id());
|
includes/bp-media-class-album.php
CHANGED
@@ -9,7 +9,8 @@ class BP_Media_Album{
|
|
9 |
$delete_url,
|
10 |
$thumbnail,
|
11 |
$edit_url,
|
12 |
-
$media_entries
|
|
|
13 |
|
14 |
/**
|
15 |
* Constructs a new BP_Media_Album
|
@@ -43,13 +44,51 @@ class BP_Media_Album{
|
|
43 |
$this->description = $album->post_content;
|
44 |
$this->name = $album->post_title;
|
45 |
$this->owner = $album->post_author;
|
46 |
-
$
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
$this->thumbnail = '<img src = '.plugins_url('img/image_thumb.png', __FILE__) .' />';
|
54 |
}
|
55 |
$this->media_entries = get_children(array(
|
@@ -199,5 +238,12 @@ class BP_Media_Album{
|
|
199 |
function get_owner(){
|
200 |
return $this->owner;
|
201 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
}
|
203 |
?>
|
9 |
$delete_url,
|
10 |
$thumbnail,
|
11 |
$edit_url,
|
12 |
+
$media_entries,
|
13 |
+
$group_id;
|
14 |
|
15 |
/**
|
16 |
* Constructs a new BP_Media_Album
|
44 |
$this->description = $album->post_content;
|
45 |
$this->name = $album->post_title;
|
46 |
$this->owner = $album->post_author;
|
47 |
+
$meta_key = get_post_meta($this->id, 'bp-media-key', true);
|
48 |
+
/**
|
49 |
+
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
50 |
+
* if the value is less than 0 it means it the group id to which the media belongs
|
51 |
+
* and if its greater than 0 then it means its the author id of the uploader
|
52 |
+
* But for use in the class, we use group_id as positive integer even though
|
53 |
+
* we use it as negative value in the bp-media-key meta key
|
54 |
+
*/
|
55 |
+
$this->group_id = $meta_key<0?-$meta_key:0;
|
56 |
+
if($this->group_id>0){
|
57 |
+
$current_group = new BP_Groups_Group($this->group_id);
|
58 |
+
$group_url = bp_get_group_permalink($current_group);
|
59 |
+
$this->url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
60 |
+
$this->edit_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
61 |
+
$this->delete_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
62 |
}
|
63 |
else{
|
64 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
65 |
+
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
66 |
+
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
67 |
+
}
|
68 |
+
$attachments = get_children(array(
|
69 |
+
'numberposts' => 1,
|
70 |
+
'order'=> 'DESC',
|
71 |
+
'post_mime_type' => 'image',
|
72 |
+
'post_parent' => $this->id,
|
73 |
+
'post_type' => 'attachment'
|
74 |
+
));
|
75 |
+
$attachments_featured = get_children(array(
|
76 |
+
'numberposts' => 1,
|
77 |
+
'meta_key' => 'featured',
|
78 |
+
'orderby' => 'meta_value',
|
79 |
+
'post_mime_type' => 'image',
|
80 |
+
'post_parent' => $this->id,
|
81 |
+
'post_type' => 'attachment',
|
82 |
+
));
|
83 |
+
if($attachments_featured) {
|
84 |
+
foreach($attachments_featured as $attachment) {
|
85 |
+
$this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
|
86 |
+
}
|
87 |
+
}elseif ($attachments) {
|
88 |
+
foreach($attachments as $attachment) {
|
89 |
+
$this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
|
90 |
+
}
|
91 |
+
}else{
|
92 |
$this->thumbnail = '<img src = '.plugins_url('img/image_thumb.png', __FILE__) .' />';
|
93 |
}
|
94 |
$this->media_entries = get_children(array(
|
238 |
function get_owner(){
|
239 |
return $this->owner;
|
240 |
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Returns the group id to which the media belongs, 0 if it does not belong to any group
|
244 |
+
*/
|
245 |
+
function get_group_id(){
|
246 |
+
return $this->group_id;
|
247 |
+
}
|
248 |
}
|
249 |
?>
|
includes/bp-media-class-wordpress.php
CHANGED
@@ -4,7 +4,7 @@ class BP_Media_Host_Wordpress {
|
|
4 |
/**
|
5 |
* Private variables not to be accessible outside this class' member functions
|
6 |
*/
|
7 |
-
|
8 |
$name, //Name of the entry
|
9 |
$description, //Description of the entry
|
10 |
$url, //URL of the entry
|
@@ -13,7 +13,8 @@ class BP_Media_Host_Wordpress {
|
|
13 |
$delete_url, //The delete url for the media
|
14 |
$thumbnail_id, //The thumbnail's id
|
15 |
$album_id, //The album id to which the media belongs
|
16 |
-
$edit_url
|
|
|
17 |
|
18 |
/**
|
19 |
* Constructs a new BP_Media_Host_Wordpress element
|
@@ -48,34 +49,21 @@ class BP_Media_Host_Wordpress {
|
|
48 |
$this->name = $media->post_title;
|
49 |
$this->owner = $media->post_author;
|
50 |
$this->album_id = $media->post_parent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
preg_match_all('/audio|video|image/i', $media->post_mime_type, $result);
|
52 |
if(isset($result[0][0]))
|
53 |
$this->type = $result[0][0];
|
54 |
else
|
55 |
return false;
|
56 |
-
|
57 |
-
case 'video' :
|
58 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . $this->id);
|
59 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id);
|
60 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
61 |
-
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
62 |
-
break;
|
63 |
-
case 'audio' :
|
64 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . $this->id);
|
65 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id);
|
66 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
67 |
-
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
68 |
-
break;
|
69 |
-
case 'image' :
|
70 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . $this->id);
|
71 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id);
|
72 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
73 |
-
$image_array = image_downsize($this->id, 'bp_media_single_image');
|
74 |
-
$this->thumbnail_id = $this->id;
|
75 |
-
break;
|
76 |
-
default :
|
77 |
-
return false;
|
78 |
-
}
|
79 |
}
|
80 |
|
81 |
/**
|
@@ -88,27 +76,9 @@ class BP_Media_Host_Wordpress {
|
|
88 |
global $bp, $wpdb, $bp_media_count;
|
89 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
90 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
if($album->post_author!= get_current_user_id()){
|
95 |
-
$create_new_album_flag = true;
|
96 |
-
}
|
97 |
-
else{
|
98 |
-
$post_id = $album->ID;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
else{
|
102 |
-
$create_new_album_flag = true;
|
103 |
-
}
|
104 |
-
if($create_new_album_flag){
|
105 |
-
$post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title = 'Wall Posts' AND post_author = '". get_current_user_id()."' AND post_type='bp_media_album'");
|
106 |
-
if($post_id==null){
|
107 |
-
$album = new BP_Media_Album();
|
108 |
-
$album->add_album('Wall Posts');
|
109 |
-
$post_id = $album->get_id();
|
110 |
-
}
|
111 |
-
}
|
112 |
$file = wp_handle_upload($_FILES['bp_media_file']);
|
113 |
if (isset($file['error']) || $file === null) {
|
114 |
throw new Exception(__('Error Uploading File', 'bp-media'));
|
@@ -214,34 +184,15 @@ class BP_Media_Host_Wordpress {
|
|
214 |
$this->type = $type;
|
215 |
$this->owner = get_current_user_id();
|
216 |
$this->album_id = $post_id;
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id);
|
221 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
222 |
-
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
223 |
-
break;
|
224 |
-
case 'audio' :
|
225 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . $this->id);
|
226 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id);
|
227 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
228 |
-
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
229 |
-
break;
|
230 |
-
case 'image' :
|
231 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . $this->id);
|
232 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id);
|
233 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
234 |
-
$image_array = image_downsize($this->id, 'bp_media_single_image');
|
235 |
-
$this->thumbnail_id = $this->id;
|
236 |
-
break;
|
237 |
-
default :
|
238 |
-
//return false;
|
239 |
-
}
|
240 |
-
if($group == 0)
|
241 |
update_post_meta($attachment_id, 'bp-media-key', get_current_user_id());
|
242 |
-
|
|
|
|
|
243 |
update_post_meta($attachment_id, 'bp-media-key', (-$group));
|
244 |
-
|
245 |
do_action('bp_media_after_add_media',$this,$is_multiple);
|
246 |
}
|
247 |
|
@@ -306,7 +257,12 @@ class BP_Media_Host_Wordpress {
|
|
306 |
*/
|
307 |
function get_media_single_content() {
|
308 |
global $bp_media_default_sizes, $bp_media_default_excerpts;
|
309 |
-
$content = '
|
|
|
|
|
|
|
|
|
|
|
310 |
switch ($this->type) {
|
311 |
case 'video' :
|
312 |
if($this->thumbnail_id){
|
@@ -528,6 +484,36 @@ class BP_Media_Host_Wordpress {
|
|
528 |
return $result;
|
529 |
}
|
530 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
/**
|
532 |
* Deletes the Media Entry
|
533 |
*/
|
@@ -661,5 +647,101 @@ class BP_Media_Host_Wordpress {
|
|
661 |
function get_type(){
|
662 |
return $this->type;
|
663 |
}
|
664 |
-
|
665 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
/**
|
5 |
* Private variables not to be accessible outside this class' member functions
|
6 |
*/
|
7 |
+
protected $id, //id of the entry
|
8 |
$name, //Name of the entry
|
9 |
$description, //Description of the entry
|
10 |
$url, //URL of the entry
|
13 |
$delete_url, //The delete url for the media
|
14 |
$thumbnail_id, //The thumbnail's id
|
15 |
$album_id, //The album id to which the media belongs
|
16 |
+
$edit_url, //The edit page's url for the media
|
17 |
+
$group_id; //The group id of the current media file if it belongs to a group
|
18 |
|
19 |
/**
|
20 |
* Constructs a new BP_Media_Host_Wordpress element
|
49 |
$this->name = $media->post_title;
|
50 |
$this->owner = $media->post_author;
|
51 |
$this->album_id = $media->post_parent;
|
52 |
+
$meta_key = get_post_meta($this->id, 'bp-media-key', true);
|
53 |
+
/**
|
54 |
+
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
55 |
+
* if the value is less than 0 it means it the group id to which the media belongs
|
56 |
+
* and if its greater than 0 then it means its the author id of the uploader
|
57 |
+
* But for use in the class, we use group_id as positive integer even though
|
58 |
+
* we use it as negative value in the bp-media-key meta key
|
59 |
+
*/
|
60 |
+
$this->group_id = $meta_key<0?-$meta_key:0;
|
61 |
preg_match_all('/audio|video|image/i', $media->post_mime_type, $result);
|
62 |
if(isset($result[0][0]))
|
63 |
$this->type = $result[0][0];
|
64 |
else
|
65 |
return false;
|
66 |
+
$this->set_permalinks();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
/**
|
76 |
global $bp, $wpdb, $bp_media_count;
|
77 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
78 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
79 |
+
|
80 |
+
$post_id = $this->check_and_create_album($album_id,$group);
|
81 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
$file = wp_handle_upload($_FILES['bp_media_file']);
|
83 |
if (isset($file['error']) || $file === null) {
|
84 |
throw new Exception(__('Error Uploading File', 'bp-media'));
|
184 |
$this->type = $type;
|
185 |
$this->owner = get_current_user_id();
|
186 |
$this->album_id = $post_id;
|
187 |
+
$this->group_id = $group;
|
188 |
+
$this->set_permalinks();
|
189 |
+
if($group == 0){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
update_post_meta($attachment_id, 'bp-media-key', get_current_user_id());
|
191 |
+
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
192 |
+
}
|
193 |
+
else{
|
194 |
update_post_meta($attachment_id, 'bp-media-key', (-$group));
|
195 |
+
}
|
196 |
do_action('bp_media_after_add_media',$this,$is_multiple);
|
197 |
}
|
198 |
|
257 |
*/
|
258 |
function get_media_single_content() {
|
259 |
global $bp_media_default_sizes, $bp_media_default_excerpts;
|
260 |
+
$content = '';
|
261 |
+
if($this->group_id>0){
|
262 |
+
|
263 |
+
$content .= '<div class="bp_media_author">Uploaded by '. bp_core_get_userlink($this->owner).'</div>';
|
264 |
+
}
|
265 |
+
$content .= '<div class="bp_media_content">';
|
266 |
switch ($this->type) {
|
267 |
case 'video' :
|
268 |
if($this->thumbnail_id){
|
484 |
return $result;
|
485 |
}
|
486 |
|
487 |
+
/**
|
488 |
+
* Updates activity content's title and description sync with the editing of Media
|
489 |
+
*
|
490 |
+
*/
|
491 |
+
function update_media_activity(){
|
492 |
+
global $wpdb, $bp, $current_user;
|
493 |
+
$q = $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id);
|
494 |
+
$activities = $wpdb->get_results($q);
|
495 |
+
if(isset($activities) && count($activities) > 0){
|
496 |
+
$activities_template = new BP_Activity_Template(array(
|
497 |
+
'max' => TRUE,
|
498 |
+
'user_id' => $current_user,
|
499 |
+
'in' => $activities[0]->id
|
500 |
+
));
|
501 |
+
foreach ($activities_template->activities as $activity){
|
502 |
+
$args = array(
|
503 |
+
'content' => $this->get_media_activity_content(),
|
504 |
+
'id' => $activity->id,
|
505 |
+
'type' => 'media_upload',
|
506 |
+
'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $this->get_author() ), '<a href="' . $this->get_url() . '">' . $this->get_media_activity_type() . '</a>' ) ),
|
507 |
+
'primary_link' => $this->get_url(),
|
508 |
+
'item_id' => $this->get_id(),
|
509 |
+
'recorded_time' => $activity->date_recorded,
|
510 |
+
'user_id' => $this->get_author()
|
511 |
+
);
|
512 |
+
$activity_id = bp_media_record_activity($args);
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
/**
|
518 |
* Deletes the Media Entry
|
519 |
*/
|
647 |
function get_type(){
|
648 |
return $this->type;
|
649 |
}
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Returns the group id of the media, 0 if it does not belong to a group
|
653 |
+
*/
|
654 |
+
function get_group_id(){
|
655 |
+
return $this->group_id;
|
656 |
+
}
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Sets the permalinks of the media depending upon whether its in member directory
|
660 |
+
* or group and acording to the media type
|
661 |
+
*/
|
662 |
+
protected function set_permalinks(){
|
663 |
+
if($this->group_id>0){
|
664 |
+
$current_group = new BP_Groups_Group($this->group_id);
|
665 |
+
$pre_url = bp_get_group_permalink($current_group);
|
666 |
+
}
|
667 |
+
else{
|
668 |
+
$pre_url = bp_core_get_user_domain($this->owner);
|
669 |
+
}
|
670 |
+
switch ($this->type) {
|
671 |
+
case 'video' :
|
672 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . $this->id);
|
673 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id);
|
674 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
675 |
+
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
676 |
+
break;
|
677 |
+
case 'audio' :
|
678 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . $this->id);
|
679 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id);
|
680 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
681 |
+
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
682 |
+
break;
|
683 |
+
case 'image' :
|
684 |
+
$this->url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . $this->id);
|
685 |
+
$this->edit_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id);
|
686 |
+
$this->delete_url = trailingslashit( $pre_url . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
687 |
+
$image_array = image_downsize($this->id, 'bp_media_single_image');
|
688 |
+
$this->thumbnail_id = $this->id;
|
689 |
+
break;
|
690 |
+
default :
|
691 |
+
return false;
|
692 |
+
}
|
693 |
+
return true;
|
694 |
+
}
|
695 |
+
|
696 |
+
/**
|
697 |
+
* Checks if the album given exists if not, creates a new one according to context
|
698 |
+
*/
|
699 |
+
function check_and_create_album($album_id,$group){
|
700 |
+
global $wpdb;
|
701 |
+
$create_new_album_flag = false;
|
702 |
+
if($album_id!=0){
|
703 |
+
$album = get_post($album_id);
|
704 |
+
if($album->post_author!= get_current_user_id() && $group == 0){
|
705 |
+
$create_new_album_flag = true;
|
706 |
+
}
|
707 |
+
else{
|
708 |
+
$post_id = $album->ID;
|
709 |
+
}
|
710 |
+
}
|
711 |
+
else{
|
712 |
+
$create_new_album_flag = true;
|
713 |
+
}
|
714 |
+
if($create_new_album_flag){
|
715 |
+
if($group == 0){
|
716 |
+
$post_id = $wpdb->get_var(
|
717 |
+
"SELECT ID
|
718 |
+
FROM $wpdb->posts
|
719 |
+
WHERE
|
720 |
+
post_title = 'Wall Posts'
|
721 |
+
AND post_author = '". get_current_user_id()."'
|
722 |
+
AND post_type='bp_media_album'"
|
723 |
+
);
|
724 |
+
}
|
725 |
+
else{
|
726 |
+
$post_id = $wpdb->get_var(
|
727 |
+
"SELECT wp_posts.ID
|
728 |
+
FROM $wpdb->posts
|
729 |
+
INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id
|
730 |
+
AND $wpdb->postmeta.meta_key = 'bp-media-key'
|
731 |
+
AND $wpdb->postmeta.meta_value = -$group
|
732 |
+
AND $wpdb->posts.post_title = 'Wall Posts'" );
|
733 |
+
}
|
734 |
+
if($post_id==null){
|
735 |
+
$album = new BP_Media_Album();
|
736 |
+
if($group == 0 )
|
737 |
+
$album->add_album('Wall Posts', get_current_user_id(), $group);
|
738 |
+
else{
|
739 |
+
$current_user = wp_get_current_user();
|
740 |
+
$album->add_album($current_user->display_name.'\'s Album', get_current_user_id(), $group);
|
741 |
+
}
|
742 |
+
$post_id = $album->get_id();
|
743 |
+
}
|
744 |
+
}
|
745 |
+
return $post_id;
|
746 |
+
}
|
747 |
+
} ?>
|
includes/bp-media-filters.php
CHANGED
@@ -120,7 +120,6 @@ add_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',1
|
|
120 |
*
|
121 |
* @global type $wp_admin_bar
|
122 |
*/
|
123 |
-
|
124 |
function bp_media_my_account_menu() {
|
125 |
global $wp_admin_bar;
|
126 |
|
@@ -189,7 +188,6 @@ add_action( 'admin_bar_menu', 'bp_media_my_account_menu', 1 );
|
|
189 |
*
|
190 |
* @global type $wp_admin_bar
|
191 |
*/
|
192 |
-
|
193 |
function bp_media_adminbar_settings_menu() {
|
194 |
global $wp_admin_bar;
|
195 |
|
120 |
*
|
121 |
* @global type $wp_admin_bar
|
122 |
*/
|
|
|
123 |
function bp_media_my_account_menu() {
|
124 |
global $wp_admin_bar;
|
125 |
|
188 |
*
|
189 |
* @global type $wp_admin_bar
|
190 |
*/
|
|
|
191 |
function bp_media_adminbar_settings_menu() {
|
192 |
global $wp_admin_bar;
|
193 |
|
includes/bp-media-functions.php
CHANGED
@@ -115,6 +115,7 @@ function bp_media_update_count() {
|
|
115 |
function bp_media_update_media(){
|
116 |
global $bp_media_current_entry;
|
117 |
if($bp_media_current_entry->update_media(array('description'=> esc_html($_POST['bp_media_description']),'name'=>esc_html($_POST['bp_media_title'])))){
|
|
|
118 |
@setcookie('bp-message', 'The media has been updated' , time() + 60 * 60 * 24, COOKIEPATH);
|
119 |
@setcookie('bp-message-type', 'success' , time() + 60 * 60 * 24, COOKIEPATH);
|
120 |
wp_redirect($bp_media_current_entry->get_url());
|
@@ -233,4 +234,32 @@ function bp_media_wp_comment_form_mod() {
|
|
233 |
global $bp_media_current_entry;
|
234 |
echo '<input type="hidden" name="redirect_to" value="'.$bp_media_current_entry->get_url().'">' ;
|
235 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
?>
|
115 |
function bp_media_update_media(){
|
116 |
global $bp_media_current_entry;
|
117 |
if($bp_media_current_entry->update_media(array('description'=> esc_html($_POST['bp_media_description']),'name'=>esc_html($_POST['bp_media_title'])))){
|
118 |
+
$bp_media_current_entry->update_media_activity();
|
119 |
@setcookie('bp-message', 'The media has been updated' , time() + 60 * 60 * 24, COOKIEPATH);
|
120 |
@setcookie('bp-message-type', 'success' , time() + 60 * 60 * 24, COOKIEPATH);
|
121 |
wp_redirect($bp_media_current_entry->get_url());
|
234 |
global $bp_media_current_entry;
|
235 |
echo '<input type="hidden" name="redirect_to" value="'.$bp_media_current_entry->get_url().'">' ;
|
236 |
}
|
237 |
+
|
238 |
+
function implement_featured_ajax() {
|
239 |
+
if(isset($_POST['post_id'])) {
|
240 |
+
if(isset($_POST['post_date']) && $_POST['remove_featured'] == 0){
|
241 |
+
update_post_meta($_POST['post_id'], 'featured', date('Y-m-d H:i:s', strtotime($_POST['post_date'])) );
|
242 |
+
} else {
|
243 |
+
update_post_meta($_POST['post_id'], 'featured', FALSE);
|
244 |
+
}
|
245 |
+
die(1);
|
246 |
+
}
|
247 |
+
}
|
248 |
+
add_action('wp_ajax_my_featured_action', 'implement_featured_ajax');
|
249 |
+
add_action('wp_ajax_nopriv_my_featured_action', 'implement_featured_ajax');
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Redirects the user to the location given in the parameter as well as set the message
|
253 |
+
* and context of redirect
|
254 |
+
*
|
255 |
+
* @param $location String The URL to redirect to
|
256 |
+
* @param $message String The message to show on the page where redirected
|
257 |
+
* @param $type String Type of message(updated, success, error, warning), works only if message is set
|
258 |
+
* @param $status String The HTTP status header for the redirection page.
|
259 |
+
*/
|
260 |
+
function bp_media_redirect($location,$message = '',$type='updated',$status='302'){
|
261 |
+
if($message!='')
|
262 |
+
bp_core_add_message( $message, 'error' );
|
263 |
+
bp_core_redirect($location, $status);
|
264 |
+
}
|
265 |
?>
|
includes/bp-media-groups-actions.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Called on bp_init by screen functions
|
5 |
+
*
|
6 |
+
* @uses global $bp, $bp_media_query
|
7 |
+
*
|
8 |
+
* @since BP Media 2.0
|
9 |
+
*/
|
10 |
+
function bp_media_groups_set_query() {
|
11 |
+
global $bp, $bp_media_query,$bp_media_posts_per_page;
|
12 |
+
if(isset($bp->current_action)&&$bp->current_action==BP_MEDIA_SLUG){
|
13 |
+
if(bp_action_variable(0)){
|
14 |
+
switch (bp_action_variable(0)) {
|
15 |
+
case BP_MEDIA_IMAGES_SLUG:
|
16 |
+
$type = 'image';
|
17 |
+
break;
|
18 |
+
case BP_MEDIA_AUDIO_SLUG:
|
19 |
+
$type = 'audio';
|
20 |
+
break;
|
21 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
22 |
+
$type = 'video';
|
23 |
+
break;
|
24 |
+
default :
|
25 |
+
$type = null;
|
26 |
+
}
|
27 |
+
if (bp_action_variable(1)=='page'&& is_numeric(bp_action_variable(2))) {
|
28 |
+
$paged = bp_action_variable(2);
|
29 |
+
} else {
|
30 |
+
$paged = 1;
|
31 |
+
}
|
32 |
+
if ($type) {
|
33 |
+
$args = array(
|
34 |
+
'post_type' => 'attachment',
|
35 |
+
'post_status' => 'any',
|
36 |
+
'post_mime_type' => $type,
|
37 |
+
'meta_key' => 'bp-media-key',
|
38 |
+
'meta_value' => -bp_get_current_group_id(),
|
39 |
+
'meta_compare' => '=',
|
40 |
+
'paged' => $paged,
|
41 |
+
'posts_per_page' => $bp_media_posts_per_page
|
42 |
+
);
|
43 |
+
$bp_media_query = new WP_Query($args);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Called on bp_init by screen functions
|
52 |
+
* Initializes the albums query for groups
|
53 |
+
*
|
54 |
+
* @uses global $bp, $bp_media_albums_query
|
55 |
+
*
|
56 |
+
* @since BP Media 2.2
|
57 |
+
*/
|
58 |
+
function bp_media_groups_albums_set_query() {
|
59 |
+
global $bp, $bp_media_albums_query;
|
60 |
+
if (isset($bp->action_variables) && isset($bp->action_variables[1]) && $bp->action_variables[1] == 'page' && isset($bp->action_variables[2]) && is_numeric($bp->action_variables[2])) {
|
61 |
+
$paged = $bp->action_variables[2];
|
62 |
+
} else {
|
63 |
+
$paged = 1;
|
64 |
+
}
|
65 |
+
|
66 |
+
if (isset($bp->action_variables[0])&&$bp->action_variables[0] == BP_MEDIA_ALBUMS_SLUG) {
|
67 |
+
$args = array(
|
68 |
+
'post_type' => 'bp_media_album',
|
69 |
+
'paged' => $paged,
|
70 |
+
'meta_key' => 'bp-media-key',
|
71 |
+
'meta_value' => -bp_get_current_group_id(),
|
72 |
+
'meta_compare' => '='
|
73 |
+
);
|
74 |
+
$bp_media_albums_query = new WP_Query($args);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
function bp_media_groups_activity_create_after_add_media($media,$hidden=false){
|
79 |
+
if(function_exists('bp_activity_add')){
|
80 |
+
if(!is_object($media)){
|
81 |
+
try{
|
82 |
+
$media = new BP_Media_Host_Wordpress($media);
|
83 |
+
}catch(exception $e){
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
$args = array(
|
88 |
+
'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $media->get_author() ), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>' ) ),
|
89 |
+
'content' => $media->get_media_activity_content(),
|
90 |
+
'primary_link' => $media->get_url(),
|
91 |
+
'item_id' => $media->get_id(),
|
92 |
+
'type' => 'media_upload',
|
93 |
+
'user_id' => $media->get_author()
|
94 |
+
);
|
95 |
+
$hidden = apply_filters('bp_media_force_hide_activity',$hidden);
|
96 |
+
if($hidden){
|
97 |
+
$args['secondary_item_id'] = -999;
|
98 |
+
//do_action('bp_media_album_updated',$media->get_album_id());
|
99 |
+
}
|
100 |
+
$activity_id = bp_media_record_activity($args);
|
101 |
+
add_post_meta($media->get_id(),'bp_media_child_activity',$activity_id);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
//add_action('bp_media_groups_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
|
105 |
+
|
106 |
+
function bp_media_groups_redirection_handler(){
|
107 |
+
global $bp;
|
108 |
+
echo '<pre>';
|
109 |
+
var_dump($bp);
|
110 |
+
echo '</pre>';
|
111 |
+
die();
|
112 |
+
}
|
113 |
+
//add_action('bp_media_init','bp_media_groups_redirection_handler');
|
114 |
+
|
115 |
+
function bp_media_groups_force_hide_activity(){
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
?>
|
includes/bp-media-groups-loader.php
ADDED
@@ -0,0 +1,333 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
global $bp_media_group_sub_nav;
|
4 |
+
$bp_media_group_sub_nav = array();
|
5 |
+
class BP_Media_Groups_Extension extends BP_Group_Extension {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Constructor for the BP_Group_Extension adding values to the variables defined
|
9 |
+
*
|
10 |
+
* @uses global $bp
|
11 |
+
*
|
12 |
+
* @since BP Media 2.3
|
13 |
+
*/
|
14 |
+
function __construct() {
|
15 |
+
global $bp;
|
16 |
+
$this->name = BP_MEDIA_LABEL;
|
17 |
+
$this->slug = BP_MEDIA_SLUG;
|
18 |
+
$this->create_step_position = 21;
|
19 |
+
$this->nav_item_position = 31;
|
20 |
+
}
|
21 |
+
|
22 |
+
function create_screen() {
|
23 |
+
if ( !bp_is_group_creation_step( $this->slug ) )
|
24 |
+
return false;
|
25 |
+
?>
|
26 |
+
<h4>Album Creation Control</h4>
|
27 |
+
<p>Who can create Albums in this group?</p>
|
28 |
+
<div class="radio">
|
29 |
+
<label>
|
30 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" checked="checked" value="all">
|
31 |
+
<strong>All Group Members</strong>
|
32 |
+
</label>
|
33 |
+
<label>
|
34 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators">
|
35 |
+
<strong>Group Admins and Mods only</strong>
|
36 |
+
</label>
|
37 |
+
<label>
|
38 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin">
|
39 |
+
<strong>Group Admin only</strong>
|
40 |
+
</label>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<?php
|
44 |
+
wp_nonce_field( 'groups_create_save_' . $this->slug );
|
45 |
+
}
|
46 |
+
|
47 |
+
function create_screen_save() {
|
48 |
+
global $bp;
|
49 |
+
|
50 |
+
check_admin_referer( 'groups_create_save_' . $this->slug );
|
51 |
+
|
52 |
+
/* Save any details submitted here */
|
53 |
+
if(isset($_POST['bp_album_creation_control'])&&$_POST['bp_album_creation_control']!='')
|
54 |
+
groups_update_groupmeta( $bp->groups->new_group_id, 'bp_media_group_control_level', $_POST['bp_album_creation_control'] );
|
55 |
+
}
|
56 |
+
|
57 |
+
function edit_screen() {
|
58 |
+
if ( !bp_is_group_admin_screen( $this->slug ) )
|
59 |
+
return false;
|
60 |
+
$current_level = groups_get_groupmeta(bp_get_current_group_id(),'bp_media_group_control_level');
|
61 |
+
?>
|
62 |
+
|
63 |
+
<h4>Album Creation Control</h4>
|
64 |
+
<p>Who can create Albums in this group?</p>
|
65 |
+
<div class="radio">
|
66 |
+
<label>
|
67 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="all"<?php checked($current_level, 'all', true) ?>>
|
68 |
+
<strong>All Group Members</strong>
|
69 |
+
</label>
|
70 |
+
<label>
|
71 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_moderators" value="moderators" <?php checked($current_level, 'moderators', true) ?>>
|
72 |
+
<strong>Group Admins and Mods only</strong>
|
73 |
+
</label>
|
74 |
+
<label>
|
75 |
+
<input name="bp_album_creation_control" type="radio" id="bp_media_group_level_admin" value="admin" <?php checked($current_level, 'admin', true) ?>>
|
76 |
+
<strong>Group Admin only</strong>
|
77 |
+
</label>
|
78 |
+
</div>
|
79 |
+
<hr>
|
80 |
+
<input type="submit" name="save" value="Save Changes" />
|
81 |
+
<?php
|
82 |
+
wp_nonce_field( 'groups_edit_save_' . $this->slug );
|
83 |
+
}
|
84 |
+
|
85 |
+
function edit_screen_save() {
|
86 |
+
global $bp;
|
87 |
+
|
88 |
+
if ( !isset( $_POST['save'] ) )
|
89 |
+
return false;
|
90 |
+
|
91 |
+
check_admin_referer( 'groups_edit_save_' . $this->slug );
|
92 |
+
|
93 |
+
if(isset($_POST['bp_album_creation_control'])&&$_POST['bp_album_creation_control']!='')
|
94 |
+
$success = groups_update_groupmeta(bp_get_current_group_id(), 'bp_media_group_control_level', $_POST['bp_album_creation_control'] );
|
95 |
+
else
|
96 |
+
$success = false;
|
97 |
+
|
98 |
+
/* To post an error/success message to the screen, use the following */
|
99 |
+
if ( !$success )
|
100 |
+
bp_core_add_message( __( 'There was an error saving, please try again', 'buddypress' ), 'error' );
|
101 |
+
else
|
102 |
+
bp_core_add_message( __( 'Settings saved successfully', 'buddypress' ) );
|
103 |
+
|
104 |
+
bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/' . $this->slug );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* The display method for the extension
|
109 |
+
*
|
110 |
+
* @since BP Media 2.3
|
111 |
+
*/
|
112 |
+
function display() {
|
113 |
+
bp_media_groups_display_screen();
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
function widget_display() { ?>
|
118 |
+
<div class="info-group">
|
119 |
+
<h4><?php echo esc_attr( $this->name ) ?></h4>
|
120 |
+
<p>
|
121 |
+
You could display a small snippet of information from your group extension here. It will show on the group
|
122 |
+
home screen.
|
123 |
+
</p>
|
124 |
+
</div>
|
125 |
+
<?php
|
126 |
+
}
|
127 |
+
}
|
128 |
+
bp_register_group_extension( 'BP_Media_Groups_Extension' );
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Handles the custom navigation structure of the BuddyPress Group Extension Media
|
132 |
+
*
|
133 |
+
* @uses global $bp
|
134 |
+
*
|
135 |
+
* @since BP Media 2.3
|
136 |
+
*/
|
137 |
+
function bp_media_groups_custom_nav(){
|
138 |
+
global $bp;
|
139 |
+
$current_group = isset($bp->groups->current_group->slug)?$bp->groups->current_group->slug:null;
|
140 |
+
if(!$current_group)
|
141 |
+
return;
|
142 |
+
if(!(isset($bp->bp_options_nav[$current_group])&& is_array($bp->bp_options_nav[$current_group])))
|
143 |
+
return;
|
144 |
+
|
145 |
+
/** This line might break a thing or two in custom themes and widgets */
|
146 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
147 |
+
|
148 |
+
foreach ($bp->bp_options_nav[$current_group] as $key => $nav_item) {
|
149 |
+
switch($nav_item['slug']){
|
150 |
+
case BP_MEDIA_IMAGES_SLUG:
|
151 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
152 |
+
case BP_MEDIA_AUDIO_SLUG:
|
153 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
154 |
+
unset($bp->bp_options_nav[$current_group][$key]);
|
155 |
+
|
156 |
+
}
|
157 |
+
switch($bp->current_action){
|
158 |
+
case BP_MEDIA_IMAGES_SLUG:
|
159 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
160 |
+
case BP_MEDIA_AUDIO_SLUG:
|
161 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
162 |
+
$count = count($bp->action_variables);
|
163 |
+
for ($i = $count; $i > 0; $i--) {
|
164 |
+
$bp->action_variables[$i] = $bp->action_variables[$i - 1];
|
165 |
+
}
|
166 |
+
$bp->action_variables[0] = $bp->current_action;
|
167 |
+
$bp->current_action = BP_MEDIA_SLUG;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
add_action('bp_actions','bp_media_groups_custom_nav',999);
|
172 |
+
|
173 |
+
/**
|
174 |
+
* This loop creates dummy classes for images, videos, audio and albums so that the url structuring
|
175 |
+
* can be uniform as it is in the members section.
|
176 |
+
*/
|
177 |
+
foreach(array('IMAGES','VIDEOS','AUDIO','ALBUMS') as $item){
|
178 |
+
eval('
|
179 |
+
class BP_Media_Group_Extension_'.constant('BP_MEDIA_'.$item.'_SLUG').' extends BP_Group_Extension{
|
180 |
+
var $enable_edit_item = false;
|
181 |
+
var $enable_create_step = false;
|
182 |
+
function __construct(){
|
183 |
+
$this->name = BP_MEDIA_'.$item.'_LABEL;
|
184 |
+
$this->slug = BP_MEDIA_'.$item.'_SLUG;
|
185 |
+
$enable_create_step = false;
|
186 |
+
$enable_edit_item = false;
|
187 |
+
}
|
188 |
+
function display(){bp_media_groups_display_screen();}
|
189 |
+
function widget_display(){}
|
190 |
+
}
|
191 |
+
bp_register_group_extension("BP_Media_Group_Extension_'.constant('BP_MEDIA_'.$item.'_SLUG').'" );
|
192 |
+
');
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Adds the current group id as parameter for plupload
|
197 |
+
*
|
198 |
+
* @param Array $multipart_params Array of Multipart Parameters to be passed on to plupload script
|
199 |
+
*
|
200 |
+
* @since BP Media 2.3
|
201 |
+
*/
|
202 |
+
function bp_media_groups_multipart_params_handler($multipart_params){
|
203 |
+
if(is_array($multipart_params)){
|
204 |
+
global $bp;
|
205 |
+
if(isset($bp->current_action)&&$bp->current_action==BP_MEDIA_SLUG
|
206 |
+
&&isset($bp->action_variables)&&empty($bp->action_variables)
|
207 |
+
&&isset($bp->current_component)&&$bp->current_component=='groups'
|
208 |
+
&&isset($bp->groups->current_group->id)){
|
209 |
+
$multipart_params['bp_media_group_id']=$bp->groups->current_group->id;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return $multipart_params;
|
213 |
+
}
|
214 |
+
add_filter('bp_media_multipart_params_filter','bp_media_groups_multipart_params_handler');
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Displays the navigation available to the group media tab for the
|
218 |
+
* logged in user.
|
219 |
+
*
|
220 |
+
* @uses $bp Global Variable set by BuddyPress
|
221 |
+
*
|
222 |
+
* @since BP Media 2.3
|
223 |
+
*/
|
224 |
+
function bp_media_groups_display_navigation_menu(){
|
225 |
+
global $bp;
|
226 |
+
|
227 |
+
if(!isset($bp->current_action)||$bp->current_action!=BP_MEDIA_SLUG)
|
228 |
+
return false;
|
229 |
+
$current_tab = bp_media_groups_can_upload()?BP_MEDIA_UPLOAD_SLUG:BP_MEDIA_IMAGES_SLUG;
|
230 |
+
if(isset($bp->action_variables[0])){
|
231 |
+
$current_tab = $bp->action_variables[0];
|
232 |
+
}
|
233 |
+
|
234 |
+
if(bp_media_groups_can_upload()){
|
235 |
+
$bp_media_nav[BP_MEDIA_UPLOAD_SLUG] = array(
|
236 |
+
'url' => trailingslashit(bp_get_group_permalink( $bp->groups->current_group )).BP_MEDIA_SLUG,
|
237 |
+
'label' => BP_MEDIA_UPLOAD_LABEL,
|
238 |
+
);
|
239 |
+
}
|
240 |
+
else{
|
241 |
+
$bp_media_nav = array();
|
242 |
+
}
|
243 |
+
|
244 |
+
foreach(array('IMAGES','VIDEOS','AUDIO','ALBUMS') as $type){
|
245 |
+
$bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array(
|
246 |
+
'url' => trailingslashit(bp_get_group_permalink( $bp->groups->current_group )).constant('BP_MEDIA_' . $type . '_SLUG'),
|
247 |
+
'label' => constant('BP_MEDIA_' . $type . '_LABEL'),
|
248 |
+
);
|
249 |
+
}
|
250 |
+
|
251 |
+
/** This variable will be used to display the tabs in group component */
|
252 |
+
$bp_media_group_tabs = apply_filters('bp_media_group_tabs', $bp_media_nav,$current_tab);
|
253 |
+
?>
|
254 |
+
<div class="item-list-tabs no-ajax bp-media-group-navigation" id="subnav">
|
255 |
+
<ul>
|
256 |
+
<?php
|
257 |
+
foreach($bp_media_group_tabs as $tab_slug=>$tab_info){
|
258 |
+
echo '<li id="'.$tab_slug.'-group-li" '.($current_tab==$tab_slug?'class="current selected"':'').'><a id="'.$tab_slug.'" href="'.$tab_info['url'].'" title="'.$tab_info['label'].'">'.$tab_info['label'].'</a></li>';
|
259 |
+
}
|
260 |
+
?>
|
261 |
+
</ul>
|
262 |
+
</div>
|
263 |
+
<?php
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Checks whether the current logged in user has the ability to upload on
|
268 |
+
* the given group or not
|
269 |
+
*
|
270 |
+
* @since BP Media 2.3
|
271 |
+
*/
|
272 |
+
function bp_media_groups_can_upload(){
|
273 |
+
/** @todo Implementation Pending */
|
274 |
+
global $bp;
|
275 |
+
if(isset($bp->loggedin_user->id)&&is_numeric($bp->loggedin_user->id)){
|
276 |
+
return groups_is_user_member($bp->loggedin_user->id, bp_get_current_group_id());
|
277 |
+
}
|
278 |
+
else{
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
|
282 |
+
return true;
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Adds the Media Settings menu for groups in the admin bar
|
287 |
+
*
|
288 |
+
* @uses global $bp,$wp_admin_bar
|
289 |
+
*
|
290 |
+
* @since BP Media 2.3
|
291 |
+
*/
|
292 |
+
function bp_media_groups_adminbar(){
|
293 |
+
global $wp_admin_bar, $bp;
|
294 |
+
$wp_admin_bar->add_menu( array(
|
295 |
+
'parent' => $bp->group_admin_menu_id,
|
296 |
+
'id' => 'bp-media-group',
|
297 |
+
'title' => __( 'Media Settings', 'buddypress' ),
|
298 |
+
'href' => bp_get_groups_action_link( 'admin/media' )
|
299 |
+
) );
|
300 |
+
}
|
301 |
+
//add_action('admin_bar_menu','bp_media_groups_adminbar',99);
|
302 |
+
/* This will need some handling for checking if its a single group page or not, also whether the person can
|
303 |
+
* edit media settings or not
|
304 |
+
*/
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Checks whether a user can create an album in the given group or not
|
308 |
+
*
|
309 |
+
* @param string $group_id The group id to check against
|
310 |
+
* @param string $user_id The user to be checked for permission
|
311 |
+
*
|
312 |
+
* @return boolean True if the user can create an album in the group, false if not
|
313 |
+
*/
|
314 |
+
function bp_media_groups_user_can_create_album($group_id, $user_id = 0){
|
315 |
+
if($user_id == 0)
|
316 |
+
$user_id = get_current_user_id ();
|
317 |
+
$current_level = groups_get_groupmeta($group_id,'bp_media_group_control_level');
|
318 |
+
switch($current_level){
|
319 |
+
case 'all':
|
320 |
+
return groups_is_user_member($user_id, $group_id);
|
321 |
+
break;
|
322 |
+
case 'moderators':
|
323 |
+
return groups_is_user_mod($user_id, $group_id);
|
324 |
+
break;
|
325 |
+
case 'admin':
|
326 |
+
return groups_is_user_admin($user_id, $group_id);
|
327 |
+
break;
|
328 |
+
default :
|
329 |
+
return false;
|
330 |
+
}
|
331 |
+
return false;
|
332 |
+
}
|
333 |
+
?>
|
includes/bp-media-groups-screens.php
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Displays the Video, Audio, Image, Album and Upload screens
|
5 |
+
*
|
6 |
+
* @uses global $bp_media_group_sub_nav, $bp
|
7 |
+
*
|
8 |
+
* @since BP Media 2.3
|
9 |
+
*/
|
10 |
+
function bp_media_groups_display_screen(){
|
11 |
+
global $bp_media_group_sub_nav,$bp;
|
12 |
+
bp_media_groups_set_query();
|
13 |
+
bp_media_groups_display_navigation_menu();
|
14 |
+
if(bp_action_variable(0)){
|
15 |
+
switch(bp_action_variable(0)){
|
16 |
+
case BP_MEDIA_IMAGES_SLUG:
|
17 |
+
bp_media_groups_images_screen();
|
18 |
+
break;
|
19 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
20 |
+
if(isset($bp->action_variables[1])){
|
21 |
+
switch($bp->action_variables[1]){
|
22 |
+
case BP_MEDIA_VIDEOS_EDIT_SLUG:
|
23 |
+
//Edit screen for image
|
24 |
+
break;
|
25 |
+
case BP_MEDIA_DELETE_SLUG:
|
26 |
+
//Delete function for media file
|
27 |
+
break;
|
28 |
+
default:
|
29 |
+
if(intval(bp_action_variable(1))>0){
|
30 |
+
global $bp_media_current_entry;
|
31 |
+
try {
|
32 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
|
33 |
+
if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
|
34 |
+
throw new Exception(__('Sorry, the requested media does not belong to the group'));
|
35 |
+
} catch (Exception $e) {
|
36 |
+
/** Error Handling when media not present or not belong to the group */
|
37 |
+
echo '<div id="message" class="error">';
|
38 |
+
echo '<p>'.$e->getMessage().'</p>';
|
39 |
+
echo '</div>';
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
bp_media_videos_entry_screen_content();
|
43 |
+
break;
|
44 |
+
}
|
45 |
+
else{
|
46 |
+
/** @todo display 404 */
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}else{
|
50 |
+
bp_media_videos_screen_content();
|
51 |
+
}
|
52 |
+
break;
|
53 |
+
case BP_MEDIA_AUDIO_SLUG:
|
54 |
+
if(isset($bp->action_variables[1])){
|
55 |
+
switch($bp->action_variables[1]){
|
56 |
+
case BP_MEDIA_AUDIO_EDIT_SLUG:
|
57 |
+
//Edit screen for image
|
58 |
+
break;
|
59 |
+
case BP_MEDIA_DELETE_SLUG:
|
60 |
+
//Delete function for media file
|
61 |
+
break;
|
62 |
+
default:
|
63 |
+
if(intval(bp_action_variable(1))>0){
|
64 |
+
global $bp_media_current_entry;
|
65 |
+
try {
|
66 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
|
67 |
+
if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
|
68 |
+
throw new Exception(__('Sorry, the requested media does not belong to the group'));
|
69 |
+
} catch (Exception $e) {
|
70 |
+
/** Error Handling when media not present or not belong to the group */
|
71 |
+
echo '<div id="message" class="error">';
|
72 |
+
echo '<p>'.$e->getMessage().'</p>';
|
73 |
+
echo '</div>';
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
bp_media_audio_entry_screen_content();
|
77 |
+
break;
|
78 |
+
}
|
79 |
+
else{
|
80 |
+
/** @todo display 404 */
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}else{
|
84 |
+
bp_media_audio_screen_content();
|
85 |
+
}
|
86 |
+
break;
|
87 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
88 |
+
if(isset($bp->action_variables[1])){
|
89 |
+
switch($bp->action_variables[1]){
|
90 |
+
case BP_MEDIA_ALBUMS_EDIT_SLUG:
|
91 |
+
//Edit screen for image
|
92 |
+
break;
|
93 |
+
case BP_MEDIA_DELETE_SLUG:
|
94 |
+
//Delete function for media file
|
95 |
+
break;
|
96 |
+
default:
|
97 |
+
if(intval(bp_action_variable(1))>0){
|
98 |
+
global $bp_media_current_album;
|
99 |
+
try {
|
100 |
+
$bp_media_current_album = new BP_Media_Host_Wordpress(bp_action_variable(1));
|
101 |
+
if($bp_media_current_album->get_group_id()!= bp_get_current_group_id())
|
102 |
+
throw new Exception(__('Sorry, the requested album does not belong to the group'));
|
103 |
+
} catch (Exception $e) {
|
104 |
+
/** Error Handling when media not present or not belong to the group */
|
105 |
+
echo '<div id="message" class="error">';
|
106 |
+
echo '<p>'.$e->getMessage().'</p>';
|
107 |
+
echo '</div>';
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
bp_media_albums_entry_screen_content();
|
111 |
+
break;
|
112 |
+
}
|
113 |
+
else{
|
114 |
+
/** @todo display 404 */
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}else{
|
118 |
+
bp_media_groups_albums_set_query();
|
119 |
+
bp_media_albums_screen_content();
|
120 |
+
}
|
121 |
+
break;
|
122 |
+
default:
|
123 |
+
/** @todo Error is to be displayed for 404 */
|
124 |
+
}
|
125 |
+
}
|
126 |
+
else{
|
127 |
+
if(bp_media_groups_can_upload())
|
128 |
+
bp_media_upload_screen_content();
|
129 |
+
else{
|
130 |
+
$bp->action_variables[0] = BP_MEDIA_IMAGES_SLUG;
|
131 |
+
bp_media_groups_set_query();
|
132 |
+
bp_media_groups_images_screen();
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
function bp_media_groups_images_screen(){
|
138 |
+
global $bp_media_current_entry;
|
139 |
+
if(bp_action_variable(1)){
|
140 |
+
switch(bp_action_variable(1)){
|
141 |
+
case BP_MEDIA_IMAGES_EDIT_SLUG:
|
142 |
+
//Edit screen for image
|
143 |
+
break;
|
144 |
+
case BP_MEDIA_DELETE_SLUG:
|
145 |
+
//Delete function for media file
|
146 |
+
break;
|
147 |
+
default:
|
148 |
+
if(intval(bp_action_variable(1))>0){
|
149 |
+
global $bp_media_current_entry;
|
150 |
+
try {
|
151 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress(bp_action_variable(1));
|
152 |
+
if($bp_media_current_entry->get_group_id()!= bp_get_current_group_id())
|
153 |
+
throw new Exception(__('Sorry, the requested media does not belong to the group'));
|
154 |
+
} catch (Exception $e) {
|
155 |
+
/** Error Handling when media not present or not belong to the group */
|
156 |
+
echo '<div id="message" class="error">';
|
157 |
+
echo '<p>'.$e->getMessage().'</p>';
|
158 |
+
echo '</div>';
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
bp_media_images_entry_screen_content();
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
else{
|
165 |
+
/** @todo display 404 */
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}else{
|
169 |
+
bp_media_images_screen_content();
|
170 |
+
}
|
171 |
+
}
|
172 |
+
?>
|
includes/bp-media-loader.php
CHANGED
@@ -163,6 +163,9 @@ class BP_Media_Component extends BP_Component {
|
|
163 |
'includes/bp-media-shortcodes.php',
|
164 |
'includes/bp-media-widgets.php',
|
165 |
'includes/bp-media-class-album.php',
|
|
|
|
|
|
|
166 |
);
|
167 |
if (is_admin() || is_network_admin()) {
|
168 |
$includes[] = 'includes/bp-media-admin.php';
|
163 |
'includes/bp-media-shortcodes.php',
|
164 |
'includes/bp-media-widgets.php',
|
165 |
'includes/bp-media-class-album.php',
|
166 |
+
'includes/bp-media-groups-loader.php',
|
167 |
+
'includes/bp-media-groups-actions.php',
|
168 |
+
'includes/bp-media-groups-screens.php'
|
169 |
);
|
170 |
if (is_admin() || is_network_admin()) {
|
171 |
$includes[] = 'includes/bp-media-admin.php';
|
includes/bp-media-screens.php
CHANGED
@@ -447,6 +447,10 @@ function bp_media_audio_entry_screen() {
|
|
447 |
|
448 |
function bp_media_audio_entry_screen_content() {
|
449 |
global $bp, $bp_media_current_entry, $bp_media_options;
|
|
|
|
|
|
|
|
|
450 |
if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
|
451 |
return false;
|
452 |
do_action('bp_media_before_content');
|
447 |
|
448 |
function bp_media_audio_entry_screen_content() {
|
449 |
global $bp, $bp_media_current_entry, $bp_media_options;
|
450 |
+
if($bp_media_current_entry==null){
|
451 |
+
echo 'Entry not found';
|
452 |
+
}
|
453 |
+
|
454 |
if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
|
455 |
return false;
|
456 |
do_action('bp_media_before_content');
|
includes/bp-media-template-functions.php
CHANGED
@@ -36,11 +36,22 @@ function bp_media_show_upload_form_multiple() {
|
|
36 |
global $bp,$bp_media_default_excerpts;
|
37 |
?>
|
38 |
<div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
if(isset($albums->posts)&& is_array($albums->posts)&& count($albums->posts)>0){
|
45 |
foreach ($albums->posts as $album){
|
46 |
if($album->post_title == 'Wall Posts')
|
@@ -50,21 +61,27 @@ function bp_media_show_upload_form_multiple() {
|
|
50 |
};
|
51 |
}else{
|
52 |
$album = new BP_Media_Album();
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
echo '<option value="'.$album->get_id().'" selected="selected">'.$album->get_title().'</option>' ;
|
55 |
}
|
56 |
?></select></div>
|
57 |
-
<div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
|
58 |
-
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
</div>
|
65 |
</div>
|
66 |
-
|
67 |
-
<div id="bp-media-uploaded-files"></div>
|
68 |
<?php
|
69 |
}
|
70 |
|
@@ -92,8 +109,6 @@ function bp_media_show_pagination($type = 'top' , $inner = false) {
|
|
92 |
$current_single = BP_MEDIA_LABEL_SINGULAR;
|
93 |
}
|
94 |
|
95 |
-
|
96 |
-
|
97 |
if($bp->current_action == BP_MEDIA_ALBUMS_SLUG && !$inner){
|
98 |
$args = array(
|
99 |
'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
|
@@ -166,13 +181,13 @@ function bp_media_get_permalink($id = 0) {
|
|
166 |
return false;
|
167 |
switch (get_post_meta($media->ID, 'bp_media_type', true)) {
|
168 |
case 'video' :
|
169 |
-
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/
|
170 |
break;
|
171 |
case 'audio' :
|
172 |
-
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/
|
173 |
break;
|
174 |
case 'image' :
|
175 |
-
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/
|
176 |
break;
|
177 |
default :
|
178 |
return false;
|
36 |
global $bp,$bp_media_default_excerpts;
|
37 |
?>
|
38 |
<div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
|
39 |
+
if(bp_is_current_component('groups')){
|
40 |
+
$albums = new WP_Query(array(
|
41 |
+
'post_type' => 'bp_media_album',
|
42 |
+
'posts_per_page'=> -1,
|
43 |
+
'meta_key' => 'bp-media-key',
|
44 |
+
'meta_value' => -bp_get_current_group_id(),
|
45 |
+
'meta_compare' => '='
|
46 |
+
));
|
47 |
+
}
|
48 |
+
else{
|
49 |
+
$albums = new WP_Query(array(
|
50 |
+
'post_type' => 'bp_media_album',
|
51 |
+
'posts_per_page'=> -1,
|
52 |
+
'author'=> get_current_user_id()
|
53 |
+
));
|
54 |
+
}
|
55 |
if(isset($albums->posts)&& is_array($albums->posts)&& count($albums->posts)>0){
|
56 |
foreach ($albums->posts as $album){
|
57 |
if($album->post_title == 'Wall Posts')
|
61 |
};
|
62 |
}else{
|
63 |
$album = new BP_Media_Album();
|
64 |
+
if(bp_is_current_component('groups')){
|
65 |
+
$current_group = new BP_Groups_Group(bp_get_current_group_id());
|
66 |
+
$album->add_album('Wall Posts',$current_group->creator_id , bp_get_current_group_id());
|
67 |
+
}
|
68 |
+
else{
|
69 |
+
$album->add_album('Wall Posts', bp_loggedin_user_id());
|
70 |
+
}
|
71 |
echo '<option value="'.$album->get_id().'" selected="selected">'.$album->get_title().'</option>' ;
|
72 |
}
|
73 |
?></select></div>
|
74 |
+
<div id="bp-media-album-new" title="Create New Album"><label for="bp_media_album_name">Album Name</label><input id="bp_media_album_name" type="text" name="bp_media_album_name" /></div>
|
75 |
+
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
|
76 |
+
<div id="drag-drop-area">
|
77 |
+
<div class="drag-drop-inside">
|
78 |
+
<p class="drag-drop-info">Drop files here</p>
|
79 |
+
<p>or</p>
|
80 |
+
<p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Select Files" class="button" /></p>
|
81 |
+
</div>
|
82 |
</div>
|
83 |
</div>
|
84 |
+
<div id="bp-media-uploaded-files"></div>
|
|
|
85 |
<?php
|
86 |
}
|
87 |
|
109 |
$current_single = BP_MEDIA_LABEL_SINGULAR;
|
110 |
}
|
111 |
|
|
|
|
|
112 |
if($bp->current_action == BP_MEDIA_ALBUMS_SLUG && !$inner){
|
113 |
$args = array(
|
114 |
'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
|
181 |
return false;
|
182 |
switch (get_post_meta($media->ID, 'bp_media_type', true)) {
|
183 |
case 'video' :
|
184 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $media->ID);
|
185 |
break;
|
186 |
case 'audio' :
|
187 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $media->ID);
|
188 |
break;
|
189 |
case 'image' :
|
190 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $media->ID);
|
191 |
break;
|
192 |
default :
|
193 |
return false;
|
includes/bp-media-widgets.php
CHANGED
@@ -14,159 +14,159 @@ class BP_Media_Recent_Media extends WP_Widget {
|
|
14 |
|
15 |
function widget($args, $instance) {
|
16 |
extract( $args );
|
17 |
-
|
18 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
|
19 |
-
|
20 |
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
21 |
$number = 10;
|
22 |
-
|
23 |
echo $before_widget;
|
24 |
echo $before_title . $title . $after_title;
|
25 |
?>
|
26 |
<div id="recent-media-tabs" class="media-tabs-container">
|
27 |
<ul>
|
28 |
<li><a href="#recent-media-tabs-all"><?php _e('All','bp-media'); ?></a></li>
|
29 |
-
<li><a href="#recent-media-tabs-photos"><?php _e('Photos','bp-media'); ?></a></li>
|
30 |
<li><a href="#recent-media-tabs-music"><?php _e('Music','bp-media'); ?></a></li>
|
31 |
<li><a href="#recent-media-tabs-videos"><?php _e('Videos','bp-media'); ?></a></li>
|
32 |
</ul>
|
33 |
-
<div id="recent-media-tabs-all" class="bp-media-tab-panel">
|
34 |
-
<?php
|
35 |
// All Media
|
36 |
-
$args = array( 'post_type' => 'attachment',
|
37 |
-
'post_status' => 'any',
|
38 |
'posts_per_page' => $number,
|
39 |
-
'meta_key' => 'bp-media-key',
|
40 |
'meta_value' => 0,
|
41 |
-
'meta_compare' => '>' );
|
42 |
-
|
43 |
-
$bp_media_widget_query = new WP_Query($args);
|
44 |
-
|
45 |
if($bp_media_widget_query->have_posts()){ ?>
|
46 |
-
|
47 |
-
<ul class="widget-item-listing"><?php
|
48 |
-
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
49 |
-
|
50 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
51 |
|
52 |
-
<?php echo $entry -> get_media_gallery_content();?><?php
|
53 |
-
|
54 |
} ?>
|
55 |
-
|
56 |
-
</ul><!-- .widget-item-listing --><?php
|
57 |
-
|
58 |
-
}else
|
59 |
_e('No rescent media found', 'bp-media');
|
60 |
-
|
61 |
wp_reset_query(); ?>
|
62 |
-
|
63 |
</div><!-- #recent-media-tabs-all -->
|
64 |
-
|
65 |
<div id="recent-media-tabs-photos" class="bp-media-tab-panel">
|
66 |
-
<?php
|
67 |
// Rescent photos
|
68 |
-
$args = array( 'post_type' => 'attachment',
|
69 |
'post_status' => 'any',
|
70 |
'post_mime_type' => 'image',
|
71 |
'posts_per_page' => $number,
|
72 |
-
'meta_key' => 'bp-media-key',
|
73 |
'meta_value' => 0,
|
74 |
'meta_compare' => '>' );
|
75 |
|
76 |
-
|
77 |
$bp_media_widget_query = new WP_Query($args);
|
78 |
-
|
79 |
if($bp_media_widget_query->have_posts()){ ?>
|
80 |
-
|
81 |
-
<ul class="widget-item-listing"><?php
|
82 |
-
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
83 |
-
|
84 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
85 |
|
86 |
-
<?php echo $entry -> get_media_gallery_content();?><?php
|
87 |
-
|
88 |
} ?>
|
89 |
-
|
90 |
-
</ul><!-- .widget-item-listing --><?php
|
91 |
-
|
92 |
-
}else
|
93 |
_e('No rescent photo found', 'bp-media');
|
94 |
-
|
95 |
wp_reset_query(); ?>
|
96 |
-
|
97 |
-
</div><!-- #media-tabs-photos -->
|
98 |
-
|
99 |
<div id="recent-media-tabs-music" class="bp-media-tab-panel">
|
100 |
-
<?php
|
101 |
// Rescent Audio
|
102 |
-
$args = array( 'post_type' => 'attachment',
|
103 |
'post_status' => 'any',
|
104 |
'post_mime_type' => 'audio',
|
105 |
'posts_per_page' => $number,
|
106 |
-
'meta_key' => 'bp-media-key',
|
107 |
'meta_value' => 0,
|
108 |
'meta_compare' => '>' );
|
109 |
-
|
110 |
$bp_media_widget_query = new WP_Query($args);
|
111 |
-
|
112 |
if($bp_media_widget_query->have_posts()){ ?>
|
113 |
-
|
114 |
-
<ul class="widget-item-listing"><?php
|
115 |
-
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
116 |
-
|
117 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
118 |
|
119 |
-
<?php echo $entry -> get_media_gallery_content();?><?php
|
120 |
-
|
121 |
} ?>
|
122 |
-
|
123 |
-
</ul><!-- .widget-item-listing --><?php
|
124 |
-
|
125 |
-
}else
|
126 |
_e('No rescent audio found', 'bp-media');
|
127 |
-
|
128 |
wp_reset_query(); ?>
|
129 |
-
|
130 |
</div><!-- #recent-media-tabs-music -->
|
131 |
-
|
132 |
<div id="recent-media-tabs-videos" class="bp-media-tab-panel">
|
133 |
-
<?php
|
134 |
// Rescent Video
|
135 |
-
$args = array( 'post_type' => 'attachment',
|
136 |
'post_status' => 'any',
|
137 |
'post_mime_type' => 'video',
|
138 |
'posts_per_page' => $number,
|
139 |
-
'meta_key' => 'bp-media-key',
|
140 |
'meta_value' => 0,
|
141 |
'meta_compare' => '>' );
|
142 |
-
|
143 |
$bp_media_widget_query = new WP_Query($args);
|
144 |
-
|
145 |
if($bp_media_widget_query->have_posts()){ ?>
|
146 |
-
|
147 |
-
<ul class="widget-item-listing"><?php
|
148 |
-
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
149 |
-
|
150 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
151 |
|
152 |
-
<?php echo $entry -> get_media_gallery_content();?><?php
|
153 |
-
|
154 |
} ?>
|
155 |
-
|
156 |
-
</ul><!-- .widget-item-listing --><?php
|
157 |
-
|
158 |
-
}else
|
159 |
_e('No rescent video found', 'bp-media');
|
160 |
-
|
161 |
wp_reset_query(); ?>
|
162 |
-
|
163 |
</div><!-- #media-tabs-videos -->
|
164 |
-
|
165 |
</div>
|
166 |
<?php
|
167 |
-
echo $after_widget;
|
168 |
-
|
169 |
-
|
170 |
}
|
171 |
|
172 |
function update( $new_instance, $old_instance ) {
|
@@ -175,7 +175,7 @@ class BP_Media_Recent_Media extends WP_Widget {
|
|
175 |
$instance['number'] = (int) $new_instance['number'];
|
176 |
return $instance;
|
177 |
}
|
178 |
-
|
179 |
function form( $instance ) {
|
180 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
181 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
@@ -186,9 +186,9 @@ class BP_Media_Recent_Media extends WP_Widget {
|
|
186 |
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
|
187 |
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
188 |
<?php
|
189 |
-
|
190 |
}
|
191 |
-
|
192 |
}
|
193 |
|
194 |
|
@@ -209,54 +209,54 @@ class BP_Media_Popular_Media extends WP_Widget {
|
|
209 |
|
210 |
function widget($args, $instance) {
|
211 |
extract( $args );
|
212 |
-
|
213 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
|
214 |
-
|
215 |
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
216 |
$number = 10;
|
217 |
-
|
218 |
echo $before_widget;
|
219 |
echo $before_title . $title . $after_title;
|
220 |
?>
|
221 |
<div id="popular-media-tabs" class="media-tabs-container">
|
222 |
<!-- <ul>
|
223 |
<li><a href="#popular-media-tabs-comments"><?php _e('comments', 'bp-media'); ?></a></li>
|
224 |
-
<li><a href="#popular-media-tabs-views"><?php _e('Views', 'bp-media'); ?></a></li>
|
225 |
</ul>-->
|
226 |
-
<div id="popular-media-tabs-comments" class="bp-media-tab-panel">
|
227 |
-
<?php
|
228 |
-
$args = array( 'post_type' => 'attachment',
|
229 |
-
'post_status' => 'any',
|
230 |
'posts_per_page' => $number,
|
231 |
-
'meta_key' => 'bp-media-key',
|
232 |
'meta_value' => 0,
|
233 |
'meta_compare' => '>',
|
234 |
'orderby' => 'comment_count');
|
235 |
-
|
236 |
$bp_media_widget_query = new WP_Query($args);
|
237 |
-
|
238 |
if($bp_media_widget_query->have_posts()){ ?>
|
239 |
-
|
240 |
-
<ul class="widget-item-listing"><?php
|
241 |
-
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
242 |
-
|
243 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
244 |
|
245 |
-
<?php echo $entry -> get_media_gallery_content();?><?php
|
246 |
-
|
247 |
} ?>
|
248 |
-
|
249 |
-
</ul><!-- .widget-item-listing --><?php
|
250 |
-
|
251 |
}else
|
252 |
_e('No popular media found', 'bp-media');
|
253 |
-
|
254 |
wp_reset_query(); ?>
|
255 |
-
|
256 |
</div><!-- #popular-media-tabs-comments -->
|
257 |
</div>
|
258 |
<?php
|
259 |
-
echo $after_widget;
|
260 |
}
|
261 |
|
262 |
function update( $new_instance, $old_instance ) {
|
@@ -265,7 +265,7 @@ class BP_Media_Popular_Media extends WP_Widget {
|
|
265 |
$instance['number'] = (int) $new_instance['number'];
|
266 |
return $instance;
|
267 |
}
|
268 |
-
|
269 |
function form( $instance ) {
|
270 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
271 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
@@ -276,9 +276,9 @@ class BP_Media_Popular_Media extends WP_Widget {
|
|
276 |
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
|
277 |
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
278 |
<?php
|
279 |
-
|
280 |
}
|
281 |
-
|
282 |
}
|
283 |
|
284 |
|
@@ -289,3 +289,5 @@ function bp_media_widgets_init(){
|
|
289 |
|
290 |
/* Initialize widgets */
|
291 |
add_action('widgets_init', 'bp_media_widgets_init', 1);
|
|
|
|
14 |
|
15 |
function widget($args, $instance) {
|
16 |
extract( $args );
|
17 |
+
|
18 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
|
19 |
+
|
20 |
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
21 |
$number = 10;
|
22 |
+
|
23 |
echo $before_widget;
|
24 |
echo $before_title . $title . $after_title;
|
25 |
?>
|
26 |
<div id="recent-media-tabs" class="media-tabs-container">
|
27 |
<ul>
|
28 |
<li><a href="#recent-media-tabs-all"><?php _e('All','bp-media'); ?></a></li>
|
29 |
+
<li><a href="#recent-media-tabs-photos"><?php _e('Photos','bp-media'); ?></a></li>
|
30 |
<li><a href="#recent-media-tabs-music"><?php _e('Music','bp-media'); ?></a></li>
|
31 |
<li><a href="#recent-media-tabs-videos"><?php _e('Videos','bp-media'); ?></a></li>
|
32 |
</ul>
|
33 |
+
<div id="recent-media-tabs-all" class="bp-media-tab-panel">
|
34 |
+
<?php
|
35 |
// All Media
|
36 |
+
$args = array( 'post_type' => 'attachment',
|
37 |
+
'post_status' => 'any',
|
38 |
'posts_per_page' => $number,
|
39 |
+
'meta_key' => 'bp-media-key',
|
40 |
'meta_value' => 0,
|
41 |
+
'meta_compare' => '>' );
|
42 |
+
|
43 |
+
$bp_media_widget_query = new WP_Query($args);
|
44 |
+
|
45 |
if($bp_media_widget_query->have_posts()){ ?>
|
46 |
+
|
47 |
+
<ul class="widget-item-listing"><?php
|
48 |
+
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
49 |
+
|
50 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
51 |
|
52 |
+
<?php echo $entry -> get_media_gallery_content();?><?php
|
53 |
+
|
54 |
} ?>
|
55 |
+
|
56 |
+
</ul><!-- .widget-item-listing --><?php
|
57 |
+
|
58 |
+
}else
|
59 |
_e('No rescent media found', 'bp-media');
|
60 |
+
|
61 |
wp_reset_query(); ?>
|
62 |
+
|
63 |
</div><!-- #recent-media-tabs-all -->
|
64 |
+
|
65 |
<div id="recent-media-tabs-photos" class="bp-media-tab-panel">
|
66 |
+
<?php
|
67 |
// Rescent photos
|
68 |
+
$args = array( 'post_type' => 'attachment',
|
69 |
'post_status' => 'any',
|
70 |
'post_mime_type' => 'image',
|
71 |
'posts_per_page' => $number,
|
72 |
+
'meta_key' => 'bp-media-key',
|
73 |
'meta_value' => 0,
|
74 |
'meta_compare' => '>' );
|
75 |
|
76 |
+
|
77 |
$bp_media_widget_query = new WP_Query($args);
|
78 |
+
|
79 |
if($bp_media_widget_query->have_posts()){ ?>
|
80 |
+
|
81 |
+
<ul class="widget-item-listing"><?php
|
82 |
+
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
83 |
+
|
84 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
85 |
|
86 |
+
<?php echo $entry -> get_media_gallery_content();?><?php
|
87 |
+
|
88 |
} ?>
|
89 |
+
|
90 |
+
</ul><!-- .widget-item-listing --><?php
|
91 |
+
|
92 |
+
}else
|
93 |
_e('No rescent photo found', 'bp-media');
|
94 |
+
|
95 |
wp_reset_query(); ?>
|
96 |
+
|
97 |
+
</div><!-- #media-tabs-photos -->
|
98 |
+
|
99 |
<div id="recent-media-tabs-music" class="bp-media-tab-panel">
|
100 |
+
<?php
|
101 |
// Rescent Audio
|
102 |
+
$args = array( 'post_type' => 'attachment',
|
103 |
'post_status' => 'any',
|
104 |
'post_mime_type' => 'audio',
|
105 |
'posts_per_page' => $number,
|
106 |
+
'meta_key' => 'bp-media-key',
|
107 |
'meta_value' => 0,
|
108 |
'meta_compare' => '>' );
|
109 |
+
|
110 |
$bp_media_widget_query = new WP_Query($args);
|
111 |
+
|
112 |
if($bp_media_widget_query->have_posts()){ ?>
|
113 |
+
|
114 |
+
<ul class="widget-item-listing"><?php
|
115 |
+
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
116 |
+
|
117 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
118 |
|
119 |
+
<?php echo $entry -> get_media_gallery_content();?><?php
|
120 |
+
|
121 |
} ?>
|
122 |
+
|
123 |
+
</ul><!-- .widget-item-listing --><?php
|
124 |
+
|
125 |
+
}else
|
126 |
_e('No rescent audio found', 'bp-media');
|
127 |
+
|
128 |
wp_reset_query(); ?>
|
129 |
+
|
130 |
</div><!-- #recent-media-tabs-music -->
|
131 |
+
|
132 |
<div id="recent-media-tabs-videos" class="bp-media-tab-panel">
|
133 |
+
<?php
|
134 |
// Rescent Video
|
135 |
+
$args = array( 'post_type' => 'attachment',
|
136 |
'post_status' => 'any',
|
137 |
'post_mime_type' => 'video',
|
138 |
'posts_per_page' => $number,
|
139 |
+
'meta_key' => 'bp-media-key',
|
140 |
'meta_value' => 0,
|
141 |
'meta_compare' => '>' );
|
142 |
+
|
143 |
$bp_media_widget_query = new WP_Query($args);
|
144 |
+
|
145 |
if($bp_media_widget_query->have_posts()){ ?>
|
146 |
+
|
147 |
+
<ul class="widget-item-listing"><?php
|
148 |
+
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
149 |
+
|
150 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
151 |
|
152 |
+
<?php echo $entry -> get_media_gallery_content();?><?php
|
153 |
+
|
154 |
} ?>
|
155 |
+
|
156 |
+
</ul><!-- .widget-item-listing --><?php
|
157 |
+
|
158 |
+
}else
|
159 |
_e('No rescent video found', 'bp-media');
|
160 |
+
|
161 |
wp_reset_query(); ?>
|
162 |
+
|
163 |
</div><!-- #media-tabs-videos -->
|
164 |
+
|
165 |
</div>
|
166 |
<?php
|
167 |
+
echo $after_widget;
|
168 |
+
|
169 |
+
|
170 |
}
|
171 |
|
172 |
function update( $new_instance, $old_instance ) {
|
175 |
$instance['number'] = (int) $new_instance['number'];
|
176 |
return $instance;
|
177 |
}
|
178 |
+
|
179 |
function form( $instance ) {
|
180 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
181 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
186 |
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
|
187 |
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
188 |
<?php
|
189 |
+
|
190 |
}
|
191 |
+
|
192 |
}
|
193 |
|
194 |
|
209 |
|
210 |
function widget($args, $instance) {
|
211 |
extract( $args );
|
212 |
+
|
213 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Media', 'bp-media') : $instance['title'], $instance, $this->id_base);
|
214 |
+
|
215 |
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
216 |
$number = 10;
|
217 |
+
|
218 |
echo $before_widget;
|
219 |
echo $before_title . $title . $after_title;
|
220 |
?>
|
221 |
<div id="popular-media-tabs" class="media-tabs-container">
|
222 |
<!-- <ul>
|
223 |
<li><a href="#popular-media-tabs-comments"><?php _e('comments', 'bp-media'); ?></a></li>
|
224 |
+
<li><a href="#popular-media-tabs-views"><?php _e('Views', 'bp-media'); ?></a></li>
|
225 |
</ul>-->
|
226 |
+
<div id="popular-media-tabs-comments" class="bp-media-tab-panel">
|
227 |
+
<?php
|
228 |
+
$args = array( 'post_type' => 'attachment',
|
229 |
+
'post_status' => 'any',
|
230 |
'posts_per_page' => $number,
|
231 |
+
'meta_key' => 'bp-media-key',
|
232 |
'meta_value' => 0,
|
233 |
'meta_compare' => '>',
|
234 |
'orderby' => 'comment_count');
|
235 |
+
|
236 |
$bp_media_widget_query = new WP_Query($args);
|
237 |
+
|
238 |
if($bp_media_widget_query->have_posts()){ ?>
|
239 |
+
|
240 |
+
<ul class="widget-item-listing"><?php
|
241 |
+
while ($bp_media_widget_query->have_posts()) { $bp_media_widget_query->the_post();
|
242 |
+
|
243 |
$entry = new BP_Media_Host_Wordpress( get_the_ID() );?>
|
244 |
|
245 |
+
<?php echo $entry -> get_media_gallery_content();?><?php
|
246 |
+
|
247 |
} ?>
|
248 |
+
|
249 |
+
</ul><!-- .widget-item-listing --><?php
|
250 |
+
|
251 |
}else
|
252 |
_e('No popular media found', 'bp-media');
|
253 |
+
|
254 |
wp_reset_query(); ?>
|
255 |
+
|
256 |
</div><!-- #popular-media-tabs-comments -->
|
257 |
</div>
|
258 |
<?php
|
259 |
+
echo $after_widget;
|
260 |
}
|
261 |
|
262 |
function update( $new_instance, $old_instance ) {
|
265 |
$instance['number'] = (int) $new_instance['number'];
|
266 |
return $instance;
|
267 |
}
|
268 |
+
|
269 |
function form( $instance ) {
|
270 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
271 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
276 |
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'bp-media'); ?></label>
|
277 |
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
278 |
<?php
|
279 |
+
|
280 |
}
|
281 |
+
|
282 |
}
|
283 |
|
284 |
|
289 |
|
290 |
/* Initialize widgets */
|
291 |
add_action('widgets_init', 'bp_media_widgets_init', 1);
|
292 |
+
|
293 |
+
?>
|
includes/css/bp-media-style.css
CHANGED
@@ -12,6 +12,7 @@ ul.bp-media-gallery li img{max-width:150px;width:100%;height:auto;-moz-box-shado
|
|
12 |
ul.bp-media-gallery li img:hover{-moz-box-shadow: 1px 1px 10px #333;-webkit-box-shadow: 1px 1px 10px #333;box-shadow: 1px 1px 10px #333;}
|
13 |
ul.bp-media-gallery h3{max-width: 150px;overflow: hidden;text-align: center;font-size: 110%;white-space: nowrap;height: 20px;margin: 10px 0px;}
|
14 |
ul.bp-media-gallery a{width:150px;}
|
|
|
15 |
.bp-media-single .activity-list .activity-content,.bp-media-single div.activity-comments{margin-left:0;}
|
16 |
li.media div.activity-content div.activity-inner p{display:none;}
|
17 |
div.bp_media_title{margin-bottom:10px;}
|
12 |
ul.bp-media-gallery li img:hover{-moz-box-shadow: 1px 1px 10px #333;-webkit-box-shadow: 1px 1px 10px #333;box-shadow: 1px 1px 10px #333;}
|
13 |
ul.bp-media-gallery h3{max-width: 150px;overflow: hidden;text-align: center;font-size: 110%;white-space: nowrap;height: 20px;margin: 10px 0px;}
|
14 |
ul.bp-media-gallery a{width:150px;}
|
15 |
+
ul.bp-media-gallery li span img{height: 150px;}
|
16 |
.bp-media-single .activity-list .activity-content,.bp-media-single div.activity-comments{margin-left:0;}
|
17 |
li.media div.activity-content div.activity-inner p{display:none;}
|
18 |
div.bp_media_title{margin-bottom:10px;}
|
includes/js/bp-media-uploader.js
CHANGED
@@ -35,12 +35,13 @@ jQuery(document).ready(function(){
|
|
35 |
}
|
36 |
var data = {
|
37 |
action: 'bp_media_add_album',
|
38 |
-
bp_media_album_name : album_name
|
|
|
39 |
};
|
40 |
jQuery.post(bp_media_vars.ajaxurl,data,function(response){
|
41 |
var album = parseInt(response);
|
42 |
if(album == 0){
|
43 |
-
alert('
|
44 |
}
|
45 |
else{
|
46 |
jQuery('#bp-media-selected-album').append('<option value='+album+' selected="selected">'+jQuery('#bp_media_album_name').val()+'</option>')
|
35 |
}
|
36 |
var data = {
|
37 |
action: 'bp_media_add_album',
|
38 |
+
bp_media_album_name : album_name,
|
39 |
+
bp_media_group_id : bp_media_uploader_params.multipart_params.bp_media_group_id
|
40 |
};
|
41 |
jQuery.post(bp_media_vars.ajaxurl,data,function(response){
|
42 |
var album = parseInt(response);
|
43 |
if(album == 0){
|
44 |
+
alert('Sorry you cannot create albums in this group');
|
45 |
}
|
46 |
else{
|
47 |
jQuery('#bp-media-selected-album').append('<option value='+album+' selected="selected">'+jQuery('#bp_media_album_name').val()+'</option>')
|
includes/js/bp-media.js
CHANGED
@@ -50,7 +50,8 @@ jQuery(document).ready(function(){
|
|
50 |
current_action : bp_media_vars.current_action,
|
51 |
action_variables : bp_media_vars.action_variables,
|
52 |
displayed_user : bp_media_vars.displayed_user,
|
53 |
-
loggedin_user : bp_media_vars.loggedin_user
|
|
|
54 |
};
|
55 |
|
56 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
@@ -73,4 +74,36 @@ jQuery(document).ready(function(){
|
|
73 |
|
74 |
},1000);
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
});
|
50 |
current_action : bp_media_vars.current_action,
|
51 |
action_variables : bp_media_vars.action_variables,
|
52 |
displayed_user : bp_media_vars.displayed_user,
|
53 |
+
loggedin_user : bp_media_vars.loggedin_user,
|
54 |
+
current_group : bp_media_vars.current_group
|
55 |
};
|
56 |
|
57 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
74 |
|
75 |
},1000);
|
76 |
|
77 |
+
/* Add Featured Image */
|
78 |
+
|
79 |
+
jQuery('.bp-media-featured').live('click',function(e){
|
80 |
+
e.preventDefault();
|
81 |
+
var post_id = jQuery(this).attr('data-post-id');
|
82 |
+
var post_date = new Date();
|
83 |
+
var date = post_date.getFullYear()+'-'+(post_date.getMonth() + 1) +'-'+post_date.getDate()+' '+ post_date.getHours()+':'+(post_date.getMinutes() + 1)+':'+(post_date.getSeconds()+1);
|
84 |
+
// var post_date = d.getTime();
|
85 |
+
var curr_obj = jQuery(this);
|
86 |
+
var remove_featured = 0;
|
87 |
+
if(jQuery(this).attr('data-remove-featured')){
|
88 |
+
remove_featured = jQuery(this).attr('data-remove-featured');
|
89 |
+
}
|
90 |
+
jQuery.ajax({
|
91 |
+
url:"/wp-admin/admin-ajax.php",
|
92 |
+
type:'POST',
|
93 |
+
data:'action=my_featured_action&post_id='+post_id+'&remove_featured='+remove_featured+'&post_date='+date,
|
94 |
+
success:function( results )
|
95 |
+
{
|
96 |
+
if(remove_featured == 1){
|
97 |
+
curr_obj.text('Featured');
|
98 |
+
curr_obj.attr('data-remove-featured','0');
|
99 |
+
} else {
|
100 |
+
curr_obj.text('Remove Featured');
|
101 |
+
curr_obj.attr('data-remove-featured','1');
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
105 |
+
});
|
106 |
+
});
|
107 |
+
|
108 |
+
|
109 |
});
|
loader.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
-
Version: 2.
|
7 |
Author: rtCamp
|
8 |
Author URI: http://rtcamp.com
|
9 |
*/
|
@@ -48,6 +48,7 @@ function bp_media_init() {
|
|
48 |
if (defined('BP_VERSION')&&version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '>')) {
|
49 |
add_filter( 'plugin_action_links', 'bp_media_settings_link', 10, 2 );
|
50 |
require( BP_MEDIA_PLUGIN_DIR . '/includes/bp-media-loader.php' );
|
|
|
51 |
}
|
52 |
}
|
53 |
add_action('bp_include', 'bp_media_init');
|
@@ -151,4 +152,4 @@ function bp_media_get_admin_url( $path = '', $scheme = 'admin' ) {
|
|
151 |
|
152 |
return $url;
|
153 |
}
|
154 |
-
?>
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
+
Version: 2.3
|
7 |
Author: rtCamp
|
8 |
Author URI: http://rtcamp.com
|
9 |
*/
|
48 |
if (defined('BP_VERSION')&&version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '>')) {
|
49 |
add_filter( 'plugin_action_links', 'bp_media_settings_link', 10, 2 );
|
50 |
require( BP_MEDIA_PLUGIN_DIR . '/includes/bp-media-loader.php' );
|
51 |
+
//require( BP_MEDIA_PLUGIN_DIR . '/includes/bp-media-groups-loader.php');
|
52 |
}
|
53 |
}
|
54 |
add_action('bp_include', 'bp_media_init');
|
152 |
|
153 |
return $url;
|
154 |
}
|
155 |
+
?>
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
|
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.3.2
|
8 |
Tested up to: 3.4.2
|
9 |
-
Stable tag: 2.
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
@@ -73,6 +73,10 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
73 |
|
74 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
75 |
|
|
|
|
|
|
|
|
|
76 |
= 2.2.8 =
|
77 |
* Fixed some screen functions
|
78 |
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.3.2
|
8 |
Tested up to: 3.4.2
|
9 |
+
Stable tag: 2.3
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
73 |
|
74 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
75 |
|
76 |
+
= 2.3 =
|
77 |
+
* Groups Media feature added
|
78 |
+
* Featured image selection in albums
|
79 |
+
|
80 |
= 2.2.8 =
|
81 |
* Fixed some screen functions
|
82 |
|