Version Description
- Album Support for Users
- Ajaxified pagination to make it easy to view large albums.
- Multiple file uploads with progress bar
- Easy access to the backend admin-options
- Admin-option to disable download button below media files.
Download this release
Release Info
Developer | rtcamp |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.5 to 2.2
- includes/bp-media-actions.php +332 -65
- includes/bp-media-admin.php +558 -194
- includes/bp-media-class-album.php +200 -0
- includes/bp-media-class-wordpress.php +183 -84
- includes/bp-media-filters.php +331 -32
- includes/bp-media-functions.php +73 -36
- includes/bp-media-loader.php +223 -89
- includes/bp-media-screens.php +201 -20
- includes/bp-media-shortcodes.php +21 -6
- includes/bp-media-template-functions.php +137 -21
- includes/bp-media-upgrade-script.php +61 -0
- includes/bp-media-upload-handler.php +2 -2
- includes/bp-media-widgets.php +291 -0
- includes/css/bp-media-style.css +129 -206
- includes/img/bpm-icon-16.png +0 -0
- includes/img/bpm-icon-32.png +0 -0
- includes/img/donate.gif +0 -0
- includes/img/donate.png +0 -0
- includes/img/logo_medibp_32.png +0 -0
- includes/img/rtCamp-bullet.png +0 -0
- includes/img/rtcamp-logo.png +0 -0
- includes/js/bp-media-uploader.js +99 -24
- includes/js/bp-media.js +42 -2
- loader.php +39 -12
- readme.txt +43 -19
includes/bp-media-actions.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Handles the uploads and creates respective posts for the upload
|
4 |
-
*
|
5 |
* @since BP Media 2.0
|
6 |
*/
|
7 |
function bp_media_handle_uploads() {
|
@@ -12,6 +12,7 @@ function bp_media_handle_uploads() {
|
|
12 |
'images_enabled' => true,
|
13 |
));
|
14 |
if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
|
|
|
15 |
if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
|
16 |
if(preg_match('/image/',$_FILES['bp_media_file']['type'])){
|
17 |
if($bp_media_options['images_enabled']==false){
|
@@ -35,22 +36,40 @@ function bp_media_handle_uploads() {
|
|
35 |
$bp_media_entry = new $class_name();
|
36 |
try {
|
37 |
$title = isset($_POST['bp_media_title']) ? ($_POST['bp_media_title'] != "") ? $_POST['bp_media_title'] : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME) : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME);
|
38 |
-
$
|
|
|
|
|
39 |
if(!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
|
40 |
$bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', 'bp-media');
|
41 |
} catch (Exception $e) {
|
42 |
$bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
|
43 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
} else {
|
45 |
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', 'bp-media');
|
46 |
}
|
47 |
}
|
48 |
}
|
49 |
-
add_action('bp_init', 'bp_media_handle_uploads');
|
50 |
|
51 |
/**
|
52 |
* Displays the messages that other functions/methods creates according to the BuddyPress' formating
|
53 |
-
*
|
54 |
* @since BP Media 2.0
|
55 |
*/
|
56 |
function bp_media_show_messages() {
|
@@ -68,72 +87,77 @@ add_action('bp_media_before_content', 'bp_media_show_messages');
|
|
68 |
|
69 |
/**
|
70 |
* Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media.
|
71 |
-
*
|
72 |
* @since BP Media 2.0
|
73 |
*/
|
74 |
function bp_media_enqueue_scripts_styles() {
|
75 |
-
|
|
|
|
|
76 |
wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
77 |
-
|
78 |
-
wp_enqueue_style('bp-media-default', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
|
79 |
-
}
|
80 |
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
/**
|
84 |
-
* Deletes associated media entry and its files upon deletion of an activity.
|
85 |
-
*
|
86 |
-
* @since BP Media 2.0
|
87 |
-
*/
|
88 |
-
function bp_media_delete_activity_handler($activity_id, $user) {
|
89 |
-
global $bp_media_count;
|
90 |
-
bp_media_init_count(bp_loggedin_user_id());
|
91 |
-
$post_id = bp_activity_get_meta($activity_id, 'bp_media_parent_post');
|
92 |
-
$type = get_post_meta($post_id, 'bp_media_type', true);
|
93 |
-
switch ($type) {
|
94 |
-
case 'image':
|
95 |
-
$bp_media_count['images'] = intval($bp_media_count['images']) - 1;
|
96 |
-
break;
|
97 |
-
case 'video':
|
98 |
-
$bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
|
99 |
-
break;
|
100 |
-
case 'audio':
|
101 |
-
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
|
102 |
-
break;
|
103 |
-
}
|
104 |
-
$attachment_id = get_post_meta($post_id, 'bp_media_child_attachment', true);
|
105 |
-
wp_delete_attachment($attachment_id, true);
|
106 |
-
wp_delete_post($post_id, true);
|
107 |
-
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
108 |
}
|
|
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
//The above hook isn't at right place yet, so skipped it till its corrected
|
113 |
-
//add_action('bp_activity_before_action_delete_activity', 'bp_media_delete_activity_handler', 10, 2);
|
114 |
-
|
115 |
-
function bp_media_delete_activity_handler_old($args){
|
116 |
global $bp_media_count,$wpdb;
|
117 |
-
|
118 |
if(!array_key_exists('id', $args))
|
119 |
return;
|
120 |
-
|
121 |
$activity_id=$args['id'];
|
122 |
$query="SELECT post_id from $wpdb->postmeta WHERE meta_key='bp_media_child_activity' AND meta_value=$activity_id";
|
123 |
$result=$wpdb->get_results($query);
|
124 |
if(!(is_array($result)&& count($result)==1 ))
|
125 |
return;
|
126 |
$post_id=$result[0]->post_id;
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
-
add_action('
|
131 |
|
132 |
/**
|
133 |
* Called on bp_init by screen functions
|
134 |
-
*
|
135 |
* @uses global $bp, $bp_media_query
|
136 |
-
*
|
137 |
* @since BP Media 2.0
|
138 |
*/
|
139 |
function bp_media_set_query() {
|
@@ -158,10 +182,12 @@ function bp_media_set_query() {
|
|
158 |
}
|
159 |
if ($type) {
|
160 |
$args = array(
|
161 |
-
'post_type' => '
|
|
|
|
|
162 |
'author' => $bp->displayed_user->id,
|
163 |
-
'meta_key' => '
|
164 |
-
'meta_value' => $
|
165 |
'meta_compare' => 'LIKE',
|
166 |
'paged' => $paged
|
167 |
);
|
@@ -171,26 +197,31 @@ function bp_media_set_query() {
|
|
171 |
|
172 |
/**
|
173 |
* Adds a download button and edit button on single entry pages of media files.
|
174 |
-
*
|
|
|
|
|
175 |
* @since BP Media 2.0
|
176 |
*/
|
177 |
function bp_media_action_buttons() {
|
178 |
if(!in_array('bp_media_current_entry', $GLOBALS))
|
179 |
return false;
|
180 |
-
global $bp_media_current_entry;
|
|
|
181 |
if($bp_media_current_entry!=NULL){
|
182 |
-
if(bp_displayed_user_id()== bp_loggedin_user_id())
|
183 |
-
|
184 |
-
|
|
|
|
|
185 |
}
|
186 |
}
|
187 |
-
add_action('bp_activity_entry_meta', 'bp_media_action_buttons');
|
188 |
|
189 |
/* Should be used with Content Disposition Type for media files set to attachment */
|
190 |
|
191 |
/**
|
192 |
* Shows the media count of a user in the tabs
|
193 |
-
*
|
194 |
* @since BP Media 2.0
|
195 |
*/
|
196 |
function bp_media_init_count($user = null) {
|
@@ -214,6 +245,7 @@ function bp_media_init_count($user = null) {
|
|
214 |
add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'bp_media_items_count_filter', 10, 2);
|
215 |
add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'bp_media_items_count_filter', 10, 2);
|
216 |
add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'bp_media_items_count_filter', 10, 2);
|
|
|
217 |
}
|
218 |
return true;
|
219 |
}
|
@@ -221,14 +253,16 @@ add_action('init', 'bp_media_init_count');
|
|
221 |
|
222 |
/**
|
223 |
* Displays the footer of the BP Media Plugin if enabled through the dashboard options page
|
224 |
-
*
|
225 |
* @since BP Media 2.0
|
226 |
*/
|
227 |
function bp_media_footer() { ?>
|
228 |
<div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
|
229 |
<?php
|
230 |
}
|
231 |
-
|
|
|
|
|
232 |
add_action('bp_footer','bp_media_footer');
|
233 |
|
234 |
function bp_media_upload_enqueue(){
|
@@ -247,12 +281,245 @@ function bp_media_upload_enqueue(){
|
|
247 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
248 |
'multi_selection' => true,
|
249 |
'multipart_params' => array('action'=>'wp_handle_upload')
|
250 |
-
|
251 |
-
);
|
252 |
-
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'));
|
253 |
wp_localize_script('bp-media-uploader','bp_media_uploader_params',$params);
|
254 |
wp_enqueue_style('bp-media-default',plugins_url('css/bp-media-style.css',__FILE__));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
-
|
257 |
-
//This is used only on the uploads page
|
258 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
* Handles the uploads and creates respective posts for the upload
|
4 |
+
*
|
5 |
* @since BP Media 2.0
|
6 |
*/
|
7 |
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('/image/',$_FILES['bp_media_file']['type'])){
|
18 |
if($bp_media_options['images_enabled']==false){
|
36 |
$bp_media_entry = new $class_name();
|
37 |
try {
|
38 |
$title = isset($_POST['bp_media_title']) ? ($_POST['bp_media_title'] != "") ? $_POST['bp_media_title'] : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME) : pathinfo($_FILES['bp_media_file']['name'], PATHINFO_FILENAME);
|
39 |
+
$album_id = isset($_POST['bp_media_album_id']) ? intval($_POST['bp_media_album_id']) : 0;
|
40 |
+
$description = isset($_POST['bp_media_description'])? $_POST['bp_media_description'] : '';
|
41 |
+
$entry = $bp_media_entry->add_media($title, $description,$album_id);
|
42 |
if(!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
|
43 |
$bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', 'bp-media');
|
44 |
} catch (Exception $e) {
|
45 |
$bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
|
46 |
}
|
47 |
+
if(function_exists('bp_activity_add')){
|
48 |
+
$activity_content = $bp_media_entry->get_media_activity_content();
|
49 |
+
$args = array(
|
50 |
+
'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . $bp_media_entry->get_url() . '">' . $bp_media_entry->get_media_activity_type() . '</a>' ) ),
|
51 |
+
'content' => $activity_content,
|
52 |
+
'primary_link' => $bp_media_entry->get_url(),
|
53 |
+
'item_id' => $bp_media_entry->get_id(),
|
54 |
+
'type' => 'media_upload',
|
55 |
+
);
|
56 |
+
if(isset($_POST['is_multiple_upload'])&&$_POST['is_multiple_upload']=='true'){
|
57 |
+
$args['secondary_item_id'] = -999;
|
58 |
+
do_action('bp_media_album_updated',$bp_media_entry->get_album_id());
|
59 |
+
}
|
60 |
+
$activity_id = bp_media_record_activity($args);
|
61 |
+
add_post_meta($bp_media_entry->get_id(),'bp_media_child_activity',$activity_id);
|
62 |
+
}
|
63 |
} else {
|
64 |
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', 'bp-media');
|
65 |
}
|
66 |
}
|
67 |
}
|
68 |
+
//add_action('bp_init', 'bp_media_handle_uploads');
|
69 |
|
70 |
/**
|
71 |
* Displays the messages that other functions/methods creates according to the BuddyPress' formating
|
72 |
+
*
|
73 |
* @since BP Media 2.0
|
74 |
*/
|
75 |
function bp_media_show_messages() {
|
87 |
|
88 |
/**
|
89 |
* Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media.
|
90 |
+
*
|
91 |
* @since BP Media 2.0
|
92 |
*/
|
93 |
function bp_media_enqueue_scripts_styles() {
|
94 |
+
|
95 |
+
wp_enqueue_script('jquery-ui-tabs');
|
96 |
+
wp_enqueue_script('bp-media-mejs', plugins_url('includes/media-element/mediaelement-and-player.min.js', dirname(__FILE__)));
|
97 |
wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
98 |
+
global $bp;
|
|
|
|
|
99 |
|
100 |
+
$bp_media_vars = array(
|
101 |
+
'ajaxurl' => admin_url( 'admin-ajax.php'),
|
102 |
+
'page' => 1,
|
103 |
+
'current_action' => isset($bp->current_action)?$bp->current_action:false,
|
104 |
+
'action_variables' => isset($bp->action_variables)?$bp->action_variables:false,
|
105 |
+
'displayed_user' => bp_displayed_user_id(),
|
106 |
+
'loggedin_user' => bp_loggedin_user_id()
|
107 |
+
);
|
108 |
+
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
109 |
+
wp_enqueue_style('bp-media-mecss', plugins_url('includes/media-element/mediaelementplayer.min.css', dirname(__FILE__)));
|
110 |
+
wp_enqueue_style('bp-media-default', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
+
add_action('wp_enqueue_scripts', 'bp_media_enqueue_scripts_styles', 11);
|
114 |
|
115 |
+
function bp_media_delete_activity_handler($args){
|
116 |
+
remove_action('bp_media_before_delete_media','bp_media_delete_media_handler');
|
|
|
|
|
|
|
|
|
117 |
global $bp_media_count,$wpdb;
|
|
|
118 |
if(!array_key_exists('id', $args))
|
119 |
return;
|
120 |
+
|
121 |
$activity_id=$args['id'];
|
122 |
$query="SELECT post_id from $wpdb->postmeta WHERE meta_key='bp_media_child_activity' AND meta_value=$activity_id";
|
123 |
$result=$wpdb->get_results($query);
|
124 |
if(!(is_array($result)&& count($result)==1 ))
|
125 |
return;
|
126 |
$post_id=$result[0]->post_id;
|
127 |
+
try{
|
128 |
+
$post = get_post($post_id);
|
129 |
+
switch($post->post_type){
|
130 |
+
case 'attachment':
|
131 |
+
$media = new BP_Media_Host_Wordpress($post_id);
|
132 |
+
$media->delete_media();
|
133 |
+
break;
|
134 |
+
case 'bp_media_album':
|
135 |
+
$album = new BP_Media_Album($post_id);
|
136 |
+
$album->delete_album();
|
137 |
+
break;
|
138 |
+
default:
|
139 |
+
wp_delete_post($post_id);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
catch(Exception $e){
|
143 |
+
error_log('Media tried to delete was already deleted');
|
144 |
+
}
|
145 |
+
}
|
146 |
+
add_action('bp_before_activity_delete', 'bp_media_delete_activity_handler');
|
147 |
+
|
148 |
+
function bp_media_delete_media_handler($media_id){
|
149 |
+
/* @var $media BP_Media_Host_Wordpress */
|
150 |
+
remove_action('bp_before_activity_delete', 'bp_media_delete_activity_handler');
|
151 |
+
$activity_id = get_post_meta($media_id,'bp_media_child_activity',true);
|
152 |
+
bp_activity_delete_by_activity_id($activity_id);
|
153 |
}
|
154 |
+
add_action('bp_media_before_delete_media','bp_media_delete_media_handler');
|
155 |
|
156 |
/**
|
157 |
* Called on bp_init by screen functions
|
158 |
+
*
|
159 |
* @uses global $bp, $bp_media_query
|
160 |
+
*
|
161 |
* @since BP Media 2.0
|
162 |
*/
|
163 |
function bp_media_set_query() {
|
182 |
}
|
183 |
if ($type) {
|
184 |
$args = array(
|
185 |
+
'post_type' => 'attachment',
|
186 |
+
'post_status' => 'any',
|
187 |
+
'post_mime_type' => $type,
|
188 |
'author' => $bp->displayed_user->id,
|
189 |
+
'meta_key' => 'bp-media-key',
|
190 |
+
'meta_value' => $bp->displayed_user->id,
|
191 |
'meta_compare' => 'LIKE',
|
192 |
'paged' => $paged
|
193 |
);
|
197 |
|
198 |
/**
|
199 |
* Adds a download button and edit button on single entry pages of media files.
|
200 |
+
*
|
201 |
+
* @uses $bp_media_options Global variable
|
202 |
+
*
|
203 |
* @since BP Media 2.0
|
204 |
*/
|
205 |
function bp_media_action_buttons() {
|
206 |
if(!in_array('bp_media_current_entry', $GLOBALS))
|
207 |
return false;
|
208 |
+
global $bp_media_current_entry,$bp_media_options;
|
209 |
+
|
210 |
if($bp_media_current_entry!=NULL){
|
211 |
+
if(bp_displayed_user_id()== bp_loggedin_user_id())
|
212 |
+
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>';
|
213 |
+
|
214 |
+
if($bp_media_options['download_enabled']==true)
|
215 |
+
echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action bp-media-download" title="Download">Download</a>';
|
216 |
}
|
217 |
}
|
218 |
+
add_action('bp_activity_entry_meta', 'bp_media_action_buttons');
|
219 |
|
220 |
/* Should be used with Content Disposition Type for media files set to attachment */
|
221 |
|
222 |
/**
|
223 |
* Shows the media count of a user in the tabs
|
224 |
+
*
|
225 |
* @since BP Media 2.0
|
226 |
*/
|
227 |
function bp_media_init_count($user = null) {
|
245 |
add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'bp_media_items_count_filter', 10, 2);
|
246 |
add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'bp_media_items_count_filter', 10, 2);
|
247 |
add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'bp_media_items_count_filter', 10, 2);
|
248 |
+
add_filter('bp_get_options_nav_' . BP_MEDIA_ALBUMS_SLUG, 'bp_media_items_count_filter', 10, 2);
|
249 |
}
|
250 |
return true;
|
251 |
}
|
253 |
|
254 |
/**
|
255 |
* Displays the footer of the BP Media Plugin if enabled through the dashboard options page
|
256 |
+
*
|
257 |
* @since BP Media 2.0
|
258 |
*/
|
259 |
function bp_media_footer() { ?>
|
260 |
<div id="bp-media-footer"><p>Using <a title="BuddyPress Media adds photos, video and audio upload/management feature" href="http://rtcamp.com/buddypress-media/">BuddyPress Media</a>.</p></div>
|
261 |
<?php
|
262 |
}
|
263 |
+
|
264 |
+
global $bp_media_options;
|
265 |
+
if($bp_media_options['remove_linkback']!='1')
|
266 |
add_action('bp_footer','bp_media_footer');
|
267 |
|
268 |
function bp_media_upload_enqueue(){
|
281 |
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
282 |
'multi_selection' => true,
|
283 |
'multipart_params' => array('action'=>'wp_handle_upload')
|
284 |
+
);
|
285 |
+
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'));
|
|
|
286 |
wp_localize_script('bp-media-uploader','bp_media_uploader_params',$params);
|
287 |
wp_enqueue_style('bp-media-default',plugins_url('css/bp-media-style.css',__FILE__));
|
288 |
+
// wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
|
289 |
+
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
|
290 |
+
}
|
291 |
+
add_action('wp_enqueue_scripts','bp_media_upload_enqueue');
|
292 |
+
//This is used only on the uploads page so its added as action in the screens function of upload page.
|
293 |
+
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Called on bp_init by screen functions
|
297 |
+
*
|
298 |
+
* @uses global $bp, $bp_media_albums_query
|
299 |
+
*
|
300 |
+
* @since BP Media 2.2
|
301 |
+
*/
|
302 |
+
function bp_media_albums_set_query() {
|
303 |
+
global $bp, $bp_media_albums_query;
|
304 |
+
if (isset($bp->action_variables) && is_array($bp->action_variables) && isset($bp->action_variables[0]) && $bp->action_variables[0] == 'page' && isset($bp->action_variables[1]) && is_numeric($bp->action_variables[1])) {
|
305 |
+
$paged = $bp->action_variables[1];
|
306 |
+
} else {
|
307 |
+
$paged = 1;
|
308 |
+
}
|
309 |
+
if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
|
310 |
+
$args = array(
|
311 |
+
'post_type' => 'bp_media_album',
|
312 |
+
'author' => $bp->displayed_user->id,
|
313 |
+
'paged' => $paged,
|
314 |
+
);
|
315 |
+
$bp_media_albums_query = new WP_Query($args);
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Called on bp_init by screen functions
|
321 |
+
*
|
322 |
+
* @uses global $bp, $bp_media_query
|
323 |
+
*
|
324 |
+
* @since BP Media 2.2
|
325 |
+
*/
|
326 |
+
function bp_media_albums_set_inner_query($album_id=0) {
|
327 |
+
global $bp, $bp_media_query;
|
328 |
+
$paged = 0;
|
329 |
+
$action_variables = isset($bp->canonical_stack['action_variables'])?$bp->canonical_stack['action_variables']:null;
|
330 |
+
if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0])) {
|
331 |
+
if($action_variables[0] == 'page' && isset($action_variables[1]) && is_numeric($action_variables[1]))
|
332 |
+
$paged = $action_variables[1];
|
333 |
+
else if($action_variables[1] == 'page' && isset($action_variables[2]) && is_numeric($action_variables[2]))
|
334 |
+
$paged = $action_variables[2];
|
335 |
+
}
|
336 |
+
if(!$paged)
|
337 |
+
$paged = 1;
|
338 |
+
$args = array(
|
339 |
+
'post_type' => 'attachment',
|
340 |
+
'post_status' => 'any',
|
341 |
+
'author' => $bp->displayed_user->id,
|
342 |
+
'post_parent'=>$album_id,
|
343 |
+
'paged' => $paged
|
344 |
+
);
|
345 |
+
$bp_media_query = new WP_Query($args);
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Function to return the media for the ajax requests
|
350 |
+
*/
|
351 |
+
function bp_media_load_more() {
|
352 |
+
global $bp,$bp_media_query;
|
353 |
+
$page = isset($_POST['page'])?$_POST['page']:die();
|
354 |
+
$current_action = isset($_POST['current_action'])?$_POST['current_action']:null;
|
355 |
+
$action_variables = isset($_POST['action_variables'])?$_POST['action_variables']:null;
|
356 |
+
$displayed_user = isset($_POST['displayed_user'])?$_POST['displayed_user']:null;
|
357 |
+
$loggedin_user = isset($_POST['loggedin_user'])?$_POST['loggedin_user']:null;
|
358 |
+
if(!$displayed_user||intval($displayed_user)==0){
|
359 |
+
die();
|
360 |
+
}
|
361 |
+
$posts_per_page = 10;
|
362 |
+
switch($current_action){
|
363 |
+
case BP_MEDIA_IMAGES_SLUG:
|
364 |
+
$args = array(
|
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' => 'LIKE',
|
372 |
+
'paged' => $page,
|
373 |
+
'posts_per_page' => $posts_per_page
|
374 |
+
);
|
375 |
+
break;
|
376 |
+
case BP_MEDIA_AUDIO_SLUG:
|
377 |
+
$args = array(
|
378 |
+
'post_type' => 'attachment',
|
379 |
+
'post_status' => 'any',
|
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' => 'LIKE',
|
385 |
+
'paged' => $page,
|
386 |
+
'posts_per_page' => $posts_per_page
|
387 |
+
);
|
388 |
+
break;
|
389 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
390 |
+
$args = array(
|
391 |
+
'post_type' => 'attachment',
|
392 |
+
'post_status' => 'any',
|
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' => 'LIKE',
|
398 |
+
'paged' => $page,
|
399 |
+
'posts_per_page' => $posts_per_page
|
400 |
+
);
|
401 |
+
break;
|
402 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
403 |
+
if(isset($action_variables)&& is_array($action_variables)&&isset($action_variables[0])&&isset($action_variables[1])){
|
404 |
+
$args = array(
|
405 |
+
'post_type' => 'attachment',
|
406 |
+
'post_status' => 'any',
|
407 |
+
'author' => $displayed_user,
|
408 |
+
'post_parent'=>$action_variables[1],
|
409 |
+
'paged' => $page
|
410 |
+
);
|
411 |
+
}
|
412 |
+
else{
|
413 |
+
$args = array(
|
414 |
+
'post_type' => 'bp_media_album',
|
415 |
+
'author' => $displayed_user,
|
416 |
+
'paged' => $page,
|
417 |
+
);
|
418 |
+
}
|
419 |
+
break;
|
420 |
+
default:
|
421 |
+
die();
|
422 |
+
}
|
423 |
+
$bp_media_query = new WP_Query($args);
|
424 |
+
if(isset($bp_media_query->posts)&&is_array($bp_media_query->posts)&&count($bp_media_query->posts)){
|
425 |
+
foreach($bp_media_query->posts as $attachment){
|
426 |
+
try{
|
427 |
+
$media = new BP_Media_Host_Wordpress($attachment->ID);
|
428 |
+
echo $media->get_media_gallery_content();
|
429 |
+
}
|
430 |
+
catch(exception $e){
|
431 |
+
die();
|
432 |
+
}
|
433 |
+
}
|
434 |
+
}
|
435 |
+
die();
|
436 |
+
}
|
437 |
+
add_action('wp_ajax_bp_media_load_more', 'bp_media_load_more');
|
438 |
+
add_action( 'wp_ajax_nopriv_bp_media_load_more', 'bp_media_load_more' );
|
439 |
+
|
440 |
+
|
441 |
+
function bp_media_delete_attachment_handler($attachment_id){
|
442 |
+
if(get_post_meta($attachment_id,'bp-media-key')){
|
443 |
+
do_action('bp_media_before_delete_media',$attachment_id);
|
444 |
+
global $bp_media_count;
|
445 |
+
$attachment = get_post($attachment_id);
|
446 |
+
preg_match_all('/audio|video|image/i', $attachment->post_mime_type, $result);
|
447 |
+
if(isset($result[0][0]))
|
448 |
+
$type = $result[0][0];
|
449 |
+
else
|
450 |
+
return false;
|
451 |
+
bp_media_init_count($attachment->post_author);
|
452 |
+
switch($type){
|
453 |
+
case 'image':
|
454 |
+
$images = intval($bp_media_count['images'])?intval($bp_media_count['images']):0;
|
455 |
+
$bp_media_count['images'] = $images - 1;
|
456 |
+
break;
|
457 |
+
case 'audio':
|
458 |
+
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
|
459 |
+
break;
|
460 |
+
case 'video':
|
461 |
+
$bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
|
462 |
+
break;
|
463 |
+
default:
|
464 |
+
return false;
|
465 |
+
}
|
466 |
+
bp_update_user_meta($attachment->post_author, 'bp_media_count', $bp_media_count);
|
467 |
+
do_action('bp_media_after_delete_media',$attachment_id);
|
468 |
+
return true;
|
469 |
+
}
|
470 |
+
}
|
471 |
+
add_action('delete_attachment','bp_media_delete_attachment_handler');
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Function to create new album called via ajax request
|
475 |
+
*/
|
476 |
+
function bp_media_add_album() {
|
477 |
+
if(isset($_POST['bp_media_album_name'])&&$_POST['bp_media_album_name']!=''){
|
478 |
+
$album = new BP_Media_Album();
|
479 |
+
try{
|
480 |
+
$album -> add_album($_POST['bp_media_album_name']);
|
481 |
+
echo $album->get_id();
|
482 |
+
}
|
483 |
+
catch(exception $e){
|
484 |
+
echo '0';
|
485 |
+
}
|
486 |
+
}
|
487 |
+
else{
|
488 |
+
echo '0';
|
489 |
+
}
|
490 |
+
die();
|
491 |
+
}
|
492 |
+
add_action('wp_ajax_bp_media_add_album', 'bp_media_add_album');
|
493 |
+
|
494 |
+
function bp_media_add_new_from_activity(){
|
495 |
+
bp_media_show_upload_form_multiple_activity();
|
496 |
+
}
|
497 |
+
//add_action('bp_after_activity_post_form','bp_media_add_new_from_activity');
|
498 |
+
|
499 |
+
|
500 |
+
function bp_media_album_create_activity($album){
|
501 |
+
/* @var $album BP_Media_Album */
|
502 |
+
$args = array(
|
503 |
+
'action' => apply_filters( 'bp_media_album_created', sprintf( __( '%1$s created an album %2$s', 'bp-media'), bp_core_get_userlink( $album->get_owner() ), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>' ) ),
|
504 |
+
'component' => BP_MEDIA_SLUG,
|
505 |
+
'type' => 'album_created',
|
506 |
+
'primary_link' => $album->get_url(),
|
507 |
+
'user_id' => $album->get_owner(),
|
508 |
+
'item_id' => $album->get_id()
|
509 |
+
);
|
510 |
+
$activity_id = bp_media_record_activity($args);
|
511 |
+
update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
|
512 |
+
}
|
513 |
+
add_action('bp_media_after_add_album','bp_media_album_create_activity');
|
514 |
+
|
515 |
+
function bp_media_album_activity_update($album_id){
|
516 |
+
bp_media_update_album_activity($album_id);
|
517 |
+
}
|
518 |
+
add_action('bp_media_album_updated','bp_media_album_activity_update');
|
519 |
+
|
520 |
+
function bp_media_album_activity_sync($media_id){
|
521 |
+
$album_id = wp_get_post_parent_id($media_id);
|
522 |
+
bp_media_update_album_activity($album_id,false,$media_id);
|
523 |
}
|
524 |
+
add_action('bp_media_after_delete_media','bp_media_album_activity_sync');
|
|
|
525 |
?>
|
includes/bp-media-admin.php
CHANGED
@@ -1,184 +1,426 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
/**
|
5 |
* Add the BuddyPress Media's options menu in the BuddyPress' options subnavigation.
|
6 |
-
*
|
7 |
* @since BP Media 2.0
|
8 |
*/
|
9 |
function bp_media_add_admin_menu() {
|
|
|
10 |
global $bp;
|
11 |
if (!is_super_admin())
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
);
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
/**
|
21 |
* Displays and updates the options menu of BuddyPress Media
|
22 |
-
*
|
23 |
* @since BP Media 2.0
|
24 |
*/
|
25 |
function bp_media_admin_menu() {
|
|
|
26 |
$bp_media_errors=array();
|
27 |
$bp_media_messages=array();
|
|
|
28 |
global $bp_media_options;
|
29 |
$bp_media_options = get_option('bp_media_options',array(
|
30 |
'videos_enabled' => true,
|
31 |
'audio_enabled' => true,
|
32 |
'images_enabled' => true,
|
33 |
));
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
<div id="icon-bp-media" class="icon32"><br></div>
|
88 |
-
<h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Media', 'bp-media' ) ); ?></h2>
|
89 |
-
<h2>BuddyPress Media Settings</h2>
|
90 |
-
<?php if(count($bp_media_errors)) { ?>
|
91 |
-
<div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div>
|
92 |
-
<?php } if(count($bp_media_messages)){?>
|
93 |
-
<div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div>
|
94 |
-
<?php }?>
|
95 |
-
<form method="post" action="?page=bp-media-settings">
|
96 |
-
<?php wp_nonce_field( 'bp_media_update_options' ); ?>
|
97 |
-
<h3>Media Types Enabled</h3>
|
98 |
-
<table class="form-table ">
|
99 |
-
<tbody>
|
100 |
-
<tr valign="top">
|
101 |
-
<th scope="row"><label for="enable_videos">Videos</label></th>
|
102 |
-
<td>
|
103 |
-
<fieldset>
|
104 |
-
<legend class="screen-reader-text"><span>Enable Videos</span></legend>
|
105 |
-
<label for="enable_videos"><input name="enable_videos" type="checkbox" id="enable_videos" value="1" <?php global $bp_media_options;checked($bp_media_options['videos_enabled'],true) ?>> (Check to enable video upload functionality)</label>
|
106 |
-
</fieldset>
|
107 |
-
</td>
|
108 |
-
</tr>
|
109 |
-
<tr valign="top">
|
110 |
-
<th scope="row"><label for="enable_audio">Audio</label></th>
|
111 |
-
<td>
|
112 |
-
<fieldset>
|
113 |
-
<legend class="screen-reader-text"><span>Enable Audio</span></legend>
|
114 |
-
<label for="enable_audio"><input name="enable_audio" type="checkbox" id="enable_audio" value="1" <?php checked($bp_media_options['audio_enabled'],true) ?>> (Check to enable audio upload functionality)</label>
|
115 |
-
</fieldset>
|
116 |
-
</td>
|
117 |
-
</tr>
|
118 |
-
<tr valign="top">
|
119 |
-
<th scope="row"><label for="enable_images">Images</label></th>
|
120 |
-
<td>
|
121 |
-
<fieldset>
|
122 |
-
<legend class="screen-reader-text"><span>Enable Images</span></legend>
|
123 |
-
<label for="enable_images"><input name="enable_images" type="checkbox" id="enable_images" value="1" <?php checked($bp_media_options['images_enabled'],true) ?>> (Check to enable images upload functionality)</label>
|
124 |
-
</fieldset>
|
125 |
-
</td>
|
126 |
-
</tr>
|
127 |
-
</tbody>
|
128 |
-
</table>
|
129 |
-
<h3>General Settings</h3>
|
130 |
-
<table class="form-table ">
|
131 |
-
<tbody>
|
132 |
-
<tr valign="top">
|
133 |
-
<th scope="row"><label for="remove_linkback">Spread the word</label></th>
|
134 |
-
<td>
|
135 |
-
<fieldset>
|
136 |
-
<legend class="screen-reader-text"><span>Yes, we support BuddyPress Media</span></legend>
|
137 |
-
<label for="remove_linkback_yes"><input name="remove_linkback" type="radio" id="remove_linkback_yes" value="2" <?php if(get_option('bp_media_remove_linkback')=='2') echo 'checked="checked"' ?>> Yes, we support BuddyPress Media</label>
|
138 |
-
<br/>
|
139 |
-
<legend class="screen-reader-text"><span>No, we don't support BuddyPress Media</span></legend>
|
140 |
-
<label for="remove_linkback_no"><input name="remove_linkback" type="radio" id="remove_linkback_no" value="1" <?php if(get_option('bp_media_remove_linkback')=='1') echo 'checked="checked"' ?>> No, we don't support BuddyPress Media</label>
|
141 |
-
</fieldset>
|
142 |
-
</td>
|
143 |
-
</tr>
|
144 |
-
</tbody>
|
145 |
-
</table>
|
146 |
-
<?php do_action('bp_media_extension_options'); ?>
|
147 |
-
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p></form>
|
148 |
-
<h3>Other Options</h3>
|
149 |
-
<table class="form-table">
|
150 |
-
<tbody>
|
151 |
-
<tr valign="top">
|
152 |
-
<th scope="row"><label for="refresh_media_count">Re-Count Media Entries</label></th>
|
153 |
-
<td> <fieldset>
|
154 |
-
<a id="refresh_media_count" href ="?page=bp-media-settings&bp_media_refresh_count=1&wp_nonce=<?php echo wp_create_nonce( 'bp_media_refresh_count' ); ?>" class="button" title="<?php printf(__('It will re-count all media entries of all users and correct any discrepancies.')); ?>">Re-Count</a>
|
155 |
-
</fieldset></td>
|
156 |
-
</tr>
|
157 |
-
</tbody>
|
158 |
-
</table>
|
159 |
-
</div>
|
160 |
-
<?php
|
161 |
}
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
/**
|
164 |
* Default BuddyPress Media admin sidebar with metabox styling
|
165 |
-
*
|
166 |
* @since BP Media 2.0
|
167 |
*/
|
168 |
-
function bp_media_default_admin_sidebar() {
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
<h3 class="hndle"><span><?php _e('Need Help?', 'bp-media'); ?></span></h3>
|
173 |
<div class="inside"><p><?php printf(__(' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
|
174 |
<a href="%s">Hire us!</a> To get professional customisation/setup service.', 'bp-media'), 'http://rtcamp.com/support/forum/buddypress-media/','http://rtcamp.com/buddypress-media/hire/'); ?>.</p></div>
|
175 |
</div>
|
176 |
|
177 |
-
<div class="postbox" id="
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
<h3 class="hndle"><span><?php _e('Premium Addons', 'bp-media'); ?></span></h3>
|
180 |
<div class="inside">
|
181 |
<ul>
|
|
|
182 |
<li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="BuddyPress Media FFMPEG">BPM-FFMPEG</a> - add FFMEG-based audio/video conversion support</li>
|
183 |
</ul>
|
184 |
<h4><?php printf(__('Are you a developer?','bp-media')) ?></h4>
|
@@ -186,81 +428,203 @@ function bp_media_default_admin_sidebar() {
|
|
186 |
</div>
|
187 |
</div>
|
188 |
|
189 |
-
<div class="postbox" id="
|
190 |
-
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
191 |
-
<h3 class="hndle"><span><?php _e('Getting Social is Good', 'bp-media'); ?></span></h3>
|
192 |
-
<div class="inside" style="text-align:center;">
|
193 |
-
<a href="<?php printf('%s', 'http://www.facebook.com/rtCamp.solutions/'); ?>" target="_blank" title="<?php _e('Become a fan on Facebook', 'bp-media'); ?>" class="bp-media-facebook bp-media-social"><?php _e('Facebook', 'bp-media'); ?></a>
|
194 |
-
<a href="<?php printf('%s', 'https://twitter.com/rtcamp/'); ?>" target="_blank" title="<?php _e('Follow us on Twitter', 'bp-media'); ?>" class="bp-media-twitter bp-media-social"><?php _e('Twitter', 'bp-media'); ?></a>
|
195 |
-
<a href="<?php printf('%s', 'http://feeds.feedburner.com/rtcamp/'); ?>" target="_blank" title="<?php _e('Subscribe to our feeds', 'bp-media'); ?>" class="bp-media-rss bp-media-social"><?php _e('RSS Feed', 'bp-media'); ?></a>
|
196 |
-
</div>
|
197 |
-
</div>
|
198 |
|
199 |
-
<div class="postbox" id="bp_media_latest_news">
|
200 |
-
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
201 |
<h3 class="hndle"><span><?php _e('Latest News', 'bp-media'); ?></span></h3>
|
202 |
<div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
|
203 |
</div><?php
|
204 |
}
|
205 |
|
|
|
|
|
206 |
/**
|
207 |
* Enqueues the scripts and stylesheets needed for the BuddyPress Media's options page
|
208 |
*/
|
209 |
function bp_media_admin_enqueue() {
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
wp_enqueue_script( 'dashboard' );
|
217 |
-
}
|
218 |
}
|
219 |
add_action('admin_enqueue_scripts', 'bp_media_admin_enqueue');
|
220 |
|
|
|
|
|
221 |
/**
|
222 |
* Adds a tab for Media settings in the BuddyPress settings page
|
|
|
|
|
223 |
*/
|
224 |
function bp_media_admin_tab() {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
|
|
238 |
add_action('bp_admin_tabs','bp_media_admin_tab');
|
239 |
|
|
|
240 |
/**
|
241 |
-
*
|
|
|
|
|
242 |
*/
|
243 |
-
function
|
244 |
-
|
245 |
-
|
246 |
-
if ( !is_super_admin() )
|
247 |
-
return false;
|
248 |
-
|
249 |
-
$page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
|
250 |
-
|
251 |
-
$hook = add_submenu_page( $page, __( 'Media', 'bp-media' ), __( 'Media', 'bp-media' ), 'manage_options', 'bp-media-settings', "bp_media_admin_menu" );
|
252 |
-
|
253 |
-
// Fudge the highlighted subnav item when on the BuddyPress Forums admin page
|
254 |
-
add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
|
255 |
}
|
256 |
-
add_action(
|
|
|
|
|
257 |
|
258 |
/**
|
259 |
-
*
|
|
|
|
|
260 |
*/
|
261 |
-
|
262 |
-
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
}
|
265 |
-
|
266 |
?>
|
1 |
<?php
|
2 |
+
if(version_compare('2.0',get_option('bp_media_db_version','1.0'),'>')){
|
3 |
+
$query = new WP_Query(array('post_type'=>'bp_media','posts_per_page'=>1));
|
4 |
+
if($query->found_posts>0)
|
5 |
+
add_action('admin_notices', 'bp_media_upgrade_db_notice');
|
6 |
+
}
|
7 |
+
|
8 |
+
add_action('wp_loaded','bp_media_upgrade_script');
|
9 |
+
function bp_media_upgrade_script(){
|
10 |
+
if(isset($_GET['bp_media_upgrade_db']) && empty($_REQUEST['settings-updated'])){
|
11 |
+
check_admin_referer('bp_media_upgrade_db','wp_nonce');
|
12 |
+
require_once('bp-media-upgrade-script.php');
|
13 |
+
bp_media_upgrade_to_2_2();
|
14 |
+
remove_action('admin_notices', 'bp_media_upgrade_db_notice');
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Displays admin notice to upgrade BuddyPress Media Database
|
21 |
+
*/
|
22 |
+
function bp_media_upgrade_db_notice() {
|
23 |
+
?>
|
24 |
+
<div class="error"><p>
|
25 |
+
Please click upgrade to upgrade the database of BuddyPress Media <a class="button" id="refresh_media_count" href ="?page=bp-media-settings&bp_media_upgrade_db=1&wp_nonce=<?php echo wp_create_nonce( 'bp_media_upgrade_db' ); ?>" class="button" title="<?php printf(__('It will migrate your BuddyPress Media\'s earlier database to new database.')); ?>">Upgrade</a>
|
26 |
+
</p></div>
|
27 |
+
<?php
|
28 |
+
}
|
29 |
+
|
30 |
/**
|
31 |
* Add the BuddyPress Media's options menu in the BuddyPress' options subnavigation.
|
32 |
+
*
|
33 |
* @since BP Media 2.0
|
34 |
*/
|
35 |
function bp_media_add_admin_menu() {
|
36 |
+
|
37 |
global $bp;
|
38 |
if (!is_super_admin())
|
39 |
+
return false;
|
40 |
+
|
41 |
+
add_menu_page( 'BP Media Component', 'BP Media', 'manage_options', 'bp-media-settings', 'bp_media_settings_page' );
|
42 |
+
add_submenu_page( 'bp-media-settings', __( 'BP-Media Settings', 'bp-media' ), __( 'Settings', 'bp-media' ), 'manage_options', 'bp-media-settings', "bp_media_settings_page" );
|
43 |
+
add_submenu_page( 'bp-media-settings', __( 'BP-Media Addons', 'bp-media' ), __( 'Addons', 'bp-media' ), 'manage_options', 'bp-media-addons', "bp_media_settings_page" );
|
44 |
+
add_submenu_page( 'bp-media-settings', __( 'BP-Media Support', 'bp-media' ), __( 'Support ', 'bp-media' ), 'manage_options', 'bp-media-support', "bp_media_settings_page" );
|
45 |
+
|
46 |
+
$tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
|
47 |
+
add_action('admin_print_styles-' . $tab, 'bp_media_admin_enqueue');
|
48 |
}
|
49 |
+
|
50 |
+
add_action(bp_core_admin_hook(), 'bp_media_add_admin_menu');
|
51 |
+
|
52 |
+
add_action('admin_init','bp_media_on_load_page');
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Applies WordPress metabox funtionality to metaboxes
|
56 |
+
*
|
57 |
+
*
|
58 |
+
*/
|
59 |
+
function bp_media_on_load_page() {
|
60 |
+
|
61 |
+
/* Javascripts loaded to allow drag/drop, expand/collapse and hide/show of boxes. */
|
62 |
+
wp_enqueue_script( 'common' );
|
63 |
+
wp_enqueue_script( 'wp-lists' );
|
64 |
+
wp_enqueue_script( 'postbox' );
|
65 |
+
|
66 |
+
// Check to see which tab we are on
|
67 |
+
$tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
|
68 |
+
|
69 |
+
switch ( $tab ) {
|
70 |
+
case 'bp-media-addons' :
|
71 |
+
// All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
72 |
+
add_meta_box('bp-media-addons-list_metabox',__('BuddyPress Media Addons for Audio/Video Conversion','bp-media'),'bp_media_addons_list','bp-media-settings', 'normal', 'core' );
|
73 |
+
break;
|
74 |
+
case 'bp-media-support' :
|
75 |
+
// All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
76 |
+
add_meta_box( 'post_summaries_options_metabox', __('BuddyPress Media Support', 'rtPanel'), 'bp_media_support', 'bp-media-settings', 'normal', 'core' );
|
77 |
+
break;
|
78 |
+
case $tab :
|
79 |
+
// All metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
|
80 |
+
add_meta_box( 'bp_media_settings_metabox', __('BuddyPress Media Settings', 'rtPanel'), 'bp_media_admin_menu', 'bp-media-settings', 'normal', 'core' );
|
81 |
+
add_meta_box( 'bp_media_options_metabox', __('Spread the word', 'rtPanel'), 'bp_media_settings_options', 'bp-media-settings', 'normal', 'core' );
|
82 |
+
add_meta_box( 'bp_media_other_options_metabox', __('BuddyPress Media Other options', 'rtPanel'), 'bp_media_settings_other_options', 'bp-media-settings', 'normal', 'core' );
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
function bp_media_settings_page(){
|
89 |
+
|
90 |
+
$tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
|
91 |
+
|
92 |
+
?>
|
93 |
+
<div class="wrap bp-media-admin">
|
94 |
+
<?php //screen_icon( 'buddypress' ); ?>
|
95 |
+
<div id="icon-buddypress" class="icon32"><br></div>
|
96 |
+
<h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Media', 'bp-media' ) ); ?></h2>
|
97 |
+
<div class="metabox-holder columns-2"><?php
|
98 |
+
|
99 |
+
if(array_key_exists('bp_media_refresh_count', $_GET) && empty($_REQUEST['settings-updated'])){
|
100 |
+
check_admin_referer('bp_media_refresh_count','wp_nonce');
|
101 |
+
if(!bp_media_update_count())
|
102 |
+
$bp_media_errors[]="Recounting Failed";
|
103 |
+
else
|
104 |
+
$bp_media_messages[]="Recounting of media files done successfully";
|
105 |
+
|
106 |
+
if(isset($bp_media_errors) && count($bp_media_errors)) { ?>
|
107 |
+
<div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div><?php
|
108 |
+
} if(isset($bp_media_messages) && count($bp_media_messages)){ ?>
|
109 |
+
<div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div><?php
|
110 |
+
}
|
111 |
+
}
|
112 |
+
else{
|
113 |
+
settings_errors();
|
114 |
+
}?>
|
115 |
+
|
116 |
+
<div class="bp-media-settings-tabs"><?php
|
117 |
+
// Check to see which tab we are on
|
118 |
+
if(current_user_can('manage_options')){
|
119 |
+
$tabs_html = '';
|
120 |
+
$idle_class = 'media-nav-tab';
|
121 |
+
$active_class = 'media-nav-tab media-nav-tab-active';
|
122 |
+
$tabs = array();
|
123 |
+
|
124 |
+
// Check to see which tab we are on
|
125 |
+
$tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
|
126 |
+
/* BP Media */
|
127 |
+
$tabs[] = array(
|
128 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
|
129 |
+
'title' => __( 'BP Media Settings', 'bp-media' ),
|
130 |
+
'name' => __( 'Settings', 'bp-media' ),
|
131 |
+
'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class. ' first_tab'
|
132 |
+
);
|
133 |
+
|
134 |
+
$tabs[] = array(
|
135 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-addons' ), 'admin.php' ) ),
|
136 |
+
'title' => __( 'BP Media Addons', 'bp-media' ),
|
137 |
+
'name' => __( 'Addons', 'bp-media' ),
|
138 |
+
'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
|
139 |
+
);
|
140 |
+
|
141 |
+
$tabs[] = array(
|
142 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-support' ), 'admin.php' ) ),
|
143 |
+
'title' => __( 'BP Media Support', 'bp-media' ),
|
144 |
+
'name' => __( 'Support', 'bp-media' ),
|
145 |
+
'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class. ' last_tab'
|
146 |
+
);
|
147 |
+
|
148 |
+
$pipe = '|' ;
|
149 |
+
$i = '1';
|
150 |
+
foreach($tabs as $tab){
|
151 |
+
if($i!=1) $tabs_html.=$pipe;
|
152 |
+
$tabs_html.= '<a title=""' . $tab['title'] . '" " href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
|
153 |
+
$i++;
|
154 |
+
}
|
155 |
+
echo $tabs_html;
|
156 |
+
}?>
|
157 |
+
</div>
|
158 |
+
|
159 |
+
<div id="bp-media-settings-boxes">
|
160 |
+
|
161 |
+
<form id="bp_media_settings_form" name="bp_media_settings_form" action="options.php" method="post" enctype="multipart/form-data">
|
162 |
+
<?php
|
163 |
+
|
164 |
+
settings_fields( 'bp_media_options_settings');
|
165 |
+
do_settings_fields( 'bp_media_options_settings','' );
|
166 |
+
do_meta_boxes( 'bp-media-settings', 'normal', '' ); ?>
|
167 |
+
|
168 |
+
<script type="text/javascript">
|
169 |
+
//<![CDATA[
|
170 |
+
jQuery(document).ready( function($) {
|
171 |
+
// close postboxes that should be closed
|
172 |
+
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
173 |
+
// postboxes setup
|
174 |
+
postboxes.add_postbox_toggles('bp-media-settings');
|
175 |
+
});
|
176 |
+
//]]>
|
177 |
+
</script>
|
178 |
+
</form>
|
179 |
+
</div><!-- .bp-media-settings-boxes -->
|
180 |
+
<div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
|
181 |
+
<?php bp_media_default_admin_sidebar(); ?>
|
182 |
+
</div>
|
183 |
+
</div><!-- .metabox-holder -->
|
184 |
+
</div><!-- .bp-media-admin --><?php
|
185 |
+
}
|
186 |
+
|
187 |
|
188 |
/**
|
189 |
* Displays and updates the options menu of BuddyPress Media
|
190 |
+
*
|
191 |
* @since BP Media 2.0
|
192 |
*/
|
193 |
function bp_media_admin_menu() {
|
194 |
+
|
195 |
$bp_media_errors=array();
|
196 |
$bp_media_messages=array();
|
197 |
+
|
198 |
global $bp_media_options;
|
199 |
$bp_media_options = get_option('bp_media_options',array(
|
200 |
'videos_enabled' => true,
|
201 |
'audio_enabled' => true,
|
202 |
'images_enabled' => true,
|
203 |
));
|
204 |
+
|
205 |
+
$bp_media_options = get_option('bp_media_options');?>
|
206 |
+
|
207 |
+
<?php if(count($bp_media_errors)) { ?>
|
208 |
+
<div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div>
|
209 |
+
<?php } if(count($bp_media_messages)){ ?>
|
210 |
+
<div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div>
|
211 |
+
<?php } ?>
|
212 |
+
<table class="form-table ">
|
213 |
+
<tbody>
|
214 |
+
<tr valign="top">
|
215 |
+
<th scope="row"><label for="enable_videos">Videos</label></th>
|
216 |
+
<td>
|
217 |
+
<fieldset>
|
218 |
+
<legend class="screen-reader-text"><span>Enable Videos</span></legend>
|
219 |
+
<label for="videos_enabled"><input name="bp_media_options[videos_enabled]" type="checkbox" id="videos_enabled" value="1" <?php global $bp_media_options;checked($bp_media_options['videos_enabled'],true) ?>> (Check to enable video upload functionality)</label>
|
220 |
+
</fieldset>
|
221 |
+
</td>
|
222 |
+
</tr>
|
223 |
+
<tr valign="top">
|
224 |
+
<th scope="row"><label for="enable_audio">Audio</label></th>
|
225 |
+
<td>
|
226 |
+
<fieldset>
|
227 |
+
<legend class="screen-reader-text"><span>Enable Audio</span></legend>
|
228 |
+
<label for="audio_enabled"><input name="bp_media_options[audio_enabled]" type="checkbox" id="audio_enabled" value="1" <?php checked($bp_media_options['audio_enabled'],true) ?>> (Check to enable audio upload functionality)</label>
|
229 |
+
</fieldset>
|
230 |
+
</td>
|
231 |
+
</tr>
|
232 |
+
<tr valign="top">
|
233 |
+
<th scope="row"><label for="enable_images">Images</label></th>
|
234 |
+
<td>
|
235 |
+
<fieldset>
|
236 |
+
<legend class="screen-reader-text"><span>Enable Images</span></legend>
|
237 |
+
<label for="images_enabled"><input name="bp_media_options[images_enabled]" type="checkbox" id="images_enabled" value="1" <?php checked($bp_media_options['images_enabled'],true) ?>> (Check to enable images upload functionality)</label>
|
238 |
+
</fieldset>
|
239 |
+
</td>
|
240 |
+
</tr>
|
241 |
+
<tr valign="top">
|
242 |
+
<th scope="row"><label for="download_enabled">Download</label></th>
|
243 |
+
<td>
|
244 |
+
<fieldset>
|
245 |
+
<legend class="screen-reader-text"><span>Enable Download</span></legend>
|
246 |
+
<label for="download_enabled"><input name="bp_media_options[download_enabled]" type="checkbox" id="download_enabled" value="1" <?php checked($bp_media_options['download_enabled'],true) ?>> (Check to enable download functionality)</label>
|
247 |
+
</fieldset>
|
248 |
+
</td>
|
249 |
+
</tr>
|
250 |
+
</tbody>
|
251 |
+
</table>
|
252 |
+
|
253 |
+
<?php do_action('bp_media_extension_options'); ?>
|
254 |
+
|
255 |
+
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p>
|
256 |
+
<div class="clear"></div><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
+
function bp_media_settings_other_options(){ ?>
|
260 |
+
|
261 |
+
<table class="form-table">
|
262 |
+
<tbody>
|
263 |
+
<tr valign="top">
|
264 |
+
<th scope="row"><label for="refresh_media_count">Re-Count Media Entries</label></th>
|
265 |
+
<td> <fieldset>
|
266 |
+
<a id="refresh_media_count" href ="?page=bp-media-settings&bp_media_refresh_count=1&wp_nonce=<?php echo wp_create_nonce( 'bp_media_refresh_count' ); ?>" class="button" title="<?php printf(__('It will re-count all media entries of all users and correct any discrepancies.')); ?>">Re-Count</a>
|
267 |
+
</fieldset>
|
268 |
+
</td>
|
269 |
+
</tr>
|
270 |
+
</tbody>
|
271 |
+
</table>
|
272 |
+
<div class="clear"></div>
|
273 |
+
|
274 |
+
<?php }
|
275 |
+
|
276 |
+
function bp_media_settings_options(){
|
277 |
+
$bp_media_options = get_option('bp_media_options');
|
278 |
+
?>
|
279 |
+
<table class="form-table ">
|
280 |
+
<tbody>
|
281 |
+
<tr valign="top">
|
282 |
+
<th scope="row"><label for="remove_linkback">Spread the word</label></th>
|
283 |
+
<td>
|
284 |
+
<fieldset>
|
285 |
+
<legend class="screen-reader-text"><span>Yes, I want to support BuddyPress Media</span></legend>
|
286 |
+
<label for="remove_linkback_yes"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_yes" value="2" <?php checked($bp_media_options['remove_linkback'], '2' ); ?>> Yes, I support BuddyPress Media</label>
|
287 |
+
<br/>
|
288 |
+
<legend class="screen-reader-text"><span>No, I don't want to support BuddyPress Media</span></legend>
|
289 |
+
<label for="remove_linkback_no"><input name="bp_media_options[remove_linkback]" type="radio" id="remove_linkback_no" value="1" <?php checked($bp_media_options['remove_linkback'], '1' ); ?>> No, I don't support BuddyPress Media</label>
|
290 |
+
</fieldset>
|
291 |
+
</td>
|
292 |
+
</tr>
|
293 |
+
</tbody>
|
294 |
+
</table>
|
295 |
+
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p>
|
296 |
+
<div class="clear"></div>
|
297 |
+
<?php }
|
298 |
+
|
299 |
+
|
300 |
+
|
301 |
+
|
302 |
+
function bp_media_addons_list(){ ?>
|
303 |
+
|
304 |
+
<div class="addon-list">
|
305 |
+
<ul class="products">
|
306 |
+
|
307 |
+
<li class="product first">
|
308 |
+
<a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">
|
309 |
+
<img width="240" height="184" title="BuddyPress - Media Kaltura Add-on" alt="BuddyPress - Media Kaltura Add-on" src="http://cdn.rtcamp.com/files/2012/10/new-buddypress-media-kaltura-logo-240x184.png">
|
310 |
+
</a>
|
311 |
+
<h4><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress - Media Kaltura Add-on">BuddyPress-Media Kaltura Add-on</a></h4>
|
312 |
+
<div class="product_desc">
|
313 |
+
<p>Add support for more video formats using Kaltura video solution.</p>
|
314 |
+
<p>Works with Kaltura.com, self-hosted Kaltura-CE and Kaltura-on-premise.</p>
|
315 |
+
</div>
|
316 |
+
<div class="product_footer">
|
317 |
+
<span class="price alignleft"><span class="amount">$99</span></span>
|
318 |
+
<a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=15446"><?php _e('Buy Now', 'bp-media'); ?></a>
|
319 |
+
<a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-kaltura/" title="BuddyPress Media Kaltura Add-on">Live Demo</a>
|
320 |
+
</div><!-- .product_footer -->
|
321 |
+
</li>
|
322 |
+
<li class="product last">
|
323 |
+
<a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >
|
324 |
+
<img width="240" height="184" title="BuddyPress-Media FFMPEG Converter Plugin" alt="BuddyPress-Media FFMPEG Converter Plugin" src="http://cdn.rtcamp.com/files/2012/09/ffmpeg-logo-240x184.png">
|
325 |
+
</a>
|
326 |
+
<h4><a href="http://rtcamp.com/store/buddypress-media-ffmpeg-converter/" title="BuddyPress-Media FFMPEG Converter Plugin" >BuddyPress-Media FFMPEG Add-on</a></h4>
|
327 |
+
<div class="product_desc">
|
328 |
+
<p>Add supports for more audio & video formats using open-source <a href="https://github.com/rtCamp/media-node">media-node</a>.</p>
|
329 |
+
<p>Media node comes with automated setup script for Ubuntu/Debian.</p>
|
330 |
+
</div>
|
331 |
+
<div class="product_footer">
|
332 |
+
<span class="price alignleft"><span class="amount">$49</span></span>
|
333 |
+
<a class="add_to_cart_button alignright product_type_simple" href="http://rtcamp.com/store/?add-to-cart=13677"><?php _e('Buy Now', 'bp-media'); ?></a>
|
334 |
+
<a class="alignleft product_demo_link" href="http://demo.rtcamp.com/bpm-media" title="BuddyPress Media FFMPEG Add-on">Live Demo</a>
|
335 |
+
</div><!-- .product_footer -->
|
336 |
+
</li>
|
337 |
+
|
338 |
+
</ul><!-- .products -->
|
339 |
+
</div><!-- .addon-list -->
|
340 |
+
|
341 |
+
<?php }
|
342 |
+
|
343 |
+
|
344 |
+
function bp_media_support(){ global $current_user; ?>
|
345 |
+
|
346 |
+
<div class="bp-media-support">
|
347 |
+
<h2><?php _e('Need Help/Support?', 'bp-media');?></h2>
|
348 |
+
<ul class="support_list">
|
349 |
+
<li><a href="http://rtcamp.com/buddypress-media/faq/" title="<?php _e('Read FAQ', 'bp-media');?>"><?php _e('Read FAQ', 'bp-media');?></a> </li>
|
350 |
+
<li><a href="http://rtcamp.com/support/forum/buddypress-media/" title="<?php _e('Free Support Forum', 'bp-media');?>"><?php _e('Free Support Forum', 'bp-media');?></a></li>
|
351 |
+
<li><a href="https://github.com/rtCamp/buddypress-media/issues/" title="<?php _e('Github Issue Tracker', 'bp-media');?>"><?php _e('Github Issue Tracker', 'bp-media');?> </a> </li>
|
352 |
+
</ul>
|
353 |
+
<br/>
|
354 |
+
|
355 |
+
<h2><?php _e('Hire Us!', 'bp-media');?></h2>
|
356 |
+
|
357 |
+
<h4><a href="http://rtcamp.com/contact/?purpose=hire"><?php _e('We are available for customisation and premium support. Get on touch with us. :-)', 'bp-media');?></a></h4>
|
358 |
+
<!--
|
359 |
+
<div class="bp-media-form" id="premium-support-form" >
|
360 |
+
<h4><?php _e('Please fill the form for premium support'); ?></h4>
|
361 |
+
<ul>
|
362 |
+
<li>
|
363 |
+
<label class="bp-media-label" for="ur_name"><?php _e('Your Name:','bp-media');?></label><input class="bp-media-input" id="ur_name" type="text" name="premium_support[ur_name]" value="<?php echo (isset($_REQUEST['premium_support']['ur_name']))? $_REQUEST['premium_support']['ur_name'] : $current_user->user_login; ?>"/>
|
364 |
+
</li>
|
365 |
+
<li>
|
366 |
+
<label class="bp-media-label" for="ur_email"><?php _e('Your Email-Id:','bp-media');?></label><input id="ur_email" class="bp-media-input" type="text" name="premium_support[ur_email]" value="<?php echo (isset($_REQUEST['premium_support']['ur_name']))? $_REQUEST['premium_support']['ur_name'] : get_option('admin_email'); ?>"/>
|
367 |
+
</li>
|
368 |
+
<li>
|
369 |
+
<label class="bp-media-label" for="ur_query"><?php _e('Details:','bp-media');?></label><textarea id="ur_query" class="bp-media-textarea" type="text" name="premium_support[ur_query]"/><?php echo (isset($_REQUEST['premium_support']['ur_query']))? $_REQUEST['premium_support']['ur_query'] : ''; ?></textarea>
|
370 |
+
</li>
|
371 |
+
<li>
|
372 |
+
<label class="bp-media-label" for="ur_budget"><?php _e('Your Budget:','bp-media');?></label><input id="ur_budget" class="bp-media-input" type="text" name="premium_support[ur_budget]" value="<?php echo (isset($_REQUEST['premium_support']['ur_budget']))? $_REQUEST['premium_support']['ur_budget'] : ''; ?>"/>
|
373 |
+
</li>
|
374 |
+
<li>
|
375 |
+
<label class="bp-media-label" for="ur_delivery_date"><?php _e('Expected Delivery Date:','bp-media');?></label><input id="ur_delivery_date" class="bp-media-input" type="text" name="premium_support[ur_delivery_date]" value="<?php echo (isset($_REQUEST['premium_support']['ur_delivery_date']))? $_REQUEST['premium_support']['ur_delivery_date'] : ''; ?>"/>
|
376 |
+
</li>
|
377 |
+
</ul>
|
378 |
+
<p class="submit"><input type="submit" name="premium_form_submit" id="submit" class="button-primary" value="Submit"></p>
|
379 |
+
</div><!-- .premium-support-form-->
|
380 |
+
<br/>
|
381 |
+
</div>
|
382 |
+
|
383 |
+
<?php }
|
384 |
+
|
385 |
+
|
386 |
/**
|
387 |
* Default BuddyPress Media admin sidebar with metabox styling
|
388 |
+
*
|
389 |
* @since BP Media 2.0
|
390 |
*/
|
391 |
+
function bp_media_default_admin_sidebar() { ?>
|
392 |
+
|
393 |
+
<div class="rtmetabox postbox" id="branding">
|
394 |
+
<div class="inside">
|
395 |
+
<a href="http://rtcamp.com" title="Empowering The Web With WordPress" id="logo"><img src="<?php echo plugins_url( '/img/rtcamp-logo.png', __FILE__ ); ?>" alt="rtCamp" /></a>
|
396 |
+
<ul id="social">
|
397 |
+
<li><a href="<?php printf('%s', 'http://www.facebook.com/rtCamp.solutions/'); ?>" title="<?php _e('Become a fan on Facebook', 'bp-media'); ?>" class="bp-media-facebook bp-media-social"><?php _e('Facebook', 'bp-media'); ?></a></li>
|
398 |
+
<li><a href="<?php printf('%s', 'https://twitter.com/rtcamp/'); ?>" title="<?php _e('Follow us on Twitter', 'bp-media'); ?>" class="bp-media-twitter bp-media-social"><?php _e('Twitter', 'bp-media'); ?></a></li>
|
399 |
+
<li><a href="<?php printf('%s', 'http://feeds.feedburner.com/rtcamp/'); ?>" title="<?php _e('Subscribe to our feeds', 'bp-media'); ?>" class="bp-media-rss bp-media-social"><?php _e('RSS Feed', 'bp-media'); ?></a></li>
|
400 |
+
</ul>
|
401 |
+
</div>
|
402 |
+
</div>
|
403 |
+
|
404 |
+
<div class="rtmetabox postbox" id="support">
|
405 |
+
|
406 |
<h3 class="hndle"><span><?php _e('Need Help?', 'bp-media'); ?></span></h3>
|
407 |
<div class="inside"><p><?php printf(__(' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
|
408 |
<a href="%s">Hire us!</a> To get professional customisation/setup service.', 'bp-media'), 'http://rtcamp.com/support/forum/buddypress-media/','http://rtcamp.com/buddypress-media/hire/'); ?>.</p></div>
|
409 |
</div>
|
410 |
|
411 |
+
<div class="rtmetabox postbox" id="donate">
|
412 |
+
|
413 |
+
<h3 class="hndle"><span><?php _e('Donate', 'bp-media'); ?></span></h3>
|
414 |
+
<span><a href="http://rtcamp.com/donate/" title="Help the development keep going."><img class="bp-media-donation-image" src ="<?php echo plugins_url( '/img/donate.gif', __FILE__ ); ?>" /></a></span>
|
415 |
+
<div class="inside"><p><?php printf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', 'bp-media')); ?>.</p></div>
|
416 |
+
</div>
|
417 |
+
|
418 |
+
<div class="rtmetabox postbox" id="bp-media-premium-addons">
|
419 |
+
|
420 |
<h3 class="hndle"><span><?php _e('Premium Addons', 'bp-media'); ?></span></h3>
|
421 |
<div class="inside">
|
422 |
<ul>
|
423 |
+
<li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="BuddyPress Media Kaltura">BPM-Kaltura</a> - add support for Kaltura.com/Kaltura-CE based video conversion support</li>
|
424 |
<li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="BuddyPress Media FFMPEG">BPM-FFMPEG</a> - add FFMEG-based audio/video conversion support</li>
|
425 |
</ul>
|
426 |
<h4><?php printf(__('Are you a developer?','bp-media')) ?></h4>
|
428 |
</div>
|
429 |
</div>
|
430 |
|
431 |
+
<div class="rtmetabox postbox" id="bp_media_latest_news">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
|
|
|
|
|
433 |
<h3 class="hndle"><span><?php _e('Latest News', 'bp-media'); ?></span></h3>
|
434 |
<div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
|
435 |
</div><?php
|
436 |
}
|
437 |
|
438 |
+
|
439 |
+
|
440 |
/**
|
441 |
* Enqueues the scripts and stylesheets needed for the BuddyPress Media's options page
|
442 |
*/
|
443 |
function bp_media_admin_enqueue() {
|
444 |
+
$current_screen = get_current_screen();
|
445 |
+
$admin_js = trailingslashit(site_url()).'?bp_media_get_feeds=1';
|
446 |
+
wp_enqueue_script('bp-media-js',plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
447 |
+
wp_localize_script('bp-media-js','bp_media_news_url',$admin_js);
|
448 |
+
wp_enqueue_style('bp-media-admin-style', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
|
449 |
+
|
|
|
|
|
450 |
}
|
451 |
add_action('admin_enqueue_scripts', 'bp_media_admin_enqueue');
|
452 |
|
453 |
+
|
454 |
+
|
455 |
/**
|
456 |
* Adds a tab for Media settings in the BuddyPress settings page
|
457 |
+
*
|
458 |
+
*
|
459 |
*/
|
460 |
function bp_media_admin_tab() {
|
461 |
+
|
462 |
+
if(current_user_can('manage_options')){
|
463 |
+
$tabs_html = '';
|
464 |
+
$idle_class = 'nav-tab';
|
465 |
+
$active_class = 'nav-tab nav-tab-active';
|
466 |
+
$tabs = array();
|
467 |
+
|
468 |
+
// Check to see which tab we are on
|
469 |
+
$tab = isset( $_GET['page'] ) ? $_GET['page'] : "bp-media-settings";
|
470 |
+
/* BP Media */
|
471 |
+
$tabs[] = array(
|
472 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
|
473 |
+
'title' => __( 'BP Media', 'bp-media' ),
|
474 |
+
'name' => __( 'BP Media', 'bp-media' ),
|
475 |
+
'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
|
476 |
+
);
|
477 |
+
|
478 |
+
foreach($tabs as $tab){
|
479 |
+
$tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
|
480 |
+
}
|
481 |
+
echo $tabs_html;
|
482 |
+
}
|
483 |
}
|
484 |
+
|
485 |
add_action('bp_admin_tabs','bp_media_admin_tab');
|
486 |
|
487 |
+
|
488 |
/**
|
489 |
+
* Registers BP Media Settings options
|
490 |
+
*
|
491 |
+
*
|
492 |
*/
|
493 |
+
function bp_media_admin_init_settings() {
|
494 |
+
register_setting( 'bp_media_options_settings', 'bp_media_options', 'bp_media_validate' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
}
|
496 |
+
add_action( 'admin_init', 'bp_media_admin_init_settings',1 );
|
497 |
+
|
498 |
+
|
499 |
|
500 |
/**
|
501 |
+
* Validate bp_media_settings options
|
502 |
+
*
|
503 |
+
* @param type $input Validate
|
504 |
*/
|
505 |
+
|
506 |
+
function bp_media_validate( $input ){
|
507 |
+
|
508 |
+
if(isset($_REQUEST['premium_form_submit'])){
|
509 |
+
$input = get_option('bp_media_options');
|
510 |
+
if(empty($_REQUEST['premium_support']['ur_name'])){
|
511 |
+
add_settings_error( 'enquire_name', 'enquire_name', __( 'Please enter your name', 'rtPanel' ), 'error' );
|
512 |
+
}
|
513 |
+
else if(empty($_REQUEST['premium_support']['ur_email']) || !is_email($_REQUEST['premium_support']['ur_email'])){
|
514 |
+
add_settings_error( 'enquire_name', 'enquire_name', __( 'Please enter valid email-Id', 'rtPanel' ), 'error' );
|
515 |
+
}
|
516 |
+
else{
|
517 |
+
$send_array = array();
|
518 |
+
$body = '';
|
519 |
+
$body = '<p>Name : '. esc_attr(trim($_REQUEST['premium_support']['ur_name'])).'</p>';
|
520 |
+
$body .= '<p>Email Id : '.esc_attr(trim($_REQUEST['premium_support']['ur_email'])).'</p>';
|
521 |
+
if(!empty($_REQUEST['premium_support']['ur_query'])) $body .= '<p>Query : '.esc_attr(trim($_REQUEST['premium_support']['ur_query'])).'</p>';
|
522 |
+
if(!empty($_REQUEST['premium_support']['ur_budget'])) $body .= '<p>Budget : '.esc_attr(trim($_REQUEST['premium_support']['ur_budget'])).'</p>';
|
523 |
+
if(!empty($_REQUEST['premium_support']['ur_delivery_date'])) $body .= '<p>Expected Delivery Date : '.esc_attr(trim($_REQUEST['premium_support']['ur_delivery_date'])).'</p>';
|
524 |
+
$send_array['task[body]'] = $body;
|
525 |
+
$send_array['ur_name'] = $_REQUEST['premium_support']['ur_name'];
|
526 |
+
|
527 |
+
$return = bp_media_send_enquiry($send_array);
|
528 |
+
|
529 |
+
if(!empty($return))
|
530 |
+
add_settings_error( 'form_submitted', 'form_submitted', __( 'Thanks for contacting us. We will get in touch with you soon.', 'rtPanel' ), 'updated' );
|
531 |
+
else
|
532 |
+
add_settings_error( 'form_submitted', 'form_submitted', __( 'Sorry, your enquiry is not submitted', 'rtPanel' ), 'error' );
|
533 |
+
}
|
534 |
+
|
535 |
+
}else if(isset($_REQUEST['submit'])){
|
536 |
+
|
537 |
+
if(array_key_exists('remove_linkback', $_POST)){
|
538 |
+
if($input['remove_linkback']=='2'){
|
539 |
+
update_option('bp_media_remove_linkback', '2');
|
540 |
+
}
|
541 |
+
else {
|
542 |
+
update_option('bp_media_remove_linkback', '1');
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
if(isset($input['videos_enabled'])){
|
547 |
+
$input['videos_enabled'] = true;}
|
548 |
+
else{
|
549 |
+
$input['videos_enabled'] = false;}
|
550 |
+
if(isset($input['audio_enabled'])){
|
551 |
+
$input['audio_enabled'] = true;}
|
552 |
+
else{
|
553 |
+
$input['audio_enabled'] = false;}
|
554 |
+
if(isset($input['images_enabled'])){
|
555 |
+
$input['images_enabled'] = true;}
|
556 |
+
else{
|
557 |
+
$input['images_enabled'] = false;}
|
558 |
+
|
559 |
+
if(isset($input['download_enabled'])){
|
560 |
+
$input['download_enabled'] = true;}
|
561 |
+
else{
|
562 |
+
$input['download_enabled'] = false;}
|
563 |
+
}
|
564 |
+
|
565 |
+
return $input;
|
566 |
+
}
|
567 |
+
|
568 |
+
|
569 |
+
function bp_media_send_enquiry($new_ticket){
|
570 |
+
|
571 |
+
$bp_media_request_activecollab = new bp_media_request_activecollab();
|
572 |
+
|
573 |
+
/* Set Enquiry Name */
|
574 |
+
$task_name = !empty($new_ticket['ur_name']) ? __('New Premium Request from','bp-media').' '. $new_ticket['ur_name'] : __('New Premium Request','bp-media');
|
575 |
+
|
576 |
+
$defaults = array( 'task[name]' => $task_name,
|
577 |
+
'task[body]' => '',
|
578 |
+
'task[label_id]' => BP_MEDIA_AC_API_LABEL_ID,
|
579 |
+
'task[priority]' => BP_MEDIA_AC_API_PRIORITY,
|
580 |
+
'task[assignee_id]' => BP_MEDIA_AC_API_ASSIGNEE_ID,
|
581 |
+
'task[category_id]' => BP_MEDIA_AC_API_CATEGORY_ID,
|
582 |
+
'submitted' => 'submitted' );
|
583 |
+
/* merge default array */
|
584 |
+
$new_ticket = wp_parse_args( $new_ticket, $defaults );
|
585 |
+
|
586 |
+
/* send form submit request to active collabe */
|
587 |
+
$result = $bp_media_request_activecollab->send_ticket($new_ticket);
|
588 |
+
|
589 |
+
return $result;
|
590 |
+
}
|
591 |
+
|
592 |
+
|
593 |
+
class bp_media_request_activecollab{
|
594 |
+
|
595 |
+
//ActiveCollab API variables
|
596 |
+
|
597 |
+
var $acollab_projid = BP_MEDIA_AC_API_PROJECT_ID; //The project ID we want to add a ticket to. You can find this in the URL of the project when you enter it. ex: /projects/16/ - 16 is the ID
|
598 |
+
var $acollab_token = BP_MEDIA_AC_API_AUTH_TOKEN; // API token. Different for each ActiveCollab user. Create a user fo the API, then grab the API Token under User Profile > Settings
|
599 |
+
var $acollab_url = BP_MEDIA_AC_API_URL; // Find it in the same place you find your API token.
|
600 |
+
|
601 |
+
// Errors
|
602 |
+
var $errorMsg = "";
|
603 |
+
|
604 |
+
|
605 |
+
function send_ticket($request){
|
606 |
+
|
607 |
+
$api_url = $this->acollab_url . '?path_info=projects/buddypress-media/tasks/add&auth_api_token='.$this->acollab_token;
|
608 |
+
/* Send it */
|
609 |
+
|
610 |
+
$ch = curl_init();
|
611 |
+
|
612 |
+
// ActivCollab wants the pathinfo and token in the URL, not in the POST info.
|
613 |
+
|
614 |
+
curl_setopt($ch, CURLOPT_URL, $api_url);
|
615 |
+
curl_setopt($ch, CURLOPT_POST,1);
|
616 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
617 |
+
|
618 |
+
// The POST data
|
619 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
620 |
+
|
621 |
+
$result = curl_exec($ch);
|
622 |
+
|
623 |
+
curl_close($ch);
|
624 |
+
|
625 |
+
return $result;
|
626 |
+
|
627 |
+
}
|
628 |
}
|
629 |
+
|
630 |
?>
|
includes/bp-media-class-album.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BP_Media_Album{
|
4 |
+
private $id,
|
5 |
+
$name,
|
6 |
+
$description,
|
7 |
+
$url,
|
8 |
+
$owner,
|
9 |
+
$delete_url,
|
10 |
+
$thumbnail,
|
11 |
+
$edit_url,
|
12 |
+
$media_entries;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Constructs a new BP_Media_Album
|
16 |
+
*
|
17 |
+
* @param mixed $album_id optional Album ID of the element to be initialized if not defined, returns an empty element.
|
18 |
+
*
|
19 |
+
* @since BP Media 2.2
|
20 |
+
*/
|
21 |
+
function __construct($album_id = '') {
|
22 |
+
if (!$album_id == '') {
|
23 |
+
$this->init($album_id);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initializes the object
|
29 |
+
*
|
30 |
+
* @param mixed $album_id Album ID of the element to be initialized. Can be the ID or the object of the Album
|
31 |
+
*
|
32 |
+
* @since BP Media 2.2
|
33 |
+
*/
|
34 |
+
function init($album_id){
|
35 |
+
if (is_object($album_id)) {
|
36 |
+
$album = $album_id;
|
37 |
+
} else {
|
38 |
+
$album = &get_post($album_id);
|
39 |
+
}
|
40 |
+
if (empty($album->ID))
|
41 |
+
throw new Exception(__('Sorry, the requested album does not exist.', 'bp-media'));
|
42 |
+
$this->id = $album->ID;
|
43 |
+
$this->description = $album->post_content;
|
44 |
+
$this->name = $album->post_title;
|
45 |
+
$this->owner = $album->post_author;
|
46 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
47 |
+
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
48 |
+
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
49 |
+
if(has_post_thumbnail($this->id)){
|
50 |
+
$this->thumbnail = get_the_post_thumbnail($this->id, 'thumbnail');
|
51 |
+
}
|
52 |
+
else{
|
53 |
+
$this->thumbnail = '<img src = '.plugins_url('img/image_thumb.png', __FILE__) .' />';
|
54 |
+
}
|
55 |
+
$this->media_entries = get_children(array(
|
56 |
+
'post_parent' => $this->id,
|
57 |
+
'post_type' => 'attachment'
|
58 |
+
));
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Adds a new album and initializes the object with the new album
|
63 |
+
*
|
64 |
+
* @param string $title The title of the album.
|
65 |
+
* @param string $author_id Optional The author id, defaults to zero in which case takes the logged in user id.
|
66 |
+
* @param string $group_id Optional The group id to which the album belongs, defaults to 0 meaning its not attached with a group.
|
67 |
+
*
|
68 |
+
* @since BP Media 2.2
|
69 |
+
*/
|
70 |
+
function add_album($title,$author_id = 0, $group_id = 0){
|
71 |
+
do_action('bp_media_before_add_album');
|
72 |
+
$author_id = $author_id?$author_id:get_current_user_id();
|
73 |
+
$post_vars = array(
|
74 |
+
'post_title' => $title,
|
75 |
+
'post_name' => $title,
|
76 |
+
'post_status'=> 'publish',
|
77 |
+
'post_type' => 'bp_media_album',
|
78 |
+
'post_author'=> $author_id
|
79 |
+
);
|
80 |
+
bp_media_init_count($author_id);
|
81 |
+
global $bp_media_count;
|
82 |
+
$album_id = wp_insert_post($post_vars);
|
83 |
+
if($group_id){
|
84 |
+
add_post_meta($album_id, 'bp-media-key', (-$group_id));
|
85 |
+
}
|
86 |
+
else{
|
87 |
+
add_post_meta($album_id, 'bp-media-key', $author_id);
|
88 |
+
}
|
89 |
+
$this->init($album_id);
|
90 |
+
$bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) + 1;
|
91 |
+
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
92 |
+
do_action('bp_media_after_add_album',$this);
|
93 |
+
return $album_id;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Deletes the album and all associated attachments
|
98 |
+
*
|
99 |
+
* @since BP Media 2.2
|
100 |
+
*/
|
101 |
+
function delete_album(){
|
102 |
+
do_action('bp_media_before_delete_album', $this);
|
103 |
+
foreach($this->media_entries as $entry){
|
104 |
+
wp_delete_attachment($entry->ID,true);
|
105 |
+
}
|
106 |
+
$author_id = $this->owner;
|
107 |
+
bp_media_init_count($author_id);
|
108 |
+
wp_delete_post($this->id,true);
|
109 |
+
global $bp_media_count;
|
110 |
+
$bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) - 1;
|
111 |
+
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
112 |
+
do_action('bp_media_after_delete_album', $this);
|
113 |
+
}
|
114 |
+
|
115 |
+
function edit_album($title=''){
|
116 |
+
do_action('bp_media_before_edit_album',$this);
|
117 |
+
if($title==''){
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
else{
|
121 |
+
$this->name = $title;
|
122 |
+
$args = array(
|
123 |
+
'ID' => $this->id,
|
124 |
+
'post_title'=>$this->name
|
125 |
+
);
|
126 |
+
$status = wp_insert_post($args);
|
127 |
+
if(get_class($status)=='WP_Error'||$status==0){
|
128 |
+
return false;
|
129 |
+
}
|
130 |
+
else{
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
do_action('bp_media_after_edit_album',$this);
|
135 |
+
}
|
136 |
+
|
137 |
+
function get_album_gallery_content(){
|
138 |
+
?><li>
|
139 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
140 |
+
<?php echo $this->thumbnail; ?>
|
141 |
+
</a>
|
142 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
143 |
+
</li><?php
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Returns the attachments linked with the albume
|
148 |
+
*
|
149 |
+
* @since BP Media 2.2
|
150 |
+
*/
|
151 |
+
function get_entries(){
|
152 |
+
return $this->media_entries;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Returns the title of the album
|
157 |
+
*
|
158 |
+
* @since BP Media 2.2
|
159 |
+
*/
|
160 |
+
function get_title(){
|
161 |
+
return $this->name;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Echoes the title of the album
|
166 |
+
*
|
167 |
+
* @since BP Media 2.2
|
168 |
+
*/
|
169 |
+
function the_title(){
|
170 |
+
echo $this->name;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Returns the id of the album
|
175 |
+
*
|
176 |
+
* @since BP Media 2.2
|
177 |
+
*/
|
178 |
+
function get_id(){
|
179 |
+
return $this->id;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Returns the url of the album
|
184 |
+
*
|
185 |
+
* @since BP Media 2.2
|
186 |
+
*/
|
187 |
+
function get_url(){
|
188 |
+
return $this->url;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Returns the owner's id
|
193 |
+
*
|
194 |
+
* @since BP Media 2.2
|
195 |
+
*/
|
196 |
+
function get_owner(){
|
197 |
+
return $this->owner;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
?>
|
includes/bp-media-class-wordpress.php
CHANGED
@@ -10,16 +10,16 @@ class BP_Media_Host_Wordpress {
|
|
10 |
$url, //URL of the entry
|
11 |
$type, //Type of the entry (Video, Image or Audio)
|
12 |
$owner, //Owner of the entry
|
13 |
-
$attachment_id, //The attachment ID of the media file
|
14 |
$delete_url, //The delete url for the media
|
15 |
-
$thumbnail_id, //The thumbnail's
|
|
|
16 |
$edit_url; //The edit page's url for the media
|
17 |
-
|
18 |
/**
|
19 |
* Constructs a new BP_Media_Host_Wordpress element
|
20 |
-
*
|
21 |
* @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
|
22 |
-
*
|
23 |
* @since BP Media 2.0
|
24 |
*/
|
25 |
function __construct($media_id = '') {
|
@@ -30,9 +30,9 @@ class BP_Media_Host_Wordpress {
|
|
30 |
|
31 |
/**
|
32 |
* Initializes the object with the variables from the post
|
33 |
-
*
|
34 |
* @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
|
35 |
-
*
|
36 |
* @since BP Media 2.0
|
37 |
*/
|
38 |
function init($media_id = '') {
|
@@ -47,27 +47,31 @@ class BP_Media_Host_Wordpress {
|
|
47 |
$this->description = $media->post_content;
|
48 |
$this->name = $media->post_title;
|
49 |
$this->owner = $media->post_author;
|
50 |
-
$this->
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
switch ($this->type) {
|
53 |
case 'video' :
|
54 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' .
|
55 |
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_EDIT_SLUG . '/' . $this->id);
|
56 |
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
57 |
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
58 |
break;
|
59 |
case 'audio' :
|
60 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' .
|
61 |
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_EDIT_SLUG . '/' . $this->id);
|
62 |
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
63 |
$this->thumbnail_id = get_post_meta($this->id, 'bp_media_thumbnail',true);
|
64 |
break;
|
65 |
case 'image' :
|
66 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' .
|
67 |
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_EDIT_SLUG . '/' . $this->id);
|
68 |
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
69 |
-
$image_array = image_downsize($this->
|
70 |
-
$this->thumbnail_id = $this->
|
71 |
break;
|
72 |
default :
|
73 |
return false;
|
@@ -76,26 +80,40 @@ class BP_Media_Host_Wordpress {
|
|
76 |
|
77 |
/**
|
78 |
* Handles the uploaded media file and creates attachment post for the file.
|
79 |
-
*
|
80 |
* @since BP Media 2.0
|
81 |
*/
|
82 |
-
function add_media($name, $description) {
|
|
|
83 |
global $bp, $wpdb, $bp_media_count;
|
84 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
85 |
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
86 |
-
|
87 |
-
$
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
$file = wp_handle_upload($_FILES['bp_media_file']);
|
95 |
if (isset($file['error']) || $file === null) {
|
96 |
-
wp_delete_post($post_id, true);
|
97 |
throw new Exception(__('Error Uploading File', 'bp-media'));
|
98 |
}
|
|
|
99 |
$attachment = array();
|
100 |
$url = $file['url'];
|
101 |
$type = $file['type'];
|
@@ -119,7 +137,6 @@ class BP_Media_Host_Wordpress {
|
|
119 |
$getID3 = new getID3;
|
120 |
$vid_info = $getID3->analyze($file);
|
121 |
} catch (Exception $e) {
|
122 |
-
wp_delete_post($post_id, true);
|
123 |
unlink($file);
|
124 |
$activity_content = false;
|
125 |
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
|
@@ -127,19 +144,16 @@ class BP_Media_Host_Wordpress {
|
|
127 |
if (is_array($vid_info)) {
|
128 |
if (!array_key_exists('error',$vid_info)&& array_key_exists('fileformat', $vid_info) && array_key_exists('video', $vid_info)&&array_key_exists('fourcc',$vid_info['video'])) {
|
129 |
if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
|
130 |
-
wp_delete_post($post_id, true);
|
131 |
unlink($file);
|
132 |
$activity_content = false;
|
133 |
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
|
134 |
}
|
135 |
} else {
|
136 |
-
wp_delete_post($post_id, true);
|
137 |
unlink($file);
|
138 |
$activity_content = false;
|
139 |
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
|
140 |
}
|
141 |
} else {
|
142 |
-
wp_delete_post($post_id, true);
|
143 |
unlink($file);
|
144 |
$activity_content = false;
|
145 |
throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
|
@@ -152,7 +166,6 @@ class BP_Media_Host_Wordpress {
|
|
152 |
$getID3 = new getID3;
|
153 |
$file_info = $getID3->analyze($file);
|
154 |
} catch (Exception $e) {
|
155 |
-
wp_delete_post($post_id, true);
|
156 |
unlink($file);
|
157 |
$activity_content = false;
|
158 |
throw new Exception(__('MP3 file you have uploaded is currupt.', 'bp-media'));
|
@@ -160,19 +173,16 @@ class BP_Media_Host_Wordpress {
|
|
160 |
if (is_array($file_info)) {
|
161 |
if (!array_key_exists('error',$file_info)&& array_key_exists('fileformat', $file_info) && array_key_exists('audio', $file_info)&&array_key_exists('dataformat',$file_info['audio'])) {
|
162 |
if (!($file_info['fileformat']=='mp3'&&$file_info['audio']['dataformat']=='mp3')) {
|
163 |
-
wp_delete_post($post_id, true);
|
164 |
unlink($file);
|
165 |
$activity_content = false;
|
166 |
throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
|
167 |
}
|
168 |
} else {
|
169 |
-
wp_delete_post($post_id, true);
|
170 |
unlink($file);
|
171 |
$activity_content = false;
|
172 |
throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
|
173 |
}
|
174 |
} else {
|
175 |
-
wp_delete_post($post_id, true);
|
176 |
unlink($file);
|
177 |
$activity_content = false;
|
178 |
throw new Exception(__('The MP3 file you have uploaded is not an audio file.', 'bp-media'));
|
@@ -186,8 +196,7 @@ class BP_Media_Host_Wordpress {
|
|
186 |
$type = 'image';
|
187 |
$bp_media_count['images'] = intval($bp_media_count['images']) + 1;
|
188 |
break;
|
189 |
-
default :
|
190 |
-
wp_delete_post($post_id, true);
|
191 |
unlink($file);
|
192 |
$activity_content = false;
|
193 |
throw new Exception(__('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', 'bp-media'));
|
@@ -196,45 +205,53 @@ class BP_Media_Host_Wordpress {
|
|
196 |
if (!is_wp_error($attachment_id)) {
|
197 |
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
198 |
} else {
|
199 |
-
wp_delete_post($post_id, true);
|
200 |
unlink($file);
|
201 |
-
throw new Exception(__('Error creating
|
202 |
}
|
203 |
-
$
|
204 |
-
$postarr['post_mime_type'] = $type;
|
205 |
-
$postarr['post_status'] = 'publish';
|
206 |
-
wp_insert_post($postarr);
|
207 |
-
$activity_content = '[bp_media_content id="' . $post_id . '"]';
|
208 |
-
$activity_id = bp_media_record_activity(array(
|
209 |
-
'action' => '[bp_media_action id="' . $post_id . '"]',
|
210 |
-
'content' => $activity_content,
|
211 |
-
'primary_link' => 'bp_media_url id="' . $post_id . '"',
|
212 |
-
'type' => 'media_upload'
|
213 |
-
));
|
214 |
-
bp_activity_update_meta($activity_id, 'bp_media_parent_post', $post_id);
|
215 |
-
update_post_meta($post_id, 'bp_media_child_activity', $activity_id);
|
216 |
-
update_post_meta($post_id, 'bp_media_child_attachment', $attachment_id);
|
217 |
-
update_post_meta($post_id, 'bp_media_type', $type);
|
218 |
-
update_post_meta($post_id, 'bp_media_hosting', 'wordpress');
|
219 |
-
$this->id = $post_id;
|
220 |
$this->name = $name;
|
221 |
$this->description = $description;
|
222 |
-
$this->owner = bp_loggedin_user_id();
|
223 |
$this->type = $type;
|
224 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
|
|
226 |
}
|
227 |
|
228 |
/**
|
229 |
* Fetches the content of the activity of media upload based on its type
|
230 |
-
*
|
231 |
*/
|
232 |
function get_media_activity_content() {
|
233 |
-
if (!bp_is_activity_component()) {
|
234 |
-
return false;
|
235 |
-
}
|
236 |
global $bp_media_counter, $bp_media_default_excerpts;
|
237 |
-
$attachment_id =
|
238 |
$activity_content = '<div class="bp_media_title"><a href="' . $this->url . '" title="' . $this->description . '">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['activity_entry_title']) . '</a></div>';
|
239 |
$activity_content .='<div class="bp_media_content">';
|
240 |
switch ($this->type) {
|
@@ -294,18 +311,18 @@ class BP_Media_Host_Wordpress {
|
|
294 |
case 'video' :
|
295 |
if($this->thumbnail_id){
|
296 |
$image_array = image_downsize($this->thumbnail_id, 'bp_media_single_image');
|
297 |
-
$content.='<video poster="'.$image_array[0].'" src="' . wp_get_attachment_url($this->
|
298 |
}
|
299 |
else{
|
300 |
-
$content.='<video src="' . wp_get_attachment_url($this->
|
301 |
}
|
302 |
break;
|
303 |
case 'audio' :
|
304 |
-
$content.='<audio src="' . wp_get_attachment_url($this->
|
305 |
$type = 'audio';
|
306 |
break;
|
307 |
case 'image' :
|
308 |
-
$image_array = image_downsize($this->
|
309 |
$content.='<img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '" />';
|
310 |
$type = 'image';
|
311 |
break;
|
@@ -321,7 +338,7 @@ class BP_Media_Host_Wordpress {
|
|
321 |
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
322 |
*/
|
323 |
function get_media_gallery_content() {
|
324 |
-
$attachment =
|
325 |
switch ($this->type) {
|
326 |
case 'video' :
|
327 |
if($this->thumbnail_id){
|
@@ -341,10 +358,17 @@ class BP_Media_Host_Wordpress {
|
|
341 |
<?php
|
342 |
break;
|
343 |
case 'audio' :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
?>
|
345 |
<li>
|
346 |
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
347 |
-
<img src="<?php echo
|
348 |
</a>
|
349 |
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
350 |
</li>
|
@@ -367,11 +391,24 @@ class BP_Media_Host_Wordpress {
|
|
367 |
}
|
368 |
}
|
369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
/**
|
371 |
* Outputs the comments and comment form in the single media entry page
|
372 |
*/
|
373 |
function show_comment_form() {
|
374 |
$activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
|
|
|
|
|
375 |
if (bp_has_activities(array(
|
376 |
'display_comments' => 'stream',
|
377 |
'include' => $activity_id,
|
@@ -458,17 +495,17 @@ class BP_Media_Host_Wordpress {
|
|
458 |
* Returns the URL of the attached media file
|
459 |
*/
|
460 |
function get_attachment_url(){
|
461 |
-
return wp_get_attachment_url($this->
|
462 |
}
|
463 |
-
|
464 |
/**
|
465 |
* Updates the media entry
|
466 |
-
*
|
467 |
* @param array $args Array with the following keys:<br/>
|
468 |
* 'name' <br/>
|
469 |
* 'description'<br/>
|
470 |
* 'owner'
|
471 |
-
*
|
472 |
* @return bool True when the update is successful, False when the update fails
|
473 |
*/
|
474 |
function update_media($args=array()){
|
@@ -486,11 +523,12 @@ class BP_Media_Host_Wordpress {
|
|
486 |
$this->init($this->id);
|
487 |
return $result;
|
488 |
}
|
489 |
-
|
490 |
/**
|
491 |
* Deletes the Media Entry
|
492 |
*/
|
493 |
function delete_media(){
|
|
|
494 |
global $bp_media_count;
|
495 |
bp_media_init_count($this->owner);
|
496 |
switch ($this->type) {
|
@@ -504,52 +542,113 @@ class BP_Media_Host_Wordpress {
|
|
504 |
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
|
505 |
break;
|
506 |
}
|
507 |
-
|
508 |
-
wp_delete_attachment($this->attachment_id);
|
509 |
-
wp_delete_post($this->id);
|
510 |
bp_update_user_meta($this->owner, 'bp_media_count', $bp_media_count);
|
|
|
511 |
}
|
512 |
-
|
513 |
/**
|
514 |
-
*
|
515 |
*/
|
516 |
-
function
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
}
|
519 |
-
|
520 |
/**
|
521 |
* Returns the description of the Media Entry
|
522 |
*/
|
523 |
function get_content() {
|
524 |
return $this->description;
|
525 |
}
|
526 |
-
|
527 |
/**
|
528 |
* Returns the owner id of the Media Entry
|
529 |
*/
|
530 |
function get_author() {
|
531 |
return $this->owner;
|
532 |
}
|
533 |
-
|
534 |
/**
|
535 |
* Returns the id of the Media Entry
|
536 |
*/
|
537 |
function get_id(){
|
538 |
return $this->id;
|
539 |
}
|
540 |
-
|
541 |
/**
|
542 |
* Returns the edit url of the Media Entry
|
543 |
*/
|
544 |
function get_edit_url() {
|
545 |
return $this->edit_url;
|
546 |
}
|
547 |
-
|
548 |
/**
|
549 |
* Returns the delete url of the Media Entry
|
550 |
*/
|
551 |
function get_delete_url() {
|
552 |
return $this->delete_url;
|
553 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
}
|
555 |
?>
|
10 |
$url, //URL of the entry
|
11 |
$type, //Type of the entry (Video, Image or Audio)
|
12 |
$owner, //Owner 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 |
+
|
18 |
/**
|
19 |
* Constructs a new BP_Media_Host_Wordpress element
|
20 |
+
*
|
21 |
* @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
|
22 |
+
*
|
23 |
* @since BP Media 2.0
|
24 |
*/
|
25 |
function __construct($media_id = '') {
|
30 |
|
31 |
/**
|
32 |
* Initializes the object with the variables from the post
|
33 |
+
*
|
34 |
* @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
|
35 |
+
*
|
36 |
* @since BP Media 2.0
|
37 |
*/
|
38 |
function init($media_id = '') {
|
47 |
$this->description = $media->post_content;
|
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 |
switch ($this->type) {
|
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;
|
80 |
|
81 |
/**
|
82 |
* Handles the uploaded media file and creates attachment post for the file.
|
83 |
+
*
|
84 |
* @since BP Media 2.0
|
85 |
*/
|
86 |
+
function add_media($name, $description, $album_id = 0, $group = 0) {
|
87 |
+
do_action('bp_media_before_add_media');
|
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 |
+
$create_new_album_flag = false;
|
92 |
+
if($album_id!=0){
|
93 |
+
$album = get_post($album_id);
|
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'));
|
115 |
}
|
116 |
+
|
117 |
$attachment = array();
|
118 |
$url = $file['url'];
|
119 |
$type = $file['type'];
|
137 |
$getID3 = new getID3;
|
138 |
$vid_info = $getID3->analyze($file);
|
139 |
} catch (Exception $e) {
|
|
|
140 |
unlink($file);
|
141 |
$activity_content = false;
|
142 |
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
|
144 |
if (is_array($vid_info)) {
|
145 |
if (!array_key_exists('error',$vid_info)&& array_key_exists('fileformat', $vid_info) && array_key_exists('video', $vid_info)&&array_key_exists('fourcc',$vid_info['video'])) {
|
146 |
if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
|
|
|
147 |
unlink($file);
|
148 |
$activity_content = false;
|
149 |
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
|
150 |
}
|
151 |
} else {
|
|
|
152 |
unlink($file);
|
153 |
$activity_content = false;
|
154 |
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
|
155 |
}
|
156 |
} else {
|
|
|
157 |
unlink($file);
|
158 |
$activity_content = false;
|
159 |
throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
|
166 |
$getID3 = new getID3;
|
167 |
$file_info = $getID3->analyze($file);
|
168 |
} catch (Exception $e) {
|
|
|
169 |
unlink($file);
|
170 |
$activity_content = false;
|
171 |
throw new Exception(__('MP3 file you have uploaded is currupt.', 'bp-media'));
|
173 |
if (is_array($file_info)) {
|
174 |
if (!array_key_exists('error',$file_info)&& array_key_exists('fileformat', $file_info) && array_key_exists('audio', $file_info)&&array_key_exists('dataformat',$file_info['audio'])) {
|
175 |
if (!($file_info['fileformat']=='mp3'&&$file_info['audio']['dataformat']=='mp3')) {
|
|
|
176 |
unlink($file);
|
177 |
$activity_content = false;
|
178 |
throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
|
179 |
}
|
180 |
} else {
|
|
|
181 |
unlink($file);
|
182 |
$activity_content = false;
|
183 |
throw new Exception(__('The MP3 file you have uploaded is using an unsupported audio format. Supported audio format is MP3.', 'bp-media'));
|
184 |
}
|
185 |
} else {
|
|
|
186 |
unlink($file);
|
187 |
$activity_content = false;
|
188 |
throw new Exception(__('The MP3 file you have uploaded is not an audio file.', 'bp-media'));
|
196 |
$type = 'image';
|
197 |
$bp_media_count['images'] = intval($bp_media_count['images']) + 1;
|
198 |
break;
|
199 |
+
default :
|
|
|
200 |
unlink($file);
|
201 |
$activity_content = false;
|
202 |
throw new Exception(__('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3, .mov and .mp4.', 'bp-media'));
|
205 |
if (!is_wp_error($attachment_id)) {
|
206 |
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
207 |
} else {
|
|
|
208 |
unlink($file);
|
209 |
+
throw new Exception(__('Error creating attachment for the media file, please try again', 'bp-media'));
|
210 |
}
|
211 |
+
$this->id = $attachment_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
$this->name = $name;
|
213 |
$this->description = $description;
|
|
|
214 |
$this->type = $type;
|
215 |
+
$this->owner = get_current_user_id();
|
216 |
+
$this->album_id = $post_id;
|
217 |
+
switch ($this->type) {
|
218 |
+
case 'video' :
|
219 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . $this->id);
|
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 |
+
else
|
243 |
+
update_post_meta($attachment_id, 'bp-media-key', (-$group));
|
244 |
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
245 |
+
do_action('bp_media_after_add_media',$this);
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
* Fetches the content of the activity of media upload based on its type
|
250 |
+
*
|
251 |
*/
|
252 |
function get_media_activity_content() {
|
|
|
|
|
|
|
253 |
global $bp_media_counter, $bp_media_default_excerpts;
|
254 |
+
$attachment_id = $this->id;
|
255 |
$activity_content = '<div class="bp_media_title"><a href="' . $this->url . '" title="' . $this->description . '">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['activity_entry_title']) . '</a></div>';
|
256 |
$activity_content .='<div class="bp_media_content">';
|
257 |
switch ($this->type) {
|
311 |
case 'video' :
|
312 |
if($this->thumbnail_id){
|
313 |
$image_array = image_downsize($this->thumbnail_id, 'bp_media_single_image');
|
314 |
+
$content.='<video poster="'.$image_array[0].'" src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_video']['width'] . '" height="' . ($bp_media_default_sizes['single_video']['height'] == 0 ? 'auto' : $bp_media_default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>';
|
315 |
}
|
316 |
else{
|
317 |
+
$content.='<video src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_video']['width'] . '" height="' . ($bp_media_default_sizes['single_video']['height'] == 0 ? 'auto' : $bp_media_default_sizes['single_video']['height']) . '" type="video/mp4" id="bp_media_video_' . $this->id . '" controls="controls" preload="none"></video><script>bp_media_create_element("bp_media_video_' . $this->id . '");</script>';
|
318 |
}
|
319 |
break;
|
320 |
case 'audio' :
|
321 |
+
$content.='<audio src="' . wp_get_attachment_url($this->id) . '" width="' . $bp_media_default_sizes['single_audio']['width'] . '" type="audio/mp3" id="bp_media_audio_' . $this->id . '" controls="controls" preload="none" ></audio><script>bp_media_create_element("bp_media_audio_' . $this->id . '");</script>';
|
322 |
$type = 'audio';
|
323 |
break;
|
324 |
case 'image' :
|
325 |
+
$image_array = image_downsize($this->id, 'bp_media_single_image');
|
326 |
$content.='<img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '" />';
|
327 |
$type = 'image';
|
328 |
break;
|
338 |
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
339 |
*/
|
340 |
function get_media_gallery_content() {
|
341 |
+
$attachment = $this->id;
|
342 |
switch ($this->type) {
|
343 |
case 'video' :
|
344 |
if($this->thumbnail_id){
|
358 |
<?php
|
359 |
break;
|
360 |
case 'audio' :
|
361 |
+
if($this->thumbnail_id){
|
362 |
+
$medium_array = image_downsize($this->thumbnail_id, 'thumbnail');
|
363 |
+
$thumb_url = $medium_array[0];
|
364 |
+
}
|
365 |
+
else{
|
366 |
+
$thumb_url = plugins_url('img/audio_thumb.png', __FILE__);
|
367 |
+
}
|
368 |
?>
|
369 |
<li>
|
370 |
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
371 |
+
<img src="<?php echo $thumb_url ?>" />
|
372 |
</a>
|
373 |
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
374 |
</li>
|
391 |
}
|
392 |
}
|
393 |
|
394 |
+
function show_comment_form_wordpress(){
|
395 |
+
query_posts('attachment_id='.$this->id);
|
396 |
+
while(have_posts()): the_post();
|
397 |
+
add_action('comment_form', function() {
|
398 |
+
global $bp_media_current_entry;
|
399 |
+
echo '<input type="hidden" name="redirect_to" value="'.$bp_media_current_entry->get_url().'">' ;
|
400 |
+
});
|
401 |
+
comments_template();
|
402 |
+
endwhile;
|
403 |
+
}
|
404 |
+
|
405 |
/**
|
406 |
* Outputs the comments and comment form in the single media entry page
|
407 |
*/
|
408 |
function show_comment_form() {
|
409 |
$activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
|
410 |
+
if(!$activity_id || !function_exists('bp_has_activities'))
|
411 |
+
return false;
|
412 |
if (bp_has_activities(array(
|
413 |
'display_comments' => 'stream',
|
414 |
'include' => $activity_id,
|
495 |
* Returns the URL of the attached media file
|
496 |
*/
|
497 |
function get_attachment_url(){
|
498 |
+
return wp_get_attachment_url($this->id);
|
499 |
}
|
500 |
+
|
501 |
/**
|
502 |
* Updates the media entry
|
503 |
+
*
|
504 |
* @param array $args Array with the following keys:<br/>
|
505 |
* 'name' <br/>
|
506 |
* 'description'<br/>
|
507 |
* 'owner'
|
508 |
+
*
|
509 |
* @return bool True when the update is successful, False when the update fails
|
510 |
*/
|
511 |
function update_media($args=array()){
|
523 |
$this->init($this->id);
|
524 |
return $result;
|
525 |
}
|
526 |
+
|
527 |
/**
|
528 |
* Deletes the Media Entry
|
529 |
*/
|
530 |
function delete_media(){
|
531 |
+
do_action('bp_media_before_delete_media',$this->id);
|
532 |
global $bp_media_count;
|
533 |
bp_media_init_count($this->owner);
|
534 |
switch ($this->type) {
|
542 |
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
|
543 |
break;
|
544 |
}
|
545 |
+
wp_delete_attachment($this->id,true);
|
|
|
|
|
546 |
bp_update_user_meta($this->owner, 'bp_media_count', $bp_media_count);
|
547 |
+
do_action('bp_media_after_delete_media',$this->id);
|
548 |
}
|
549 |
+
|
550 |
/**
|
551 |
+
* Function to return the content to be placed in the activity of album
|
552 |
*/
|
553 |
+
function get_album_activity_content(){
|
554 |
+
$attachment = $this->id;
|
555 |
+
switch ($this->type) {
|
556 |
+
case 'video' :
|
557 |
+
if($this->thumbnail_id){
|
558 |
+
$medium_array = image_downsize($this->thumbnail_id, 'thumbnail');
|
559 |
+
$thumb_url = $medium_array[0];
|
560 |
+
}
|
561 |
+
else{
|
562 |
+
$thumb_url = plugins_url('img/video_thumb.png', __FILE__);
|
563 |
+
}
|
564 |
+
break;
|
565 |
+
case 'audio' :
|
566 |
+
if($this->thumbnail_id){
|
567 |
+
$medium_array = image_downsize($this->thumbnail_id, 'thumbnail');
|
568 |
+
$thumb_url = $medium_array[0];
|
569 |
+
}
|
570 |
+
else{
|
571 |
+
$thumb_url = plugins_url('img/audio_thumb.png', __FILE__);
|
572 |
+
}
|
573 |
+
break;
|
574 |
+
case 'image' :
|
575 |
+
$medium_array = image_downsize($attachment, 'thumbnail');
|
576 |
+
$thumb_url = $medium_array[0];
|
577 |
+
break;
|
578 |
+
default :
|
579 |
+
return false;
|
580 |
+
}
|
581 |
+
$content = '<li>';
|
582 |
+
$content .= '<a href="'.$this->url.'" title="'.$this->name.'">';
|
583 |
+
$content .= '<img src="'.$thumb_url.'" />';
|
584 |
+
$content .= '</a>';
|
585 |
+
$content .= '</li>';
|
586 |
+
return $content;
|
587 |
}
|
588 |
+
|
589 |
/**
|
590 |
* Returns the description of the Media Entry
|
591 |
*/
|
592 |
function get_content() {
|
593 |
return $this->description;
|
594 |
}
|
595 |
+
|
596 |
/**
|
597 |
* Returns the owner id of the Media Entry
|
598 |
*/
|
599 |
function get_author() {
|
600 |
return $this->owner;
|
601 |
}
|
602 |
+
|
603 |
/**
|
604 |
* Returns the id of the Media Entry
|
605 |
*/
|
606 |
function get_id(){
|
607 |
return $this->id;
|
608 |
}
|
609 |
+
|
610 |
/**
|
611 |
* Returns the edit url of the Media Entry
|
612 |
*/
|
613 |
function get_edit_url() {
|
614 |
return $this->edit_url;
|
615 |
}
|
616 |
+
|
617 |
/**
|
618 |
* Returns the delete url of the Media Entry
|
619 |
*/
|
620 |
function get_delete_url() {
|
621 |
return $this->delete_url;
|
622 |
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Returns the type of activity
|
626 |
+
*/
|
627 |
+
function get_media_activity_type() {
|
628 |
+
switch($this->type){
|
629 |
+
case 'image':
|
630 |
+
return BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
631 |
+
case 'video':
|
632 |
+
return BP_MEDIA_VIDEOS_LABEL_SINGULAR;
|
633 |
+
case 'audio':
|
634 |
+
return BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
635 |
+
default:
|
636 |
+
return 'Media';
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* Returns the album id
|
642 |
+
*/
|
643 |
+
function get_album_id(){
|
644 |
+
return $this->album_id;
|
645 |
+
}
|
646 |
+
|
647 |
+
/**
|
648 |
+
* Returns the title of the media
|
649 |
+
*/
|
650 |
+
function get_title(){
|
651 |
+
return $this->name;
|
652 |
+
}
|
653 |
}
|
654 |
?>
|
includes/bp-media-filters.php
CHANGED
@@ -1,51 +1,83 @@
|
|
1 |
<?php
|
2 |
function bp_media_activity_permalink_filter($link, $activity_obj = null) {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
}
|
9 |
if ($activity_obj != null && 'activity_comment' == $activity_obj->type) {
|
10 |
-
|
|
|
|
|
11 |
if ($parent) {
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
}
|
16 |
return $link;
|
17 |
}
|
18 |
add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
|
19 |
|
20 |
-
function
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
function bp_media_activity_content_filter($activity_content, $activity_obj = null ) {
|
31 |
-
if ($activity_obj != null && 'media_upload' == $activity_obj->type) {
|
32 |
-
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
33 |
-
$activity_content = do_shortcode($activity_content);
|
34 |
-
remove_shortcode('bp_media_content');
|
35 |
-
}
|
36 |
-
return $activity_content;
|
37 |
-
}
|
38 |
-
add_filter('bp_get_activity_content_body', 'bp_media_activity_content_filter', 10, 2);
|
39 |
-
|
40 |
-
function bp_media_activity_parent_content_filter($content) {
|
41 |
-
add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
42 |
-
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
43 |
-
$content=do_shortcode($content);
|
44 |
-
remove_shortcode('bp_media_action');
|
45 |
-
remove_shortcode('bp_media_content');
|
46 |
return $content;
|
|
|
47 |
}
|
48 |
-
add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
function bp_media_delete_button_handler($link) {
|
51 |
if(bp_current_component()=='media')
|
@@ -69,8 +101,275 @@ function bp_media_items_count_filter ($title,$nav_item) {
|
|
69 |
case BP_MEDIA_AUDIO_SLUG:
|
70 |
$count= intval($bp_media_count['audio']);
|
71 |
break;
|
|
|
|
|
|
|
72 |
}
|
73 |
$count_html=' <span>'. $count.'</span>';
|
74 |
return str_replace('</a>', $count_html.'</a>', $title);
|
75 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
?>
|
1 |
<?php
|
2 |
function bp_media_activity_permalink_filter($link, $activity_obj = null) {
|
3 |
+
global $bp_media_activity_types;
|
4 |
+
if ($activity_obj != null && in_array($activity_obj->type,$bp_media_activity_types)) {
|
5 |
+
if($activity_obj->primary_link!=''){
|
6 |
+
try{
|
7 |
+
return $activity_obj->primary_link;
|
8 |
+
}
|
9 |
+
catch(Exception $e){
|
10 |
+
return $link;
|
11 |
+
}
|
12 |
}
|
13 |
}
|
14 |
if ($activity_obj != null && 'activity_comment' == $activity_obj->type) {
|
15 |
+
global $activities_template;
|
16 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
17 |
+
$parent = $activity_obj->item_id;
|
18 |
if ($parent) {
|
19 |
+
try{
|
20 |
+
if(isset($activities_template->activity_parents[$parent])){
|
21 |
+
return $activities_template->activity_parents[$parent]->primary_link;
|
22 |
+
}
|
23 |
+
else{
|
24 |
+
$activities = bp_activity_get(array('in' => $parent));
|
25 |
+
if(isset($activities['activities'][0])){
|
26 |
+
$activities_template->activity_parents[$parent] = $activities['activities'][0];
|
27 |
+
return $activities['activities'][0]->primary_link;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
catch(Exception $e){
|
32 |
+
return $link;
|
33 |
+
}
|
34 |
}
|
35 |
}
|
36 |
return $link;
|
37 |
}
|
38 |
add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
|
39 |
|
40 |
+
function bp_media_activity_parent_content_filter($activity_content) {
|
41 |
+
global $activities_template;
|
42 |
+
$defaults = array(
|
43 |
+
'hide_user' => false
|
44 |
+
);
|
45 |
+
if ( !$parent_id = $activities_template->activity->item_id )
|
46 |
+
return false;
|
47 |
+
if(!isset($bp_media_hidden_activity_cache[$parent_id])){
|
48 |
+
$activities = bp_activity_get(array('in' => $parent_id));
|
49 |
+
if(isset($activities['activities'][0])){
|
50 |
+
$bp_media_hidden_activity_cache[$parent_id] = $activities['activities'][0];
|
51 |
+
}
|
52 |
}
|
53 |
+
if ( empty( $bp_media_hidden_activity_cache[$parent_id] ) )
|
54 |
+
return false;
|
55 |
+
|
56 |
+
if ( empty( $bp_media_hidden_activity_cache[$parent_id]->content ) )
|
57 |
+
$content = $bp_media_hidden_activity_cache[$parent_id]->action;
|
58 |
+
else
|
59 |
+
$content = $bp_media_hidden_activity_cache[$parent_id]->action . ' ' . $bp_media_hidden_activity_cache[$parent_id]->content;
|
60 |
+
|
61 |
+
// Remove the time since content for backwards compatibility
|
62 |
+
$content = str_replace( '<span class="time-since">%s</span>', '', $content );
|
63 |
+
|
64 |
+
// Remove images
|
65 |
+
$content = preg_replace( '/<img[^>]*>/Ui', '', $content );
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
return $content;
|
68 |
+
return $activity_content;
|
69 |
}
|
70 |
+
//add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter', 1);
|
71 |
+
|
72 |
+
//function bp_media_activity_parent__content_filter($content) {
|
73 |
+
// add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
74 |
+
// add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
75 |
+
// $content=do_shortcode($content);
|
76 |
+
// remove_shortcode('bp_media_action');
|
77 |
+
// remove_shortcode('bp_media_content');
|
78 |
+
// return $content;
|
79 |
+
//}
|
80 |
+
//add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter');
|
81 |
|
82 |
function bp_media_delete_button_handler($link) {
|
83 |
if(bp_current_component()=='media')
|
101 |
case BP_MEDIA_AUDIO_SLUG:
|
102 |
$count= intval($bp_media_count['audio']);
|
103 |
break;
|
104 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
105 |
+
$count= intval($bp_media_count['albums']);
|
106 |
+
break;
|
107 |
}
|
108 |
$count_html=' <span>'. $count.'</span>';
|
109 |
return str_replace('</a>', $count_html.'</a>', $title);
|
110 |
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* To hide some activities of multiple uploads
|
114 |
+
*/
|
115 |
+
function bp_media_activity_query_filter($query){
|
116 |
+
global $wpdb;
|
117 |
+
$query = preg_replace('/WHERE/i', 'WHERE a.secondary_item_id!=-999 AND ',$query);
|
118 |
+
return $query;
|
119 |
+
}
|
120 |
+
add_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Added menu under buddypress menu 'my account' in admin bar
|
124 |
+
*
|
125 |
+
* @global type $wp_admin_bar
|
126 |
+
*/
|
127 |
+
|
128 |
+
function bp_media_my_account_menu() {
|
129 |
+
global $wp_admin_bar;
|
130 |
+
|
131 |
+
$bp_media_admin_nav = array();
|
132 |
+
|
133 |
+
// Added Main menu for BP Media
|
134 |
+
$bp_media_admin_nav[] = array(
|
135 |
+
'parent' => 'my-account-buddypress',
|
136 |
+
'id' => 'my-account-bpmedia',
|
137 |
+
'title' => __('Media', 'bp-media'),
|
138 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
|
139 |
+
'meta' => array(
|
140 |
+
'class' => 'menupop')
|
141 |
+
);
|
142 |
+
|
143 |
+
// Uplaod Media
|
144 |
+
/*$bp_media_admin_nav[] = array(
|
145 |
+
'parent' => 'my-account-bpmedia',
|
146 |
+
'id' => 'my-account-upload-media',
|
147 |
+
'title' => __('Upload Media','bp-media'),
|
148 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
|
149 |
+
);*/
|
150 |
+
|
151 |
+
// Photos
|
152 |
+
$bp_media_admin_nav[] = array(
|
153 |
+
'parent' => 'my-account-bpmedia',
|
154 |
+
'id' => 'my-account-photos',
|
155 |
+
'title' => __('Photos','bp-media'),
|
156 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG)
|
157 |
+
);
|
158 |
+
|
159 |
+
// Video
|
160 |
+
$bp_media_admin_nav[] = array(
|
161 |
+
'parent' => 'my-account-bpmedia',
|
162 |
+
'id' => 'my-account-videos',
|
163 |
+
'title' => __('Videos','bp-media'),
|
164 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG)
|
165 |
+
);
|
166 |
+
|
167 |
+
// Audio
|
168 |
+
$bp_media_admin_nav[] = array(
|
169 |
+
'parent' => 'my-account-bpmedia',
|
170 |
+
'id' => 'my-account-audio',
|
171 |
+
'title' => __('Audio','bp-media'),
|
172 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG)
|
173 |
+
);
|
174 |
+
|
175 |
+
// Albums
|
176 |
+
$bp_media_admin_nav[] = array(
|
177 |
+
'parent' => 'my-account-bpmedia',
|
178 |
+
'id' => 'my-account-album',
|
179 |
+
'title' => __('Albums','bp-media'),
|
180 |
+
'href' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG)
|
181 |
+
);
|
182 |
+
|
183 |
+
foreach( $bp_media_admin_nav as $admin_menu )
|
184 |
+
$wp_admin_bar->add_menu( $admin_menu );
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
// and we hook our function via wp_before_admin_bar_render
|
189 |
+
add_action( 'admin_bar_menu', 'bp_media_my_account_menu', 1 );
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Added menu under buddypress menu 'my account' in admin bar
|
193 |
+
*
|
194 |
+
* @global type $wp_admin_bar
|
195 |
+
*/
|
196 |
+
|
197 |
+
function bp_media_adminbar_settings_menu() {
|
198 |
+
global $wp_admin_bar;
|
199 |
+
|
200 |
+
if( current_user_can('manage_options') ){
|
201 |
+
|
202 |
+
$bp_media_admin_nav = array();
|
203 |
+
$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'BP Media', 'admin bar menu group label' ) . '</span>';
|
204 |
+
|
205 |
+
// Added Main menu for BP Media
|
206 |
+
$bp_media_admin_nav[] = array(
|
207 |
+
'id' => 'bp-media-menu',
|
208 |
+
'title' => $title,
|
209 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) ),
|
210 |
+
'meta' => array(
|
211 |
+
'class' => 'menupop bp-media-settings-menu')
|
212 |
+
);
|
213 |
+
|
214 |
+
// Settings
|
215 |
+
$bp_media_admin_nav[] = array(
|
216 |
+
'parent' => 'bp-media-menu',
|
217 |
+
'id' => 'bp-media-settings',
|
218 |
+
'title' => __('Settings','bp-media'),
|
219 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-settings' ), 'admin.php' ) )
|
220 |
+
);
|
221 |
+
|
222 |
+
// Addons
|
223 |
+
$bp_media_admin_nav[] = array(
|
224 |
+
'parent' => 'bp-media-menu',
|
225 |
+
'id' => 'my-account-addons',
|
226 |
+
'title' => __('Addons','bp-media'),
|
227 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-addons' ), 'admin.php' ) )
|
228 |
+
);
|
229 |
+
|
230 |
+
// Support
|
231 |
+
$bp_media_admin_nav[] = array(
|
232 |
+
'parent' => 'bp-media-menu',
|
233 |
+
'id' => 'my-account-support',
|
234 |
+
'title' => __('Support','bp-media'),
|
235 |
+
'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-media-support' ), 'admin.php' ) )
|
236 |
+
);
|
237 |
+
|
238 |
+
foreach( $bp_media_admin_nav as $admin_menu )
|
239 |
+
$wp_admin_bar->add_menu( $admin_menu );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
// and we hook our function via wp_before_admin_bar_render
|
244 |
+
add_action( 'wp_before_admin_bar_render', 'bp_media_adminbar_settings_menu' );
|
245 |
+
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Set BP Media dashboard widget
|
249 |
+
*
|
250 |
+
*/
|
251 |
+
//add_action('wp_dashboard_setup','bp_media_dashboard_widgets');
|
252 |
+
|
253 |
+
function bp_media_dashboard_widgets(){
|
254 |
+
global $wp_meta_boxes;
|
255 |
+
// Buddypress Media
|
256 |
+
// if ( is_user_admin() )
|
257 |
+
wp_add_dashboard_widget( 'dashboard_media_widget', __( 'BuddPress Media' ), 'bp_media_dashboard_media' );
|
258 |
+
|
259 |
+
global $wp_meta_boxes;
|
260 |
+
|
261 |
+
// Get the regular dashboard widgets array
|
262 |
+
// (which has our new widget already but at the end)
|
263 |
+
|
264 |
+
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
|
265 |
+
|
266 |
+
// Backup and delete our new dashbaord widget from the end of the array
|
267 |
+
|
268 |
+
$example_widget_backup = array('dashboard_media_widget' => $normal_dashboard['dashboard_media_widget']);
|
269 |
+
unset($normal_dashboard['dashboard_media_widget']);
|
270 |
+
|
271 |
+
// Merge the two arrays together so our widget is at the beginning
|
272 |
+
|
273 |
+
$sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
|
274 |
+
|
275 |
+
// Save the sorted array back into the original metaboxes
|
276 |
+
|
277 |
+
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
278 |
+
|
279 |
+
}
|
280 |
+
|
281 |
+
function bp_media_dashboard_media(){
|
282 |
+
|
283 |
+
/* Single user media counts */
|
284 |
+
$photos_count = bp_media_admin_total_count('photo');
|
285 |
+
$videos_count = bp_media_admin_total_count('video');
|
286 |
+
$audio_count = bp_media_admin_total_count('audio');
|
287 |
+
$albums_count = bp_media_admin_total_count('album');
|
288 |
+
|
289 |
+
/* Group media counts */
|
290 |
+
$g_photos_count = bp_media_admin_group_total_count('photo');
|
291 |
+
$g_videos_count = bp_media_admin_group_total_count('video');
|
292 |
+
$g_audio_count = bp_media_admin_group_total_count('audio');
|
293 |
+
$g_albums_count = bp_media_admin_group_total_count('album');
|
294 |
+
|
295 |
+
?>
|
296 |
+
<div class="bp-media-dashboard">
|
297 |
+
<h3 class="sub"><?php _e('Users','bp-media');?> </h3>
|
298 |
+
<div class="table table_user">
|
299 |
+
<div class=""><span class="media-cnt"><?php echo $photos_count; ?></span><span class="media-label"><?php _e('Total Photos','bp-media'); ?></span></div>
|
300 |
+
<div class=""><span class="media-cnt"><?php echo $videos_count; ?></span><span class="media-label"><?php _e('Total Videos','bp-media'); ?></span></div>
|
301 |
+
<div class=""><span class="media-cnt"><?php echo $audio_count; ?></span><span class="media-label"><?php _e('Total Audio','bp-media'); ?></span></div>
|
302 |
+
<div class=""><span class="media-cnt"><?php echo $albums_count; ?></span><span class="media-label"><?php _e('Total Albums','bp-media'); ?></span></div>
|
303 |
+
</div><!-- .table_user -->
|
304 |
+
<h3 class="sub"><?php _e('Groups','bp-media');?> </h3>
|
305 |
+
<div class="table table_group">
|
306 |
+
|
307 |
+
</div><!-- .table_group -->
|
308 |
+
</div><!-- .bp-media-dashboard-->
|
309 |
+
|
310 |
+
<?php
|
311 |
+
}
|
312 |
+
|
313 |
+
function bp_media_admin_total_count($media_type){
|
314 |
+
|
315 |
+
switch($media_type){
|
316 |
+
case 'photo':
|
317 |
+
return bp_media_total_count_media('image');
|
318 |
+
|
319 |
+
case 'video':
|
320 |
+
return bp_media_total_count_media('video');
|
321 |
+
|
322 |
+
case 'audio':
|
323 |
+
return bp_media_total_count_media('audio');
|
324 |
+
|
325 |
+
case 'album':
|
326 |
+
return bp_media_total_count_albums();
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
function bp_media_admin_group_total_count($media_type){
|
331 |
+
|
332 |
+
switch($media_type){
|
333 |
+
case 'photo':
|
334 |
+
return bp_media_total_count_media('image');
|
335 |
+
|
336 |
+
case 'video':
|
337 |
+
return bp_media_total_count_media('video');
|
338 |
+
|
339 |
+
case 'audio':
|
340 |
+
return bp_media_total_count_media('audio');
|
341 |
+
|
342 |
+
case 'album':
|
343 |
+
return bp_media_total_count_albums();
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
+
function bp_media_total_count_media($type){
|
349 |
+
global $wpdb;
|
350 |
+
|
351 |
+
$query = "SELECT COUNT(*) AS total
|
352 |
+
FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
|
353 |
+
WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value > 0 AND ( wp_posts.post_mime_type LIKE '$type%')";
|
354 |
+
|
355 |
+
$result = $wpdb->get_var( ( $query ) );
|
356 |
+
|
357 |
+
if(isset($result )) return $result;
|
358 |
+
else return false;
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
function bp_media_total_count_albums(){
|
363 |
+
global $wpdb;
|
364 |
+
|
365 |
+
$query = "SELECT COUNT(*) AS total
|
366 |
+
FROM wp_posts RIGHT JOIN wp_postmeta on wp_postmeta.post_id = wp_posts.id
|
367 |
+
WHERE wp_postmeta.meta_key = 'bp-media-key' AND wp_postmeta.meta_value < 0 ";
|
368 |
+
|
369 |
+
$result = $wpdb->get_var( ( $query ) );
|
370 |
+
|
371 |
+
if(isset($result )) return $result;
|
372 |
+
else return false;
|
373 |
+
|
374 |
+
}
|
375 |
?>
|
includes/bp-media-functions.php
CHANGED
@@ -4,22 +4,11 @@ function bp_media_record_activity($args = '') {
|
|
4 |
if (!function_exists('bp_activity_add'))
|
5 |
return false;
|
6 |
$defaults = array(
|
7 |
-
'id' => false, // Pass an existing activity ID to update an existing entry.
|
8 |
-
'action' => '', // The activity action - e.g. "Jon Doe posted an update"
|
9 |
-
'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
|
10 |
'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
|
11 |
-
'type' => false, // The activity type e.g. activity_update, profile_updated
|
12 |
-
'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
|
13 |
-
'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
|
14 |
-
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
|
15 |
-
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
|
16 |
-
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded
|
17 |
-
'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
|
18 |
);
|
19 |
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags');
|
20 |
$r = wp_parse_args($args, $defaults);
|
21 |
-
|
22 |
-
$activity_id = bp_activity_add(array('id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide));
|
23 |
return $activity_id;
|
24 |
}
|
25 |
|
@@ -50,6 +39,9 @@ function bp_media_override_allowed_tags($activity_allowedtags) {
|
|
50 |
$activity_allowedtags['a'] = array();
|
51 |
$activity_allowedtags['a']['title'] = array();
|
52 |
$activity_allowedtags['a']['href'] = array();
|
|
|
|
|
|
|
53 |
return $activity_allowedtags;
|
54 |
}
|
55 |
|
@@ -70,7 +62,8 @@ function bp_media_show_formatted_error_message($messages, $type) {
|
|
70 |
}
|
71 |
|
72 |
function bp_media_conditional_override_allowed_tags($content, $activity=null) {
|
73 |
-
|
|
|
74 |
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
|
75 |
}
|
76 |
return bp_activity_filter_kses($content);
|
@@ -87,38 +80,37 @@ add_action('bp_init', 'bp_media_swap_filters');
|
|
87 |
*/
|
88 |
function bp_media_update_count() {
|
89 |
global $wpdb;
|
90 |
-
$query =
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
$result = $wpdb->get_results($query);
|
95 |
-
$users_count = array();
|
96 |
foreach ($result as $obj) {
|
97 |
-
$
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$count = array(
|
103 |
-
'images' => isset($users_count[$user->ID]['image']) ? intval($users_count[$user->ID]['image']) : 0,
|
104 |
-
'videos' => isset($users_count[$user->ID]['video']) ? intval($users_count[$user->ID]['video']) : 0,
|
105 |
-
'audio' => isset($users_count[$user->ID]['audio']) ? intval($users_count[$user->ID]['audio']) : 0,
|
106 |
);
|
107 |
-
|
108 |
-
$count = array(
|
109 |
-
'images' => 0,
|
110 |
-
'videos' => 0,
|
111 |
-
'audio' => 0
|
112 |
-
);
|
113 |
-
}
|
114 |
-
bp_update_user_meta($user->ID, 'bp_media_count', $count);
|
115 |
}
|
116 |
return true;
|
117 |
}
|
118 |
|
119 |
function bp_media_update_media(){
|
120 |
global $bp_media_current_entry;
|
121 |
-
if($bp_media_current_entry->update_media(array('
|
122 |
@setcookie('bp-message', 'The media has been updated' , time() + 60 * 60 * 24, COOKIEPATH);
|
123 |
@setcookie('bp-message-type', 'success' , time() + 60 * 60 * 24, COOKIEPATH);
|
124 |
wp_redirect($bp_media_current_entry->get_url());
|
@@ -187,4 +179,49 @@ function bp_media_get_feeds($feed_url = 'http://rtcamp.com/tag/buddypress/feed/'
|
|
187 |
</ul><?php
|
188 |
}
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
?>
|
4 |
if (!function_exists('bp_activity_add'))
|
5 |
return false;
|
6 |
$defaults = array(
|
|
|
|
|
|
|
7 |
'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
);
|
9 |
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags');
|
10 |
$r = wp_parse_args($args, $defaults);
|
11 |
+
$activity_id = bp_activity_add($r);
|
|
|
12 |
return $activity_id;
|
13 |
}
|
14 |
|
39 |
$activity_allowedtags['a'] = array();
|
40 |
$activity_allowedtags['a']['title'] = array();
|
41 |
$activity_allowedtags['a']['href'] = array();
|
42 |
+
$activity_allowedtags['ul'] = array();
|
43 |
+
$activity_allowedtags['li'] = array();
|
44 |
+
|
45 |
return $activity_allowedtags;
|
46 |
}
|
47 |
|
62 |
}
|
63 |
|
64 |
function bp_media_conditional_override_allowed_tags($content, $activity=null) {
|
65 |
+
global $bp_media_activity_types;
|
66 |
+
if ($activity != null && in_array($activity->type,$bp_media_activity_types)) {
|
67 |
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
|
68 |
}
|
69 |
return bp_activity_filter_kses($content);
|
80 |
*/
|
81 |
function bp_media_update_count() {
|
82 |
global $wpdb;
|
83 |
+
$query =
|
84 |
+
"SELECT
|
85 |
+
post_author,
|
86 |
+
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
|
87 |
+
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
|
88 |
+
SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
|
89 |
+
SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums,
|
90 |
+
COUNT(*) as Total
|
91 |
+
FROM
|
92 |
+
$wpdb->posts RIGHT JOIN $wpdb->postmeta on wp_postmeta.post_id = wp_posts.id
|
93 |
+
WHERE
|
94 |
+
`meta_key` = 'bp-media-key' AND
|
95 |
+
`meta_value` > 0 AND
|
96 |
+
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
|
97 |
+
GROUP BY post_author";
|
98 |
$result = $wpdb->get_results($query);
|
|
|
99 |
foreach ($result as $obj) {
|
100 |
+
$count = array(
|
101 |
+
'images' => $obj->Images,
|
102 |
+
'videos' => $obj->Videos,
|
103 |
+
'audio' => $obj->Audio,
|
104 |
+
'albums'=> $obj->Albums
|
|
|
|
|
|
|
|
|
105 |
);
|
106 |
+
bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
return true;
|
109 |
}
|
110 |
|
111 |
function bp_media_update_media(){
|
112 |
global $bp_media_current_entry;
|
113 |
+
if($bp_media_current_entry->update_media(array('description'=> esc_html($_POST['bp_media_description']),'name'=>esc_html($_POST['bp_media_title'])))){
|
114 |
@setcookie('bp-message', 'The media has been updated' , time() + 60 * 60 * 24, COOKIEPATH);
|
115 |
@setcookie('bp-message-type', 'success' , time() + 60 * 60 * 24, COOKIEPATH);
|
116 |
wp_redirect($bp_media_current_entry->get_url());
|
179 |
</ul><?php
|
180 |
}
|
181 |
|
182 |
+
function bp_media_update_album_activity($album,$current_time = true,$delete_media_id = null){
|
183 |
+
if(!is_object($album)){
|
184 |
+
$album = new BP_Media_Album($album);
|
185 |
+
}
|
186 |
+
$args = array(
|
187 |
+
'post_parent' => $album->get_id(),
|
188 |
+
'numberposts' => 4,
|
189 |
+
'post_type' => 'attachment',
|
190 |
+
);
|
191 |
+
if($delete_media_id)
|
192 |
+
$args['exclude'] = $delete_media_id;
|
193 |
+
$attachments = get_posts($args);
|
194 |
+
if(is_array($attachments)){
|
195 |
+
$content = '<ul>';
|
196 |
+
foreach($attachments as $media){
|
197 |
+
$bp_media = new BP_Media_Host_Wordpress($media->ID);
|
198 |
+
$content .= $bp_media->get_album_activity_content();
|
199 |
+
}
|
200 |
+
$content .= '</ul>';
|
201 |
+
$activity_id = get_post_meta($album->get_id(), 'bp_media_child_activity');
|
202 |
+
if($activity_id){
|
203 |
+
$args = array(
|
204 |
+
'in' => $activity_id,
|
205 |
+
);
|
206 |
+
|
207 |
+
$activity = @bp_activity_get($args);
|
208 |
+
if(isset($activity['activities'][0]->id)){
|
209 |
+
$args = array(
|
210 |
+
'content' => $content,
|
211 |
+
'id' => $activity_id,
|
212 |
+
'type' => 'album_updated',
|
213 |
+
'user_id' => $activity['activities'][0]->user_id,
|
214 |
+
'action' => apply_filters( 'bp_media_filter_album_updated', sprintf( __( '%1$s added new media in album %2$s', 'bp-media'), bp_core_get_userlink( $activity['activities'][0]->user_id ), '<a href="' . $album->get_url() . '">' . $album->get_title() . '</a>' ) ),
|
215 |
+
'component' => BP_MEDIA_SLUG, // The name/ID of the component e.g. groups, profile, mycomponent
|
216 |
+
'primary_link' => $activity['activities'][0]->primary_link,
|
217 |
+
'item_id' => $activity['activities'][0]->item_id,
|
218 |
+
'secondary_item_id' => $activity['activities'][0]->secondary_item_id,
|
219 |
+
'recorded_time' => $current_time? bp_core_current_time(): $activity['activities'][0]->date_recorded,
|
220 |
+
'hide_sitewide' => $activity['activities'][0]->hide_sitewide
|
221 |
+
);
|
222 |
+
bp_media_record_activity($args);
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
?>
|
includes/bp-media-loader.php
CHANGED
@@ -12,7 +12,7 @@ define('BP_MEDIA_SLUG', 'media');
|
|
12 |
define('BP_MEDIA_UPLOAD_SLUG', 'upload');
|
13 |
define('BP_MEDIA_DELETE_SLUG', 'delete');
|
14 |
|
15 |
-
define('BP_MEDIA_IMAGES_SLUG', '
|
16 |
define('BP_MEDIA_IMAGES_ENTRY_SLUG', 'view');
|
17 |
define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit');
|
18 |
|
@@ -20,24 +20,33 @@ define('BP_MEDIA_VIDEOS_SLUG', 'videos');
|
|
20 |
define('BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch');
|
21 |
define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit');
|
22 |
|
23 |
-
define('BP_MEDIA_AUDIO_SLUG', '
|
24 |
define('BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen');
|
25 |
define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit');
|
26 |
|
|
|
|
|
|
|
|
|
27 |
/* Label Constants(need to be translatable) */
|
28 |
define('BP_MEDIA_LABEL', __('Media', 'bp-media'));
|
29 |
define('BP_MEDIA_LABEL_SINGULAR', __('Media', 'bp-media'));
|
30 |
-
define('BP_MEDIA_IMAGES_LABEL', __('
|
31 |
-
define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('
|
32 |
define('BP_MEDIA_VIDEOS_LABEL', __('Videos', 'bp-media'));
|
33 |
define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', 'bp-media'));
|
34 |
-
define('BP_MEDIA_AUDIO_LABEL', __('
|
35 |
-
define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('
|
|
|
|
|
36 |
define('BP_MEDIA_UPLOAD_LABEL', __('Upload', 'bp-media'));
|
37 |
|
38 |
/* Global variable to store the query */
|
39 |
global $bp_media_query;
|
40 |
|
|
|
|
|
|
|
41 |
/* Global variable for making distinct ids for different media objects in activity stream */
|
42 |
global $bp_media_counter;
|
43 |
$bp_media_counter = 0;
|
@@ -77,33 +86,41 @@ $bp_media_default_sizes = array(
|
|
77 |
global $bp_media_default_excerpts;
|
78 |
$bp_media_default_excerpts=array(
|
79 |
'single_entry_title' => 100,
|
80 |
-
'single_entry_description' => 500,
|
81 |
'activity_entry_title' => 50,
|
82 |
'activity_entry_description'=> 500
|
83 |
);
|
84 |
|
|
|
85 |
$bp_media_options = get_option('bp_media_options',array(
|
86 |
'videos_enabled' => true,
|
87 |
'audio_enabled' => true,
|
88 |
'images_enabled' => true,
|
|
|
89 |
));
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
/* To set the language according to the locale selected and availability of the language file. */
|
92 |
if (file_exists(BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo'))
|
93 |
load_textdomain('bp-media', BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo');
|
94 |
|
95 |
/**
|
96 |
* BP Media Class, extends BP_Component
|
97 |
-
*
|
98 |
* @see BP_Component
|
99 |
-
*
|
100 |
* @since BP Media 2.0
|
101 |
*/
|
102 |
class BP_Media_Component extends BP_Component {
|
103 |
|
104 |
/**
|
105 |
* Hold the messages generated during initialization process and will be shown on the screen functions
|
106 |
-
*
|
107 |
* @since BP Media 2.0
|
108 |
*/
|
109 |
var $messages = array(
|
@@ -111,10 +128,11 @@ class BP_Media_Component extends BP_Component {
|
|
111 |
'info' => array(),
|
112 |
'updated' => array()
|
113 |
);
|
114 |
-
|
|
|
115 |
/**
|
116 |
* Constructor for the BuddyPress Media
|
117 |
-
*
|
118 |
* @since BP Media 2.0
|
119 |
*/
|
120 |
function __construct() {
|
@@ -124,10 +142,10 @@ class BP_Media_Component extends BP_Component {
|
|
124 |
$bp->active_components[$this->id] = '1';
|
125 |
add_action('init', array(&$this, 'register_post_types'));
|
126 |
}
|
127 |
-
|
128 |
/**
|
129 |
* Includes the files required for the BuddyPress Media and calls the parent class' includes function
|
130 |
-
*
|
131 |
* @since BP Media 2.0
|
132 |
*/
|
133 |
function includes() {
|
@@ -139,7 +157,9 @@ class BP_Media_Component extends BP_Component {
|
|
139 |
'includes/bp-media-actions.php',
|
140 |
'includes/bp-media-interface.php',
|
141 |
'includes/bp-media-class-wordpress.php',
|
142 |
-
'includes/bp-media-shortcodes.php'
|
|
|
|
|
143 |
);
|
144 |
if (is_admin() || is_network_admin()) {
|
145 |
$includes[] = 'includes/bp-media-admin.php';
|
@@ -164,6 +184,34 @@ class BP_Media_Component extends BP_Component {
|
|
164 |
|
165 |
function setup_nav() {
|
166 |
/* Add 'Media' to the main navigation */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
if (bp_is_my_profile()) {
|
168 |
$main_nav = array(
|
169 |
'name' => BP_MEDIA_LABEL,
|
@@ -198,36 +246,6 @@ class BP_Media_Component extends BP_Component {
|
|
198 |
'screen_function' => 'bp_media_images_screen'
|
199 |
));
|
200 |
|
201 |
-
bp_core_new_nav_item(array(
|
202 |
-
'name' => BP_MEDIA_VIDEOS_LABEL,
|
203 |
-
'slug' => BP_MEDIA_VIDEOS_SLUG,
|
204 |
-
'screen_function' => 'bp_media_videos_screen'
|
205 |
-
));
|
206 |
-
|
207 |
-
bp_core_new_nav_item(array(
|
208 |
-
'name' => BP_MEDIA_AUDIO_LABEL,
|
209 |
-
'slug' => BP_MEDIA_AUDIO_SLUG,
|
210 |
-
'screen_function' => 'bp_media_audio_screen'
|
211 |
-
));
|
212 |
-
|
213 |
-
bp_core_new_subnav_item(array(
|
214 |
-
'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
|
215 |
-
'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
|
216 |
-
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
217 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
218 |
-
'position' => 90, /* Index of where this nav item should be positioned */
|
219 |
-
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
220 |
-
));
|
221 |
-
|
222 |
-
bp_core_new_subnav_item(array(
|
223 |
-
'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
|
224 |
-
'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
|
225 |
-
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
226 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
227 |
-
'position' => 90, /* Index of where this nav item should be positioned */
|
228 |
-
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
229 |
-
));
|
230 |
-
|
231 |
bp_core_new_subnav_item(array(
|
232 |
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
233 |
'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
|
@@ -236,7 +254,7 @@ class BP_Media_Component extends BP_Component {
|
|
236 |
'position' => 90, /* Index of where this nav item should be positioned */
|
237 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
238 |
));
|
239 |
-
|
240 |
bp_core_new_subnav_item(array(
|
241 |
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
242 |
'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
|
@@ -245,7 +263,7 @@ class BP_Media_Component extends BP_Component {
|
|
245 |
'position' => 90, /* Index of where this nav item should be positioned */
|
246 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
247 |
));
|
248 |
-
|
249 |
bp_core_new_subnav_item(array(
|
250 |
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
251 |
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
@@ -254,25 +272,32 @@ class BP_Media_Component extends BP_Component {
|
|
254 |
'position' => 90, /* Index of where this nav item should be positioned */
|
255 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
256 |
));
|
257 |
-
|
258 |
bp_core_new_subnav_item(array(
|
259 |
-
'name' => '
|
260 |
-
'slug' =>
|
261 |
-
'parent_slug' =>
|
262 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() .
|
263 |
'position' => 90, /* Index of where this nav item should be positioned */
|
264 |
-
'screen_function' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
));
|
266 |
-
|
267 |
bp_core_new_subnav_item(array(
|
268 |
-
'name' => '
|
269 |
-
'slug' =>
|
270 |
-
'parent_slug' =>
|
271 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() .
|
272 |
'position' => 90, /* Index of where this nav item should be positioned */
|
273 |
-
'screen_function' => '
|
274 |
));
|
275 |
-
|
276 |
bp_core_new_subnav_item(array(
|
277 |
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
278 |
'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
|
@@ -290,14 +315,48 @@ class BP_Media_Component extends BP_Component {
|
|
290 |
'position' => 90, /* Index of where this nav item should be positioned */
|
291 |
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
292 |
));
|
293 |
-
|
294 |
bp_core_new_subnav_item(array(
|
295 |
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
296 |
'slug' => 'page', /* URL slug for the nav item */
|
297 |
-
'parent_slug' =>
|
298 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() .
|
299 |
'position' => 90, /* Index of where this nav item should be positioned */
|
300 |
-
'screen_function' => '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
));
|
302 |
|
303 |
bp_core_new_subnav_item(array(
|
@@ -308,18 +367,86 @@ class BP_Media_Component extends BP_Component {
|
|
308 |
'position' => 90, /* Index of where this nav item should be positioned */
|
309 |
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
310 |
));
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
bp_core_new_subnav_item(array(
|
313 |
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
314 |
'slug' => 'page', /* URL slug for the nav item */
|
315 |
-
'parent_slug' =>
|
316 |
-
'parent_url' => trailingslashit(bp_loggedin_user_domain() .
|
317 |
'position' => 90, /* Index of where this nav item should be positioned */
|
318 |
-
'screen_function' => '
|
319 |
));
|
320 |
}
|
321 |
|
|
|
|
|
|
|
322 |
function register_post_types() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
/* Set up labels for the post type */
|
324 |
$labels = array(
|
325 |
'name' => __('Media', 'bp-media'),
|
@@ -343,7 +470,6 @@ class BP_Media_Component extends BP_Component {
|
|
343 |
|
344 |
function bp_media_load_core_component() {
|
345 |
global $bp;
|
346 |
-
|
347 |
$bp->{BP_MEDIA_SLUG} = new BP_Media_Component();
|
348 |
}
|
349 |
add_action('bp_loaded', 'bp_media_load_core_component');
|
@@ -354,28 +480,36 @@ add_action('bp_loaded', 'bp_media_load_core_component');
|
|
354 |
function bp_media_custom_nav() {
|
355 |
global $bp;
|
356 |
foreach ($bp->bp_nav as $key => $nav_item) {
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
|
|
|
|
|
|
|
|
369 |
}
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
}
|
376 |
-
$bp->action_variables[0] = $bp->current_action;
|
377 |
-
$bp->current_action = $bp->current_component;
|
378 |
-
$bp->current_component = BP_MEDIA_SLUG;
|
379 |
}
|
380 |
}
|
381 |
add_action('bp_setup_nav', 'bp_media_custom_nav', 999);
|
12 |
define('BP_MEDIA_UPLOAD_SLUG', 'upload');
|
13 |
define('BP_MEDIA_DELETE_SLUG', 'delete');
|
14 |
|
15 |
+
define('BP_MEDIA_IMAGES_SLUG', 'photos');
|
16 |
define('BP_MEDIA_IMAGES_ENTRY_SLUG', 'view');
|
17 |
define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit');
|
18 |
|
20 |
define('BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch');
|
21 |
define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit');
|
22 |
|
23 |
+
define('BP_MEDIA_AUDIO_SLUG', 'music');
|
24 |
define('BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen');
|
25 |
define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit');
|
26 |
|
27 |
+
define('BP_MEDIA_ALBUMS_SLUG', 'albums');
|
28 |
+
define('BP_MEDIA_ALBUMS_ENTRY_SLUG', 'list');
|
29 |
+
define('BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit');
|
30 |
+
|
31 |
/* Label Constants(need to be translatable) */
|
32 |
define('BP_MEDIA_LABEL', __('Media', 'bp-media'));
|
33 |
define('BP_MEDIA_LABEL_SINGULAR', __('Media', 'bp-media'));
|
34 |
+
define('BP_MEDIA_IMAGES_LABEL', __('Photos', 'bp-media'));
|
35 |
+
define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('Photo', 'bp-media'));
|
36 |
define('BP_MEDIA_VIDEOS_LABEL', __('Videos', 'bp-media'));
|
37 |
define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', 'bp-media'));
|
38 |
+
define('BP_MEDIA_AUDIO_LABEL', __('Music', 'bp-media'));
|
39 |
+
define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('Music', 'bp-media'));
|
40 |
+
define('BP_MEDIA_ALBUMS_LABEL', __('Albums', 'bp-media'));
|
41 |
+
define('BP_MEDIA_ALBUMS_LABEL_SINGULAR', __('Album', 'bp-media'));
|
42 |
define('BP_MEDIA_UPLOAD_LABEL', __('Upload', 'bp-media'));
|
43 |
|
44 |
/* Global variable to store the query */
|
45 |
global $bp_media_query;
|
46 |
|
47 |
+
/* Global variable to store the albums query */
|
48 |
+
global $bp_media_albums_query;
|
49 |
+
|
50 |
/* Global variable for making distinct ids for different media objects in activity stream */
|
51 |
global $bp_media_counter;
|
52 |
$bp_media_counter = 0;
|
86 |
global $bp_media_default_excerpts;
|
87 |
$bp_media_default_excerpts=array(
|
88 |
'single_entry_title' => 100,
|
89 |
+
'single_entry_description' => 500,
|
90 |
'activity_entry_title' => 50,
|
91 |
'activity_entry_description'=> 500
|
92 |
);
|
93 |
|
94 |
+
global $bp_media_options;
|
95 |
$bp_media_options = get_option('bp_media_options',array(
|
96 |
'videos_enabled' => true,
|
97 |
'audio_enabled' => true,
|
98 |
'images_enabled' => true,
|
99 |
+
'download_enabled' => true
|
100 |
));
|
101 |
|
102 |
+
global $bp_media_activity_types;
|
103 |
+
$bp_media_activity_types = array('media_upload','album_updated','album_created');
|
104 |
+
|
105 |
+
global $bp_media_hidden_activity_cache;
|
106 |
+
$bp_media_hidden_activity_cache = array();
|
107 |
+
|
108 |
/* To set the language according to the locale selected and availability of the language file. */
|
109 |
if (file_exists(BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo'))
|
110 |
load_textdomain('bp-media', BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo');
|
111 |
|
112 |
/**
|
113 |
* BP Media Class, extends BP_Component
|
114 |
+
*
|
115 |
* @see BP_Component
|
116 |
+
*
|
117 |
* @since BP Media 2.0
|
118 |
*/
|
119 |
class BP_Media_Component extends BP_Component {
|
120 |
|
121 |
/**
|
122 |
* Hold the messages generated during initialization process and will be shown on the screen functions
|
123 |
+
*
|
124 |
* @since BP Media 2.0
|
125 |
*/
|
126 |
var $messages = array(
|
128 |
'info' => array(),
|
129 |
'updated' => array()
|
130 |
);
|
131 |
+
|
132 |
+
|
133 |
/**
|
134 |
* Constructor for the BuddyPress Media
|
135 |
+
*
|
136 |
* @since BP Media 2.0
|
137 |
*/
|
138 |
function __construct() {
|
142 |
$bp->active_components[$this->id] = '1';
|
143 |
add_action('init', array(&$this, 'register_post_types'));
|
144 |
}
|
145 |
+
|
146 |
/**
|
147 |
* Includes the files required for the BuddyPress Media and calls the parent class' includes function
|
148 |
+
*
|
149 |
* @since BP Media 2.0
|
150 |
*/
|
151 |
function includes() {
|
157 |
'includes/bp-media-actions.php',
|
158 |
'includes/bp-media-interface.php',
|
159 |
'includes/bp-media-class-wordpress.php',
|
160 |
+
'includes/bp-media-shortcodes.php',
|
161 |
+
'includes/bp-media-widgets.php',
|
162 |
+
'includes/bp-media-class-album.php',
|
163 |
);
|
164 |
if (is_admin() || is_network_admin()) {
|
165 |
$includes[] = 'includes/bp-media-admin.php';
|
184 |
|
185 |
function setup_nav() {
|
186 |
/* Add 'Media' to the main navigation */
|
187 |
+
global $bp;
|
188 |
+
switch($bp->current_component){
|
189 |
+
case BP_MEDIA_IMAGES_SLUG:
|
190 |
+
if(is_numeric($bp->current_action)){
|
191 |
+
$bp->action_variables[0]=$bp->current_action;
|
192 |
+
$bp->current_action=BP_MEDIA_IMAGES_ENTRY_SLUG;
|
193 |
+
}
|
194 |
+
break;
|
195 |
+
case BP_MEDIA_AUDIO_SLUG:
|
196 |
+
if(is_numeric($bp->current_action)){
|
197 |
+
$bp->action_variables[0]=$bp->current_action;
|
198 |
+
$bp->current_action=BP_MEDIA_AUDIO_ENTRY_SLUG;
|
199 |
+
}
|
200 |
+
break;
|
201 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
202 |
+
if(is_numeric($bp->current_action)){
|
203 |
+
$bp->action_variables[0]=$bp->current_action;
|
204 |
+
$bp->current_action=BP_MEDIA_VIDEOS_ENTRY_SLUG;
|
205 |
+
}
|
206 |
+
break;
|
207 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
208 |
+
if(is_numeric($bp->current_action)){
|
209 |
+
$bp->action_variables[0]=$bp->current_action;
|
210 |
+
$bp->current_action=BP_MEDIA_ALBUMS_ENTRY_SLUG;
|
211 |
+
}
|
212 |
+
break;
|
213 |
+
}
|
214 |
+
|
215 |
if (bp_is_my_profile()) {
|
216 |
$main_nav = array(
|
217 |
'name' => BP_MEDIA_LABEL,
|
246 |
'screen_function' => 'bp_media_images_screen'
|
247 |
));
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
bp_core_new_subnav_item(array(
|
250 |
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
251 |
'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
|
254 |
'position' => 90, /* Index of where this nav item should be positioned */
|
255 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
256 |
));
|
257 |
+
|
258 |
bp_core_new_subnav_item(array(
|
259 |
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
260 |
'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
|
263 |
'position' => 90, /* Index of where this nav item should be positioned */
|
264 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
265 |
));
|
266 |
+
|
267 |
bp_core_new_subnav_item(array(
|
268 |
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
269 |
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
272 |
'position' => 90, /* Index of where this nav item should be positioned */
|
273 |
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
274 |
));
|
275 |
+
|
276 |
bp_core_new_subnav_item(array(
|
277 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
278 |
+
'slug' => 'page', /* URL slug for the nav item */
|
279 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
280 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
281 |
'position' => 90, /* Index of where this nav item should be positioned */
|
282 |
+
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
283 |
+
));
|
284 |
+
|
285 |
+
|
286 |
+
bp_core_new_nav_item(array(
|
287 |
+
'name' => BP_MEDIA_VIDEOS_LABEL,
|
288 |
+
'slug' => BP_MEDIA_VIDEOS_SLUG,
|
289 |
+
'screen_function' => 'bp_media_videos_screen'
|
290 |
));
|
291 |
+
|
292 |
bp_core_new_subnav_item(array(
|
293 |
+
'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
|
294 |
+
'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
|
295 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
296 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
297 |
'position' => 90, /* Index of where this nav item should be positioned */
|
298 |
+
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
299 |
));
|
300 |
+
|
301 |
bp_core_new_subnav_item(array(
|
302 |
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
303 |
'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
|
315 |
'position' => 90, /* Index of where this nav item should be positioned */
|
316 |
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
317 |
));
|
318 |
+
|
319 |
bp_core_new_subnav_item(array(
|
320 |
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
321 |
'slug' => 'page', /* URL slug for the nav item */
|
322 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
323 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
324 |
'position' => 90, /* Index of where this nav item should be positioned */
|
325 |
+
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
326 |
+
));
|
327 |
+
|
328 |
+
|
329 |
+
bp_core_new_nav_item(array(
|
330 |
+
'name' => BP_MEDIA_AUDIO_LABEL,
|
331 |
+
'slug' => BP_MEDIA_AUDIO_SLUG,
|
332 |
+
'screen_function' => 'bp_media_audio_screen'
|
333 |
+
));
|
334 |
+
|
335 |
+
bp_core_new_subnav_item(array(
|
336 |
+
'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
|
337 |
+
'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
|
338 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
339 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
340 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
341 |
+
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
342 |
+
));
|
343 |
+
|
344 |
+
bp_core_new_subnav_item(array(
|
345 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
346 |
+
'slug' => BP_MEDIA_AUDIO_EDIT_SLUG, /* URL slug for the nav item */
|
347 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
348 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
349 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
350 |
+
'screen_function' => 'bp_media_audio_edit_screen', /* The name of the function to run when clicked */
|
351 |
+
));
|
352 |
+
|
353 |
+
bp_core_new_subnav_item(array(
|
354 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
355 |
+
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
356 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
357 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
358 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
359 |
+
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
360 |
));
|
361 |
|
362 |
bp_core_new_subnav_item(array(
|
367 |
'position' => 90, /* Index of where this nav item should be positioned */
|
368 |
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
369 |
));
|
370 |
+
|
371 |
+
|
372 |
+
bp_core_new_nav_item(array(
|
373 |
+
'name' => BP_MEDIA_ALBUMS_LABEL,
|
374 |
+
'slug' => BP_MEDIA_ALBUMS_SLUG,
|
375 |
+
'screen_function' => 'bp_media_albums_screen'
|
376 |
+
));
|
377 |
+
|
378 |
+
bp_core_new_subnav_item(array(
|
379 |
+
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
380 |
+
'slug' => BP_MEDIA_ALBUMS_ENTRY_SLUG, /* URL slug for the nav item */
|
381 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
382 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
383 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
384 |
+
'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
|
385 |
+
));
|
386 |
+
|
387 |
+
bp_core_new_subnav_item(array(
|
388 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
389 |
+
'slug' => BP_MEDIA_ALBUMS_EDIT_SLUG, /* URL slug for the nav item */
|
390 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
391 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
392 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
393 |
+
'screen_function' => 'bp_media_albums_edit_screen', /* The name of the function to run when clicked */
|
394 |
+
));
|
395 |
+
|
396 |
+
bp_core_new_subnav_item(array(
|
397 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
398 |
+
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
399 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
400 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
401 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
402 |
+
'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
|
403 |
+
));
|
404 |
+
|
405 |
bp_core_new_subnav_item(array(
|
406 |
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
407 |
'slug' => 'page', /* URL slug for the nav item */
|
408 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
409 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
410 |
'position' => 90, /* Index of where this nav item should be positioned */
|
411 |
+
'screen_function' => 'bp_media_albums_screen', /* The name of the function to run when clicked */
|
412 |
));
|
413 |
}
|
414 |
|
415 |
+
/**
|
416 |
+
* Creating a custom post type album for BuddyPress Media
|
417 |
+
*/
|
418 |
function register_post_types() {
|
419 |
+
$labels = array(
|
420 |
+
'name' => __('Albums', 'bp-media'),
|
421 |
+
'singular_name' => __('Album', 'bp-media'),
|
422 |
+
'add_new' => __('Create', 'bp-media'),
|
423 |
+
'add_new_item' => __('Create Album', 'bp-media'),
|
424 |
+
'edit_item' => __('Edit Album', 'bp-media'),
|
425 |
+
'new_item' => __('New Album', 'bp-media'),
|
426 |
+
'all_items' => __('All Albums', 'bp-media'),
|
427 |
+
'view_item' => __('View Album', 'bp-media'),
|
428 |
+
'search_items' => __('Search Albums', 'bp-media'),
|
429 |
+
'not_found' => __('No album found', 'bp-media'),
|
430 |
+
'not_found_in_trash' => __('No album found in Trash', 'bp-media'),
|
431 |
+
'parent_item_colon' => '',
|
432 |
+
'menu_name' => __('Albums', 'bp-media')
|
433 |
+
);
|
434 |
+
|
435 |
+
$args = array(
|
436 |
+
'labels' => $labels,
|
437 |
+
'public' => true,
|
438 |
+
'publicly_queryable' => true,
|
439 |
+
'show_ui' => false,
|
440 |
+
'show_in_menu' => false,
|
441 |
+
'query_var' => true,
|
442 |
+
'capability_type' => 'post',
|
443 |
+
'has_archive' => true,
|
444 |
+
'hierarchical' => false,
|
445 |
+
'menu_position' => null,
|
446 |
+
'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'comments' )
|
447 |
+
);
|
448 |
+
register_post_type('bp_media_album', $args);
|
449 |
+
|
450 |
/* Set up labels for the post type */
|
451 |
$labels = array(
|
452 |
'name' => __('Media', 'bp-media'),
|
470 |
|
471 |
function bp_media_load_core_component() {
|
472 |
global $bp;
|
|
|
473 |
$bp->{BP_MEDIA_SLUG} = new BP_Media_Component();
|
474 |
}
|
475 |
add_action('bp_loaded', 'bp_media_load_core_component');
|
480 |
function bp_media_custom_nav() {
|
481 |
global $bp;
|
482 |
foreach ($bp->bp_nav as $key => $nav_item) {
|
483 |
+
switch($nav_item['slug']){
|
484 |
+
case BP_MEDIA_IMAGES_SLUG:
|
485 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
486 |
+
case BP_MEDIA_AUDIO_SLUG:
|
487 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
488 |
+
$bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
|
489 |
+
'name' => $nav_item['name'],
|
490 |
+
'link' => (isset($bp->displayed_user->domain) ? $bp->displayed_user->domain : (isset($bp->loggedin_user->domain) ? $bp->loggedin_user->domain : '')) . $nav_item['slug'] . '/',
|
491 |
+
'slug' => $nav_item['slug'],
|
492 |
+
'css_id' => $nav_item['css_id'],
|
493 |
+
'position' => $nav_item['position'],
|
494 |
+
'screen_function' => $nav_item['screen_function'],
|
495 |
+
'user_has_access' => true,
|
496 |
+
'parent_url' => trailingslashit(bp_displayed_user_domain())
|
497 |
+
);
|
498 |
+
unset($bp->bp_nav[$key]);
|
499 |
}
|
500 |
+
switch($bp->current_component){
|
501 |
+
case BP_MEDIA_IMAGES_SLUG:
|
502 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
503 |
+
case BP_MEDIA_AUDIO_SLUG:
|
504 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
505 |
+
$count = count($bp->action_variables);
|
506 |
+
for ($i = $count; $i > 0; $i--) {
|
507 |
+
$bp->action_variables[$i] = $bp->action_variables[$i - 1];
|
508 |
+
}
|
509 |
+
$bp->action_variables[0] = $bp->current_action;
|
510 |
+
$bp->current_action = $bp->current_component;
|
511 |
+
$bp->current_component = BP_MEDIA_SLUG;
|
512 |
}
|
|
|
|
|
|
|
513 |
}
|
514 |
}
|
515 |
add_action('bp_setup_nav', 'bp_media_custom_nav', 999);
|
includes/bp-media-screens.php
CHANGED
@@ -12,19 +12,25 @@ if (!defined('ABSPATH'))
|
|
12 |
* Screen function for Upload page
|
13 |
*/
|
14 |
function bp_media_upload_screen() {
|
15 |
-
|
16 |
add_action('bp_template_title', 'bp_media_upload_screen_title');
|
17 |
add_action('bp_template_content', 'bp_media_upload_screen_content');
|
18 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
19 |
}
|
20 |
|
|
|
|
|
|
|
21 |
function bp_media_upload_screen_title() {
|
22 |
_e('Upload Media');
|
23 |
}
|
24 |
|
|
|
|
|
|
|
25 |
function bp_media_upload_screen_content() {
|
26 |
do_action('bp_media_before_content');
|
27 |
-
|
28 |
do_action('bp_media_after_content');
|
29 |
}
|
30 |
|
@@ -33,6 +39,7 @@ function bp_media_upload_screen_content() {
|
|
33 |
*/
|
34 |
function bp_media_images_screen() {
|
35 |
global $bp;
|
|
|
36 |
if (isset($bp->action_variables[0])) {
|
37 |
switch ($bp->action_variables[0]) {
|
38 |
case BP_MEDIA_IMAGES_EDIT_SLUG :
|
@@ -79,22 +86,27 @@ function bp_media_images_screen() {
|
|
79 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
80 |
}
|
81 |
|
|
|
|
|
|
|
82 |
function bp_media_images_screen_title() {
|
83 |
_e('Images List Page');
|
84 |
}
|
85 |
|
|
|
|
|
|
|
86 |
function bp_media_images_screen_content() {
|
87 |
global $bp_media_query;
|
88 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
89 |
-
bp_media_show_pagination();
|
90 |
do_action('bp_media_before_content');
|
91 |
-
echo '<ul id="
|
92 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
93 |
bp_media_the_content();
|
94 |
endwhile;
|
95 |
echo '</ul>';
|
|
|
96 |
do_action('bp_media_after_content');
|
97 |
-
bp_media_show_pagination('bottom');
|
98 |
else:
|
99 |
bp_media_show_formatted_error_message(__('Sorry, no images were found.', 'bp-media'), 'info');
|
100 |
endif;
|
@@ -120,7 +132,7 @@ function bp_media_images_edit_screen() {
|
|
120 |
exit;
|
121 |
}
|
122 |
bp_media_check_user();
|
123 |
-
|
124 |
//For saving the data if the form is submitted
|
125 |
if(array_key_exists('bp_media_title', $_POST)){
|
126 |
bp_media_update_media();
|
@@ -130,10 +142,16 @@ function bp_media_images_edit_screen() {
|
|
130 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
131 |
}
|
132 |
|
|
|
|
|
|
|
133 |
function bp_media_images_edit_screen_title() {
|
134 |
_e('Edit Image','bp-media');
|
135 |
}
|
136 |
|
|
|
|
|
|
|
137 |
function bp_media_images_edit_screen_content() {
|
138 |
global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
|
139 |
?>
|
@@ -159,12 +177,22 @@ function bp_media_images_entry_screen_title() {
|
|
159 |
}
|
160 |
|
161 |
function bp_media_images_entry_screen_content() {
|
162 |
-
global $bp, $bp_media_current_entry;
|
163 |
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
164 |
return false;
|
165 |
do_action('bp_media_before_content');
|
166 |
echo '<div class="bp-media-single bp-media-image">';
|
167 |
echo $bp_media_current_entry->get_media_single_content();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
echo $bp_media_current_entry->show_comment_form();
|
169 |
echo '</div>';
|
170 |
do_action('bp_media_after_content');
|
@@ -175,6 +203,7 @@ function bp_media_images_entry_screen_content() {
|
|
175 |
*/
|
176 |
function bp_media_videos_screen() {
|
177 |
global $bp;
|
|
|
178 |
if (isset($bp->action_variables[0])) {
|
179 |
switch ($bp->action_variables[0]) {
|
180 |
case BP_MEDIA_VIDEOS_EDIT_SLUG :
|
@@ -201,6 +230,8 @@ function bp_media_videos_screen() {
|
|
201 |
}
|
202 |
bp_media_entry_delete();
|
203 |
break;
|
|
|
|
|
204 |
default:
|
205 |
bp_media_set_query();
|
206 |
add_action('bp_template_content', 'bp_media_videos_screen_content');
|
@@ -219,15 +250,14 @@ function bp_media_videos_screen_title() {
|
|
219 |
function bp_media_videos_screen_content() {
|
220 |
global $bp_media_query;
|
221 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
222 |
-
bp_media_show_pagination();
|
223 |
do_action('bp_media_before_content');
|
224 |
-
echo '<ul class="bp-media-gallery">';
|
225 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
226 |
bp_media_the_content();
|
227 |
endwhile;
|
228 |
echo '</ul>';
|
|
|
229 |
do_action('bp_media_after_content');
|
230 |
-
bp_media_show_pagination('bottom');
|
231 |
else:
|
232 |
bp_media_show_formatted_error_message(__('Sorry, no videos were found.', 'bp-media'), 'info');
|
233 |
endif;
|
@@ -244,7 +274,6 @@ function bp_media_videos_edit_screen() {
|
|
244 |
//Creating global bp_media_current_entry for later use
|
245 |
try {
|
246 |
$bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
|
247 |
-
|
248 |
} catch (Exception $e) {
|
249 |
/* Send the values to the cookie for page reload display */
|
250 |
@setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
|
@@ -253,7 +282,7 @@ function bp_media_videos_edit_screen() {
|
|
253 |
exit;
|
254 |
}
|
255 |
bp_media_check_user();
|
256 |
-
|
257 |
//For saving the data if the form is submitted
|
258 |
if(array_key_exists('bp_media_title', $_POST)){
|
259 |
bp_media_update_media();
|
@@ -292,12 +321,22 @@ function bp_media_videos_entry_screen_title() {
|
|
292 |
}
|
293 |
|
294 |
function bp_media_videos_entry_screen_content() {
|
295 |
-
global $bp, $bp_media_current_entry;
|
296 |
if (!$bp->action_variables[0] == BP_MEDIA_VIDEOS_ENTRY_SLUG)
|
297 |
return false;
|
298 |
do_action('bp_media_before_content');
|
299 |
echo '<div class="bp-media-single bp-media-video">';
|
300 |
echo $bp_media_current_entry->get_media_single_content();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
echo $bp_media_current_entry->show_comment_form();
|
302 |
echo '</div>';
|
303 |
do_action('bp_media_after_content');
|
@@ -308,6 +347,7 @@ function bp_media_videos_entry_screen_content() {
|
|
308 |
*/
|
309 |
function bp_media_audio_screen() {
|
310 |
global $bp;
|
|
|
311 |
if (isset($bp->action_variables[0])) {
|
312 |
switch ($bp->action_variables[0]) {
|
313 |
case BP_MEDIA_AUDIO_EDIT_SLUG :
|
@@ -345,22 +385,27 @@ function bp_media_audio_screen() {
|
|
345 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
346 |
}
|
347 |
|
|
|
|
|
|
|
348 |
function bp_media_audio_screen_title() {
|
349 |
_e('Audio List Page');
|
350 |
}
|
351 |
|
|
|
|
|
|
|
352 |
function bp_media_audio_screen_content() {
|
353 |
global $bp_media_query;
|
354 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
355 |
-
bp_media_show_pagination();
|
356 |
do_action('bp_media_before_content');
|
357 |
-
echo '<ul class="bp-media-gallery">';
|
358 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
359 |
bp_media_the_content();
|
360 |
endwhile;
|
361 |
echo '</ul>';
|
|
|
362 |
do_action('bp_media_after_content');
|
363 |
-
bp_media_show_pagination('bottom');
|
364 |
else:
|
365 |
bp_media_show_formatted_error_message(__('Sorry, no audio files were found.', 'bp-media'), 'info');
|
366 |
endif;
|
@@ -386,7 +431,7 @@ function bp_media_audio_edit_screen() {
|
|
386 |
exit;
|
387 |
}
|
388 |
bp_media_check_user();
|
389 |
-
|
390 |
//For saving the data if the form is submitted
|
391 |
if(array_key_exists('bp_media_title', $_POST)){
|
392 |
bp_media_update_media();
|
@@ -425,12 +470,22 @@ function bp_media_audio_entry_screen_title() {
|
|
425 |
}
|
426 |
|
427 |
function bp_media_audio_entry_screen_content() {
|
428 |
-
global $bp, $bp_media_current_entry;
|
429 |
if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
|
430 |
return false;
|
431 |
do_action('bp_media_before_content');
|
432 |
echo '<div class="bp-media-single bp-media-audio">';
|
433 |
echo $bp_media_current_entry->get_media_single_content();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
echo $bp_media_current_entry->show_comment_form();
|
435 |
echo '</div>';
|
436 |
do_action('bp_media_after_content');
|
@@ -464,13 +519,139 @@ function bp_media_entry_delete() {
|
|
464 |
}
|
465 |
$post_id = $bp_media_current_entry->get_id();
|
466 |
$activity_id=get_post_meta($post_id,'bp_media_child_activity',true);
|
467 |
-
|
468 |
bp_activity_delete_by_activity_id($activity_id);
|
469 |
$bp_media_current_entry->delete_media();
|
470 |
-
|
471 |
@setcookie('bp-message', __('Media deleted successfully','bp-media'), time() + 60 * 60 * 24, COOKIEPATH);
|
472 |
@setcookie('bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH);
|
473 |
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
|
474 |
exit;
|
475 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
?>
|
12 |
* Screen function for Upload page
|
13 |
*/
|
14 |
function bp_media_upload_screen() {
|
15 |
+
add_action('wp_enqueue_scripts','bp_media_upload_enqueue');
|
16 |
add_action('bp_template_title', 'bp_media_upload_screen_title');
|
17 |
add_action('bp_template_content', 'bp_media_upload_screen_content');
|
18 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
19 |
}
|
20 |
|
21 |
+
/**
|
22 |
+
* Screen function to display upload screen title
|
23 |
+
*/
|
24 |
function bp_media_upload_screen_title() {
|
25 |
_e('Upload Media');
|
26 |
}
|
27 |
|
28 |
+
/**
|
29 |
+
* Screen function to display upload screen content
|
30 |
+
*/
|
31 |
function bp_media_upload_screen_content() {
|
32 |
do_action('bp_media_before_content');
|
33 |
+
bp_media_show_upload_form_multiple();
|
34 |
do_action('bp_media_after_content');
|
35 |
}
|
36 |
|
39 |
*/
|
40 |
function bp_media_images_screen() {
|
41 |
global $bp;
|
42 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
43 |
if (isset($bp->action_variables[0])) {
|
44 |
switch ($bp->action_variables[0]) {
|
45 |
case BP_MEDIA_IMAGES_EDIT_SLUG :
|
86 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Screen function to display images screen title
|
91 |
+
*/
|
92 |
function bp_media_images_screen_title() {
|
93 |
_e('Images List Page');
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
+
* Screen function to display images screen content
|
98 |
+
*/
|
99 |
function bp_media_images_screen_content() {
|
100 |
global $bp_media_query;
|
101 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
|
|
102 |
do_action('bp_media_before_content');
|
103 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
104 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
105 |
bp_media_the_content();
|
106 |
endwhile;
|
107 |
echo '</ul>';
|
108 |
+
bp_media_display_show_more();
|
109 |
do_action('bp_media_after_content');
|
|
|
110 |
else:
|
111 |
bp_media_show_formatted_error_message(__('Sorry, no images were found.', 'bp-media'), 'info');
|
112 |
endif;
|
132 |
exit;
|
133 |
}
|
134 |
bp_media_check_user();
|
135 |
+
|
136 |
//For saving the data if the form is submitted
|
137 |
if(array_key_exists('bp_media_title', $_POST)){
|
138 |
bp_media_update_media();
|
142 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
143 |
}
|
144 |
|
145 |
+
/**
|
146 |
+
* Screen function to dipslay edit images screen title
|
147 |
+
*/
|
148 |
function bp_media_images_edit_screen_title() {
|
149 |
_e('Edit Image','bp-media');
|
150 |
}
|
151 |
|
152 |
+
/**
|
153 |
+
* Screen function to display edit image screen content
|
154 |
+
*/
|
155 |
function bp_media_images_edit_screen_content() {
|
156 |
global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
|
157 |
?>
|
177 |
}
|
178 |
|
179 |
function bp_media_images_entry_screen_content() {
|
180 |
+
global $bp, $bp_media_current_entry,$bp_media_options;
|
181 |
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
182 |
return false;
|
183 |
do_action('bp_media_before_content');
|
184 |
echo '<div class="bp-media-single bp-media-image">';
|
185 |
echo $bp_media_current_entry->get_media_single_content();
|
186 |
+
// echo '<div class="bp-media-actions">';
|
187 |
+
// echo '<a href="#comment" class="button acomment-reply bp-primary-action">Comment</a>';
|
188 |
+
// if(bp_loggedin_user_id()== bp_displayed_user_id()){
|
189 |
+
// echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action edit-media">Edit</a>';
|
190 |
+
// echo '<a href="'.$bp_media_current_entry->get_delete_url().'" class="button item-button bp-secondary-action delete-media confirm">Delete</a>';
|
191 |
+
// }
|
192 |
+
// if(isset($bp_media_options['download_enabled'])&&$bp_media_options['download_enabled']==true){
|
193 |
+
// echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action download-media">Download</a>';
|
194 |
+
// }
|
195 |
+
// echo '</div>';
|
196 |
echo $bp_media_current_entry->show_comment_form();
|
197 |
echo '</div>';
|
198 |
do_action('bp_media_after_content');
|
203 |
*/
|
204 |
function bp_media_videos_screen() {
|
205 |
global $bp;
|
206 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
207 |
if (isset($bp->action_variables[0])) {
|
208 |
switch ($bp->action_variables[0]) {
|
209 |
case BP_MEDIA_VIDEOS_EDIT_SLUG :
|
230 |
}
|
231 |
bp_media_entry_delete();
|
232 |
break;
|
233 |
+
case '206':
|
234 |
+
wp_redirect('http://google.com');
|
235 |
default:
|
236 |
bp_media_set_query();
|
237 |
add_action('bp_template_content', 'bp_media_videos_screen_content');
|
250 |
function bp_media_videos_screen_content() {
|
251 |
global $bp_media_query;
|
252 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
|
|
253 |
do_action('bp_media_before_content');
|
254 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
255 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
256 |
bp_media_the_content();
|
257 |
endwhile;
|
258 |
echo '</ul>';
|
259 |
+
bp_media_display_show_more();
|
260 |
do_action('bp_media_after_content');
|
|
|
261 |
else:
|
262 |
bp_media_show_formatted_error_message(__('Sorry, no videos were found.', 'bp-media'), 'info');
|
263 |
endif;
|
274 |
//Creating global bp_media_current_entry for later use
|
275 |
try {
|
276 |
$bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
|
|
|
277 |
} catch (Exception $e) {
|
278 |
/* Send the values to the cookie for page reload display */
|
279 |
@setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
|
282 |
exit;
|
283 |
}
|
284 |
bp_media_check_user();
|
285 |
+
|
286 |
//For saving the data if the form is submitted
|
287 |
if(array_key_exists('bp_media_title', $_POST)){
|
288 |
bp_media_update_media();
|
321 |
}
|
322 |
|
323 |
function bp_media_videos_entry_screen_content() {
|
324 |
+
global $bp, $bp_media_current_entry, $bp_media_options;
|
325 |
if (!$bp->action_variables[0] == BP_MEDIA_VIDEOS_ENTRY_SLUG)
|
326 |
return false;
|
327 |
do_action('bp_media_before_content');
|
328 |
echo '<div class="bp-media-single bp-media-video">';
|
329 |
echo $bp_media_current_entry->get_media_single_content();
|
330 |
+
// echo '<div class="bp-media-actions">';
|
331 |
+
// echo '<a href="#comment" class="button acomment-reply bp-primary-action">Comment</a>';
|
332 |
+
// if(bp_loggedin_user_id()== bp_displayed_user_id()){
|
333 |
+
// echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action edit-media">Edit</a>';
|
334 |
+
// echo '<a href="'.$bp_media_current_entry->get_delete_url().'" class="button item-button bp-secondary-action delete-media confirm">Delete</a>';
|
335 |
+
// }
|
336 |
+
// if(isset($bp_media_options['download_enabled'])&&$bp_media_options['download_enabled']==true){
|
337 |
+
// echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action download-media">Download</a>';
|
338 |
+
// }
|
339 |
+
// echo '</div>';
|
340 |
echo $bp_media_current_entry->show_comment_form();
|
341 |
echo '</div>';
|
342 |
do_action('bp_media_after_content');
|
347 |
*/
|
348 |
function bp_media_audio_screen() {
|
349 |
global $bp;
|
350 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
351 |
if (isset($bp->action_variables[0])) {
|
352 |
switch ($bp->action_variables[0]) {
|
353 |
case BP_MEDIA_AUDIO_EDIT_SLUG :
|
385 |
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
386 |
}
|
387 |
|
388 |
+
/**
|
389 |
+
* Screen function to dipslay edit audio screen title
|
390 |
+
*/
|
391 |
function bp_media_audio_screen_title() {
|
392 |
_e('Audio List Page');
|
393 |
}
|
394 |
|
395 |
+
/**
|
396 |
+
* Screen function to dipslay edit audio screen content
|
397 |
+
*/
|
398 |
function bp_media_audio_screen_content() {
|
399 |
global $bp_media_query;
|
400 |
if ($bp_media_query && $bp_media_query->have_posts()):
|
|
|
401 |
do_action('bp_media_before_content');
|
402 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
403 |
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
404 |
bp_media_the_content();
|
405 |
endwhile;
|
406 |
echo '</ul>';
|
407 |
+
bp_media_display_show_more();
|
408 |
do_action('bp_media_after_content');
|
|
|
409 |
else:
|
410 |
bp_media_show_formatted_error_message(__('Sorry, no audio files were found.', 'bp-media'), 'info');
|
411 |
endif;
|
431 |
exit;
|
432 |
}
|
433 |
bp_media_check_user();
|
434 |
+
|
435 |
//For saving the data if the form is submitted
|
436 |
if(array_key_exists('bp_media_title', $_POST)){
|
437 |
bp_media_update_media();
|
470 |
}
|
471 |
|
472 |
function bp_media_audio_entry_screen_content() {
|
473 |
+
global $bp, $bp_media_current_entry, $bp_media_options;
|
474 |
if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
|
475 |
return false;
|
476 |
do_action('bp_media_before_content');
|
477 |
echo '<div class="bp-media-single bp-media-audio">';
|
478 |
echo $bp_media_current_entry->get_media_single_content();
|
479 |
+
// echo '<div class="bp-media-actions">';
|
480 |
+
// echo '<a href="#comment" class="button acomment-reply bp-primary-action">Comment</a>';
|
481 |
+
// if(bp_loggedin_user_id()== bp_displayed_user_id()){
|
482 |
+
// echo '<a href="'.$bp_media_current_entry->get_edit_url().'" class="button item-button bp-secondary-action edit-media">Edit</a>';
|
483 |
+
// echo '<a href="'.$bp_media_current_entry->get_delete_url().'" class="button item-button bp-secondary-action delete-media confirm">Delete</a>';
|
484 |
+
// }
|
485 |
+
// if(isset($bp_media_options['download_enabled'])&&$bp_media_options['download_enabled']==true){
|
486 |
+
// echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action download-media">Download</a>';
|
487 |
+
// }
|
488 |
+
// echo '</div>';
|
489 |
echo $bp_media_current_entry->show_comment_form();
|
490 |
echo '</div>';
|
491 |
do_action('bp_media_after_content');
|
519 |
}
|
520 |
$post_id = $bp_media_current_entry->get_id();
|
521 |
$activity_id=get_post_meta($post_id,'bp_media_child_activity',true);
|
522 |
+
|
523 |
bp_activity_delete_by_activity_id($activity_id);
|
524 |
$bp_media_current_entry->delete_media();
|
525 |
+
|
526 |
@setcookie('bp-message', __('Media deleted successfully','bp-media'), time() + 60 * 60 * 24, COOKIEPATH);
|
527 |
@setcookie('bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH);
|
528 |
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
|
529 |
exit;
|
530 |
}
|
531 |
+
|
532 |
+
/**
|
533 |
+
* Screen function for Albums listing page (Default)
|
534 |
+
*/
|
535 |
+
function bp_media_albums_screen() {
|
536 |
+
global $bp;
|
537 |
+
if (isset($bp->action_variables[0])) {
|
538 |
+
switch ($bp->action_variables[0]) {
|
539 |
+
case BP_MEDIA_ALBUMS_EDIT_SLUG :
|
540 |
+
bp_media_album_edit_screen();
|
541 |
+
break;
|
542 |
+
case BP_MEDIA_ALBUMS_ENTRY_SLUG:
|
543 |
+
global $bp_media_current_album;
|
544 |
+
if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
|
545 |
+
return false;
|
546 |
+
try {
|
547 |
+
$bp_media_current_album = new BP_Media_Album($bp->action_variables[1]);
|
548 |
+
} catch (Exception $e) {
|
549 |
+
/* Send the values to the cookie for page reload display */
|
550 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
551 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
552 |
+
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_ALBUMS_SLUG));
|
553 |
+
exit;
|
554 |
+
}
|
555 |
+
add_action('bp_template_content', 'bp_media_albums_entry_screen_content');
|
556 |
+
break;
|
557 |
+
case BP_MEDIA_DELETE_SLUG :
|
558 |
+
if(!isset($bp->action_variables[1])){
|
559 |
+
bp_media_page_not_exist();
|
560 |
+
}
|
561 |
+
bp_media_entry_delete();
|
562 |
+
break;
|
563 |
+
default:
|
564 |
+
bp_media_albums_set_query();
|
565 |
+
add_action('bp_template_content', 'bp_media_albums_screen_content');
|
566 |
+
}
|
567 |
+
} else {
|
568 |
+
bp_media_albums_set_query();
|
569 |
+
add_action('bp_template_content', 'bp_media_albums_screen_content');
|
570 |
+
}
|
571 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
572 |
+
}
|
573 |
+
|
574 |
+
function bp_media_albums_screen_title() {
|
575 |
+
_e('Albums List Page');
|
576 |
+
}
|
577 |
+
|
578 |
+
function bp_media_albums_screen_content() {
|
579 |
+
global $bp_media_albums_query;
|
580 |
+
if ($bp_media_albums_query && $bp_media_albums_query->have_posts()):
|
581 |
+
do_action('bp_media_before_content');
|
582 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
583 |
+
while ($bp_media_albums_query->have_posts()) : $bp_media_albums_query->the_post();
|
584 |
+
bp_media_album_the_content();
|
585 |
+
endwhile;
|
586 |
+
echo '</ul>';
|
587 |
+
bp_media_display_show_more();
|
588 |
+
do_action('bp_media_after_content');
|
589 |
+
else:
|
590 |
+
bp_media_show_formatted_error_message(__('Sorry, no albums were found.', 'bp-media'), 'info');
|
591 |
+
endif;
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* Screen function for Albums Edit page
|
596 |
+
*/
|
597 |
+
function bp_media_albums_edit_screen() {
|
598 |
+
global $bp_media_current_album,$bp;
|
599 |
+
if(!isset($bp->action_variables[1])){
|
600 |
+
bp_media_page_not_exist();
|
601 |
+
}
|
602 |
+
//Creating global bp_media_current_entry for later use
|
603 |
+
try {
|
604 |
+
$bp_media_current_album = new BP_Media_Album($bp->action_variables[1]);
|
605 |
+
} catch (Exception $e) {
|
606 |
+
/* Send the values to the cookie for page reload display */
|
607 |
+
@setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
|
608 |
+
@setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
|
609 |
+
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
|
610 |
+
exit;
|
611 |
+
}
|
612 |
+
bp_media_check_user();
|
613 |
+
|
614 |
+
//For saving the data if the form is submitted
|
615 |
+
if(array_key_exists('bp_media_title', $_POST)){
|
616 |
+
bp_media_update_media();
|
617 |
+
}
|
618 |
+
add_action('bp_template_title', 'bp_media_albums_edit_screen_title');
|
619 |
+
add_action('bp_template_content', 'bp_media_albums_edit_screen_content');
|
620 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
621 |
+
}
|
622 |
+
|
623 |
+
function bp_media_albums_edit_screen_title() {
|
624 |
+
_e('Edit Album');
|
625 |
+
}
|
626 |
+
|
627 |
+
function bp_media_albums_edit_screen_content() {
|
628 |
+
global $bp, $bp_media_current_entry,$bp_media_default_excerpts;
|
629 |
+
?>
|
630 |
+
<form method="post" class="standard-form" id="bp-media-upload-form">
|
631 |
+
<label for="bp-media-upload-input-title"><?php _e('Album Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" value="<?php echo $bp_media_current_entry->get_title(); ?>" />
|
632 |
+
<label for="bp-media-upload-input-description"><?php _e('Album Description', 'bp-media'); ?></label><input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'],$bp_media_default_excerpts['activity_entry_description'])) ?>" value="<?php echo $bp_media_current_entry->get_content(); ?>" />
|
633 |
+
<div class="submit"><input type="submit" class="auto" value="Update" /><a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="Back to Media File">Back to Media</a></div>
|
634 |
+
</form>
|
635 |
+
<?php
|
636 |
+
}
|
637 |
+
|
638 |
+
function bp_media_albums_entry_screen_content() {
|
639 |
+
global $bp, $bp_media_current_album,$bp_media_query;
|
640 |
+
if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
|
641 |
+
return false;
|
642 |
+
echo '<div class="bp_media_title">'.$bp_media_current_album->get_title().'</div>';
|
643 |
+
bp_media_albums_set_inner_query($bp_media_current_album->get_id());
|
644 |
+
if ($bp_media_query && $bp_media_query->have_posts()):
|
645 |
+
do_action('bp_media_before_content');
|
646 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
647 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
648 |
+
bp_media_the_content();
|
649 |
+
endwhile;
|
650 |
+
echo '</ul>';
|
651 |
+
bp_media_display_show_more();
|
652 |
+
do_action('bp_media_after_content');
|
653 |
+
else:
|
654 |
+
bp_media_show_formatted_error_message(__('Sorry, no media items were found in this album.', 'bp-media'), 'info');
|
655 |
+
endif;
|
656 |
+
}
|
657 |
?>
|
includes/bp-media-shortcodes.php
CHANGED
@@ -8,8 +8,13 @@ function bp_media_shortcode_action($atts) {
|
|
8 |
'id' => '0'
|
9 |
), $atts)
|
10 |
);
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
//add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
15 |
|
@@ -21,8 +26,13 @@ function bp_media_shortcode_content($atts) {
|
|
21 |
'id' => '0'
|
22 |
), $atts)
|
23 |
);
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
//add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
28 |
|
@@ -31,8 +41,13 @@ function bp_media_shortcode_url($atts) {
|
|
31 |
'id' => '0'
|
32 |
), $atts)
|
33 |
);
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
//add_shortcode('bp_media_url','bp_media_shortcode_url');
|
38 |
?>
|
8 |
'id' => '0'
|
9 |
), $atts)
|
10 |
);
|
11 |
+
try{
|
12 |
+
$media=new BP_Media_Host_Wordpress($id);
|
13 |
+
return $media->get_media_activity_action();
|
14 |
+
}
|
15 |
+
catch(Exception $e){
|
16 |
+
return 'Media not present';
|
17 |
+
}
|
18 |
}
|
19 |
//add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
20 |
|
26 |
'id' => '0'
|
27 |
), $atts)
|
28 |
);
|
29 |
+
try{
|
30 |
+
$media=new BP_Media_Host_Wordpress($id);
|
31 |
+
return $media->get_media_activity_content();
|
32 |
+
}
|
33 |
+
catch(Exception $e){
|
34 |
+
return 'Media not present';
|
35 |
+
}
|
36 |
}
|
37 |
//add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
38 |
|
41 |
'id' => '0'
|
42 |
), $atts)
|
43 |
);
|
44 |
+
try{
|
45 |
+
$media=new BP_Media_Host_Wordpress($id);
|
46 |
+
return $media->get_media_activity_url();
|
47 |
+
}
|
48 |
+
catch(Exception $e){
|
49 |
+
return home_url();
|
50 |
+
}
|
51 |
}
|
52 |
//add_shortcode('bp_media_url','bp_media_shortcode_url');
|
53 |
?>
|
includes/bp-media-template-functions.php
CHANGED
@@ -20,7 +20,7 @@ function bp_media_show_upload_form() {
|
|
20 |
}
|
21 |
$allowed = apply_filters('bp_media_allowed_filter',$allowed);
|
22 |
$accept = implode(',',$allowed['accept']);
|
23 |
-
|
24 |
?>
|
25 |
<form method="post" enctype="multipart/form-data" class="standard-form" id="bp-media-upload-form">
|
26 |
<label for="bp-media-upload-input-title"><?php _e('Media Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" />
|
@@ -32,9 +32,29 @@ function bp_media_show_upload_form() {
|
|
32 |
<?php
|
33 |
}
|
34 |
|
35 |
-
function
|
36 |
-
global $bp,$bp_media_default_excerpts;
|
37 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
|
39 |
<div id="drag-drop-area">
|
40 |
<div class="drag-drop-inside">
|
@@ -48,8 +68,8 @@ function bp_media_show_upload_form2() {
|
|
48 |
<?php
|
49 |
}
|
50 |
|
51 |
-
function bp_media_show_pagination($type = 'top') {
|
52 |
-
global $bp, $bp_media_paginated_links, $bp_media_query;
|
53 |
switch ($bp->current_action) {
|
54 |
case BP_MEDIA_IMAGES_SLUG :
|
55 |
$current = $bp_media_query->found_posts > 1 ? BP_MEDIA_IMAGES_LABEL : BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
@@ -63,24 +83,64 @@ function bp_media_show_pagination($type = 'top') {
|
|
63 |
$current = BP_MEDIA_AUDIO_LABEL;
|
64 |
$current_single = BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
65 |
break;
|
|
|
|
|
|
|
|
|
66 |
default :
|
67 |
$current = BP_MEDIA_LABEL;
|
68 |
$current_single = BP_MEDIA_LABEL_SINGULAR;
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
?>
|
85 |
<div id="pag-<?php echo $type; ?>" class="pagination no-ajax">
|
86 |
<div class="pag-count">
|
@@ -132,7 +192,63 @@ function bp_media_the_content($id = 0) {
|
|
132 |
return false;
|
133 |
if (!$media->post_type == 'bp_media')
|
134 |
return false;
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
?>
|
20 |
}
|
21 |
$allowed = apply_filters('bp_media_allowed_filter',$allowed);
|
22 |
$accept = implode(',',$allowed['accept']);
|
23 |
+
|
24 |
?>
|
25 |
<form method="post" enctype="multipart/form-data" class="standard-form" id="bp-media-upload-form">
|
26 |
<label for="bp-media-upload-input-title"><?php _e('Media Title', 'bp-media'); ?></label><input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input" maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'],$bp_media_default_excerpts['activity_entry_title'])) ?>" />
|
32 |
<?php
|
33 |
}
|
34 |
|
35 |
+
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 |
+
$albums = new WP_Query(array(
|
40 |
+
'post_type' => 'bp_media_album',
|
41 |
+
'posts_per_page'=> -1,
|
42 |
+
'author'=> get_current_user_id()
|
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')
|
47 |
+
echo '<option value="'.$album->ID.'" selected="selected">'.$album->post_title.'</option>' ;
|
48 |
+
else
|
49 |
+
echo '<option value="'.$album->ID.'">'.$album->post_title.'</option>' ;
|
50 |
+
};
|
51 |
+
}else{
|
52 |
+
$album = new BP_Media_Album();
|
53 |
+
$album->add_album('Wall Posts', bp_loggedin_user_id());
|
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 |
<div id="drag-drop-area">
|
60 |
<div class="drag-drop-inside">
|
68 |
<?php
|
69 |
}
|
70 |
|
71 |
+
function bp_media_show_pagination($type = 'top' , $inner = false) {
|
72 |
+
global $bp, $bp_media_paginated_links, $bp_media_query, $bp_media_albums_query;
|
73 |
switch ($bp->current_action) {
|
74 |
case BP_MEDIA_IMAGES_SLUG :
|
75 |
$current = $bp_media_query->found_posts > 1 ? BP_MEDIA_IMAGES_LABEL : BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
83 |
$current = BP_MEDIA_AUDIO_LABEL;
|
84 |
$current_single = BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
85 |
break;
|
86 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
87 |
+
$current = BP_MEDIA_ALBUMS_LABEL;
|
88 |
+
$current_single = BP_MEDIA_ALBUMS_LABEL_SINGULAR;
|
89 |
+
break;
|
90 |
default :
|
91 |
$current = BP_MEDIA_LABEL;
|
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 . '/') . '%_%',
|
100 |
+
'format' => 'page/%#%',
|
101 |
+
'total' => $bp_media_albums_query->max_num_pages,
|
102 |
+
'current' => $bp_media_albums_query->query_vars['paged'],
|
103 |
+
'type' => 'array',
|
104 |
+
'prev_text' => '←',
|
105 |
+
'next_text' => '→',
|
106 |
+
);
|
107 |
+
$start_num = intval($bp_media_albums_query->query_vars['posts_per_page'] * ($bp_media_albums_query->query_vars['paged'] - 1)) + 1;
|
108 |
+
$from_num = $start_num;
|
109 |
+
$to_num = $start_num + $bp_media_albums_query->post_count - 1;
|
110 |
+
$total = $bp_media_albums_query->found_posts;
|
111 |
+
$bp_media_paginated_links = paginate_links($args);
|
112 |
+
}
|
113 |
+
else{
|
114 |
+
if($inner){
|
115 |
+
$current = BP_MEDIA_LABEL;
|
116 |
+
$current_single = BP_MEDIA_LABEL_SINGULAR;
|
117 |
+
$args = array(
|
118 |
+
'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/'.$bp->action_variables[1]) . '%_%',
|
119 |
+
'format' => 'page/%#%',
|
120 |
+
'total' => $bp_media_query->max_num_pages,
|
121 |
+
'current' => $bp_media_query->query_vars['paged'],
|
122 |
+
'type' => 'array',
|
123 |
+
'prev_text' => '←',
|
124 |
+
'next_text' => '→',
|
125 |
+
);
|
126 |
+
}
|
127 |
+
else{
|
128 |
+
$args = array(
|
129 |
+
'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
|
130 |
+
'format' => 'page/%#%',
|
131 |
+
'total' => $bp_media_query->max_num_pages,
|
132 |
+
'current' => $bp_media_query->query_vars['paged'],
|
133 |
+
'type' => 'array',
|
134 |
+
'prev_text' => '←',
|
135 |
+
'next_text' => '→',
|
136 |
+
);
|
137 |
+
}
|
138 |
+
$start_num = intval($bp_media_query->query_vars['posts_per_page'] * ($bp_media_query->query_vars['paged'] - 1)) + 1;
|
139 |
+
$from_num = $start_num;
|
140 |
+
$to_num = $start_num + $bp_media_query->post_count - 1;
|
141 |
+
$total = $bp_media_query->found_posts;
|
142 |
+
$bp_media_paginated_links = paginate_links($args);
|
143 |
+
}
|
144 |
?>
|
145 |
<div id="pag-<?php echo $type; ?>" class="pagination no-ajax">
|
146 |
<div class="pag-count">
|
192 |
return false;
|
193 |
if (!$media->post_type == 'bp_media')
|
194 |
return false;
|
195 |
+
try{
|
196 |
+
$media = new BP_Media_Host_Wordpress($media->ID);
|
197 |
+
echo $media->get_media_gallery_content();
|
198 |
+
}
|
199 |
+
catch(Exception $e){
|
200 |
+
echo '';
|
201 |
+
}
|
202 |
+
}
|
203 |
+
function bp_media_album_the_content($id = 0) {
|
204 |
+
if (is_object($id))
|
205 |
+
$album = $id;
|
206 |
+
else
|
207 |
+
$album = &get_post($id);
|
208 |
+
if (empty($album->ID))
|
209 |
+
return false;
|
210 |
+
if (!$album->post_type == 'bp_media_album')
|
211 |
+
return false;
|
212 |
+
try{
|
213 |
+
$album = new BP_Media_Album($album->ID);
|
214 |
+
echo $album->get_album_gallery_content();
|
215 |
+
}
|
216 |
+
catch(Exception $e){
|
217 |
+
echo '';
|
218 |
+
}
|
219 |
+
}
|
220 |
+
function bp_media_display_show_more(){
|
221 |
+
global $bp_media_query;
|
222 |
+
//found_posts
|
223 |
+
if($bp_media_query->found_posts>10)
|
224 |
+
echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">Show More</a></div>';
|
225 |
}
|
226 |
+
|
227 |
+
function bp_media_show_upload_form_multiple_activity() {
|
228 |
+
global $bp,$bp_media_default_excerpts;
|
229 |
+
if($bp->current_component!='activity')
|
230 |
+
return;
|
231 |
+
?>
|
232 |
+
<div id="bp-media-album-prompt" title="Select Album"><select id="bp-media-selected-album"><?php
|
233 |
+
$albums = new WP_Query(array(
|
234 |
+
'post_type' => 'bp_media_album',
|
235 |
+
'posts_per_page'=> -1,
|
236 |
+
'author'=> get_current_user_id()
|
237 |
+
));
|
238 |
+
if(isset($albums->posts)&& is_array($albums->posts)&& count($albums->posts)>0){
|
239 |
+
foreach ($albums->posts as $album){
|
240 |
+
if($album->post_title == 'Wall Posts')
|
241 |
+
echo '<option value="'.$album->ID.'" selected="selected">'.$album->post_title.'</option>' ;
|
242 |
+
else
|
243 |
+
echo '<option value="'.$album->ID.'">'.$album->post_title.'</option>' ;
|
244 |
+
};
|
245 |
+
}?></select></div>
|
246 |
+
<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>
|
247 |
+
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop activity-component">
|
248 |
+
<p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="Add Media" class="button" /></p>
|
249 |
+
</div>
|
250 |
+
<div id="bp-media-uploaded-files"></div>
|
251 |
+
<?php
|
252 |
+
}
|
253 |
+
|
254 |
?>
|
includes/bp-media-upgrade-script.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bp_media_upgrade_to_2_2(){
|
4 |
+
global $wpdb;
|
5 |
+
remove_filter('bp_activity_get_user_join_filter','bp_media_activity_query_filter',10);
|
6 |
+
/* @var $wpdb wpdb */
|
7 |
+
$media_files = new WP_Query(array(
|
8 |
+
'post_type' => 'bp_media',
|
9 |
+
'posts_per_page' => -1
|
10 |
+
));
|
11 |
+
$media_files = $media_files->posts;
|
12 |
+
$wall_posts_album_ids=array();
|
13 |
+
if(is_array($media_files)&&count($media_files)){
|
14 |
+
foreach($media_files as $media_file){
|
15 |
+
$attachment_id = get_post_meta($media_file->ID,'bp_media_child_attachment',true);
|
16 |
+
$child_activity = get_post_meta($media_file->ID,'bp_media_child_activity',true);
|
17 |
+
update_post_meta($attachment_id, 'bp_media_child_activity', $child_activity);
|
18 |
+
$attachment = get_post($attachment_id , ARRAY_A);
|
19 |
+
if(isset($wall_posts_album_ids[$media_file->post_author])){
|
20 |
+
$wall_posts_id = $wall_posts_album_ids[$media_file->post_author];
|
21 |
+
}
|
22 |
+
else{
|
23 |
+
$wall_posts_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_title = 'Wall Posts' AND post_author = '". $media_file->post_author."' AND post_type='bp_media_album'");
|
24 |
+
if($wall_posts_id==null){
|
25 |
+
$album = new BP_Media_Album();
|
26 |
+
$album->add_album('Wall Posts',$media_file->post_author);
|
27 |
+
$wall_posts_id = $album->get_id();
|
28 |
+
}
|
29 |
+
if(!$wall_posts_id){
|
30 |
+
continue; //This condition should never be encountered
|
31 |
+
}
|
32 |
+
$wall_posts_album_ids[$media_file->post_author] = $wall_posts_id;
|
33 |
+
}
|
34 |
+
$attachment['post_parent'] = $wall_posts_id;
|
35 |
+
wp_update_post($attachment);
|
36 |
+
update_post_meta($attachment_id,'bp-media-key',$media_file->post_author);
|
37 |
+
$activity = bp_activity_get(array('in'=>intval($child_activity)));
|
38 |
+
if(isset($activity['activities'][0]->id))
|
39 |
+
$activity = $activity['activities'][0];
|
40 |
+
$bp_media = new BP_Media_Host_Wordpress($attachment_id);
|
41 |
+
$args = array(
|
42 |
+
'content' => $bp_media->get_media_activity_content(),
|
43 |
+
'id' => $child_activity,
|
44 |
+
'type' => 'media_upload',
|
45 |
+
'action' => apply_filters( 'bp_media_added_media', sprintf( __( '%1$s added a %2$s', 'bp-media'), bp_core_get_userlink( $media_file->post_author ), '<a href="' . $bp_media->get_url() . '">' . $bp_media->get_media_activity_type() . '</a>' ) ),
|
46 |
+
'primary_link' => $bp_media->get_url(),
|
47 |
+
'item_id' => $attachment_id,
|
48 |
+
'recorded_time' => $activity->date_recorded,
|
49 |
+
);
|
50 |
+
$act_id = bp_media_record_activity($args);
|
51 |
+
bp_activity_delete_meta($child_activity, 'bp_media_parent_post');
|
52 |
+
wp_delete_post($media_file->ID);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
update_option('bp_media_db_version',BP_MEDIA_DB_VERSION);
|
56 |
+
add_action('admin_notices',function (){echo '<div class="updated rt-success"><p>
|
57 |
+
<b>BuddyPress Media</b> Database upgraded successfully.
|
58 |
+
</p></div>';});
|
59 |
+
wp_cache_flush();
|
60 |
+
}
|
61 |
+
?>
|
includes/bp-media-upload-handler.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
ignore_user_abort(true);
|
3 |
-
|
4 |
require_once('lib/bootstrap.php');
|
5 |
|
6 |
// Disable error reporting or else AJAX Requests might give different data format
|
7 |
error_reporting(E_ALL);
|
8 |
|
9 |
// Check for rights
|
10 |
-
if ( !is_user_logged_in() )
|
11 |
wp_die(__("You are not allowed to be here"));
|
12 |
|
13 |
//set_time_limit(0);
|
1 |
<?php
|
2 |
ignore_user_abort(true);
|
3 |
+
|
4 |
require_once('lib/bootstrap.php');
|
5 |
|
6 |
// Disable error reporting or else AJAX Requests might give different data format
|
7 |
error_reporting(E_ALL);
|
8 |
|
9 |
// Check for rights
|
10 |
+
if ( !is_user_logged_in() )
|
11 |
wp_die(__("You are not allowed to be here"));
|
12 |
|
13 |
//set_time_limit(0);
|
includes/bp-media-widgets.php
ADDED
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Recent_media widget class
|
4 |
+
*
|
5 |
+
* @since 2.8.0
|
6 |
+
*/
|
7 |
+
|
8 |
+
class BP_Media_Recent_Media extends WP_Widget {
|
9 |
+
|
10 |
+
function __construct() {
|
11 |
+
$widget_ops = array('classname' => 'widget_recent_media', 'description' => __( "The most recent media uploaded on your site", 'bp-media') );
|
12 |
+
parent::__construct('recent-media', __('Recent Media', 'bp-media'), $widget_ops);
|
13 |
+
}
|
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 ) {
|
173 |
+
$instance = $old_instance;
|
174 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
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;
|
182 |
+
?>
|
183 |
+
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'bp-media'); ?></label>
|
184 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
|
185 |
+
|
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 |
+
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Popular_media widget class
|
199 |
+
*
|
200 |
+
* @since 2.8.0
|
201 |
+
*/
|
202 |
+
|
203 |
+
class BP_Media_Popular_Media extends WP_Widget {
|
204 |
+
|
205 |
+
function __construct() {
|
206 |
+
$widget_ops = array('classname' => 'BP_Media_Popular_Media', 'description' => __( "The most popular media on your site", 'bp-media') );
|
207 |
+
parent::__construct('popular-media', __('Popular Media', 'bp-media'), $widget_ops);
|
208 |
+
}
|
209 |
+
|
210 |
+
function widget($args, $instance) {
|
211 |
+
extract( $args );
|
212 |
+
|
213 |
+
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent 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 ) {
|
263 |
+
$instance = $old_instance;
|
264 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
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;
|
272 |
+
?>
|
273 |
+
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'bp-media'); ?></label>
|
274 |
+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
|
275 |
+
|
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 |
+
|
285 |
+
function bp_media_widgets_init(){
|
286 |
+
register_widget('BP_Media_Recent_Media');
|
287 |
+
register_widget('BP_Media_Popular_Media');
|
288 |
+
}
|
289 |
+
|
290 |
+
/* Initialize widgets */
|
291 |
+
add_action('widgets_init', 'bp_media_widgets_init', 1);
|
includes/css/bp-media-style.css
CHANGED
@@ -1,213 +1,136 @@
|
|
1 |
-
/*
|
2 |
* Default stylesheet for BuddyPress Media
|
3 |
*/
|
4 |
-
.bp_media_content img{
|
5 |
-
|
6 |
-
}
|
7 |
-
.
|
8 |
-
|
9 |
-
}
|
10 |
-
.
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
}
|
15 |
-
.
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
|
20 |
-
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
-moz-transition: box-shadow 0.2s linear;
|
35 |
-
-webkit-transition: box-shadow 0.2s linear;
|
36 |
-
transition: box-shadow 0.2s linear;
|
37 |
-
}
|
38 |
-
ul.bp-media-gallery li img:hover{
|
39 |
-
-moz-box-shadow: 1px 1px 10px #333;
|
40 |
-
-webkit-box-shadow: 1px 1px 10px #333;
|
41 |
-
box-shadow: 1px 1px 10px #333;
|
42 |
-
|
43 |
-
}
|
44 |
-
ul.bp-media-gallery h3{
|
45 |
-
max-width:150px;
|
46 |
-
overflow: hidden;
|
47 |
-
text-align: center;
|
48 |
-
font-size:110%;
|
49 |
-
white-space: nowrap;
|
50 |
-
height:20px;
|
51 |
-
}
|
52 |
-
ul.bp-media-gallery a{
|
53 |
-
width:150px;
|
54 |
-
}
|
55 |
-
.bp-media-single .activity-list .activity-content,.bp-media-single div.activity-comments{
|
56 |
-
margin-left:0;
|
57 |
-
}
|
58 |
-
li.media div.activity-content div.activity-inner p{
|
59 |
-
display:none;
|
60 |
-
}
|
61 |
-
div.bp_media_title{
|
62 |
-
margin-bottom:5px;
|
63 |
-
}
|
64 |
-
#bp-media-footer {
|
65 |
-
color: #4D4D4D;
|
66 |
-
text-align: center;
|
67 |
-
text-shadow: #FAFAFA 1px 1px 0;
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/* Used on backend */
|
72 |
-
#wpbody-content div.metabox-fixed{
|
73 |
-
width: 22%;
|
74 |
-
margin-right: 10px;
|
75 |
-
clear: both;
|
76 |
-
}
|
77 |
-
#wpbody-content div.wrap.bp-media-admin{
|
78 |
-
overflow: hidden;
|
79 |
-
width: 76%;
|
80 |
-
}
|
81 |
-
#icon-bp-media{
|
82 |
-
background:url('../img/logo_medibp_32.png') no-repeat scroll 0 0 transparent;
|
83 |
-
}.bp-media-social{
|
84 |
-
background: url('../img/bp_media_social.png');
|
85 |
-
height: 35px;
|
86 |
-
width: 35px;
|
87 |
-
display: inline-block;
|
88 |
-
font-size: 0px;
|
89 |
-
margin-right:5px;
|
90 |
-
}
|
91 |
-
.bp-media-facebook{
|
92 |
-
background-position: 0px 0px;
|
93 |
-
}
|
94 |
-
.bp-media-facebook:hover{
|
95 |
-
background-position: 0px 36px;
|
96 |
-
}
|
97 |
-
.bp-media-twitter{
|
98 |
-
background-position: 80px 0px;
|
99 |
-
}
|
100 |
-
.bp-media-twitter:hover{
|
101 |
-
background-position: 80px 36px;
|
102 |
-
}
|
103 |
-
.bp-media-rss{
|
104 |
-
background-position: 35px 0px;
|
105 |
-
}
|
106 |
-
.bp-media-rss:hover{
|
107 |
-
background-position: 35px 36px;
|
108 |
-
}
|
109 |
-
|
110 |
-
/*
|
111 |
-
Document : bp-media-uploader
|
112 |
-
Created on : Aug 21, 2012, 1:24:31 PM
|
113 |
-
Author : Gagan
|
114 |
-
Description:
|
115 |
-
Purpose of the stylesheet follows.
|
116 |
-
*/
|
117 |
#bp-media-upload-ui{position: relative;}
|
118 |
#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 200px;}
|
119 |
#bp-media-upload-ui .drag-drop-inside{margin: 70px auto 0;width: 250px;}
|
120 |
#bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 5px 0;}
|
121 |
#bp-media-upload-ui .drag-drop-info{font-size: 20px;}
|
122 |
-
#bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;
|
123 |
-
|
124 |
-
font-size:
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
-
|
133 |
-
|
134 |
-
|
135 |
-
.
|
136 |
-
|
137 |
-
|
138 |
-
padding: 0;
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
#
|
154 |
-
|
155 |
-
|
156 |
-
#
|
157 |
-
|
158 |
-
|
159 |
-
#
|
160 |
-
-
|
161 |
-
|
162 |
-
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
.
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
.
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
#
|
185 |
-
background-image: linear-gradient(bottom,
|
186 |
-
#
|
187 |
-
#
|
188 |
-
background-image: -
|
189 |
-
|
190 |
-
#
|
191 |
-
|
192 |
-
#
|
193 |
-
#
|
194 |
-
background-image: -
|
195 |
-
#
|
196 |
-
#
|
197 |
-
background-image: -
|
198 |
-
|
199 |
-
|
200 |
-
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
box-shadow: 0 0
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
}
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
* Default stylesheet for BuddyPress Media
|
3 |
*/
|
4 |
+
.bp_media_content img{max-width:98%;}
|
5 |
+
.bp_media_content .mejs-poster img{max-width: 100%;}
|
6 |
+
.bp_media_title {display:block;font-size:20px;font-weight:bold;}
|
7 |
+
ul.bp-media-gallery{overflow: hidden}
|
8 |
+
.bp_media_description {display:block;margin-top:20px;}
|
9 |
+
ul.bp-media-gallery.item-list{overflow:hidden;margin: 1% 0;}
|
10 |
+
#item-body ul.bp-media-gallery li{float: left;margin: 1% 1% 0;width: 18%;border-bottom: none;padding: 0;}
|
11 |
+
ul.bp-media-gallery li img{max-width:150px;width:100%;height:auto;-moz-box-shadow: 1px 1px 10px #a0a0a0;-webkit-box-shadow: 1px 1px 10px #a0a0a0;box-shadow: 1px 1px 10px #a0a0a0;-moz-transition: box-shadow 0.2s linear;-webkit-transition: box-shadow 0.2s linear;transition: box-shadow 0.2s linear;}
|
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;}
|
18 |
+
#bp-media-footer {color: #4D4D4D;text-align: center;text-shadow: #FAFAFA 1px 1px 0;}
|
19 |
+
#wpbody-content div.metabox-fixed{width: 280px;margin-right: -300px;float: right;}
|
20 |
+
#wpbody-content div.wrap.bp-media-admin .columns-2{margin-right:300px;padding-top: 0;margin-top: 15px;width: 600px}
|
21 |
+
#wpbody-content .bp-media-settings-tabs{margin-bottom: 15px}
|
22 |
+
#wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
|
23 |
+
#wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
|
24 |
+
|
25 |
+
|
26 |
+
#wpbody-content .wrap div.bp-media-metabox-holder{padding-top: 0}
|
27 |
+
.bp-media-social{background: url('../img/bp_media_social.png');height: 35px;width: 35px;display: inline-block;font-size: 0px;margin-right:5px;}
|
28 |
+
.bp-media-facebook{background-position: 0px 0px;}
|
29 |
+
.bp-media-facebook:hover{background-position: 0px 36px;}
|
30 |
+
.bp-media-twitter{background-position: 80px 0px;}
|
31 |
+
.bp-media-twitter:hover{background-position: 80px 36px;}
|
32 |
+
.bp-media-rss{background-position: 35px 0px;}
|
33 |
+
.bp-media-rss:hover{background-position: 35px 36px;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
#bp-media-upload-ui{position: relative;}
|
35 |
#bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 200px;}
|
36 |
#bp-media-upload-ui .drag-drop-inside{margin: 70px auto 0;width: 250px;}
|
37 |
#bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 5px 0;}
|
38 |
#bp-media-upload-ui .drag-drop-info{font-size: 20px;}
|
39 |
+
#bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;color: #464646;text-decoration: none;font-size: 12px!important;line-height: 13px;padding: 3px 8px;cursor: pointer;border-width: 1px;border-style: solid;-webkit-border-radius: 11px;border-radius: 11px;-moz-box-sizing: content-box;-webkit-box-sizing: content-box;box-sizing: content-box;}
|
40 |
+
.bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)}
|
41 |
+
.bp-media-progress-text{z-index: 10;position: relative;width: 100%;padding: 0 8px;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);color: rgba(0, 0, 0, 0.6);font-size:16px;line-height: 28px;}
|
42 |
+
.bp-media-progress-completed{z-index: 9;width: 0;height: 35px;margin-top: -35px;background-color: #83B4D8;background-image: linear-gradient(bottom,#72A7CF 0,#90C5EE 100%);background-image: -o-linear-gradient(bottom,#72A7CF 0,#90C5EE 100%);background-image: -moz-linear-gradient(bottom,#72A7CF 0,#90C5EE 100%);background-image: -webkit-linear-gradient(bottom,#72A7CF 0,#90C5EE 100%);background-image: -ms-linear-gradient(bottom,#72A7CF 0,#90C5EE 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);}
|
43 |
+
.bpm-aligncenter{display: inline-block;text-align: center;width: 100%;}
|
44 |
+
#bp-media-premium-addons ul,#bp-media-premium-addons li{list-style:disc;margin-left:10px;}
|
45 |
+
.bp-media-single div.bp_media_content{text-align:center;}
|
46 |
+
.bp-media-single .bp_media_content .mejs-container{margin-left:auto;margin-right:auto;}
|
47 |
+
|
48 |
+
.bp-media-support .support_list{ margin-left: 25px}
|
49 |
+
.bp-media-support .support_list li{list-style: disc;margin-bottom: 10px}
|
50 |
+
|
51 |
+
.media-tabs-container .ui-tabs-panel{}
|
52 |
+
.media-tabs-container .ui-tabs-hide{display: none}
|
53 |
+
|
54 |
+
.media-tabs-container .ui-tabs-nav{clear: both;display: block;margin: 0 0 15px;overflow: hidden;}
|
55 |
+
.media-tabs-container .ui-state-default{border-left: 1px solid;float: left;line-height: 110%;padding: 0 5px;}
|
56 |
+
.media-tabs-container .ui-state-default:first-child{margin-left: 0px;border: 0; padding-left: 0}
|
57 |
+
|
58 |
+
.media-tabs-container .ui-state-default a{text-decoration: none}
|
59 |
+
.media-tabs-container .ui-state-default.ui-state-active a{text-decoration: underline}
|
60 |
+
|
61 |
+
.media-tabs-container .widget-item-listing li{margin-top: 10px;overflow: hidden;min-height: 52px}
|
62 |
+
.media-tabs-container .widget-item-listing li img{max-width:52px; margin-right: 10px; float: left; display: block }
|
63 |
+
.media-tabs-container .widget-item-listing li h3 {margin: 0}
|
64 |
+
.media-tabs-container .widget-item-listing li h3 a{font-size: 13px;font-weight: normal;word-wrap: break-word; }
|
65 |
+
|
66 |
+
.bp-media-actions{margin:20px 0;}
|
67 |
+
.bp-media-actions a{display:inline-block;}
|
68 |
+
|
69 |
+
|
70 |
+
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a{background:url('../img/bpm-icon-16.png') center 1px no-repeat;}
|
71 |
+
#adminmenu li.toplevel_page_bp-media-settings:hover .wp-menu-image a,
|
72 |
+
#adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
|
73 |
+
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
|
74 |
+
#bp-media-settings-boxes{overflow: hidden;width: 100%;float: left;}
|
75 |
+
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
|
76 |
+
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
|
77 |
+
.metabox-holder .postbox#bp_media_latest_news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left top no-repeat; padding-left: 19px;}
|
78 |
+
#branding #logo{text-align:center;padding: 10px 0;display:block;}
|
79 |
+
ul#social{display:block;text-align:center;margin:0;}
|
80 |
+
ul#social li{display:inline;}
|
81 |
+
#bp-media-show-more{width: 200px;margin-left: auto;margin-right: auto;display: block;height: 30px;line-height: 30px;font-size: 20px;}
|
82 |
+
#bp-media-upload-ui.activity-component{margin-left: 74px;margin-top: 10px;}
|
83 |
+
ul#activity-stream li.media.album_updated ul{}
|
84 |
+
ul#activity-stream li.media.album_updated ul li{float: left;margin-right:2%}
|
85 |
+
|
86 |
+
|
87 |
+
/* Addons page Styling */
|
88 |
+
#bp-media-addons-list_metabox {background: #ffffff}
|
89 |
+
.products ul:after, ul.products:after {clear: both;content: "";display: block;}
|
90 |
+
.products ul, ul.products {clear: both;list-style: none outside none;margin: 0 0 14px;padding: 0;}
|
91 |
+
.products {margin: 0;}
|
92 |
+
ul.products li.product.first { }
|
93 |
+
ul.products li.product {margin: 20px 10px 30px;padding: 0;position: relative;overflow: hidden}
|
94 |
+
ul.products li.product h4 {background: none repeat scroll 0 0 transparent;border: 0 none;color: #006999;cursor: pointer;font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size: 20px;font-weight: normal;line-height: 26px;margin: 0 0 10px;}
|
95 |
+
ul.products li.product a {text-decoration: none;}
|
96 |
+
ul.products li.product a img, div.product div.images img {box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);}
|
97 |
+
ul.products li.product a img {box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.3);display: block;height: auto;margin: 5px 15px 5px 5px;transition: all 0.2s ease-in-out 0s;float: left; width: 200px}
|
98 |
+
|
99 |
+
ul.products li.product .price, ul.products li.product .price .amount, ul.products li.product .price ins {color: #85AD74;font-size: 25px;font-weight: bold;}
|
100 |
+
ul.products li.product .price {line-height: 1.4em;color: #85AD74;display: block;font-weight: normal;margin-bottom: 0.5em;}
|
101 |
+
/*ul.products li.product .add_to_cart_button{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
|
102 |
+
background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
|
103 |
+
background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
|
104 |
+
background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
|
105 |
+
background-image: -ms-linear-gradient(bottom, #F7F6F7 0%, #DFDBDF 100%);
|
106 |
+
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #F7F6F7),color-stop(1, #DFDBDF));
|
107 |
+
border: 1px solid #C7C0C7;border-radius: 2px 2px 2px 2px;box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.075) inset, 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 2px rgba(0, 0, 0, 0.1);color: #5E5E5E;cursor: pointer;font-family: inherit;font-size: 14px;font-weight: bold;float: right;left: auto;margin: 0;overflow: visible;padding: 6px 10px;position: relative;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;}
|
108 |
+
|
109 |
+
ul.products li.product .add_to_cart_button:hover{background-image: linear-gradient(bottom, #F7F6F7 47%, #DFDBDF 74%);
|
110 |
+
background-image: -o-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
|
111 |
+
background-image: -moz-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
|
112 |
+
background-image: -webkit-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
|
113 |
+
background-image: -ms-linear-gradient(bottom, #F7F6F7 0%, #D3CED3 100%);
|
114 |
+
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(1, #F7F6F7),color-stop(1, #D3CED3));}
|
115 |
+
*/
|
116 |
+
ul.products li.product .product_footer{margin: 20px 0 0;overflow: hidden;}
|
117 |
+
ul.products li.product .add_to_cart_button{background: #C45200; color: #FFFFFF;display: inline-block;font-size: 18px;font-weight: bold; line-height: 1.4em; margin: 0 20px; padding: 4px 15px;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6)}
|
118 |
+
ul.products li.product .product_footer .product_demo_link{font-size: 16px;margin: 8px 20px; font-weight: bold}
|
119 |
+
|
120 |
+
ul.products li.product .add_to_cart_button:hover{background: none repeat scroll 0 0 #D75A00;
|
121 |
+
box-shadow: 0 1px rgba(0, 0, 0, 0.2), 0 0 1px rgba(0, 0, 0, 0.4) inset;
|
122 |
+
color: #FFFFFF;}
|
123 |
+
|
124 |
+
/* Admin bar Menu */
|
125 |
+
#wpadminbar .bp-media-settings-menu > .ab-item .ab-icon{background: url("../img/bpm-icon-16.png") no-repeat scroll -8px -7px transparent}
|
126 |
+
#wpadminbar .bp-media-settings-menu:hover .ab-icon{background-position: -8px -41px}
|
127 |
+
|
128 |
+
|
129 |
+
.bp-media-form li{margin-bottom: 10px}
|
130 |
+
.bp-media-form .bp-media-label{ display: inline-block;margin-right: 10px;width: 150px;vertical-align: top}
|
131 |
+
.bp-media-form .bp-media-input{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;line-height: 16px;padding: 5px;width: 220px;}
|
132 |
+
.bp-media-form .bp-media-textarea{background-color: #FFFFFF;border: 1px solid #DFDFDF;border-radius: 3px 3px 3px 3px;color: #333333;line-height: 16px;padding: 5px;width: 220px;}
|
133 |
+
#normal-sortables .postbox .bp-media-form .submit{float: none; margin-left: 150px}
|
134 |
+
div.rt-success{background-color: #E1FFDF;border-color: #2ACF2A;}
|
135 |
+
img.bp-media-donation-image{display:block;margin: 10px auto;}
|
136 |
+
|
includes/img/bpm-icon-16.png
ADDED
Binary file
|
includes/img/bpm-icon-32.png
ADDED
Binary file
|
includes/img/donate.gif
ADDED
Binary file
|
includes/img/donate.png
ADDED
Binary file
|
includes/img/logo_medibp_32.png
CHANGED
Binary file
|
includes/img/rtCamp-bullet.png
ADDED
Binary file
|
includes/img/rtcamp-logo.png
ADDED
Binary file
|
includes/js/bp-media-uploader.js
CHANGED
@@ -1,37 +1,112 @@
|
|
1 |
-
/*
|
2 |
* To change this template, choose Tools | Templates
|
3 |
* and open the template in the editor.
|
4 |
*/
|
5 |
|
6 |
jQuery(document).ready(function(){
|
|
|
|
|
|
|
7 |
var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
|
|
|
8 |
bp_media_uploader.init();
|
9 |
bp_media_uploader.bind('FilesAdded', function(up, files) {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
});
|
|
|
|
|
|
|
|
|
15 |
bp_media_uploader.start();
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
});
|
1 |
+
/*
|
2 |
* To change this template, choose Tools | Templates
|
3 |
* and open the template in the editor.
|
4 |
*/
|
5 |
|
6 |
jQuery(document).ready(function(){
|
7 |
+
var bp_media_is_multiple_upload = false;
|
8 |
+
if(jQuery('#'+bp_media_uploader_params.container).length==0)
|
9 |
+
return false;
|
10 |
var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
|
11 |
+
var bp_media_album_selected = false;
|
12 |
bp_media_uploader.init();
|
13 |
bp_media_uploader.bind('FilesAdded', function(up, files) {
|
14 |
+
//bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
|
15 |
+
bp_media_is_multiple_upload = files.length>1;
|
16 |
+
jQuery.each(files, function(i, file) {
|
17 |
+
jQuery('#bp-media-uploaded-files').append(
|
18 |
+
'<div id="bp-media-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' +
|
19 |
+
file.name + ' (' + plupload.formatSize(file.size) + ')(<b></b>)</div><div class="bp-media-progress-completed"></div></div>');
|
20 |
+
});
|
21 |
+
if(bp_media_album_selected == false&&bp_media_is_multiple_upload==true){
|
22 |
+
bp_media_album_select.dialog('option','buttons',{
|
23 |
+
'Select': function() {
|
24 |
+
bp_media_album_selected = jQuery('#bp-media-selected-album').val();
|
25 |
+
bp_media_uploader.start();
|
26 |
+
jQuery(this).dialog("close");
|
27 |
+
},
|
28 |
+
'Create New': function(){
|
29 |
+
bp_media_new_album.dialog('option','buttons',{
|
30 |
+
'Create' : function(){
|
31 |
+
var album_name = jQuery('#bp_media_album_name').val();
|
32 |
+
if(album_name.length==0){
|
33 |
+
alert('You have not filled the album name');
|
34 |
+
return false;
|
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('There was some error creating album');
|
44 |
+
}
|
45 |
+
else{
|
46 |
+
jQuery('#bp-media-selected-album').append('<option value='+album+' selected="selected">'+jQuery('#bp_media_album_name').val()+'</option>')
|
47 |
+
bp_media_new_album.dialog('close');
|
48 |
+
bp_media_album_selected = jQuery('#bp-media-selected-album').val();
|
49 |
+
bp_media_album_select.dialog('close');
|
50 |
+
bp_media_uploader.start();
|
51 |
+
}
|
52 |
+
});
|
53 |
+
}
|
54 |
+
});
|
55 |
+
bp_media_new_album.dialog('open');
|
56 |
+
}
|
57 |
});
|
58 |
+
bp_media_album_select.dialog('open');
|
59 |
+
}
|
60 |
+
else{
|
61 |
+
bp_media_album_selected = jQuery('#bp-media-selected-album').val();
|
62 |
bp_media_uploader.start();
|
63 |
+
}
|
64 |
+
up.refresh(); // Reposition Flash/Silverlight
|
65 |
+
});
|
66 |
+
bp_media_uploader.bind('UploadProgress', function(up, file) {
|
67 |
+
jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
|
68 |
+
jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
|
69 |
+
});
|
70 |
|
71 |
+
bp_media_uploader.bind('Error', function(up, err) {
|
72 |
+
jQuery('#bp-media-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
|
73 |
+
', Message: ' + err.message +
|
74 |
+
(err.file ? ', File: ' + err.file.name : '') +
|
75 |
+
'</p></div>'
|
76 |
+
);
|
77 |
+
up.refresh();
|
78 |
+
});
|
79 |
|
80 |
+
bp_media_uploader.bind('FileUploaded', function(up, file) {
|
81 |
+
jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html("100%");
|
82 |
+
});
|
83 |
+
bp_media_uploader.bind('BeforeUpload',function(up){
|
84 |
+
up.settings.multipart_params.is_multiple_upload = bp_media_is_multiple_upload;
|
85 |
+
up.settings.multipart_params.bp_media_album_id = bp_media_album_selected;
|
86 |
+
});
|
87 |
+
var bp_media_album_select =jQuery('#bp-media-album-prompt').dialog({
|
88 |
+
autoOpen:false,
|
89 |
+
draggable:false,
|
90 |
+
modal:true,
|
91 |
+
resizable:false,
|
92 |
+
closeOnEscape:false
|
93 |
+
});
|
94 |
+
var bp_media_new_album = jQuery('#bp-media-album-new').dialog({
|
95 |
+
autoOpen:false,
|
96 |
+
draggable:false,
|
97 |
+
modal:true,
|
98 |
+
resizable:false,
|
99 |
+
closeOnEscape:false
|
100 |
+
});
|
101 |
+
bp_media_uploader.bind('UploadComplete',function(){
|
102 |
+
var new_location = window.location.href;
|
103 |
+
if(new_location.search('/media/')>0){
|
104 |
+
new_location = new_location.replace('media','albums');
|
105 |
+
if(bp_media_album_selected>0)
|
106 |
+
new_location = new_location.concat(bp_media_album_selected);
|
107 |
+
else
|
108 |
+
new_location = new_location.concat('0/');
|
109 |
+
window.location.replace(new_location);
|
110 |
+
}
|
111 |
+
});
|
112 |
});
|
includes/js/bp-media.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
/*
|
2 |
* BuddyPress Media Default JS
|
3 |
*/
|
4 |
|
5 |
function bp_media_create_element(id){
|
6 |
-
jQuery('#'+id).mediaelementplayer({
|
7 |
enableKeyboard: false,
|
8 |
startVolume: 1,
|
9 |
success: function(mediaElement,domElement){
|
@@ -21,4 +21,44 @@ jQuery(document).ready(function(){
|
|
21 |
bp_media_news_section.find('.inside').html(data);
|
22 |
});
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
});
|
1 |
+
/*
|
2 |
* BuddyPress Media Default JS
|
3 |
*/
|
4 |
|
5 |
function bp_media_create_element(id){
|
6 |
+
jQuery('#'+id).mediaelementplayer({
|
7 |
enableKeyboard: false,
|
8 |
startVolume: 1,
|
9 |
success: function(mediaElement,domElement){
|
21 |
bp_media_news_section.find('.inside').html(data);
|
22 |
});
|
23 |
}
|
24 |
+
var bp_media_recent_tabs = jQuery('#recent-media-tabs');
|
25 |
+
if(bp_media_recent_tabs.length>0){
|
26 |
+
jQuery(bp_media_recent_tabs).tabs();
|
27 |
+
}
|
28 |
+
|
29 |
+
// var bp_media_popular_tabs = jQuery('#popular-media-tabs');
|
30 |
+
// if(bp_media_popular_tabs.length>0){
|
31 |
+
// jQuery( bp_media_popular_tabs ).tabs();
|
32 |
+
// }
|
33 |
+
|
34 |
+
var tallest = 0;
|
35 |
+
jQuery('#recent-media-tabs .bp-media-tab-panel').each(function() {
|
36 |
+
|
37 |
+
var thisHeight = jQuery(this).height();
|
38 |
+
console.log(thisHeight);
|
39 |
+
if(thisHeight > tallest) {
|
40 |
+
tallest = thisHeight;
|
41 |
+
}
|
42 |
+
}).height(tallest);
|
43 |
+
|
44 |
+
|
45 |
+
jQuery('#bp-media-show-more').click(function(e){
|
46 |
+
e.preventDefault();
|
47 |
+
var data = {
|
48 |
+
action: 'bp_media_load_more',
|
49 |
+
page:++bp_media_vars.page,
|
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
|
57 |
+
jQuery.post(bp_media_vars.ajaxurl, data, function(response) {
|
58 |
+
if(response.length==0)
|
59 |
+
jQuery('#bp-media-show-more').parent().remove();
|
60 |
+
else
|
61 |
+
jQuery('#bp-media-list').append(response);
|
62 |
+
});
|
63 |
+
});
|
64 |
});
|
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 |
*/
|
@@ -12,24 +12,36 @@ Author URI: http://rtcamp.com
|
|
12 |
define('BP_MEDIA_IS_INSTALLED', 1);
|
13 |
|
14 |
/* Constant to store the current version of the BP Media Plugin. */
|
15 |
-
define('BP_MEDIA_VERSION', '2.
|
16 |
|
17 |
/* A constant to be used as base for other URLs throughout the plugin */
|
18 |
define('BP_MEDIA_PLUGIN_DIR', dirname(__FILE__));
|
19 |
|
20 |
-
/* A constant to store the Database Version of the BP Media Plugin */
|
21 |
-
define('BP_MEDIA_DB_VERSION', '1');
|
22 |
-
|
23 |
/* A constant to store the required */
|
24 |
-
define('BP_MEDIA_REQUIRED_BP','1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
/**
|
27 |
* Function to initialize the BP Media Plugin
|
28 |
-
*
|
29 |
* It checks for the version minimum required version of buddypress before initializing.
|
30 |
-
*
|
31 |
* @uses BP_VERSION to check if the plugin supports the BuddyPress version.
|
32 |
-
*
|
33 |
* @since BP Media 2.0
|
34 |
*/
|
35 |
function bp_media_init() {
|
@@ -43,13 +55,28 @@ add_action('bp_include', 'bp_media_init');
|
|
43 |
* Function to do the tasks required to be done while activating the plugin
|
44 |
*/
|
45 |
function bp_media_activate() {
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
|
|
48 |
register_activation_hook(__FILE__, 'bp_media_activate');
|
49 |
|
50 |
/**
|
51 |
* Function to do the tasks during deactivation.
|
52 |
-
*
|
53 |
* Will Make this function to do the db deletion and other things that might have been created with the plugin.
|
54 |
*/
|
55 |
function bp_media_deactivate() {
|
@@ -72,7 +99,7 @@ function bp_media_admin_notice() {
|
|
72 |
echo "</p></div>";
|
73 |
}
|
74 |
}
|
75 |
-
else
|
76 |
echo '<div class="error"><p>';
|
77 |
printf(__('You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin.<a class="alignright" href="%1$s">X</a>'), '?bp_media_nag_ignore=0');
|
78 |
echo "</p></div>";
|
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.2
|
7 |
Author: rtCamp
|
8 |
Author URI: http://rtcamp.com
|
9 |
*/
|
12 |
define('BP_MEDIA_IS_INSTALLED', 1);
|
13 |
|
14 |
/* Constant to store the current version of the BP Media Plugin. */
|
15 |
+
define('BP_MEDIA_VERSION', '2.2');
|
16 |
|
17 |
/* A constant to be used as base for other URLs throughout the plugin */
|
18 |
define('BP_MEDIA_PLUGIN_DIR', dirname(__FILE__));
|
19 |
|
|
|
|
|
|
|
20 |
/* A constant to store the required */
|
21 |
+
define('BP_MEDIA_REQUIRED_BP','1.6');
|
22 |
+
|
23 |
+
/* A constatnt to store database version */
|
24 |
+
define('BP_MEDIA_DB_VERSION','2.0');
|
25 |
+
|
26 |
+
/* A constant to Active Collab API Assignee ID */
|
27 |
+
define('BP_MEDIA_AC_API_ASSIGNEE_ID','5');
|
28 |
+
|
29 |
+
/* A constant to Active Collab API Assignee ID */
|
30 |
+
define('BP_MEDIA_AC_API_LABEL_ID','1');
|
31 |
+
|
32 |
+
/* A constant to Active Collab API priority */
|
33 |
+
define('BP_MEDIA_AC_API_PRIORITY','2');
|
34 |
+
|
35 |
+
/* A constant to Active Collab API priority */
|
36 |
+
define('BP_MEDIA_AC_API_CATEGORY_ID','224');
|
37 |
|
38 |
/**
|
39 |
* Function to initialize the BP Media Plugin
|
40 |
+
*
|
41 |
* It checks for the version minimum required version of buddypress before initializing.
|
42 |
+
*
|
43 |
* @uses BP_VERSION to check if the plugin supports the BuddyPress version.
|
44 |
+
*
|
45 |
* @since BP Media 2.0
|
46 |
*/
|
47 |
function bp_media_init() {
|
55 |
* Function to do the tasks required to be done while activating the plugin
|
56 |
*/
|
57 |
function bp_media_activate() {
|
58 |
+
$bp_media_options = get_option('bp_media_options',array(
|
59 |
+
'videos_enabled' => true,
|
60 |
+
'audio_enabled' => true,
|
61 |
+
'images_enabled' => true,
|
62 |
+
'remove_linkback' => '1',
|
63 |
+
'download_enabled' => true,
|
64 |
+
));
|
65 |
+
$previous_linkback_status = get_option('bp_media_remove_linkback');
|
66 |
+
if($previous_linkback_status===false)
|
67 |
+
$bp_media_options['remove_linkback'] = '1';
|
68 |
+
else{
|
69 |
+
$bp_media_options['remove_linkback'] = $previous_linkback_status;
|
70 |
+
delete_option('bp_media_remove_linkback');
|
71 |
+
}
|
72 |
+
update_option('bp_media_options',$bp_media_options);
|
73 |
}
|
74 |
+
|
75 |
register_activation_hook(__FILE__, 'bp_media_activate');
|
76 |
|
77 |
/**
|
78 |
* Function to do the tasks during deactivation.
|
79 |
+
*
|
80 |
* Will Make this function to do the db deletion and other things that might have been created with the plugin.
|
81 |
*/
|
82 |
function bp_media_deactivate() {
|
99 |
echo "</p></div>";
|
100 |
}
|
101 |
}
|
102 |
+
else {
|
103 |
echo '<div class="error"><p>';
|
104 |
printf(__('You have not installed BuddyPress. Please install latest version of BuddyPress to use BuddyPress Media plugin.<a class="alignright" href="%1$s">X</a>'), '?bp_media_nag_ignore=0');
|
105 |
echo "</p></div>";
|
readme.txt
CHANGED
@@ -1,49 +1,64 @@
|
|
1 |
=== BuddyPress Media ===
|
2 |
-
Contributors: rtcamp
|
3 |
-
Donate link: https://
|
4 |
-
Tags: BuddyPress, media, multimedia, audio, video, photo,
|
5 |
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
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
BuddyPress Media adds
|
16 |
|
17 |
= Features =
|
18 |
-
|
|
|
|
|
|
|
19 |
* Uploading Photos/Videos via mobile (Tested on iPhone running iOS6)
|
20 |
* HTML5 player (with fall back to flash/silverlight player support)
|
21 |
-
* Automatic conversion of common audio & video formats to mp3/mp4. via [
|
22 |
|
23 |
= Roadmap =
|
24 |
-
|
|
|
|
|
25 |
* Paid membership plans, i.e. "Upload Quota" for buddypress members (in planning stage).
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
== Installation ==
|
28 |
|
29 |
= BuddyPress Media Plugin =
|
30 |
|
31 |
-
Install the plugin from the 'Plugins' section in your dashboard (Go to `Plugins > Add New > Search` and search for BuddyPress Media).
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
It also supports many audio formats including *.mp3, *.ogg, *.wav, *.aac, *.m4a, *.wma.
|
43 |
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
|
48 |
|
49 |
== Frequently Asked Questions ==
|
@@ -56,6 +71,15 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
= 2.1.5 =
|
60 |
* Fixed the postmeta box bug
|
61 |
|
@@ -100,4 +124,4 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
100 |
* HTML5 Video Tag Support (with fallback)
|
101 |
|
102 |
== Upgrade Notice ==
|
103 |
-
|
1 |
=== BuddyPress Media ===
|
2 |
+
Contributors: rtcamp, rahul286, gagan0123, umeshnevase
|
3 |
+
Donate link: https://rtcamp.com/donate
|
4 |
+
Tags: BuddyPress, media, multimedia, album, audio, songs, music, video, photo, image, upload, share, MediaElement.js, ffmpeg, kaltura, media-node
|
5 |
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.2
|
10 |
|
11 |
+
Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
BuddyPress Media adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
16 |
|
17 |
= Features =
|
18 |
+
|
19 |
+
* Images, Music, Videos Upload
|
20 |
+
* User-Albums Support
|
21 |
+
* Multiple files upload with Darg-n-Drop
|
22 |
* Uploading Photos/Videos via mobile (Tested on iPhone running iOS6)
|
23 |
* HTML5 player (with fall back to flash/silverlight player support)
|
24 |
+
* Automatic conversion of common audio & video formats to mp3/mp4. via [Kaltura Add-On](http://rtcamp.com/store/buddypress-media-kaltura/ "BuddyPress Media Kaltura Addon for Kaltura.com/Kaltura-CE/Kaltura On-Prem version") and [FFMPEG Add-On](http://rtcamp.com/store/buddypress-media-ffmpeg-converter/ "BuddyPress Media FFMPEG Addon")
|
25 |
|
26 |
= Roadmap =
|
27 |
+
|
28 |
+
* Group Albums
|
29 |
+
* Activity-update form media upload
|
30 |
* Paid membership plans, i.e. "Upload Quota" for buddypress members (in planning stage).
|
31 |
|
32 |
+
= Demo =
|
33 |
+
* [BuddyPress-Media Demo](http://demo.rtcamp.com/buddypress-media) (Stand-alone)
|
34 |
+
* [BuddyPress-Media + Kaltura Add-on](http://demo.rtcamp.com/bpm-kaltura)
|
35 |
+
* [BuddyPress-Media + FFMPEG Add-on](http://demo.rtcamp.com/bpm-ffmpeg)
|
36 |
+
|
37 |
== Installation ==
|
38 |
|
39 |
= BuddyPress Media Plugin =
|
40 |
|
41 |
+
* Install the plugin from the 'Plugins' section in your dashboard (Go to `Plugins > Add New > Search` and search for BuddyPress Media).
|
42 |
+
* Alternatively, you can [download](http://downloads.wordpress.org/plugin/buddypress-media.zip "Download BuddyPress Media") the plugin from the repository. Unzip it and upload it to the plugins folder of your WordPress installation (`wp-content/plugins/` directory of your WordPress installation).
|
43 |
+
* Activate it through the 'Plugins' section.
|
44 |
+
|
45 |
+
= BuddyPress Media Add-ons =
|
46 |
|
47 |
+
[**BuddyPress-Media Kaltura addon**](http://rtcamp.com/store/buddypress-media-kaltura/ "BuddyPress Media Kaltura Addon for Kaltura.com/Kaltura-CE/Kaltura On-Prem version")
|
48 |
|
49 |
+
* It also supports many video formats including *.avi, *.mkv, *.asf, *.flv, *.wmv, *.rm, *.mpg.
|
50 |
+
* You can use Kaltura.com/Kaltura On-Prem or self-hosted Kaltura-CE server with this.
|
51 |
|
52 |
+
You can purchase it from [here](http://rtcamp.com/store/buddypress-media-kaltura/ "BuddyPress Media Kaltura Addon for Kaltura.com/Kaltura-CE/Kaltura On-Prem version")
|
53 |
|
54 |
+
--
|
55 |
|
56 |
+
[**BuddyPress-Media FFMPEG addon**](http://rtcamp.com/store/buddypress-media-ffmpeg-converter/ "BuddyPress Media FFMPEG Addon").
|
|
|
57 |
|
58 |
+
* It also supports many video formats including *.avi, *.mkv, *.asf, *.flv, *.wmv, *.rm, *.mpg.
|
59 |
+
* It also supports many audio formats including *.mp3, *.ogg, *.wav, *.aac, *.m4a, *.wma.
|
60 |
|
61 |
+
You can purchase it from [here](http://rtcamp.com/store/buddypress-media-ffmpeg-converter/ "BuddyPress Media FFMPEG Addon").
|
62 |
|
63 |
|
64 |
== Frequently Asked Questions ==
|
71 |
|
72 |
== Changelog ==
|
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 fuure releases.
|
75 |
+
|
76 |
+
= 2.2 =
|
77 |
+
* Album Support for Users
|
78 |
+
* Ajaxified pagination to make it easy to view large albums.
|
79 |
+
* Multiple file uploads with progress bar
|
80 |
+
* Easy access to the backend admin-options
|
81 |
+
* Admin-option to disable download button below media files.
|
82 |
+
|
83 |
= 2.1.5 =
|
84 |
* Fixed the postmeta box bug
|
85 |
|
124 |
* HTML5 Video Tag Support (with fallback)
|
125 |
|
126 |
== Upgrade Notice ==
|
127 |
+
Added album support for user-profile. Important update with plenty of new features.
|