Version Description
- Fixes warning on admin side.
Download this release
Release Info
Developer | saurabhshukla |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.5.2 |
Comparing to | |
See all releases |
Code changes from version 2.5.1 to 2.5.2
- app/admin/BPMediaAdmin.php +164 -136
- app/helper/BPMediaAddon.php +5 -0
- app/helper/BPMediaAdminWidget.php +7 -0
- app/helper/BPMediaFeed.php +5 -0
- app/helper/BPMediaLog.php +71 -50
- app/helper/BPMediaSettings.php +69 -15
- app/helper/BPMediaSupport.php +9 -0
- app/helper/BPMediaUpgrade.php +24 -8
- app/helper/rtPluginInfo.php +114 -106
- app/helper/rtPluginUpdate.php +121 -89
- app/helper/rtPluginUpdateChecker.php +655 -558
- app/main/BPMediaLoader.php +112 -96
- app/main/BuddyPressMedia.php +35 -7
- app/main/group/BPMediaGroup.php +52 -10
- app/main/group/BPMediaGroupAction.php +31 -3
- app/main/group/BPMediaGroupElementExtension.php +20 -4
- app/main/group/BPMediaGroupsExtension.php +35 -4
- app/main/group/dummy/BPMediaGroupAlbum.php +10 -7
- app/main/includes/BPMediaActions.php +93 -3
- app/main/includes/BPMediaComponent.php +353 -339
- app/main/includes/BPMediaFilters.php +75 -3
- app/main/includes/BPMediaFunction.php +54 -1
- app/main/includes/BPMediaHostWordpress.php +194 -28
- app/main/includes/BPMediaTemplateFunctions.php +36 -7
- app/main/includes/BPMediaUpgradeScript.php +10 -3
- app/main/profile/BPMediaAlbum.php +328 -259
- app/main/profile/BPMediaAlbumScreen.php +182 -136
- app/main/profile/BPMediaScreen.php +440 -398
- app/main/profile/BPMediaTemplate.php +241 -206
- app/main/profile/BPMediaUploadScreen.php +125 -115
- app/main/widgets/BPMediaPopularMedia.php +21 -6
- app/main/widgets/BPMediaRecentMedia.php +23 -8
- app/main/widgets/BPMediaWidget.php +41 -26
- index.php +1 -1
- readme.txt +6 -3
app/admin/BPMediaAdmin.php
CHANGED
@@ -41,6 +41,11 @@ if (!class_exists('BPMediaAdmin')) {
|
|
41 |
*
|
42 |
* @param string $hook
|
43 |
*/
|
|
|
|
|
|
|
|
|
|
|
44 |
public function ui($hook) {
|
45 |
$admin_ajax = admin_url('admin-ajax.php');
|
46 |
wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js');
|
@@ -81,6 +86,10 @@ if (!class_exists('BPMediaAdmin')) {
|
|
81 |
$this->render_page('bp-media-support');
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
84 |
static function get_current_tab() {
|
85 |
return isset($_GET['page']) ? $_GET['page'] : "bp-media-settings";
|
86 |
}
|
@@ -90,6 +99,12 @@ if (!class_exists('BPMediaAdmin')) {
|
|
90 |
*
|
91 |
* @global string BP_MEDIA_TXT_DOMAIN
|
92 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
public function render_page($page, $option_group = NULL) {
|
94 |
?>
|
95 |
|
@@ -99,7 +114,7 @@ if (!class_exists('BPMediaAdmin')) {
|
|
99 |
<?php settings_errors(); ?>
|
100 |
<div class="columns-2">
|
101 |
<h3 class="bp-media-settings-tabs"><?php
|
102 |
-
|
103 |
?>
|
104 |
</h3>
|
105 |
|
@@ -126,85 +141,90 @@ if (!class_exists('BPMediaAdmin')) {
|
|
126 |
</div>
|
127 |
</div><!-- .metabox-holder -->
|
128 |
</div><!-- .bp-media-admin --><?php
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
208 |
post_author,
|
209 |
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
|
210 |
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
|
@@ -218,82 +238,90 @@ if (!class_exists('BPMediaAdmin')) {
|
|
218 |
`meta_value` > 0 AND
|
219 |
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
|
220 |
GROUP BY post_author";
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
<ul id="social">
|
266 |
<li><a href="' . sprintf('%s', 'http://www.facebook.com/rtCamp.solutions/') . '" title="' . __('Become a fan on Facebook', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-facebook bp-media-social">' . __('Facebook', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
267 |
<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-twitter bp-media-social">' . __('Twitter', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
268 |
<li><a href="' . sprintf('%s', 'http://feeds.feedburner.com/rtcamp/') . '" title="' . __('Subscribe to our feeds', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-rss bp-media-social">' . __('RSS Feed', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
269 |
</ul>';
|
270 |
-
|
271 |
|
272 |
-
|
273 |
<li>' . sprintf('<a href="%s">' . __("Read FAQ", BP_MEDIA_TXT_DOMAIN) . '</a>', 'http://rtcamp.com/buddypress-media/faq/') . '</li>
|
274 |
<li>' . sprintf('<a href="%s">' . __("Free Support Forum", BP_MEDIA_TXT_DOMAIN) . '</a>', $bp_media->support_url) . '</li>
|
275 |
<li>' . sprintf('<a href="%s">' . __("Github Issue Tracker", BP_MEDIA_TXT_DOMAIN) . '</a>', 'https://github.com/rtCamp/buddypress-media/issues/') . '</li>
|
276 |
<li>' . sprintf('<a href="%s">' . __("Hire Us!", BP_MEDIA_TXT_DOMAIN) . '</a> ' . __("To get professional customisation/setup service.", BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/buddypress-media/hire/') . '</li>
|
277 |
</ul></p>';
|
278 |
-
|
279 |
|
280 |
-
|
281 |
<p>' . sprintf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', BP_MEDIA_TXT_DOMAIN)) . '</p>';
|
282 |
-
|
283 |
|
284 |
-
|
285 |
<li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="' . __('BuddyPress Media Kaltura', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-Kaltura', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add support for Kaltura.com/Kaltura-CE based video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
|
286 |
<li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="' . __('BuddyPress Media FFMPEG', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-FFMPEG', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add FFMEG-based audio/video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
|
287 |
</ul>
|
288 |
<h4>' . sprintf(__('Are you a developer?', BP_MEDIA_TXT_DOMAIN)) . '</h4>
|
289 |
<p>' . sprintf(__('If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href="%s">More info!</a>', BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/contact/') . '</p></h4>';
|
290 |
-
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
|
296 |
-
|
297 |
|
298 |
-
}
|
299 |
?>
|
41 |
*
|
42 |
* @param string $hook
|
43 |
*/
|
44 |
+
|
45 |
+
/**
|
46 |
+
*
|
47 |
+
* @param type $hook
|
48 |
+
*/
|
49 |
public function ui($hook) {
|
50 |
$admin_ajax = admin_url('admin-ajax.php');
|
51 |
wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js');
|
86 |
$this->render_page('bp-media-support');
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
*
|
91 |
+
* @return type
|
92 |
+
*/
|
93 |
static function get_current_tab() {
|
94 |
return isset($_GET['page']) ? $_GET['page'] : "bp-media-settings";
|
95 |
}
|
99 |
*
|
100 |
* @global string BP_MEDIA_TXT_DOMAIN
|
101 |
*/
|
102 |
+
|
103 |
+
/**
|
104 |
+
*
|
105 |
+
* @param type $page
|
106 |
+
* @param type $option_group
|
107 |
+
*/
|
108 |
public function render_page($page, $option_group = NULL) {
|
109 |
?>
|
110 |
|
114 |
<?php settings_errors(); ?>
|
115 |
<div class="columns-2">
|
116 |
<h3 class="bp-media-settings-tabs"><?php
|
117 |
+
$this->sub_tabs();
|
118 |
?>
|
119 |
</h3>
|
120 |
|
141 |
</div>
|
142 |
</div><!-- .metabox-holder -->
|
143 |
</div><!-- .bp-media-admin --><?php
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Adds a tab for Media settings in the BuddyPress settings page
|
148 |
+
*
|
149 |
+
* @global type $bp_media
|
150 |
+
*/
|
151 |
+
public function tab() {
|
152 |
+
|
153 |
+
$tabs_html = '';
|
154 |
+
$idle_class = 'nav-tab';
|
155 |
+
$active_class = 'nav-tab nav-tab-active';
|
156 |
+
$tabs = array();
|
157 |
+
|
158 |
+
// Check to see which tab we are on
|
159 |
+
$tab = $this->get_current_tab();
|
160 |
+
/* BuddyPress Media */
|
161 |
+
$tabs[] = array(
|
162 |
+
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
|
163 |
+
'title' => __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
|
164 |
+
'name' => __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
|
165 |
+
'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
|
166 |
+
);
|
167 |
+
|
168 |
+
foreach ($tabs as $tab) {
|
169 |
+
$tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
|
170 |
+
}
|
171 |
+
echo $tabs_html;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Adds a sub tabs to the BuddyPress Media settings page
|
176 |
+
*
|
177 |
+
* @global type $bp_media
|
178 |
+
*/
|
179 |
+
public function sub_tabs() {
|
180 |
+
$tabs_html = '';
|
181 |
+
$idle_class = 'nav-tab';
|
182 |
+
$active_class = 'nav-tab nav-tab-active';
|
183 |
+
$tabs = array();
|
184 |
+
|
185 |
+
// Check to see which tab we are on
|
186 |
+
$tab = $this->get_current_tab();
|
187 |
+
/* BuddyPress Media */
|
188 |
+
$tabs[] = array(
|
189 |
+
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
|
190 |
+
'title' => __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN),
|
191 |
+
'name' => __('Settings', BP_MEDIA_TXT_DOMAIN),
|
192 |
+
'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
|
193 |
+
);
|
194 |
+
|
195 |
+
$tabs[] = array(
|
196 |
+
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
|
197 |
+
'title' => __('BuddyPress Media Addons', BP_MEDIA_TXT_DOMAIN),
|
198 |
+
'name' => __('Addons', BP_MEDIA_TXT_DOMAIN),
|
199 |
+
'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
|
200 |
+
);
|
201 |
+
|
202 |
+
$tabs[] = array(
|
203 |
+
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
|
204 |
+
'title' => __('BuddyPress Media Support', BP_MEDIA_TXT_DOMAIN),
|
205 |
+
'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
|
206 |
+
'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
|
207 |
+
);
|
208 |
+
$tabs = apply_filters('bp_media_add_sub_tabs', $tabs, $tab);
|
209 |
+
foreach ($tabs as $tab) {
|
210 |
+
$tabs_html.= '<a title="' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
|
211 |
+
}
|
212 |
+
echo $tabs_html;
|
213 |
+
}
|
214 |
+
|
215 |
+
/*
|
216 |
+
* Updates the media count of all users.
|
217 |
+
*/
|
218 |
+
|
219 |
+
/**
|
220 |
+
*
|
221 |
+
* @global type $wpdb
|
222 |
+
* @return boolean
|
223 |
+
*/
|
224 |
+
public function update_count() {
|
225 |
+
global $wpdb;
|
226 |
+
$query =
|
227 |
+
"SELECT
|
228 |
post_author,
|
229 |
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
|
230 |
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
|
238 |
`meta_value` > 0 AND
|
239 |
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
|
240 |
GROUP BY post_author";
|
241 |
+
$result = $wpdb->get_results($query);
|
242 |
+
if (!is_array($result))
|
243 |
+
return false;
|
244 |
+
|
245 |
+
foreach ($result as $obj) {
|
246 |
+
|
247 |
+
$count = array(
|
248 |
+
'images' => isset($obj->Images) ? $obj->Images : 0,
|
249 |
+
'videos' => isset($obj->Videos) ? $obj->Videos : 0,
|
250 |
+
'audio' => isset($obj->Audio) ? $obj->Audio : 0,
|
251 |
+
'albums' => isset($obj->Albums) ? $obj->Albums : 0
|
252 |
+
);
|
253 |
+
bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
|
254 |
+
}
|
255 |
+
return true;
|
256 |
+
}
|
257 |
+
|
258 |
+
/* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
|
259 |
+
|
260 |
+
/**
|
261 |
+
*
|
262 |
+
* @global type $bp_media_admin
|
263 |
+
*/
|
264 |
+
public function save_multisite_options() {
|
265 |
+
global $bp_media_admin;
|
266 |
+
if (isset($_POST['refresh-count'])) {
|
267 |
+
$bp_media_admin->update_count();
|
268 |
+
}
|
269 |
+
do_action('bp_media_sanitize_settings', $_POST);
|
270 |
+
|
271 |
+
if (isset($_POST['bp_media_options'])) {
|
272 |
+
bp_update_option('bp_media_options', $_POST['bp_media_options']);
|
273 |
+
|
274 |
+
// redirect to settings page in network
|
275 |
+
wp_redirect(
|
276 |
+
add_query_arg(
|
277 |
+
array('page' => 'bp-media-settings', 'updated' => 'true'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
278 |
+
)
|
279 |
+
);
|
280 |
+
exit;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
/* Admin Sidebar */
|
285 |
+
|
286 |
+
/**
|
287 |
+
*
|
288 |
+
* @global type $bp_media
|
289 |
+
*/
|
290 |
+
public function admin_sidebar() {
|
291 |
+
global $bp_media;
|
292 |
+
$branding = '<a href="http://rtcamp.com" title="' . __('Empowering The Web With WordPress', BP_MEDIA_TXT_DOMAIN) . '" id="logo"><img src="' . BP_MEDIA_URL . 'app/assets/img/rtcamp-logo.png" alt="' . __('rtCamp', BP_MEDIA_TXT_DOMAIN) . '" /></a>
|
293 |
<ul id="social">
|
294 |
<li><a href="' . sprintf('%s', 'http://www.facebook.com/rtCamp.solutions/') . '" title="' . __('Become a fan on Facebook', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-facebook bp-media-social">' . __('Facebook', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
295 |
<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-twitter bp-media-social">' . __('Twitter', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
296 |
<li><a href="' . sprintf('%s', 'http://feeds.feedburner.com/rtcamp/') . '" title="' . __('Subscribe to our feeds', BP_MEDIA_TXT_DOMAIN) . '" class="bp-media-rss bp-media-social">' . __('RSS Feed', BP_MEDIA_TXT_DOMAIN) . '</a></li>
|
297 |
</ul>';
|
298 |
+
new BPMediaAdminWidget('branding', '', $branding);
|
299 |
|
300 |
+
$support = '<p><ul>
|
301 |
<li>' . sprintf('<a href="%s">' . __("Read FAQ", BP_MEDIA_TXT_DOMAIN) . '</a>', 'http://rtcamp.com/buddypress-media/faq/') . '</li>
|
302 |
<li>' . sprintf('<a href="%s">' . __("Free Support Forum", BP_MEDIA_TXT_DOMAIN) . '</a>', $bp_media->support_url) . '</li>
|
303 |
<li>' . sprintf('<a href="%s">' . __("Github Issue Tracker", BP_MEDIA_TXT_DOMAIN) . '</a>', 'https://github.com/rtCamp/buddypress-media/issues/') . '</li>
|
304 |
<li>' . sprintf('<a href="%s">' . __("Hire Us!", BP_MEDIA_TXT_DOMAIN) . '</a> ' . __("To get professional customisation/setup service.", BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/buddypress-media/hire/') . '</li>
|
305 |
</ul></p>';
|
306 |
+
new BPMediaAdminWidget('support', __('Need Help?', BP_MEDIA_TXT_DOMAIN), $support);
|
307 |
|
308 |
+
$donate = '<span><a href="http://rtcamp.com/donate/" title="' . __('Help the development keep going.', BP_MEDIA_TXT_DOMAIN) . '"><img class="bp-media-donation-image" src ="' . BP_MEDIA_URL . 'app/assets/img/donate.gif" /></a></span>
|
309 |
<p>' . sprintf(__('Help us release more amazing features faster. Consider making a donation to our consistent efforts.', BP_MEDIA_TXT_DOMAIN)) . '</p>';
|
310 |
+
new BPMediaAdminWidget('donate', __('Donate', BP_MEDIA_TXT_DOMAIN), $donate);
|
311 |
|
312 |
+
$addons = '<ul>
|
313 |
<li><a href="http://rtcamp.com/store/buddypress-media-kaltura/" title="' . __('BuddyPress Media Kaltura', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-Kaltura', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add support for Kaltura.com/Kaltura-CE based video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
|
314 |
<li><a href="http://rtcamp.com/store/buddy-press-media-ffmpeg/" title="' . __('BuddyPress Media FFMPEG', BP_MEDIA_TXT_DOMAIN) . '">' . __('BPM-FFMPEG', BP_MEDIA_TXT_DOMAIN) . '</a> - ' . __('Add FFMEG-based audio/video conversion support', BP_MEDIA_TXT_DOMAIN) . '</li>
|
315 |
</ul>
|
316 |
<h4>' . sprintf(__('Are you a developer?', BP_MEDIA_TXT_DOMAIN)) . '</h4>
|
317 |
<p>' . sprintf(__('If you are developing a BuddyPress Media addon we would like to include it in above list. We can also help you sell them. <a href="%s">More info!</a>', BP_MEDIA_TXT_DOMAIN), 'http://rtcamp.com/contact/') . '</p></h4>';
|
318 |
+
new BPMediaAdminWidget('premium-addons', __('Premium Addons', BP_MEDIA_TXT_DOMAIN), $addons);
|
319 |
|
320 |
+
$news = '<img src ="' . admin_url('/images/wpspin_light.gif') . '" /> Loading...';
|
321 |
+
new BPMediaAdminWidget('latest-news', __('Latest News', BP_MEDIA_TXT_DOMAIN), $news);
|
322 |
+
}
|
323 |
|
324 |
+
}
|
325 |
|
326 |
+
}
|
327 |
?>
|
app/helper/BPMediaAddon.php
CHANGED
@@ -52,6 +52,11 @@ if (!class_exists('BPMediaAddon')) {
|
|
52 |
}
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
public function addon($args) {
|
56 |
global $bp_media;
|
57 |
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @global type $bp_media
|
58 |
+
* @param type $args
|
59 |
+
*/
|
60 |
public function addon($args) {
|
61 |
global $bp_media;
|
62 |
|
app/helper/BPMediaAdminWidget.php
CHANGED
@@ -9,6 +9,13 @@ if (!class_exists('BPMediaAdminWidget')) {
|
|
9 |
|
10 |
class BPMediaAdminWidget {
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
public function __construct($id = NULL, $title = NULL, $content = NULL) {
|
13 |
global $bp_media;
|
14 |
if ($id) {
|
9 |
|
10 |
class BPMediaAdminWidget {
|
11 |
|
12 |
+
/**
|
13 |
+
*
|
14 |
+
* @global type $bp_media
|
15 |
+
* @param type $id
|
16 |
+
* @param type $title
|
17 |
+
* @param type $content
|
18 |
+
*/
|
19 |
public function __construct($id = NULL, $title = NULL, $content = NULL) {
|
20 |
global $bp_media;
|
21 |
if ($id) {
|
app/helper/BPMediaFeed.php
CHANGED
@@ -18,6 +18,11 @@ class BPMediaFeed {
|
|
18 |
/**
|
19 |
* Get BuddyPress Media Feed from rtCamp.com
|
20 |
*/
|
|
|
|
|
|
|
|
|
|
|
21 |
public function fetch_feed() {
|
22 |
global $bp_media;
|
23 |
// Get RSS Feed(s)
|
18 |
/**
|
19 |
* Get BuddyPress Media Feed from rtCamp.com
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @global type $bp_media
|
25 |
+
*/
|
26 |
public function fetch_feed() {
|
27 |
global $bp_media;
|
28 |
// Get RSS Feed(s)
|
app/helper/BPMediaLog.php
CHANGED
@@ -5,61 +5,82 @@
|
|
5 |
*
|
6 |
* @author Saurabh Shukla <saurabh.shukla@rtcamp.com>
|
7 |
*/
|
8 |
-
if (
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
function log_msg( $msg, $context = '' ) {
|
35 |
-
$logmsg = gmdate( "Y-m-d H:i:s " ) . " | ";
|
36 |
-
if ( $context ) {
|
37 |
-
$logmsg .= $context . " | ";
|
38 |
-
}
|
39 |
-
if ( ! is_string( $msg ) ) {
|
40 |
-
$msg = var_export( $msg, false );
|
41 |
-
}
|
42 |
-
$logmsg .= $msg;
|
43 |
-
return $logmsg;
|
44 |
-
}
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
}
|
65 |
?>
|
5 |
*
|
6 |
* @author Saurabh Shukla <saurabh.shukla@rtcamp.com>
|
7 |
*/
|
8 |
+
if (!class_exists('BPMediaLog')) {
|
9 |
|
10 |
+
class BPMediaLog {
|
11 |
+
/**
|
12 |
+
* Formats and logs the error message
|
13 |
+
*
|
14 |
+
* @param any $msg The message to log
|
15 |
+
* @param string $context The context string, optional
|
16 |
+
* @return boolean True if successful
|
17 |
+
*/
|
18 |
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param type $msg
|
22 |
+
* @param string $context
|
23 |
+
* @param string $log_file
|
24 |
+
* @return type
|
25 |
+
*/
|
26 |
+
public function __construct($msg, $context = '', $log_file = '') {
|
27 |
+
$log_msg = $this->log_msg($msg, $context = '');
|
28 |
+
if ($log_file == '') {
|
29 |
+
$log_file = BP_MEDIA_PATH . 'log/bpmedia.log';
|
30 |
+
}
|
31 |
+
return $this->log($log_msg, $log_file);
|
32 |
+
}
|
33 |
|
34 |
+
/**
|
35 |
+
* Formats the message
|
36 |
+
*
|
37 |
+
* @param any $msg The message to format
|
38 |
+
* @param string $context The context string, optional
|
39 |
+
* @return string The formatted log entry
|
40 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* @param type $msg
|
45 |
+
* @param type $context
|
46 |
+
* @return type
|
47 |
+
*/
|
48 |
+
function log_msg($msg, $context = '') {
|
49 |
+
$logmsg = gmdate("Y-m-d H:i:s ") . " | ";
|
50 |
+
if ($context) {
|
51 |
+
$logmsg .= $context . " | ";
|
52 |
+
}
|
53 |
+
if (!is_string($msg)) {
|
54 |
+
$msg = var_export($msg, false);
|
55 |
+
}
|
56 |
+
$logmsg .= $msg;
|
57 |
+
return $logmsg;
|
58 |
+
}
|
59 |
|
60 |
+
/**
|
61 |
+
* Logs the entry to the log file
|
62 |
+
*
|
63 |
+
* @param string $logmsg The formatted log entry
|
64 |
+
* @param string $file The log file's path
|
65 |
+
* @return boolean Success
|
66 |
+
*/
|
67 |
+
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @param type $logmsg
|
71 |
+
* @param type $file
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
+
public function log($logmsg, $file) {
|
75 |
+
$fp = fopen(BP_MEDIA_PATH . 'plugin.log', "a+");
|
76 |
+
if ($fp) {
|
77 |
+
fwrite($fp, "\n" . $logmsg);
|
78 |
+
fclose($fp);
|
79 |
+
}
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
84 |
|
85 |
}
|
86 |
?>
|
app/helper/BPMediaSettings.php
CHANGED
@@ -15,9 +15,14 @@ if (!class_exists('BPMediaSettings')) {
|
|
15 |
|
16 |
/**
|
17 |
* Register Settings
|
18 |
-
*
|
19 |
* @global string BP_MEDIA_TXT_DOMAIN
|
20 |
*/
|
|
|
|
|
|
|
|
|
|
|
21 |
public function settings() {
|
22 |
global $bp_media_addon;
|
23 |
add_settings_section('bpm-settings', __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN), is_multisite() ? array($this, 'network_notices') : '', 'bp-media-settings');
|
@@ -56,6 +61,15 @@ if (!class_exists('BPMediaSettings')) {
|
|
56 |
'name' => __('Re-Count', BP_MEDIA_TXT_DOMAIN),
|
57 |
'desc' => __('It will re-count all media entries of all users and correct any discrepancies.', BP_MEDIA_TXT_DOMAIN)
|
58 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
$bp_media_addon = new BPMediaAddon();
|
60 |
add_settings_section('bpm-addons', __('BuddyPress Media Addons for Audio/Video Conversion', BP_MEDIA_TXT_DOMAIN), array($bp_media_addon, 'get_addons'), 'bp-media-addons');
|
61 |
add_settings_section('bpm-support', __('Submit a request form', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-support');
|
@@ -84,6 +98,13 @@ if (!class_exists('BPMediaSettings')) {
|
|
84 |
/**
|
85 |
* Sanitizes the settings
|
86 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
public function sanitize($input) {
|
88 |
global $bp_media_admin;
|
89 |
if (isset($_POST['refresh-count'])) {
|
@@ -107,10 +128,17 @@ if (!class_exists('BPMediaSettings')) {
|
|
107 |
|
108 |
/**
|
109 |
* Output a checkbox
|
110 |
-
*
|
111 |
* @global array $bp_media
|
112 |
* @param array $args
|
113 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
public function checkbox($args) {
|
115 |
global $bp_media;
|
116 |
$options = $bp_media->options;
|
@@ -137,16 +165,23 @@ if (!class_exists('BPMediaSettings')) {
|
|
137 |
?>
|
138 |
<label for="<?php echo $option; ?>">
|
139 |
<input<?php checked($options[$option]); ?> name="<?php echo $name; ?>" id="<?php echo $option; ?>" value="1" type="checkbox" />
|
140 |
-
|
141 |
</label><?php
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* Outputs Radio Buttons
|
146 |
-
*
|
147 |
* @global array $bp_media
|
148 |
* @param array $args
|
149 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
public function radio($args) {
|
151 |
global $bp_media;
|
152 |
$options = $bp_media->options;
|
@@ -177,17 +212,24 @@ if (!class_exists('BPMediaSettings')) {
|
|
177 |
}
|
178 |
|
179 |
foreach ($radios as $value => $desc) {
|
180 |
-
|
181 |
<label for="<?php echo sanitize_title($desc); ?>"><input<?php checked($options[$option], $value); ?> value="<?php echo $value; ?>" name="<?php echo $name; ?>" id="<?php echo sanitize_title($desc); ?>" type="radio" /><?php echo $desc; ?></label><br /><?php
|
182 |
}
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
* Outputs Textbox
|
187 |
-
*
|
188 |
* @global array $bp_media
|
189 |
* @param array $args
|
190 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
public function textbox($args) {
|
192 |
global $bp_media;
|
193 |
$options = $bp_media->options;
|
@@ -213,20 +255,26 @@ if (!class_exists('BPMediaSettings')) {
|
|
213 |
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
|
214 |
$options[$option] = '';
|
215 |
}
|
216 |
-
|
217 |
<label for="<?php echo sanitize_title($option); ?>"><input value="<?php echo $options[$option]; ?>" name="<?php echo $name; ?>" id="<?php echo sanitize_title($option); ?>" type="<?php echo $password ? 'password' : 'text'; ?>" /><?php
|
218 |
if (!empty($desc)) {
|
219 |
echo '<br /><span class="description">' . $desc . '</span>';
|
220 |
}
|
221 |
-
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
* Outputs Dropdown
|
226 |
-
*
|
227 |
* @global array $bp_media
|
228 |
* @param array $args
|
229 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
public function dropdown($args) {
|
231 |
$defaults = array(
|
232 |
'setting' => '',
|
@@ -253,23 +301,29 @@ if (!class_exists('BPMediaSettings')) {
|
|
253 |
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
|
254 |
$options[$option] = '';
|
255 |
}
|
256 |
-
|
257 |
<select name="<?php echo $name; ?>" id="<?php echo $option; ?>"><?php if ($none) { ?>
|
258 |
<option><?php __e('None', BP_MEDIA_TXT_DOMAIN); ?></option><?php
|
259 |
}
|
260 |
foreach ($values as $value => $text) {
|
261 |
-
?>
|
262 |
-
<option<?php selected($options[$option], $value); ?> value="<?php echo $value; ?>"><?php echo $text; ?></option><?php }
|
263 |
?>
|
|
|
|
|
264 |
</select><?php
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
* Outputs a Button
|
269 |
-
*
|
270 |
* @global array $bp_media
|
271 |
* @param array $args
|
272 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
public function button($args) {
|
274 |
$defaults = array(
|
275 |
'setting' => '',
|
@@ -289,7 +343,7 @@ if (!class_exists('BPMediaSettings')) {
|
|
289 |
$button = $option;
|
290 |
submit_button($name, '', $button, false);
|
291 |
if (!empty($desc)) {
|
292 |
-
|
293 |
<span class="description"><?php echo $desc; ?></a><?php
|
294 |
}
|
295 |
}
|
@@ -297,4 +351,4 @@ if (!class_exists('BPMediaSettings')) {
|
|
297 |
}
|
298 |
|
299 |
}
|
300 |
-
|
15 |
|
16 |
/**
|
17 |
* Register Settings
|
18 |
+
*
|
19 |
* @global string BP_MEDIA_TXT_DOMAIN
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @global BPMediaAddon $bp_media_addon
|
25 |
+
*/
|
26 |
public function settings() {
|
27 |
global $bp_media_addon;
|
28 |
add_settings_section('bpm-settings', __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN), is_multisite() ? array($this, 'network_notices') : '', 'bp-media-settings');
|
61 |
'name' => __('Re-Count', BP_MEDIA_TXT_DOMAIN),
|
62 |
'desc' => __('It will re-count all media entries of all users and correct any discrepancies.', BP_MEDIA_TXT_DOMAIN)
|
63 |
));
|
64 |
+
/*add_settings_section('bpm-admin-bar-menu', __('Admin Bar Menu', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
|
65 |
+
add_settings_field('bpm-admin-bar-menu', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), array($this, 'radio'), 'bp-media-settings', 'bpm-spread-the-word', array(
|
66 |
+
'setting' => 'bp_media_options',
|
67 |
+
'option' => 'remove_linkback',
|
68 |
+
'radios' => array(
|
69 |
+
2 => __('Yes, I support BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
|
70 |
+
1 => __('No, I don\'t want to support BuddyPress Media', BP_MEDIA_TXT_DOMAIN)),
|
71 |
+
'default' => 2)
|
72 |
+
);*/
|
73 |
$bp_media_addon = new BPMediaAddon();
|
74 |
add_settings_section('bpm-addons', __('BuddyPress Media Addons for Audio/Video Conversion', BP_MEDIA_TXT_DOMAIN), array($bp_media_addon, 'get_addons'), 'bp-media-addons');
|
75 |
add_settings_section('bpm-support', __('Submit a request form', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-support');
|
98 |
/**
|
99 |
* Sanitizes the settings
|
100 |
*/
|
101 |
+
|
102 |
+
/**
|
103 |
+
*
|
104 |
+
* @global type $bp_media_admin
|
105 |
+
* @param type $input
|
106 |
+
* @return type
|
107 |
+
*/
|
108 |
public function sanitize($input) {
|
109 |
global $bp_media_admin;
|
110 |
if (isset($_POST['refresh-count'])) {
|
128 |
|
129 |
/**
|
130 |
* Output a checkbox
|
131 |
+
*
|
132 |
* @global array $bp_media
|
133 |
* @param array $args
|
134 |
*/
|
135 |
+
|
136 |
+
/**
|
137 |
+
*
|
138 |
+
* @global array $bp_media
|
139 |
+
* @param type $args
|
140 |
+
* @return type
|
141 |
+
*/
|
142 |
public function checkbox($args) {
|
143 |
global $bp_media;
|
144 |
$options = $bp_media->options;
|
165 |
?>
|
166 |
<label for="<?php echo $option; ?>">
|
167 |
<input<?php checked($options[$option]); ?> name="<?php echo $name; ?>" id="<?php echo $option; ?>" value="1" type="checkbox" />
|
168 |
+
<?php echo $desc; ?>
|
169 |
</label><?php
|
170 |
}
|
171 |
|
172 |
/**
|
173 |
* Outputs Radio Buttons
|
174 |
+
*
|
175 |
* @global array $bp_media
|
176 |
* @param array $args
|
177 |
*/
|
178 |
+
|
179 |
+
/**
|
180 |
+
*
|
181 |
+
* @global array $bp_media
|
182 |
+
* @param type $args
|
183 |
+
* @return type
|
184 |
+
*/
|
185 |
public function radio($args) {
|
186 |
global $bp_media;
|
187 |
$options = $bp_media->options;
|
212 |
}
|
213 |
|
214 |
foreach ($radios as $value => $desc) {
|
215 |
+
?>
|
216 |
<label for="<?php echo sanitize_title($desc); ?>"><input<?php checked($options[$option], $value); ?> value="<?php echo $value; ?>" name="<?php echo $name; ?>" id="<?php echo sanitize_title($desc); ?>" type="radio" /><?php echo $desc; ?></label><br /><?php
|
217 |
}
|
218 |
}
|
219 |
|
220 |
/**
|
221 |
* Outputs Textbox
|
222 |
+
*
|
223 |
* @global array $bp_media
|
224 |
* @param array $args
|
225 |
*/
|
226 |
+
|
227 |
+
/**
|
228 |
+
*
|
229 |
+
* @global array $bp_media
|
230 |
+
* @param type $args
|
231 |
+
* @return type
|
232 |
+
*/
|
233 |
public function textbox($args) {
|
234 |
global $bp_media;
|
235 |
$options = $bp_media->options;
|
255 |
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
|
256 |
$options[$option] = '';
|
257 |
}
|
258 |
+
?>
|
259 |
<label for="<?php echo sanitize_title($option); ?>"><input value="<?php echo $options[$option]; ?>" name="<?php echo $name; ?>" id="<?php echo sanitize_title($option); ?>" type="<?php echo $password ? 'password' : 'text'; ?>" /><?php
|
260 |
if (!empty($desc)) {
|
261 |
echo '<br /><span class="description">' . $desc . '</span>';
|
262 |
}
|
263 |
+
?></label><br /><?php
|
264 |
}
|
265 |
|
266 |
/**
|
267 |
* Outputs Dropdown
|
268 |
+
*
|
269 |
* @global array $bp_media
|
270 |
* @param array $args
|
271 |
*/
|
272 |
+
|
273 |
+
/**
|
274 |
+
*
|
275 |
+
* @param type $args
|
276 |
+
* @return type
|
277 |
+
*/
|
278 |
public function dropdown($args) {
|
279 |
$defaults = array(
|
280 |
'setting' => '',
|
301 |
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
|
302 |
$options[$option] = '';
|
303 |
}
|
304 |
+
?>
|
305 |
<select name="<?php echo $name; ?>" id="<?php echo $option; ?>"><?php if ($none) { ?>
|
306 |
<option><?php __e('None', BP_MEDIA_TXT_DOMAIN); ?></option><?php
|
307 |
}
|
308 |
foreach ($values as $value => $text) {
|
|
|
|
|
309 |
?>
|
310 |
+
<option<?php selected($options[$option], $value); ?> value="<?php echo $value; ?>"><?php echo $text; ?></option><?php }
|
311 |
+
?>
|
312 |
</select><?php
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
* Outputs a Button
|
317 |
+
*
|
318 |
* @global array $bp_media
|
319 |
* @param array $args
|
320 |
*/
|
321 |
+
|
322 |
+
/**
|
323 |
+
*
|
324 |
+
* @param type $args
|
325 |
+
* @return type
|
326 |
+
*/
|
327 |
public function button($args) {
|
328 |
$defaults = array(
|
329 |
'setting' => '',
|
343 |
$button = $option;
|
344 |
submit_button($name, '', $button, false);
|
345 |
if (!empty($desc)) {
|
346 |
+
?>
|
347 |
<span class="description"><?php echo $desc; ?></a><?php
|
348 |
}
|
349 |
}
|
351 |
}
|
352 |
|
353 |
}
|
354 |
+
?>
|
app/helper/BPMediaSupport.php
CHANGED
@@ -13,6 +13,11 @@ if (!class_exists('BPMediaSupport')) {
|
|
13 |
;
|
14 |
}
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
public function get_form($form) {
|
17 |
if (empty($form))
|
18 |
$form = (isset($_POST['form'])) ? $_POST['form'] : '';
|
@@ -91,6 +96,10 @@ if (!class_exists('BPMediaSupport')) {
|
|
91 |
}
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
94 |
public function submit_request() {
|
95 |
global $bp_media;
|
96 |
$form_data = wp_parse_args($_POST['form_data']);
|
13 |
;
|
14 |
}
|
15 |
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
* @global type $current_user
|
19 |
+
* @param type $form
|
20 |
+
*/
|
21 |
public function get_form($form) {
|
22 |
if (empty($form))
|
23 |
$form = (isset($_POST['form'])) ? $_POST['form'] : '';
|
96 |
}
|
97 |
}
|
98 |
|
99 |
+
/**
|
100 |
+
*
|
101 |
+
* @global type $bp_media
|
102 |
+
*/
|
103 |
public function submit_request() {
|
104 |
global $bp_media;
|
105 |
$form_data = wp_parse_args($_POST['form_data']);
|
app/helper/BPMediaUpgrade.php
CHANGED
@@ -23,6 +23,11 @@ if (!class_exists('BPMediaUpgrade')) {
|
|
23 |
*
|
24 |
* @global string BP_MEDIA_TXT_DOMAIN
|
25 |
*/
|
|
|
|
|
|
|
|
|
|
|
26 |
public function upgrade_db() {
|
27 |
global $bp_media;
|
28 |
?>
|
@@ -53,9 +58,15 @@ if (!class_exists('BPMediaUpgrade')) {
|
|
53 |
* @global wpdb $wpdb
|
54 |
* @global string BP_MEDIA_TXT_DOMAIN
|
55 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
public function upgrade_1_0_to_2_1() {
|
57 |
global $wpdb, $bp_media;
|
58 |
-
$post_wall =__(
|
59 |
remove_filter('bp_activity_get_user_join_filter', 'BPMediaFilters::activity_query_filter', 10);
|
60 |
/* @var $wpdb wpdb */
|
61 |
$wall_posts_album_ids = array();
|
@@ -124,17 +135,22 @@ if (!class_exists('BPMediaUpgrade')) {
|
|
124 |
*
|
125 |
* @global string BP_MEDIA_TXT_DOMAIN
|
126 |
*/
|
|
|
|
|
|
|
|
|
|
|
127 |
public function upgrade_2_0_to_2_1() {
|
128 |
global $bp_media;
|
129 |
$page = 0;
|
130 |
while ($media_entries = BPMediaUpgradeScript::return_query_posts(array(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
))) {
|
139 |
foreach ($media_entries as $media) {
|
140 |
try {
|
23 |
*
|
24 |
* @global string BP_MEDIA_TXT_DOMAIN
|
25 |
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
* @global type $bp_media
|
30 |
+
*/
|
31 |
public function upgrade_db() {
|
32 |
global $bp_media;
|
33 |
?>
|
58 |
* @global wpdb $wpdb
|
59 |
* @global string BP_MEDIA_TXT_DOMAIN
|
60 |
*/
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @global wpdb $wpdb
|
65 |
+
* @global type $bp_media
|
66 |
+
*/
|
67 |
public function upgrade_1_0_to_2_1() {
|
68 |
global $wpdb, $bp_media;
|
69 |
+
$post_wall = __('Wall Posts', BP_MEDIA_TXT_DOMAIN);
|
70 |
remove_filter('bp_activity_get_user_join_filter', 'BPMediaFilters::activity_query_filter', 10);
|
71 |
/* @var $wpdb wpdb */
|
72 |
$wall_posts_album_ids = array();
|
135 |
*
|
136 |
* @global string BP_MEDIA_TXT_DOMAIN
|
137 |
*/
|
138 |
+
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @global type $bp_media
|
142 |
+
*/
|
143 |
public function upgrade_2_0_to_2_1() {
|
144 |
global $bp_media;
|
145 |
$page = 0;
|
146 |
while ($media_entries = BPMediaUpgradeScript::return_query_posts(array(
|
147 |
+
'post_type' => 'attachment',
|
148 |
+
'post_status' => 'any',
|
149 |
+
'meta_key' => 'bp-media-key',
|
150 |
+
'meta_value' => 0,
|
151 |
+
'meta_compare' => '>',
|
152 |
+
'paged' => ++$page,
|
153 |
+
'postsperpage' => 10
|
154 |
))) {
|
155 |
foreach ($media_entries as $media) {
|
156 |
try {
|
app/helper/rtPluginInfo.php
CHANGED
@@ -1,116 +1,124 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* A container class for holding and transforming various plugin metadata.
|
4 |
*
|
5 |
* @author faishal
|
6 |
*/
|
7 |
class rtPluginInfo {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
-
|
115 |
|
116 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* A container class for holding and transforming various plugin metadata.
|
5 |
*
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class rtPluginInfo {
|
9 |
+
|
10 |
+
//Most fields map directly to the contents of the plugin's info.json file.
|
11 |
+
//See the relevant docs for a description of their meaning.
|
12 |
+
public $name;
|
13 |
+
public $slug;
|
14 |
+
public $version;
|
15 |
+
public $homepage;
|
16 |
+
public $sections;
|
17 |
+
public $download_url;
|
18 |
+
public $author;
|
19 |
+
public $author_homepage;
|
20 |
+
public $requires;
|
21 |
+
public $tested;
|
22 |
+
public $upgrade_notice;
|
23 |
+
public $rating;
|
24 |
+
public $num_ratings;
|
25 |
+
public $downloaded;
|
26 |
+
public $last_updated;
|
27 |
+
public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Create a new instance of PluginInfo from JSON-encoded plugin info
|
31 |
+
* returned by an external update API.
|
32 |
+
*
|
33 |
+
* @param string $json Valid JSON string representing plugin info.
|
34 |
+
* @param bool $triggerErrors
|
35 |
+
* @return PluginInfo|null New instance of PluginInfo, or NULL on error.
|
36 |
+
*/
|
37 |
+
|
38 |
+
/**
|
39 |
+
*
|
40 |
+
* @param type $json
|
41 |
+
* @param type $triggerErrors
|
42 |
+
* @return null|\self
|
43 |
+
*/
|
44 |
+
public static function fromJson($json, $triggerErrors = false) {
|
45 |
+
/** @var StdClass $apiResponse */
|
46 |
+
$apiResponse = json_decode($json);
|
47 |
+
if (empty($apiResponse) || !is_object($apiResponse)) {
|
48 |
+
if ($triggerErrors) {
|
49 |
+
trigger_error(
|
50 |
+
"Failed to parse plugin metadata. Try validating your .json file with http://jsonlint.com/", E_USER_NOTICE
|
51 |
+
);
|
52 |
+
}
|
53 |
+
return null;
|
54 |
+
}
|
55 |
+
|
56 |
+
//Very, very basic validation.
|
57 |
+
$valid = isset($apiResponse->name) && !empty($apiResponse->name) && isset($apiResponse->version) && !empty($apiResponse->version);
|
58 |
+
if (!$valid) {
|
59 |
+
if ($triggerErrors) {
|
60 |
+
trigger_error(
|
61 |
+
"The plugin metadata file does not contain the required 'name' and/or 'version' keys.", E_USER_NOTICE
|
62 |
+
);
|
63 |
+
}
|
64 |
+
return null;
|
65 |
+
}
|
66 |
+
|
67 |
+
$info = new self();
|
68 |
+
foreach (get_object_vars($apiResponse) as $key => $value) {
|
69 |
+
$info->$key = $value;
|
70 |
+
}
|
71 |
+
|
72 |
+
return $info;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Transform plugin info into the format used by the native WordPress.org API
|
77 |
+
*
|
78 |
+
* @return object
|
79 |
+
*/
|
80 |
+
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* @return \StdClass
|
84 |
+
*/
|
85 |
+
public function toWpFormat() {
|
86 |
+
$info = new StdClass;
|
87 |
+
|
88 |
+
//The custom update API is built so that many fields have the same name and format
|
89 |
+
//as those returned by the native WordPress.org API. These can be assigned directly.
|
90 |
+
$sameFormat = array(
|
91 |
+
'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
|
92 |
+
'num_ratings', 'downloaded', 'homepage', 'last_updated',
|
93 |
+
);
|
94 |
+
foreach ($sameFormat as $field) {
|
95 |
+
if (isset($this->$field)) {
|
96 |
+
$info->$field = $this->$field;
|
97 |
+
} else {
|
98 |
+
$info->$field = null;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
//Other fields need to be renamed and/or transformed.
|
103 |
+
$info->download_link = $this->download_url;
|
104 |
+
|
105 |
+
if (!empty($this->author_homepage)) {
|
106 |
+
$info->author = sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
|
107 |
+
} else {
|
108 |
+
$info->author = $this->author;
|
109 |
+
}
|
110 |
+
|
111 |
+
if (is_object($this->sections)) {
|
112 |
+
$info->sections = get_object_vars($this->sections);
|
113 |
+
} elseif (is_array($this->sections)) {
|
114 |
+
$info->sections = $this->sections;
|
115 |
+
} else {
|
116 |
+
$info->sections = array('description' => '');
|
117 |
+
}
|
118 |
+
|
119 |
+
return $info;
|
120 |
+
}
|
121 |
+
|
122 |
}
|
|
|
123 |
|
124 |
?>
|
app/helper/rtPluginUpdate.php
CHANGED
@@ -1,98 +1,130 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Description of rtPluginUpdate
|
4 |
* A simple container class for holding information about an available update.
|
5 |
* @author faishal
|
6 |
*/
|
7 |
class rtPluginUpdate {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
|
|
98 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Description of rtPluginUpdate
|
5 |
* A simple container class for holding information about an available update.
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class rtPluginUpdate {
|
9 |
+
|
10 |
+
public $id = 0;
|
11 |
+
public $slug;
|
12 |
+
public $version;
|
13 |
+
public $homepage;
|
14 |
+
public $download_url;
|
15 |
+
public $upgrade_notice;
|
16 |
+
private static $fields = array('id', 'slug', 'version', 'homepage', 'download_url', 'upgrade_notice');
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Create a new instance of PluginUpdate from its JSON-encoded representation.
|
20 |
+
*
|
21 |
+
* @param string $json
|
22 |
+
* @param bool $triggerErrors
|
23 |
+
* @return PluginUpdate|null
|
24 |
+
*/
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @param type $json
|
29 |
+
* @param type $triggerErrors
|
30 |
+
* @return null
|
31 |
+
*/
|
32 |
+
public static function fromJson($json, $triggerErrors = false) {
|
33 |
+
//Since update-related information is simply a subset of the full plugin info,
|
34 |
+
//we can parse the update JSON as if it was a plugin info string, then copy over
|
35 |
+
//the parts that we care about.
|
36 |
+
$pluginInfo = rtPluginInfo::fromJson($json, $triggerErrors);
|
37 |
+
if ($pluginInfo != null) {
|
38 |
+
return self::fromPluginInfo($pluginInfo);
|
39 |
+
} else {
|
40 |
+
return null;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
|
46 |
+
* Basically, this just copies a subset of fields from one object to another.
|
47 |
+
*
|
48 |
+
* @param PluginInfo $info
|
49 |
+
* @return PluginUpdate
|
50 |
+
*/
|
51 |
+
|
52 |
+
/**
|
53 |
+
*
|
54 |
+
* @param type $info
|
55 |
+
* @return type
|
56 |
+
*/
|
57 |
+
public static function fromPluginInfo($info) {
|
58 |
+
return self::fromObject($info);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Create a new instance of PluginUpdate by copying the necessary fields from
|
63 |
+
* another object.
|
64 |
+
*
|
65 |
+
* @param StdClass|PluginInfo|PluginUpdate $object The source object.
|
66 |
+
* @return PluginUpdate The new copy.
|
67 |
+
*/
|
68 |
+
|
69 |
+
/**
|
70 |
+
*
|
71 |
+
* @param type $object
|
72 |
+
* @return \self
|
73 |
+
*/
|
74 |
+
public static function fromObject($object) {
|
75 |
+
$update = new self();
|
76 |
+
foreach (self::$fields as $field) {
|
77 |
+
$update->$field = $object->$field;
|
78 |
+
}
|
79 |
+
return $update;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Create an instance of StdClass that can later be converted back to
|
84 |
+
* a PluginUpdate. Useful for serialization and caching, as it avoids
|
85 |
+
* the "incomplete object" problem if the cached value is loaded before
|
86 |
+
* this class.
|
87 |
+
*
|
88 |
+
* @return StdClass
|
89 |
+
*/
|
90 |
+
|
91 |
+
/**
|
92 |
+
*
|
93 |
+
* @return \StdClass
|
94 |
+
*/
|
95 |
+
public function toStdClass() {
|
96 |
+
$object = new StdClass();
|
97 |
+
foreach (self::$fields as $field) {
|
98 |
+
$object->$field = $this->$field;
|
99 |
+
}
|
100 |
+
return $object;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Transform the update into the format used by WordPress native plugin API.
|
105 |
+
*
|
106 |
+
* @return object
|
107 |
+
*/
|
108 |
+
|
109 |
+
/**
|
110 |
+
*
|
111 |
+
* @return \StdClass
|
112 |
+
*/
|
113 |
+
public function toWpFormat() {
|
114 |
+
$update = new StdClass;
|
115 |
+
|
116 |
+
$update->id = $this->id;
|
117 |
+
$update->slug = $this->slug;
|
118 |
+
$update->new_version = $this->version;
|
119 |
+
$update->url = $this->homepage;
|
120 |
+
$update->package = $this->download_url;
|
121 |
+
if (!empty($this->upgrade_notice)) {
|
122 |
+
$update->upgrade_notice = $this->upgrade_notice;
|
123 |
+
}
|
124 |
+
|
125 |
+
return $update;
|
126 |
+
}
|
127 |
+
|
128 |
}
|
129 |
+
|
130 |
?>
|
app/helper/rtPluginUpdateChecker.php
CHANGED
@@ -7,563 +7,660 @@
|
|
7 |
* @author faishal
|
8 |
*/
|
9 |
class rtPluginUpdateChecker {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
}
|
|
|
569 |
?>
|
7 |
* @author faishal
|
8 |
*/
|
9 |
class rtPluginUpdateChecker {
|
10 |
+
|
11 |
+
public $metadataUrl = ''; //The URL of the plugin's metadata file.
|
12 |
+
public $pluginFile = ''; //Plugin filename relative to the plugins directory.
|
13 |
+
public $slug = ''; //Plugin slug.
|
14 |
+
public $checkPeriod = 12; //How often to check for updates (in hours).
|
15 |
+
public $optionName = ''; //Where to store the update info.
|
16 |
+
public $debugMode = true; //Set to TRUE to enable error reporting. Errors are raised using trigger_error()
|
17 |
+
//and should be logged to the standard PHP error log.
|
18 |
+
private $cronHook = null;
|
19 |
+
private $debugBarPlugin = null;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class constructor.
|
23 |
+
*
|
24 |
+
* @param string $metadataUrl The URL of the plugin's metadata file.
|
25 |
+
* @param string $pluginFile Fully qualified path to the main plugin file.
|
26 |
+
* @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
|
27 |
+
* @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
|
28 |
+
* @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
*
|
33 |
+
* @param type $metadataUrl
|
34 |
+
* @param type $pluginFile
|
35 |
+
* @param type $slug
|
36 |
+
* @param type $checkPeriod
|
37 |
+
* @param type $optionName
|
38 |
+
*/
|
39 |
+
public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '') {
|
40 |
+
$this->metadataUrl = $metadataUrl;
|
41 |
+
$this->pluginFile = plugin_basename($pluginFile);
|
42 |
+
$this->checkPeriod = $checkPeriod;
|
43 |
+
$this->slug = $slug;
|
44 |
+
$this->optionName = $optionName;
|
45 |
+
$this->debugMode = defined('WP_DEBUG') && WP_DEBUG;
|
46 |
+
|
47 |
+
//If no slug is specified, use the name of the main plugin file as the slug.
|
48 |
+
//For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
|
49 |
+
if (empty($this->slug)) {
|
50 |
+
$this->slug = basename($this->pluginFile, '.php');
|
51 |
+
}
|
52 |
+
|
53 |
+
if (empty($this->optionName)) {
|
54 |
+
$this->optionName = 'external_updates-' . $this->slug;
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->installHooks();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Install the hooks required to run periodic update checks and inject update info
|
62 |
+
* into WP data structures.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
protected function installHooks() {
|
67 |
+
//Override requests for plugin information
|
68 |
+
add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
|
69 |
+
|
70 |
+
//Insert our update info into the update array maintained by WP
|
71 |
+
add_filter('site_transient_update_plugins', array($this, 'injectUpdate')); //WP 3.0+
|
72 |
+
add_filter('transient_update_plugins', array($this, 'injectUpdate')); //WP 2.8+
|
73 |
+
|
74 |
+
add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 4);
|
75 |
+
add_action('admin_init', array($this, 'handleManualCheck'));
|
76 |
+
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
|
77 |
+
|
78 |
+
//Set up the periodic update checks
|
79 |
+
$this->cronHook = 'check_plugin_updates-' . $this->slug;
|
80 |
+
if ($this->checkPeriod > 0) {
|
81 |
+
|
82 |
+
//Trigger the check via Cron
|
83 |
+
add_filter('cron_schedules', array($this, '_addCustomSchedule'));
|
84 |
+
if (!wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING')) {
|
85 |
+
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
86 |
+
wp_schedule_event(time(), $scheduleName, $this->cronHook);
|
87 |
+
}
|
88 |
+
add_action($this->cronHook, array($this, 'checkForUpdates'));
|
89 |
+
|
90 |
+
register_deactivation_hook($this->pluginFile, array($this, '_removeUpdaterCron'));
|
91 |
+
|
92 |
+
//In case Cron is disabled or unreliable, we also manually trigger
|
93 |
+
//the periodic checks while the user is browsing the Dashboard.
|
94 |
+
add_action('admin_init', array($this, 'maybeCheckForUpdates'));
|
95 |
+
} else {
|
96 |
+
//Periodic checks are disabled.
|
97 |
+
wp_clear_scheduled_hook($this->cronHook);
|
98 |
+
}
|
99 |
+
|
100 |
+
add_action('plugins_loaded', array($this, 'initDebugBarPanel'));
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Add our custom schedule to the array of Cron schedules used by WP.
|
105 |
+
*
|
106 |
+
* @param array $schedules
|
107 |
+
* @return array
|
108 |
+
*/
|
109 |
+
|
110 |
+
/**
|
111 |
+
*
|
112 |
+
* @param type $schedules
|
113 |
+
* @return type
|
114 |
+
*/
|
115 |
+
public function _addCustomSchedule($schedules) {
|
116 |
+
if ($this->checkPeriod && ($this->checkPeriod > 0)) {
|
117 |
+
$scheduleName = 'every' . $this->checkPeriod . 'hours';
|
118 |
+
$schedules[$scheduleName] = array(
|
119 |
+
'interval' => $this->checkPeriod * 3600,
|
120 |
+
'display' => sprintf('Every %d hours', $this->checkPeriod),
|
121 |
+
);
|
122 |
+
}
|
123 |
+
return $schedules;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Remove the scheduled cron event that the library uses to check for updates.
|
128 |
+
*
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
public function _removeUpdaterCron() {
|
132 |
+
wp_clear_scheduled_hook($this->cronHook);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
|
137 |
+
*
|
138 |
+
* @return string
|
139 |
+
*/
|
140 |
+
|
141 |
+
/**
|
142 |
+
*
|
143 |
+
* @return type
|
144 |
+
*/
|
145 |
+
public function getCronHookName() {
|
146 |
+
return $this->cronHook;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Retrieve plugin info from the configured API endpoint.
|
151 |
+
*
|
152 |
+
* @uses wp_remote_get()
|
153 |
+
*
|
154 |
+
* @param array $queryArgs Additional query arguments to append to the request. Optional.
|
155 |
+
* @return PluginInfo
|
156 |
+
*/
|
157 |
+
|
158 |
+
/**
|
159 |
+
*
|
160 |
+
* @param type $queryArgs
|
161 |
+
* @return type
|
162 |
+
*/
|
163 |
+
public function requestInfo($queryArgs = array()) {
|
164 |
+
//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
|
165 |
+
$installedVersion = $this->getInstalledVersion();
|
166 |
+
$queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : '';
|
167 |
+
$queryArgs['admin_email'] = get_option("admin_email");
|
168 |
+
$queryArgs['slug'] = $this->slug;
|
169 |
+
$queryArgs = apply_filters('puc_request_info_query_args-' . $this->slug, $queryArgs);
|
170 |
+
//Various options for the wp_remote_get() call. Plugins can filter these, too.
|
171 |
+
$options = array(
|
172 |
+
'timeout' => 10, //seconds
|
173 |
+
'headers' => array(
|
174 |
+
'Accept' => 'application/json'
|
175 |
+
),
|
176 |
+
);
|
177 |
+
$options = apply_filters('puc_request_info_options-' . $this->slug, $options);
|
178 |
+
|
179 |
+
//The plugin info should be at 'http://your-api.com/url/here/$slug/info.json'
|
180 |
+
$url = $this->metadataUrl;
|
181 |
+
if (!empty($queryArgs)) {
|
182 |
+
$url = add_query_arg($queryArgs, $url);
|
183 |
+
}
|
184 |
+
|
185 |
+
$result = wp_remote_get(
|
186 |
+
$url, $options
|
187 |
+
);
|
188 |
+
//Try to parse the response
|
189 |
+
$pluginInfo = null;
|
190 |
+
if (!is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body'])) {
|
191 |
+
$pluginInfo = rtPluginInfo::fromJson($result['body'], $this->debugMode);
|
192 |
+
} else if ($this->debugMode) {
|
193 |
+
$message = sprintf("The URL %s does not point to a valid plugin metadata file. ", $url);
|
194 |
+
if (is_wp_error($result)) {
|
195 |
+
$message .= "WP HTTP error: " . $result->get_error_message();
|
196 |
+
} else if (isset($result['response']['code'])) {
|
197 |
+
$message .= "HTTP response code is " . $result['response']['code'] . " (expected: 200)";
|
198 |
+
} else {
|
199 |
+
$message .= "wp_remote_get() returned an unexpected result.";
|
200 |
+
}
|
201 |
+
trigger_error($message, E_USER_WARNING);
|
202 |
+
}
|
203 |
+
|
204 |
+
$pluginInfo = apply_filters('puc_request_info_result-' . $this->slug, $pluginInfo, $result);
|
205 |
+
return $pluginInfo;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Retrieve the latest update (if any) from the configured API endpoint.
|
210 |
+
*
|
211 |
+
* @uses PluginUpdateChecker::requestInfo()
|
212 |
+
*
|
213 |
+
* @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available.
|
214 |
+
*/
|
215 |
+
|
216 |
+
/**
|
217 |
+
*
|
218 |
+
* @return null
|
219 |
+
*/
|
220 |
+
public function requestUpdate() {
|
221 |
+
//For the sake of simplicity, this function just calls requestInfo()
|
222 |
+
//and transforms the result accordingly.
|
223 |
+
$pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
|
224 |
+
if ($pluginInfo == null) {
|
225 |
+
return null;
|
226 |
+
}
|
227 |
+
return rtPluginUpdate::fromPluginInfo($pluginInfo);
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Get the currently installed version of the plugin.
|
232 |
+
*
|
233 |
+
* @return string Version number.
|
234 |
+
*/
|
235 |
+
|
236 |
+
/**
|
237 |
+
*
|
238 |
+
* @return null
|
239 |
+
*/
|
240 |
+
public function getInstalledVersion() {
|
241 |
+
|
242 |
+
if (!function_exists('get_plugins')) {
|
243 |
+
if (is_multisite()) {
|
244 |
+
require_once( ABSPATH . '/wp-admin/network/includes/plugin.php' );
|
245 |
+
} else {
|
246 |
+
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
247 |
+
}
|
248 |
+
}
|
249 |
+
$allPlugins = get_plugins();
|
250 |
+
if (array_key_exists($this->pluginFile, $allPlugins) && array_key_exists('Version', $allPlugins[$this->pluginFile])) {
|
251 |
+
return $allPlugins[$this->pluginFile]['Version'];
|
252 |
+
} else {
|
253 |
+
//This can happen if the filename is wrong or the plugin is installed in mu-plugins.
|
254 |
+
if ($this->debugMode) {
|
255 |
+
trigger_error(
|
256 |
+
sprintf(
|
257 |
+
"Can't to read the Version header for %s. The filename may be incorrect, or the file is not present in /wp-content/plugins.", $this->pluginFile
|
258 |
+
), E_USER_WARNING
|
259 |
+
);
|
260 |
+
}
|
261 |
+
return null;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check for plugin updates.
|
267 |
+
* The results are stored in the DB option specified in $optionName.
|
268 |
+
*
|
269 |
+
* @return PluginUpdate|null
|
270 |
+
*/
|
271 |
+
|
272 |
+
/**
|
273 |
+
*
|
274 |
+
* @return null
|
275 |
+
*/
|
276 |
+
public function checkForUpdates() {
|
277 |
+
$installedVersion = $this->getInstalledVersion();
|
278 |
+
//Fail silently if we can't find the plugin or read its header.
|
279 |
+
if ($installedVersion === null) {
|
280 |
+
if ($this->debugMode) {
|
281 |
+
trigger_error(
|
282 |
+
sprintf('Skipping update check for %s - installed version unknown.', $this->pluginFile), E_USER_WARNING
|
283 |
+
);
|
284 |
+
}
|
285 |
+
return null;
|
286 |
+
}
|
287 |
+
|
288 |
+
$state = $this->getUpdateState();
|
289 |
+
if (empty($state)) {
|
290 |
+
$state = new StdClass;
|
291 |
+
$state->lastCheck = 0;
|
292 |
+
$state->checkedVersion = '';
|
293 |
+
$state->update = null;
|
294 |
+
}
|
295 |
+
|
296 |
+
$state->lastCheck = time();
|
297 |
+
$state->checkedVersion = $installedVersion;
|
298 |
+
$this->setUpdateState($state); //Save before checking in case something goes wrong
|
299 |
+
|
300 |
+
$state->update = $this->requestUpdate();
|
301 |
+
$this->setUpdateState($state);
|
302 |
+
|
303 |
+
return $this->getUpdate();
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Check for updates only if the configured check interval has already elapsed.
|
308 |
+
*
|
309 |
+
* @return void
|
310 |
+
*/
|
311 |
+
|
312 |
+
/**
|
313 |
+
*
|
314 |
+
* @return type
|
315 |
+
*/
|
316 |
+
public function maybeCheckForUpdates() {
|
317 |
+
if (empty($this->checkPeriod)) {
|
318 |
+
return;
|
319 |
+
}
|
320 |
+
$state = $this->getUpdateState();
|
321 |
+
|
322 |
+
$shouldCheck =
|
323 |
+
empty($state) ||
|
324 |
+
!isset($state->lastCheck) ||
|
325 |
+
( (time() - $state->lastCheck) >= $this->checkPeriod * 3600 );
|
326 |
+
|
327 |
+
if ($shouldCheck) {
|
328 |
+
$this->checkForUpdates();
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Load the update checker state from the DB.
|
334 |
+
*
|
335 |
+
* @return StdClass|null
|
336 |
+
*/
|
337 |
+
|
338 |
+
/**
|
339 |
+
*
|
340 |
+
* @return null
|
341 |
+
*/
|
342 |
+
public function getUpdateState() {
|
343 |
+
$state = get_site_option($this->optionName, null);
|
344 |
+
if (empty($state) || !is_object($state)) {
|
345 |
+
$state = null;
|
346 |
+
}
|
347 |
+
|
348 |
+
if (!empty($state) && isset($state->update) && is_object($state->update)) {
|
349 |
+
$state->update = rtPluginUpdate::fromObject($state->update);
|
350 |
+
}
|
351 |
+
return $state;
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Persist the update checker state to the DB.
|
356 |
+
*
|
357 |
+
* @param StdClass $state
|
358 |
+
* @return void
|
359 |
+
*/
|
360 |
+
|
361 |
+
/**
|
362 |
+
*
|
363 |
+
* @param type $state
|
364 |
+
*/
|
365 |
+
private function setUpdateState($state) {
|
366 |
+
if (isset($state->update) && is_object($state->update) && method_exists($state->update, 'toStdClass')) {
|
367 |
+
$update = $state->update;/** @var PluginUpdate $update */
|
368 |
+
$state->update = $update->toStdClass();
|
369 |
+
}
|
370 |
+
update_site_option($this->optionName, $state);
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Reset update checker state - i.e. last check time, cached update data and so on.
|
375 |
+
*
|
376 |
+
* Call this when your plugin is being uninstalled, or if you want to
|
377 |
+
* clear the update cache.
|
378 |
+
*/
|
379 |
+
public function resetUpdateState() {
|
380 |
+
delete_site_option($this->optionName);
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Intercept plugins_api() calls that request information about our plugin and
|
385 |
+
* use the configured API endpoint to satisfy them.
|
386 |
+
*
|
387 |
+
* @see plugins_api()
|
388 |
+
*
|
389 |
+
* @param mixed $result
|
390 |
+
* @param string $action
|
391 |
+
* @param array|object $args
|
392 |
+
* @return mixed
|
393 |
+
*/
|
394 |
+
|
395 |
+
/**
|
396 |
+
*
|
397 |
+
* @param type $result
|
398 |
+
* @param type $action
|
399 |
+
* @param type $args
|
400 |
+
* @return type
|
401 |
+
*/
|
402 |
+
public function injectInfo($result, $action = null, $args = null) {
|
403 |
+
$relevant = ($action == 'plugin_information') && isset($args->slug) && ($args->slug == $this->slug);
|
404 |
+
if (!$relevant) {
|
405 |
+
return $result;
|
406 |
+
}
|
407 |
+
|
408 |
+
$pluginInfo = $this->requestInfo();
|
409 |
+
$pluginInfo = apply_filters('puc_pre_inject_info-' . $this->slug, $pluginInfo);
|
410 |
+
if ($pluginInfo) {
|
411 |
+
return $pluginInfo->toWpFormat();
|
412 |
+
}
|
413 |
+
|
414 |
+
return $result;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Insert the latest update (if any) into the update list maintained by WP.
|
419 |
+
*
|
420 |
+
* @param StdClass $updates Update list.
|
421 |
+
* @return StdClass Modified update list.
|
422 |
+
*/
|
423 |
+
|
424 |
+
/**
|
425 |
+
*
|
426 |
+
* @param StdClass $updates
|
427 |
+
* @return \StdClass
|
428 |
+
*/
|
429 |
+
public function injectUpdate($updates) {
|
430 |
+
//Is there an update to insert?
|
431 |
+
$update = $this->getUpdate();
|
432 |
+
if (!empty($update)) {
|
433 |
+
//Let plugins filter the update info before it's passed on to WordPress.
|
434 |
+
$update = apply_filters('puc_pre_inject_update-' . $this->slug, $update);
|
435 |
+
if (!is_object($updates)) {
|
436 |
+
$updates = new StdClass();
|
437 |
+
$updates->response = array();
|
438 |
+
}
|
439 |
+
$updates->response[$this->pluginFile] = $update->toWpFormat();
|
440 |
+
} else if (isset($updates, $updates->response)) {
|
441 |
+
unset($updates->response[$this->pluginFile]);
|
442 |
+
}
|
443 |
+
|
444 |
+
return $updates;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Get the details of the currently available update, if any.
|
449 |
+
*
|
450 |
+
* If no updates are available, or if the last known update version is below or equal
|
451 |
+
* to the currently installed version, this method will return NULL.
|
452 |
+
*
|
453 |
+
* Uses cached update data. To retrieve update information straight from
|
454 |
+
* the metadata URL, call requestUpdate() instead.
|
455 |
+
*
|
456 |
+
* @return PluginUpdate|null
|
457 |
+
*/
|
458 |
+
|
459 |
+
/**
|
460 |
+
*
|
461 |
+
* @return null
|
462 |
+
*/
|
463 |
+
public function getUpdate() {
|
464 |
+
$state = $this->getUpdateState();/** @var StdClass $state */
|
465 |
+
//Is there an update available insert?
|
466 |
+
if (!empty($state) && isset($state->update) && !empty($state->update)) {
|
467 |
+
$update = $state->update;
|
468 |
+
//Check if the update is actually newer than the currently installed version.
|
469 |
+
$installedVersion = $this->getInstalledVersion();
|
470 |
+
if (($installedVersion !== null) && version_compare($update->version, $installedVersion, '>')) {
|
471 |
+
return $update;
|
472 |
+
}
|
473 |
+
}
|
474 |
+
return null;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
|
479 |
+
* the new link will appear after the "Visit plugin site" link.
|
480 |
+
*
|
481 |
+
* You can change the link text by using the "puc_manual_check_link-$slug" filter.
|
482 |
+
* Returning an empty string from the filter will disable the link.
|
483 |
+
*
|
484 |
+
* @param array $pluginMeta Array of meta links.
|
485 |
+
* @param string $pluginFile
|
486 |
+
* @param array|null $pluginData Currently ignored.
|
487 |
+
* @param string|null $status Currently ignored.
|
488 |
+
* @return array
|
489 |
+
*/
|
490 |
+
|
491 |
+
/**
|
492 |
+
*
|
493 |
+
* @param type $pluginMeta
|
494 |
+
* @param type $pluginFile
|
495 |
+
* @param type $pluginData
|
496 |
+
* @param type $status
|
497 |
+
* @return type
|
498 |
+
*/
|
499 |
+
public function addCheckForUpdatesLink($pluginMeta, $pluginFile, $pluginData = null, $status = null) {
|
500 |
+
if ($pluginFile == $this->pluginFile && current_user_can('update_plugins')) {
|
501 |
+
$linkUrl = wp_nonce_url(
|
502 |
+
add_query_arg(
|
503 |
+
array(
|
504 |
+
'puc_check_for_updates' => 1,
|
505 |
+
'puc_slug' => $this->slug,
|
506 |
+
), is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
|
507 |
+
), 'puc_check_for_updates'
|
508 |
+
);
|
509 |
+
|
510 |
+
$linkText = apply_filters('puc_manual_check_link-' . $this->slug, 'Check for updates');
|
511 |
+
if (!empty($linkText)) {
|
512 |
+
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
|
513 |
+
}
|
514 |
+
}
|
515 |
+
return $pluginMeta;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Check for updates when the user clicks the "Check for updates" link.
|
520 |
+
* @see self::addCheckForUpdatesLink()
|
521 |
+
*
|
522 |
+
* @return void
|
523 |
+
*/
|
524 |
+
public function handleManualCheck() {
|
525 |
+
$shouldCheck =
|
526 |
+
isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
|
527 |
+
&& $_GET['puc_slug'] == $this->slug
|
528 |
+
&& current_user_can('update_plugins')
|
529 |
+
&& check_admin_referer('puc_check_for_updates');
|
530 |
+
|
531 |
+
if ($shouldCheck) {
|
532 |
+
$update = $this->checkForUpdates();
|
533 |
+
$status = ($update === null) ? 'no_update' : 'update_available';
|
534 |
+
wp_redirect(add_query_arg(
|
535 |
+
array(
|
536 |
+
'puc_update_check_result' => $status,
|
537 |
+
'puc_slug' => $this->slug,
|
538 |
+
), is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
|
539 |
+
));
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Display the results of a manual update check.
|
545 |
+
* @see self::handleManualCheck()
|
546 |
+
*
|
547 |
+
* You can change the result message by using the "puc_manual_check_message-$slug" filter.
|
548 |
+
*/
|
549 |
+
public function displayManualCheckResult() {
|
550 |
+
if (isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug)) {
|
551 |
+
$status = strval($_GET['puc_update_check_result']);
|
552 |
+
if ($status == 'no_update') {
|
553 |
+
$message = 'This plugin is up to date.';
|
554 |
+
} else if ($status == 'update_available') {
|
555 |
+
$message = 'A new version of this plugin is available.';
|
556 |
+
} else {
|
557 |
+
$message = sprintf('Unknown update checker status "%s"', htmlentities($status));
|
558 |
+
}
|
559 |
+
printf(
|
560 |
+
'<div class="updated"><p>%s</p></div>', apply_filters('puc_manual_check_message-' . $this->slug, $message, $status)
|
561 |
+
);
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Register a callback for filtering query arguments.
|
567 |
+
*
|
568 |
+
* The callback function should take one argument - an associative array of query arguments.
|
569 |
+
* It should return a modified array of query arguments.
|
570 |
+
*
|
571 |
+
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
572 |
+
*
|
573 |
+
* @param callable $callback
|
574 |
+
* @return void
|
575 |
+
*/
|
576 |
+
|
577 |
+
/**
|
578 |
+
*
|
579 |
+
* @param type $callback
|
580 |
+
*/
|
581 |
+
public function addQueryArgFilter($callback) {
|
582 |
+
add_filter('puc_request_info_query_args-' . $this->slug, $callback);
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Register a callback for filtering arguments passed to wp_remote_get().
|
587 |
+
*
|
588 |
+
* The callback function should take one argument - an associative array of arguments -
|
589 |
+
* and return a modified array or arguments. See the WP documentation on wp_remote_get()
|
590 |
+
* for details on what arguments are available and how they work.
|
591 |
+
*
|
592 |
+
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
593 |
+
*
|
594 |
+
* @param callable $callback
|
595 |
+
* @return void
|
596 |
+
*/
|
597 |
+
|
598 |
+
/**
|
599 |
+
*
|
600 |
+
* @param type $callback
|
601 |
+
*/
|
602 |
+
public function addHttpRequestArgFilter($callback) {
|
603 |
+
add_filter('puc_request_info_options-' . $this->slug, $callback);
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Register a callback for filtering the plugin info retrieved from the external API.
|
608 |
+
*
|
609 |
+
* The callback function should take two arguments. If the plugin info was retrieved
|
610 |
+
* successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
|
611 |
+
* it will be NULL. The second argument will be the corresponding return value of
|
612 |
+
* wp_remote_get (see WP docs for details).
|
613 |
+
*
|
614 |
+
* The callback function should return a new or modified instance of PluginInfo or NULL.
|
615 |
+
*
|
616 |
+
* @uses add_filter() This method is a convenience wrapper for add_filter().
|
617 |
+
*
|
618 |
+
* @param callable $callback
|
619 |
+
* @return void
|
620 |
+
*/
|
621 |
+
|
622 |
+
/**
|
623 |
+
*
|
624 |
+
* @param type $callback
|
625 |
+
*/
|
626 |
+
public function addResultFilter($callback) {
|
627 |
+
add_filter('puc_request_info_result-' . $this->slug, $callback, 10, 2);
|
628 |
+
}
|
629 |
+
|
630 |
+
/**
|
631 |
+
* Register a callback for one of the update checker filters.
|
632 |
+
*
|
633 |
+
* Identical to add_filter(), except it automatically adds the "puc_" prefix
|
634 |
+
* and the "-$plugin_slug" suffix to the filter name. For example, "request_info_result"
|
635 |
+
* becomes "puc_request_info_result-your_plugin_slug".
|
636 |
+
*
|
637 |
+
* @param string $tag
|
638 |
+
* @param callable $callback
|
639 |
+
* @param int $priority
|
640 |
+
* @param int $acceptedArgs
|
641 |
+
*/
|
642 |
+
|
643 |
+
/**
|
644 |
+
*
|
645 |
+
* @param type $tag
|
646 |
+
* @param type $callback
|
647 |
+
* @param type $priority
|
648 |
+
* @param type $acceptedArgs
|
649 |
+
*/
|
650 |
+
public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
|
651 |
+
add_filter('puc_' . $tag . '-' . $this->slug, $callback, $priority, $acceptedArgs);
|
652 |
+
}
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Initialize the update checker Debug Bar plugin/add-on thingy.
|
656 |
+
*/
|
657 |
+
public function initDebugBarPanel() {
|
658 |
+
if (class_exists('Debug_Bar')) {
|
659 |
+
require_once dirname(__FILE__) . '/debug-bar-plugin.php';
|
660 |
+
$this->debugBarPlugin = new PucDebugBarPlugin($this);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
}
|
665 |
+
|
666 |
?>
|
app/main/BPMediaLoader.php
CHANGED
@@ -13,106 +13,122 @@
|
|
13 |
*/
|
14 |
class BPMediaLoader {
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
public function load_component() {
|
41 |
-
global $bp;
|
42 |
-
$bp->{BP_MEDIA_SLUG} = new BPMediaComponent();
|
43 |
-
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
global $bp;
|
54 |
-
foreach ( $bp->bp_nav as $key => $nav_item ) {
|
55 |
-
switch ( $nav_item[ 'slug' ] ) {
|
56 |
-
case BP_MEDIA_IMAGES_SLUG:
|
57 |
-
case BP_MEDIA_VIDEOS_SLUG:
|
58 |
-
case BP_MEDIA_AUDIO_SLUG:
|
59 |
-
case BP_MEDIA_ALBUMS_SLUG:
|
60 |
-
$bp->bp_options_nav[ BP_MEDIA_SLUG ][ ] = array(
|
61 |
-
'name' => $nav_item[ 'name' ],
|
62 |
-
'link' => (isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : (isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '')) . $nav_item[ 'slug' ] . '/',
|
63 |
-
'slug' => $nav_item[ 'slug' ],
|
64 |
-
'css_id' => $nav_item[ 'css_id' ],
|
65 |
-
'position' => $nav_item[ 'position' ],
|
66 |
-
'screen_function' => $nav_item[ 'screen_function' ],
|
67 |
-
'user_has_access' => true,
|
68 |
-
'parent_url' => trailingslashit( bp_displayed_user_domain() )
|
69 |
-
);
|
70 |
-
unset( $bp->bp_nav[ $key ] );
|
71 |
-
break;
|
72 |
-
case BP_MEDIA_UPLOAD_SLUG:
|
73 |
-
$bp->bp_options_nav[ BP_MEDIA_SLUG ][ ] = array(
|
74 |
-
'name' => $nav_item[ 'name' ],
|
75 |
-
'link' => (isset( $bp->displayed_user->domain ) ? $bp->displayed_user->domain : (isset( $bp->loggedin_user->domain ) ? $bp->loggedin_user->domain : '')) . $nav_item[ 'slug' ] . '/',
|
76 |
-
'slug' => $nav_item[ 'slug' ],
|
77 |
-
'css_id' => $nav_item[ 'css_id' ],
|
78 |
-
'position' => $nav_item[ 'position' ],
|
79 |
-
'screen_function' => $nav_item[ 'screen_function' ],
|
80 |
-
'user_has_access' => bp_is_my_profile(),
|
81 |
-
'parent_url' => trailingslashit( bp_displayed_user_domain() )
|
82 |
-
);
|
83 |
-
unset( $bp->bp_nav[ $key ] );
|
84 |
-
}
|
85 |
-
switch ( $bp->current_component ) {
|
86 |
-
case BP_MEDIA_IMAGES_SLUG:
|
87 |
-
case BP_MEDIA_VIDEOS_SLUG:
|
88 |
-
case BP_MEDIA_AUDIO_SLUG:
|
89 |
-
case BP_MEDIA_ALBUMS_SLUG:
|
90 |
-
case BP_MEDIA_UPLOAD_SLUG:
|
91 |
-
$count = count( $bp->action_variables );
|
92 |
-
for ( $i = $count; $i > 0; $i -- ) {
|
93 |
-
$bp->action_variables[ $i ] = $bp->action_variables[ $i - 1 ];
|
94 |
-
}
|
95 |
-
$bp->action_variables[ 0 ] = $bp->current_action;
|
96 |
-
$bp->current_action = $bp->current_component;
|
97 |
-
$bp->current_component = BP_MEDIA_SLUG;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
}
|
101 |
-
/**
|
102 |
-
* Custom Thumbnail Sizes
|
103 |
-
*
|
104 |
-
* Adds image sizes required by the plugin to existing WordPress sizes
|
105 |
-
*
|
106 |
-
* @global object $bp_media
|
107 |
-
*/
|
108 |
-
public function thumbnail() {
|
109 |
-
global $bp_media;
|
110 |
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
}
|
118 |
|
13 |
*/
|
14 |
class BPMediaLoader {
|
15 |
|
16 |
+
/**
|
17 |
+
* Hooks into BuddyPress
|
18 |
+
*
|
19 |
+
* Hooks into bp_loaded to load itself
|
20 |
+
* Hooks into bp_setup_nav to add tabs to the profile and group navigation
|
21 |
+
* Hooks into after_setup_theme to add its thumbnail sizes
|
22 |
+
*
|
23 |
+
* @uses bp_loaded
|
24 |
+
* @uses bp_setup_nav
|
25 |
+
* @uses after_setup_theme
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
add_action('bp_loaded', array($this, 'load_component'));
|
29 |
+
add_action('bp_setup_nav', array($this, 'custom_nav'), 999);
|
30 |
+
add_action('after_setup_theme', array($this, 'thumbnail'));
|
31 |
+
}
|
32 |
|
33 |
+
/**
|
34 |
+
* BuddyPress Media Loader
|
35 |
+
*
|
36 |
+
* Loads and adds it to the BuddyPress global object
|
37 |
+
*
|
38 |
+
* @global object $bp BuddyPress object
|
39 |
+
*/
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @global object $bp
|
44 |
+
*/
|
45 |
+
public function load_component() {
|
46 |
+
global $bp;
|
47 |
+
$bp->{BP_MEDIA_SLUG} = new BPMediaComponent();
|
48 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
/**
|
51 |
+
* Navigation Loader
|
52 |
+
*
|
53 |
+
* Loads BuddyPress Media's navigation
|
54 |
+
*
|
55 |
+
* @global object $bp BuddyPress object
|
56 |
+
*/
|
57 |
|
58 |
+
/**
|
59 |
+
*
|
60 |
+
* @global object $bp
|
61 |
+
*/
|
62 |
+
public function custom_nav() {
|
63 |
+
global $bp;
|
64 |
+
foreach ($bp->bp_nav as $key => $nav_item) {
|
65 |
+
switch ($nav_item['slug']) {
|
66 |
+
case BP_MEDIA_IMAGES_SLUG:
|
67 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
68 |
+
case BP_MEDIA_AUDIO_SLUG:
|
69 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
70 |
+
$bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
|
71 |
+
'name' => $nav_item['name'],
|
72 |
+
'link' => (isset($bp->displayed_user->domain) ? $bp->displayed_user->domain : (isset($bp->loggedin_user->domain) ? $bp->loggedin_user->domain : '')) . $nav_item['slug'] . '/',
|
73 |
+
'slug' => $nav_item['slug'],
|
74 |
+
'css_id' => $nav_item['css_id'],
|
75 |
+
'position' => $nav_item['position'],
|
76 |
+
'screen_function' => $nav_item['screen_function'],
|
77 |
+
'user_has_access' => true,
|
78 |
+
'parent_url' => trailingslashit(bp_displayed_user_domain())
|
79 |
+
);
|
80 |
+
unset($bp->bp_nav[$key]);
|
81 |
+
break;
|
82 |
+
case BP_MEDIA_UPLOAD_SLUG:
|
83 |
+
$bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
|
84 |
+
'name' => $nav_item['name'],
|
85 |
+
'link' => (isset($bp->displayed_user->domain) ? $bp->displayed_user->domain : (isset($bp->loggedin_user->domain) ? $bp->loggedin_user->domain : '')) . $nav_item['slug'] . '/',
|
86 |
+
'slug' => $nav_item['slug'],
|
87 |
+
'css_id' => $nav_item['css_id'],
|
88 |
+
'position' => $nav_item['position'],
|
89 |
+
'screen_function' => $nav_item['screen_function'],
|
90 |
+
'user_has_access' => bp_is_my_profile(),
|
91 |
+
'parent_url' => trailingslashit(bp_displayed_user_domain())
|
92 |
+
);
|
93 |
+
unset($bp->bp_nav[$key]);
|
94 |
+
}
|
95 |
+
switch ($bp->current_component) {
|
96 |
+
case BP_MEDIA_IMAGES_SLUG:
|
97 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
98 |
+
case BP_MEDIA_AUDIO_SLUG:
|
99 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
100 |
+
case BP_MEDIA_UPLOAD_SLUG:
|
101 |
+
$count = count($bp->action_variables);
|
102 |
+
for ($i = $count; $i > 0; $i--) {
|
103 |
+
$bp->action_variables[$i] = $bp->action_variables[$i - 1];
|
104 |
+
}
|
105 |
+
$bp->action_variables[0] = $bp->current_action;
|
106 |
+
$bp->current_action = $bp->current_component;
|
107 |
+
$bp->current_component = BP_MEDIA_SLUG;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Custom Thumbnail Sizes
|
114 |
+
*
|
115 |
+
* Adds image sizes required by the plugin to existing WordPress sizes
|
116 |
+
*
|
117 |
+
* @global object $bp_media
|
118 |
+
*/
|
119 |
+
|
120 |
+
/**
|
121 |
+
*
|
122 |
+
* @global type $bp_media
|
123 |
+
*/
|
124 |
+
public function thumbnail() {
|
125 |
+
global $bp_media;
|
126 |
+
|
127 |
+
$default_sizes = $bp_media->media_sizes();
|
128 |
+
|
129 |
+
add_image_size('bp_media_activity_image', $default_sizes['activity_image']['width'], $default_sizes['activity_image']['height'], true);
|
130 |
+
add_image_size('bp_media_single_image', $default_sizes['single_image']['width'], $default_sizes['single_image']['height'], true);
|
131 |
+
}
|
132 |
|
133 |
}
|
134 |
|
app/main/BuddyPressMedia.php
CHANGED
@@ -48,9 +48,9 @@ class BuddyPressMedia {
|
|
48 |
*/
|
49 |
add_action('bp_include', array($this, 'init'));
|
50 |
add_action('widgets_init', array($this, 'widgets_init'), 1);
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
}
|
55 |
|
56 |
public function bp_exists() {
|
@@ -191,6 +191,10 @@ class BuddyPressMedia {
|
|
191 |
define('BP_MEDIA_SUPPORT_EMAIL', $this->support_email);
|
192 |
}
|
193 |
|
|
|
|
|
|
|
|
|
194 |
function init() {
|
195 |
$this->get_option();
|
196 |
|
@@ -209,13 +213,19 @@ class BuddyPressMedia {
|
|
209 |
$bp_media_admin = new BPMediaAdmin();
|
210 |
}
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
function settings_link($links, $file) {
|
217 |
/* create link */
|
218 |
-
$plugin_name = plugin_basename(BP_MEDIA_PATH.'index.php');
|
219 |
$admin_link = $this->get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php'));
|
220 |
if ($file == $plugin_name) {
|
221 |
array_unshift(
|
@@ -225,6 +235,10 @@ class BuddyPressMedia {
|
|
225 |
return $links;
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
228 |
function media_sizes() {
|
229 |
$def_sizes = array(
|
230 |
'activity_image' => array(
|
@@ -254,6 +268,10 @@ class BuddyPressMedia {
|
|
254 |
return apply_filters('bpm_media_sizes', $def_sizes);
|
255 |
}
|
256 |
|
|
|
|
|
|
|
|
|
257 |
function excerpt_lengths() {
|
258 |
global $bp_media_default_excerpts;
|
259 |
$def_excerpt = array(
|
@@ -266,6 +284,10 @@ class BuddyPressMedia {
|
|
266 |
$bp_media_default_excerpts = apply_filters('bpm_excerpt_lengths', $def_excerpt);
|
267 |
}
|
268 |
|
|
|
|
|
|
|
|
|
269 |
public function admin_notice() {
|
270 |
global $current_user;
|
271 |
$user_id = $current_user->ID;
|
@@ -302,6 +324,12 @@ class BuddyPressMedia {
|
|
302 |
}
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
function get_admin_url($path = '', $scheme = 'admin') {
|
306 |
|
307 |
// Links belong in network admin
|
48 |
*/
|
49 |
add_action('bp_include', array($this, 'init'));
|
50 |
add_action('widgets_init', array($this, 'widgets_init'), 1);
|
51 |
+
add_action('plugins_loaded', array($this, 'load_translation'));
|
52 |
+
global $bp_media_counter;
|
53 |
+
$bp_media_counter = 0;
|
54 |
}
|
55 |
|
56 |
public function bp_exists() {
|
191 |
define('BP_MEDIA_SUPPORT_EMAIL', $this->support_email);
|
192 |
}
|
193 |
|
194 |
+
/**
|
195 |
+
*
|
196 |
+
* @global BPMediaAdmin $bp_media_admin
|
197 |
+
*/
|
198 |
function init() {
|
199 |
$this->get_option();
|
200 |
|
213 |
$bp_media_admin = new BPMediaAdmin();
|
214 |
}
|
215 |
|
216 |
+
static function load_translation() {
|
217 |
+
load_plugin_textdomain(BP_MEDIA_TXT_DOMAIN, false, basename(BP_MEDIA_PATH) . '/languages/');
|
218 |
+
}
|
219 |
|
220 |
+
/**
|
221 |
+
*
|
222 |
+
* @param type $links
|
223 |
+
* @param type $file
|
224 |
+
* @return type
|
225 |
+
*/
|
226 |
function settings_link($links, $file) {
|
227 |
/* create link */
|
228 |
+
$plugin_name = plugin_basename(BP_MEDIA_PATH . 'index.php');
|
229 |
$admin_link = $this->get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php'));
|
230 |
if ($file == $plugin_name) {
|
231 |
array_unshift(
|
235 |
return $links;
|
236 |
}
|
237 |
|
238 |
+
/**
|
239 |
+
*
|
240 |
+
* @return type
|
241 |
+
*/
|
242 |
function media_sizes() {
|
243 |
$def_sizes = array(
|
244 |
'activity_image' => array(
|
268 |
return apply_filters('bpm_media_sizes', $def_sizes);
|
269 |
}
|
270 |
|
271 |
+
/**
|
272 |
+
*
|
273 |
+
* @global type $bp_media_default_excerpts
|
274 |
+
*/
|
275 |
function excerpt_lengths() {
|
276 |
global $bp_media_default_excerpts;
|
277 |
$def_excerpt = array(
|
284 |
$bp_media_default_excerpts = apply_filters('bpm_excerpt_lengths', $def_excerpt);
|
285 |
}
|
286 |
|
287 |
+
/**
|
288 |
+
*
|
289 |
+
* @global type $current_user
|
290 |
+
*/
|
291 |
public function admin_notice() {
|
292 |
global $current_user;
|
293 |
$user_id = $current_user->ID;
|
324 |
}
|
325 |
}
|
326 |
|
327 |
+
/**
|
328 |
+
*
|
329 |
+
* @param type $path
|
330 |
+
* @param type $scheme
|
331 |
+
* @return type
|
332 |
+
*/
|
333 |
function get_admin_url($path = '', $scheme = 'admin') {
|
334 |
|
335 |
// Links belong in network admin
|
app/main/group/BPMediaGroup.php
CHANGED
@@ -29,6 +29,12 @@ class BPMediaGroup {
|
|
29 |
*
|
30 |
* @since BuddyPress Media 2.3
|
31 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
function custom_nav() {
|
33 |
global $bp;
|
34 |
$current_group = isset($bp->groups->current_group->slug) ? $bp->groups->current_group->slug : null;
|
@@ -72,6 +78,13 @@ class BPMediaGroup {
|
|
72 |
*
|
73 |
* @since BuddyPress Media 2.3
|
74 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
function multipart_params_handler($multipart_params) {
|
76 |
if (is_array($multipart_params)) {
|
77 |
global $bp;
|
@@ -92,12 +105,18 @@ class BPMediaGroup {
|
|
92 |
*
|
93 |
* @since BuddyPress Media 2.3
|
94 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
static function navigation_menu() {
|
96 |
global $bp;
|
97 |
if (!isset($bp->current_action) || $bp->current_action != BP_MEDIA_SLUG)
|
98 |
return false;
|
99 |
-
$bp_media_upload = new BPMediaUploadScreen(
|
100 |
-
$bp_media_image = new BPMediaScreen(
|
101 |
$current_tab = BP_MEDIA_IMAGES_SLUG;
|
102 |
|
103 |
if (isset($bp->action_variables[0])) {
|
@@ -105,18 +124,18 @@ class BPMediaGroup {
|
|
105 |
}
|
106 |
|
107 |
// if (BPMediaGroup::can_upload()) {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
// } else {
|
114 |
// $bp_media_nav = array();
|
115 |
// }
|
116 |
|
117 |
foreach (array('VIDEOS', 'AUDIO', 'ALBUMS', 'UPLOAD') as $type) {
|
118 |
-
if (
|
119 |
-
if (
|
120 |
$bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array(
|
121 |
'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'),
|
122 |
'label' => constant('BP_MEDIA_' . $type . '_LABEL'),
|
@@ -153,6 +172,12 @@ class BPMediaGroup {
|
|
153 |
*
|
154 |
* @since BuddyPress Media 2.3
|
155 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
static function can_upload() {
|
157 |
/** @todo Implementation Pending */
|
158 |
global $bp;
|
@@ -172,6 +197,12 @@ class BPMediaGroup {
|
|
172 |
*
|
173 |
* @since BuddyPress Media 2.3
|
174 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
function admin_bar() {
|
176 |
global $wp_admin_bar, $bp;
|
177 |
$wp_admin_bar->add_menu(array(
|
@@ -195,6 +226,13 @@ class BPMediaGroup {
|
|
195 |
*
|
196 |
* @return boolean True if the user can create an album in the group, false if not
|
197 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
static function user_can_create_album($group_id, $user_id = 0) {
|
199 |
if ($user_id == 0)
|
200 |
$user_id = get_current_user_id();
|
@@ -215,11 +253,15 @@ class BPMediaGroup {
|
|
215 |
return false;
|
216 |
}
|
217 |
|
|
|
|
|
|
|
|
|
218 |
static function bp_media_display_error($errorMessage) {
|
219 |
?>
|
220 |
<div id="message" class="error">
|
221 |
<p>
|
222 |
-
|
223 |
</p>
|
224 |
</div>
|
225 |
<?php
|
29 |
*
|
30 |
* @since BuddyPress Media 2.3
|
31 |
*/
|
32 |
+
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @global type $bp
|
36 |
+
* @return type
|
37 |
+
*/
|
38 |
function custom_nav() {
|
39 |
global $bp;
|
40 |
$current_group = isset($bp->groups->current_group->slug) ? $bp->groups->current_group->slug : null;
|
78 |
*
|
79 |
* @since BuddyPress Media 2.3
|
80 |
*/
|
81 |
+
|
82 |
+
/**
|
83 |
+
*
|
84 |
+
* @global type $bp
|
85 |
+
* @param type $multipart_params
|
86 |
+
* @return type
|
87 |
+
*/
|
88 |
function multipart_params_handler($multipart_params) {
|
89 |
if (is_array($multipart_params)) {
|
90 |
global $bp;
|
105 |
*
|
106 |
* @since BuddyPress Media 2.3
|
107 |
*/
|
108 |
+
|
109 |
+
/**
|
110 |
+
*
|
111 |
+
* @global type $bp
|
112 |
+
* @return boolean
|
113 |
+
*/
|
114 |
static function navigation_menu() {
|
115 |
global $bp;
|
116 |
if (!isset($bp->current_action) || $bp->current_action != BP_MEDIA_SLUG)
|
117 |
return false;
|
118 |
+
$bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG);
|
119 |
+
$bp_media_image = new BPMediaScreen('image', BP_MEDIA_IMAGES_SLUG);
|
120 |
$current_tab = BP_MEDIA_IMAGES_SLUG;
|
121 |
|
122 |
if (isset($bp->action_variables[0])) {
|
124 |
}
|
125 |
|
126 |
// if (BPMediaGroup::can_upload()) {
|
127 |
+
$bp_media_nav[BP_MEDIA_IMAGES_SLUG] = array(
|
128 |
+
'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . BP_MEDIA_SLUG,
|
129 |
+
'label' => BP_MEDIA_IMAGES_LABEL,
|
130 |
+
'screen_function' => array($bp_media_image, 'screen')
|
131 |
+
);
|
132 |
// } else {
|
133 |
// $bp_media_nav = array();
|
134 |
// }
|
135 |
|
136 |
foreach (array('VIDEOS', 'AUDIO', 'ALBUMS', 'UPLOAD') as $type) {
|
137 |
+
if ($type == 'UPLOAD') {
|
138 |
+
if (BPMediaGroup::can_upload()) {
|
139 |
$bp_media_nav[constant('BP_MEDIA_' . $type . '_SLUG')] = array(
|
140 |
'url' => trailingslashit(bp_get_group_permalink($bp->groups->current_group)) . constant('BP_MEDIA_' . $type . '_SLUG'),
|
141 |
'label' => constant('BP_MEDIA_' . $type . '_LABEL'),
|
172 |
*
|
173 |
* @since BuddyPress Media 2.3
|
174 |
*/
|
175 |
+
|
176 |
+
/**
|
177 |
+
*
|
178 |
+
* @global type $bp
|
179 |
+
* @return boolean
|
180 |
+
*/
|
181 |
static function can_upload() {
|
182 |
/** @todo Implementation Pending */
|
183 |
global $bp;
|
197 |
*
|
198 |
* @since BuddyPress Media 2.3
|
199 |
*/
|
200 |
+
|
201 |
+
/**
|
202 |
+
*
|
203 |
+
* @global type $wp_admin_bar
|
204 |
+
* @global type $bp
|
205 |
+
*/
|
206 |
function admin_bar() {
|
207 |
global $wp_admin_bar, $bp;
|
208 |
$wp_admin_bar->add_menu(array(
|
226 |
*
|
227 |
* @return boolean True if the user can create an album in the group, false if not
|
228 |
*/
|
229 |
+
|
230 |
+
/**
|
231 |
+
*
|
232 |
+
* @param type $group_id
|
233 |
+
* @param type $user_id
|
234 |
+
* @return boolean
|
235 |
+
*/
|
236 |
static function user_can_create_album($group_id, $user_id = 0) {
|
237 |
if ($user_id == 0)
|
238 |
$user_id = get_current_user_id();
|
253 |
return false;
|
254 |
}
|
255 |
|
256 |
+
/**
|
257 |
+
*
|
258 |
+
* @param type $errorMessage
|
259 |
+
*/
|
260 |
static function bp_media_display_error($errorMessage) {
|
261 |
?>
|
262 |
<div id="message" class="error">
|
263 |
<p>
|
264 |
+
<?php _e($errorMessage, BP_MEDIA_TXT_DOMAIN); ?>
|
265 |
</p>
|
266 |
</div>
|
267 |
<?php
|
app/main/group/BPMediaGroupAction.php
CHANGED
@@ -6,7 +6,6 @@
|
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class BPMediaGroupAction {
|
9 |
-
|
10 |
/**
|
11 |
* Called on bp_init by screen functions
|
12 |
*
|
@@ -14,6 +13,13 @@ class BPMediaGroupAction {
|
|
14 |
*
|
15 |
* @since BuddyPress Media 2.0
|
16 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
static function bp_media_groups_set_query() {
|
18 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
19 |
if (isset($bp->current_action) && $bp->current_action == BP_MEDIA_SLUG) {
|
@@ -65,6 +71,12 @@ class BPMediaGroupAction {
|
|
65 |
*
|
66 |
* @since BuddyPress Media 2.2
|
67 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
static function bp_media_groups_albums_set_query() {
|
69 |
global $bp, $bp_media_albums_query;
|
70 |
if (isset($bp->action_variables) && isset($bp->action_variables[1]) && $bp->action_variables[1] == 'page' && isset($bp->action_variables[2]) && is_numeric($bp->action_variables[2])) {
|
@@ -82,10 +94,15 @@ class BPMediaGroupAction {
|
|
82 |
'meta_compare' => '='
|
83 |
);
|
84 |
$bp_media_albums_query = new WP_Query($args);
|
85 |
-
|
86 |
}
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
static function bp_media_groups_activity_create_after_add_media($media, $hidden = false) {
|
90 |
if (function_exists('bp_activity_add')) {
|
91 |
if (!is_object($media)) {
|
@@ -114,7 +131,15 @@ class BPMediaGroupAction {
|
|
114 |
}
|
115 |
|
116 |
//add_action('bp_media_groups_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
|
|
|
|
|
|
|
|
|
117 |
|
|
|
|
|
|
|
|
|
118 |
static function bp_media_groups_redirection_handler() {
|
119 |
global $bp;
|
120 |
echo '<pre>';
|
@@ -124,7 +149,10 @@ class BPMediaGroupAction {
|
|
124 |
}
|
125 |
|
126 |
//add_action('bp_media_init','bp_media_groups_redirection_handler');
|
127 |
-
|
|
|
|
|
|
|
128 |
static function bp_media_groups_force_hide_activity() {
|
129 |
return true;
|
130 |
}
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class BPMediaGroupAction {
|
|
|
9 |
/**
|
10 |
* Called on bp_init by screen functions
|
11 |
*
|
13 |
*
|
14 |
* @since BuddyPress Media 2.0
|
15 |
*/
|
16 |
+
|
17 |
+
/**
|
18 |
+
*
|
19 |
+
* @global type $bp
|
20 |
+
* @global WP_Query $bp_media_query
|
21 |
+
* @global type $bp_media_posts_per_page
|
22 |
+
*/
|
23 |
static function bp_media_groups_set_query() {
|
24 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
25 |
if (isset($bp->current_action) && $bp->current_action == BP_MEDIA_SLUG) {
|
71 |
*
|
72 |
* @since BuddyPress Media 2.2
|
73 |
*/
|
74 |
+
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
* @global type $bp
|
78 |
+
* @global WP_Query $bp_media_albums_query
|
79 |
+
*/
|
80 |
static function bp_media_groups_albums_set_query() {
|
81 |
global $bp, $bp_media_albums_query;
|
82 |
if (isset($bp->action_variables) && isset($bp->action_variables[1]) && $bp->action_variables[1] == 'page' && isset($bp->action_variables[2]) && is_numeric($bp->action_variables[2])) {
|
94 |
'meta_compare' => '='
|
95 |
);
|
96 |
$bp_media_albums_query = new WP_Query($args);
|
|
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
*
|
102 |
+
* @param BPMediaHostWordpress $media
|
103 |
+
* @param type $hidden
|
104 |
+
* @return boolean
|
105 |
+
*/
|
106 |
static function bp_media_groups_activity_create_after_add_media($media, $hidden = false) {
|
107 |
if (function_exists('bp_activity_add')) {
|
108 |
if (!is_object($media)) {
|
131 |
}
|
132 |
|
133 |
//add_action('bp_media_groups_after_add_media','bp_media_groups_activity_create_after_add_media',10,2);
|
134 |
+
/**
|
135 |
+
*
|
136 |
+
* @global type $bp
|
137 |
+
*/
|
138 |
|
139 |
+
/**
|
140 |
+
*
|
141 |
+
* @global type $bp
|
142 |
+
*/
|
143 |
static function bp_media_groups_redirection_handler() {
|
144 |
global $bp;
|
145 |
echo '<pre>';
|
149 |
}
|
150 |
|
151 |
//add_action('bp_media_init','bp_media_groups_redirection_handler');
|
152 |
+
/**
|
153 |
+
*
|
154 |
+
* @return boolean
|
155 |
+
*/
|
156 |
static function bp_media_groups_force_hide_activity() {
|
157 |
return true;
|
158 |
}
|
app/main/group/BPMediaGroupElementExtension.php
CHANGED
@@ -11,11 +11,23 @@ if (class_exists('BP_Group_Extension')) :
|
|
11 |
var $enable_edit_item = false;
|
12 |
var $enable_create_step = false;
|
13 |
|
|
|
|
|
|
|
|
|
|
|
14 |
function __construct($name, $slug) {
|
15 |
$this->name = $name;
|
16 |
$this->slug = $slug;
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
function display() {
|
20 |
global $bp;
|
21 |
BPMediaGroupAction::bp_media_groups_set_query();
|
@@ -26,7 +38,7 @@ if (class_exists('BP_Group_Extension')) :
|
|
26 |
BPMediaGroup::navigation_menu();
|
27 |
$media_type = "";
|
28 |
$slug = "";
|
29 |
-
switch (
|
30 |
case BP_MEDIA_IMAGES_SLUG:
|
31 |
$media_type = "image";
|
32 |
$slug = BP_MEDIA_IMAGES_SLUG;
|
@@ -73,7 +85,7 @@ if (class_exists('BP_Group_Extension')) :
|
|
73 |
}
|
74 |
if ($media_type == "album") {
|
75 |
$bp_media_content = new BPMediaAlbumScreen($media_type, BP_MEDIA_ALBUMS_ENTRY_SLUG);
|
76 |
-
$bp->action_variables[
|
77 |
$bp_media_content->entry_screen();
|
78 |
} else {
|
79 |
$bp_media_content = new BPMediaScreen($media_type, $slug);
|
@@ -90,7 +102,7 @@ if (class_exists('BP_Group_Extension')) :
|
|
90 |
BPMediaGroupAction::bp_media_groups_albums_set_query();
|
91 |
$bp_media_content = new BPMediaAlbumScreen($media_type, $slug);
|
92 |
$bp_media_content->screen_content();
|
93 |
-
} else if (
|
94 |
if (BPMediaGroup::can_upload()) {
|
95 |
$bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG);
|
96 |
$bp_media_upload->upload_screen_content();
|
@@ -104,9 +116,13 @@ if (class_exists('BP_Group_Extension')) :
|
|
104 |
}
|
105 |
|
106 |
function widget_display() {
|
107 |
-
|
108 |
}
|
109 |
|
|
|
|
|
|
|
|
|
110 |
function bp_media_display_error($errorMessage) {
|
111 |
?>
|
112 |
<div id="message" class="error">
|
11 |
var $enable_edit_item = false;
|
12 |
var $enable_create_step = false;
|
13 |
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @param type $name
|
17 |
+
* @param type $slug
|
18 |
+
*/
|
19 |
function __construct($name, $slug) {
|
20 |
$this->name = $name;
|
21 |
$this->slug = $slug;
|
22 |
}
|
23 |
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @global type $bp
|
27 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
28 |
+
* @return type
|
29 |
+
* @throws Exception
|
30 |
+
*/
|
31 |
function display() {
|
32 |
global $bp;
|
33 |
BPMediaGroupAction::bp_media_groups_set_query();
|
38 |
BPMediaGroup::navigation_menu();
|
39 |
$media_type = "";
|
40 |
$slug = "";
|
41 |
+
switch ($current_tab) {
|
42 |
case BP_MEDIA_IMAGES_SLUG:
|
43 |
$media_type = "image";
|
44 |
$slug = BP_MEDIA_IMAGES_SLUG;
|
85 |
}
|
86 |
if ($media_type == "album") {
|
87 |
$bp_media_content = new BPMediaAlbumScreen($media_type, BP_MEDIA_ALBUMS_ENTRY_SLUG);
|
88 |
+
$bp->action_variables[0] = BP_MEDIA_ALBUMS_ENTRY_SLUG;
|
89 |
$bp_media_content->entry_screen();
|
90 |
} else {
|
91 |
$bp_media_content = new BPMediaScreen($media_type, $slug);
|
102 |
BPMediaGroupAction::bp_media_groups_albums_set_query();
|
103 |
$bp_media_content = new BPMediaAlbumScreen($media_type, $slug);
|
104 |
$bp_media_content->screen_content();
|
105 |
+
} else if ($media_type == 'upload') {
|
106 |
if (BPMediaGroup::can_upload()) {
|
107 |
$bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG);
|
108 |
$bp_media_upload->upload_screen_content();
|
116 |
}
|
117 |
|
118 |
function widget_display() {
|
119 |
+
|
120 |
}
|
121 |
|
122 |
+
/**
|
123 |
+
*
|
124 |
+
* @param type $errorMessage
|
125 |
+
*/
|
126 |
function bp_media_display_error($errorMessage) {
|
127 |
?>
|
128 |
<div id="message" class="error">
|
app/main/group/BPMediaGroupsExtension.php
CHANGED
@@ -7,7 +7,6 @@
|
|
7 |
if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems during upgrade or when Groups are disabled
|
8 |
|
9 |
class BPMediaGroupsExtension extends BPMediaGroupElementExtension {
|
10 |
-
|
11 |
/**
|
12 |
* Constructor for the BP_Group_Extension adding values to the variables defined
|
13 |
*
|
@@ -15,14 +14,24 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
15 |
*
|
16 |
* @since BuddyPress Media 2.3
|
17 |
*/
|
|
|
|
|
|
|
|
|
|
|
18 |
function __construct() {
|
19 |
global $bp;
|
20 |
-
$this->name = __(BP_MEDIA_LABEL,BP_MEDIA_TXT_DOMAIN);
|
21 |
$this->slug = BP_MEDIA_SLUG;
|
22 |
$this->create_step_position = 21;
|
23 |
$this->nav_item_position = 31;
|
24 |
-
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
function create_screen() {
|
27 |
global $bp_media;
|
28 |
if (!bp_is_group_creation_step($this->slug))
|
@@ -49,6 +58,10 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
49 |
wp_nonce_field('groups_create_save_' . $this->slug);
|
50 |
}
|
51 |
|
|
|
|
|
|
|
|
|
52 |
function create_screen_save() {
|
53 |
global $bp;
|
54 |
|
@@ -59,6 +72,11 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
59 |
groups_update_groupmeta($bp->groups->new_group_id, 'bp_media_group_control_level', $_POST['bp_album_creation_control']);
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
function edit_screen() {
|
63 |
global $bp_media;
|
64 |
if (!bp_is_group_admin_screen($this->slug))
|
@@ -88,6 +106,12 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
88 |
wp_nonce_field('groups_edit_save_' . $this->slug);
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
function edit_screen_save() {
|
92 |
global $bp, $bp_media;
|
93 |
|
@@ -115,6 +139,11 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
115 |
*
|
116 |
* @since BuddyPress Media 2.3
|
117 |
*/
|
|
|
|
|
|
|
|
|
|
|
118 |
function widget_display() {
|
119 |
global $bp_media;
|
120 |
?>
|
@@ -128,9 +157,11 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
128 |
<?php
|
129 |
}
|
130 |
|
|
|
131 |
|
|
|
132 |
|
133 |
-
|
134 |
|
135 |
|
136 |
endif; // class_exists( 'BP_Group_Extension' )
|
7 |
if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems during upgrade or when Groups are disabled
|
8 |
|
9 |
class BPMediaGroupsExtension extends BPMediaGroupElementExtension {
|
|
|
10 |
/**
|
11 |
* Constructor for the BP_Group_Extension adding values to the variables defined
|
12 |
*
|
14 |
*
|
15 |
* @since BuddyPress Media 2.3
|
16 |
*/
|
17 |
+
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
* @global type $bp
|
21 |
+
*/
|
22 |
function __construct() {
|
23 |
global $bp;
|
24 |
+
$this->name = __(BP_MEDIA_LABEL, BP_MEDIA_TXT_DOMAIN);
|
25 |
$this->slug = BP_MEDIA_SLUG;
|
26 |
$this->create_step_position = 21;
|
27 |
$this->nav_item_position = 31;
|
28 |
+
}
|
29 |
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @global type $bp_media
|
33 |
+
* @return boolean
|
34 |
+
*/
|
35 |
function create_screen() {
|
36 |
global $bp_media;
|
37 |
if (!bp_is_group_creation_step($this->slug))
|
58 |
wp_nonce_field('groups_create_save_' . $this->slug);
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @global type $bp
|
64 |
+
*/
|
65 |
function create_screen_save() {
|
66 |
global $bp;
|
67 |
|
72 |
groups_update_groupmeta($bp->groups->new_group_id, 'bp_media_group_control_level', $_POST['bp_album_creation_control']);
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
* @global type $bp_media
|
78 |
+
* @return boolean
|
79 |
+
*/
|
80 |
function edit_screen() {
|
81 |
global $bp_media;
|
82 |
if (!bp_is_group_admin_screen($this->slug))
|
106 |
wp_nonce_field('groups_edit_save_' . $this->slug);
|
107 |
}
|
108 |
|
109 |
+
/**
|
110 |
+
*
|
111 |
+
* @global type $bp
|
112 |
+
* @global type $bp_media
|
113 |
+
* @return boolean
|
114 |
+
*/
|
115 |
function edit_screen_save() {
|
116 |
global $bp, $bp_media;
|
117 |
|
139 |
*
|
140 |
* @since BuddyPress Media 2.3
|
141 |
*/
|
142 |
+
|
143 |
+
/**
|
144 |
+
*
|
145 |
+
* @global type $bp_media
|
146 |
+
*/
|
147 |
function widget_display() {
|
148 |
global $bp_media;
|
149 |
?>
|
157 |
<?php
|
158 |
}
|
159 |
|
160 |
+
}
|
161 |
|
162 |
+
|
163 |
|
164 |
+
|
165 |
|
166 |
|
167 |
endif; // class_exists( 'BP_Group_Extension' )
|
app/main/group/dummy/BPMediaGroupAlbum.php
CHANGED
@@ -1,17 +1,20 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Description of BPMediaGroupImage
|
4 |
*
|
5 |
* @author faishal
|
6 |
*/
|
7 |
-
if (
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
function __construct() {
|
11 |
-
parent::__construct(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_ALBUMS_SLUG);
|
12 |
-
bp_register_group_extension("BPMediaGroupAlbum");
|
13 |
}
|
14 |
|
15 |
-
|
16 |
-
endif;
|
17 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Description of BPMediaGroupImage
|
5 |
*
|
6 |
* @author faishal
|
7 |
*/
|
8 |
+
if (class_exists('BP_Group_Extension')) :
|
9 |
+
|
10 |
+
class BPMediaGroupAlbum extends BPMediaGroupElementExtension {
|
11 |
+
|
12 |
+
function __construct() {
|
13 |
+
parent::__construct(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_ALBUMS_SLUG);
|
14 |
+
bp_register_group_extension("BPMediaGroupAlbum");
|
15 |
+
}
|
16 |
|
|
|
|
|
|
|
17 |
}
|
18 |
|
19 |
+
endif;
|
|
|
20 |
?>
|
app/main/includes/BPMediaActions.php
CHANGED
@@ -7,6 +7,10 @@
|
|
7 |
*/
|
8 |
class BPMediaActions {
|
9 |
|
|
|
|
|
|
|
|
|
10 |
function __construct() {
|
11 |
add_action('bp_media_before_content', 'BPMediaActions::show_messages');
|
12 |
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'), 11);
|
@@ -34,6 +38,13 @@ class BPMediaActions {
|
|
34 |
*
|
35 |
* @since BuddyPress Media 2.0
|
36 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
static function handle_uploads() {
|
38 |
global $bp, $bp_media_options;
|
39 |
$bp_media_options = get_site_option('bp_media_options', array(
|
@@ -105,6 +116,11 @@ class BPMediaActions {
|
|
105 |
*
|
106 |
* @since BuddyPress Media 2.0
|
107 |
*/
|
|
|
|
|
|
|
|
|
|
|
108 |
static function show_messages() {
|
109 |
global $bp;
|
110 |
if (is_array($bp->{BP_MEDIA_SLUG}->messages)) {
|
@@ -122,6 +138,11 @@ class BPMediaActions {
|
|
122 |
*
|
123 |
* @since BuddyPress Media 2.0
|
124 |
*/
|
|
|
|
|
|
|
|
|
|
|
125 |
function enqueue_scripts_styles() {
|
126 |
|
127 |
wp_enqueue_script('jquery-ui-tabs');
|
@@ -149,6 +170,13 @@ class BPMediaActions {
|
|
149 |
wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
|
150 |
}
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
static function delete_activity_handler($args) {
|
153 |
remove_action('bp_media_before_delete_media', 'BPMediaActions::delete_media_handler');
|
154 |
global $bp_media_count, $wpdb;
|
@@ -184,6 +212,11 @@ class BPMediaActions {
|
|
184 |
}
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
187 |
static function delete_media_handler($media_id) {
|
188 |
/* @var $media BPMediaHostWordpress */
|
189 |
remove_action('bp_before_activity_delete', 'BPMediaActions::delete_activity_handler');
|
@@ -200,6 +233,13 @@ class BPMediaActions {
|
|
200 |
*
|
201 |
* @since BuddyPress Media 2.0
|
202 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
function set_query() {
|
204 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
205 |
switch ($bp->current_action) {
|
@@ -243,6 +283,13 @@ class BPMediaActions {
|
|
243 |
*
|
244 |
* @since BuddyPress Media 2.0
|
245 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
function action_buttons() {
|
247 |
if (!in_array('bp_media_current_entry', $GLOBALS))
|
248 |
return false;
|
@@ -282,6 +329,13 @@ class BPMediaActions {
|
|
282 |
*
|
283 |
* @since BuddyPress Media 2.0
|
284 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
static function init_count($user = null) {
|
286 |
global $bp_media_count;
|
287 |
if (!$user)
|
@@ -352,6 +406,12 @@ class BPMediaActions {
|
|
352 |
*
|
353 |
* @since BuddyPress Media 2.2
|
354 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
function albums_set_query() {
|
356 |
global $bp, $bp_media_albums_query;
|
357 |
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])) {
|
@@ -375,6 +435,13 @@ class BPMediaActions {
|
|
375 |
/**
|
376 |
* Function to return the media for the ajax requests
|
377 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
function load_more() {
|
379 |
|
380 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
@@ -462,6 +529,12 @@ class BPMediaActions {
|
|
462 |
die();
|
463 |
}
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
function delete_attachment_handler($attachment_id) {
|
466 |
if (get_post_meta($attachment_id, 'bp-media-key')) {
|
467 |
do_action('bp_media_before_delete_media', $attachment_id);
|
@@ -531,7 +604,10 @@ class BPMediaActions {
|
|
531 |
|
532 |
//add_action('bp_after_activity_post_form','add_new_from_activity');
|
533 |
|
534 |
-
|
|
|
|
|
|
|
535 |
function album_create_activity($album) {
|
536 |
/* @var $album BP_Media_Album */
|
537 |
$args = array(
|
@@ -546,15 +622,29 @@ class BPMediaActions {
|
|
546 |
update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
|
547 |
}
|
548 |
|
|
|
|
|
|
|
|
|
549 |
function album_activity_update($album_id) {
|
550 |
BPMediaFunction::update_album_activity($album_id);
|
551 |
}
|
552 |
|
|
|
|
|
|
|
|
|
553 |
function album_activity_sync($media_id) {
|
554 |
$album_id = wp_get_post_parent_id($media_id);
|
555 |
BPMediaFunction::update_album_activity($album_id, false, $media_id);
|
556 |
}
|
557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
static function activity_create_after_add_media($media, $hidden = false) {
|
559 |
if (function_exists('bp_activity_add')) {
|
560 |
if (!is_object($media)) {
|
@@ -564,8 +654,8 @@ class BPMediaActions {
|
|
564 |
return false;
|
565 |
}
|
566 |
}
|
567 |
-
|
568 |
-
|
569 |
$args = array(
|
570 |
'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media->get_author()), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>')),
|
571 |
'content' => $activity_content,
|
7 |
*/
|
8 |
class BPMediaActions {
|
9 |
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
* @global type $bp_media_options
|
13 |
+
*/
|
14 |
function __construct() {
|
15 |
add_action('bp_media_before_content', 'BPMediaActions::show_messages');
|
16 |
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'), 11);
|
38 |
*
|
39 |
* @since BuddyPress Media 2.0
|
40 |
*/
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* @global type $bp
|
45 |
+
* @global type $bp_media_options
|
46 |
+
* @return type
|
47 |
+
*/
|
48 |
static function handle_uploads() {
|
49 |
global $bp, $bp_media_options;
|
50 |
$bp_media_options = get_site_option('bp_media_options', array(
|
116 |
*
|
117 |
* @since BuddyPress Media 2.0
|
118 |
*/
|
119 |
+
|
120 |
+
/**
|
121 |
+
*
|
122 |
+
* @global type $bp
|
123 |
+
*/
|
124 |
static function show_messages() {
|
125 |
global $bp;
|
126 |
if (is_array($bp->{BP_MEDIA_SLUG}->messages)) {
|
138 |
*
|
139 |
* @since BuddyPress Media 2.0
|
140 |
*/
|
141 |
+
|
142 |
+
/**
|
143 |
+
*
|
144 |
+
* @global type $bp
|
145 |
+
*/
|
146 |
function enqueue_scripts_styles() {
|
147 |
|
148 |
wp_enqueue_script('jquery-ui-tabs');
|
170 |
wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css');
|
171 |
}
|
172 |
|
173 |
+
/**
|
174 |
+
*
|
175 |
+
* @global type $bp_media_count
|
176 |
+
* @global type $wpdb
|
177 |
+
* @param type $args
|
178 |
+
* @return boolean
|
179 |
+
*/
|
180 |
static function delete_activity_handler($args) {
|
181 |
remove_action('bp_media_before_delete_media', 'BPMediaActions::delete_media_handler');
|
182 |
global $bp_media_count, $wpdb;
|
212 |
}
|
213 |
}
|
214 |
|
215 |
+
/**
|
216 |
+
*
|
217 |
+
* @param type $media_id
|
218 |
+
* @return boolean
|
219 |
+
*/
|
220 |
static function delete_media_handler($media_id) {
|
221 |
/* @var $media BPMediaHostWordpress */
|
222 |
remove_action('bp_before_activity_delete', 'BPMediaActions::delete_activity_handler');
|
233 |
*
|
234 |
* @since BuddyPress Media 2.0
|
235 |
*/
|
236 |
+
|
237 |
+
/**
|
238 |
+
*
|
239 |
+
* @global type $bp
|
240 |
+
* @global WP_Query $bp_media_query
|
241 |
+
* @global type $bp_media_posts_per_page
|
242 |
+
*/
|
243 |
function set_query() {
|
244 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
245 |
switch ($bp->current_action) {
|
283 |
*
|
284 |
* @since BuddyPress Media 2.0
|
285 |
*/
|
286 |
+
|
287 |
+
/**
|
288 |
+
*
|
289 |
+
* @global type $bp_media_current_entry
|
290 |
+
* @global type $bp_media_options
|
291 |
+
* @return boolean
|
292 |
+
*/
|
293 |
function action_buttons() {
|
294 |
if (!in_array('bp_media_current_entry', $GLOBALS))
|
295 |
return false;
|
329 |
*
|
330 |
* @since BuddyPress Media 2.0
|
331 |
*/
|
332 |
+
|
333 |
+
/**
|
334 |
+
*
|
335 |
+
* @global type $bp_media_count
|
336 |
+
* @param type $user
|
337 |
+
* @return boolean
|
338 |
+
*/
|
339 |
static function init_count($user = null) {
|
340 |
global $bp_media_count;
|
341 |
if (!$user)
|
406 |
*
|
407 |
* @since BuddyPress Media 2.2
|
408 |
*/
|
409 |
+
|
410 |
+
/**
|
411 |
+
*
|
412 |
+
* @global type $bp
|
413 |
+
* @global WP_Query $bp_media_albums_query
|
414 |
+
*/
|
415 |
function albums_set_query() {
|
416 |
global $bp, $bp_media_albums_query;
|
417 |
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])) {
|
435 |
/**
|
436 |
* Function to return the media for the ajax requests
|
437 |
*/
|
438 |
+
|
439 |
+
/**
|
440 |
+
*
|
441 |
+
* @global type $bp
|
442 |
+
* @global WP_Query $bp_media_query
|
443 |
+
* @global type $bp_media_posts_per_page
|
444 |
+
*/
|
445 |
function load_more() {
|
446 |
|
447 |
global $bp, $bp_media_query, $bp_media_posts_per_page;
|
529 |
die();
|
530 |
}
|
531 |
|
532 |
+
/**
|
533 |
+
*
|
534 |
+
* @global type $bp_media_count
|
535 |
+
* @param type $attachment_id
|
536 |
+
* @return boolean
|
537 |
+
*/
|
538 |
function delete_attachment_handler($attachment_id) {
|
539 |
if (get_post_meta($attachment_id, 'bp-media-key')) {
|
540 |
do_action('bp_media_before_delete_media', $attachment_id);
|
604 |
|
605 |
//add_action('bp_after_activity_post_form','add_new_from_activity');
|
606 |
|
607 |
+
/**
|
608 |
+
*
|
609 |
+
* @param type $album
|
610 |
+
*/
|
611 |
function album_create_activity($album) {
|
612 |
/* @var $album BP_Media_Album */
|
613 |
$args = array(
|
622 |
update_post_meta($album->get_id(), 'bp_media_child_activity', $activity_id);
|
623 |
}
|
624 |
|
625 |
+
/**
|
626 |
+
*
|
627 |
+
* @param type $album_id
|
628 |
+
*/
|
629 |
function album_activity_update($album_id) {
|
630 |
BPMediaFunction::update_album_activity($album_id);
|
631 |
}
|
632 |
|
633 |
+
/**
|
634 |
+
*
|
635 |
+
* @param type $media_id
|
636 |
+
*/
|
637 |
function album_activity_sync($media_id) {
|
638 |
$album_id = wp_get_post_parent_id($media_id);
|
639 |
BPMediaFunction::update_album_activity($album_id, false, $media_id);
|
640 |
}
|
641 |
|
642 |
+
/**
|
643 |
+
*
|
644 |
+
* @param BPMediaHostWordpress $media
|
645 |
+
* @param type $hidden
|
646 |
+
* @return boolean
|
647 |
+
*/
|
648 |
static function activity_create_after_add_media($media, $hidden = false) {
|
649 |
if (function_exists('bp_activity_add')) {
|
650 |
if (!is_object($media)) {
|
654 |
return false;
|
655 |
}
|
656 |
}
|
657 |
+
$activity_content = $media->get_media_activity_content();
|
658 |
+
new BPMediaLog($activity_content);
|
659 |
$args = array(
|
660 |
'action' => apply_filters('bp_media_added_media', sprintf(__('%1$s added a %2$s', BP_MEDIA_TXT_DOMAIN), bp_core_get_userlink($media->get_author()), '<a href="' . $media->get_url() . '">' . $media->get_media_activity_type() . '</a>')),
|
661 |
'content' => $activity_content,
|
app/main/includes/BPMediaComponent.php
CHANGED
@@ -12,103 +12,117 @@
|
|
12 |
*/
|
13 |
class BPMediaComponent extends BP_Component {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
// if ( bp_is_my_profile() ) {
|
113 |
// $main_nav = array(
|
114 |
// 'name' => BP_MEDIA_LABEL,
|
@@ -118,249 +132,249 @@ class BPMediaComponent extends BP_Component {
|
|
118 |
// 'default_subnav_slug' => BP_MEDIA_UPLOAD_SLUG
|
119 |
// );
|
120 |
// } else {
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
// }
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
|
365 |
}
|
366 |
|
12 |
*/
|
13 |
class BPMediaComponent extends BP_Component {
|
14 |
|
15 |
+
/**
|
16 |
+
* Hold the messages generated during initialization process and will be shown on the screen functions
|
17 |
+
*
|
18 |
+
* @since BuddyPress Media 2.0
|
19 |
+
*/
|
20 |
+
var $messages = array(
|
21 |
+
'error' => array(),
|
22 |
+
'info' => array(),
|
23 |
+
'updated' => array()
|
24 |
+
);
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Constructor for the BuddyPress Media
|
28 |
+
*
|
29 |
+
* @since BuddyPress Media 2.0
|
30 |
+
*/
|
31 |
+
|
32 |
+
/**
|
33 |
+
*
|
34 |
+
* @global type $bp
|
35 |
+
*/
|
36 |
+
function __construct() {
|
37 |
+
global $bp;
|
38 |
+
parent::start(BP_MEDIA_SLUG, BP_MEDIA_LABEL, BP_MEDIA_PATH);
|
39 |
+
$this->includes();
|
40 |
+
$bp->active_components[$this->id] = '1';
|
41 |
+
add_action('init', array(&$this, 'register_post_types'), 10);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Includes the files required for the BuddyPress Media and calls the parent class' includes function
|
46 |
+
*
|
47 |
+
* @since BuddyPress Media 2.0
|
48 |
+
*/
|
49 |
+
function includes() {
|
50 |
+
$inc_path_prefix = 'app/main/includes/';
|
51 |
+
$includes = array(
|
52 |
+
$inc_path_prefix . 'bp-media-functions.php',
|
53 |
+
$inc_path_prefix . 'bp-media-template-functions.php',
|
54 |
+
$inc_path_prefix . 'bp-media-interface.php',
|
55 |
+
$inc_path_prefix . 'bp-media-shortcodes.php',
|
56 |
+
$inc_path_prefix . 'bp-media-widgets.php'
|
57 |
+
//$inc_path_prefix . 'BPMediaFilter.php',
|
58 |
+
);
|
59 |
+
parent::includes($includes);
|
60 |
+
do_action('bp_media_init');
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Initializes the global variables of the BuddyPress Media and its parent class.
|
65 |
+
*/
|
66 |
+
|
67 |
+
/**
|
68 |
+
*
|
69 |
+
* @global type $bp
|
70 |
+
*/
|
71 |
+
function setup_globals() {
|
72 |
+
global $bp;
|
73 |
+
$globals = array(
|
74 |
+
'slug' => BP_MEDIA_SLUG,
|
75 |
+
'root_slug' => isset($bp->pages->{$this->id}->slug) ? $bp->pages->{$this->id}->slug : BP_MEDIA_SLUG,
|
76 |
+
/* 'has_directory' => true, /* Set to false if not required */
|
77 |
+
'search_string' => __('Search Media...', BP_MEDIA_TXT_DOMAIN),
|
78 |
+
);
|
79 |
+
parent::setup_globals($globals);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
*
|
84 |
+
* @global type $bp
|
85 |
+
*/
|
86 |
+
function setup_nav() {
|
87 |
+
/* Add 'Media' to the main navigation */
|
88 |
+
global $bp;
|
89 |
+
$bp_media_upload = new BPMediaUploadScreen('upload', BP_MEDIA_UPLOAD_SLUG);
|
90 |
+
|
91 |
+
$bp_media_image = new BPMediaScreen('image', BP_MEDIA_IMAGES_SLUG);
|
92 |
+
$bp_media_video = new BPMediaScreen('video', BP_MEDIA_VIDEOS_SLUG);
|
93 |
+
$bp_media_audio = new BPMediaScreen('audio', BP_MEDIA_AUDIO_SLUG);
|
94 |
+
|
95 |
+
$bp_media_album = new BPMediaAlbumScreen('album', BP_MEDIA_ALBUMS_SLUG);
|
96 |
+
switch ($bp->current_component) {
|
97 |
+
case BP_MEDIA_IMAGES_SLUG:
|
98 |
+
if (is_numeric($bp->current_action)) {
|
99 |
+
$bp->action_variables[0] = $bp->current_action;
|
100 |
+
$bp->current_action = BP_MEDIA_IMAGES_ENTRY_SLUG;
|
101 |
+
}
|
102 |
+
break;
|
103 |
+
case BP_MEDIA_AUDIO_SLUG:
|
104 |
+
if (is_numeric($bp->current_action)) {
|
105 |
+
$bp->action_variables[0] = $bp->current_action;
|
106 |
+
$bp->current_action = BP_MEDIA_AUDIO_ENTRY_SLUG;
|
107 |
+
}
|
108 |
+
break;
|
109 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
110 |
+
if (is_numeric($bp->current_action)) {
|
111 |
+
$bp->action_variables[0] = $bp->current_action;
|
112 |
+
$bp->current_action = BP_MEDIA_VIDEOS_ENTRY_SLUG;
|
113 |
+
}
|
114 |
+
break;
|
115 |
+
case BP_MEDIA_ALBUMS_SLUG:
|
116 |
+
if (is_numeric($bp->current_action)) {
|
117 |
+
$bp->action_variables[0] = $bp->current_action;
|
118 |
+
$bp->current_action = BP_MEDIA_ALBUMS_ENTRY_SLUG;
|
119 |
+
}
|
120 |
+
break;
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
|
125 |
+
// -------------- Removed Upload as default tab ------------- //
|
126 |
// if ( bp_is_my_profile() ) {
|
127 |
// $main_nav = array(
|
128 |
// 'name' => BP_MEDIA_LABEL,
|
132 |
// 'default_subnav_slug' => BP_MEDIA_UPLOAD_SLUG
|
133 |
// );
|
134 |
// } else {
|
135 |
+
$main_nav = array(
|
136 |
+
'name' => __(BP_MEDIA_LABEL, BP_MEDIA_TXT_DOMAIN),
|
137 |
+
'slug' => BP_MEDIA_SLUG,
|
138 |
+
'position' => 80,
|
139 |
+
'screen_function' => array($bp_media_image, 'screen'),
|
140 |
+
'default_subnav_slug' => BP_MEDIA_IMAGES_SLUG
|
141 |
+
);
|
142 |
// }
|
143 |
+
$sub_nav[] = array();
|
144 |
+
parent::setup_nav($main_nav, $sub_nav);
|
145 |
+
bp_core_new_nav_item(array(
|
146 |
+
'name' => __(BP_MEDIA_IMAGES_LABEL, BP_MEDIA_TXT_DOMAIN),
|
147 |
+
'slug' => BP_MEDIA_IMAGES_SLUG,
|
148 |
+
'screen_function' => array($bp_media_image, 'screen'),
|
149 |
+
));
|
150 |
+
|
151 |
+
|
152 |
+
bp_core_new_subnav_item(array(
|
153 |
+
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
154 |
+
'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG, /* URL slug for the nav item */
|
155 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
156 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
157 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
158 |
+
'screen_function' => array($bp_media_image, 'screen'), /* The name of the function to run when clicked */
|
159 |
+
));
|
160 |
+
|
161 |
+
bp_core_new_subnav_item(array(
|
162 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
163 |
+
'slug' => BP_MEDIA_IMAGES_EDIT_SLUG, /* URL slug for the nav item */
|
164 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
165 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
166 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
167 |
+
'screen_function' => array($bp_media_image, 'edit_screen'), /* The name of the function to run when clicked */
|
168 |
+
));
|
169 |
+
|
170 |
+
bp_core_new_subnav_item(array(
|
171 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
172 |
+
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
173 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
174 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
175 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
176 |
+
'screen_function' => array($bp_media_image, 'screen'), /* The name of the function to run when clicked */
|
177 |
+
));
|
178 |
+
|
179 |
+
bp_core_new_subnav_item(array(
|
180 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
181 |
+
'slug' => 'page', /* URL slug for the nav item */
|
182 |
+
'parent_slug' => BP_MEDIA_IMAGES_SLUG, /* URL slug of the parent nav item */
|
183 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_IMAGES_SLUG), /* URL of the parent item */
|
184 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
185 |
+
'screen_function' => array($bp_media_image, 'screen'), /* The name of the function to run when clicked */
|
186 |
+
));
|
187 |
+
|
188 |
+
|
189 |
+
bp_core_new_nav_item(array(
|
190 |
+
'name' => __(BP_MEDIA_VIDEOS_LABEL, BP_MEDIA_TXT_DOMAIN),
|
191 |
+
'slug' => BP_MEDIA_VIDEOS_SLUG,
|
192 |
+
'screen_function' => array($bp_media_video, 'screen')
|
193 |
+
));
|
194 |
+
|
195 |
+
bp_core_new_subnav_item(array(
|
196 |
+
'name' => 'Watch', /* Display name for the nav item(It won't be shown anywhere) */
|
197 |
+
'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG, /* URL slug for the nav item */
|
198 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
199 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
200 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
201 |
+
'screen_function' => array($bp_media_video, 'screen'), /* The name of the function to run when clicked */
|
202 |
+
));
|
203 |
+
|
204 |
+
bp_core_new_subnav_item(array(
|
205 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
206 |
+
'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG, /* URL slug for the nav item */
|
207 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
208 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
209 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
210 |
+
'screen_function' => array($bp_media_video, 'edit_screen'), /* The name of the function to run when clicked */
|
211 |
+
));
|
212 |
+
|
213 |
+
bp_core_new_subnav_item(array(
|
214 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
215 |
+
'slug' => BP_MEDIA_DELETE_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' => array($bp_media_video, 'screen'), /* The name of the function to run when clicked */
|
220 |
+
));
|
221 |
+
|
222 |
+
bp_core_new_subnav_item(array(
|
223 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
224 |
+
'slug' => 'page', /* URL slug for the nav item */
|
225 |
+
'parent_slug' => BP_MEDIA_VIDEOS_SLUG, /* URL slug of the parent nav item */
|
226 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_VIDEOS_SLUG), /* URL of the parent item */
|
227 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
228 |
+
'screen_function' => array($bp_media_video, 'screen'), /* The name of the function to run when clicked */
|
229 |
+
));
|
230 |
+
|
231 |
+
|
232 |
+
bp_core_new_nav_item(array(
|
233 |
+
'name' => __(BP_MEDIA_AUDIO_LABEL, BP_MEDIA_TXT_DOMAIN),
|
234 |
+
'slug' => BP_MEDIA_AUDIO_SLUG,
|
235 |
+
'screen_function' => array($bp_media_audio, 'screen')
|
236 |
+
));
|
237 |
+
|
238 |
+
bp_core_new_subnav_item(array(
|
239 |
+
'name' => 'Listen', /* Display name for the nav item(It won't be shown anywhere) */
|
240 |
+
'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG, /* URL slug for the nav item */
|
241 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
242 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
243 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
244 |
+
'screen_function' => array($bp_media_audio, 'screen'), /* The name of the function to run when clicked */
|
245 |
+
));
|
246 |
+
|
247 |
+
bp_core_new_subnav_item(array(
|
248 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
249 |
+
'slug' => BP_MEDIA_AUDIO_EDIT_SLUG, /* URL slug for the nav item */
|
250 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
251 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
252 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
253 |
+
'screen_function' => array($bp_media_audio, 'edit_screen'), /* The name of the function to run when clicked */
|
254 |
+
));
|
255 |
+
|
256 |
+
bp_core_new_subnav_item(array(
|
257 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
258 |
+
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
259 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
260 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
261 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
262 |
+
'screen_function' => array($bp_media_audio, 'screen'), /* The name of the function to run when clicked */
|
263 |
+
));
|
264 |
+
|
265 |
+
bp_core_new_subnav_item(array(
|
266 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
267 |
+
'slug' => 'page', /* URL slug for the nav item */
|
268 |
+
'parent_slug' => BP_MEDIA_AUDIO_SLUG, /* URL slug of the parent nav item */
|
269 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
|
270 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
271 |
+
'screen_function' => array($bp_media_audio, 'screen'), /* The name of the function to run when clicked */
|
272 |
+
));
|
273 |
+
|
274 |
+
|
275 |
+
bp_core_new_nav_item(array(
|
276 |
+
'name' => __(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_TXT_DOMAIN),
|
277 |
+
'slug' => BP_MEDIA_ALBUMS_SLUG,
|
278 |
+
'screen_function' => array($bp_media_album, 'screen'),
|
279 |
+
));
|
280 |
+
|
281 |
+
bp_core_new_subnav_item(array(
|
282 |
+
'name' => 'View', /* Display name for the nav item(It won't be shown anywhere) */
|
283 |
+
'slug' => BP_MEDIA_ALBUMS_ENTRY_SLUG, /* URL slug for the nav item */
|
284 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
285 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
286 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
287 |
+
'screen_function' => array($bp_media_album, 'screen'), /* The name of the function to run when clicked */
|
288 |
+
));
|
289 |
+
|
290 |
+
bp_core_new_subnav_item(array(
|
291 |
+
'name' => 'Edit', /* Display name for the nav item(It won't be shown anywhere) */
|
292 |
+
'slug' => BP_MEDIA_ALBUMS_EDIT_SLUG, /* URL slug for the nav item */
|
293 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
294 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
295 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
296 |
+
'screen_function' => array($bp_media_album, 'edit_screen'), /* The name of the function to run when clicked */
|
297 |
+
));
|
298 |
+
|
299 |
+
bp_core_new_subnav_item(array(
|
300 |
+
'name' => 'Delete', /* Display name for the nav item(It won't be shown anywhere) */
|
301 |
+
'slug' => BP_MEDIA_DELETE_SLUG, /* URL slug for the nav item */
|
302 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
303 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
304 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
305 |
+
'screen_function' => array($bp_media_album, 'screen'), /* The name of the function to run when clicked */
|
306 |
+
));
|
307 |
+
|
308 |
+
bp_core_new_subnav_item(array(
|
309 |
+
'name' => 'Page', /* Display name for the nav item(It won't be shown anywhere) */
|
310 |
+
'slug' => 'page', /* URL slug for the nav item */
|
311 |
+
'parent_slug' => BP_MEDIA_ALBUMS_SLUG, /* URL slug of the parent nav item */
|
312 |
+
'parent_url' => trailingslashit(bp_loggedin_user_domain() . BP_MEDIA_ALBUMS_SLUG), /* URL of the parent item */
|
313 |
+
'position' => 90, /* Index of where this nav item should be positioned */
|
314 |
+
'screen_function' => array($bp_media_album, 'screen'), /* The name of the function to run when clicked */
|
315 |
+
));
|
316 |
+
bp_core_new_nav_item(array(
|
317 |
+
'name' => __(BP_MEDIA_UPLOAD_LABEL, BP_MEDIA_TXT_DOMAIN),
|
318 |
+
'slug' => BP_MEDIA_UPLOAD_SLUG,
|
319 |
+
'screen_function' => array($bp_media_upload, 'upload_screen'),
|
320 |
+
'user_has_access' => bp_is_my_profile()
|
321 |
+
));
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Creating a custom post type album for BuddyPress Media
|
326 |
+
*/
|
327 |
+
function register_post_types() {
|
328 |
+
$labels = array(
|
329 |
+
'name' => __('Albums', BP_MEDIA_TXT_DOMAIN),
|
330 |
+
'singular_name' => __('Album', BP_MEDIA_TXT_DOMAIN),
|
331 |
+
'add_new' => __('Create', BP_MEDIA_TXT_DOMAIN),
|
332 |
+
'add_new_item' => __('Create Album', BP_MEDIA_TXT_DOMAIN),
|
333 |
+
'edit_item' => __('Edit Album', BP_MEDIA_TXT_DOMAIN),
|
334 |
+
'new_item' => __('New Album', BP_MEDIA_TXT_DOMAIN),
|
335 |
+
'all_items' => __('All Albums', BP_MEDIA_TXT_DOMAIN),
|
336 |
+
'view_item' => __('View Album', BP_MEDIA_TXT_DOMAIN),
|
337 |
+
'search_items' => __('Search Albums', BP_MEDIA_TXT_DOMAIN),
|
338 |
+
'not_found' => __('No album found', BP_MEDIA_TXT_DOMAIN),
|
339 |
+
'not_found_in_trash' => __('No album found in Trash', BP_MEDIA_TXT_DOMAIN),
|
340 |
+
'parent_item_colon' => '',
|
341 |
+
'menu_name' => __('Albums', BP_MEDIA_TXT_DOMAIN)
|
342 |
+
);
|
343 |
+
|
344 |
+
$args = array(
|
345 |
+
'labels' => $labels,
|
346 |
+
'public' => true,
|
347 |
+
'publicly_queryable' => true,
|
348 |
+
'show_ui' => false,
|
349 |
+
'show_in_menu' => false,
|
350 |
+
'query_var' => true,
|
351 |
+
'capability_type' => 'post',
|
352 |
+
'has_archive' => true,
|
353 |
+
'hierarchical' => false,
|
354 |
+
'menu_position' => null,
|
355 |
+
'supports' => array('title', 'author', 'thumbnail', 'excerpt', 'comments')
|
356 |
+
);
|
357 |
+
register_post_type('bp_media_album', $args);
|
358 |
+
global $bp_media;
|
359 |
+
/* Set up labels for the post type */
|
360 |
+
$labels = array(
|
361 |
+
'name' => __('Media', BP_MEDIA_TXT_DOMAIN),
|
362 |
+
'singular' => __('Media', BP_MEDIA_TXT_DOMAIN),
|
363 |
+
'add_new' => __('Add New Media', BP_MEDIA_TXT_DOMAIN)
|
364 |
+
);
|
365 |
+
|
366 |
+
/* Set up the argument array for register_post_type() */
|
367 |
+
$args = array(
|
368 |
+
'label' => __('Media', BP_MEDIA_TXT_DOMAIN),
|
369 |
+
'labels' => $labels,
|
370 |
+
'description' => __('BuddyPress Media\'s Media Files', BP_MEDIA_TXT_DOMAIN),
|
371 |
+
'public' => true,
|
372 |
+
'show_ui' => false,
|
373 |
+
'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields')
|
374 |
+
);
|
375 |
+
register_post_type('bp_media', $args);
|
376 |
+
parent::register_post_types();
|
377 |
+
}
|
378 |
|
379 |
}
|
380 |
|
app/main/includes/BPMediaFilters.php
CHANGED
@@ -7,6 +7,10 @@
|
|
7 |
*/
|
8 |
class BPMediaFilters {
|
9 |
|
|
|
|
|
|
|
|
|
10 |
function __construct() {
|
11 |
add_filter('bp_activity_get_permalink', array($this, 'activity_permalink_filter'), 10, 2);
|
12 |
add_filter('bp_get_activity_delete_link', array($this, 'delete_button_handler'));
|
@@ -19,6 +23,14 @@ class BPMediaFilters {
|
|
19 |
$bp_media_activity_types = array('media_upload', 'album_updated', 'album_created');
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
function activity_permalink_filter($link, $activity_obj = null) {
|
23 |
global $bp_media_activity_types;
|
24 |
if ($activity_obj != null && in_array($activity_obj->type, $bp_media_activity_types)) {
|
@@ -53,6 +65,12 @@ class BPMediaFilters {
|
|
53 |
return $link;
|
54 |
}
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
function activity_parent_content_filter($activity_content) {
|
57 |
global $activities_template;
|
58 |
$defaults = array(
|
@@ -85,7 +103,12 @@ class BPMediaFilters {
|
|
85 |
}
|
86 |
|
87 |
//add_filter('bp_get_activity_parent_content', 'activity_parent_content_filter', 1);
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
function delete_button_handler($link) {
|
90 |
global $activities_template;
|
91 |
$media_label = NULL;
|
@@ -114,6 +137,13 @@ class BPMediaFilters {
|
|
114 |
return $link;
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
static function items_count_filter($title, $nav_item) {
|
118 |
global $bp_media_count;
|
119 |
$bp_media_count = wp_parse_args($bp_media_count, array(
|
@@ -146,6 +176,13 @@ class BPMediaFilters {
|
|
146 |
/**
|
147 |
* To hide some activities of multiple uploads
|
148 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
static function activity_query_filter($query) {
|
150 |
global $wpdb;
|
151 |
$query = preg_replace('/WHERE/i', 'WHERE a.secondary_item_id!=-999 AND ', $query);
|
@@ -157,6 +194,11 @@ class BPMediaFilters {
|
|
157 |
*
|
158 |
* @global type $wp_admin_bar
|
159 |
*/
|
|
|
|
|
|
|
|
|
|
|
160 |
function my_account_menu() {
|
161 |
global $wp_admin_bar;
|
162 |
|
@@ -221,7 +263,12 @@ class BPMediaFilters {
|
|
221 |
*
|
222 |
* @global type $wp_admin_bar
|
223 |
*/
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
225 |
global $wp_admin_bar;
|
226 |
|
227 |
if (current_user_can('manage_options') && is_super_admin()) {
|
@@ -274,7 +321,11 @@ class BPMediaFilters {
|
|
274 |
*
|
275 |
*/
|
276 |
//add_action('wp_dashboard_setup','dashboard_widgets');
|
277 |
-
|
|
|
|
|
|
|
|
|
278 |
function dashboard_widgets() {
|
279 |
global $wp_meta_boxes;
|
280 |
// BuddyPress Media
|
@@ -333,6 +384,11 @@ class BPMediaFilters {
|
|
333 |
<?php
|
334 |
}
|
335 |
|
|
|
|
|
|
|
|
|
|
|
336 |
function admin_total_count($media_type) {
|
337 |
|
338 |
switch ($media_type) {
|
@@ -350,6 +406,11 @@ class BPMediaFilters {
|
|
350 |
}
|
351 |
}
|
352 |
|
|
|
|
|
|
|
|
|
|
|
353 |
function group_total_count($media_type) {
|
354 |
|
355 |
switch ($media_type) {
|
@@ -367,6 +428,12 @@ class BPMediaFilters {
|
|
367 |
}
|
368 |
}
|
369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
function total_count_media($type) {
|
371 |
global $wpdb;
|
372 |
|
@@ -382,6 +449,11 @@ class BPMediaFilters {
|
|
382 |
return false;
|
383 |
}
|
384 |
|
|
|
|
|
|
|
|
|
|
|
385 |
function total_count_albums() {
|
386 |
global $wpdb;
|
387 |
|
7 |
*/
|
8 |
class BPMediaFilters {
|
9 |
|
10 |
+
/**
|
11 |
+
*
|
12 |
+
* @global array $bp_media_activity_types
|
13 |
+
*/
|
14 |
function __construct() {
|
15 |
add_filter('bp_activity_get_permalink', array($this, 'activity_permalink_filter'), 10, 2);
|
16 |
add_filter('bp_get_activity_delete_link', array($this, 'delete_button_handler'));
|
23 |
$bp_media_activity_types = array('media_upload', 'album_updated', 'album_created');
|
24 |
}
|
25 |
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @global array $bp_media_activity_types
|
29 |
+
* @global type $activities_template
|
30 |
+
* @param type $link
|
31 |
+
* @param type $activity_obj
|
32 |
+
* @return type
|
33 |
+
*/
|
34 |
function activity_permalink_filter($link, $activity_obj = null) {
|
35 |
global $bp_media_activity_types;
|
36 |
if ($activity_obj != null && in_array($activity_obj->type, $bp_media_activity_types)) {
|
65 |
return $link;
|
66 |
}
|
67 |
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @global type $activities_template
|
71 |
+
* @param type $activity_content
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
function activity_parent_content_filter($activity_content) {
|
75 |
global $activities_template;
|
76 |
$defaults = array(
|
103 |
}
|
104 |
|
105 |
//add_filter('bp_get_activity_parent_content', 'activity_parent_content_filter', 1);
|
106 |
+
/**
|
107 |
+
*
|
108 |
+
* @global type $activities_template
|
109 |
+
* @param type $link
|
110 |
+
* @return type
|
111 |
+
*/
|
112 |
function delete_button_handler($link) {
|
113 |
global $activities_template;
|
114 |
$media_label = NULL;
|
137 |
return $link;
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
+
*
|
142 |
+
* @global type $bp_media_count
|
143 |
+
* @param type $title
|
144 |
+
* @param type $nav_item
|
145 |
+
* @return type
|
146 |
+
*/
|
147 |
static function items_count_filter($title, $nav_item) {
|
148 |
global $bp_media_count;
|
149 |
$bp_media_count = wp_parse_args($bp_media_count, array(
|
176 |
/**
|
177 |
* To hide some activities of multiple uploads
|
178 |
*/
|
179 |
+
|
180 |
+
/**
|
181 |
+
*
|
182 |
+
* @global type $wpdb
|
183 |
+
* @param type $query
|
184 |
+
* @return type
|
185 |
+
*/
|
186 |
static function activity_query_filter($query) {
|
187 |
global $wpdb;
|
188 |
$query = preg_replace('/WHERE/i', 'WHERE a.secondary_item_id!=-999 AND ', $query);
|
194 |
*
|
195 |
* @global type $wp_admin_bar
|
196 |
*/
|
197 |
+
|
198 |
+
/**
|
199 |
+
*
|
200 |
+
* @global type $wp_admin_bar
|
201 |
+
*/
|
202 |
function my_account_menu() {
|
203 |
global $wp_admin_bar;
|
204 |
|
263 |
*
|
264 |
* @global type $wp_admin_bar
|
265 |
*/
|
266 |
+
|
267 |
+
/**
|
268 |
+
*
|
269 |
+
* @global type $wp_admin_bar
|
270 |
+
*/
|
271 |
+
static function adminbar_settings_menu() {
|
272 |
global $wp_admin_bar;
|
273 |
|
274 |
if (current_user_can('manage_options') && is_super_admin()) {
|
321 |
*
|
322 |
*/
|
323 |
//add_action('wp_dashboard_setup','dashboard_widgets');
|
324 |
+
/**
|
325 |
+
*
|
326 |
+
* @global array $wp_meta_boxes
|
327 |
+
* @global array $wp_meta_boxes
|
328 |
+
*/
|
329 |
function dashboard_widgets() {
|
330 |
global $wp_meta_boxes;
|
331 |
// BuddyPress Media
|
384 |
<?php
|
385 |
}
|
386 |
|
387 |
+
/**
|
388 |
+
*
|
389 |
+
* @param type $media_type
|
390 |
+
* @return type
|
391 |
+
*/
|
392 |
function admin_total_count($media_type) {
|
393 |
|
394 |
switch ($media_type) {
|
406 |
}
|
407 |
}
|
408 |
|
409 |
+
/**
|
410 |
+
*
|
411 |
+
* @param type $media_type
|
412 |
+
* @return type
|
413 |
+
*/
|
414 |
function group_total_count($media_type) {
|
415 |
|
416 |
switch ($media_type) {
|
428 |
}
|
429 |
}
|
430 |
|
431 |
+
/**
|
432 |
+
*
|
433 |
+
* @global type $wpdb
|
434 |
+
* @param type $type
|
435 |
+
* @return boolean
|
436 |
+
*/
|
437 |
function total_count_media($type) {
|
438 |
global $wpdb;
|
439 |
|
449 |
return false;
|
450 |
}
|
451 |
|
452 |
+
/**
|
453 |
+
*
|
454 |
+
* @global type $wpdb
|
455 |
+
* @return boolean
|
456 |
+
*/
|
457 |
function total_count_albums() {
|
458 |
global $wpdb;
|
459 |
|
app/main/includes/BPMediaFunction.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
3 |
class BPMediaFunction {
|
4 |
|
5 |
function __construct() {
|
@@ -9,6 +11,12 @@ class BPMediaFunction {
|
|
9 |
add_action('wp_ajax_nopriv_my_featured_action', array($this, 'implement_featured_ajax'));
|
10 |
}
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
static function record_activity($args = '') {
|
13 |
global $bp;
|
14 |
if (!function_exists('bp_activity_add'))
|
@@ -22,6 +30,11 @@ class BPMediaFunction {
|
|
22 |
return $activity_id;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
25 |
static function override_allowed_tags($activity_allowedtags) {
|
26 |
$activity_allowedtags['video'] = array();
|
27 |
$activity_allowedtags['video']['id'] = array();
|
@@ -56,6 +69,11 @@ class BPMediaFunction {
|
|
56 |
return $activity_allowedtags;
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
59 |
static function show_formatted_error_message($messages, $type) {
|
60 |
echo '<div id="message" class="' . $type . '">';
|
61 |
if (is_array($messages)) {
|
@@ -82,6 +100,13 @@ class BPMediaFunction {
|
|
82 |
*
|
83 |
*/
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
function conditional_override_allowed_tags($content, $activity = null) {
|
86 |
global $bp_media;
|
87 |
|
@@ -99,6 +124,12 @@ class BPMediaFunction {
|
|
99 |
/**
|
100 |
* Updates the media count of all users.
|
101 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
static function update_count() {
|
103 |
global $wpdb;
|
104 |
$query =
|
@@ -133,6 +164,10 @@ class BPMediaFunction {
|
|
133 |
return true;
|
134 |
}
|
135 |
|
|
|
|
|
|
|
|
|
136 |
static function update_media() {
|
137 |
global $bp_media_current_entry;
|
138 |
if ($bp_media_current_entry->update_media(array('description' => esc_html($_POST['bp_media_description']), 'name' => esc_html($_POST['bp_media_title'])))) {
|
@@ -167,6 +202,12 @@ class BPMediaFunction {
|
|
167 |
exit;
|
168 |
}
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
static function update_album_activity($album, $current_time = true, $delete_media_id = null) {
|
171 |
if (!is_object($album)) {
|
172 |
$album = new BPMediaAlbum($album);
|
@@ -213,6 +254,10 @@ class BPMediaFunction {
|
|
213 |
}
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
216 |
static function wp_comment_form_mod() {
|
217 |
global $bp_media_current_entry;
|
218 |
echo '<input type="hidden" name="redirect_to" value="' . $bp_media_current_entry->get_url() . '">';
|
@@ -238,6 +283,14 @@ class BPMediaFunction {
|
|
238 |
* @param $type String Type of message(updated, success, error, warning), works only if message is set
|
239 |
* @param $status String The HTTP status header for the redirection page.
|
240 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
function redirect($location, $message = '', $type = 'updated', $status = '302') {
|
242 |
if ($message != '')
|
243 |
bp_core_add_message($message, 'error');
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*/
|
5 |
class BPMediaFunction {
|
6 |
|
7 |
function __construct() {
|
11 |
add_action('wp_ajax_nopriv_my_featured_action', array($this, 'implement_featured_ajax'));
|
12 |
}
|
13 |
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @global type $bp
|
17 |
+
* @param type $args
|
18 |
+
* @return boolean
|
19 |
+
*/
|
20 |
static function record_activity($args = '') {
|
21 |
global $bp;
|
22 |
if (!function_exists('bp_activity_add'))
|
30 |
return $activity_id;
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @param type $activity_allowedtags
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
static function override_allowed_tags($activity_allowedtags) {
|
39 |
$activity_allowedtags['video'] = array();
|
40 |
$activity_allowedtags['video']['id'] = array();
|
69 |
return $activity_allowedtags;
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
*
|
74 |
+
* @param type $messages
|
75 |
+
* @param type $type
|
76 |
+
*/
|
77 |
static function show_formatted_error_message($messages, $type) {
|
78 |
echo '<div id="message" class="' . $type . '">';
|
79 |
if (is_array($messages)) {
|
100 |
*
|
101 |
*/
|
102 |
|
103 |
+
/**
|
104 |
+
*
|
105 |
+
* @global type $bp_media
|
106 |
+
* @param type $content
|
107 |
+
* @param type $activity
|
108 |
+
* @return type
|
109 |
+
*/
|
110 |
function conditional_override_allowed_tags($content, $activity = null) {
|
111 |
global $bp_media;
|
112 |
|
124 |
/**
|
125 |
* Updates the media count of all users.
|
126 |
*/
|
127 |
+
|
128 |
+
/**
|
129 |
+
*
|
130 |
+
* @global type $wpdb
|
131 |
+
* @return boolean
|
132 |
+
*/
|
133 |
static function update_count() {
|
134 |
global $wpdb;
|
135 |
$query =
|
164 |
return true;
|
165 |
}
|
166 |
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @global type $bp_media_current_entry
|
170 |
+
*/
|
171 |
static function update_media() {
|
172 |
global $bp_media_current_entry;
|
173 |
if ($bp_media_current_entry->update_media(array('description' => esc_html($_POST['bp_media_description']), 'name' => esc_html($_POST['bp_media_title'])))) {
|
202 |
exit;
|
203 |
}
|
204 |
|
205 |
+
/**
|
206 |
+
*
|
207 |
+
* @param BPMediaAlbum $album
|
208 |
+
* @param type $current_time
|
209 |
+
* @param type $delete_media_id
|
210 |
+
*/
|
211 |
static function update_album_activity($album, $current_time = true, $delete_media_id = null) {
|
212 |
if (!is_object($album)) {
|
213 |
$album = new BPMediaAlbum($album);
|
254 |
}
|
255 |
}
|
256 |
|
257 |
+
/**
|
258 |
+
*
|
259 |
+
* @global type $bp_media_current_entry
|
260 |
+
*/
|
261 |
static function wp_comment_form_mod() {
|
262 |
global $bp_media_current_entry;
|
263 |
echo '<input type="hidden" name="redirect_to" value="' . $bp_media_current_entry->get_url() . '">';
|
283 |
* @param $type String Type of message(updated, success, error, warning), works only if message is set
|
284 |
* @param $status String The HTTP status header for the redirection page.
|
285 |
*/
|
286 |
+
|
287 |
+
/**
|
288 |
+
*
|
289 |
+
* @param type $location
|
290 |
+
* @param type $message
|
291 |
+
* @param type $type
|
292 |
+
* @param type $status
|
293 |
+
*/
|
294 |
function redirect($location, $message = '', $type = 'updated', $status = '302') {
|
295 |
if ($message != '')
|
296 |
bp_core_add_message($message, 'error');
|
app/main/includes/BPMediaHostWordpress.php
CHANGED
@@ -25,6 +25,10 @@ class BPMediaHostWordpress {
|
|
25 |
* @since BuddyPress Media 2.0
|
26 |
*/
|
27 |
|
|
|
|
|
|
|
|
|
28 |
function __construct($media_id = '') {
|
29 |
if (!$media_id == '') {
|
30 |
$this->init($media_id);
|
@@ -38,6 +42,13 @@ class BPMediaHostWordpress {
|
|
38 |
*
|
39 |
* @since BuddyPress Media 2.0
|
40 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
function init($media_id = '') {
|
42 |
if (is_object($media_id)) {
|
43 |
$media = $media_id;
|
@@ -59,9 +70,8 @@ class BPMediaHostWordpress {
|
|
59 |
* But for use in the class, we use group_id as positive integer even though
|
60 |
* we use it as negative value in the bp-media-key meta key
|
61 |
*/
|
62 |
-
|
63 |
$this->group_id = $meta_key < 0 ? -$meta_key : 0;
|
64 |
-
if (
|
65 |
preg_match_all('/audio|video|image/i', $media->post_mime_type, $result);
|
66 |
else
|
67 |
$result[0][0] = 'album';
|
@@ -77,6 +87,20 @@ class BPMediaHostWordpress {
|
|
77 |
*
|
78 |
* @since BuddyPress Media 2.0
|
79 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
function add_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false) {
|
81 |
do_action('bp_media_before_add_media');
|
82 |
global $bp, $wpdb, $bp_media_count, $bp_media;
|
@@ -205,6 +229,14 @@ class BPMediaHostWordpress {
|
|
205 |
* Fetches the content of the activity of media upload based on its type
|
206 |
*
|
207 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
function get_media_activity_content() {
|
209 |
global $bp_media_counter, $bp_media_default_excerpts, $bp_media;
|
210 |
$attachment_id = $this->id;
|
@@ -232,13 +264,18 @@ class BPMediaHostWordpress {
|
|
232 |
return false;
|
233 |
}
|
234 |
$activity_content .= '</div>';
|
235 |
-
$activity_content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['activity_entry_description']). '</div>';
|
236 |
return $activity_content;
|
237 |
}
|
238 |
|
239 |
/**
|
240 |
* Returns the single media entry's URL
|
241 |
*/
|
|
|
|
|
|
|
|
|
|
|
242 |
function get_media_activity_url() {
|
243 |
if (!bp_is_activity_component())
|
244 |
return false;
|
@@ -249,6 +286,12 @@ class BPMediaHostWordpress {
|
|
249 |
/**
|
250 |
* Returns the media activity's action text
|
251 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
function get_media_activity_action() {
|
253 |
global $bp_media;
|
254 |
if (!bp_is_activity_component())
|
@@ -260,6 +303,13 @@ class BPMediaHostWordpress {
|
|
260 |
/**
|
261 |
* Returns the HTML for content of the single entry page of the Media Entry
|
262 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
function get_media_single_content() {
|
264 |
global $bp_media_default_excerpts, $bp_media;
|
265 |
|
@@ -290,13 +340,20 @@ class BPMediaHostWordpress {
|
|
290 |
return false;
|
291 |
}
|
292 |
$content .= '</div>';
|
293 |
-
$content .= '<div class="bp_media_description">' .wp_html_excerpt($this->description, $bp_media_default_excerpts['single_entry_description']) . '</div>';
|
294 |
return $content;
|
295 |
}
|
296 |
|
297 |
/**
|
298 |
* Returns the HTML for title of the single entry page of the Media Entry
|
299 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
function get_media_single_title() {
|
301 |
global $bp_media_default_excerpts, $bp_media;
|
302 |
$content = '<div class="bp_media_title">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['single_entry_title']) . '</div>';
|
@@ -306,6 +363,12 @@ class BPMediaHostWordpress {
|
|
306 |
/**
|
307 |
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
308 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
function get_media_gallery_content() {
|
310 |
global $bp_media;
|
311 |
$attachment = $this->id;
|
@@ -370,6 +433,12 @@ class BPMediaHostWordpress {
|
|
370 |
/**
|
371 |
* Outputs the comments and comment form in the single media entry page
|
372 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
function show_comment_form() {
|
374 |
global $bp_media;
|
375 |
$activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
|
@@ -388,29 +457,29 @@ class BPMediaHostWordpress {
|
|
388 |
<ul id="activity-stream" class="activity-list item-list">
|
389 |
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
390 |
<div class="activity-content">
|
391 |
-
|
392 |
<?php if (is_user_logged_in()) : ?>
|
393 |
<div class="activity-meta no-ajax">
|
394 |
<?php if (bp_activity_can_comment()) : ?>
|
395 |
<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>', BP_MEDIA_TXT_DOMAIN), bp_activity_get_comment_count()); ?></a>
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
<a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
|
400 |
-
|
401 |
<a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Remove Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
|
402 |
-
<?php endif; ?>
|
403 |
<?php endif; ?>
|
404 |
-
|
405 |
-
|
|
|
406 |
</div>
|
407 |
-
|
408 |
</div>
|
409 |
-
|
410 |
-
|
411 |
<div class="activity-comments">
|
412 |
-
|
413 |
-
|
414 |
<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(); ?>>
|
415 |
<div class="ac-reply-avatar"><?php bp_loggedin_user_avatar('width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT); ?></div>
|
416 |
<div class="ac-reply-content">
|
@@ -420,26 +489,26 @@ class BPMediaHostWordpress {
|
|
420 |
<input type="submit" name="ac_form_submit" value="<?php _e('Post', BP_MEDIA_TXT_DOMAIN); ?>" /> <?php _e('or press esc to cancel.', BP_MEDIA_TXT_DOMAIN); ?>
|
421 |
<input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
|
422 |
</div>
|
423 |
-
|
424 |
-
|
425 |
</form>
|
426 |
-
|
427 |
</div>
|
428 |
-
|
429 |
<?php do_action('bp_after_activity_entry_comments'); ?>
|
430 |
</li>
|
431 |
</ul>
|
432 |
</div>
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
<div class="activity">
|
439 |
<ul id="activity-stream" class="activity-list item-list">
|
440 |
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
441 |
<div class="activity-content">
|
442 |
-
|
443 |
<?php if (is_user_logged_in()) : ?>
|
444 |
<div class="activity-meta no-ajax">
|
445 |
<a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow"><?php _e("Delete", BP_MEDIA_TXT_DOMAIN); ?></a>
|
@@ -456,6 +525,11 @@ class BPMediaHostWordpress {
|
|
456 |
/**
|
457 |
* Returns the URL of the single media entry page
|
458 |
*/
|
|
|
|
|
|
|
|
|
|
|
459 |
function get_url() {
|
460 |
return $this->url;
|
461 |
}
|
@@ -463,6 +537,11 @@ class BPMediaHostWordpress {
|
|
463 |
/**
|
464 |
* Returns the URL of the attached media file
|
465 |
*/
|
|
|
|
|
|
|
|
|
|
|
466 |
function get_attachment_url() {
|
467 |
return wp_get_attachment_url($this->id);
|
468 |
}
|
@@ -477,6 +556,12 @@ class BPMediaHostWordpress {
|
|
477 |
*
|
478 |
* @return bool True when the update is successful, False when the update fails
|
479 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
function update_media($args = array()) {
|
481 |
$defaults = array(
|
482 |
'name' => $this->name,
|
@@ -498,6 +583,14 @@ class BPMediaHostWordpress {
|
|
498 |
* Updates activity content's title and description sync with the editing of Media
|
499 |
*
|
500 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
function update_media_activity() {
|
502 |
global $wpdb, $bp, $current_user, $bp_media;
|
503 |
$q = $wpdb->prepare("SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id);
|
@@ -527,6 +620,11 @@ class BPMediaHostWordpress {
|
|
527 |
/**
|
528 |
* Deletes the Media Entry
|
529 |
*/
|
|
|
|
|
|
|
|
|
|
|
530 |
function delete_media() {
|
531 |
do_action('bp_media_before_delete_media', $this->id);
|
532 |
global $bp_media_count;
|
@@ -550,6 +648,11 @@ class BPMediaHostWordpress {
|
|
550 |
/**
|
551 |
* Function to return the content to be placed in the activity of album
|
552 |
*/
|
|
|
|
|
|
|
|
|
|
|
553 |
function get_album_activity_content() {
|
554 |
$attachment = $this->id;
|
555 |
switch ($this->type) {
|
@@ -587,6 +690,11 @@ class BPMediaHostWordpress {
|
|
587 |
/**
|
588 |
* Returns the description of the Media Entry
|
589 |
*/
|
|
|
|
|
|
|
|
|
|
|
590 |
function get_content() {
|
591 |
return $this->description;
|
592 |
}
|
@@ -594,6 +702,11 @@ class BPMediaHostWordpress {
|
|
594 |
/**
|
595 |
* Returns the owner id of the Media Entry
|
596 |
*/
|
|
|
|
|
|
|
|
|
|
|
597 |
function get_author() {
|
598 |
return $this->owner;
|
599 |
}
|
@@ -601,6 +714,11 @@ class BPMediaHostWordpress {
|
|
601 |
/**
|
602 |
* Returns the id of the Media Entry
|
603 |
*/
|
|
|
|
|
|
|
|
|
|
|
604 |
function get_id() {
|
605 |
return $this->id;
|
606 |
}
|
@@ -608,6 +726,11 @@ class BPMediaHostWordpress {
|
|
608 |
/**
|
609 |
* Returns the edit url of the Media Entry
|
610 |
*/
|
|
|
|
|
|
|
|
|
|
|
611 |
function get_edit_url() {
|
612 |
return $this->edit_url;
|
613 |
}
|
@@ -615,6 +738,11 @@ class BPMediaHostWordpress {
|
|
615 |
/**
|
616 |
* Returns the delete url of the Media Entry
|
617 |
*/
|
|
|
|
|
|
|
|
|
|
|
618 |
function get_delete_url() {
|
619 |
return $this->delete_url;
|
620 |
}
|
@@ -622,6 +750,11 @@ class BPMediaHostWordpress {
|
|
622 |
/**
|
623 |
* Returns the type of activity
|
624 |
*/
|
|
|
|
|
|
|
|
|
|
|
625 |
function get_media_activity_type() {
|
626 |
switch ($this->type) {
|
627 |
case 'image':
|
@@ -638,6 +771,11 @@ class BPMediaHostWordpress {
|
|
638 |
/**
|
639 |
* Returns the album id
|
640 |
*/
|
|
|
|
|
|
|
|
|
|
|
641 |
function get_album_id() {
|
642 |
return $this->album_id;
|
643 |
}
|
@@ -645,6 +783,11 @@ class BPMediaHostWordpress {
|
|
645 |
/**
|
646 |
* Returns the title of the media
|
647 |
*/
|
|
|
|
|
|
|
|
|
|
|
648 |
function get_title() {
|
649 |
return $this->name;
|
650 |
}
|
@@ -652,6 +795,11 @@ class BPMediaHostWordpress {
|
|
652 |
/**
|
653 |
* Returns the type of media
|
654 |
*/
|
|
|
|
|
|
|
|
|
|
|
655 |
function get_type() {
|
656 |
return $this->type;
|
657 |
}
|
@@ -666,6 +814,11 @@ class BPMediaHostWordpress {
|
|
666 |
/**
|
667 |
* Returns the group id of the media, 0 if it does not belong to a group
|
668 |
*/
|
|
|
|
|
|
|
|
|
|
|
669 |
function get_group_id() {
|
670 |
return $this->group_id;
|
671 |
}
|
@@ -674,6 +827,11 @@ class BPMediaHostWordpress {
|
|
674 |
* Sets the permalinks of the media depending upon whether its in member directory
|
675 |
* or group and acording to the media type
|
676 |
*/
|
|
|
|
|
|
|
|
|
|
|
677 |
protected function set_permalinks() {
|
678 |
if ($this->group_id > 0) {
|
679 |
$current_group = new BP_Groups_Group($this->group_id);
|
@@ -716,9 +874,17 @@ class BPMediaHostWordpress {
|
|
716 |
/**
|
717 |
* Checks if the album given exists if not, creates a new one according to context
|
718 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
719 |
function check_and_create_album($album_id, $group) {
|
720 |
global $wpdb;
|
721 |
-
$post_wall=__(
|
722 |
$create_new_album_flag = false;
|
723 |
if ($album_id != 0) {
|
724 |
$album = get_post($album_id);
|
25 |
* @since BuddyPress Media 2.0
|
26 |
*/
|
27 |
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @param type $media_id
|
31 |
+
*/
|
32 |
function __construct($media_id = '') {
|
33 |
if (!$media_id == '') {
|
34 |
$this->init($media_id);
|
42 |
*
|
43 |
* @since BuddyPress Media 2.0
|
44 |
*/
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @param type $media_id
|
49 |
+
* @return boolean
|
50 |
+
* @throws Exception
|
51 |
+
*/
|
52 |
function init($media_id = '') {
|
53 |
if (is_object($media_id)) {
|
54 |
$media = $media_id;
|
70 |
* But for use in the class, we use group_id as positive integer even though
|
71 |
* we use it as negative value in the bp-media-key meta key
|
72 |
*/
|
|
|
73 |
$this->group_id = $meta_key < 0 ? -$meta_key : 0;
|
74 |
+
if (!'bp_media_album' == $media->post_type || !empty($media->post_mime_type))
|
75 |
preg_match_all('/audio|video|image/i', $media->post_mime_type, $result);
|
76 |
else
|
77 |
$result[0][0] = 'album';
|
87 |
*
|
88 |
* @since BuddyPress Media 2.0
|
89 |
*/
|
90 |
+
|
91 |
+
/**
|
92 |
+
*
|
93 |
+
* @global type $bp
|
94 |
+
* @global type $wpdb
|
95 |
+
* @global type $bp_media_count
|
96 |
+
* @global type $bp_media
|
97 |
+
* @param type $name
|
98 |
+
* @param type $description
|
99 |
+
* @param type $album_id
|
100 |
+
* @param type $group
|
101 |
+
* @param type $is_multiple
|
102 |
+
* @throws Exception
|
103 |
+
*/
|
104 |
function add_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false) {
|
105 |
do_action('bp_media_before_add_media');
|
106 |
global $bp, $wpdb, $bp_media_count, $bp_media;
|
229 |
* Fetches the content of the activity of media upload based on its type
|
230 |
*
|
231 |
*/
|
232 |
+
|
233 |
+
/**
|
234 |
+
*
|
235 |
+
* @global type $bp_media_counter
|
236 |
+
* @global type $bp_media_default_excerpts
|
237 |
+
* @global type $bp_media
|
238 |
+
* @return boolean|string
|
239 |
+
*/
|
240 |
function get_media_activity_content() {
|
241 |
global $bp_media_counter, $bp_media_default_excerpts, $bp_media;
|
242 |
$attachment_id = $this->id;
|
264 |
return false;
|
265 |
}
|
266 |
$activity_content .= '</div>';
|
267 |
+
$activity_content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['activity_entry_description']) . '</div>';
|
268 |
return $activity_content;
|
269 |
}
|
270 |
|
271 |
/**
|
272 |
* Returns the single media entry's URL
|
273 |
*/
|
274 |
+
|
275 |
+
/**
|
276 |
+
*
|
277 |
+
* @return boolean
|
278 |
+
*/
|
279 |
function get_media_activity_url() {
|
280 |
if (!bp_is_activity_component())
|
281 |
return false;
|
286 |
/**
|
287 |
* Returns the media activity's action text
|
288 |
*/
|
289 |
+
|
290 |
+
/**
|
291 |
+
*
|
292 |
+
* @global type $bp_media
|
293 |
+
* @return boolean
|
294 |
+
*/
|
295 |
function get_media_activity_action() {
|
296 |
global $bp_media;
|
297 |
if (!bp_is_activity_component())
|
303 |
/**
|
304 |
* Returns the HTML for content of the single entry page of the Media Entry
|
305 |
*/
|
306 |
+
|
307 |
+
/**
|
308 |
+
*
|
309 |
+
* @global type $bp_media_default_excerpts
|
310 |
+
* @global type $bp_media
|
311 |
+
* @return boolean|string
|
312 |
+
*/
|
313 |
function get_media_single_content() {
|
314 |
global $bp_media_default_excerpts, $bp_media;
|
315 |
|
340 |
return false;
|
341 |
}
|
342 |
$content .= '</div>';
|
343 |
+
$content .= '<div class="bp_media_description">' . wp_html_excerpt($this->description, $bp_media_default_excerpts['single_entry_description']) . '</div>';
|
344 |
return $content;
|
345 |
}
|
346 |
|
347 |
/**
|
348 |
* Returns the HTML for title of the single entry page of the Media Entry
|
349 |
*/
|
350 |
+
|
351 |
+
/**
|
352 |
+
*
|
353 |
+
* @global type $bp_media_default_excerpts
|
354 |
+
* @global type $bp_media
|
355 |
+
* @return string
|
356 |
+
*/
|
357 |
function get_media_single_title() {
|
358 |
global $bp_media_default_excerpts, $bp_media;
|
359 |
$content = '<div class="bp_media_title">' . wp_html_excerpt($this->name, $bp_media_default_excerpts['single_entry_title']) . '</div>';
|
363 |
/**
|
364 |
* Returns the HTML for a media entry to be shown in the listing/gallery page
|
365 |
*/
|
366 |
+
|
367 |
+
/**
|
368 |
+
*
|
369 |
+
* @global type $bp_media
|
370 |
+
* @return boolean
|
371 |
+
*/
|
372 |
function get_media_gallery_content() {
|
373 |
global $bp_media;
|
374 |
$attachment = $this->id;
|
433 |
/**
|
434 |
* Outputs the comments and comment form in the single media entry page
|
435 |
*/
|
436 |
+
|
437 |
+
/**
|
438 |
+
*
|
439 |
+
* @global type $bp_media
|
440 |
+
* @return boolean
|
441 |
+
*/
|
442 |
function show_comment_form() {
|
443 |
global $bp_media;
|
444 |
$activity_id = get_post_meta($this->id, 'bp_media_child_activity', true);
|
457 |
<ul id="activity-stream" class="activity-list item-list">
|
458 |
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
459 |
<div class="activity-content">
|
460 |
+
<?php do_action('bp_activity_entry_content'); ?>
|
461 |
<?php if (is_user_logged_in()) : ?>
|
462 |
<div class="activity-meta no-ajax">
|
463 |
<?php if (bp_activity_can_comment()) : ?>
|
464 |
<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>', BP_MEDIA_TXT_DOMAIN), bp_activity_get_comment_count()); ?></a>
|
465 |
+
<?php endif; ?>
|
466 |
+
<?php if (bp_activity_can_favorite()) : ?>
|
467 |
+
<?php if (!bp_get_activity_is_favorite()) : ?>
|
468 |
<a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e('Mark as Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
|
469 |
+
<?php else : ?>
|
470 |
<a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e('Remove Favorite', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('Remove Favorite', BP_MEDIA_TXT_DOMAIN) ?></a>
|
|
|
471 |
<?php endif; ?>
|
472 |
+
<?php endif; ?>
|
473 |
+
<?php if (bp_activity_user_can_delete()) bp_activity_delete_link(); ?>
|
474 |
+
<?php do_action('bp_activity_entry_meta'); ?>
|
475 |
</div>
|
476 |
+
<?php endif; ?>
|
477 |
</div>
|
478 |
+
<?php do_action('bp_before_activity_entry_comments'); ?>
|
479 |
+
<?php if (( is_user_logged_in() && bp_activity_can_comment() ) || bp_activity_get_comment_count()) : ?>
|
480 |
<div class="activity-comments">
|
481 |
+
<?php bp_activity_comments(); ?>
|
482 |
+
<?php if (is_user_logged_in()) : ?>
|
483 |
<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(); ?>>
|
484 |
<div class="ac-reply-avatar"><?php bp_loggedin_user_avatar('width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT); ?></div>
|
485 |
<div class="ac-reply-content">
|
489 |
<input type="submit" name="ac_form_submit" value="<?php _e('Post', BP_MEDIA_TXT_DOMAIN); ?>" /> <?php _e('or press esc to cancel.', BP_MEDIA_TXT_DOMAIN); ?>
|
490 |
<input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
|
491 |
</div>
|
492 |
+
<?php do_action('bp_activity_entry_comments'); ?>
|
493 |
+
<?php wp_nonce_field('new_activity_comment', '_wpnonce_new_activity_comment'); ?>
|
494 |
</form>
|
495 |
+
<?php endif; ?>
|
496 |
</div>
|
497 |
+
<?php endif; ?>
|
498 |
<?php do_action('bp_after_activity_entry_comments'); ?>
|
499 |
</li>
|
500 |
</ul>
|
501 |
</div>
|
502 |
+
<?php
|
503 |
+
}
|
504 |
+
}
|
505 |
+
else {
|
506 |
+
?>
|
507 |
<div class="activity">
|
508 |
<ul id="activity-stream" class="activity-list item-list">
|
509 |
<li class="activity activity_update" id="activity-<?php echo $activity_id; ?>">
|
510 |
<div class="activity-content">
|
511 |
+
<?php do_action('bp_activity_entry_content'); ?>
|
512 |
<?php if (is_user_logged_in()) : ?>
|
513 |
<div class="activity-meta no-ajax">
|
514 |
<a href="<?php echo $this->get_delete_url(); ?>" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow"><?php _e("Delete", BP_MEDIA_TXT_DOMAIN); ?></a>
|
525 |
/**
|
526 |
* Returns the URL of the single media entry page
|
527 |
*/
|
528 |
+
|
529 |
+
/**
|
530 |
+
*
|
531 |
+
* @return type
|
532 |
+
*/
|
533 |
function get_url() {
|
534 |
return $this->url;
|
535 |
}
|
537 |
/**
|
538 |
* Returns the URL of the attached media file
|
539 |
*/
|
540 |
+
|
541 |
+
/**
|
542 |
+
*
|
543 |
+
* @return type
|
544 |
+
*/
|
545 |
function get_attachment_url() {
|
546 |
return wp_get_attachment_url($this->id);
|
547 |
}
|
556 |
*
|
557 |
* @return bool True when the update is successful, False when the update fails
|
558 |
*/
|
559 |
+
|
560 |
+
/**
|
561 |
+
*
|
562 |
+
* @param type $args
|
563 |
+
* @return type
|
564 |
+
*/
|
565 |
function update_media($args = array()) {
|
566 |
$defaults = array(
|
567 |
'name' => $this->name,
|
583 |
* Updates activity content's title and description sync with the editing of Media
|
584 |
*
|
585 |
*/
|
586 |
+
|
587 |
+
/**
|
588 |
+
*
|
589 |
+
* @global type $wpdb
|
590 |
+
* @global type $bp
|
591 |
+
* @global type $current_user
|
592 |
+
* @global type $bp_media
|
593 |
+
*/
|
594 |
function update_media_activity() {
|
595 |
global $wpdb, $bp, $current_user, $bp_media;
|
596 |
$q = $wpdb->prepare("SELECT id FROM {$bp->activity->table_name} WHERE type = %s AND item_id = %d", 'media_upload', $this->id);
|
620 |
/**
|
621 |
* Deletes the Media Entry
|
622 |
*/
|
623 |
+
|
624 |
+
/**
|
625 |
+
*
|
626 |
+
* @global type $bp_media_count
|
627 |
+
*/
|
628 |
function delete_media() {
|
629 |
do_action('bp_media_before_delete_media', $this->id);
|
630 |
global $bp_media_count;
|
648 |
/**
|
649 |
* Function to return the content to be placed in the activity of album
|
650 |
*/
|
651 |
+
|
652 |
+
/**
|
653 |
+
*
|
654 |
+
* @return boolean|string
|
655 |
+
*/
|
656 |
function get_album_activity_content() {
|
657 |
$attachment = $this->id;
|
658 |
switch ($this->type) {
|
690 |
/**
|
691 |
* Returns the description of the Media Entry
|
692 |
*/
|
693 |
+
|
694 |
+
/**
|
695 |
+
*
|
696 |
+
* @return type
|
697 |
+
*/
|
698 |
function get_content() {
|
699 |
return $this->description;
|
700 |
}
|
702 |
/**
|
703 |
* Returns the owner id of the Media Entry
|
704 |
*/
|
705 |
+
|
706 |
+
/**
|
707 |
+
*
|
708 |
+
* @return type
|
709 |
+
*/
|
710 |
function get_author() {
|
711 |
return $this->owner;
|
712 |
}
|
714 |
/**
|
715 |
* Returns the id of the Media Entry
|
716 |
*/
|
717 |
+
|
718 |
+
/**
|
719 |
+
*
|
720 |
+
* @return type
|
721 |
+
*/
|
722 |
function get_id() {
|
723 |
return $this->id;
|
724 |
}
|
726 |
/**
|
727 |
* Returns the edit url of the Media Entry
|
728 |
*/
|
729 |
+
|
730 |
+
/**
|
731 |
+
*
|
732 |
+
* @return type
|
733 |
+
*/
|
734 |
function get_edit_url() {
|
735 |
return $this->edit_url;
|
736 |
}
|
738 |
/**
|
739 |
* Returns the delete url of the Media Entry
|
740 |
*/
|
741 |
+
|
742 |
+
/**
|
743 |
+
*
|
744 |
+
* @return type
|
745 |
+
*/
|
746 |
function get_delete_url() {
|
747 |
return $this->delete_url;
|
748 |
}
|
750 |
/**
|
751 |
* Returns the type of activity
|
752 |
*/
|
753 |
+
|
754 |
+
/**
|
755 |
+
*
|
756 |
+
* @return string
|
757 |
+
*/
|
758 |
function get_media_activity_type() {
|
759 |
switch ($this->type) {
|
760 |
case 'image':
|
771 |
/**
|
772 |
* Returns the album id
|
773 |
*/
|
774 |
+
|
775 |
+
/**
|
776 |
+
*
|
777 |
+
* @return type
|
778 |
+
*/
|
779 |
function get_album_id() {
|
780 |
return $this->album_id;
|
781 |
}
|
783 |
/**
|
784 |
* Returns the title of the media
|
785 |
*/
|
786 |
+
|
787 |
+
/**
|
788 |
+
*
|
789 |
+
* @return type
|
790 |
+
*/
|
791 |
function get_title() {
|
792 |
return $this->name;
|
793 |
}
|
795 |
/**
|
796 |
* Returns the type of media
|
797 |
*/
|
798 |
+
|
799 |
+
/**
|
800 |
+
*
|
801 |
+
* @return type
|
802 |
+
*/
|
803 |
function get_type() {
|
804 |
return $this->type;
|
805 |
}
|
814 |
/**
|
815 |
* Returns the group id of the media, 0 if it does not belong to a group
|
816 |
*/
|
817 |
+
|
818 |
+
/**
|
819 |
+
*
|
820 |
+
* @return type
|
821 |
+
*/
|
822 |
function get_group_id() {
|
823 |
return $this->group_id;
|
824 |
}
|
827 |
* Sets the permalinks of the media depending upon whether its in member directory
|
828 |
* or group and acording to the media type
|
829 |
*/
|
830 |
+
|
831 |
+
/**
|
832 |
+
*
|
833 |
+
* @return boolean
|
834 |
+
*/
|
835 |
protected function set_permalinks() {
|
836 |
if ($this->group_id > 0) {
|
837 |
$current_group = new BP_Groups_Group($this->group_id);
|
874 |
/**
|
875 |
* Checks if the album given exists if not, creates a new one according to context
|
876 |
*/
|
877 |
+
|
878 |
+
/**
|
879 |
+
*
|
880 |
+
* @global type $wpdb
|
881 |
+
* @param type $album_id
|
882 |
+
* @param type $group
|
883 |
+
* @return type
|
884 |
+
*/
|
885 |
function check_and_create_album($album_id, $group) {
|
886 |
global $wpdb;
|
887 |
+
$post_wall = __('Wall Posts', BP_MEDIA_TXT_DOMAIN);
|
888 |
$create_new_album_flag = false;
|
889 |
if ($album_id != 0) {
|
890 |
$album = get_post($album_id);
|
app/main/includes/BPMediaTemplateFunctions.php
CHANGED
@@ -2,6 +2,12 @@
|
|
2 |
|
3 |
class BPMediaTemplateFunctions {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
function show_upload_form() {
|
6 |
global $bp, $bp_media_default_excerpts, $bp_media_options;
|
7 |
$allowed = array(
|
@@ -35,7 +41,15 @@ class BPMediaTemplateFunctions {
|
|
35 |
}
|
36 |
|
37 |
//------------- Function removed show_upload_form_multiple() ------------
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
function show_pagination($type = 'top', $inner = false) {
|
40 |
global $bp, $bp_media_paginated_links, $bp_media_query, $bp_media_albums_query;
|
41 |
switch ($bp->current_action) {
|
@@ -111,15 +125,21 @@ class BPMediaTemplateFunctions {
|
|
111 |
Viewing <?php echo $current_single ?> <?php echo $from_num ?> to <?php echo $to_num ?> (of <?php echo $total; ?> <?php echo $current ?>)
|
112 |
</div>
|
113 |
<div class="pagination-links">
|
114 |
-
|
115 |
-
|
116 |
<?php endforeach;
|
117 |
-
endif;
|
|
|
118 |
</div>
|
119 |
</div>
|
120 |
<?php
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
|
|
123 |
function get_permalink($id = 0) {
|
124 |
if (is_object($id))
|
125 |
$media = $id;
|
@@ -165,6 +185,11 @@ class BPMediaTemplateFunctions {
|
|
165 |
}
|
166 |
}
|
167 |
|
|
|
|
|
|
|
|
|
|
|
168 |
function album_the_content($id = 0) {
|
169 |
if (is_object($id))
|
170 |
$album = $id;
|
@@ -182,6 +207,12 @@ class BPMediaTemplateFunctions {
|
|
182 |
}
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
function display_show_more($type = 'media') {
|
186 |
$showmore = false;
|
187 |
switch ($type) {
|
@@ -198,12 +229,10 @@ class BPMediaTemplateFunctions {
|
|
198 |
break;
|
199 |
}
|
200 |
if ($showmore) {
|
201 |
-
echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">'. __('Show More', BP_MEDIA_TXT_DOMAIN).'</a></div>';
|
202 |
}
|
203 |
}
|
204 |
|
205 |
//----------- Function removed show_upload_form_multiple_activity() -------------
|
206 |
-
|
207 |
-
|
208 |
}
|
209 |
?>
|
2 |
|
3 |
class BPMediaTemplateFunctions {
|
4 |
|
5 |
+
/**
|
6 |
+
*
|
7 |
+
* @global type $bp
|
8 |
+
* @global type $bp_media_default_excerpts
|
9 |
+
* @global type $bp_media_options
|
10 |
+
*/
|
11 |
function show_upload_form() {
|
12 |
global $bp, $bp_media_default_excerpts, $bp_media_options;
|
13 |
$allowed = array(
|
41 |
}
|
42 |
|
43 |
//------------- Function removed show_upload_form_multiple() ------------
|
44 |
+
/**
|
45 |
+
*
|
46 |
+
* @global type $bp
|
47 |
+
* @global type $bp_media_paginated_links
|
48 |
+
* @global type $bp_media_query
|
49 |
+
* @global type $bp_media_albums_query
|
50 |
+
* @param type $type
|
51 |
+
* @param type $inner
|
52 |
+
*/
|
53 |
function show_pagination($type = 'top', $inner = false) {
|
54 |
global $bp, $bp_media_paginated_links, $bp_media_query, $bp_media_albums_query;
|
55 |
switch ($bp->current_action) {
|
125 |
Viewing <?php echo $current_single ?> <?php echo $from_num ?> to <?php echo $to_num ?> (of <?php echo $total; ?> <?php echo $current ?>)
|
126 |
</div>
|
127 |
<div class="pagination-links">
|
128 |
+
<?php if (is_array($bp_media_paginated_links)) : foreach ($bp_media_paginated_links as $link) : ?>
|
129 |
+
<?php echo $link; ?>
|
130 |
<?php endforeach;
|
131 |
+
endif;
|
132 |
+
?>
|
133 |
</div>
|
134 |
</div>
|
135 |
<?php
|
136 |
}
|
137 |
|
138 |
+
/**
|
139 |
+
*
|
140 |
+
* @param type $id
|
141 |
+
* @return boolean
|
142 |
+
*/
|
143 |
function get_permalink($id = 0) {
|
144 |
if (is_object($id))
|
145 |
$media = $id;
|
185 |
}
|
186 |
}
|
187 |
|
188 |
+
/**
|
189 |
+
*
|
190 |
+
* @param type $id
|
191 |
+
* @return boolean
|
192 |
+
*/
|
193 |
function album_the_content($id = 0) {
|
194 |
if (is_object($id))
|
195 |
$album = $id;
|
207 |
}
|
208 |
}
|
209 |
|
210 |
+
/**
|
211 |
+
*
|
212 |
+
* @global type $bp_media_query
|
213 |
+
* @global type $bp_media_albums_query
|
214 |
+
* @param type $type
|
215 |
+
*/
|
216 |
function display_show_more($type = 'media') {
|
217 |
$showmore = false;
|
218 |
switch ($type) {
|
229 |
break;
|
230 |
}
|
231 |
if ($showmore) {
|
232 |
+
echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">' . __('Show More', BP_MEDIA_TXT_DOMAIN) . '</a></div>';
|
233 |
}
|
234 |
}
|
235 |
|
236 |
//----------- Function removed show_upload_form_multiple_activity() -------------
|
|
|
|
|
237 |
}
|
238 |
?>
|
app/main/includes/BPMediaUpgradeScript.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
class BPMediaUpgradeScript{
|
3 |
-
|
|
|
|
|
|
|
4 |
static function upgrade_from_1_0_to_2_1(){
|
5 |
global $wpdb;
|
6 |
$post_wall =__( 'Wall Posts', BP_MEDIA_TXT_DOMAIN );
|
@@ -69,12 +72,12 @@ class BPMediaUpgradeScript{
|
|
69 |
add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
|
70 |
wp_cache_flush();
|
71 |
}
|
72 |
-
|
73 |
static function database_updated_notice(){
|
74 |
echo '<div class="updated rt-success"><p>
|
75 |
<b>BuddyPress Media</b> Database upgraded successfully.
|
76 |
</p></div>';
|
77 |
}
|
|
|
78 |
static function upgrade_from_2_0_to_2_1(){
|
79 |
$page = 0;
|
80 |
while($media_entries = BPMediaUpgradeScript::return_query_posts(array(
|
@@ -117,7 +120,11 @@ class BPMediaUpgradeScript{
|
|
117 |
add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
|
118 |
wp_cache_flush();
|
119 |
}
|
120 |
-
|
|
|
|
|
|
|
|
|
121 |
static function return_query_posts($args){
|
122 |
$bp_media_query = new WP_Query($args);
|
123 |
return $bp_media_query->posts;
|
1 |
<?php
|
2 |
class BPMediaUpgradeScript{
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
* @global wpdb $wpdb
|
6 |
+
*/
|
7 |
static function upgrade_from_1_0_to_2_1(){
|
8 |
global $wpdb;
|
9 |
$post_wall =__( 'Wall Posts', BP_MEDIA_TXT_DOMAIN );
|
72 |
add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
|
73 |
wp_cache_flush();
|
74 |
}
|
|
|
75 |
static function database_updated_notice(){
|
76 |
echo '<div class="updated rt-success"><p>
|
77 |
<b>BuddyPress Media</b> Database upgraded successfully.
|
78 |
</p></div>';
|
79 |
}
|
80 |
+
|
81 |
static function upgrade_from_2_0_to_2_1(){
|
82 |
$page = 0;
|
83 |
while($media_entries = BPMediaUpgradeScript::return_query_posts(array(
|
120 |
add_action('admin_notices','BPMediaUpgradeScript::database_updated_notice');
|
121 |
wp_cache_flush();
|
122 |
}
|
123 |
+
/**
|
124 |
+
*
|
125 |
+
* @param type $args
|
126 |
+
* @return type
|
127 |
+
*/
|
128 |
static function return_query_posts($args){
|
129 |
$bp_media_query = new WP_Query($args);
|
130 |
return $bp_media_query->posts;
|
app/main/profile/BPMediaAlbum.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Adds the album screens and functionality
|
4 |
*
|
@@ -9,277 +10,345 @@
|
|
9 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
10 |
*
|
11 |
*/
|
12 |
-
class BPMediaAlbum{
|
13 |
-
private $id,
|
14 |
-
$name,
|
15 |
-
$description,
|
16 |
-
$url,
|
17 |
-
$owner,
|
18 |
-
$delete_url,
|
19 |
-
$thumbnail,
|
20 |
-
$edit_url,
|
21 |
-
$media_entries,
|
22 |
-
$group_id;
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
*/
|
35 |
-
function __construct($album_id = '') {
|
36 |
-
if (!$album_id == '') {
|
37 |
-
$this->init($album_id);
|
38 |
-
}
|
39 |
-
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
*/
|
53 |
-
function init($album_id){
|
54 |
-
if (is_object($album_id)) {
|
55 |
-
$album = $album_id;
|
56 |
-
} else {
|
57 |
-
$album = &get_post($album_id);
|
58 |
-
}
|
59 |
-
if (empty($album->ID))
|
60 |
-
throw new Exception(__('Sorry, the requested album does not exist.', BP_MEDIA_TXT_DOMAIN));
|
61 |
-
$this->id = $album->ID;
|
62 |
-
$this->description = $album->post_content;
|
63 |
-
$this->name = $album->post_title;
|
64 |
-
$this->owner = $album->post_author;
|
65 |
-
$meta_key = get_post_meta($this->id, 'bp-media-key', true);
|
66 |
-
/**
|
67 |
-
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
68 |
-
* if the value is less than 0 it means it the group id to which the media belongs
|
69 |
-
* and if its greater than 0 then it means its the author id of the uploader
|
70 |
-
* But for use in the class, we use group_id as positive integer even though
|
71 |
-
* we use it as negative value in the bp-media-key meta key
|
72 |
-
*/
|
73 |
-
$this->group_id = $meta_key<0?-$meta_key:0;
|
74 |
-
if($this->group_id>0){
|
75 |
-
$current_group = new BP_Groups_Group($this->group_id);
|
76 |
-
$group_url = bp_get_group_permalink($current_group);
|
77 |
-
$this->url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
78 |
-
$this->edit_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
79 |
-
$this->delete_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
80 |
-
}
|
81 |
-
else{
|
82 |
-
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
83 |
-
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
84 |
-
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
85 |
-
}
|
86 |
-
$attachments = get_children(array(
|
87 |
-
'numberposts' => 1,
|
88 |
-
'order'=> 'DESC',
|
89 |
-
'post_mime_type' => 'image',
|
90 |
-
'post_parent' => $this->id,
|
91 |
-
'post_type' => 'attachment'
|
92 |
-
));
|
93 |
-
$attachments_featured = get_children(array(
|
94 |
-
'numberposts' => 1,
|
95 |
-
'meta_key' => 'featured',
|
96 |
-
'orderby' => 'meta_value',
|
97 |
-
'post_mime_type' => 'image',
|
98 |
-
'post_parent' => $this->id,
|
99 |
-
'post_type' => 'attachment',
|
100 |
-
));
|
101 |
-
if($attachments_featured) {
|
102 |
-
foreach($attachments_featured as $attachment) {
|
103 |
-
$this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
|
104 |
-
}
|
105 |
-
}elseif ($attachments) {
|
106 |
-
foreach($attachments as $attachment) {
|
107 |
-
$this->thumbnail = '<span><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></span>';
|
108 |
-
}
|
109 |
-
}else{
|
110 |
-
$this->thumbnail = '<img src ="'.BP_MEDIA_URL.'app/assets/img/image_thumb.png">';
|
111 |
-
}
|
112 |
-
$this->media_entries = get_children(array(
|
113 |
-
'post_parent' => $this->id,
|
114 |
-
'post_type' => 'attachment'
|
115 |
-
));
|
116 |
-
}
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
function add_album($title,$author_id = 0, $group_id = 0){
|
128 |
-
do_action('bp_media_before_add_album');
|
129 |
-
$author_id = $author_id?$author_id:get_current_user_id();
|
130 |
-
$post_vars = array(
|
131 |
-
'post_title' => $title,
|
132 |
-
'post_name' => $title,
|
133 |
-
'post_status' => 'publish',
|
134 |
-
'post_type' => 'bp_media_album',
|
135 |
-
'post_author' => $author_id
|
136 |
-
);
|
137 |
-
BPMediaActions::init_count($author_id);
|
138 |
-
global $bp_media_count;
|
139 |
-
$album_id = wp_insert_post($post_vars);
|
140 |
-
if($group_id){
|
141 |
-
add_post_meta($album_id, 'bp-media-key', (-$group_id));
|
142 |
-
}
|
143 |
-
else{
|
144 |
-
add_post_meta($album_id, 'bp-media-key', $author_id);
|
145 |
-
}
|
146 |
-
$this->init($album_id);
|
147 |
-
$bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) + 1;
|
148 |
-
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
149 |
-
do_action('bp_media_after_add_album',$this);
|
150 |
-
return $album_id;
|
151 |
-
}
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
-
$author_id = $this->owner;
|
167 |
-
BPMediaActions::init_count($author_id);
|
168 |
-
wp_delete_post($this->id,true);
|
169 |
-
global $bp_media_count;
|
170 |
-
$bp_media_count['albums'] = intval(isset($bp_media_count['albums'])?$bp_media_count['albums']:0) - 1;
|
171 |
-
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
172 |
-
do_action('bp_media_after_delete_album', $this);
|
173 |
-
}
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description,BP_MEDIA_TXT_DOMAIN); ?>"><?php echo ( ( strlen( $this->name ) > 14 ) ? substr( $this->name, 0, 14 ) . "…" : $this->name );?> </a><?php echo ' ('.count($this->media_entries).')'; ?></h3>
|
207 |
-
</li><?php
|
208 |
-
}
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
function get_title(){
|
225 |
-
return $this->name;
|
226 |
-
}
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
-
/**
|
265 |
-
* Returns the edit url of the album
|
266 |
-
*/
|
267 |
-
function get_edit_url(){
|
268 |
-
return $this->edit_url;
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Returns the delete url of the album
|
273 |
-
*/
|
274 |
-
function get_delete_url(){
|
275 |
-
return $this->delete_url;
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Returns the group id to which the media belongs, 0 if it does not belong to any group
|
280 |
-
*/
|
281 |
-
function get_group_id(){
|
282 |
-
return $this->group_id;
|
283 |
-
}
|
284 |
}
|
285 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Adds the album screens and functionality
|
5 |
*
|
10 |
* @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
|
11 |
*
|
12 |
*/
|
13 |
+
class BPMediaAlbum {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
private $id,
|
16 |
+
$name,
|
17 |
+
$description,
|
18 |
+
$url,
|
19 |
+
$owner,
|
20 |
+
$delete_url,
|
21 |
+
$thumbnail,
|
22 |
+
$edit_url,
|
23 |
+
$media_entries,
|
24 |
+
$group_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @param type $album_id
|
29 |
+
*/
|
30 |
+
/**
|
31 |
+
* Constructs a new BP_Media_Album
|
32 |
+
*
|
33 |
+
* @param mixed $album_id optional Album ID of the element to be initialized if not defined, returns an empty element.
|
34 |
+
*
|
35 |
+
* @since BuddyPress Media 2.2
|
36 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
/**
|
39 |
+
*
|
40 |
+
* @param type $album_id
|
41 |
+
*/
|
42 |
+
function __construct($album_id = '') {
|
43 |
+
if (!$album_id == '') {
|
44 |
+
$this->init($album_id);
|
45 |
+
}
|
46 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
+
/**
|
49 |
+
*
|
50 |
+
* @param type $album_id
|
51 |
+
* @throws Exception
|
52 |
+
*/
|
53 |
+
/**
|
54 |
+
* Initializes the object
|
55 |
+
*
|
56 |
+
* @param mixed $album_id Album ID of the element to be initialized. Can be the ID or the object of the Album
|
57 |
+
*
|
58 |
+
* @since BuddyPress Media 2.2
|
59 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @param type $album_id
|
64 |
+
* @throws Exception
|
65 |
+
*/
|
66 |
+
function init($album_id) {
|
67 |
+
if (is_object($album_id)) {
|
68 |
+
$album = $album_id;
|
69 |
+
} else {
|
70 |
+
$album = &get_post($album_id);
|
71 |
+
}
|
72 |
+
if (empty($album->ID))
|
73 |
+
throw new Exception(__('Sorry, the requested album does not exist.', BP_MEDIA_TXT_DOMAIN));
|
74 |
+
$this->id = $album->ID;
|
75 |
+
$this->description = $album->post_content;
|
76 |
+
$this->name = $album->post_title;
|
77 |
+
$this->owner = $album->post_author;
|
78 |
+
$meta_key = get_post_meta($this->id, 'bp-media-key', true);
|
79 |
+
/**
|
80 |
+
* We use bp-media-key to distinguish if the entry belongs to a group or not
|
81 |
+
* if the value is less than 0 it means it the group id to which the media belongs
|
82 |
+
* and if its greater than 0 then it means its the author id of the uploader
|
83 |
+
* But for use in the class, we use group_id as positive integer even though
|
84 |
+
* we use it as negative value in the bp-media-key meta key
|
85 |
+
*/
|
86 |
+
$this->group_id = $meta_key < 0 ? -$meta_key : 0;
|
87 |
+
if ($this->group_id > 0) {
|
88 |
+
$current_group = new BP_Groups_Group($this->group_id);
|
89 |
+
$group_url = bp_get_group_permalink($current_group);
|
90 |
+
$this->url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
91 |
+
$this->edit_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
92 |
+
$this->delete_url = trailingslashit($group_url . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
93 |
+
} else {
|
94 |
+
$this->url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . $this->id);
|
95 |
+
$this->edit_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_ALBUMS_EDIT_SLUG . '/' . $this->id);
|
96 |
+
$this->delete_url = trailingslashit(bp_core_get_user_domain($this->owner) . BP_MEDIA_ALBUMS_SLUG . '/' . BP_MEDIA_DELETE_SLUG . '/' . $this->id);
|
97 |
+
}
|
98 |
+
$attachments = get_children(array(
|
99 |
+
'numberposts' => 1,
|
100 |
+
'order' => 'DESC',
|
101 |
+
'post_mime_type' => 'image',
|
102 |
+
'post_parent' => $this->id,
|
103 |
+
'post_type' => 'attachment'
|
104 |
+
));
|
105 |
+
$attachments_featured = get_children(array(
|
106 |
+
'numberposts' => 1,
|
107 |
+
'meta_key' => 'featured',
|
108 |
+
'orderby' => 'meta_value',
|
109 |
+
'post_mime_type' => 'image',
|
110 |
+
'post_parent' => $this->id,
|
111 |
+
'post_type' => 'attachment',
|
112 |
+
));
|
113 |
+
if ($attachments_featured) {
|
114 |
+
foreach ($attachments_featured as $attachment) {
|
115 |
+
$this->thumbnail = '<span><img src="' . wp_get_attachment_thumb_url($attachment->ID) . '"></span>';
|
116 |
+
}
|
117 |
+
} elseif ($attachments) {
|
118 |
+
foreach ($attachments as $attachment) {
|
119 |
+
$this->thumbnail = '<span><img src="' . wp_get_attachment_thumb_url($attachment->ID) . '"></span>';
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
$this->thumbnail = '<img src ="' . BP_MEDIA_URL . 'app/assets/img/image_thumb.png">';
|
123 |
+
}
|
124 |
+
$this->media_entries = get_children(array(
|
125 |
+
'post_parent' => $this->id,
|
126 |
+
'post_type' => 'attachment'
|
127 |
+
));
|
128 |
+
}
|
129 |
|
130 |
+
/**
|
131 |
+
* Adds a new album and initializes the object with the new album
|
132 |
+
*
|
133 |
+
* @param string $title The title of the album.
|
134 |
+
* @param string $author_id Optional The author id, defaults to zero in which case takes the logged in user id.
|
135 |
+
* @param string $group_id Optional The group id to which the album belongs, defaults to 0 meaning its not attached with a group.
|
136 |
+
*
|
137 |
+
* @since BuddyPress Media 2.2
|
138 |
+
*/
|
|
|
|
|
|
|
139 |
|
140 |
+
/**
|
141 |
+
*
|
142 |
+
* @global array $bp_media_count
|
143 |
+
* @param type $title
|
144 |
+
* @param type $author_id
|
145 |
+
* @param type $group_id
|
146 |
+
* @return type
|
147 |
+
*/
|
148 |
+
function add_album($title, $author_id = 0, $group_id = 0) {
|
149 |
+
do_action('bp_media_before_add_album');
|
150 |
+
$author_id = $author_id ? $author_id : get_current_user_id();
|
151 |
+
$post_vars = array(
|
152 |
+
'post_title' => $title,
|
153 |
+
'post_name' => $title,
|
154 |
+
'post_status' => 'publish',
|
155 |
+
'post_type' => 'bp_media_album',
|
156 |
+
'post_author' => $author_id
|
157 |
+
);
|
158 |
+
BPMediaActions::init_count($author_id);
|
159 |
+
global $bp_media_count;
|
160 |
+
$album_id = wp_insert_post($post_vars);
|
161 |
+
if ($group_id) {
|
162 |
+
add_post_meta($album_id, 'bp-media-key', (-$group_id));
|
163 |
+
} else {
|
164 |
+
add_post_meta($album_id, 'bp-media-key', $author_id);
|
165 |
+
}
|
166 |
+
$this->init($album_id);
|
167 |
+
$bp_media_count['albums'] = intval(isset($bp_media_count['albums']) ? $bp_media_count['albums'] : 0) + 1;
|
168 |
+
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
169 |
+
do_action('bp_media_after_add_album', $this);
|
170 |
+
return $album_id;
|
171 |
+
}
|
172 |
|
173 |
+
/**
|
174 |
+
* Deletes the album and all associated attachments
|
175 |
+
*
|
176 |
+
* @since BuddyPress Media 2.2
|
177 |
+
*/
|
|
|
|
|
|
|
178 |
|
179 |
+
/**
|
180 |
+
*
|
181 |
+
* @global array $bp_media_count
|
182 |
+
*/
|
183 |
+
function delete_album() {
|
184 |
+
do_action('bp_media_before_delete_album', $this);
|
185 |
+
foreach ($this->media_entries as $entry) {
|
186 |
+
BPMediaActions::delete_media_handler($entry->ID);
|
187 |
+
//do_action('bp_media_before_delete_media',$entry->ID); //Not working for some reason so called the required function directly
|
188 |
+
wp_delete_attachment($entry->ID, true);
|
189 |
+
do_action('bp_media_after_delete_media', $entry->ID);
|
190 |
+
}
|
191 |
+
$author_id = $this->owner;
|
192 |
+
BPMediaActions::init_count($author_id);
|
193 |
+
wp_delete_post($this->id, true);
|
194 |
+
global $bp_media_count;
|
195 |
+
$bp_media_count['albums'] = intval(isset($bp_media_count['albums']) ? $bp_media_count['albums'] : 0) - 1;
|
196 |
+
bp_update_user_meta($author_id, 'bp_media_count', $bp_media_count);
|
197 |
+
do_action('bp_media_after_delete_album', $this);
|
198 |
+
}
|
199 |
|
200 |
+
/**
|
201 |
+
*
|
202 |
+
* @param type $title
|
203 |
+
* @return boolean
|
204 |
+
*/
|
205 |
+
function edit_album($title = '') {
|
206 |
+
do_action('bp_media_before_edit_album', $this);
|
207 |
+
if ($title == '') {
|
208 |
+
return false;
|
209 |
+
} else {
|
210 |
+
$this->name = $title;
|
211 |
+
$args = array(
|
212 |
+
'ID' => $this->id,
|
213 |
+
'post_title' => $this->name
|
214 |
+
);
|
215 |
+
$status = wp_insert_post($args);
|
216 |
+
if (get_class($status) == 'WP_Error' || $status == 0) {
|
217 |
+
return false;
|
218 |
+
} else {
|
219 |
+
return true;
|
220 |
+
}
|
221 |
+
}
|
222 |
+
do_action('bp_media_after_edit_album', $this);
|
223 |
+
}
|
224 |
|
225 |
+
/**
|
226 |
+
*
|
227 |
+
* @global type $bp_media
|
228 |
+
*/
|
229 |
+
function get_album_gallery_content() {
|
230 |
+
?><li>
|
231 |
+
<a href="<?php echo $this->url ?>" title="<?php _e($this->description, BP_MEDIA_TXT_DOMAIN); ?>">
|
232 |
+
<?php echo $this->thumbnail; ?>
|
233 |
+
</a>
|
234 |
+
<h3 title="<?php echo $this->name ?>"><a href="<?php echo $this->url ?>" title="<?php _e($this->description, BP_MEDIA_TXT_DOMAIN); ?>"><?php echo ( ( strlen($this->name) > 14 ) ? substr($this->name, 0, 14) . "…" : $this->name ); ?> </a><?php echo ' (' . count($this->media_entries) . ')'; ?></h3>
|
235 |
+
</li><?php
|
236 |
+
}
|
237 |
|
238 |
+
/**
|
239 |
+
* Returns the attachments linked with the albume
|
240 |
+
*
|
241 |
+
* @since BuddyPress Media 2.2
|
242 |
+
*/
|
243 |
+
|
244 |
+
/**
|
245 |
+
*
|
246 |
+
* @return type
|
247 |
+
*/
|
248 |
+
function get_entries() {
|
249 |
+
return $this->media_entries;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Returns the title of the album
|
254 |
+
*
|
255 |
+
* @since BuddyPress Media 2.2
|
256 |
+
*/
|
257 |
+
|
258 |
+
/**
|
259 |
+
*
|
260 |
+
* @return type
|
261 |
+
*/
|
262 |
+
function get_title() {
|
263 |
+
return $this->name;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Echoes the title of the album
|
268 |
+
*
|
269 |
+
* @since BuddyPress Media 2.2
|
270 |
+
*/
|
271 |
+
function the_title() {
|
272 |
+
echo $this->name;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Returns the id of the album
|
277 |
+
*
|
278 |
+
* @since BuddyPress Media 2.2
|
279 |
+
*/
|
280 |
+
|
281 |
+
/**
|
282 |
+
*
|
283 |
+
* @return type
|
284 |
+
*/
|
285 |
+
function get_id() {
|
286 |
+
return $this->id;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Returns the url of the album
|
291 |
+
*
|
292 |
+
* @since BuddyPress Media 2.2
|
293 |
+
*/
|
294 |
+
|
295 |
+
/**
|
296 |
+
*
|
297 |
+
* @return type
|
298 |
+
*/
|
299 |
+
function get_url() {
|
300 |
+
return $this->url;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Returns the owner's id
|
305 |
+
*
|
306 |
+
* @since BuddyPress Media 2.2
|
307 |
+
*/
|
308 |
+
|
309 |
+
/**
|
310 |
+
*
|
311 |
+
* @return type
|
312 |
+
*/
|
313 |
+
function get_owner() {
|
314 |
+
return $this->owner;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Returns the edit url of the album
|
319 |
+
*/
|
320 |
+
|
321 |
+
/**
|
322 |
+
*
|
323 |
+
* @return type
|
324 |
+
*/
|
325 |
+
function get_edit_url() {
|
326 |
+
return $this->edit_url;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Returns the delete url of the album
|
331 |
+
*/
|
332 |
+
|
333 |
+
/**
|
334 |
+
*
|
335 |
+
* @return type
|
336 |
+
*/
|
337 |
+
function get_delete_url() {
|
338 |
+
return $this->delete_url;
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Returns the group id to which the media belongs, 0 if it does not belong to any group
|
343 |
+
*/
|
344 |
+
|
345 |
+
/**
|
346 |
+
*
|
347 |
+
* @return type
|
348 |
+
*/
|
349 |
+
function get_group_id() {
|
350 |
+
return $this->group_id;
|
351 |
+
}
|
352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
354 |
?>
|
app/main/profile/BPMediaAlbumScreen.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Adds the Album Screen to the BuddyPress Profile
|
4 |
*
|
@@ -11,152 +12,197 @@
|
|
11 |
*/
|
12 |
class BPMediaAlbumScreen extends BPMediaScreen {
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
case BP_MEDIA_ALBUMS_EDIT_SLUG :
|
23 |
-
$this->edit_screen();
|
24 |
-
break;
|
25 |
-
case BP_MEDIA_ALBUMS_ENTRY_SLUG:
|
26 |
-
$this->entry_screen();
|
27 |
-
$this->template_actions( 'entry_screen' );
|
28 |
-
break;
|
29 |
-
case BP_MEDIA_DELETE_SLUG :
|
30 |
-
if ( ! isset( $bp->action_variables[ 1 ] ) ) {
|
31 |
-
$this->page_not_exist();
|
32 |
-
}
|
33 |
-
$this->entry_delete();
|
34 |
-
break;
|
35 |
-
default:
|
36 |
-
$this->set_query();
|
37 |
-
$this->template_actions( 'screen' );
|
38 |
-
}
|
39 |
-
} else {
|
40 |
-
$this->set_query();
|
41 |
-
$this->template_actions( 'screen' );
|
42 |
-
}
|
43 |
-
$this->template->loader();
|
44 |
-
}
|
45 |
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
BPMediaUploadScreen::upload_screen_content();
|
98 |
-
echo '</li>';
|
99 |
-
}
|
100 |
-
while ( $bp_media_query->have_posts() ) : $bp_media_query->the_post();
|
101 |
-
$this->template->the_content();
|
102 |
-
endwhile;
|
103 |
-
echo '</ul>';
|
104 |
-
$this->template->show_more();
|
105 |
-
else:
|
106 |
-
BPMediaFunction::show_formatted_error_message( __( 'Sorry, no media items were found in this album.', BP_MEDIA_TXT_DOMAIN ), 'info' );
|
107 |
-
if ( bp_is_my_profile() || BPMediaGroup::can_upload() ) {
|
108 |
-
echo '<div class="bp-media-area-allocate"></div>';
|
109 |
-
BPMediaUploadScreen::upload_screen_content();
|
110 |
-
}
|
111 |
-
endif;
|
112 |
-
$this->hook_after();
|
113 |
-
}
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
}
|
162 |
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Adds the Album Screen to the BuddyPress Profile
|
5 |
*
|
12 |
*/
|
13 |
class BPMediaAlbumScreen extends BPMediaScreen {
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @param type $media_type
|
18 |
+
* @param type $slug
|
19 |
+
*/
|
20 |
+
public function __construct($media_type, $slug) {
|
21 |
+
parent::__construct($media_type, $slug);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
*
|
26 |
+
* @global type $bp
|
27 |
+
*/
|
28 |
+
function screen() {
|
29 |
+
global $bp;
|
30 |
+
if (isset($bp->action_variables[0])) {
|
31 |
+
switch ($bp->action_variables[0]) {
|
32 |
+
case BP_MEDIA_ALBUMS_EDIT_SLUG :
|
33 |
+
$this->edit_screen();
|
34 |
+
break;
|
35 |
+
case BP_MEDIA_ALBUMS_ENTRY_SLUG:
|
36 |
+
$this->entry_screen();
|
37 |
+
$this->template_actions('entry_screen');
|
38 |
+
break;
|
39 |
+
case BP_MEDIA_DELETE_SLUG :
|
40 |
+
if (!isset($bp->action_variables[1])) {
|
41 |
+
$this->page_not_exist();
|
42 |
+
}
|
43 |
+
$this->entry_delete();
|
44 |
+
break;
|
45 |
+
default:
|
46 |
+
$this->set_query();
|
47 |
+
$this->template_actions('screen');
|
48 |
+
}
|
49 |
+
} else {
|
50 |
+
$this->set_query();
|
51 |
+
$this->template_actions('screen');
|
52 |
+
}
|
53 |
+
$this->template->loader();
|
54 |
+
}
|
55 |
|
56 |
+
/**
|
57 |
+
*
|
58 |
+
* @global type $bp_media_albums_query
|
59 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
/**
|
62 |
+
*
|
63 |
+
* @global type $bp_media_albums_query
|
64 |
+
*/
|
65 |
+
function screen_content() {
|
66 |
+
global $bp_media_albums_query;
|
67 |
|
68 |
+
$this->hook_before();
|
69 |
|
70 |
+
if ($bp_media_albums_query && $bp_media_albums_query->have_posts()):
|
71 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
72 |
+
while ($bp_media_albums_query->have_posts()) : $bp_media_albums_query->the_post();
|
73 |
+
$this->template->the_album_content();
|
74 |
+
endwhile;
|
75 |
+
echo '</ul>';
|
76 |
+
$this->template->show_more();
|
77 |
+
else:
|
78 |
+
BPMediaFunction::show_formatted_error_message(sprintf(__('Sorry, no %s were found.', BP_MEDIA_TXT_DOMAIN), $this->slug), 'info');
|
79 |
+
endif;
|
80 |
+
$this->hook_after();
|
81 |
+
}
|
82 |
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
* @global type $bp
|
86 |
+
* @global BPMediaAlbum $bp_media_current_album
|
87 |
+
* @return boolean
|
88 |
+
*/
|
89 |
+
function entry_screen() {
|
90 |
+
global $bp, $bp_media_current_album;
|
91 |
+
if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
|
92 |
+
return false;
|
93 |
+
try {
|
94 |
+
$bp_media_current_album = new BPMediaAlbum($bp->action_variables[1]);
|
95 |
+
} catch (Exception $e) {
|
96 |
+
/* Send the values to the cookie for page reload display */
|
97 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
98 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
99 |
+
$this->template->redirect($this->media_const);
|
100 |
+
exit;
|
101 |
+
}
|
102 |
+
}
|
103 |
|
104 |
+
/**
|
105 |
+
*
|
106 |
+
* @global type $bp
|
107 |
+
* @global BPMediaAlbum $bp_media_current_album
|
108 |
+
* @global type $bp_media_query
|
109 |
+
* @return boolean
|
110 |
+
*/
|
111 |
+
function entry_screen_content() {
|
112 |
+
global $bp, $bp_media_current_album, $bp_media_query;
|
113 |
+
if (!$bp->action_variables[0] == BP_MEDIA_ALBUMS_ENTRY_SLUG)
|
114 |
+
return false;
|
115 |
+
echo '<div class="bp_media_title">' . $bp_media_current_album->get_title() . '</div>';
|
116 |
+
if (bp_displayed_user_id() == bp_loggedin_user_id()) {
|
117 |
+
echo '<div class="activity-meta">';
|
118 |
+
echo '<a href="' . $bp_media_current_album->get_edit_url() . '" class="button item-button bp-secondary-action bp-media-edit bp-media-edit-album" title="' . __('Rename Album', BP_MEDIA_TXT_DOMAIN) . '">' . __('Rename', BP_MEDIA_TXT_DOMAIN) . '</a>';
|
119 |
+
echo '<a href="' . $bp_media_current_album->get_delete_url() . '" class="button item-button bp-secondary-action delete-activity-single confirm" rel="nofollow">' . __("Delete", BP_MEDIA_TXT_DOMAIN) . '</a>';
|
120 |
+
echo '</div>';
|
121 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
+
$this->inner_query($bp_media_current_album->get_id());
|
124 |
+
$this->hook_before();
|
125 |
+
if ($bp_media_current_album && $bp_media_query->have_posts()):
|
126 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
127 |
+
if (bp_is_my_profile() || BPMediaGroup::can_upload()) {
|
128 |
+
echo '<li>';
|
129 |
+
BPMediaUploadScreen::upload_screen_content();
|
130 |
+
echo '</li>';
|
131 |
+
}
|
132 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
133 |
+
$this->template->the_content();
|
134 |
+
endwhile;
|
135 |
+
echo '</ul>';
|
136 |
+
$this->template->show_more();
|
137 |
+
else:
|
138 |
+
BPMediaFunction::show_formatted_error_message(__('Sorry, no media items were found in this album.', BP_MEDIA_TXT_DOMAIN), 'info');
|
139 |
+
if (bp_is_my_profile() || BPMediaGroup::can_upload()) {
|
140 |
+
echo '<div class="bp-media-area-allocate"></div>';
|
141 |
+
BPMediaUploadScreen::upload_screen_content();
|
142 |
+
}
|
143 |
+
endif;
|
144 |
+
$this->hook_after();
|
145 |
+
}
|
146 |
|
147 |
+
/**
|
148 |
+
*
|
149 |
+
* @global type $bp
|
150 |
+
* @global type $bp_media_albums_query
|
151 |
+
*/
|
152 |
+
function set_query() {
|
153 |
+
global $bp, $bp_media_albums_query;
|
154 |
+
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])) {
|
155 |
+
$paged = $bp->action_variables[1];
|
156 |
+
} else {
|
157 |
+
$paged = 1;
|
158 |
+
}
|
159 |
+
if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
|
160 |
+
$args = array(
|
161 |
+
'post_type' => 'bp_media_album',
|
162 |
+
'author' => $bp->displayed_user->id,
|
163 |
+
'paged' => $paged,
|
164 |
+
'meta_key' => 'bp-media-key',
|
165 |
+
'meta_value' => $bp->displayed_user->id,
|
166 |
+
'meta_compare' => '='
|
167 |
+
);
|
168 |
+
$bp_media_albums_query = new WP_Query($args);
|
169 |
+
}
|
170 |
+
}
|
171 |
|
172 |
+
/**
|
173 |
+
*
|
174 |
+
* @param type $action
|
175 |
+
*/
|
176 |
+
function template_actions($action) {
|
177 |
+
add_action('bp_template_content', array($this, $action . '_content'));
|
178 |
+
}
|
179 |
|
180 |
+
/**
|
181 |
+
*
|
182 |
+
* @global type $bp
|
183 |
+
* @global type $bp_media_query
|
184 |
+
* @param type $album_id
|
185 |
+
*/
|
186 |
+
function inner_query($album_id = 0) {
|
187 |
+
global $bp, $bp_media_query;
|
188 |
+
$paged = 0;
|
189 |
+
$action_variables = isset($bp->canonical_stack['action_variables']) ? $bp->canonical_stack['action_variables'] : null;
|
190 |
+
if (isset($action_variables) && is_array($action_variables) && isset($action_variables[0])) {
|
191 |
+
if ($action_variables[0] == 'page' && isset($action_variables[1]) && is_numeric($action_variables[1]))
|
192 |
+
$paged = $action_variables[1];
|
193 |
+
else if (isset($action_variables[1]) && $action_variables[1] == 'page' && isset($action_variables[2]) && is_numeric($action_variables[2]))
|
194 |
+
$paged = $action_variables[2];
|
195 |
+
}
|
196 |
+
if (!$paged)
|
197 |
+
$paged = 1;
|
198 |
+
$args = array(
|
199 |
+
'post_type' => 'attachment',
|
200 |
+
'post_status' => 'any',
|
201 |
+
'post_parent' => $album_id,
|
202 |
+
'paged' => $paged
|
203 |
+
);
|
204 |
+
$bp_media_query = new WP_Query($args);
|
205 |
+
}
|
206 |
|
207 |
}
|
208 |
|
app/main/profile/BPMediaScreen.php
CHANGED
@@ -11,403 +11,445 @@
|
|
11 |
*/
|
12 |
class BPMediaScreen {
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
}
|
413 |
?>
|
11 |
*/
|
12 |
class BPMediaScreen {
|
13 |
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @var string Slug to be used for the media type/screen
|
17 |
+
*/
|
18 |
+
public $slug = NULL;
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* @var string Media type for use in the class
|
23 |
+
*/
|
24 |
+
public $media_type = '';
|
25 |
+
|
26 |
+
/**
|
27 |
+
*
|
28 |
+
* @var string Media type string used to build constants
|
29 |
+
*/
|
30 |
+
public $media_const = '';
|
31 |
+
|
32 |
+
/**
|
33 |
+
*
|
34 |
+
* @var string Plural media type string
|
35 |
+
*/
|
36 |
+
public $medias_type = '';
|
37 |
+
public $template = '';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Populates all the variables of the class, $media_type, $media_const, $medias_type
|
41 |
+
*
|
42 |
+
* @param string $media_type The media type for which the screen is going to be created
|
43 |
+
* @param string $slug The slug to use for the media type
|
44 |
+
*/
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @param type $media_type
|
49 |
+
* @param type $slug
|
50 |
+
*/
|
51 |
+
public function __construct($media_type, $slug) {
|
52 |
+
$this->slug = $slug;
|
53 |
+
$this->media_constant($media_type);
|
54 |
+
$this->template = new BPMediaTemplate();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Populates variable $media_type
|
59 |
+
* @param string $media_type
|
60 |
+
*/
|
61 |
+
|
62 |
+
/**
|
63 |
+
*
|
64 |
+
* @param type $media_type
|
65 |
+
*/
|
66 |
+
private function media($media_type) {
|
67 |
+
$this->media_type = $media_type;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Creates plural
|
72 |
+
* @param type $media_type
|
73 |
+
*/
|
74 |
+
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
* @param type $media_type
|
78 |
+
*/
|
79 |
+
private function medias($media_type) {
|
80 |
+
$this->media($media_type);
|
81 |
+
$media = strtolower($this->media_type);
|
82 |
+
if ($media != 'audio') {
|
83 |
+
$media .= 's';
|
84 |
+
}
|
85 |
+
$this->medias_type = $media;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
*
|
90 |
+
* @param type $media_type
|
91 |
+
*/
|
92 |
+
private function media_constant($media_type) {
|
93 |
+
$this->medias($media_type);
|
94 |
+
$this->media_const = strtoupper($this->medias_type);
|
95 |
+
}
|
96 |
+
|
97 |
+
public function hook_before() {
|
98 |
+
do_action('bp_media_before_content');
|
99 |
+
do_action('bp_media_before_' . $this->slug);
|
100 |
+
}
|
101 |
+
|
102 |
+
public function hook_after() {
|
103 |
+
do_action('bp_media_after_' . $this->slug);
|
104 |
+
do_action('bp_media_after_content');
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
*
|
109 |
+
* @global type $bp_media
|
110 |
+
*/
|
111 |
+
private function page_not_exist() {
|
112 |
+
@setcookie('bp-message', __('The requested url does not exist', BP_MEDIA_TXT_DOMAIN), time() + 60 * 60 * 24, COOKIEPATH);
|
113 |
+
@setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
|
114 |
+
$this->template->redirect($this->media_const);
|
115 |
+
exit;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* @global type $bp_media
|
121 |
+
*/
|
122 |
+
private function screen_title() {
|
123 |
+
printf(__('%s List Page', BP_MEDIA_TXT_DOMAIN), $this->slug);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
*
|
128 |
+
* @global type $bp
|
129 |
+
*/
|
130 |
+
public function screen() {
|
131 |
+
$editslug = 'BP_MEDIA_' . $this->media_const . '_EDIT_SLUG';
|
132 |
+
$entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
|
133 |
+
|
134 |
+
global $bp;
|
135 |
+
|
136 |
+
remove_filter('bp_activity_get_user_join_filter', 'BPMediaFilters::activity_query_filter', 10);
|
137 |
+
if (isset($bp->action_variables[0])) {
|
138 |
+
switch ($bp->action_variables[0]) {
|
139 |
+
case constant($editslug) :
|
140 |
+
$this->edit_screen();
|
141 |
+
break;
|
142 |
+
case constant($entryslug) :
|
143 |
+
$this->entry_screen();
|
144 |
+
break;
|
145 |
+
case BP_MEDIA_DELETE_SLUG :
|
146 |
+
if (!isset($bp->action_variables[1])) {
|
147 |
+
$this->page_not_exist();
|
148 |
+
}
|
149 |
+
$this->entry_delete();
|
150 |
+
break;
|
151 |
+
default:
|
152 |
+
$this->set_query();
|
153 |
+
add_action('bp_template_content', array($this, 'screen_content'));
|
154 |
+
}
|
155 |
+
} else {
|
156 |
+
$this->set_query();
|
157 |
+
add_action('bp_template_content', array($this, 'screen_content'));
|
158 |
+
}
|
159 |
+
$this->template->loader();
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
*
|
164 |
+
* @global type $bp_media
|
165 |
+
* @global type $bp_media_query
|
166 |
+
* @global type $bp_media_albums_query
|
167 |
+
*/
|
168 |
+
|
169 |
+
/**
|
170 |
+
*
|
171 |
+
* @global type $bp_media_query
|
172 |
+
* @global type $bp_media_albums_query
|
173 |
+
*/
|
174 |
+
function screen_content() {
|
175 |
+
global $bp_media_query, $bp_media_albums_query;
|
176 |
+
$this->set_query();
|
177 |
+
|
178 |
+
$this->hook_before();
|
179 |
+
if ($bp_media_query && $bp_media_query->have_posts()):
|
180 |
+
echo '<ul id="bp-media-list" class="bp-media-gallery item-list">';
|
181 |
+
if (bp_is_my_profile() || BPMediaGroup::can_upload()) {
|
182 |
+
echo '<li>';
|
183 |
+
BPMediaUploadScreen::upload_screen_content();
|
184 |
+
echo '</li>';
|
185 |
+
}
|
186 |
+
while ($bp_media_query->have_posts()) : $bp_media_query->the_post();
|
187 |
+
$this->template->the_content();
|
188 |
+
endwhile;
|
189 |
+
echo '</ul>';
|
190 |
+
$this->template->show_more();
|
191 |
+
else:
|
192 |
+
BPMediaFunction::show_formatted_error_message(sprintf(__('Sorry, no %s were found.', BP_MEDIA_TXT_DOMAIN), $this->slug), 'info');
|
193 |
+
if (bp_is_my_profile() || BPMediaGroup::can_upload()) {
|
194 |
+
echo '<div class="bp-media-area-allocate"></div>';
|
195 |
+
BPMediaUploadScreen::upload_screen_content();
|
196 |
+
}
|
197 |
+
endif;
|
198 |
+
$this->hook_after();
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
*
|
203 |
+
* @global type $bp
|
204 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
205 |
+
* @return boolean
|
206 |
+
*/
|
207 |
+
function entry_screen() {
|
208 |
+
|
209 |
+
global $bp, $bp_media_current_entry;
|
210 |
+
$entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
|
211 |
+
if (!$bp->action_variables[0] == constant($entryslug))
|
212 |
+
return false;
|
213 |
+
try {
|
214 |
+
|
215 |
+
$bp_media_current_entry = new BPMediaHostWordpress($bp->action_variables[1]);
|
216 |
+
} catch (Exception $e) {
|
217 |
+
/* Send the values to the cookie for page reload display */
|
218 |
+
@setcookie('bp-message', $_COOKIE['bp-message'], time() + 60 * 60 * 24, COOKIEPATH);
|
219 |
+
@setcookie('bp-message-type', $_COOKIE['bp-message-type'], time() + 60 * 60 * 24, COOKIEPATH);
|
220 |
+
$this->template->redirect($this->media_const);
|
221 |
+
exit;
|
222 |
+
}
|
223 |
+
|
224 |
+
$this->template_actions('entry_screen');
|
225 |
+
$this->template->loader();
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
*
|
230 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
231 |
+
*/
|
232 |
+
function entry_screen_title() {
|
233 |
+
|
234 |
+
global $bp_media_current_entry;
|
235 |
+
/** @var $bp_media_current_entry BPMediaHostWordpress */
|
236 |
+
if (is_object($bp_media_current_entry))
|
237 |
+
echo $bp_media_current_entry->get_media_single_title();
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
*
|
242 |
+
* @global type $bp
|
243 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
244 |
+
* @return boolean
|
245 |
+
*/
|
246 |
+
function entry_screen_content() {
|
247 |
+
global $bp, $bp_media_current_entry;
|
248 |
+
$entryslug = 'BP_MEDIA_' . $this->media_const . '_ENTRY_SLUG';
|
249 |
+
$this->hook_before();
|
250 |
+
if (!$bp->action_variables[0] == constant($entryslug))
|
251 |
+
return false;
|
252 |
+
echo '<div class="bp-media-single bp-media-image">';
|
253 |
+
echo $bp_media_current_entry->get_media_single_content();
|
254 |
+
echo $bp_media_current_entry->show_comment_form();
|
255 |
+
echo '</div>';
|
256 |
+
$this->hook_after();
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
*
|
261 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
262 |
+
* @global type $bp
|
263 |
+
*/
|
264 |
+
function edit_screen() {
|
265 |
+
global $bp_media_current_entry, $bp;
|
266 |
+
if (!isset($bp->action_variables[1])) {
|
267 |
+
$this->page_not_exist();
|
268 |
+
}
|
269 |
+
//Creating global bp_media_current_entry for later use
|
270 |
+
try {
|
271 |
+
$bp_media_current_entry = new BPMediaHostWordpress($bp->action_variables[1]);
|
272 |
+
} catch (Exception $e) {
|
273 |
+
/* Send the values to the cookie for page reload display */
|
274 |
+
@setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
|
275 |
+
@setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
|
276 |
+
$this->template->redirect($this->media_const);
|
277 |
+
exit;
|
278 |
+
}
|
279 |
+
BPMediaFunction::check_user();
|
280 |
+
|
281 |
+
//For saving the data if the form is submitted
|
282 |
+
if (array_key_exists('bp_media_title', $_POST)) {
|
283 |
+
BPMediaFunction::update_media();
|
284 |
+
}
|
285 |
+
$this->template_actions('edit_screen');
|
286 |
+
$this->template->loader();
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
*
|
291 |
+
* @global type $bp_media
|
292 |
+
*/
|
293 |
+
function edit_screen_title() {
|
294 |
+
printf(__('Edit %s', BP_MEDIA_TXT_DOMAIN), $this->slug);
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
*
|
299 |
+
* @global type $bp
|
300 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
301 |
+
* @global type $bp_media_default_excerpts
|
302 |
+
* @global type $bp_media
|
303 |
+
*/
|
304 |
+
|
305 |
+
/**
|
306 |
+
*
|
307 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
308 |
+
* @global type $bp_media_default_excerpts
|
309 |
+
*/
|
310 |
+
function edit_screen_content() {
|
311 |
+
global $bp_media_current_entry, $bp_media_default_excerpts;
|
312 |
+
?>
|
313 |
+
<form method="post" class="standard-form" id="bp-media-upload-form">
|
314 |
+
<label for="bp-media-upload-input-title">
|
315 |
+
<?php printf(__('%s Title', BP_MEDIA_TXT_DOMAIN), ucfirst($this->media_type)); ?>
|
316 |
+
</label>
|
317 |
+
<input id="bp-media-upload-input-title" type="text" name="bp_media_title" class="settings-input"
|
318 |
+
maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_title'], $bp_media_default_excerpts['activity_entry_title'])) ?>"
|
319 |
+
value="<?php echo $bp_media_current_entry->get_title(); ?>" />
|
320 |
+
<?php if ($bp_media_current_entry->get_type() != 'album') { ?>
|
321 |
+
<label for="bp-media-upload-input-description">
|
322 |
+
<?php printf(__('%s Description', BP_MEDIA_TXT_DOMAIN), ucfirst($this->media_type)); ?>
|
323 |
+
</label>
|
324 |
+
<input id="bp-media-upload-input-description" type="text" name="bp_media_description" class="settings-input"
|
325 |
+
maxlength="<?php echo max(array($bp_media_default_excerpts['single_entry_description'], $bp_media_default_excerpts['activity_entry_description'])) ?>"
|
326 |
+
value="<?php echo $bp_media_current_entry->get_content(); ?>" />
|
327 |
+
<?php }
|
328 |
+
do_action('bp_media_add_media_fields', $this->media_type);
|
329 |
+
?>
|
330 |
+
<div class="submit">
|
331 |
+
<input type="submit" class="auto" value="<?php _e('Update', BP_MEDIA_TXT_DOMAIN); ?>" />
|
332 |
+
<a href="<?php echo $bp_media_current_entry->get_url(); ?>" class="button" title="<?php _e('Back to Media File', BP_MEDIA_TXT_DOMAIN); ?>">
|
333 |
+
<?php _e('Back to Media', BP_MEDIA_TXT_DOMAIN); ?>
|
334 |
+
</a>
|
335 |
+
</div>
|
336 |
+
</form>
|
337 |
+
<?php
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
*
|
342 |
+
* @global type $bp
|
343 |
+
* @global type $bp_media
|
344 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
345 |
+
*/
|
346 |
+
|
347 |
+
/**
|
348 |
+
*
|
349 |
+
* @global type $bp
|
350 |
+
* @global BPMediaHostWordpress $bp_media_current_entry
|
351 |
+
*/
|
352 |
+
function entry_delete() {
|
353 |
+
global $bp;
|
354 |
+
if (bp_loggedin_user_id() != bp_displayed_user_id()) {
|
355 |
+
bp_core_no_access(array(
|
356 |
+
'message' => __('You do not have access to this page.', BP_MEDIA_TXT_DOMAIN),
|
357 |
+
'root' => bp_displayed_user_domain(),
|
358 |
+
'redirect' => false
|
359 |
+
));
|
360 |
+
exit;
|
361 |
+
}
|
362 |
+
if (!isset($bp->action_variables[1])) {
|
363 |
+
@setcookie('bp-message', __('The requested url does not exist', BP_MEDIA_TXT_DOMAIN), time() + 60 * 60 * 24, COOKIEPATH);
|
364 |
+
@setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
|
365 |
+
$this->template->redirect($this->media_const);
|
366 |
+
exit;
|
367 |
+
}
|
368 |
+
global $bp_media_current_entry;
|
369 |
+
try {
|
370 |
+
$bp_media_current_entry = new BPMediaHostWordpress($bp->action_variables[1]);
|
371 |
+
} catch (Exception $e) {
|
372 |
+
/* Send the values to the cookie for page reload display */
|
373 |
+
@setcookie('bp-message', $e->getMessage(), time() + 60 * 60 * 24, COOKIEPATH);
|
374 |
+
@setcookie('bp-message-type', 'error', time() + 60 * 60 * 24, COOKIEPATH);
|
375 |
+
$this->template->redirect($this->media_const);
|
376 |
+
exit;
|
377 |
+
}
|
378 |
+
$post_id = $bp_media_current_entry->get_id();
|
379 |
+
$activity_id = get_post_meta($post_id, 'bp_media_child_activity', true);
|
380 |
+
|
381 |
+
bp_activity_delete_by_activity_id($activity_id);
|
382 |
+
$bp_media_current_entry->delete_media();
|
383 |
+
|
384 |
+
@setcookie('bp-message', __('Media deleted successfully', BP_MEDIA_TXT_DOMAIN), time() + 60 * 60 * 24, COOKIEPATH);
|
385 |
+
@setcookie('bp-message-type', 'success', time() + 60 * 60 * 24, COOKIEPATH);
|
386 |
+
$this->template->redirect($this->media_const);
|
387 |
+
exit;
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
*
|
392 |
+
* @param type $action
|
393 |
+
*/
|
394 |
+
|
395 |
+
/**
|
396 |
+
*
|
397 |
+
* @param type $action
|
398 |
+
*/
|
399 |
+
function template_actions($action) {
|
400 |
+
add_action('bp_template_title', array($this, $action . '_title'));
|
401 |
+
add_action('bp_template_content', array($this, $action . '_content'));
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
*
|
406 |
+
* @global type $bp
|
407 |
+
* @global type $bp_media_posts_per_page
|
408 |
+
* @global type $bp_media_query
|
409 |
+
*/
|
410 |
+
|
411 |
+
/**
|
412 |
+
*
|
413 |
+
* @global type $bp
|
414 |
+
* @global type $bp_media_posts_per_page
|
415 |
+
* @global type $bp_media_query
|
416 |
+
*/
|
417 |
+
public function set_query() {
|
418 |
+
global $bp, $bp_media_posts_per_page, $bp_media_query;
|
419 |
+
switch ($bp->current_action) {
|
420 |
+
case BP_MEDIA_IMAGES_SLUG:
|
421 |
+
$type = 'image';
|
422 |
+
break;
|
423 |
+
case BP_MEDIA_AUDIO_SLUG:
|
424 |
+
$type = 'audio';
|
425 |
+
break;
|
426 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
427 |
+
$type = 'video';
|
428 |
+
break;
|
429 |
+
default :
|
430 |
+
$type = null;
|
431 |
+
}
|
432 |
+
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])) {
|
433 |
+
$paged = $bp->action_variables[1];
|
434 |
+
} else {
|
435 |
+
$paged = 1;
|
436 |
+
}
|
437 |
+
if ($type) {
|
438 |
+
$args = array(
|
439 |
+
'post_type' => 'attachment',
|
440 |
+
'post_status' => 'any',
|
441 |
+
'post_mime_type' => $type,
|
442 |
+
'author' => $bp->displayed_user->id,
|
443 |
+
'meta_key' => 'bp-media-key',
|
444 |
+
'meta_value' => $bp->displayed_user->id,
|
445 |
+
'meta_compare' => '=',
|
446 |
+
'paged' => $paged,
|
447 |
+
'posts_per_page' => $bp_media_posts_per_page
|
448 |
+
);
|
449 |
+
|
450 |
+
$bp_media_query = new WP_Query($args);
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
}
|
455 |
?>
|
app/main/profile/BPMediaTemplate.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Contains methods for template functions
|
4 |
*
|
@@ -10,220 +11,254 @@
|
|
10 |
*/
|
11 |
class BPMediaTemplate {
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
<input type="
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
<
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
function redirect( $mediaconst ) {
|
165 |
-
bp_core_redirect( trailingslashit( bp_displayed_user_domain() . constant( 'BP_MEDIA_' . $mediaconst . '_SLUG' ) ) );
|
166 |
-
}
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
<
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
}
|
229 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* Contains methods for template functions
|
5 |
*
|
11 |
*/
|
12 |
class BPMediaTemplate {
|
13 |
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @global type $bp_media_current_album
|
17 |
+
*/
|
18 |
+
function upload_form_multiple() {
|
19 |
+
global $bp_media_current_album;
|
20 |
+
$post_wall = __('Wall Posts', BP_MEDIA_TXT_DOMAIN);
|
21 |
+
if (!isset($bp_media_current_album)) {
|
22 |
+
?>
|
23 |
+
<div id="bp-media-album-prompt" title="Select Album">
|
24 |
+
<span><?php _e('Select Album', BP_MEDIA_TXT_DOMAIN); ?></span>
|
25 |
+
<div class="bp-media-album-content">
|
26 |
+
<select id="bp-media-selected-album"><?php
|
27 |
+
if (bp_is_current_component('groups')) {
|
28 |
+
$albums = new WP_Query(array(
|
29 |
+
'post_type' => 'bp_media_album',
|
30 |
+
'posts_per_page' => -1,
|
31 |
+
'meta_key' => 'bp-media-key',
|
32 |
+
'meta_value' => -bp_get_current_group_id(),
|
33 |
+
'meta_compare' => '='
|
34 |
+
));
|
35 |
+
} else {
|
36 |
+
$albums = new WP_Query(array(
|
37 |
+
'post_type' => 'bp_media_album',
|
38 |
+
'posts_per_page' => -1,
|
39 |
+
'author' => get_current_user_id()
|
40 |
+
));
|
41 |
+
}
|
42 |
+
if (isset($albums->posts) && is_array($albums->posts) && count($albums->posts) > 0) {
|
43 |
+
foreach ($albums->posts as $album) {
|
44 |
+
if ($album->post_title == $post_wall)
|
45 |
+
echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
|
46 |
+
else
|
47 |
+
echo '<option value="' . $album->ID . '">' . $album->post_title . '</option>';
|
48 |
+
};
|
49 |
+
}else {
|
50 |
+
$album = new BPMediaAlbum();
|
51 |
+
if (bp_is_current_component('groups')) {
|
52 |
+
$current_group = new BP_Groups_Group(bp_get_current_group_id());
|
53 |
+
$album->add_album($post_wall, $current_group->creator_id, bp_get_current_group_id());
|
54 |
+
} else {
|
55 |
+
$album->add_album($post_wall, bp_loggedin_user_id());
|
56 |
+
}
|
57 |
+
echo '<option value="' . $album->get_id() . '" selected="selected">' . $album->get_title()->post_title . '</option>';
|
58 |
+
}
|
59 |
+
echo '<option id="create-new" value="create_new" >' . __('+ Create New Album', BP_MEDIA_TXT_DOMAIN) . '</option>';
|
60 |
+
?>
|
61 |
+
</select>
|
62 |
+
</div>
|
63 |
+
<div class="hide">
|
64 |
+
<input type="text" id="bp_media_album_new" value="" />
|
65 |
+
<input type="button" class="button" id="btn-create-new" value="<?php _e('Create', BP_MEDIA_TXT_DOMAIN); ?>"/>
|
66 |
+
<input type="button" class="button" id="btn-create-cancel" value="<?php _e('Cancel', BP_MEDIA_TXT_DOMAIN); ?>"/>
|
67 |
+
</div>
|
68 |
+
</div><?php } else {
|
69 |
+
?>
|
70 |
+
<input type="hidden" id="bp-media-selected-album" value="<?php echo $bp_media_current_album->get_id(); ?>"/>
|
71 |
+
<?php } ?>
|
72 |
+
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop">
|
73 |
+
<div id="drag-drop-area">
|
74 |
+
<div class="drag-drop-inside">
|
75 |
+
<p class="drag-drop-info"><?php _e('Drop files here', BP_MEDIA_TXT_DOMAIN); ?></p>
|
76 |
+
<p><?php _e(' or ', BP_MEDIA_TXT_DOMAIN); ?></p>
|
77 |
+
<p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="<?php _e('Select Files', BP_MEDIA_TXT_DOMAIN); ?>" class="button" /></p>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
<div id="bp-media-uploaded-files"></div>
|
81 |
+
</div>
|
82 |
+
<?php
|
83 |
+
}
|
84 |
|
85 |
+
/**
|
86 |
+
*
|
87 |
+
* @param type $id
|
88 |
+
* @return boolean
|
89 |
+
*/
|
90 |
+
function get_permalink($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 |
+
switch (get_post_meta($media->ID, 'bp_media_type', true)) {
|
100 |
+
case 'video' :
|
101 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_VIDEOS_SLUG . '/' . BP_MEDIA_VIDEOS_ENTRY_SLUG . '/' . $media->ID);
|
102 |
+
break;
|
103 |
+
case 'audio' :
|
104 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_AUDIO_SLUG . '/' . BP_MEDIA_AUDIO_ENTRY_SLUG . '/' . $media->ID);
|
105 |
+
break;
|
106 |
+
case 'image' :
|
107 |
+
return trailingslashit(bp_displayed_user_domain() . BP_MEDIA_IMAGES_SLUG . '/' . BP_MEDIA_IMAGES_ENTRY_SLUG . '/' . $media->ID);
|
108 |
+
break;
|
109 |
+
default :
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
}
|
113 |
|
114 |
+
function the_permalink() {
|
115 |
+
echo apply_filters('the_permalink', array($this, 'get_permalink'));
|
116 |
+
}
|
117 |
|
118 |
+
/**
|
119 |
+
*
|
120 |
+
* @param type $id
|
121 |
+
* @return boolean
|
122 |
+
*/
|
123 |
+
function the_content($id = 0) {
|
124 |
+
if (is_object($id))
|
125 |
+
$media = $id;
|
126 |
+
else
|
127 |
+
$media = &get_post($id);
|
128 |
+
if (empty($media->ID))
|
129 |
+
return false;
|
130 |
+
if ($media->post_type != 'attachment')
|
131 |
+
return false;
|
132 |
+
try {
|
133 |
+
$media = new BPMediaHostWordpress($media->ID);
|
134 |
+
echo $media->get_media_gallery_content();
|
135 |
+
} catch (Exception $e) {
|
136 |
+
echo '';
|
137 |
+
}
|
138 |
+
}
|
139 |
|
140 |
+
/**
|
141 |
+
*
|
142 |
+
* @param type $id
|
143 |
+
* @return boolean
|
144 |
+
*/
|
145 |
+
function the_album_content($id = 0) {
|
146 |
+
if (is_object($id))
|
147 |
+
$album = $id;
|
148 |
+
else
|
149 |
+
$album = &get_post($id);
|
150 |
+
if (empty($album->ID))
|
151 |
+
return false;
|
152 |
+
if (!$album->post_type == 'bp_media_album')
|
153 |
+
return false;
|
154 |
+
try {
|
155 |
+
$album = new BPMediaAlbum($album->ID);
|
156 |
+
echo $album->get_album_gallery_content();
|
157 |
+
} catch (Exception $e) {
|
158 |
+
echo '';
|
159 |
+
}
|
160 |
+
}
|
161 |
|
162 |
+
/**
|
163 |
+
*
|
164 |
+
* @global type $bp_media_query
|
165 |
+
* @global type $bp_media_albums_query
|
166 |
+
* @param type $type
|
167 |
+
*/
|
168 |
+
function show_more($type = 'media') {
|
169 |
+
$showmore = false;
|
170 |
+
switch ($type) {
|
171 |
+
case 'media':
|
172 |
+
global $bp_media_query;
|
173 |
+
//found_posts
|
174 |
+
if (isset($bp_media_query->found_posts) && $bp_media_query->found_posts > 10)
|
175 |
+
$showmore = true;
|
176 |
+
break;
|
177 |
+
case 'albums':
|
178 |
+
global $bp_media_albums_query;
|
179 |
+
if (isset($bp_media_albums_query->found_posts) && $bp_media_albums_query->found_posts > 10)
|
180 |
+
$showmore = true;
|
181 |
+
break;
|
182 |
+
}
|
183 |
+
if ($showmore) {
|
184 |
+
echo '<div class="bp-media-actions"><a href="#" class="button" id="bp-media-show-more">' . __('Show More', BP_MEDIA_TXT_DOMAIN) . '</a></div>';
|
185 |
+
}
|
186 |
+
}
|
187 |
|
188 |
+
/**
|
189 |
+
*
|
190 |
+
*/
|
|
|
|
|
|
|
191 |
|
192 |
+
/**
|
193 |
+
*
|
194 |
+
* @param type $mediaconst
|
195 |
+
*/
|
196 |
+
function redirect($mediaconst) {
|
197 |
+
bp_core_redirect(trailingslashit(bp_displayed_user_domain() . constant('BP_MEDIA_' . $mediaconst . '_SLUG')));
|
198 |
+
}
|
199 |
|
200 |
+
function loader() {
|
201 |
+
bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
*
|
206 |
+
* @global type $bp
|
207 |
+
* @global type $bp_media_default_excerpts
|
208 |
+
* @return type
|
209 |
+
*/
|
210 |
+
function upload_form_multiple_activity() {
|
211 |
+
global $bp, $bp_media_default_excerpts;
|
212 |
+
if ($bp->current_component != 'activity')
|
213 |
+
return;
|
214 |
+
?>
|
215 |
+
<div id="bp-media-album-prompt" title="Select Album">
|
216 |
+
<div class="bp-media-album-title">
|
217 |
+
<span><?php _e('Select Album', BP_MEDIA_TXT_DOMAIN); ?></span>
|
218 |
+
<span id="bp-media-close"><?php _e('x', BP_MEDIA_TXT_DOMAIN); ?></span>
|
219 |
+
</div>
|
220 |
+
<div class="bp-media-album-content">
|
221 |
+
<select id="bp-media-selected-album"><?php
|
222 |
+
$albums = new WP_Query(array(
|
223 |
+
'post_type' => 'bp_media_album',
|
224 |
+
'posts_per_page' => -1,
|
225 |
+
'author' => get_current_user_id()
|
226 |
+
));
|
227 |
+
if (isset($albums->posts) && is_array($albums->posts) && count($albums->posts) > 0) {
|
228 |
+
foreach ($albums->posts as $album) {
|
229 |
+
if ($album->post_title == $post_wall)
|
230 |
+
echo '<option value="' . $album->ID . '" selected="selected">' . $album->post_title . '</option>';
|
231 |
+
else
|
232 |
+
echo '<option value="' . $album->ID . '">' . $album->post_title, BP_MEDIA_TXT_DOMAIN . '</option>';
|
233 |
+
};
|
234 |
+
}
|
235 |
+
?></select>
|
236 |
+
</div>
|
237 |
+
<div class="select-btn-div">
|
238 |
+
<input id="selected-btn" type="button" class="btn" value="<?php _e('Select', BP_MEDIA_TXT_DOMAIN); ?>" />
|
239 |
+
<input id="create-btn" type="button" class="btn" value="<?php _e('Create Album', BP_MEDIA_TXT_DOMAIN); ?>" />
|
240 |
+
<div style="clear: both;"></div>
|
241 |
+
</div>
|
242 |
+
</div>
|
243 |
+
<div id="bp-media-album-new" title="Create New Album">
|
244 |
+
<div class="bp-media-album-title">
|
245 |
+
<span><?php _e('Create Album', BP_MEDIA_TXT_DOMAIN); ?></span>
|
246 |
+
<span id="bp-media-create-album-close"><?php _e('x', BP_MEDIA_TXT_DOMAIN); ?></span>
|
247 |
+
</div>
|
248 |
+
<div class="bp-media-album-content">
|
249 |
+
<label for="bp_media_album_name"><?php _e('Album Name', BP_MEDIA_TXT_DOMAIN); ?></label>
|
250 |
+
<input id="bp_media_album_name" type="text" name="bp_media_album_name" />
|
251 |
+
</div>
|
252 |
+
<div class="select-btn-div">
|
253 |
+
<input id="create-album" type="button" class="btn" value="<?php _e('Create', BP_MEDIA_TXT_DOMAIN); ?>" />
|
254 |
+
</div>
|
255 |
+
</div>
|
256 |
+
<div id="bp-media-upload-ui" class="hide-if-no-js drag-drop activity-component">
|
257 |
+
<p class="drag-drop-buttons"><input id="bp-media-upload-browse-button" type="button" value="<?php _e('Add Media', BP_MEDIA_TXT_DOMAIN); ?>" class="button" /></p>
|
258 |
+
<div id="bp-media-uploaded-files"></div>
|
259 |
+
</div>
|
260 |
+
<?php
|
261 |
+
}
|
262 |
|
263 |
}
|
264 |
?>
|
app/main/profile/BPMediaUploadScreen.php
CHANGED
@@ -10,131 +10,141 @@
|
|
10 |
*/
|
11 |
class BPMediaUploadScreen extends BPMediaScreen {
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
}
|
140 |
|
10 |
*/
|
11 |
class BPMediaUploadScreen extends BPMediaScreen {
|
12 |
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @param type $media_type
|
16 |
+
* @param type $slug
|
17 |
+
*/
|
18 |
+
public function __construct($media_type, $slug) {
|
19 |
+
parent::__construct($media_type, $slug);
|
20 |
+
}
|
21 |
|
22 |
+
function upload_screen() {
|
23 |
+
if (bp_is_my_profile() || BPMediaGroup::can_upload()) {
|
24 |
+
add_action('wp_enqueue_scripts', array($this, 'upload_enqueue'));
|
25 |
+
add_action('bp_template_title', array($this, 'upload_screen_title'));
|
26 |
+
add_action('bp_template_content', array($this, 'upload_screen_content'));
|
27 |
+
$this->template->loader();
|
28 |
+
} else
|
29 |
+
bp_core_redirect(trailingslashit(bp_displayed_user_domain() . constant('BP_MEDIA_SLUG')));
|
30 |
+
}
|
31 |
|
32 |
+
function upload_screen_title() {
|
33 |
+
_e('Upload Media', BP_MEDIA_TXT_DOMAIN);
|
34 |
+
}
|
35 |
|
36 |
+
function upload_screen_content() {
|
37 |
+
$this->hook_before();
|
38 |
|
39 |
+
$this->template->upload_form_multiple();
|
40 |
|
41 |
+
$this->hook_after();
|
42 |
+
}
|
43 |
|
44 |
+
function upload_enqueue() {
|
45 |
+
$params = array(
|
46 |
+
'url' => BP_MEDIA_URL . 'app/main/includes/bp-media-upload-handler.php',
|
47 |
+
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
|
48 |
+
'browse_button' => 'bp-media-upload-browse-button',
|
49 |
+
'container' => 'bp-media-upload-ui',
|
50 |
+
'drop_element' => 'drag-drop-area',
|
51 |
+
'filters' => apply_filters('bp_media_plupload_files_filter', array(array('title' => "Media Files", 'extensions' => "mp4,jpg,png,jpeg,gif,mp3"))),
|
52 |
+
'max_file_size' => min(array(ini_get('upload_max_filesize'), ini_get('post_max_size'))),
|
53 |
+
'multipart' => true,
|
54 |
+
'urlstream_upload' => true,
|
55 |
+
'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
56 |
+
'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
57 |
+
'file_data_name' => 'bp_media_file', // key passed to $_FILE.
|
58 |
+
'multi_selection' => true,
|
59 |
+
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
60 |
+
);
|
61 |
+
wp_enqueue_script('bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers'));
|
62 |
+
wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
|
63 |
+
wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/bp-media-style.css');
|
64 |
+
//wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
|
65 |
+
//wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
66 |
+
}
|
67 |
|
68 |
+
function upload_handler() {
|
69 |
+
ignore_user_abort(true);
|
70 |
|
71 |
+
require_once(BP_MEDIA_PATH . 'lib/bootstrap.php');
|
72 |
|
73 |
+
// Check for rights
|
74 |
+
if (!is_user_logged_in())
|
75 |
+
wp_die(__("You are not allowed to be here", BP_MEDIA_TXT_DOMAIN));
|
76 |
+
}
|
77 |
|
78 |
+
/**
|
79 |
+
*
|
80 |
+
* @global type $bp
|
81 |
+
* @global type $bp_media_options
|
82 |
+
* @return type
|
83 |
+
*/
|
84 |
+
function upload_media() {
|
85 |
+
global $bp, $bp_media_options;
|
86 |
+
$bp_media_options = get_site_option('bp_media_options', array(
|
87 |
+
'videos_enabled' => true,
|
88 |
+
'audio_enabled' => true,
|
89 |
+
'images_enabled' => true,
|
90 |
+
)
|
91 |
+
);
|
92 |
+
if (isset($_POST['action']) && $_POST['action'] == 'wp_handle_upload') {
|
93 |
+
/** This section can help in the group activity handling */
|
94 |
+
if (isset($_POST['bp_media_group_id']) && intval($_POST['bp_media_group_id'])) {
|
95 |
+
remove_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 2);
|
96 |
+
add_action('bp_media_after_add_media', 'BPMediaGroupAction::bp_media_groups_activity_create_after_add_media', 10, 2);
|
97 |
+
add_filter('bp_media_force_hide_activity', 'BPMediaGroupAction::bp_media_groups_force_hide_activity');
|
98 |
+
}
|
99 |
+
/* @var $bp_media_entry BPMediaHostWordpress */
|
100 |
+
if (isset($_FILES) && is_array($_FILES) && array_key_exists('bp_media_file', $_FILES) && $_FILES['bp_media_file']['name'] != '') {
|
101 |
+
if (!preg_match('/audio|video|image/i', $_FILES['bp_media_file']['type'], $result) || !isset($result[0])) {
|
102 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported');
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
$type = $result[0];
|
106 |
+
switch ($result[0]) {
|
107 |
+
case 'image' :
|
108 |
+
if ($bp_media_options['images_enabled'] == false) {
|
109 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Image uploads are disabled', BP_MEDIA_TXT_DOMAIN);
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
break;
|
113 |
+
case 'video' :
|
114 |
+
if ($bp_media_options['videos_enabled'] == false) {
|
115 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Video uploads are disabled', BP_MEDIA_TXT_DOMAIN);
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
break;
|
119 |
+
case 'audio' :
|
120 |
+
if ($bp_media_options['audio_enabled'] == false) {
|
121 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('Audio uploads are disabled', BP_MEDIA_TXT_DOMAIN);
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
break;
|
125 |
+
default :
|
126 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('File uploaded is not supported', BP_MEDIA_TXT_DOMAIN);
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
$class_name = apply_filters('bp_media_transcoder', 'BPMediaHostWordpress', $type);
|
130 |
+
$bp_media_entry = new $class_name();
|
131 |
+
try {
|
132 |
+
$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);
|
133 |
+
$album_id = isset($_POST['bp_media_album_id']) ? intval($_POST['bp_media_album_id']) : 0;
|
134 |
+
$is_multiple = isset($_POST['is_multiple_upload']) ? ($_POST['is_multiple_upload'] == 'true' ? true : false) : false;
|
135 |
+
$description = isset($_POST['bp_media_description']) ? $_POST['bp_media_description'] : '';
|
136 |
+
$group_id = isset($_POST['bp_media_group_id']) ? intval($_POST['bp_media_group_id']) : 0;
|
137 |
+
$entry = $bp_media_entry->add_media($title, $description, $album_id, $group_id, $is_multiple);
|
138 |
+
if (!isset($bp->{BP_MEDIA_SLUG}->messages['updated'][0]))
|
139 |
+
$bp->{BP_MEDIA_SLUG}->messages['updated'][0] = __('Upload Successful', BP_MEDIA_TXT_DOMAIN);
|
140 |
+
} catch (Exception $e) {
|
141 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = $e->getMessage();
|
142 |
+
}
|
143 |
+
} else {
|
144 |
+
$bp->{BP_MEDIA_SLUG}->messages['error'][] = __('You did not specified a file to upload', BP_MEDIA_TXT_DOMAIN);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
|
149 |
}
|
150 |
|
app/main/widgets/BPMediaPopularMedia.php
CHANGED
@@ -30,6 +30,11 @@ class BPMediaPopularMedia extends WP_Widget {
|
|
30 |
}
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
function widget($args, $instance) {
|
34 |
extract($args);
|
35 |
|
@@ -63,14 +68,14 @@ class BPMediaPopularMedia extends WP_Widget {
|
|
63 |
?>
|
64 |
|
65 |
<ul class="widget-item-listing"><?php
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
?>
|
71 |
|
72 |
-
|
73 |
-
|
74 |
|
75 |
</ul><!-- .widget-item-listing --><?php
|
76 |
}
|
@@ -78,7 +83,7 @@ class BPMediaPopularMedia extends WP_Widget {
|
|
78 |
_e('No popular media found', BP_MEDIA_TXT_DOMAIN);
|
79 |
|
80 |
wp_reset_query();
|
81 |
-
|
82 |
|
83 |
</div><!-- #popular-media-tabs-comments -->
|
84 |
</div>
|
@@ -86,6 +91,12 @@ class BPMediaPopularMedia extends WP_Widget {
|
|
86 |
echo $after_widget;
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
function update($new_instance, $old_instance) {
|
90 |
$instance = $old_instance;
|
91 |
$instance['title'] = strip_tags($new_instance['title']);
|
@@ -93,6 +104,10 @@ class BPMediaPopularMedia extends WP_Widget {
|
|
93 |
return $instance;
|
94 |
}
|
95 |
|
|
|
|
|
|
|
|
|
96 |
function form($instance) {
|
97 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
98 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
30 |
}
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @param type $args
|
36 |
+
* @param type $instance
|
37 |
+
*/
|
38 |
function widget($args, $instance) {
|
39 |
extract($args);
|
40 |
|
68 |
?>
|
69 |
|
70 |
<ul class="widget-item-listing"><?php
|
71 |
+
while ($bp_media_widget_query->have_posts()) {
|
72 |
+
$bp_media_widget_query->the_post();
|
73 |
|
74 |
+
$entry = new BPMediaHostWordpress(get_the_ID());
|
75 |
?>
|
76 |
|
77 |
+
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
78 |
+
?>
|
79 |
|
80 |
</ul><!-- .widget-item-listing --><?php
|
81 |
}
|
83 |
_e('No popular media found', BP_MEDIA_TXT_DOMAIN);
|
84 |
|
85 |
wp_reset_query();
|
86 |
+
?>
|
87 |
|
88 |
</div><!-- #popular-media-tabs-comments -->
|
89 |
</div>
|
91 |
echo $after_widget;
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
+
*
|
96 |
+
* @param type $new_instance
|
97 |
+
* @param type $old_instance
|
98 |
+
* @return type
|
99 |
+
*/
|
100 |
function update($new_instance, $old_instance) {
|
101 |
$instance = $old_instance;
|
102 |
$instance['title'] = strip_tags($new_instance['title']);
|
104 |
return $instance;
|
105 |
}
|
106 |
|
107 |
+
/**
|
108 |
+
*
|
109 |
+
* @param type $instance
|
110 |
+
*/
|
111 |
function form($instance) {
|
112 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
113 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
app/main/widgets/BPMediaRecentMedia.php
CHANGED
@@ -30,6 +30,11 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
30 |
}
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
function widget($args, $instance) {
|
34 |
extract($args);
|
35 |
|
@@ -65,14 +70,14 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
65 |
?>
|
66 |
|
67 |
<ul class="widget-item-listing"><?php
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
?>
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
</ul><!-- .widget-item-listing --><?php
|
78 |
}
|
@@ -153,7 +158,7 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
153 |
_e('No recent audio found', BP_MEDIA_TXT_DOMAIN);
|
154 |
|
155 |
wp_reset_query();
|
156 |
-
|
157 |
|
158 |
</div><!-- #recent-media-tabs-music -->
|
159 |
|
@@ -178,7 +183,7 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
178 |
$bp_media_widget_query->the_post();
|
179 |
|
180 |
$entry = new BPMediaHostWordpress(get_the_ID());
|
181 |
-
|
182 |
|
183 |
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
184 |
?>
|
@@ -189,7 +194,7 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
189 |
_e('No recent video found', BP_MEDIA_TXT_DOMAIN);
|
190 |
|
191 |
wp_reset_query();
|
192 |
-
|
193 |
|
194 |
</div><!-- #media-tabs-videos -->
|
195 |
|
@@ -198,6 +203,12 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
198 |
echo $after_widget;
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
function update($new_instance, $old_instance) {
|
202 |
$instance = $old_instance;
|
203 |
$instance['title'] = strip_tags($new_instance['title']);
|
@@ -205,6 +216,10 @@ class BPMediaRecentMedia extends WP_Widget {
|
|
205 |
return $instance;
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
208 |
function form($instance) {
|
209 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
210 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
30 |
}
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
*
|
35 |
+
* @param type $args
|
36 |
+
* @param type $instance
|
37 |
+
*/
|
38 |
function widget($args, $instance) {
|
39 |
extract($args);
|
40 |
|
70 |
?>
|
71 |
|
72 |
<ul class="widget-item-listing"><?php
|
73 |
+
while ($bp_media_widget_query->have_posts()) {
|
74 |
+
$bp_media_widget_query->the_post();
|
75 |
|
76 |
+
$entry = new BPMediaHostWordpress(get_the_ID());
|
77 |
?>
|
78 |
|
79 |
+
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
80 |
+
?>
|
81 |
|
82 |
</ul><!-- .widget-item-listing --><?php
|
83 |
}
|
158 |
_e('No recent audio found', BP_MEDIA_TXT_DOMAIN);
|
159 |
|
160 |
wp_reset_query();
|
161 |
+
?>
|
162 |
|
163 |
</div><!-- #recent-media-tabs-music -->
|
164 |
|
183 |
$bp_media_widget_query->the_post();
|
184 |
|
185 |
$entry = new BPMediaHostWordpress(get_the_ID());
|
186 |
+
?>
|
187 |
|
188 |
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
189 |
?>
|
194 |
_e('No recent video found', BP_MEDIA_TXT_DOMAIN);
|
195 |
|
196 |
wp_reset_query();
|
197 |
+
?>
|
198 |
|
199 |
</div><!-- #media-tabs-videos -->
|
200 |
|
203 |
echo $after_widget;
|
204 |
}
|
205 |
|
206 |
+
/**
|
207 |
+
*
|
208 |
+
* @param type $new_instance
|
209 |
+
* @param type $old_instance
|
210 |
+
* @return type
|
211 |
+
*/
|
212 |
function update($new_instance, $old_instance) {
|
213 |
$instance = $old_instance;
|
214 |
$instance['title'] = strip_tags($new_instance['title']);
|
216 |
return $instance;
|
217 |
}
|
218 |
|
219 |
+
/**
|
220 |
+
*
|
221 |
+
* @param type $instance
|
222 |
+
*/
|
223 |
function form($instance) {
|
224 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
225 |
$number = isset($instance['number']) ? absint($instance['number']) : 10;
|
app/main/widgets/BPMediaWidget.php
CHANGED
@@ -12,6 +12,11 @@ class BPMediaWidget extends WP_Widget {
|
|
12 |
parent::__construct('buddypress-media-wid', __('BuddyPress Media Widget', BP_MEDIA_TXT_DOMAIN), $widget_ops);
|
13 |
}
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
function widget($args, $instance) {
|
16 |
extract($args);
|
17 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN) : $instance['title'], $instance, $this->id_base);
|
@@ -59,10 +64,10 @@ class BPMediaWidget extends WP_Widget {
|
|
59 |
array_push($allowMimeType, "video");
|
60 |
?>
|
61 |
<li><a href="#<?php echo $wdType; ?>-media-tabs-videos-<?php echo $widgetid; ?>"><?php _e('Videos', BP_MEDIA_TXT_DOMAIN); ?></a></li>
|
62 |
-
|
63 |
-
|
64 |
</ul>
|
65 |
-
|
66 |
<div id="<?php echo $wdType; ?>-media-tabs-all-<?php echo $widgetid; ?>" class="bp-media-tab-panel">
|
67 |
<?php
|
68 |
// All Media //'post_mime_type' => $allowMimeType,
|
@@ -81,14 +86,14 @@ class BPMediaWidget extends WP_Widget {
|
|
81 |
?>
|
82 |
|
83 |
<ul class="widget-item-listing"><?php
|
84 |
-
|
85 |
-
|
86 |
|
87 |
-
|
88 |
?>
|
89 |
|
90 |
-
|
91 |
-
|
92 |
|
93 |
</ul><?php
|
94 |
}
|
@@ -96,7 +101,7 @@ class BPMediaWidget extends WP_Widget {
|
|
96 |
_e('No ' . $wdType . ' media found', BP_MEDIA_TXT_DOMAIN);
|
97 |
|
98 |
wp_reset_query();
|
99 |
-
|
100 |
|
101 |
</div>
|
102 |
<?php
|
@@ -121,14 +126,14 @@ class BPMediaWidget extends WP_Widget {
|
|
121 |
?>
|
122 |
|
123 |
<ul class="widget-item-listing"><?php
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
|
128 |
?>
|
129 |
|
130 |
-
|
131 |
-
|
132 |
|
133 |
</ul><!-- .widget-item-listing --><?php
|
134 |
}
|
@@ -136,7 +141,7 @@ class BPMediaWidget extends WP_Widget {
|
|
136 |
_e('No ' . $wdType . ' photo found', BP_MEDIA_TXT_DOMAIN);
|
137 |
|
138 |
wp_reset_query();
|
139 |
-
|
140 |
|
141 |
</div>
|
142 |
<?php
|
@@ -171,11 +176,11 @@ class BPMediaWidget extends WP_Widget {
|
|
171 |
?>
|
172 |
|
173 |
</ul><?php
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
?>
|
180 |
|
181 |
</div>
|
@@ -201,14 +206,14 @@ class BPMediaWidget extends WP_Widget {
|
|
201 |
?>
|
202 |
|
203 |
<ul class="widget-item-listing"><?php
|
204 |
-
|
205 |
-
|
206 |
|
207 |
-
|
208 |
?>
|
209 |
|
210 |
-
|
211 |
-
|
212 |
|
213 |
</ul><?php
|
214 |
}
|
@@ -216,16 +221,22 @@ class BPMediaWidget extends WP_Widget {
|
|
216 |
_e('No ' . $wdType . ' video found', BP_MEDIA_TXT_DOMAIN);
|
217 |
|
218 |
wp_reset_query();
|
219 |
-
|
220 |
|
221 |
</div>
|
222 |
-
|
223 |
</div>
|
224 |
<?php
|
225 |
}
|
226 |
echo $after_widget;
|
227 |
}
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
function update($new_instance, $old_instance) {
|
230 |
$instance = $old_instance;
|
231 |
$instance['wdType'] = strip_tags($new_instance['wdType']);
|
@@ -239,6 +250,10 @@ class BPMediaWidget extends WP_Widget {
|
|
239 |
return $instance;
|
240 |
}
|
241 |
|
|
|
|
|
|
|
|
|
242 |
function form($instance) {
|
243 |
$wdType = isset($instance['wdType']) ? esc_attr($instance['wdType']) : '';
|
244 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
12 |
parent::__construct('buddypress-media-wid', __('BuddyPress Media Widget', BP_MEDIA_TXT_DOMAIN), $widget_ops);
|
13 |
}
|
14 |
|
15 |
+
/**
|
16 |
+
*
|
17 |
+
* @param type $args
|
18 |
+
* @param type $instance
|
19 |
+
*/
|
20 |
function widget($args, $instance) {
|
21 |
extract($args);
|
22 |
$title = apply_filters('widget_title', empty($instance['title']) ? __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN) : $instance['title'], $instance, $this->id_base);
|
64 |
array_push($allowMimeType, "video");
|
65 |
?>
|
66 |
<li><a href="#<?php echo $wdType; ?>-media-tabs-videos-<?php echo $widgetid; ?>"><?php _e('Videos', BP_MEDIA_TXT_DOMAIN); ?></a></li>
|
67 |
+
<?php }
|
68 |
+
?>
|
69 |
</ul>
|
70 |
+
<?php if ($allowAll) { ?>
|
71 |
<div id="<?php echo $wdType; ?>-media-tabs-all-<?php echo $widgetid; ?>" class="bp-media-tab-panel">
|
72 |
<?php
|
73 |
// All Media //'post_mime_type' => $allowMimeType,
|
86 |
?>
|
87 |
|
88 |
<ul class="widget-item-listing"><?php
|
89 |
+
while ($bp_media_widget_query->have_posts()) {
|
90 |
+
$bp_media_widget_query->the_post();
|
91 |
|
92 |
+
$entry = new BPMediaHostWordpress(get_the_ID());
|
93 |
?>
|
94 |
|
95 |
+
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
96 |
+
?>
|
97 |
|
98 |
</ul><?php
|
99 |
}
|
101 |
_e('No ' . $wdType . ' media found', BP_MEDIA_TXT_DOMAIN);
|
102 |
|
103 |
wp_reset_query();
|
104 |
+
?>
|
105 |
|
106 |
</div>
|
107 |
<?php
|
126 |
?>
|
127 |
|
128 |
<ul class="widget-item-listing"><?php
|
129 |
+
while ($bp_media_widget_query->have_posts()) {
|
130 |
+
$bp_media_widget_query->the_post();
|
131 |
|
132 |
+
$entry = new BPMediaHostWordpress(get_the_ID());
|
133 |
?>
|
134 |
|
135 |
+
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
136 |
+
?>
|
137 |
|
138 |
</ul><!-- .widget-item-listing --><?php
|
139 |
}
|
141 |
_e('No ' . $wdType . ' photo found', BP_MEDIA_TXT_DOMAIN);
|
142 |
|
143 |
wp_reset_query();
|
144 |
+
?>
|
145 |
|
146 |
</div>
|
147 |
<?php
|
176 |
?>
|
177 |
|
178 |
</ul><?php
|
179 |
+
}
|
180 |
+
else
|
181 |
+
_e('No ' . $wdType . ' audio found', BP_MEDIA_TXT_DOMAIN);
|
182 |
|
183 |
+
wp_reset_query();
|
184 |
?>
|
185 |
|
186 |
</div>
|
206 |
?>
|
207 |
|
208 |
<ul class="widget-item-listing"><?php
|
209 |
+
while ($bp_media_widget_query->have_posts()) {
|
210 |
+
$bp_media_widget_query->the_post();
|
211 |
|
212 |
+
$entry = new BPMediaHostWordpress(get_the_ID());
|
213 |
?>
|
214 |
|
215 |
+
<?php echo $entry->get_media_gallery_content(); ?><?php }
|
216 |
+
?>
|
217 |
|
218 |
</ul><?php
|
219 |
}
|
221 |
_e('No ' . $wdType . ' video found', BP_MEDIA_TXT_DOMAIN);
|
222 |
|
223 |
wp_reset_query();
|
224 |
+
?>
|
225 |
|
226 |
</div>
|
227 |
+
<?php } ?>
|
228 |
</div>
|
229 |
<?php
|
230 |
}
|
231 |
echo $after_widget;
|
232 |
}
|
233 |
|
234 |
+
/**
|
235 |
+
*
|
236 |
+
* @param type $new_instance
|
237 |
+
* @param type $old_instance
|
238 |
+
* @return type
|
239 |
+
*/
|
240 |
function update($new_instance, $old_instance) {
|
241 |
$instance = $old_instance;
|
242 |
$instance['wdType'] = strip_tags($new_instance['wdType']);
|
250 |
return $instance;
|
251 |
}
|
252 |
|
253 |
+
/**
|
254 |
+
*
|
255 |
+
* @param type $instance
|
256 |
+
*/
|
257 |
function form($instance) {
|
258 |
$wdType = isset($instance['wdType']) ? esc_attr($instance['wdType']) : '';
|
259 |
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
-
Version: 2.5.
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videos and audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
+
Version: 2.5.2
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
|
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.5
|
8 |
Tested up to: 3.5
|
9 |
-
Stable tag: 2.5.
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
@@ -87,6 +87,9 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
87 |
== Changelog ==
|
88 |
|
89 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
|
|
|
|
|
|
90 |
= 2.5.1 =
|
91 |
* Fixed bug where when a user visits another member's media tab when groups are inactive, they'd get an error.
|
92 |
* Improved long album title and count display.
|
@@ -211,5 +214,5 @@ Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-medi
|
|
211 |
* HTML5 Video Tag Support (with fallback)
|
212 |
|
213 |
== Upgrade Notice ==
|
214 |
-
=2.5.
|
215 |
-
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.5
|
8 |
Tested up to: 3.5
|
9 |
+
Stable tag: 2.5.2
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to your BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
87 |
== Changelog ==
|
88 |
|
89 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
90 |
+
= 2.5.2 =
|
91 |
+
* Fixes warning on admin side.
|
92 |
+
|
93 |
= 2.5.1 =
|
94 |
* Fixed bug where when a user visits another member's media tab when groups are inactive, they'd get an error.
|
95 |
* Improved long album title and count display.
|
214 |
* HTML5 Video Tag Support (with fallback)
|
215 |
|
216 |
== Upgrade Notice ==
|
217 |
+
=2.5.2=
|
218 |
+
Fixes warning shown on the admin side for some PHP versions.
|