Version Description
- Integration into BuddyPress Activities
- HTML5 Audio Tag Support (with fallback)
- HTML5 Video Tag Support (with fallback)
Download this release
Release Info
Developer | rtcamp |
Plugin | ![]() |
Version | 2.0 |
Comparing to | |
See all releases |
Version 2.0
- includes/bp-media-actions.php +186 -0
- includes/bp-media-admin.php +187 -0
- includes/bp-media-class-wordpress.php +365 -0
- includes/bp-media-filters.php +76 -0
- includes/bp-media-functions.php +118 -0
- includes/bp-media-loader.php +353 -0
- includes/bp-media-screens.php +337 -0
- includes/bp-media-shortcodes.php +38 -0
- includes/bp-media-template-functions.php +102 -0
- includes/css/bp-media-admin.css +39 -0
- includes/css/bp-media-style.css +65 -0
- includes/img/audio_thumb.png +0 -0
- includes/img/bp_media_social.png +0 -0
- includes/img/image_thumb.png +0 -0
- includes/img/logo_medibp_32.png +0 -0
- includes/img/video_thumb.png +0 -0
- includes/js/bp-media.js +15 -0
- includes/lib/MP4Info.php +257 -0
- includes/lib/MP4Info/Box.php +446 -0
- includes/lib/MP4Info/Box/Container.php +99 -0
- includes/lib/MP4Info/Box/ftyp.php +231 -0
- includes/lib/MP4Info/Box/hdlr.php +140 -0
- includes/lib/MP4Info/Box/ilst.php +122 -0
- includes/lib/MP4Info/Box/ilst_sub.php +148 -0
- includes/lib/MP4Info/Box/mdhd.php +146 -0
- includes/lib/MP4Info/Box/meta.php +69 -0
- includes/lib/MP4Info/Box/mvhd.php +233 -0
- includes/lib/MP4Info/Box/stsd.php +139 -0
- includes/lib/MP4Info/Box/tkhd.php +215 -0
- includes/lib/MP4Info/Box/uuid.php +117 -0
- includes/lib/MP4Info/Exception.php +61 -0
- includes/lib/MP4Info/Helper.php +72 -0
- includes/media-element/background.png +0 -0
- includes/media-element/bigplay.png +0 -0
- includes/media-element/controls-ted.png +0 -0
- includes/media-element/controls-wmp-bg.png +0 -0
- includes/media-element/controls-wmp.png +0 -0
- includes/media-element/controls.png +0 -0
- includes/media-element/flashmediaelement.swf +0 -0
- includes/media-element/loading.gif +0 -0
- includes/media-element/mediaelement-and-player.js +4262 -0
- includes/media-element/mediaelement-and-player.min.js +149 -0
- includes/media-element/mediaelement.js +1517 -0
- includes/media-element/mediaelement.min.js +59 -0
- includes/media-element/mediaelementplayer.css +801 -0
- includes/media-element/mediaelementplayer.js +2743 -0
- includes/media-element/mediaelementplayer.min.css +1 -0
- includes/media-element/mediaelementplayer.min.js +88 -0
- includes/media-element/mejs-skins.css +283 -0
- includes/media-element/silverlightmediaelement.xap +0 -0
- loader.php +56 -0
- readme.txt +40 -0
includes/bp-media-actions.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() {
|
8 |
+
global $bp;
|
9 |
+
if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
|
10 |
+
if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
|
11 |
+
$bp_media_entry = new BP_Media_Host_Wordpress();
|
12 |
+
try {
|
13 |
+
$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);
|
14 |
+
$entry = $bp_media_entry->add_media($title, $_POST['bp_media_description']);
|
15 |
+
$bp->{BP_MEDIA_SLUG}->messages['updated'][] = __('Upload Successful', 'bp-media');
|
16 |
+
} catch (Exception $e) {
|
17 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
|
18 |
+
}
|
19 |
+
} else {
|
20 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', 'bp-media');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
add_action('bp_init', 'bp_media_handle_uploads');
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Displays the messages that other functions/methods creates according to the BuddyPress' formating
|
28 |
+
*
|
29 |
+
* @since BP Media 2.0
|
30 |
+
*/
|
31 |
+
function bp_media_show_messages() {
|
32 |
+
global $bp;
|
33 |
+
if (is_array($bp->{BP_MEDIA_SLUG}->messages)) {
|
34 |
+
$types = array('error', 'updated', 'info');
|
35 |
+
foreach ($types as $type) {
|
36 |
+
if (count($bp->{BP_MEDIA_SLUG}->messages[$type]) > 0) {
|
37 |
+
bp_media_show_formatted_error_message($bp->{BP_MEDIA_SLUG}->messages[$type], $type);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
add_action('bp_media_before_content', 'bp_media_show_messages');
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Enqueues all the required scripts and stylesheets for the proper working of BuddyPress Media Component
|
46 |
+
*
|
47 |
+
* @since BP Media 2.0
|
48 |
+
*/
|
49 |
+
function bp_media_enqueue_scripts_styles() {
|
50 |
+
wp_enqueue_script('bp-media-mejs', plugins_url('includes/media-element/mediaelement-and-player.min.js', dirname(__FILE__)));
|
51 |
+
wp_enqueue_script('bp-media-default', plugins_url('includes/js/bp-media.js', dirname(__FILE__)));
|
52 |
+
wp_enqueue_style('bp-media-mecss', plugins_url('includes/media-element/mediaelementplayer.min.css', dirname(__FILE__)));
|
53 |
+
wp_enqueue_style('bp-media-default', plugins_url('includes/css/bp-media-style.css', dirname(__FILE__)));
|
54 |
+
}
|
55 |
+
|
56 |
+
add_action('wp_enqueue_scripts', 'bp_media_enqueue_scripts_styles', 11);
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Deletes associated media entry and its files upon deletion of an activity.
|
60 |
+
*
|
61 |
+
* @since BP Media 2.0
|
62 |
+
*/
|
63 |
+
function bp_media_delete_activity_handler($activity_id, $user) {
|
64 |
+
global $bp_media_count;
|
65 |
+
bp_media_init_count(bp_loggedin_user_id());
|
66 |
+
$post_id = bp_activity_get_meta($activity_id, 'bp_media_parent_post');
|
67 |
+
$type = get_post_meta($post_id, 'bp_media_type', true);
|
68 |
+
switch ($type) {
|
69 |
+
case 'image':
|
70 |
+
$bp_media_count['images'] = intval($bp_media_count['images']) - 1;
|
71 |
+
break;
|
72 |
+
case 'video':
|
73 |
+
$bp_media_count['videos'] = intval($bp_media_count['videos']) - 1;
|
74 |
+
break;
|
75 |
+
case 'audio':
|
76 |
+
$bp_media_count['audio'] = intval($bp_media_count['audio']) - 1;
|
77 |
+
break;
|
78 |
+
}
|
79 |
+
$attachment_id = get_post_meta($post_id, 'bp_media_child_attachment', true);
|
80 |
+
wp_delete_attachment($attachment_id, true);
|
81 |
+
wp_delete_post($post_id, true);
|
82 |
+
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
83 |
+
}
|
84 |
+
|
85 |
+
/* Adds bp_media_delete_activity_handler() function to be called on bp_activity_before_action_delete_activity hook */
|
86 |
+
add_action('bp_activity_before_action_delete_activity', 'bp_media_delete_activity_handler', 10, 2);
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Called on bp_init by screen functions
|
90 |
+
*
|
91 |
+
* @uses global $bp, $bp_media_query
|
92 |
+
*
|
93 |
+
* @since BP Media 2.0
|
94 |
+
*/
|
95 |
+
function bp_media_set_query() {
|
96 |
+
global $bp, $bp_media_query;
|
97 |
+
switch ($bp->current_action) {
|
98 |
+
case BP_MEDIA_IMAGES_SLUG:
|
99 |
+
$type = 'image';
|
100 |
+
break;
|
101 |
+
case BP_MEDIA_AUDIO_SLUG:
|
102 |
+
$type = 'audio';
|
103 |
+
break;
|
104 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
105 |
+
$type = 'video';
|
106 |
+
break;
|
107 |
+
default :
|
108 |
+
$type = null;
|
109 |
+
}
|
110 |
+
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])) {
|
111 |
+
$paged = $bp->action_variables[1];
|
112 |
+
} else {
|
113 |
+
$paged = 1;
|
114 |
+
}
|
115 |
+
if ($type) {
|
116 |
+
$args = array(
|
117 |
+
'post_type' => 'bp_media',
|
118 |
+
'author' => $bp->displayed_user->id,
|
119 |
+
'meta_key' => 'bp_media_type',
|
120 |
+
'meta_value' => $type,
|
121 |
+
'meta_compare' => 'LIKE',
|
122 |
+
'paged' => $paged
|
123 |
+
);
|
124 |
+
$bp_media_query = new WP_Query($args);
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Adds a download button on single entry pages of media files.
|
130 |
+
*
|
131 |
+
* @since BP Media 2.0
|
132 |
+
*/
|
133 |
+
function bp_media_action_download_button() {
|
134 |
+
if(!in_array('bp_media_current_entry', $GLOBALS))
|
135 |
+
return false;
|
136 |
+
global $bp_media_current_entry;
|
137 |
+
if($bp_media_current_entry!=NULL)
|
138 |
+
echo '<a href="'.$bp_media_current_entry->get_attachment_url().'" class="button item-button bp-secondary-action bp-media-download" title="Download">Download</a>';
|
139 |
+
}
|
140 |
+
add_action('bp_activity_entry_meta', 'bp_media_action_download_button');
|
141 |
+
|
142 |
+
/* Should be used with Content Disposition Type for media files set to attachment */
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Shows the media count of a user in the tabs
|
146 |
+
*
|
147 |
+
* @since BP Media 2.0
|
148 |
+
*/
|
149 |
+
function bp_media_init_count($user = null) {
|
150 |
+
global $bp_media_count;
|
151 |
+
if (!$user)
|
152 |
+
$user = bp_displayed_user_id();
|
153 |
+
if ($user < 1) {
|
154 |
+
$bp_media_count = null;
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
$count = bp_get_user_meta($user, 'bp_media_count', true);
|
158 |
+
if (!$count) {
|
159 |
+
$bp_media_count = array('images' => 0, 'videos' => 0, 'audio' => 0);
|
160 |
+
bp_update_user_meta($user, 'bp_media_count', $bp_media_count);
|
161 |
+
} else {
|
162 |
+
$bp_media_count = $count;
|
163 |
+
}
|
164 |
+
add_filter('bp_get_displayed_user_nav_' . BP_MEDIA_SLUG, 'bp_media_items_count_filter', 10, 2);
|
165 |
+
|
166 |
+
if (bp_current_component() == BP_MEDIA_SLUG) {
|
167 |
+
add_filter('bp_get_options_nav_' . BP_MEDIA_IMAGES_SLUG, 'bp_media_items_count_filter', 10, 2);
|
168 |
+
add_filter('bp_get_options_nav_' . BP_MEDIA_VIDEOS_SLUG, 'bp_media_items_count_filter', 10, 2);
|
169 |
+
add_filter('bp_get_options_nav_' . BP_MEDIA_AUDIO_SLUG, 'bp_media_items_count_filter', 10, 2);
|
170 |
+
}
|
171 |
+
return true;
|
172 |
+
}
|
173 |
+
add_action('init', 'bp_media_init_count');
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Displays the footer of the BP Media Plugin if enabled through the dashboard options page
|
177 |
+
*
|
178 |
+
* @since BP Media 2.0
|
179 |
+
*/
|
180 |
+
function bp_media_footer() { ?>
|
181 |
+
<div id="bp-media-footer"><p>We ♥ <a href="http://rtcamp.com/buddypress-media/">MediaBP</a></p></div>
|
182 |
+
<?php
|
183 |
+
}
|
184 |
+
if(get_option('bp_media_remove_linkback')!='1')
|
185 |
+
add_action('bp_footer','bp_media_footer');
|
186 |
+
?>
|
includes/bp-media-admin.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Add the BuddyPress Media Component's options menu in the BuddyPress' options subnavigation.
|
4 |
+
*
|
5 |
+
* @since BP Media 2.0
|
6 |
+
*/
|
7 |
+
function bp_media_add_admin_menu() {
|
8 |
+
global $bp;
|
9 |
+
if (!is_super_admin())
|
10 |
+
return false;
|
11 |
+
|
12 |
+
$page = add_submenu_page('bp-general-settings', __('BuddyPress Media Component Settings', 'bp-media'), __('MediaBP', 'bp-media'), 'manage_options', 'bp-media-settings', 'bp_media_admin_menu'
|
13 |
+
);
|
14 |
+
add_action('admin_print_styles-' . $page, 'bp_media_admin_enqueue');
|
15 |
+
}
|
16 |
+
add_action(bp_core_admin_hook(), 'bp_media_add_admin_menu');
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Displays and updates the options menu of BuddyPress Media Component
|
20 |
+
*
|
21 |
+
* @since BP Media 2.0
|
22 |
+
*/
|
23 |
+
function bp_media_admin_menu() {
|
24 |
+
$bp_media_errors=array();
|
25 |
+
$bp_media_messages=array();
|
26 |
+
|
27 |
+
if(array_key_exists('submit', $_POST)){
|
28 |
+
check_admin_referer('bp_media_update_options');
|
29 |
+
if(array_key_exists('refresh_media_count', $_POST)){
|
30 |
+
if(!bp_media_update_count())
|
31 |
+
$bp_media_errors[]="Recounting Failed";
|
32 |
+
else
|
33 |
+
$bp_media_messages[]="Recounting of media files done successfully";
|
34 |
+
}
|
35 |
+
if(array_key_exists('remove_linkback', $_POST)&&$_POST['remove_linkback']=='1'){
|
36 |
+
update_option('bp_media_remove_linkback', '1');
|
37 |
+
}
|
38 |
+
else{
|
39 |
+
update_option('bp_media_remove_linkback', '0');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
?>
|
43 |
+
<div class="metabox-fixed metabox-holder alignright">
|
44 |
+
<?php bp_media_default_admin_sidebar(); ?>
|
45 |
+
</div>
|
46 |
+
<div class="wrap bp-media-admin">
|
47 |
+
<div id="icon-bp-media" class="icon32"><br/></div>
|
48 |
+
<h2>BuddyPress Media Component Settings</h2>
|
49 |
+
<?php if(count($bp_media_errors)) { ?>
|
50 |
+
<div class="error"><p><?php foreach($bp_media_errors as $error) echo $error.'<br/>'; ?></p></div>
|
51 |
+
<?php } if(count($bp_media_messages)){?>
|
52 |
+
<div class="updated"><p><?php foreach($bp_media_messages as $message) echo $message.'<br/>'; ?></p></div>
|
53 |
+
<?php }?>
|
54 |
+
<form method="post">
|
55 |
+
<?php wp_nonce_field( 'bp_media_update_options' ); ?>
|
56 |
+
<table class="form-table ">
|
57 |
+
<tbody>
|
58 |
+
<tr valign="top">
|
59 |
+
<th scope="row"><label for="refresh_media_count">Re-Count Media Entries</label></th>
|
60 |
+
<td> <fieldset><legend class="screen-reader-text"><span>Re-Count Media Entries</span></legend><label for="refresh_media_count">
|
61 |
+
<input name="refresh_media_count" type="checkbox" id="refresh_media_count" value="1">
|
62 |
+
Check for Re-Count</label>
|
63 |
+
</fieldset></td>
|
64 |
+
</tr>
|
65 |
+
<tr valign="top">
|
66 |
+
<th scope="row"><label for="remove_linkback">Remove Linkback</label></th>
|
67 |
+
<td>
|
68 |
+
<fieldset>
|
69 |
+
<legend class="screen-reader-text"><span>Remove Linkback</span></legend>
|
70 |
+
<label for="remove_linkback"><input name="remove_linkback" type="checkbox" id="remove_linkback" value="1" <?php if(get_option('bp_media_remove_linkback')=='1') echo 'checked="checked"' ?>> Removes the link to MediaBP from footer</label>
|
71 |
+
</fieldset>
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
</tbody>
|
75 |
+
</table>
|
76 |
+
<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p></form>
|
77 |
+
</div>
|
78 |
+
<?php
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Display feeds from a specified Feed URL
|
83 |
+
*
|
84 |
+
* @param string $feed_url The Feed URL.
|
85 |
+
*
|
86 |
+
* @since BP Media 2.0
|
87 |
+
*/
|
88 |
+
function bp_media_get_feeds($feed_url = 'http://rtcamp.com/blog/category/buddypress-media/feed/') {
|
89 |
+
// Get RSS Feed(s)
|
90 |
+
require_once( ABSPATH . WPINC . '/feed.php' );
|
91 |
+
$maxitems = 0;
|
92 |
+
// Get a SimplePie feed object from the specified feed source.
|
93 |
+
$rss = fetch_feed($feed_url);
|
94 |
+
if (!is_wp_error($rss)) { // Checks that the object is created correctly
|
95 |
+
// Figure out how many total items there are, but limit it to 5.
|
96 |
+
$maxitems = $rss->get_item_quantity(5);
|
97 |
+
|
98 |
+
// Build an array of all the items, starting with element 0 (first element).
|
99 |
+
$rss_items = $rss->get_items(0, $maxitems);
|
100 |
+
}
|
101 |
+
?>
|
102 |
+
<ul><?php
|
103 |
+
if ($maxitems == 0) {
|
104 |
+
echo '<li>' . __('No items', 'bp-media') . '.</li>';
|
105 |
+
} else {
|
106 |
+
// Loop through each feed item and display each item as a hyperlink.
|
107 |
+
foreach ($rss_items as $item) {
|
108 |
+
?>
|
109 |
+
<li>
|
110 |
+
<a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __('Posted ', 'bp-media') . $item->get_date('j F Y | g:i a'); ?>'><?php echo $item->get_title(); ?></a>
|
111 |
+
</li><?php
|
112 |
+
}
|
113 |
+
}
|
114 |
+
?>
|
115 |
+
</ul><?php
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Default BuddyPress Media Component admin sidebar with metabox styling
|
120 |
+
*
|
121 |
+
* @since BP Media 2.0
|
122 |
+
*/
|
123 |
+
function bp_media_default_admin_sidebar() {
|
124 |
+
?>
|
125 |
+
<div class="postbox" id="social">
|
126 |
+
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
127 |
+
<h3 class="hndle"><span><?php _e('Getting Social is Good', 'bp-media'); ?></span></h3>
|
128 |
+
<div class="inside" style="text-align:center;">
|
129 |
+
<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>
|
130 |
+
<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>
|
131 |
+
<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>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
|
135 |
+
<div class="postbox" id="donations">
|
136 |
+
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
137 |
+
<h3 class="hndle"><span><?php _e('Promote, Donate, Share', 'bp-media'); ?>...</span></h3>
|
138 |
+
<div class="inside">
|
139 |
+
<p><?php printf(__('Buy coffee/beer for team behind <a href="%s" title="BuddyPress Media Component">BuddyPress Media Component</a>.', 'bp-media'), 'http://rtcamp.com/buddypress-media/'); ?></p>
|
140 |
+
<div class="bp-media-paypal" style="text-align:center">
|
141 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
142 |
+
<input type="hidden" name="cmd" value="_donations" />
|
143 |
+
<input type="hidden" name="business" value="paypal@rtcamp.com" />
|
144 |
+
<input type="hidden" name="lc" value="US" />
|
145 |
+
<input type="hidden" name="item_name" value="BuddyPress Media Component" />
|
146 |
+
<input type="hidden" name="no_note" value="0" />
|
147 |
+
<input type="hidden" name="currency_code" value="USD" />
|
148 |
+
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest" />
|
149 |
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!" />
|
150 |
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
|
151 |
+
</form>
|
152 |
+
</div>
|
153 |
+
<div class="rt-social-share" style="text-align:center; width: 135px; margin: 2px auto">
|
154 |
+
<div class="rt-facebook" style="float:left; margin-right:5px;">
|
155 |
+
<a style=" text-align:center;" name="fb_share" type="box_count" share_url="http://rtcamp.com/buddypress-media/"></a>
|
156 |
+
</div>
|
157 |
+
<div class="rt-twitter" style="">
|
158 |
+
<a href="<?php printf('%s', 'http://twitter.com/share'); ?>" class="twitter-share-button" data-text="I ♥ #mediabp" data-url="http://rtcamp.com/buddypress-media/" data-count="vertical" data-via="mediabp"><?php _e('Tweet', 'bp-media'); ?></a>
|
159 |
+
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
|
160 |
+
</div>
|
161 |
+
<div class="clear"></div>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
|
166 |
+
<div class="postbox" id="support">
|
167 |
+
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
168 |
+
<h3 class="hndle"><span><?php _e('Free Support', 'bp-media'); ?></span></h3>
|
169 |
+
<div class="inside"><p><?php printf(__(' If you are facing any problems while using BuddyPress Media Component, or have good ideas for improvements, please discuss the same in our <a href="%s" target="_blank" title="Click here for BuddyPress Media Component Free Support">Support forums</a>', 'bp-media'), 'http://rtcamp.com/support/forum/buddypress-media/'); ?>.</p></div>
|
170 |
+
</div>
|
171 |
+
|
172 |
+
<div class="postbox" id="latest_news">
|
173 |
+
<div title="<?php _e('Click to toggle', 'bp-media'); ?>" class="handlediv"><br /></div>
|
174 |
+
<h3 class="hndle"><span><?php _e('Latest News', 'bp-media'); ?></span></h3>
|
175 |
+
<div class="inside"><?php bp_media_get_feeds(); ?></div>
|
176 |
+
</div><?php
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Enqueues the scripts and stylesheets needed for the BuddyPress Media Component's options page
|
181 |
+
*/
|
182 |
+
function bp_media_admin_enqueue() {
|
183 |
+
wp_enqueue_style('bp-media-admin-style', plugins_url('includes/css/bp-media-admin.css', dirname(__FILE__)));
|
184 |
+
wp_enqueue_script('rt-fb-share', ('http://static.ak.fbcdn.net/connect.php/js/FB.Share'), '', '', true);
|
185 |
+
}
|
186 |
+
add_action('admin_enqueue_scripts', 'bp_media_admin_enqueue');
|
187 |
+
?>
|
includes/bp-media-class-wordpress.php
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class BP_Media_Host_Wordpress {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Private variables not to be accessible outside this class' member functions
|
6 |
+
*/
|
7 |
+
private $id, //id of the entry
|
8 |
+
$name, //Name of the entry
|
9 |
+
$description, //Description of the entry
|
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 |
+
|
15 |
+
/**
|
16 |
+
* Constructs a new BP_Media_Host_Wordpress element
|
17 |
+
*
|
18 |
+
* @param mixed $media_id optional Media ID of the element to be initialized if not defined, returns an empty element.
|
19 |
+
*
|
20 |
+
* @since BP Media 2.0
|
21 |
+
*/
|
22 |
+
function __construct($media_id = '') {
|
23 |
+
if (!$media_id == '') {
|
24 |
+
$this->init($media_id);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Initializes the object with the variables from the post
|
30 |
+
*
|
31 |
+
* @param mixed $media_id Media ID of the element to be initialized. Can be the ID or the object of the Media
|
32 |
+
*
|
33 |
+
* @since BP Media 2.0
|
34 |
+
*/
|
35 |
+
function init($media_id = '') {
|
36 |
+
if (is_object($media_id)) {
|
37 |
+
$media = $media_id;
|
38 |
+
} else {
|
39 |
+
$media = &get_post($media_id);
|
40 |
+
}
|
41 |
+
if (empty($media->ID))
|
42 |
+
throw new Exception(__('Sorry, the requested entry does not exist.', 'bp-media'));
|
43 |
+
$this->id = $media->ID;
|
44 |
+
$this->description = $media->post_content;
|
45 |
+
$this->name = $media->post_title;
|
46 |
+
$this->owner = $media->post_author;
|
47 |
+
$this->type = get_post_meta($media->ID, 'bp_media_type', true);
|
48 |
+
switch ($this->type) {
|
49 |
+
case 'video' :
|
50 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $this->id);
|
51 |
+
break;
|
52 |
+
case 'audio' :
|
53 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $this->id);
|
54 |
+
break;
|
55 |
+
case 'image' :
|
56 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $this->id);
|
57 |
+
break;
|
58 |
+
default :
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
$this->attachment_id = get_post_meta($this->id, 'bp_media_child_attachment', true);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Handles the uploaded media file and creates attachment post for the file.
|
66 |
+
*
|
67 |
+
* @since BP Media 2.0
|
68 |
+
*/
|
69 |
+
function add_media($name, $description) {
|
70 |
+
global $bp, $wpdb, $bp_media_count;
|
71 |
+
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
72 |
+
include_once(ABSPATH . 'wp-admin/includes/image.php');
|
73 |
+
//media_handle_upload('async-upload', $_REQUEST['post_id']);
|
74 |
+
$postarr = array(
|
75 |
+
'post_status' => 'draft',
|
76 |
+
'post_type' => 'bp_media',
|
77 |
+
'post_content' => $description,
|
78 |
+
'post_title' => $name
|
79 |
+
);
|
80 |
+
$post_id = wp_insert_post($postarr);
|
81 |
+
$file = wp_handle_upload($_FILES['bp_media_file']);
|
82 |
+
if (isset($file['error']) || $file === null) {
|
83 |
+
wp_delete_post($post_id, true);
|
84 |
+
throw new Exception(__('Error Uploading File', 'bp-media'));
|
85 |
+
}
|
86 |
+
$attachment = array();
|
87 |
+
$url = $file['url'];
|
88 |
+
$type = $file['type'];
|
89 |
+
$file = $file['file'];
|
90 |
+
$title = $name;
|
91 |
+
$content = $description;
|
92 |
+
$attachment = array(
|
93 |
+
'post_mime_type' => $type,
|
94 |
+
'guid' => $url,
|
95 |
+
'post_title' => $title,
|
96 |
+
'post_content' => $content,
|
97 |
+
'post_parent' => $post_id,
|
98 |
+
);
|
99 |
+
bp_media_init_count(bp_loggedin_user_id());
|
100 |
+
switch ($type) {
|
101 |
+
case 'video/mp4' :
|
102 |
+
$type = 'video';
|
103 |
+
include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/MP4Info.php');
|
104 |
+
try {
|
105 |
+
$vid_info = MP4Info::getInfo($file);
|
106 |
+
} catch (MP4Info_Exception $e) {
|
107 |
+
wp_delete_post($post_id, true);
|
108 |
+
unlink($file);
|
109 |
+
$activity_content = false;
|
110 |
+
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
|
111 |
+
} catch (Exception $e) {
|
112 |
+
wp_delete_post($post_id, true);
|
113 |
+
unlink($file);
|
114 |
+
$activity_content = false;
|
115 |
+
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
|
116 |
+
}
|
117 |
+
if (is_object($vid_info)) {
|
118 |
+
if (isset($vid_info->hasVideo) && $vid_info->hasVideo && isset($vid_info->video)) {
|
119 |
+
if (!(isset($vid_info->video->codecStr) && $vid_info->video->codecStr == 'H.264')) {
|
120 |
+
wp_delete_post($post_id, true);
|
121 |
+
unlink($file);
|
122 |
+
$activity_content = false;
|
123 |
+
throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
|
124 |
+
}
|
125 |
+
} else {
|
126 |
+
wp_delete_post($post_id, true);
|
127 |
+
unlink($file);
|
128 |
+
$activity_content = false;
|
129 |
+
throw new Exception(__('The MP4 file you have uploaded contains no video.', 'bp-media'));
|
130 |
+
}
|
131 |
+
} else {
|
132 |
+
wp_delete_post($post_id, true);
|
133 |
+
unlink($file);
|
134 |
+
$activity_content = false;
|
135 |
+
throw new Exception(__('The MP4 file you have uploaded is not a video file.', 'bp-media'));
|
136 |
+
}
|
137 |
+
$bp_media_count['videos'] = intval($bp_media_count['videos']) + 1;
|
138 |
+
break;
|
139 |
+
case 'audio/mpeg' :
|
140 |
+
$type = 'audio';
|
141 |
+
$bp_media_count['audio'] = intval($bp_media_count['audio']) + 1;
|
142 |
+
break;
|
143 |
+
case 'image/gif' :
|
144 |
+
case 'image/jpeg' :
|
145 |
+
case 'image/png' :
|
146 |
+
$type = 'image';
|
147 |
+
$bp_media_count['images'] = intval($bp_media_count['images']) + 1;
|
148 |
+
break;
|
149 |
+
default : unlink($file);
|
150 |
+
wp_delete_post($post_id, true);
|
151 |
+
unlink($file);
|
152 |
+
$activity_content = false;
|
153 |
+
throw new Exception(__('Media File you have tried to upload is not supported. Supported media files are .jpg, .png, .gif, .mp3 and .mp4.', 'bp-media'));
|
154 |
+
}
|
155 |
+
$attachment_id = wp_insert_attachment($attachment, $file, $post_id);
|
156 |
+
if (!is_wp_error($attachment_id)) {
|
157 |
+
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
|
158 |
+
} else {
|
159 |
+
wp_delete_post($post_id, true);
|
160 |
+
unlink($file);
|
161 |
+
throw new Exception(__('Error creating activity for the media file, please try again', 'bp-media'));
|
162 |
+
}
|
163 |
+
$postarr['ID'] = $post_id;
|
164 |
+
$postarr['post_mime_type'] = $type;
|
165 |
+
$postarr['post_status'] = 'publish';
|
166 |
+
wp_insert_post($postarr);
|
167 |
+
$activity_content = '[bp_media_content id="' . $post_id . '"]';
|
168 |
+
$activity_id = bp_media_record_activity(array(
|
169 |
+
'action' => '[bp_media_action id="' . $post_id . '"]',
|
170 |
+
'content' => $activity_content,
|
171 |
+
'primary_link' => '[bp_media_url id="' . $post_id . '"]',
|
172 |
+
'type' => 'media_upload'
|
173 |
+
));
|
174 |
+
bp_activity_update_meta($activity_id, 'bp_media_parent_post', $post_id);
|
175 |
+
update_post_meta($post_id, 'bp_media_child_activity', $activity_id);
|
176 |
+
update_post_meta($post_id, 'bp_media_child_attachment', $attachment_id);
|
177 |
+
update_post_meta($post_id, 'bp_media_type', $type);
|
178 |
+
update_post_meta($post_id, 'bp_media_hosting', 'wordpress');
|
179 |
+
$this->id = $post_id;
|
180 |
+
$this->name = $name;
|
181 |
+
$this->description = $description;
|
182 |
+
$this->owner = bp_loggedin_user_id();
|
183 |
+
$this->type = $type;
|
184 |
+
$this->url = $url;
|
185 |
+
bp_update_user_meta(bp_loggedin_user_id(), 'bp_media_count', $bp_media_count);
|
186 |
+
}
|
187 |
+
|
188 |
+
function get_media_activity_content() {
|
189 |
+
if (!bp_is_activity_component()) {
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
global $bp_media_counter, $bp_media_default_excerpts;
|
193 |
+
$attachment_id = get_post_meta($this->id, 'bp_media_child_attachment', true);
|
194 |
+
$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>';
|
195 |
+
$activity_content .='<div class="bp_media_content">';
|
196 |
+
switch ($this->type) {
|
197 |
+
case 'video' :
|
198 |
+
$activity_content.='<video src="' . wp_get_attachment_url($attachment_id) . '" width="320" height="240" type="video/mp4" id="bp_media_video_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none"></video></span><script>bp_media_create_element("bp_media_video_' . $this->id . '_' . $bp_media_counter . '");</script>';
|
199 |
+
break;
|
200 |
+
case 'audio' :
|
201 |
+
$activity_content.='<audio src="' . wp_get_attachment_url($attachment_id) . '" width="320" type="audio/mp3" id="bp_media_audio_' . $this->id . '_' . $bp_media_counter . '" controls="controls" preload="none" ></audio></span><script>bp_media_create_element("bp_media_audio_' . $this->id . '_' . $bp_media_counter . '");</script>';
|
202 |
+
$type = 'audio';
|
203 |
+
break;
|
204 |
+
case 'image' :
|
205 |
+
$image_array = image_downsize($attachment_id, 'bp_media_activity_image');
|
206 |
+
$activity_content.='<a href="' . $this->url . '" title="' . $this->name . '"><img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '_' . $bp_media_counter++ . '" alt="' . $this->name . '" /></a>';
|
207 |
+
$type = 'image';
|
208 |
+
break;
|
209 |
+
default :
|
210 |
+
return false;
|
211 |
+
}
|
212 |
+
$activity_content .= '</div>';
|
213 |
+
$activity_content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['activity_entry_description']) . '</div>';
|
214 |
+
return $activity_content;
|
215 |
+
}
|
216 |
+
|
217 |
+
function get_media_activity_url() {
|
218 |
+
if (!bp_is_activity_component())
|
219 |
+
return false;
|
220 |
+
$activity_url = $this->url;
|
221 |
+
return $activity_url;
|
222 |
+
}
|
223 |
+
|
224 |
+
function get_media_activity_action() {
|
225 |
+
if (!bp_is_activity_component())
|
226 |
+
return false;
|
227 |
+
$activity_action = sprintf(__("%s uploaded a media."), bp_core_get_userlink($this->owner));
|
228 |
+
return $activity_action;
|
229 |
+
}
|
230 |
+
|
231 |
+
function get_media_single_content() {
|
232 |
+
global $bp_media_default_sizes, $bp_media_default_excerpts;
|
233 |
+
|
234 |
+
$content = '<div class="bp_media_title">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['single_entry_title']) . '</div><div class="bp_media_content">';
|
235 |
+
switch ($this->type) {
|
236 |
+
case 'video' :
|
237 |
+
$content.='<video src="' . wp_get_attachment_url($this->attachment_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>';
|
238 |
+
break;
|
239 |
+
case 'audio' :
|
240 |
+
$content.='<audio src="' . wp_get_attachment_url($this->attachment_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>';
|
241 |
+
$type = 'audio';
|
242 |
+
break;
|
243 |
+
case 'image' :
|
244 |
+
$image_array = image_downsize($this->attachment_id, 'bp_media_single_image');
|
245 |
+
$content.='<img src="' . $image_array[0] . '" id="bp_media_image_' . $this->id . '" />';
|
246 |
+
$type = 'image';
|
247 |
+
break;
|
248 |
+
default :
|
249 |
+
return false;
|
250 |
+
}
|
251 |
+
$content .= '</div>';
|
252 |
+
$content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['single_entry_description']) . '</div>';
|
253 |
+
return $content;
|
254 |
+
}
|
255 |
+
|
256 |
+
function get_media_gallery_content() {
|
257 |
+
$attachment = get_post_meta($this->id, 'bp_media_child_attachment', true);
|
258 |
+
switch ($this->type) {
|
259 |
+
case 'video' :
|
260 |
+
?>
|
261 |
+
<li>
|
262 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
263 |
+
<img src="<?php echo plugins_url('img/video_thumb.png', __FILE__) ?>" />
|
264 |
+
</a>
|
265 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
266 |
+
</li>
|
267 |
+
<?php
|
268 |
+
break;
|
269 |
+
case 'audio' :
|
270 |
+
?>
|
271 |
+
<li>
|
272 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
273 |
+
<img src="<?php echo plugins_url('img/audio_thumb.png', __FILE__) ?>" />
|
274 |
+
</a>
|
275 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
276 |
+
</li>
|
277 |
+
<?php
|
278 |
+
break;
|
279 |
+
case 'image' :
|
280 |
+
$medium_array = image_downsize($attachment, 'thumbnail');
|
281 |
+
$medium_path = $medium_array[0];
|
282 |
+
?>
|
283 |
+
<li>
|
284 |
+
<a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>">
|
285 |
+
<img src="<?php echo $medium_path ?>" />
|
286 |
+
</a>
|
287 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php echo $this->description ?>"><?php echo $this->name ?></a></h3>
|
288 |
+
</li>
|
289 |
+
<?php
|
290 |
+
break;
|
291 |
+
default :
|
292 |
+
return false;
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
function show_comment_form() {
|
297 |
+
$activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
|
298 |
+
if (bp_has_activities(array(
|
299 |
+
'display_comments' => 'stream',
|
300 |
+
'include' => $activity_id,
|
301 |
+
'max' => 1
|
302 |
+
))) :
|
303 |
+
while (bp_activities()) : bp_the_activity();
|
304 |
+
do_action('bp_before_activity_entry');
|
305 |
+
?>
|
306 |
+
<div class="activity">
|
307 |
+
<ul id="activity-stream" class="activity-list item-list">
|
308 |
+
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
309 |
+
<div class="activity-content">
|
310 |
+
<?php do_action('bp_activity_entry_content'); ?>
|
311 |
+
<?php if (is_user_logged_in()) : ?>
|
312 |
+
<div class="activity-meta no-ajax">
|
313 |
+
<?php if (bp_activity_can_comment()) : ?>
|
314 |
+
<a href="<?php bp_get_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf(__('Comment <span>%s</span>', 'buddypress'), bp_activity_get_comment_count()); ?></a>
|
315 |
+
<?php endif; ?>
|
316 |
+
<?php if (bp_activity_can_favorite()) : ?>
|
317 |
+
<?php if (!bp_get_activity_is_favorite()) : ?>
|
318 |
+
<a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', 'buddypress'); ?>"><?php _e('Favorite', 'buddypress') ?></a>
|
319 |
+
<?php else : ?>
|
320 |
+
<a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', 'buddypress'); ?>"><?php _e('Remove Favorite', 'buddypress') ?></a>
|
321 |
+
<?php endif; ?>
|
322 |
+
<?php endif; ?>
|
323 |
+
<?php if (bp_activity_user_can_delete()) bp_activity_delete_link(); ?>
|
324 |
+
<?php do_action('bp_activity_entry_meta'); ?>
|
325 |
+
</div>
|
326 |
+
<?php endif; ?>
|
327 |
+
</div>
|
328 |
+
<?php do_action('bp_before_activity_entry_comments'); ?>
|
329 |
+
<?php if (( is_user_logged_in() && bp_activity_can_comment() ) || bp_activity_get_comment_count()) : ?>
|
330 |
+
<div class="activity-comments">
|
331 |
+
<?php bp_activity_comments(); ?>
|
332 |
+
<?php if (is_user_logged_in()) : ?>
|
333 |
+
<form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>>
|
334 |
+
<div class="ac-reply-avatar"><?php bp_loggedin_user_avatar('width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT); ?></div>
|
335 |
+
<div class="ac-reply-content">
|
336 |
+
<div class="ac-textarea">
|
337 |
+
<textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
|
338 |
+
</div>
|
339 |
+
<input type="submit" name="ac_form_submit" value="<?php _e('Post', 'buddypress'); ?>" /> <?php _e('or press esc to cancel.', 'buddypress'); ?>
|
340 |
+
<input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
|
341 |
+
</div>
|
342 |
+
<?php do_action('bp_activity_entry_comments'); ?>
|
343 |
+
<?php wp_nonce_field('new_activity_comment', '_wpnonce_new_activity_comment'); ?>
|
344 |
+
</form>
|
345 |
+
<?php endif; ?>
|
346 |
+
</div>
|
347 |
+
<?php endif; ?>
|
348 |
+
<?php do_action('bp_after_activity_entry_comments'); ?>
|
349 |
+
</li>
|
350 |
+
</ul>
|
351 |
+
</div>
|
352 |
+
<?php
|
353 |
+
endwhile;
|
354 |
+
endif;
|
355 |
+
}
|
356 |
+
|
357 |
+
function get_url() {
|
358 |
+
return $this->url;
|
359 |
+
}
|
360 |
+
|
361 |
+
function get_attachment_url(){
|
362 |
+
return wp_get_attachment_url($this->attachment_id);
|
363 |
+
}
|
364 |
+
}
|
365 |
+
?>
|
includes/bp-media-filters.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function bp_media_activity_permalink_filter($link, $activity_obj) {
|
3 |
+
if ('media_upload' == $activity_obj->type) {
|
4 |
+
add_shortcode('bp_media_url', 'bp_media_shortcode_url');
|
5 |
+
$link = do_shortcode($activity_obj->primary_link);
|
6 |
+
remove_shortcode('bp_media_url');
|
7 |
+
}
|
8 |
+
if ('activity_comment' == $activity_obj->type) {
|
9 |
+
$parent = bp_activity_get_meta($activity_obj->item_id, 'bp_media_parent_post');
|
10 |
+
if ($parent) {
|
11 |
+
$parent = new BP_Media_Host_Wordpress($parent);
|
12 |
+
$link = $parent->get_url();
|
13 |
+
}
|
14 |
+
}
|
15 |
+
return $link;
|
16 |
+
}
|
17 |
+
add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
|
18 |
+
|
19 |
+
function bp_media_activity_action_filter($activity_action, $activity_obj) {
|
20 |
+
if ('media_upload' == $activity_obj->type) {
|
21 |
+
add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
22 |
+
$activity_action = do_shortcode($activity_action);
|
23 |
+
remove_shortcode('bp_media_action');
|
24 |
+
}
|
25 |
+
return $activity_action;
|
26 |
+
}
|
27 |
+
add_filter('bp_get_activity_action', 'bp_media_activity_action_filter', 10, 2);
|
28 |
+
|
29 |
+
function bp_media_activity_content_filter($activity_content, $activity_obj) {
|
30 |
+
if ('media_upload' == $activity_obj->type) {
|
31 |
+
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
32 |
+
$activity_content = do_shortcode($activity_content);
|
33 |
+
remove_shortcode('bp_media_content');
|
34 |
+
}
|
35 |
+
return $activity_content;
|
36 |
+
}
|
37 |
+
add_filter('bp_get_activity_content_body', 'bp_media_activity_content_filter', 10, 2);
|
38 |
+
|
39 |
+
function bp_media_activity_parent_content_filter($content) {
|
40 |
+
add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
41 |
+
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
42 |
+
$content=do_shortcode($content);
|
43 |
+
remove_shortcode('bp_media_action');
|
44 |
+
remove_shortcode('bp_media_content');
|
45 |
+
return $content;
|
46 |
+
}
|
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')
|
52 |
+
$link=str_replace('class="button', 'class="button delete-activity-single"', $link);
|
53 |
+
return $link;
|
54 |
+
}
|
55 |
+
add_filter('bp_get_activity_delete_link','bp_media_delete_button_handler');
|
56 |
+
|
57 |
+
function bp_media_items_count_filter ($title,$nav_item) {
|
58 |
+
global $bp_media_count;
|
59 |
+
switch($nav_item['slug']){
|
60 |
+
case BP_MEDIA_SLUG :
|
61 |
+
$count= intval($bp_media_count['images'])+intval($bp_media_count['videos'])+intval($bp_media_count['audio']);
|
62 |
+
break;
|
63 |
+
case BP_MEDIA_IMAGES_SLUG:
|
64 |
+
$count= intval($bp_media_count['images']);
|
65 |
+
break;
|
66 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
67 |
+
$count= intval($bp_media_count['videos']);
|
68 |
+
break;
|
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 |
+
?>
|
includes/bp-media-functions.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function bp_media_record_activity($args = '') {
|
3 |
+
global $bp;
|
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 |
+
extract($r);
|
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 |
+
|
26 |
+
function bp_media_override_allowed_tags($activity_allowedtags) {
|
27 |
+
$activity_allowedtags['video'] = array();
|
28 |
+
$activity_allowedtags['video']['id'] = array();
|
29 |
+
$activity_allowedtags['video']['class'] = array();
|
30 |
+
$activity_allowedtags['video']['src'] = array();
|
31 |
+
$activity_allowedtags['video']['height'] = array();
|
32 |
+
$activity_allowedtags['video']['width'] = array();
|
33 |
+
$activity_allowedtags['video']['controls'] = array();
|
34 |
+
$activity_allowedtags['video']['preload'] = array();
|
35 |
+
$activity_allowedtags['video']['alt'] = array();
|
36 |
+
$activity_allowedtags['video']['title'] = array();
|
37 |
+
$activity_allowedtags['audio'] = array();
|
38 |
+
$activity_allowedtags['audio']['id'] = array();
|
39 |
+
$activity_allowedtags['audio']['class'] = array();
|
40 |
+
$activity_allowedtags['audio']['src'] = array();
|
41 |
+
$activity_allowedtags['audio']['controls'] = array();
|
42 |
+
$activity_allowedtags['audio']['preload'] = array();
|
43 |
+
$activity_allowedtags['audio']['alt'] = array();
|
44 |
+
$activity_allowedtags['audio']['title'] = array();
|
45 |
+
$activity_allowedtags['script'] = array();
|
46 |
+
$activity_allowedtags['script']['type'] = array();
|
47 |
+
$activity_allowedtags['div'] = array();
|
48 |
+
$activity_allowedtags['div']['id'] = array();
|
49 |
+
$activity_allowedtags['div']['class'] = array();
|
50 |
+
$activity_allowedtags['a'] = array();
|
51 |
+
$activity_allowedtags['a']['title'] = array();
|
52 |
+
$activity_allowedtags['a']['href'] = array();
|
53 |
+
return $activity_allowedtags;
|
54 |
+
}
|
55 |
+
|
56 |
+
function bp_media_show_formatted_error_message($messages, $type) {
|
57 |
+
echo '<div id="message" class="' . $type . '">';
|
58 |
+
if (is_array($messages)) {
|
59 |
+
foreach ($messages as $key => $message) {
|
60 |
+
if (is_string($message)) {
|
61 |
+
echo '<p>' . $message . '</p>';
|
62 |
+
}
|
63 |
+
}
|
64 |
+
} else {
|
65 |
+
if (is_string($messages)) {
|
66 |
+
echo '<p>' . $messages . '</p>';
|
67 |
+
}
|
68 |
+
}
|
69 |
+
echo '</div>';
|
70 |
+
}
|
71 |
+
|
72 |
+
function bp_media_conditional_override_allowed_tags($content, $activity) {
|
73 |
+
if ($activity->type == 'media_upload') {
|
74 |
+
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
|
75 |
+
}
|
76 |
+
return bp_activity_filter_kses($content);
|
77 |
+
}
|
78 |
+
|
79 |
+
function bp_media_swap_filters() {
|
80 |
+
add_filter('bp_get_activity_content_body', 'bp_media_conditional_override_allowed_tags', 1, 2);
|
81 |
+
remove_filter('bp_get_activity_content_body', 'bp_activity_filter_kses', 1);
|
82 |
+
}
|
83 |
+
add_action('bp_init', 'bp_media_swap_filters');
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Updates the media count of all users.
|
87 |
+
*/
|
88 |
+
function bp_media_update_count() {
|
89 |
+
global $wpdb;
|
90 |
+
$query = "SELECT COUNT(*) AS total,b.meta_value AS type,a.post_author
|
91 |
+
FROM $wpdb->posts AS a,$wpdb->postmeta AS b
|
92 |
+
WHERE (a.id = b.post_id) AND a.post_type='bp_media' AND b.meta_key='bp_media_type'
|
93 |
+
GROUP BY b.meta_value,a.post_author";
|
94 |
+
$result = $wpdb->get_results($query);
|
95 |
+
$users_count = array();
|
96 |
+
foreach ($result as $obj) {
|
97 |
+
$users_count[$obj->post_author][$obj->type] = $obj->total;
|
98 |
+
}
|
99 |
+
$users = get_users();
|
100 |
+
foreach ($users as $user) {
|
101 |
+
if (array_key_exists($user->ID, $users_count)) {
|
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 |
+
} else {
|
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 |
+
?>
|
includes/bp-media-loader.php
ADDED
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Main loader file of BuddyPress Media Component Plugin
|
4 |
+
*/
|
5 |
+
/* Exit if accessed directlly. */
|
6 |
+
if (!defined('ABSPATH'))
|
7 |
+
exit;
|
8 |
+
|
9 |
+
/* Slug Constants */
|
10 |
+
define('BP_MEDIA_SLUG', 'media');
|
11 |
+
define('BP_MEDIA_UPLOAD_SLUG', 'upload');
|
12 |
+
|
13 |
+
define('BP_MEDIA_IMAGES_SLUG', 'images');
|
14 |
+
define('BP_MEDIA_IMAGES_ENTRY_SLUG', 'view');
|
15 |
+
define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit');
|
16 |
+
|
17 |
+
define('BP_MEDIA_VIDEOS_SLUG', 'videos');
|
18 |
+
define('BP_MEDIA_VIDEOS_ENTRY_SLUG', 'watch');
|
19 |
+
define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit');
|
20 |
+
|
21 |
+
define('BP_MEDIA_AUDIO_SLUG', 'audio');
|
22 |
+
define('BP_MEDIA_AUDIO_ENTRY_SLUG', 'listen');
|
23 |
+
define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit');
|
24 |
+
|
25 |
+
/* Label Constants(need to be translatable) */
|
26 |
+
define('BP_MEDIA_LABEL', __('Media', 'bp-media'));
|
27 |
+
define('BP_MEDIA_LABEL_SINGULAR', __('Media', 'bp-media'));
|
28 |
+
define('BP_MEDIA_IMAGES_LABEL', __('Images', 'bp-media'));
|
29 |
+
define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('Image', 'bp-media'));
|
30 |
+
define('BP_MEDIA_VIDEOS_LABEL', __('Videos', 'bp-media'));
|
31 |
+
define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', 'bp-media'));
|
32 |
+
define('BP_MEDIA_AUDIO_LABEL', __('Audio', 'bp-media'));
|
33 |
+
define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('Audio', 'bp-media'));
|
34 |
+
define('BP_MEDIA_UPLOAD_LABEL', __('Upload', 'bp-media'));
|
35 |
+
|
36 |
+
/* Global variable to store the query */
|
37 |
+
global $bp_media_query;
|
38 |
+
|
39 |
+
/* Global variable for making distinct ids for different media objects in activity stream */
|
40 |
+
global $bp_media_counter;
|
41 |
+
$bp_media_counter = 0;
|
42 |
+
|
43 |
+
/* Global variable storing the count of the media files displayed user has */
|
44 |
+
global $bp_media_count;
|
45 |
+
$bp_media_count=null;
|
46 |
+
|
47 |
+
/* Global variable for various display sizes */
|
48 |
+
global $bp_media_default_sizes;
|
49 |
+
$bp_media_default_sizes = array(
|
50 |
+
'activity_image' => array(
|
51 |
+
'width' => 320,
|
52 |
+
'height' => 240
|
53 |
+
),
|
54 |
+
'activity_video' => array(
|
55 |
+
'width' => 320,
|
56 |
+
'height' => 240
|
57 |
+
),
|
58 |
+
'activity_audio' => array(
|
59 |
+
'width' => 320,
|
60 |
+
),
|
61 |
+
'single_image' => array(
|
62 |
+
'width' => 800,
|
63 |
+
'height' => 0
|
64 |
+
),
|
65 |
+
'single_video' => array(
|
66 |
+
'width' => 640,
|
67 |
+
'height' => 480
|
68 |
+
),
|
69 |
+
'single_audio' => array(
|
70 |
+
'width' => 640,
|
71 |
+
),
|
72 |
+
);
|
73 |
+
|
74 |
+
/* Global variable to store various excerpt sizes */
|
75 |
+
global $bp_media_default_excerpts;
|
76 |
+
$bp_media_default_excerpts=array(
|
77 |
+
'single_entry_title' => 100,
|
78 |
+
'single_entry_description' => 500,
|
79 |
+
'activity_entry_title' => 50,
|
80 |
+
'activity_entry_description'=> 500
|
81 |
+
);
|
82 |
+
|
83 |
+
/* To set the language according to the locale selected and availability of the language file. */
|
84 |
+
if (file_exists(BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo'))
|
85 |
+
load_textdomain('bp-media', BP_MEDIA_PLUGIN_DIR . '/languages/' . get_locale() . '.mo');
|
86 |
+
|
87 |
+
/**
|
88 |
+
* BP Media Component Class, extends BP_Component
|
89 |
+
*
|
90 |
+
* @see BP_Component
|
91 |
+
*
|
92 |
+
* @since BP Media 2.0
|
93 |
+
*/
|
94 |
+
class BP_Media_Component extends BP_Component {
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Hold the messages generated during initialization process and will be shown on the screen functions
|
98 |
+
*
|
99 |
+
* @since BP Media 2.0
|
100 |
+
*/
|
101 |
+
var $messages = array(
|
102 |
+
'error' => array(),
|
103 |
+
'info' => array(),
|
104 |
+
'updated' => array()
|
105 |
+
);
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Constructor for the BuddyPress Media Component
|
109 |
+
*
|
110 |
+
* @since BP Media 2.0
|
111 |
+
*/
|
112 |
+
function __construct() {
|
113 |
+
global $bp;
|
114 |
+
parent::start(BP_MEDIA_SLUG, BP_MEDIA_LABEL, BP_MEDIA_PLUGIN_DIR);
|
115 |
+
$this->includes();
|
116 |
+
$bp->active_components[$this->id] = '1';
|
117 |
+
add_action('init', array(&$this, 'register_post_types'));
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Includes the files required for the BuddyPress Media Component and calls the parent class' includes function
|
122 |
+
*
|
123 |
+
* @since BP Media 2.0
|
124 |
+
*/
|
125 |
+
function includes() {
|
126 |
+
$includes = array(
|
127 |
+
'includes/bp-media-screens.php',
|
128 |
+
'includes/bp-media-functions.php',
|
129 |
+
'includes/bp-media-filters.php',
|
130 |
+
'includes/bp-media-template-functions.php',
|
131 |
+
'includes/bp-media-actions.php',
|
132 |
+
'includes/bp-media-interface.php',
|
133 |
+
'includes/bp-media-class-wordpress.php',
|
134 |
+
'includes/bp-media-shortcodes.php'
|
135 |
+
);
|
136 |
+
if (is_admin() || is_network_admin()) {
|
137 |
+
$includes[] = 'includes/bp-media-admin.php';
|
138 |
+
}
|
139 |
+
parent::includes($includes);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Initializes the global variables of the BuddyPress Media component and its parent class.
|
144 |
+
*/
|
145 |
+
function setup_globals() {
|
146 |
+
global $bp;
|
147 |
+
$globals = array(
|
148 |
+
'slug' => BP_MEDIA_SLUG,
|
149 |
+
'root_slug' => isset($bp->pages->{$this->id}->slug) ? $bp->pages->{$this->id}->slug : BP_MEDIA_SLUG,
|
150 |
+
/*'has_directory' => true, /* Set to false if not required */
|
151 |
+
'search_string' => __('Search Media...', 'bp-media'),
|
152 |
+
);
|
153 |
+
parent::setup_globals($globals);
|
154 |
+
}
|
155 |
+
|
156 |
+
function setup_nav() {
|
157 |
+
/* Add 'Media' to the main navigation */
|
158 |
+
if (bp_is_my_profile()) {
|
159 |
+
$main_nav = array(
|
160 |
+
'name' => BP_MEDIA_LABEL,
|
161 |
+
'slug' => BP_MEDIA_SLUG,
|
162 |
+
'position' => 80,
|
163 |
+
'screen_function' => 'bp_media_upload_screen',
|
164 |
+
'default_subnav_slug' => BP_MEDIA_UPLOAD_SLUG
|
165 |
+
);
|
166 |
+
} else {
|
167 |
+
$main_nav = array(
|
168 |
+
'name' => BP_MEDIA_LABEL,
|
169 |
+
'slug' => BP_MEDIA_SLUG,
|
170 |
+
'position' => 80,
|
171 |
+
'screen_function' => 'bp_media_images_screen',
|
172 |
+
'default_subnav_slug' => BP_MEDIA_IMAGES_SLUG
|
173 |
+
);
|
174 |
+
}
|
175 |
+
$sub_nav[] = array(
|
176 |
+
'name' => BP_MEDIA_UPLOAD_LABEL,
|
177 |
+
'slug' => BP_MEDIA_UPLOAD_SLUG,
|
178 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_SLUG),
|
179 |
+
'parent_slug' => BP_MEDIA_SLUG,
|
180 |
+
'screen_function' => 'bp_media_upload_screen',
|
181 |
+
'position' => 10,
|
182 |
+
'user_has_access' => bp_is_my_profile()
|
183 |
+
);
|
184 |
+
parent::setup_nav($main_nav, $sub_nav);
|
185 |
+
|
186 |
+
bp_core_new_nav_item(array(
|
187 |
+
'name' => BP_MEDIA_IMAGES_LABEL,
|
188 |
+
'slug' => BP_MEDIA_IMAGES_SLUG,
|
189 |
+
'screen_function' => 'bp_media_images_screen'
|
190 |
+
));
|
191 |
+
|
192 |
+
bp_core_new_nav_item(array(
|
193 |
+
'name' => BP_MEDIA_VIDEOS_LABEL,
|
194 |
+
'slug' => BP_MEDIA_VIDEOS_SLUG,
|
195 |
+
'screen_function' => 'bp_media_videos_screen'
|
196 |
+
));
|
197 |
+
|
198 |
+
bp_core_new_nav_item(array(
|
199 |
+
'name' => BP_MEDIA_AUDIO_LABEL,
|
200 |
+
'slug' => BP_MEDIA_AUDIO_SLUG,
|
201 |
+
'screen_function' => 'bp_media_audio_screen'
|
202 |
+
));
|
203 |
+
|
204 |
+
bp_core_new_subnav_item(array(
|
205 |
+
'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
|
206 |
+
'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
|
207 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
208 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
209 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
210 |
+
'screen_function' => 'bp_media_audio_screen', /* The name of the function to run when clicked */
|
211 |
+
));
|
212 |
+
|
213 |
+
bp_core_new_subnav_item(array(
|
214 |
+
'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
|
215 |
+
'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
|
216 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
217 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
218 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
219 |
+
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
220 |
+
));
|
221 |
+
|
222 |
+
bp_core_new_subnav_item(array(
|
223 |
+
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
224 |
+
'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
|
225 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
226 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
227 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
228 |
+
'screen_function' => 'bp_media_images_screen', /* The name of the function to run when clicked */
|
229 |
+
));
|
230 |
+
|
231 |
+
bp_core_new_subnav_item(array(
|
232 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
233 |
+
'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
|
234 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
235 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
236 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
237 |
+
'screen_function' => 'bp_media_images_edit_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_AUDIO_EDIT_SLUG, /* URL slug for the nav item */
|
243 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
244 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
245 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
246 |
+
'screen_function' => 'bp_media_audio_edit_screen', /* The name of the function to run when clicked */
|
247 |
+
));
|
248 |
+
|
249 |
+
bp_core_new_subnav_item(array(
|
250 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
251 |
+
'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
|
252 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
253 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
254 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
255 |
+
'screen_function' => 'bp_media_videos_edit_screen', /* The name of the function to run when clicked */
|
256 |
+
));
|
257 |
+
|
258 |
+
bp_core_new_subnav_item(array(
|
259 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
260 |
+
'slug' => 'page', /* URL slug for the nav item */
|
261 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
262 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent 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' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
269 |
+
'slug' => 'page', /* URL slug for the nav item */
|
270 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
271 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
272 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
273 |
+
'screen_function' => 'bp_media_audio_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_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
280 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
281 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
282 |
+
'screen_function' => 'bp_media_videos_screen', /* The name of the function to run when clicked */
|
283 |
+
));
|
284 |
+
}
|
285 |
+
|
286 |
+
function register_post_types() {
|
287 |
+
/* Set up labels for the post type */
|
288 |
+
$labels = array(
|
289 |
+
'name' => __('Media', 'bp-media'),
|
290 |
+
'singular' => __('Media', 'bp-media'),
|
291 |
+
'add_new' => __('Add New Media', 'bp-media')
|
292 |
+
);
|
293 |
+
|
294 |
+
/* Set up the argument array for register_post_type() */
|
295 |
+
$args = array(
|
296 |
+
'label' => __('Media', 'bp-media'),
|
297 |
+
'labels' => $labels,
|
298 |
+
'description' => 'BuddyPress Media Component\'s Media Files',
|
299 |
+
'public' => true,
|
300 |
+
'show_ui' => false,
|
301 |
+
'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields')
|
302 |
+
);
|
303 |
+
register_post_type('bp_media', $args);
|
304 |
+
parent::register_post_types();
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
function bp_media_load_core_component() {
|
309 |
+
global $bp;
|
310 |
+
|
311 |
+
$bp->{BP_MEDIA_SLUG} = new BP_Media_Component();
|
312 |
+
}
|
313 |
+
add_action('bp_loaded', 'bp_media_load_core_component');
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Function to set the custom navigation system in effect.
|
317 |
+
*/
|
318 |
+
function bp_media_custom_nav() {
|
319 |
+
global $bp;
|
320 |
+
foreach ($bp->bp_nav as $key => $nav_item) {
|
321 |
+
if ($nav_item['slug'] == BP_MEDIA_IMAGES_SLUG || $nav_item['slug'] == BP_MEDIA_VIDEOS_SLUG || $nav_item['slug'] == BP_MEDIA_AUDIO_SLUG) {
|
322 |
+
$bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
|
323 |
+
'name' => $nav_item['name'],
|
324 |
+
'link' => (isset($bp->displayed_user->domain) ? $bp->displayed_user->domain : (isset($bp->loggedin_user->domain) ? $bp->loggedin_user->domain : '')) . $nav_item['slug'] . '/',
|
325 |
+
'slug' => $nav_item['slug'],
|
326 |
+
'css_id' => $nav_item['css_id'],
|
327 |
+
'position' => $nav_item['position'],
|
328 |
+
'screen_function' => $nav_item['screen_function'],
|
329 |
+
'user_has_access' => true,
|
330 |
+
'parent_url' => trailingslashit(bp_displayed_user_domain())
|
331 |
+
);
|
332 |
+
unset($bp->bp_nav[$key]);
|
333 |
+
}
|
334 |
+
}
|
335 |
+
if ($bp->current_component == BP_MEDIA_IMAGES_SLUG || $bp->current_component == BP_MEDIA_VIDEOS_SLUG || $bp->current_component == BP_MEDIA_AUDIO_SLUG) {
|
336 |
+
$count = count($bp->action_variables);
|
337 |
+
for ($i = $count; $i > 0; $i--) {
|
338 |
+
$bp->action_variables[$i] = $bp->action_variables[$i - 1];
|
339 |
+
}
|
340 |
+
$bp->action_variables[0] = $bp->current_action;
|
341 |
+
$bp->current_action = $bp->current_component;
|
342 |
+
$bp->current_component = BP_MEDIA_SLUG;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
add_action('bp_setup_nav', 'bp_media_custom_nav', 999);
|
346 |
+
|
347 |
+
function bp_media_thumbnail() {
|
348 |
+
global $bp_media_default_sizes;
|
349 |
+
add_image_size('bp_media_activity_image', $bp_media_default_sizes['activity_image']['width'], $bp_media_default_sizes['activity_image']['height'], true);
|
350 |
+
add_image_size('bp_media_single_image', $bp_media_default_sizes['single_image']['width'], $bp_media_default_sizes['single_image']['height'], true);
|
351 |
+
}
|
352 |
+
add_action('after_setup_theme', 'bp_media_thumbnail');
|
353 |
+
?>
|
includes/bp-media-screens.php
ADDED
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Screens for all the slugs defined in the BuddyPress Media Component
|
5 |
+
*/
|
6 |
+
|
7 |
+
/* Exit if accessed directlly. */
|
8 |
+
if (!defined('ABSPATH'))
|
9 |
+
exit;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Screen function for Upload page
|
13 |
+
*/
|
14 |
+
function bp_media_upload_screen() {
|
15 |
+
add_action('bp_template_title', 'bp_media_upload_screen_title');
|
16 |
+
add_action('bp_template_content', 'bp_media_upload_screen_content');
|
17 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
18 |
+
}
|
19 |
+
|
20 |
+
function bp_media_upload_screen_title() {
|
21 |
+
_e('Upload Page');
|
22 |
+
}
|
23 |
+
|
24 |
+
function bp_media_upload_screen_content() {
|
25 |
+
do_action('bp_media_before_content');
|
26 |
+
bp_media_show_upload_form();
|
27 |
+
do_action('bp_media_after_content');
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Screen function for Images listing page (Default)
|
32 |
+
*/
|
33 |
+
function bp_media_images_screen() {
|
34 |
+
global $bp;
|
35 |
+
if (isset($bp->action_variables[0])) {
|
36 |
+
switch ($bp->action_variables[0]) {
|
37 |
+
case BP_MEDIA_IMAGES_EDIT_SLUG :
|
38 |
+
bp_media_images_edit_screen();
|
39 |
+
break;
|
40 |
+
case BP_MEDIA_IMAGES_ENTRY_SLUG:
|
41 |
+
global $bp_media_current_entry;
|
42 |
+
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
43 |
+
return false;
|
44 |
+
try {
|
45 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
|
46 |
+
} catch (Exception $e) {
|
47 |
+
/* Send the values to the cookie for page reload display */
|
48 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
49 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
50 |
+
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG));
|
51 |
+
exit;
|
52 |
+
}
|
53 |
+
add_action('bp_template_content', 'bp_media_images_entry_screen_content');
|
54 |
+
break;
|
55 |
+
default:
|
56 |
+
bp_media_set_query();
|
57 |
+
add_action('bp_template_content', 'bp_media_images_screen_content');
|
58 |
+
}
|
59 |
+
} else {
|
60 |
+
bp_media_set_query();
|
61 |
+
add_action('bp_template_content', 'bp_media_images_screen_content');
|
62 |
+
}
|
63 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
64 |
+
}
|
65 |
+
|
66 |
+
function bp_media_images_screen_title() {
|
67 |
+
_e('Images List Page');
|
68 |
+
}
|
69 |
+
|
70 |
+
function bp_media_images_screen_content() {
|
71 |
+
global $bp_media_query;
|
72 |
+
if ($bp_media_query && $bp_media_query->have_posts()):
|
73 |
+
bp_media_show_pagination();
|
74 |
+
do_action('bp_media_before_content');
|
75 |
+
echo '<ul id="groups-list" class="bp-media-gallery item-list">';
|
76 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
77 |
+
bp_media_the_content();
|
78 |
+
endwhile;
|
79 |
+
echo '</ul>';
|
80 |
+
do_action('bp_media_after_content');
|
81 |
+
bp_media_show_pagination('bottom');
|
82 |
+
else:
|
83 |
+
bp_media_show_formatted_error_message(__('Sorry, no images were found.', 'bp-media'), 'info');
|
84 |
+
endif;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Screen function for Images Edit page
|
89 |
+
*/
|
90 |
+
function bp_media_images_edit_screen() {
|
91 |
+
if (bp_loggedin_user_id() != bp_displayed_user_id()) {
|
92 |
+
bp_core_no_access(array(
|
93 |
+
'message' => __('You do not have access to this page.', 'buddypress'),
|
94 |
+
'root' => bp_displayed_user_domain(),
|
95 |
+
'redirect' => false
|
96 |
+
));
|
97 |
+
exit;
|
98 |
+
}
|
99 |
+
add_action('bp_template_title', 'bp_media_images_edit_screen_title');
|
100 |
+
add_action('bp_template_content', 'bp_media_images_edit_screen_content');
|
101 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
102 |
+
}
|
103 |
+
|
104 |
+
function bp_media_images_edit_screen_title() {
|
105 |
+
_e('Images Edit Page');
|
106 |
+
}
|
107 |
+
|
108 |
+
function bp_media_images_edit_screen_content() {
|
109 |
+
global $bp;
|
110 |
+
_e('Images Edit Page Content');
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Screen function for Images Entry page
|
115 |
+
*/
|
116 |
+
function bp_media_images_entry_screen() {
|
117 |
+
add_action('bp_template_title', 'bp_media_images_entry_screen_title');
|
118 |
+
add_action('bp_template_content', 'bp_media_images_entry_screen_content');
|
119 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
120 |
+
}
|
121 |
+
|
122 |
+
function bp_media_images_entry_screen_title() {
|
123 |
+
_e('Images Entry Page');
|
124 |
+
}
|
125 |
+
|
126 |
+
function bp_media_images_entry_screen_content() {
|
127 |
+
global $bp, $bp_media_current_entry;
|
128 |
+
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
129 |
+
return false;
|
130 |
+
do_action('bp_media_before_content');
|
131 |
+
echo '<div class="bp-media-single bp-media-image">';
|
132 |
+
echo $bp_media_current_entry->get_media_single_content();
|
133 |
+
echo $bp_media_current_entry->show_comment_form();
|
134 |
+
echo '</div>';
|
135 |
+
do_action('bp_media_after_content');
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Screen function for Videos listing page (Default)
|
140 |
+
*/
|
141 |
+
function bp_media_videos_screen() {
|
142 |
+
global $bp;
|
143 |
+
if (isset($bp->action_variables[0])) {
|
144 |
+
switch ($bp->action_variables[0]) {
|
145 |
+
case BP_MEDIA_VIDEOS_EDIT_SLUG :
|
146 |
+
add_action('bp_template_content', 'bp_media_videos_edit_screen_content');
|
147 |
+
break;
|
148 |
+
case BP_MEDIA_VIDEOS_ENTRY_SLUG:
|
149 |
+
global $bp_media_current_entry;
|
150 |
+
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
151 |
+
return false;
|
152 |
+
try {
|
153 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
|
154 |
+
} catch (Exception $e) {
|
155 |
+
/* Send the values to the cookie for page reload display */
|
156 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
157 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
158 |
+
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG));
|
159 |
+
exit;
|
160 |
+
}
|
161 |
+
add_action('bp_template_content', 'bp_media_videos_entry_screen_content');
|
162 |
+
break;
|
163 |
+
default:
|
164 |
+
bp_media_set_query();
|
165 |
+
add_action('bp_template_content', 'bp_media_videos_screen_content');
|
166 |
+
}
|
167 |
+
} else {
|
168 |
+
bp_media_set_query();
|
169 |
+
add_action('bp_template_content', 'bp_media_videos_screen_content');
|
170 |
+
}
|
171 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
172 |
+
}
|
173 |
+
|
174 |
+
function bp_media_videos_screen_title() {
|
175 |
+
_e('Videos List Page');
|
176 |
+
}
|
177 |
+
|
178 |
+
function bp_media_videos_screen_content() {
|
179 |
+
global $bp_media_query;
|
180 |
+
if ($bp_media_query && $bp_media_query->have_posts()):
|
181 |
+
bp_media_show_pagination();
|
182 |
+
do_action('bp_media_before_content');
|
183 |
+
echo '<ul class="bp-media-gallery">';
|
184 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
185 |
+
bp_media_the_content();
|
186 |
+
endwhile;
|
187 |
+
echo '</ul>';
|
188 |
+
do_action('bp_media_after_content');
|
189 |
+
bp_media_show_pagination('bottom');
|
190 |
+
else:
|
191 |
+
bp_media_show_formatted_error_message(__('Sorry, no videos were found.', 'bp-media'), 'info');
|
192 |
+
endif;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Screen function for Videos Edit page
|
197 |
+
*/
|
198 |
+
function bp_media_videos_edit_screen() {
|
199 |
+
add_action('bp_template_title', 'bp_media_videos_edit_screen_title');
|
200 |
+
add_action('bp_template_content', 'bp_media_videos_edit_screen_content');
|
201 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
202 |
+
}
|
203 |
+
|
204 |
+
function bp_media_videos_edit_screen_title() {
|
205 |
+
_e('Videos Edit Page');
|
206 |
+
}
|
207 |
+
|
208 |
+
function bp_media_videos_edit_screen_content() {
|
209 |
+
global $bp;
|
210 |
+
_e('Videos Edit Page Content');
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Screen function for Videos Entry page
|
215 |
+
*/
|
216 |
+
function bp_media_videos_entry_screen() {
|
217 |
+
add_action('bp_template_title', 'bp_media_videos_entry_screen_title');
|
218 |
+
add_action('bp_template_content', 'bp_media_videos_entry_screen_content');
|
219 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
220 |
+
}
|
221 |
+
|
222 |
+
function bp_media_videos_entry_screen_title() {
|
223 |
+
_e('Videos Entry Page');
|
224 |
+
}
|
225 |
+
|
226 |
+
function bp_media_videos_entry_screen_content() {
|
227 |
+
global $bp, $bp_media_current_entry;
|
228 |
+
if (!$bp->action_variables[0] == BP_MEDIA_VIDEOS_ENTRY_SLUG)
|
229 |
+
return false;
|
230 |
+
do_action('bp_media_before_content');
|
231 |
+
echo '<div class="bp-media-single bp-media-video">';
|
232 |
+
echo $bp_media_current_entry->get_media_single_content();
|
233 |
+
echo $bp_media_current_entry->show_comment_form();
|
234 |
+
echo '</div>';
|
235 |
+
do_action('bp_media_after_content');
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Screen function for Audio listing page (Default)
|
240 |
+
*/
|
241 |
+
function bp_media_audio_screen() {
|
242 |
+
global $bp;
|
243 |
+
if (isset($bp->action_variables[0])) {
|
244 |
+
switch ($bp->action_variables[0]) {
|
245 |
+
case BP_MEDIA_AUDIO_EDIT_SLUG :
|
246 |
+
add_action('bp_template_content', 'bp_media_audio_edit_screen_content');
|
247 |
+
break;
|
248 |
+
case BP_MEDIA_AUDIO_ENTRY_SLUG:
|
249 |
+
global $bp_media_current_entry;
|
250 |
+
if (!$bp->action_variables[0] == BP_MEDIA_IMAGES_ENTRY_SLUG)
|
251 |
+
return false;
|
252 |
+
try {
|
253 |
+
$bp_media_current_entry = new BP_Media_Host_Wordpress($bp->action_variables[1]);
|
254 |
+
} catch (Exception $e) {
|
255 |
+
/* Send the values to the cookie for page reload display */
|
256 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
257 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
258 |
+
wp_redirect(trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG));
|
259 |
+
exit;
|
260 |
+
}
|
261 |
+
add_action('bp_template_content', 'bp_media_audio_entry_screen_content');
|
262 |
+
break;
|
263 |
+
default:
|
264 |
+
bp_media_set_query();
|
265 |
+
add_action('bp_template_content', 'bp_media_audio_screen_content');
|
266 |
+
}
|
267 |
+
} else {
|
268 |
+
bp_media_set_query();
|
269 |
+
add_action('bp_template_content', 'bp_media_audio_screen_content');
|
270 |
+
}
|
271 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
272 |
+
}
|
273 |
+
|
274 |
+
function bp_media_audio_screen_title() {
|
275 |
+
_e('Audio List Page');
|
276 |
+
}
|
277 |
+
|
278 |
+
function bp_media_audio_screen_content() {
|
279 |
+
global $bp_media_query;
|
280 |
+
if ($bp_media_query && $bp_media_query->have_posts()):
|
281 |
+
bp_media_show_pagination();
|
282 |
+
do_action('bp_media_before_content');
|
283 |
+
echo '<ul class="bp-media-gallery">';
|
284 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
285 |
+
bp_media_the_content();
|
286 |
+
endwhile;
|
287 |
+
echo '</ul>';
|
288 |
+
do_action('bp_media_after_content');
|
289 |
+
bp_media_show_pagination('bottom');
|
290 |
+
else:
|
291 |
+
bp_media_show_formatted_error_message(__('Sorry, no audio files were found.', 'bp-media'), 'info');
|
292 |
+
endif;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Screen function for Audio Edit page
|
297 |
+
*/
|
298 |
+
function bp_media_audio_edit_screen() {
|
299 |
+
add_action('bp_template_title', 'bp_media_audio_edit_screen_title');
|
300 |
+
add_action('bp_template_content', 'bp_media_audio_edit_screen_content');
|
301 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
302 |
+
}
|
303 |
+
|
304 |
+
function bp_media_audio_edit_screen_title() {
|
305 |
+
_e('Audio Edit Page');
|
306 |
+
}
|
307 |
+
|
308 |
+
function bp_media_audio_edit_screen_content() {
|
309 |
+
global $bp;
|
310 |
+
_e('Audio Edit Page Content');
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Screen function for Audio Entry page
|
315 |
+
*/
|
316 |
+
function bp_media_audio_entry_screen() {
|
317 |
+
add_action('bp_template_title', 'bp_media_audio_entry_screen_title');
|
318 |
+
add_action('bp_template_content', 'bp_media_audio_entry_screen_content');
|
319 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
320 |
+
}
|
321 |
+
|
322 |
+
function bp_media_audio_entry_screen_title() {
|
323 |
+
_e('Audio Entry Page');
|
324 |
+
}
|
325 |
+
|
326 |
+
function bp_media_audio_entry_screen_content() {
|
327 |
+
global $bp, $bp_media_current_entry;
|
328 |
+
if (!$bp->action_variables[0] == BP_MEDIA_AUDIO_ENTRY_SLUG)
|
329 |
+
return false;
|
330 |
+
do_action('bp_media_before_content');
|
331 |
+
echo '<div class="bp-media-single bp-media-audio">';
|
332 |
+
echo $bp_media_current_entry->get_media_single_content();
|
333 |
+
echo $bp_media_current_entry->show_comment_form();
|
334 |
+
echo '</div>';
|
335 |
+
do_action('bp_media_after_content');
|
336 |
+
}
|
337 |
+
?>
|
includes/bp-media-shortcodes.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Shortcode for generating the action of the activity
|
5 |
+
*/
|
6 |
+
function bp_media_shortcode_action($atts) {
|
7 |
+
extract(shortcode_atts(array(
|
8 |
+
'id' => '0'
|
9 |
+
), $atts)
|
10 |
+
);
|
11 |
+
$media=new BP_Media_Host_Wordpress($id);
|
12 |
+
return $media->get_media_activity_action();
|
13 |
+
}
|
14 |
+
//add_shortcode('bp_media_action', 'bp_media_shortcode_action');
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Shortcode for generationg the content of the activity
|
18 |
+
*/
|
19 |
+
function bp_media_shortcode_content($atts) {
|
20 |
+
extract(shortcode_atts(array(
|
21 |
+
'id' => '0'
|
22 |
+
), $atts)
|
23 |
+
);
|
24 |
+
$media=new BP_Media_Host_Wordpress($id);
|
25 |
+
return $media->get_media_activity_content();
|
26 |
+
}
|
27 |
+
//add_shortcode('bp_media_content', 'bp_media_shortcode_content');
|
28 |
+
|
29 |
+
function bp_media_shortcode_url($atts) {
|
30 |
+
extract(shortcode_atts(array(
|
31 |
+
'id' => '0'
|
32 |
+
), $atts)
|
33 |
+
);
|
34 |
+
$media=new BP_Media_Host_Wordpress($id);
|
35 |
+
return $media->get_media_activity_url();
|
36 |
+
}
|
37 |
+
//add_shortcode('bp_media_url','bp_media_shortcode_url');
|
38 |
+
?>
|
includes/bp-media-template-functions.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
function bp_media_show_upload_form() {
|
3 |
+
global $bp,$bp_media_default_excerpts;
|
4 |
+
?>
|
5 |
+
<form method="post" enctype="multipart/form-data" class="standard-form" id="bp-media-upload-form">
|
6 |
+
<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'])) ?>" />
|
7 |
+
<label for="bp-media-upload-input-description"><?php _e('Media 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'])) ?>" />
|
8 |
+
<label for="bp-media-upload-file"><?php _e('Select Media File', 'bp-media') ?> (Max File Size:<?php echo min(array(ini_get('upload_max_filesize'),ini_get('post_max_size'))); ?>)</label><input type="file" name="bp_media_file" id="bp-media-upload-file" />
|
9 |
+
<input type="hidden" name="action" value="wp_handle_upload" />
|
10 |
+
<div class="submit"><input type="submit" class="auto" value="Upload" /></div>
|
11 |
+
</form>
|
12 |
+
<?php
|
13 |
+
}
|
14 |
+
|
15 |
+
function bp_media_show_pagination($type = 'top') {
|
16 |
+
global $bp, $bp_media_paginated_links, $bp_media_query;
|
17 |
+
switch ($bp->current_action) {
|
18 |
+
case BP_MEDIA_IMAGES_SLUG :
|
19 |
+
$current = $bp_media_query->found_posts > 1 ? BP_MEDIA_IMAGES_LABEL : BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
20 |
+
$current_single = BP_MEDIA_IMAGES_LABEL_SINGULAR;
|
21 |
+
break;
|
22 |
+
case BP_MEDIA_VIDEOS_SLUG :
|
23 |
+
$current = $bp_media_query->found_posts > 1 ? BP_MEDIA_VIDEOS_LABEL : BP_MEDIA_VIDEOS_LABEL_SINGULAR;
|
24 |
+
$current_single = BP_MEDIA_VIDEOS_LABEL_SINGULAR;
|
25 |
+
break;
|
26 |
+
case BP_MEDIA_AUDIO_SLUG :
|
27 |
+
$current = BP_MEDIA_AUDIO_LABEL;
|
28 |
+
$current_single = BP_MEDIA_AUDIO_LABEL_SINGULAR;
|
29 |
+
break;
|
30 |
+
default :
|
31 |
+
$current = BP_MEDIA_LABEL;
|
32 |
+
$current_single = BP_MEDIA_LABEL_SINGULAR;
|
33 |
+
}
|
34 |
+
$args = array(
|
35 |
+
'base' => trailingslashit(bp_displayed_user_domain() . $bp->current_action . '/') . '%_%',
|
36 |
+
'format' => 'page/%#%',
|
37 |
+
'total' => $bp_media_query->max_num_pages,
|
38 |
+
'current' => $bp_media_query->query_vars['paged'],
|
39 |
+
'type' => 'array',
|
40 |
+
'prev_text' => '←',
|
41 |
+
'next_text' => '→',
|
42 |
+
);
|
43 |
+
$start_num = intval($bp_media_query->query_vars['posts_per_page'] * ($bp_media_query->query_vars['paged'] - 1)) + 1;
|
44 |
+
$from_num = $start_num;
|
45 |
+
$to_num = $start_num + $bp_media_query->post_count - 1;
|
46 |
+
$total = $bp_media_query->found_posts;
|
47 |
+
$bp_media_paginated_links = paginate_links($args);
|
48 |
+
?>
|
49 |
+
<div id="pag-<?php echo $type; ?>" class="pagination no-ajax">
|
50 |
+
<div class="pag-count">
|
51 |
+
Viewing <?php echo $current_single ?> <?php echo $from_num ?> to <?php echo $to_num ?> (of <?php echo $total; ?> <?php echo $current ?>)
|
52 |
+
</div>
|
53 |
+
<div class="pagination-links">
|
54 |
+
<?php if(is_array($bp_media_paginated_links)) : foreach ($bp_media_paginated_links as $link) : ?>
|
55 |
+
<?php echo $link; ?>
|
56 |
+
<?php endforeach; endif; ?>
|
57 |
+
</div>
|
58 |
+
</div>
|
59 |
+
<?php
|
60 |
+
}
|
61 |
+
|
62 |
+
function bp_media_get_permalink($id = 0) {
|
63 |
+
if (is_object($id))
|
64 |
+
$media = $id;
|
65 |
+
else
|
66 |
+
$media = &get_post($id);
|
67 |
+
if (empty($media->ID))
|
68 |
+
return false;
|
69 |
+
if (!$media->post_type == 'bp_media')
|
70 |
+
return false;
|
71 |
+
switch (get_post_meta($media->ID, 'bp_media_type', true)) {
|
72 |
+
case 'video' :
|
73 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/watch/' . $media->ID);
|
74 |
+
break;
|
75 |
+
case 'audio' :
|
76 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/listen/' . $media->ID);
|
77 |
+
break;
|
78 |
+
case 'image' :
|
79 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/view/' . $media->ID);
|
80 |
+
break;
|
81 |
+
default :
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
function bp_media_the_permalink() {
|
87 |
+
echo apply_filters('bp_media_the_permalink', bp_media_get_permalink());
|
88 |
+
}
|
89 |
+
|
90 |
+
function bp_media_the_content($id = 0) {
|
91 |
+
if (is_object($id))
|
92 |
+
$media = $id;
|
93 |
+
else
|
94 |
+
$media = &get_post($id);
|
95 |
+
if (empty($media->ID))
|
96 |
+
return false;
|
97 |
+
if (!$media->post_type == 'bp_media')
|
98 |
+
return false;
|
99 |
+
$media = new BP_Media_Host_Wordpress($media->ID);
|
100 |
+
echo $media->get_media_gallery_content();
|
101 |
+
}
|
102 |
+
?>
|
includes/css/bp-media-admin.css
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Used on backend */
|
2 |
+
#wpbody-content div.metabox-fixed{
|
3 |
+
width: 22%;
|
4 |
+
margin-right: 10px;
|
5 |
+
clear: both;
|
6 |
+
}
|
7 |
+
#wpbody-content div.wrap.bp-media-admin{
|
8 |
+
overflow: hidden;
|
9 |
+
width: 76%;
|
10 |
+
}
|
11 |
+
#icon-bp-media{
|
12 |
+
background:url('../img/logo_medibp_32.png') no-repeat scroll 0 0 transparent;
|
13 |
+
}.bp-media-social{
|
14 |
+
background: url('../img/bp_media_social.png');
|
15 |
+
height: 35px;
|
16 |
+
width: 35px;
|
17 |
+
display: inline-block;
|
18 |
+
font-size: 0px;
|
19 |
+
margin-right:5px;
|
20 |
+
}
|
21 |
+
.bp-media-facebook{
|
22 |
+
background-position: 0px 0px;
|
23 |
+
}
|
24 |
+
.bp-media-facebook:hover{
|
25 |
+
background-position: 0px 36px;
|
26 |
+
}
|
27 |
+
.bp-media-twitter{
|
28 |
+
background-position: 80px 0px;
|
29 |
+
}
|
30 |
+
.bp-media-twitter:hover{
|
31 |
+
background-position: 80px 36px;
|
32 |
+
}
|
33 |
+
.bp-media-rss{
|
34 |
+
background-position: 35px 0px;
|
35 |
+
}
|
36 |
+
.bp-media-rss:hover{
|
37 |
+
background-position: 35px 36px;
|
38 |
+
}
|
39 |
+
|
includes/css/bp-media-style.css
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Default stylesheet for BuddyPress Media Component
|
3 |
+
*/
|
4 |
+
.bp_media_content img{
|
5 |
+
max-width:98%;
|
6 |
+
}
|
7 |
+
.bp_media_title {
|
8 |
+
display:block;
|
9 |
+
font-size:20px;
|
10 |
+
font-weight:bold;
|
11 |
+
}
|
12 |
+
.bp_media_description {
|
13 |
+
display:block;
|
14 |
+
}
|
15 |
+
ul.bp-media-gallery{
|
16 |
+
overflow:hidden;
|
17 |
+
}
|
18 |
+
ul.bp-media-gallery li{
|