rtMedia for WordPress, BuddyPress and bbPress - Version 2.5.4

Version Description

  • Added option to enable/disable BuddyPress Media on Groups. (Profile toggle, coming soon)
  • Added Polish language.
  • Media tabs display now responds to admin settings
  • Improved Uploader UI.
  • Improved settings screen.
  • More code comments and documentation added.
  • Fixed gallery responsiveness.
  • A few bug fixes.
Download this release

Release Info

Developer saurabhshukla
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 2.5.4
Comparing to
See all releases

Code changes from version 2.5.3 to 2.5.4

Files changed (52) hide show
  1. app/admin/BPMediaAdmin.php +195 -164
  2. app/assets/css/main.css +75 -39
  3. app/assets/img/drag-drop-bg.png +0 -0
  4. app/assets/js/admin.js +10 -6
  5. app/assets/js/bp-media-activity-uploader.js +239 -0
  6. app/assets/js/bp-media-uploader.js +109 -102
  7. app/helper/BPMediaSettings.php +61 -26
  8. app/{main/importers → importers}/BPMediaBPActivityPlusImporter.php +0 -0
  9. app/importers/BPMediaBPAlbumImporter.php +87 -0
  10. app/importers/BPMediaImporter.php +116 -0
  11. app/main/BPMediaComponent.php +538 -0
  12. app/main/BPMediaGroupLoader.php +312 -0
  13. app/main/BPMediaLoader.php +152 -110
  14. app/main/BuddyPressMedia.php +616 -320
  15. app/main/activity/BPMediaActivity.php +163 -0
  16. app/main/group/BPMediaGroup.php +0 -270
  17. app/main/group/BPMediaGroupAction.php +29 -8
  18. app/main/group/BPMediaGroupElementExtension.php +7 -7
  19. app/main/group/dummy/{BPMediaGroupAlbum.php → BPMediaGroupAlbums.php} +2 -2
  20. app/main/group/dummy/{BPMediaGroupMusic.php → BPMediaGroupAudio.php} +2 -2
  21. app/main/group/dummy/{BPMediaGroupImage.php → BPMediaGroupImages.php} +2 -2
  22. app/main/group/dummy/{BPMediaGroupVideo.php → BPMediaGroupVideos.php} +2 -2
  23. app/main/importers/BPMediaBPAlbumImporter.php +0 -21
  24. app/main/importers/BPMediaImporter.php +0 -45
  25. app/main/includes/BPMediaActions.php +151 -58
  26. app/main/includes/BPMediaComponent.php +0 -381
  27. app/main/includes/BPMediaFilters.php +14 -0
  28. app/main/includes/BPMediaFunction.php +0 -18
  29. app/main/includes/BPMediaHostWordpress.php +70 -61
  30. app/main/includes/BPMediaUtils.php +0 -806
  31. app/main/includes/bp-media-upload-handler.php +2 -4
  32. app/main/privacy/BPMediaPrivacy.php +11 -31
  33. app/main/profile/BPMediaAlbum.php +44 -16
  34. app/main/profile/BPMediaAlbumScreen.php +42 -16
  35. app/main/profile/BPMediaScreen.php +16 -12
  36. app/main/profile/BPMediaTemplate.php +67 -57
  37. app/main/profile/BPMediaUploadScreen.php +3 -3
  38. app/main/query/BPMediaQuery.php +24 -0
  39. app/main/widgets/BPMediaPopularMedia.php +0 -124
  40. app/main/widgets/BPMediaRecentMedia.php +0 -236
  41. app/main/widgets/BPMediaWidget.php +302 -289
  42. index.php +8 -3
  43. lang/buddypress-media.po +0 -1009
  44. languages/buddypress-media-de.mo +0 -0
  45. languages/buddypress-media-es.mo +0 -0
  46. languages/buddypress-media-fr.mo +0 -0
  47. languages/buddypress-media-it.mo +0 -0
  48. languages/buddypress-media-ja.mo +0 -0
  49. languages/buddypress-media-nl.mo +0 -0
  50. languages/buddypress-media-pl.mo +0 -0
  51. languages/buddypress-media-pt_BR.mo +0 -0
  52. readme.txt +13 -3
app/admin/BPMediaAdmin.php CHANGED
@@ -24,6 +24,7 @@ if (!class_exists('BPMediaAdmin')) {
24
add_action('wp_ajax_bp_media_cancel_request', create_function('', 'do_settings_sections("bp-media-support"); die();'), 1);
25
add_action('wp_ajax_bp_media_submit_request', array($bp_media_support, 'submit_request'), 1);
26
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
27
if (is_admin()) {
28
add_action('admin_enqueue_scripts', array($this, 'ui'));
29
add_action(bp_core_admin_hook(), array($this, 'menu'));
@@ -114,7 +115,7 @@ if (!class_exists('BPMediaAdmin')) {
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
@@ -132,6 +133,7 @@ if (!class_exists('BPMediaAdmin')) {
132
do_settings_sections($page);
133
}
134
?>
135
</div>
136
137
</form>
@@ -141,90 +143,90 @@ if (!class_exists('BPMediaAdmin')) {
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,90 +240,119 @@ if (!class_exists('BPMediaAdmin')) {
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
?>
24
add_action('wp_ajax_bp_media_cancel_request', create_function('', 'do_settings_sections("bp-media-support"); die();'), 1);
25
add_action('wp_ajax_bp_media_submit_request', array($bp_media_support, 'submit_request'), 1);
26
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
27
+ add_action('wp_ajax_bp_media_linkback', array($this, 'linkback'), 1);
28
if (is_admin()) {
29
add_action('admin_enqueue_scripts', array($this, 'ui'));
30
add_action(bp_core_admin_hook(), array($this, 'menu'));
115
<?php settings_errors(); ?>
116
<div class="columns-2">
117
<h3 class="bp-media-settings-tabs"><?php
118
+ $this->sub_tabs();
119
?>
120
</h3>
121
133
do_settings_sections($page);
134
}
135
?>
136
+ <div class="rt-link alignright"><?php _e('By', BP_MEDIA_TXT_DOMAIN); ?> <a href="http://rtcamp.com" title="<?php _e('Empowering The Web With WordPress', BP_MEDIA_TXT_DOMAIN); ?>"><?php _e('rtCamp', BP_MEDIA_TXT_DOMAIN); ?></a></div>
137
</div>
138
139
</form>
143
</div>
144
</div><!-- .metabox-holder -->
145
</div><!-- .bp-media-admin --><?php
146
+ }
147
+
148
+ /**
149
+ * Adds a tab for Media settings in the BuddyPress settings page
150
+ *
151
+ * @global type $bp_media
152
+ */
153
+ public function tab() {
154
+
155
+ $tabs_html = '';
156
+ $idle_class = 'nav-tab';
157
+ $active_class = 'nav-tab nav-tab-active';
158
+ $tabs = array();
159
+
160
+ // Check to see which tab we are on
161
+ $tab = $this->get_current_tab();
162
+ /* BuddyPress Media */
163
+ $tabs[] = array(
164
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
165
+ 'title' => __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
166
+ 'name' => __('BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
167
+ 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
168
+ );
169
+
170
+ foreach ($tabs as $tab) {
171
+ $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
172
+ }
173
+ echo $tabs_html;
174
+ }
175
+
176
+ /**
177
+ * Adds a sub tabs to the BuddyPress Media settings page
178
+ *
179
+ * @global type $bp_media
180
+ */
181
+ public function sub_tabs() {
182
+ $tabs_html = '';
183
+ $idle_class = 'nav-tab';
184
+ $active_class = 'nav-tab nav-tab-active';
185
+ $tabs = array();
186
+
187
+ // Check to see which tab we are on
188
+ $tab = $this->get_current_tab();
189
+ /* BuddyPress Media */
190
+ $tabs[] = array(
191
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
192
+ 'title' => __('BuddyPress Media Settings', BP_MEDIA_TXT_DOMAIN),
193
+ 'name' => __('Settings', BP_MEDIA_TXT_DOMAIN),
194
+ 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
195
+ );
196
+
197
+ $tabs[] = array(
198
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
199
+ 'title' => __('BuddyPress Media Addons', BP_MEDIA_TXT_DOMAIN),
200
+ 'name' => __('Addons', BP_MEDIA_TXT_DOMAIN),
201
+ 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
202
+ );
203
+
204
+ $tabs[] = array(
205
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
206
+ 'title' => __('BuddyPress Media Support', BP_MEDIA_TXT_DOMAIN),
207
+ 'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
208
+ 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
209
+ );
210
+ $tabs = apply_filters('bp_media_add_sub_tabs', $tabs, $tab);
211
+ foreach ($tabs as $tab) {
212
+ $tabs_html.= '<a title="' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
213
+ }
214
+ echo $tabs_html;
215
+ }
216
+
217
+ /*
218
+ * Updates the media count of all users.
219
+ */
220
+
221
+ /**
222
+ *
223
+ * @global type $wpdb
224
+ * @return boolean
225
+ */
226
+ public function update_count() {
227
+ global $wpdb;
228
+ $query =
229
+ "SELECT
230
post_author,
231
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
232
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
240
`meta_value` > 0 AND
241
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
242
GROUP BY post_author";
243
+ $result = $wpdb->get_results($query);
244
+ if (!is_array($result))
245
+ return false;
246
+
247
+ foreach ($result as $obj) {
248
+
249
+ $count = array(
250
+ 'images' => isset($obj->Images) ? $obj->Images : 0,
251
+ 'videos' => isset($obj->Videos) ? $obj->Videos : 0,
252
+ 'audio' => isset($obj->Audio) ? $obj->Audio : 0,
253
+ 'albums' => isset($obj->Albums) ? $obj->Albums : 0
254
+ );
255
+ bp_update_user_meta($obj->post_author, 'bp_media_count', $count);
256
+ }
257
+ return true;
258
+ }
259
+
260
+ /* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
261
+
262
+ /**
263
+ *
264
+ * @global type $bp_media_admin
265
+ */
266
+ public function save_multisite_options() {
267
+ global $bp_media_admin;
268
+ if (isset($_POST['refresh-count'])) {
269
+ $bp_media_admin->update_count();
270
+ }
271
+ do_action('bp_media_sanitize_settings', $_POST);
272
+
273
+ if (isset($_POST['bp_media_options'])) {
274
+ bp_update_option('bp_media_options', $_POST['bp_media_options']);
275
+
276
+ // redirect to settings page in network
277
+ wp_redirect(
278
+ add_query_arg(
279
+ array('page' => 'bp-media-settings', 'updated' => 'true'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
280
+ )
281
+ );
282
+ exit;
283
+ }
284
+ }
285
+
286
+ /* Admin Sidebar */
287
+
288
+ /**
289
+ *
290
+ * @global type $bp_media
291
+ */
292
+ public function admin_sidebar() {
293
+ $current_user = wp_get_current_user();
294
+
295
+ $message = sprintf(__('I use @buddypressmedia http://goo.gl/8Upmv on %s', BP_MEDIA_TXT_DOMAIN),home_url());
296
+ $addons = '<label for="bp-media-add-linkback"><input' . checked(bp_get_option('bp_media_add_linkback', false), true, false) . ' type="checkbox" name="bp-media-add-linkback" value="1" id="bp-media-add-linkback"/> ' . __('Add link to footer', BP_MEDIA_TXT_DOMAIN) . '</label>
297
+ <ul>
298
+ <li><a href="http://twitter.com/home/?status=' . $message . '" target= "_blank"><input type="button" value="' . __('Tweet', BP_MEDIA_TXT_DOMAIN) . '" class="button button-tweet"></a></li>
299
+ <li><a href="http://wordpress.org/support/view/plugin-reviews/buddypress-media?rate=5#postform" target= "_blank"><input type="button" value="' . __('Rate on WordPress.org', BP_MEDIA_TXT_DOMAIN) . '" class="button button-rating"></a></li>
300
+ </ul>';
301
+ new BPMediaAdminWidget('spread-the-word', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), $addons);
302
+
303
+ $donate = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
304
+ <!-- Identify your business so that you can collect the payments. -->
305
+ <input type="hidden" name="business"
306
+ value="paypal@rtcamp.com">
307
+ <!-- Specify a Donate button. -->
308
+ <input type="hidden" name="cmd" value="_donations">
309
+ <!-- Specify details about the contribution -->
310
+ <input type="hidden" name="item_name" value="BuddyPress Media">
311
+ <input type="text" name="amount" size="3">
312
+ <label><b>' . __('USD', BP_MEDIA_TXT_DOMAIN) . '</b></label> <br/>
313
+ <input type="hidden" name="currency_code" value="USD">
314
+ <!-- Display the payment button. -->
315
+ <input type="hidden" name="cpp_header_image" value="' . BP_MEDIA_URL . 'app/assets/img/rtcamp-logo.png">
316
+ <input type="image" name="submit" border="0"
317
+ src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif"
318
+ alt="PayPal - The safer, easier way to pay online">
319
+ <img alt="" border="0" width="1" height="1"
320
+ src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
321
+ </form>';
322
+ new BPMediaAdminWidget('donate', __('Donate', BP_MEDIA_TXT_DOMAIN), $donate);
323
+
324
+ $branding = '<form action="http://rtcamp.us1.list-manage1.com/subscribe/post?u=85b65c9c71e2ba3fab8cb1950&amp;id=9e8ded4470" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
325
+ <div class="mc-field-group">
326
+ <input type="email" value="' . $current_user->user_email . '" name="EMAIL" placeholder="Email" class="required email" id="mce-EMAIL">
327
+ <input style="display:none;" type="checkbox" checked="checked" value="1" name="group[1721][1]" id="mce-group[1721]-1721-0"><label for="mce-group[1721]-1721-0">
328
+ <div id="mce-responses" class="clear">
329
+ <div class="response" id="mce-error-response" style="display:none"></div>
330
+ <div class="response" id="mce-success-response" style="display:none"></div>
331
+ </div>
332
+ <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
333
+ </div>
334
+ </form>
335
<ul id="social">
336
<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>
337
<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>
338
<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>
339
</ul>';
340
+ new BPMediaAdminWidget('branding', __('Subscribe', BP_MEDIA_TXT_DOMAIN), $branding);
341
+
342
+ $news = '<img src ="' . admin_url('/images/wpspin_light.gif') . '" /> Loading...';
343
+ new BPMediaAdminWidget('latest-news', __('Latest News', BP_MEDIA_TXT_DOMAIN), $news);
344
+ }
345
346
+ public function linkback() {
347
+ if (isset($_POST['linkback']) && $_POST['linkback']) {
348
+ return bp_update_option('bp_media_add_linkback', true);
349
+ } else {
350
+ return bp_update_option('bp_media_add_linkback', false);
351
}
352
+ die;
353
+ }
354
+
355
+ }
356
+
357
+ }
358
?>
app/assets/css/main.css CHANGED
@@ -24,7 +24,6 @@ div.bp_media_title{margin-bottom:10px;}
24
#wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
25
#wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
26
27
-
28
#wpbody-content .wrap div.bp-media-metabox-holder{padding-top: 0}
29
.bp-media-social{background: url('../img/bp_media_social.png');height: 35px;width: 35px;display: inline-block;font-size: 0px;margin-right:5px;}
30
.bp-media-facebook{background-position: 0px 0px;}
@@ -34,28 +33,39 @@ div.bp_media_title{margin-bottom:10px;}
34
.bp-media-rss{background-position: 35px 0px;}
35
.bp-media-rss:hover{background-position: 35px 36px;}
36
/*#bp-media-upload-ui{position: relative;}*/
37
-
38
-
39
- #bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;height: 150px;width: 150px;}
40
- .upload #bp-media-upload-ui #drag-drop-area{height: auto; width: 100%;}
41
- #bp-media-upload-ui .drag-drop-inside{margin:auto;width: 100%;}
42
- #bp-media-album-prompt{margin: 0;position: absolute;right: 0;text-align: right;top: 2px;min-width: 200px;}
43
- #bp-media-album-prompt span{float: left;line-height: 25px;margin-right: 15px;}
44
- #bp-media-album-prompt .bp-media-album-content{float: left;}
45
- #bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;}
46
- #bp-media-album-prompt div.hide{display: none;position: absolute;right: 0;top: 0;z-index: 100;position: relative;}
47
- #bp-media-album-prompt #bp_media_album_new {width: 160px;}
48
- #bp-media-album-prompt input.button{height: 25px;margin-left: 5px;padding: 0 10px;position: relative;top: -1px;}
49
- div.bp-media-area-allocate{display: block;height: 15px;}
50
- div.bp_media_create_album{text-align: right}
51
- #bp_media_album_name{margin-bottom: 6px;}
52
#item-body:after,ul.bp-media-gallery.item-list:after{content: " ";clear: both;display: block;text-indent: -9999em;}
53
#item-body{position: relative;}
54
55
- #bp-media-upload-ui .drag-drop-inside p{display: block;text-align: center;color: #AAA;margin: 12px 0;}
56
- #bp-media-upload-ui .drag-drop-info{font-size: 20px;}
57
- #bp-media-upload-ui .drag-drop-buttons input{border-color: #BBB;color: #464646;text-decoration: none;font-size: 12px!important;line-height: 13px;padding: 3px 8px;cursor: pointer;border-width: 1px;border-style: solid;-webkit-border-radius: 11px;border-radius: 11px;-moz-box-sizing: content-box;-webkit-box-sizing: content-box;box-sizing: content-box;}
58
- #bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;left: 0;margin-top: 5px;position: absolute;top: 155px;width: 100%;}
59
#bp-media-uploaded-files .error{padding: 5px;text-align: center;}
60
.bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)}
61
.bp-media-progress-text{z-index: 10;position: relative;width: 100%;padding: 0 8px;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);color: rgba(0, 0, 0, 0.6);font-size:16px;line-height: 28px;height: 28px;}
@@ -94,10 +104,19 @@ div.bp_media_create_album{text-align: right}
94
#bp-media-settings-boxes{border:1px solid #CCC; overflow: hidden; padding: 10px; -webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px; float: left; width: 98%;}
95
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
96
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
97
- .metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left top no-repeat; padding-left: 19px;}
98
#branding #logo{text-align:center;padding: 10px 0;display:block;}
99
- ul#social{display:block;text-align:center;margin:0;}
100
ul#social li{display:inline;}
101
#bp-media-show-more{width: 200px;margin-left: auto;margin-right: auto;display: block;height: 30px;line-height: 30px;font-size: 20px;}
102
#bp-media-upload-ui.activity-component{margin-left: 74px;margin-top: 10px;}
103
ul#activity-stream li.media.album_updated ul{}
@@ -172,20 +191,37 @@ background-image: -webkit-gradient(linear,left bottom,left top,color-stop(1, #F7
172
.rt-success{background-color: #E1FFDF;border-color: #2ACF2A;}
173
.rt-update{background-color: #FFEAA6;border-color:#E1CA82;}
174
img.bp-media-donation-image{display:block;margin: 10px auto;}
175
-
176
- /* BuddyPress Media Image Uploader album selection */
177
- /*#bp-media-album-prompt, #bp-media-album-new { background: none repeat scroll 0 0 #FFFFFF;border: 1px solid #AAAAAA;border-radius: 5px 5px 5px 5px;display: none;padding: 3px;z-index: 110000;left: 40%;position: fixed;top: 35%;width: 300px; }
178
- #bp-media-album-new { z-index: 120000; }
179
- .bp-media-album-title { background: url("../img/Popup-title-bg.png") repeat-x scroll 50% 50% #CCCCCC;border: 1px solid #AAAAAA;border-radius: 5px 5px 5px 5px;color: #222222;display: block;font-weight: bold;padding: 0;margin-bottom: 10px; }
180
- .bp-media-album-title span { background: none repeat scroll 0 0 transparent;display: block;font-size: 16px;padding: 10px; }
181
- #bp-media-create-album-close, #bp-media-create-album-close:active, #bp-media-close, #bp-media-close:active { border-radius: 3px 3px 3px 3px;cursor: pointer;display: block;padding: 0 7px 2px;position: absolute;right: 8px;top: 11px;z-index: 10; }
182
- #bp-media-create-album-close:hover, #bp-media-create-album-close:focus, #bp-media-close:hover, #bp-media-close:focus { background: none repeat scroll 0 0 #545454;color: #CFCFCF; }
183
- .bp-media-album-content { display: block;padding: 5px; }
184
- .bp-media-album-content label { display: block;font-size: 14px;margin: 0 0 0 3px; }
185
- #bp-media-album-prompt select { min-width: 140px; }
186
- .select-btn-div { border-top: 1px solid #AAAAAA;margin: 15px 0 0;padding: 5px 5px 5px 30px;text-align: right; }
187
- .select-btn-div .btn { float: right;font-size: 14px;margin: 5px;padding: 10px 25px; }
188
- #bp-media-album-new > label { font-size: 14px; }
189
- #bp-media-album-new input[type="text"] { width: 98%; }
190
- #custom-overlay { background: none repeat scroll 0 0 #000000;bottom: 0;left: 0;min-height: 360px;opacity: 0.7;position: fixed;right: 0;top: 0;z-index: 105000; }
191
- div.error{margin: 5px 0 15px; background-color: #ffebe8; border-color: #c00;padding: 0 .6em;-webkit-border-radius: 3px;border-radius: 3px;border-width: 1px;border-style: solid;}*/
24
#wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
25
#wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
26
27
#wpbody-content .wrap div.bp-media-metabox-holder{padding-top: 0}
28
.bp-media-social{background: url('../img/bp_media_social.png');height: 35px;width: 35px;display: inline-block;font-size: 0px;margin-right:5px;}
29
.bp-media-facebook{background-position: 0px 0px;}
33
.bp-media-rss{background-position: 35px 0px;}
34
.bp-media-rss:hover{background-position: 35px 36px;}
35
/*#bp-media-upload-ui{position: relative;}*/
36
#item-body:after,ul.bp-media-gallery.item-list:after{content: " ";clear: both;display: block;text-indent: -9999em;}
37
#item-body{position: relative;}
38
39
+ .bp-media-area-allocate{height: 10px;width: 100%;display: block;}
40
+ li #bp-media-upload-ui {padding: 0;max-width: 158px;position: relative;}
41
+ #bp-media-upload-ui #drag-drop-area{border: 4px dashed #DDD;text-align: center;background: url('../img/drag-drop-bg.png') repeat scroll 0 0 transparent;overflow: hidden;padding: 20px 0 0;}
42
+ li #bp-media-upload-ui #drag-drop-area{max-width: 150px;min-height: auto;padding-top: 15px;}
43
+ .albums li #bp-media-upload-ui #drag-drop-area{padding: 20px 0 10px;}
44
+ #bp-media-upload-ui .drag-drop-inside{float: left;margin: 0 auto 10px;width: 48%;}
45
+ .albums #bp-media-upload-ui .drag-drop-inside{float: none;width: auto;}
46
+ li #bp-media-upload-ui .drag-drop-inside,li #bp-media-upload-ui #bp-media-album-prompt{float: none;margin: 0 auto 18px;max-width: 100%;width: auto;}
47
+ li #bp-media-upload-ui #bp-media-album-prompt{margin: 8px auto 0;max-width: 144px;}
48
+ #bp-media-upload-ui #bp-media-album-prompt{float: right;margin: 12px auto 0;width: 47%;}
49
+ #bp-media-upload-ui .drag-drop-inside p.drag-drop-info{font-size: 20px;line-height: 100%;}
50
+ #bp-media-upload-ui .drag-drop-buttons input,#bp-media-album-prompt input.button{-moz-box-sizing: content-box;border-color: #BBBBBB;border-radius: 15px;border-style: solid;border-width: 1px;color: #464646;cursor: pointer;font-size: 13px !important;line-height: 13px;padding: 5px 10px;text-decoration: none;}
51
+ li #bp-media-album-prompt input.button{font-size: 12px !important;padding: 3px 8px;text-decoration: none;margin-top: 5px;}
52
+ #bp-media-selected-album{max-width: 140px;font-size: 14px;width: 100%;margin: 10px 0;}
53
+ li #bp-media-album-prompt > p,li #bp-media-upload-ui #drag-drop-area p{display: none;}
54
+ .albums li #bp-media-album-prompt > p,.albums li #bp-media-upload-ui #drag-drop-area p{display: block;}
55
+ li #bp-media-upload-ui #drag-drop-area p.drag-drop-buttons{display: block;}
56
+ #bp-media-album-prompt div.hide{display: none;margin: 0;}
57
+ #bp-media-album-prompt > p{font-size: 20px;}
58
+ #bp-media-upload-ui .drag-drop-inside p,#bp-media-album-prompt #bp_media_album_new{margin-bottom: 12px;font-size: 14px;}
59
+ #bp-media-album-prompt #bp_media_album_new{max-width: 90%;}
60
+ li #bp-media-album-prompt #bp_media_album_new{margin: 0;max-width: 134px;width: 94%;}
61
+ #bp-media-upload-ui .drag-drop-to{width: 22px;line-height: 22px;margin: 40px auto 0;float: left;}
62
+ li #bp-media-upload-ui .drag-drop-to{width: 100%;line-height: 22px;margin: 0;float: none;}
63
+ #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: left;font-size: 14px;line-height: 22px;margin: 30px auto 0;width: 22px;}
64
+ li #bp-media-album-in{background-color: #333333;border-radius: 11px 11px 11px 11px;color: #FFFFFF;display: block;float: none;font-size: 14px;line-height: 22px;margin: 0 auto;width: 22px;}
65
+ #bp-media-album-prompt #create-new{background-color: #DF562C;color: #fff;}
66
+
67
+ #bp-media-uploaded-files{background: none repeat scroll 0 0 #DDDDDD;margin-top: 5px;width: 100%;}
68
+ li #bp-media-uploaded-files{left: 0;position: absolute;top: 155px;}
69
#bp-media-uploaded-files .error{padding: 5px;text-align: center;}
70
.bp-media-progressbar{height: 28px;margin: 6px 10px 0 0;line-height: 2em;padding: 0;overflow: hidden;margin-bottom: 2px;border: 1px solid #D1D1D1;background: white;background-image: linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -o-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -moz-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -webkit-linear-gradient(bottom,white 0,#F7F7F7 100%);background-image: -ms-linear-gradient(bottom,white 0,#F7F7F7 100%);-webkit-border-radius: 3px;border-radius: 3px;-webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1)}
71
.bp-media-progress-text{z-index: 10;position: relative;width: 100%;padding: 0 8px;text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);color: rgba(0, 0, 0, 0.6);font-size:16px;line-height: 28px;height: 28px;}
104
#bp-media-settings-boxes{border:1px solid #CCC; overflow: hidden; padding: 10px; -webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px; float: left; width: 98%;}
105
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
106
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
107
+ .metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left 4px no-repeat; padding-left: 26px;}
108
#branding #logo{text-align:center;padding: 10px 0;display:block;}
109
+ ul#social{display:block;text-align:center;margin:0;clear: both;}
110
+ #branding #mc-embedded-subscribe-form{float: left;width: 100%;}
111
+ #branding label{float: right;}
112
+ #branding #mc-embedded-subscribe{float: right;padding: 0 3px;}
113
+ #branding #mce-EMAIL{float: left;}
114
ul#social li{display:inline;}
115
+ #spread-the-word .inside{text-align: center;}
116
+ .wp-admin .button-tweet{background: #33ACE6; border-color: #3399DD #3399DD #2288CC; color: #FFFFFF !important; text-shadow: -1px -1px 0 #3399DD;}
117
+ .wp-admin .button-tweet:hover{background: #3399DD;border-color: #2288CC;box-shadow: 0 0 4px rgba(82, 168, 236, 0.75);}
118
+ .wp-admin .button-rating{background: #8A8A8A; border-color: #222; color: #FFFFFF !important; text-shadow: -1px -1px 0 #444;}
119
+ .wp-admin .button-rating:hover{background: #7E7E7E;border-color: #444;box-shadow: 0 0 4px rgba(128,128,128, 0.75);}
120
#bp-media-show-more{width: 200px;margin-left: auto;margin-right: auto;display: block;height: 30px;line-height: 30px;font-size: 20px;}
121
#bp-media-upload-ui.activity-component{margin-left: 74px;margin-top: 10px;}
122
ul#activity-stream li.media.album_updated ul{}
191
.rt-success{background-color: #E1FFDF;border-color: #2ACF2A;}
192
.rt-update{background-color: #FFEAA6;border-color:#E1CA82;}
193
img.bp-media-donation-image{display:block;margin: 10px auto;}
194
+ #donate form{text-align: center;}
195
+
196
+ @media (min-width: 981px) and (max-width: 1096px) {
197
+ #bp-media-upload-ui .drag-drop-area{padding-top: 12px;}
198
+ li #bp-media-upload-ui .drag-drop-inside{margin: 0 auto 10px;}
199
+ li #bp-media-upload-ui #bp-media-album-prompt{margin-top: 0;}
200
+ li #bp-media-album-prompt input.button{padding: 3px;}
201
+ .albums li #bp-media-upload-ui #drag-drop-area{padding: 10px 0 0;}
202
+ }
203
+ @media (max-width: 980px) {
204
+ #item-body ul.bp-media-gallery li{width: 23%;}
205
+ li #bp-media-upload-ui #drag-drop-area{min-height: auto;}
206
+ }
207
+ @media (max-width: 850px) {
208
+ #item-body ul.bp-media-gallery li{width: 31%;}
209
+ #bp-media-upload-ui .drag-drop-inside{width: 47%;}
210
+ #bp-media-upload-ui #bp-media-album-prompt{width: 46%;}
211
+ }
212
+ @media (max-width: 480px) {
213
+ #item-body ul.bp-media-gallery li{width: 48%;}
214
+ li #bp-media-upload-ui{max-width: 170px;}
215
+ ul.bp-media-gallery li img,li #bp-media-upload-ui #drag-drop-area{max-width: 170px;width: 100%;}
216
+ li #bp-media-upload-ui #drag-drop-area{max-width: 162px;}
217
+ #bp-media-upload-ui .drag-drop-area{padding: 23px 0 10px;}
218
+ li #bp-media-upload-ui .drag-drop-inside{margin: 0 auto 23px;}
219
+ }
220
+ @media (max-width: 379px) {
221
+ #bp-media-upload-ui{min-height: 190px;}
222
+ #item-body ul.bp-media-gallery li{width: 95%;}
223
+ #bp-media-upload-ui .drag-drop-inside{float: none;width: 100%;}
224
+ #bp-media-album-in{float: none;margin: 0 auto;}
225
+ #bp-media-upload-ui #bp-media-album-prompt{margin: 15px auto 15px;float: none;width: 100%}
226
+ #bp-media-upload-ui .drag-drop-inside p,#bp-media-album-prompt #bp_media_album_new{margin-bottom: 5px;}
227
+ }
app/assets/img/drag-drop-bg.png ADDED
Binary file
app/assets/js/admin.js CHANGED
@@ -1,5 +1,15 @@
1
jQuery(document).ready(function(){
2
3
/* Fetch Feed */
4
var bp_media_news_section = jQuery('#latest-news');
5
if(bp_media_news_section.length>0){
@@ -11,12 +21,6 @@ jQuery(document).ready(function(){
11
});
12
}
13
14
- // /* Add more attachment link */
15
- // jQuery( '.add-more-attachment-btn' ).live('click', function(event){
16
- // event.preventDefault();
17
- // jQuery(this).prev().after('<div class="more-attachment"><input class="bp-media-input" type="file" name="attachment[]" /></div>');
18
- // });
19
-
20
/* Select Request */
21
jQuery('#bp-media-settings-boxes').on('change', '#select-request', function(){
22
if(jQuery(this).val()){
1
jQuery(document).ready(function(){
2
3
+ /* Linkback */
4
+ jQuery('#spread-the-word').on('click','#bp-media-add-linkback',function(){
5
+ var data = {
6
+ action: 'bp_media_linkback',
7
+ linkback: jQuery('#bp-media-add-linkback:checked').length
8
+ };
9
+ jQuery.post(bp_media_admin_ajax,data,function(response){
10
+ });
11
+ })
12
+
13
/* Fetch Feed */
14
var bp_media_news_section = jQuery('#latest-news');
15
if(bp_media_news_section.length>0){
21
});
22
}
23
24
/* Select Request */
25
jQuery('#bp-media-settings-boxes').on('change', '#select-request', function(){
26
if(jQuery(this).val()){
app/assets/js/bp-media-activity-uploader.js ADDED
@@ -0,0 +1,239 @@
1
+ /*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+ jQuery(document).ready(function(){
7
+ if ( jQuery('#bp-media-activity-upload-ui').length > 0 ) {
8
+ //Activity Uploader
9
+ var bp_media_activity_is_multiple_upload = false;
10
+ var bp_media_activity_uploader=new plupload.Uploader(bp_media_uploader_params);
11
+ var bp_media_activity_album_selected = false;
12
+ bp_media_activity_uploader.init();
13
+
14
+ bp_media_activity_uploader.bind('FilesAdded', function(up, files) {
15
+ //bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
16
+ bp_media_activity_is_multiple_upload = files.length>1;
17
+ jQuery.each(files, function(i, file) {
18
+ var bp_media_activity_extension = file.name.substr( (file.name.lastIndexOf('.') +1) );
19
+ jQuery('#bp-media-activity-uploaded-files').append('<div id="bp-media-activity-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' + file.name + ' (' + plupload.formatSize(file.size) + ')(<b>0%</b>)</div><div class="bp-media-progress-completed"></div></div>');
20
+ });
21
+ // bp_media_activity_album_selected = jQuery('#bp-media-activity-selected-album').val();
22
+ bp_media_activity_album_selected = '535';
23
+ bp_media_activity_uploader.start();
24
+ up.refresh(); // Reposition Flash/Silverlight
25
+ });
26
+ bp_media_activity_uploader.bind('UploadProgress', function(up, file) {
27
+ jQuery('input#aw-whats-new-submit').prop('disabled',true);
28
+ jQuery('input#bp-media-aw-whats-new-submit').prop('disabled',true);
29
+ jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
30
+ jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
31
+ });
32
+
33
+ bp_media_activity_uploader.bind('Error', function(up, err) {
34
+ jQuery('#bp-media-activity-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
35
+ ', Message: ' + err.message +
36
+ (err.file ? ', File: ' + err.file.name : '') +
37
+ '</p></div>'
38
+ );
39
+ up.refresh();
40
+ });
41
+
42
+ bp_media_activity_uploader.bind('FileUploaded', function(up, file,response) {
43
+ jQuery('input#aw-whats-new-submit').after('<input type="submit" name="bp-media-aw-whats-new-submit" id="bp-media-aw-whats-new-submit" value="Post Media Update">').remove()
44
+ jQuery('#bp-media-aw-whats-new-submit').prop('disabled',true);
45
+ jQuery('#bp-media-activity-progress-'+file.id+' .bp-media-progress-text b').html("100%");
46
+ jQuery('#bp-media-activity-post-update-append').append('<span>'+response.response+'</span>');
47
+ jQuery('#bp-media-aw-whats-new-submit').prop('disabled',false);
48
+ });
49
+ bp_media_activity_uploader.bind('BeforeUpload',function(up){
50
+ up.settings.multipart_params.is_multiple_upload = bp_media_activity_is_multiple_upload;
51
+ up.settings.multipart_params.bp_media_album_id = bp_media_activity_album_selected;
52
+ up.settings.multipart_params.is_activity = true;
53
+ });
54
+ bp_media_activity_uploader.bind('UploadComplete',function(response){
55
+ });
56
+
57
+ /* New posts */
58
+ jQuery('#whats-new-submit').on('click', 'input#aw-whats-new-submit', function() {
59
+ var button = jQuery(this);
60
+ var form = button.parent().parent().parent().parent();
61
+
62
+ form.children().each( function() {
63
+ if ( jQuery.nodeName(this, "textarea") || jQuery.nodeName(this, "input") )
64
+ jQuery(this).prop( 'disabled', true );
65
+ });
66
+
67
+ /* Remove any errors */
68
+ jQuery('div.error').remove();
69
+ button.addClass('loading');
70
+ button.prop('disabled', true);
71
+
72
+ /* Default POST values */
73
+ var object = '';
74
+ var item_id = jQuery("#whats-new-post-in").val();
75
+ var content = jQuery("textarea#whats-new").val();
76
+
77
+ /* Set object for non-profile posts */
78
+ if ( item_id > 0 ) {
79
+ object = jQuery("#whats-new-post-object").val();
80
+ }
81
+
82
+ jQuery.post( ajaxurl, {
83
+ action: 'post_update',
84
+ 'cookie': encodeURIComponent(document.cookie),
85
+ '_wpnonce_post_update': jQuery("input#_wpnonce_post_update").val(),
86
+ 'content': content,
87
+ 'object': object,
88
+ 'item_id': item_id,
89
+ '_bp_as_nonce': jQuery('#_bp_as_nonce').val() || ''
90
+ },
91
+ function(response) {
92
+
93
+ form.children().each( function() {
94
+ if ( jQuery.nodeName(this, "textarea") || jQuery.nodeName(this, "input") ) {
95
+ jQuery(this).prop( 'disabled', false );
96
+ }
97
+ });
98
+
99
+ /* Check for errors and append if found. */
100
+ if ( response[0] + response[1] == '-1' ) {
101
+ form.prepend( response.substr( 2, response.length ) );
102
+ jQuery( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
103
+ } else {
104
+ if ( 0 == jQuery("ul.activity-list").length ) {
105
+ jQuery("div.error").slideUp(100).remove();
106
+ jQuery("div#message").slideUp(100).remove();
107
+ jQuery("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
108
+ }
109
+
110
+ jQuery("ul#activity-stream").prepend(response);
111
+ jQuery("ul#activity-stream li:first").addClass('new-update');
112
+
113
+ if ( 0 != jQuery("#latest-update").length ) {
114
+ var l = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").html();
115
+ var v = jQuery("ul#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
116
+
117
+ var ltext = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").text();
118
+
119
+ var u = '';
120
+ if ( ltext != '' )
121
+ u = l + ' ';
122
+
123
+ u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
124
+
125
+ jQuery("#latest-update").slideUp(300,function(){
126
+ jQuery("#latest-update").html( u );
127
+ jQuery("#latest-update").slideDown(300);
128
+ });
129
+ }
130
+
131
+ jQuery("li.new-update").hide().slideDown( 300 );
132
+ jQuery("li.new-update").removeClass( 'new-update' );
133
+ jQuery("textarea#whats-new").val('');
134
+ }
135
+
136
+ jQuery("#whats-new-options").animate({
137
+ height:'0px'
138
+ });
139
+ jQuery("form#whats-new-form textarea").animate({
140
+ height:'20px'
141
+ });
142
+ jQuery("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
143
+ });
144
+
145
+ return false;
146
+ });
147
+
148
+ jQuery('#whats-new-submit').on('click', '#bp-media-aw-whats-new-submit', function(e){
149
+ var button = jQuery(this);
150
+ button.addClass('loading');
151
+ var form = button.parent().parent().parent().parent();
152
+ /* Default POST values */
153
+ var object = '';
154
+ var item_id = jQuery("#whats-new-post-in").val();
155
+
156
+ /* Set object for non-profile posts */
157
+ if ( item_id > 0 ) {
158
+ object = jQuery("#whats-new-post-object").val();
159
+ }
160
+ var media_id = false;
161
+ var multiple = 0;
162
+ jQuery('#bp-media-activity-post-update-append span').each(function(){
163
+ if (media_id){
164
+ media_id=media_id+'-'+jQuery(this).text();
165
+ multiple = 1;
166
+ }else{
167
+ media_id=jQuery(this).text();
168
+ }
169
+ });
170
+ var data = {
171
+ action: 'bp_media_post_update',
172
+ '_wpnonce_post_update': jQuery("input#_wpnonce_post_update").val(),
173
+ 'content': jQuery('#whats-new').val(),
174
+ 'object': object,
175
+ 'item_id': item_id,
176
+ 'media_id': media_id,
177
+ 'multiple': multiple,
178
+ '_bp_as_nonce': jQuery('#_bp_as_nonce').val() || ''
179
+ };
180
+ jQuery.post(activity_ajax_url,data, function (response) {
181
+ jQuery('#bp-media-activity-uploaded-files').html('');
182
+ jQuery('#bp-media-activity-post-update-append').html('');
183
+ jQuery('#bp-media-aw-whats-new-submit').after('<input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="Post Update">').remove();
184
+ form.children().each( function() {
185
+ if ( jQuery.nodeName(this, "textarea") || jQuery.nodeName(this, "input") ) {
186
+ jQuery(this).prop( 'disabled', false );
187
+ }
188
+ });
189
+
190
+ /* Check for errors and append if found. */
191
+ if ( response[0] + response[1] == '-1' ) {
192
+ form.prepend( response.substr( 2, response.length ) );
193
+ jQuery( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
194
+ } else {
195
+ if ( 0 == jQuery("ul.activity-list").length ) {
196
+ jQuery("div.error").slideUp(100).remove();
197
+ jQuery("div#message").slideUp(100).remove();
198
+ jQuery("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
199
+ }
200
+
201
+ jQuery("ul#activity-stream").prepend(response);
202
+ jQuery("ul#activity-stream li:first").addClass('new-update');
203
+
204
+ if ( 0 != jQuery("#latest-update").length ) {
205
+ var l = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").html();
206
+ var v = jQuery("ul#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
207
+
208
+ var ltext = jQuery("ul#activity-stream li.new-update .activity-content .activity-inner p").text();
209
+
210
+ var u = '';
211
+ if ( ltext != '' )
212
+ u = l + ' ';
213
+
214
+ u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
215
+
216
+ jQuery("#latest-update").slideUp(300,function(){
217
+ jQuery("#latest-update").html( u );
218
+ jQuery("#latest-update").slideDown(300);
219
+ });
220
+ }
221
+
222
+ jQuery("li.new-update").hide().slideDown( 300 );
223
+ jQuery("li.new-update").removeClass( 'new-update' );
224
+ jQuery("textarea#whats-new").val('');
225
+ }
226
+
227
+ jQuery("#whats-new-options").animate({
228
+ height:'0px'
229
+ });
230
+ jQuery("form#whats-new-form textarea").animate({
231
+ height:'20px'
232
+ });
233
+ jQuery("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
234
+ jQuery("input#aw-whats-new-submit").bind('click');
235
+ });
236
+ e.preventDefault();
237
+ });
238
+ }
239
+ });
app/assets/js/bp-media-uploader.js CHANGED
@@ -4,110 +4,117 @@
4
*/
5
6
jQuery(document).ready(function(){
7
8
- var selected = jQuery('#bp-media-album-prompt select').val();
9
- if(jQuery('#'+bp_media_uploader_params.container).length==0)
10
- return false;
11
- jQuery('#bp-media-album-prompt select').change(function() {
12
-
13
- if ( jQuery(this).val() == 'create_new' ) {
14
- jQuery('#bp_media_album_new').css({'width':jQuery('#bp-media-album-prompt select').width()+20});
15
- jQuery('#bp-media-album-prompt select').hide();
16
- jQuery('#bp-media-album-prompt span').hide();
17
- jQuery('#bp-media-album-prompt div.hide').show();
18
- } else
19
- selected = jQuery(this).val();
20
- });
21
- var new_album_flag = 0;
22
- jQuery('#btn-create-new').click(function(){
23
- if ( new_album_flag == 1 ) {
24
- return false;
25
- }
26
- var new_album_name = jQuery('#bp_media_album_new').val();
27
- if(new_album_name.length==0){
28
- alert('You have not filled the album name');
29
- return false;
30
- } else {
31
- new_album_flag = 1;
32
- jQuery(this).val('Wait');
33
- var data = {
34
- action: 'bp_media_add_album',
35
- bp_media_album_name : new_album_name,
36
- bp_media_group_id : bp_media_uploader_params.multipart_params.bp_media_group_id
37
- };
38
- jQuery.post(bp_media_vars.ajaxurl,data,function(response){
39
- var album = parseInt(response);
40
- if(album == 0){
41
- alert('Sorry you cannot create albums in this group');
42
- }
43
- else {
44
- jQuery('#bp-media-album-prompt select option').removeAttr('selected');
45
- jQuery('#bp-media-selected-album').prepend('<option value='+album+' selected="selected">'+new_album_name+'</option>');
46
- jQuery('#bp-media-album-prompt div.hide').hide();
47
- jQuery('#bp-media-album-prompt select').show();
48
- jQuery('#bp-media-album-prompt span').show();
49
- }
50
- });
51
- }
52
});
53
- jQuery('#btn-create-cancel').click(function(){
54
- jQuery('#bp-media-album-prompt div.hide').hide();
55
- jQuery('#bp-media-album-prompt select option').removeAttr('selected');
56
- jQuery('#bp-media-album-prompt select option[value=' + selected + ']').attr('selected', 'selected');
57
- jQuery('#bp-media-album-prompt select').show();
58
- jQuery('#bp-media-album-prompt span').show();
59
- });
60
- var bp_media_is_multiple_upload = false;
61
- var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
62
- var bp_media_album_selected = false;
63
- bp_media_uploader.init();
64
-
65
- bp_media_uploader.bind('FilesAdded', function(up, files) {
66
- if ( jQuery('#bp-media-selected-album').val() == 'create_new' ) {
67
- alert("Please Select an Album !!");
68
- return false;
69
- }
70
- //bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
71
- bp_media_is_multiple_upload = files.length>1;
72
- jQuery.each(files, function(i, file) {
73
- var extension = file.name.substr( (file.name.lastIndexOf('.') +1) );
74
- jQuery('#bp-media-uploaded-files').append('<div id="bp-media-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' + file.name + ' (' + plupload.formatSize(file.size) + ')(<b>0%</b>)</div><div class="bp-media-progress-completed"></div></div>');
75
- });
76
- bp_media_album_selected = jQuery('#bp-media-selected-album').val();
77
- bp_media_uploader.start();
78
- up.refresh(); // Reposition Flash/Silverlight
79
- });
80
- bp_media_uploader.bind('UploadProgress', function(up, file) {
81
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
82
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
83
- });
84
85
- bp_media_uploader.bind('Error', function(up, err) {
86
- jQuery('#bp-media-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
87
- ', Message: ' + err.message +
88
- (err.file ? ', File: ' + err.file.name : '') +
89
- '</p></div>'
90
- );
91
- up.refresh();
92
- });
93
94
- bp_media_uploader.bind('FileUploaded', function(up, file) {
95
- jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html("100%");
96
- });
97
- bp_media_uploader.bind('BeforeUpload',function(up){
98
- up.settings.multipart_params.is_multiple_upload = bp_media_is_multiple_upload;
99
- up.settings.multipart_params.bp_media_album_id = bp_media_album_selected;
100
- });
101
- bp_media_uploader.bind('UploadComplete',function(){
102
- var new_location = window.location.href;
103
- if(new_location.search('/upload/')>0){
104
- new_location = new_location.replace('/upload/','/albums/');
105
- if(bp_media_album_selected>0)
106
- new_location = new_location.concat(bp_media_album_selected);
107
- else
108
- new_location = new_location.concat('0/');
109
- window.location.replace(new_location);
110
- } else
111
- location.reload(true);
112
- });
113
});
4
*/
5
6
jQuery(document).ready(function(){
7
+
8
+ var selected = jQuery('#bp-media-album-prompt select').val();
9
+ var in_list = 0;
10
+ if(jQuery('#'+bp_media_uploader_params.container).length==0)
11
+ return false;
12
+ if ( jQuery('#bp-media-album-prompt p').css('display') == 'none' )
13
+ in_list = 1;
14
+ jQuery('#bp-media-album-prompt select').change(function() {
15
+ if ( jQuery(this).val() == 'create_new' ) {
16
+ jQuery('#bp-media-album-prompt select').hide();
17
+ jQuery('#bp-media-album-prompt p').hide();
18
+ jQuery('#bp-media-album-prompt div.hide').show();
19
+ } else
20
+ selected = jQuery(this).val();
21
+ });
22
+ var new_album_flag = 0;
23
+ jQuery('#btn-create-new').click(function(){
24
+ if ( new_album_flag == 1 ) {
25
+ return false;
26
+ }
27
+ var new_album_name = jQuery('#bp_media_album_new').val();
28
+ if(new_album_name.length==0){
29
+ alert('You have not filled the album name');
30
+ return false;
31
+ } else {
32
+ new_album_flag = 1;
33
+ jQuery(this).val('Wait');
34
+ var data = {
35
+ action: 'bp_media_add_album',
36
+ bp_media_album_name : new_album_name,
37
+ bp_media_group_id : bp_media_uploader_params.multipart_params.bp_media_group_id
38
+ };
39
+ jQuery.post(bp_media_vars.ajaxurl,data,function(response){
40
+ var album = parseInt(response);
41
+ if(album == 0){
42
+ alert('Sorry you cannot create albums in this group');
43
+ }
44
+ else {
45
+ jQuery('#bp-media-album-prompt select option').removeAttr('selected');
46
+ jQuery('#bp-media-selected-album').prepend('<option value='+album+' selected="selected">'+new_album_name+'</option>');
47
+ jQuery('#bp-media-album-prompt div.hide').hide();
48
+ jQuery('#bp-media-album-prompt select').show();
49
+ if ( in_list == 0 )
50
+ jQuery('#bp-media-album-prompt p').show();
51
+ }
52
+ });
53
+ }
54
+ });
55
+ jQuery('#btn-create-cancel').click(function(){
56
+ jQuery('#bp-media-album-prompt div.hide').hide();
57
+ jQuery('#bp-media-album-prompt select option').removeAttr('selected');
58
+ jQuery('#bp-media-album-prompt select option[value=' + selected + ']').attr('selected', 'selected');
59
+ jQuery('#bp-media-album-prompt select').show();
60
+ if ( in_list == 0 )
61
+ jQuery('#bp-media-album-prompt p').show();
62
+ });
63
+
64
+ //Normal Uplaoder
65
+ var bp_media_is_multiple_upload = false;
66
+ var bp_media_uploader=new plupload.Uploader(bp_media_uploader_params);
67
+ var bp_media_album_selected = false;
68
+ bp_media_uploader.init();
69
70
+ bp_media_uploader.bind('FilesAdded', function(up, files) {
71
+ if ( jQuery('#bp-media-selected-album').val() == 'create_new' ) {
72
+ alert("Please Select an Album !!");
73
+ return false;
74
+ }
75
+ //bp_media_is_multiple_upload = files.length==1&&jQuery('.bp-media-progressbar').length==0?false:true;
76
+ bp_media_is_multiple_upload = files.length>1;
77
+ jQuery.each(files, function(i, file) {
78
+ var extension = file.name.substr( (file.name.lastIndexOf('.') +1) );
79
+ jQuery('#bp-media-uploaded-files').append('<div id="bp-media-progress-'+file.id+'" class="bp-media-progressbar"><div class="bp-media-progress-text">' + file.name + ' (' + plupload.formatSize(file.size) + ')(<b>0%</b>)</div><div class="bp-media-progress-completed"></div></div>');
80
});
81
+ bp_media_album_selected = jQuery('#bp-media-selected-album').val();
82
+ bp_media_uploader.start();
83
+ up.refresh(); // Reposition Flash/Silverlight
84
+ });
85
+ bp_media_uploader.bind('UploadProgress', function(up, file) {
86
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-completed').width(file.percent+'%');
87
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html(file.percent+'%');
88
+ });
89
90
+ bp_media_uploader.bind('Error', function(up, err) {
91
+ jQuery('#bp-media-uploaded-files').html('<div class="error"><p>Error: ' + err.code +
92
+ ', Message: ' + err.message +
93
+ (err.file ? ', File: ' + err.file.name : '') +
94
+ '</p></div>'
95
+ );
96
+ up.refresh();
97
+ });
98
99
+ bp_media_uploader.bind('FileUploaded', function(up, file) {
100
+ jQuery('#bp-media-progress-'+file.id+' .bp-media-progress-text b').html("100%");
101
+ });
102
+ bp_media_uploader.bind('BeforeUpload',function(up){
103
+ up.settings.multipart_params.is_multiple_upload = bp_media_is_multiple_upload;
104
+ up.settings.multipart_params.bp_media_album_id = bp_media_album_selected;
105
+ });
106
+ bp_media_uploader.bind('UploadComplete',function(){
107
+ var new_location = window.location.href;
108
+ if(new_location.search('/upload/')>0){
109
+ new_location = new_location.replace('/upload/','/albums/');
110
+ if(bp_media_album_selected>0)
111
+ new_location = new_location.concat(bp_media_album_selected);
112
+ else
113
+ new_location = new_location.concat('0/');
114
+ window.location.replace(new_location);
115
+ } else
116
+ location.reload(true);
117
+ });
118
+
119
+
120
});
app/helper/BPMediaSettings.php CHANGED
@@ -25,7 +25,21 @@ if (!class_exists('BPMediaSettings')) {
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');
29
add_settings_field('bpm-video', __('Video', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
30
'setting' => 'bp_media_options',
31
'option' => 'videos_enabled',
@@ -41,34 +55,25 @@ if (!class_exists('BPMediaSettings')) {
41
'option' => 'images_enabled',
42
'desc' => __('Check to enable images upload functionality', BP_MEDIA_TXT_DOMAIN)
43
));
44
- add_settings_field('bpm-download', __('Download', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
45
'setting' => 'bp_media_options',
46
'option' => 'download_enabled',
47
'desc' => __('Check to enable download functionality', BP_MEDIA_TXT_DOMAIN)
48
));
49
- add_settings_field('bpm-admin-bar-menu', __('Admin bar menu', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
50
'setting' => 'bp_media_options',
51
'option' => 'show_admin_menu',
52
'desc' => __('Check to enable menu in WordPress admin bar', BP_MEDIA_TXT_DOMAIN)
53
- )
54
- );
55
- add_settings_section('bpm-spread-the-word', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
56
- add_settings_field('bpm-spread-the-word-settings', __('Spread the Word', BP_MEDIA_TXT_DOMAIN), array($this, 'radio'), 'bp-media-settings', 'bpm-spread-the-word', array(
57
- 'setting' => 'bp_media_options',
58
- 'option' => 'remove_linkback',
59
- 'radios' => array(
60
- 2 => __('Yes, I support BuddyPress Media', BP_MEDIA_TXT_DOMAIN),
61
- 1 => __('No, I don\'t want to support BuddyPress Media', BP_MEDIA_TXT_DOMAIN)),
62
- 'default' => 2)
63
);
64
- add_settings_section('bpm-other', __('BuddyPress Media Other Options', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
65
- add_settings_field('bpm-other-settings', __('Re-Count Media Entries', BP_MEDIA_TXT_DOMAIN), array($this, 'button'), 'bp-media-settings', 'bpm-other', array(
66
'option' => 'refresh-count',
67
'name' => __('Re-Count', BP_MEDIA_TXT_DOMAIN),
68
'desc' => __('It will re-count all media entries of all users and correct any discrepancies.', BP_MEDIA_TXT_DOMAIN)
69
));
70
71
-
72
$bp_media_addon = new BPMediaAddon();
73
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');
74
add_settings_section('bpm-support', __('Submit a request form', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-support');
@@ -82,13 +87,29 @@ if (!class_exists('BPMediaSettings')) {
82
}
83
84
public function network_notices() {
85
if (get_site_option('bpm-recount-success', false)) {
86
echo '<div id="setting-error-bpm-recount-success" class="updated"><p><strong>' . get_site_option('bpm-recount-success') . '</strong></p></div>';
87
delete_site_option('bpm-recount-success');
88
} elseif (get_site_option('bpm-recount-fail', false)) {
89
echo '<div id="setting-error-bpm-recount-fail" class="error"><p><strong>' . get_site_option('bpm-recount-fail') . '</strong></p></div>';
90
delete_site_option('bpm-recount-fail');
91
- } elseif (get_site_option('bpm-settings-saved')) {
92
echo '<div id="setting-error-bpm-settings-saved" class="updated"><p><strong>' . get_site_option('bpm-settings-saved') . '</strong></p></div>';
93
}
94
delete_site_option('bpm-settings-saved');
@@ -119,6 +140,20 @@ if (!class_exists('BPMediaSettings')) {
119
add_settings_error(__('Recount Fail', BP_MEDIA_TXT_DOMAIN), 'bpm-recount-fail', __('Recounting Failed', BP_MEDIA_TXT_DOMAIN));
120
}
121
}
122
if (is_multisite())
123
update_site_option('bpm-settings-saved', __('Settings saved.', BP_MEDIA_FFMPEG_TXT_DOMAIN));
124
do_action('bp_media_sanitize_settings', $_POST, $input);
@@ -164,7 +199,7 @@ if (!class_exists('BPMediaSettings')) {
164
?>
165
<label for="<?php echo $option; ?>">
166
<input<?php checked($options[$option]); ?> name="<?php echo $name; ?>" id="<?php echo $option; ?>" value="1" type="checkbox" />
167
- <?php echo $desc; ?>
168
</label><?php
169
}
170
@@ -211,7 +246,7 @@ if (!class_exists('BPMediaSettings')) {
211
}
212
213
foreach ($radios as $value => $desc) {
214
- ?>
215
<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
216
}
217
}
@@ -254,12 +289,12 @@ if (!class_exists('BPMediaSettings')) {
254
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
255
$options[$option] = '';
256
}
257
- ?>
258
<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
259
if (!empty($desc)) {
260
echo '<br /><span class="description">' . $desc . '</span>';
261
}
262
- ?></label><br /><?php
263
}
264
265
/**
@@ -300,14 +335,14 @@ if (!class_exists('BPMediaSettings')) {
300
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
301
$options[$option] = '';
302
}
303
- ?>
304
<select name="<?php echo $name; ?>" id="<?php echo $option; ?>"><?php if ($none) { ?>
305
<option><?php __e('None', BP_MEDIA_TXT_DOMAIN); ?></option><?php
306
}
307
foreach ($values as $value => $text) {
308
- ?>
309
<option<?php selected($options[$option], $value); ?> value="<?php echo $value; ?>"><?php echo $text; ?></option><?php }
310
- ?>
311
</select><?php
312
}
313
@@ -342,7 +377,7 @@ if (!class_exists('BPMediaSettings')) {
342
$button = $option;
343
submit_button($name, '', $button, false);
344
if (!empty($desc)) {
345
- ?>
346
<span class="description"><?php echo $desc; ?></a><?php
347
}
348
}
@@ -350,4 +385,4 @@ if (!class_exists('BPMediaSettings')) {
350
}
351
352
}
353
- ?>
25
*/
26
public function settings() {
27
global $bp_media_addon;
28
+ add_settings_section('bpm-media-type', __('Enable BuddyPress Media on', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
29
+ // add_settings_field('bpm-admin-profile', __('User profiles', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-media-type', array(
30
+ // 'setting' => 'bp_media_options',
31
+ // 'option' => 'enable_on_profile',
32
+ // 'desc' => __('Check to enable BuddyPress Media on User profiles', BP_MEDIA_TXT_DOMAIN)
33
+ // )
34
+ // );
35
+ add_settings_field('bpm-admin-group', __('Groups', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-media-type', array(
36
+ 'setting' => 'bp_media_options',
37
+ 'option' => 'enable_on_group',
38
+ 'desc' => __('Check to enable BuddyPress Media in Groups', BP_MEDIA_TXT_DOMAIN)
39
+ )
40
+ );
41
+
42
+ add_settings_section('bpm-settings', __('Enable Media Types on', BP_MEDIA_TXT_DOMAIN), is_multisite() ? array($this, 'network_notices') : '', 'bp-media-settings');
43
add_settings_field('bpm-video', __('Video', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-settings', array(
44
'setting' => 'bp_media_options',
45
'option' => 'videos_enabled',
55
'option' => 'images_enabled',
56
'desc' => __('Check to enable images upload functionality', BP_MEDIA_TXT_DOMAIN)
57
));
58
+
59
+ add_settings_section('bpm-miscellaneous', __('Miscellaneous Settings', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
60
+ add_settings_field('bpm-download', __('Download', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-miscellaneous', array(
61
'setting' => 'bp_media_options',
62
'option' => 'download_enabled',
63
'desc' => __('Check to enable download functionality', BP_MEDIA_TXT_DOMAIN)
64
));
65
+ add_settings_field('bpm-admin-bar-menu', __('Admin bar menu', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-miscellaneous', array(
66
'setting' => 'bp_media_options',
67
'option' => 'show_admin_menu',
68
'desc' => __('Check to enable menu in WordPress admin bar', BP_MEDIA_TXT_DOMAIN)
69
+ )
70
);
71
+ add_settings_field('bpm-other-settings', __('Re-Count Media Entries', BP_MEDIA_TXT_DOMAIN), array($this, 'button'), 'bp-media-settings', 'bpm-miscellaneous', array(
72
'option' => 'refresh-count',
73
'name' => __('Re-Count', BP_MEDIA_TXT_DOMAIN),
74
'desc' => __('It will re-count all media entries of all users and correct any discrepancies.', BP_MEDIA_TXT_DOMAIN)
75
));
76
77
$bp_media_addon = new BPMediaAddon();
78
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');
79
add_settings_section('bpm-support', __('Submit a request form', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-support');
87
}
88
89
public function network_notices() {
90
+ $flag = 1;
91
+ if (get_site_option('bpm-media-enable', false)) {
92
+ echo '<div id="setting-error-bpm-media-enable" class="error"><p><strong>' . get_site_option('bpm-media-enable') . '</strong></p></div>';
93
+ delete_site_option('bpm-media-enable');
94
+ $flag = 0;
95
+ }
96
+ if (get_site_option('bpm-media-type', false)) {
97
+ echo '<div id="setting-error-bpm-media-type" class="error"><p><strong>' . get_site_option('bpm-media-type') . '</strong></p></div>';
98
+ delete_site_option('bpm-media-type');
99
+ $flag = 0;
100
+ }
101
+
102
if (get_site_option('bpm-recount-success', false)) {
103
echo '<div id="setting-error-bpm-recount-success" class="updated"><p><strong>' . get_site_option('bpm-recount-success') . '</strong></p></div>';
104
delete_site_option('bpm-recount-success');
105
+ $flag = 0;
106
} elseif (get_site_option('bpm-recount-fail', false)) {
107
echo '<div id="setting-error-bpm-recount-fail" class="error"><p><strong>' . get_site_option('bpm-recount-fail') . '</strong></p></div>';
108
delete_site_option('bpm-recount-fail');
109
+ $flag = 0;
110
+ }
111
+
112
+ if (get_site_option('bpm-settings-saved') && $flag) {
113
echo '<div id="setting-error-bpm-settings-saved" class="updated"><p><strong>' . get_site_option('bpm-settings-saved') . '</strong></p></div>';
114
}
115
delete_site_option('bpm-settings-saved');
140
add_settings_error(__('Recount Fail', BP_MEDIA_TXT_DOMAIN), 'bpm-recount-fail', __('Recounting Failed', BP_MEDIA_TXT_DOMAIN));
141
}
142
}
143
+ if (!isset($_POST['bp_media_options']['enable_on_profile']) && !isset($_POST['bp_media_options']['enable_on_group'])) {
144
+ if (is_multisite())
145
+ update_site_option('bpm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', BP_MEDIA_TXT_DOMAIN));
146
+ else
147
+ add_settings_error(__('Enable BuddyPress Media', BP_MEDIA_TXT_DOMAIN), 'bpm-media-enable', __('Enable BuddyPress Media on either User Profiles or Groups or both. Atleast one should be selected.', BP_MEDIA_TXT_DOMAIN));
148
+ $input['enable_on_profile'] = 1;
149
+ }
150
+ if (!isset($_POST['bp_media_options']['videos_enabled']) && !isset($_POST['bp_media_options']['audio_enabled']) && !isset($_POST['bp_media_options']['images_enabled'])) {
151
+ if (is_multisite())
152
+ update_site_option('bpm-media-type', __('Atleast one Media Type Must be selected', BP_MEDIA_TXT_DOMAIN));
153
+ else
154
+ add_settings_error(__('Media Type', BP_MEDIA_TXT_DOMAIN), 'bpm-media-type', __('Atleast one Media Type Must be selected', BP_MEDIA_TXT_DOMAIN));
155
+ $input['images_enabled'] = 1;
156
+ }
157
if (is_multisite())
158
update_site_option('bpm-settings-saved', __('Settings saved.', BP_MEDIA_FFMPEG_TXT_DOMAIN));
159
do_action('bp_media_sanitize_settings', $_POST, $input);
199
?>
200
<label for="<?php echo $option; ?>">
201
<input<?php checked($options[$option]); ?> name="<?php echo $name; ?>" id="<?php echo $option; ?>" value="1" type="checkbox" />
202
+ <?php echo $desc; ?>
203
</label><?php
204
}
205
246
}
247
248
foreach ($radios as $value => $desc) {
249
+ ?>
250
<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
251
}
252
}
289
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
290
$options[$option] = '';
291
}
292
+ ?>
293
<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
294
if (!empty($desc)) {
295
echo '<br /><span class="description">' . $desc . '</span>';
296
}
297
+ ?></label><br /><?php
298
}
299
300
/**
335
if ((isset($options[$option]) && empty($options[$option])) || !isset($options[$option])) {
336
$options[$option] = '';
337
}
338
+ ?>
339
<select name="<?php echo $name; ?>" id="<?php echo $option; ?>"><?php if ($none) { ?>
340
<option><?php __e('None', BP_MEDIA_TXT_DOMAIN); ?></option><?php
341
}
342
foreach ($values as $value => $text) {
343
+ ?>
344
<option<?php selected($options[$option], $value); ?> value="<?php echo $value; ?>"><?php echo $text; ?></option><?php }
345
+ ?>
346
</select><?php
347
}
348
377
$button = $option;
378
submit_button($name, '', $button, false);
379
if (!empty($desc)) {
380
+ ?>
381
<span class="description"><?php echo $desc; ?></a><?php
382
}
383
}
385
}
386
387
}
388
+ ?>
app/{main/importers → importers}/BPMediaBPActivityPlusImporter.php RENAMED
File without changes
app/importers/BPMediaBPAlbumImporter.php ADDED
@@ -0,0 +1,87 @@
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of BPMediaBPAlbumImporter
10
+ *
11
+ * @author saurabh
12
+ */
13
+ class BPMediaBPAlbumImporter extends BPMediaImporter {
14
+
15
+
16
+ function __construct() {
17
+ parent::__construct();
18
+ $this->active = $this->_active( 'bp-album/loader.php' );
19
+
20
+ if($this->active!=-1){
21
+ $this->update_table();
22
+ $this->set_total_count();
23
+ }
24
+ }
25
+
26
+ function update_table() {
27
+ global $wpdb;
28
+ $wpdb->query(
29
+ "ALTER TABLE {$wpdb->base_prefix}bp_album ADD COLUMN
30
+ import_status TINYINT (1) NOT NULL DEFAULT 0"
31
+ );
32
+ }
33
+
34
+ function create_album($album_name = 'BP Album'){
35
+ parent::create_album($album_name);
36
+ }
37
+
38
+ function get_total_count() {
39
+ global $wpdb;
40
+ $table = $wpdb->base_prefix . 'bp_album';
41
+ if ( $this->table_exists( $table ) && $this->active != -1 ) {
42
+ return $wpdb->query( "SELECT * FROM {$table}" );
43
+ }
44
+ }
45
+
46
+ function set_total_count(){
47
+ $total_count = $this->get_total_count();
48
+ update_site_option('bp_album_import_total_count',$total_count);
49
+ $this->import_steps = ceil( floatval( $total_count ) / 10 );
50
+ update_site_option('bp_album_import_total_count',$total_count);
51
+
52
+ }
53
+
54
+ static function batch_import($offset=0){
55
+ global $wpdb;
56
+ $table = $wpdb->base_prefix . 'bp_album';
57
+ $bp_album_data = $wpdb->get_results(
58
+ "SELECT * FROM {$table} WHERE import_status='0'
59
+ LIMIT 10 OFFSET {$offset}"
60
+ );
61
+
62
+ return $bp_album_data;
63
+
64
+ }
65
+
66
+ static function bpmedia_ajax_import_callback(){
67
+
68
+ $offset = 0;//$_GET['offset'];
69
+
70
+ $bp_album_data = BPMediaBPAlbumImporter::batch_import($offset);
71
+
72
+ foreach ($bp_album_data as &$bp_album_item){
73
+ $album_id=BPMediaBPAlbumImporter::create_album('',$bp_album_item->owner_id);
74
+ BPMediaImporter::add_media(
75
+ $album_id,
76
+ $bp_album_item->title,
77
+ $bp_album_item->description,
78
+ $bp_album_item->pic_org_path,
79
+ $bp_album_item->privacy,
80
+ $bp_album_item->owner_id
81
+ );
82
+ }
83
+ }
84
+
85
+ }
86
+
87
+ ?>
app/importers/BPMediaImporter.php ADDED
@@ -0,0 +1,116 @@
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of BPMediaImporter
10
+ *
11
+ * @author saurabh
12
+ */
13
+ class BPMediaImporter {
14
+
15
+ /**
16
+ *
17
+ */
18
+
19
+ var $active;
20
+ var $import_steps;
21
+
22
+ function __construct() {
23
+
24
+ }
25
+
26
+ function table_exists($table){
27
+ global $wpdb;
28
+
29
+ if($wpdb->query("SHOW TABLES LIKE '".$table."'")==1){
30
+ return true;
31
+ }
32
+
33
+ return false;
34
+ }
35
+
36
+ static function _active($path) {
37
+ if ( ! function_exists( 'is_plugin_inactive' ) ) {
38
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
39
+ }
40
+ global $wpdb;
41
+ $plugin_name = $path;
42
+ $is_active = is_plugin_active( $plugin_name );
43
+ if ( $is_active == true )
44
+ return 1;
45
+ $is_inactive = is_plugin_inactive( $plugin_name );
46
+ if ( $is_inactive == true )
47
+ return 0;
48
+ if ( ! $is_active && ! $is_inactive )
49
+ return -1;
50
+ }
51
+
52
+ static function file_array($filepath){
53
+
54
+ $path_info = pathinfo($filepath);
55
+
56
+ $file['error'] = '';
57
+ $file['name'] = $path_info['basename'];
58
+ $file['type'] = mime_content_type($filepath);
59
+ $file['tmp_name'] = $filepath;
60
+ $file['size'] = filesize( $filepath);
61
+
62
+ return $file;
63
+
64
+ }
65
+
66
+ function create_album($album_name = '',$author_id=1){
67
+
68
+ global $bp_media;
69
+
70
+ if(array_key_exists('bp_album_import_name',$bp_media->options)){
71
+ if($bp_media->options['bp_album_import_name']!=''){
72
+ $album_name = $bp_media->options['bp_album_import_name'];
73
+ }
74
+ }
75
+ $found_album = BuddyPressMedia::get_wall_album();
76
+
77
+ if(count($found_album)< 1){
78
+ $album = new BPMediaAlbum();
79
+ $album->add_album($album_name,$author_id);
80
+ $album_id = $album->get_id();
81
+ }else{
82
+ $album_id = $found_album[0]->ID;
83
+ }
84
+ return $album_id;
85
+ }
86
+
87
+ static function add_media($album_id, $title='',$description='',$filepath='',$privacy=0,$author_id=false){
88
+
89
+
90
+ $files = BPMediaImporter::file_array($filepath);
91
+
92
+
93
+ $bp_imported_media =new BPMediaHostWordpress();
94
+
95
+ $imported_media_id = $bp_imported_media->add_media($title, $description, $album_id, 0, false, false, $files);
96
+
97
+ wp_update_post($args=array('ID'=>$imported_media_id,'post_author'=> $author_id));
98
+
99
+ $bp_album_privacy = $privacy;
100
+ if($bp_album_privacy == 10)
101
+ $bp_album_privacy = 6;
102
+
103
+ $privacy = new BPMediaPrivacy();
104
+ $privacy->save($bp_album_privacy,$imported_media_id);
105
+ }
106
+
107
+
108
+ function cleanup(){
109
+ return;
110
+
111
+ }
112
+
113
+
114
+ }
115
+
116
+ ?>
app/main/BPMediaComponent.php ADDED
@@ -0,0 +1,538 @@
1
+ <?php
2
+ /**
3
+ * Don't load this file directly!
4
+ */
5
+ if ( ! defined( 'ABSPATH' ) )
6
+ exit;
7
+
8
+ /**
9
+ * Add BuddyPress Media as a component of BuddyPress
10
+ *
11
+ * @author Saurabh Shukla <saurabh.shukla@rtcamp.com>
12
+ * @author Gagandeep Singh <gagandeep.singh@rtcamp.com>
13
+ */
14
+ class BPMediaComponent extends BP_Component {
15
+
16
+ /**
17
+ * Hold the messages that are generated during initialization process
18
+ * and will be shown on the screen functions
19
+ *
20
+ * @var array
21
+ */
22
+ var $messages = array(
23
+ 'error' => array(),
24
+ 'info' => array(),
25
+ 'updated' => array()
26
+ );
27
+
28
+ /**
29
+ * Initialise the component with appropriate parameters.
30
+ * Add hook for plugins, themes, extensions to hook on to
31
+ * Activates the component
32
+ * Registers necessary post types
33
+ *
34
+ * @global object $bp The global BuddyPress object
35
+ */
36
+ function __construct() {
37
+ global $bp;
38
+ parent::start(BP_MEDIA_SLUG, BP_MEDIA_LABEL, BP_MEDIA_PATH);
39
+ do_action('bp_media_init');
40
+ $bp->active_components[$this->id] = '1';
41
+ add_action('init', array(&$this, 'register_post_types'), 10);
42
+ }
43
+
44
+ /**
45
+ * Initialise the global variables of the BuddyPress Media
46
+ * and its parent class.
47
+ * Add necessary slugs and search functionality
48
+ *
49
+ * @global object $bp The global BuddyPress object
50
+ */
51
+ function setup_globals() {
52
+ global $bp;
53
+ $globals = array(
54
+ 'slug' => BP_MEDIA_SLUG,
55
+ 'root_slug' => isset(
56
+ $bp->pages->{$this->id}->slug) ?
57
+ $bp->pages->{$this->id}->slug
58
+ : BP_MEDIA_SLUG,
59
+ // 'has_directory' => true, // Set to false if not required
60
+ 'search_string' => __('Search Media...', BP_MEDIA_TXT_DOMAIN),
61
+ );
62
+ parent::setup_globals($globals);
63
+ }
64
+
65
+ /**
66
+ * Sets up BuddyPress Media navigation and tabs on profile
67
+ *
68
+ * @global object $bp The global BuddyPress object
69
+ */
70
+ function setup_nav() {
71
+ global $bp, $bp_media;
72
+
73
+ $enabled = $bp_media->enabled();
74
+ $default_tab = $bp_media->default_tab();
75
+ $defaults_tab = $bp_media->defaults_tab();
76
+
77
+ /* Upload Screen */
78
+
79
+
80
+ /* Media Screens */
81
+ foreach ($enabled as $tab=>$active){
82
+ if($active==true){
83
+ $tabs = $tab;
84
+ if($tabs!='audio'&&$tabs!='upload'){
85
+ $tabs .= 's';
86
+ }
87
+ if($tab=='upload'){
88
+ ${'bp_media_'.$tab} = new BPMediaUploadScreen(
89
+ $tab,
90
+ constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG')
91
+ );
92
+ }elseif($tab=='album'){
93
+ $bp_media_album = new BPMediaAlbumScreen(
94
+ $tab,
95
+ constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG')
96
+ );
97
+ }else{
98
+ ${'bp_media_'.$tab} = new BPMediaScreen(
99
+ $tab,
100
+ constant('BP_MEDIA_'.strtoupper($tabs).'_SLUG')
101
+ );
102
+ }
103
+ }
104
+ }
105
+
106
+ /* Switch between different screens depending on context */
107
+ switch ($bp->current_component) {
108
+ case BP_MEDIA_IMAGES_SLUG:
109
+ if ( $enabled['image'] && is_numeric($bp->current_action)) {
110
+ $bp->action_variables[0] = $bp->current_action;
111
+ $bp->current_action = BP_MEDIA_IMAGES_ENTRY_SLUG;
112
+ }
113
+ break;
114
+ case BP_MEDIA_AUDIO_SLUG:
115
+ if ($enabled['audio'] && is_numeric($bp->current_action)) {
116
+ $bp->action_variables[0] = $bp->current_action;
117
+ $bp->current_action = BP_MEDIA_AUDIO_ENTRY_SLUG;
118
+ }
119
+ break;
120
+ case BP_MEDIA_VIDEOS_SLUG:
121
+ if ($enabled['video'] && is_numeric($bp->current_action)) {
122
+ $bp->action_variables[0] = $bp->current_action;
123
+ $bp->current_action = BP_MEDIA_VIDEOS_ENTRY_SLUG;
124
+ }
125
+ break;
126
+ case BP_MEDIA_ALBUMS_SLUG:
127
+ if (is_numeric($bp->current_action)) {
128
+ $bp->action_variables[0] = $bp->current_action;
129
+ $bp->current_action = BP_MEDIA_ALBUMS_ENTRY_SLUG;
130
+ }
131
+ break;
132
+ }
133
+
134
+ /* Create the main navigation on profile */
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_'.$default_tab}, 'screen'),
140
+ 'default_subnav_slug' => constant('BP_MEDIA_'.strtoupper($defaults_tab).'_SLUG')
141
+ );
142
+
143
+ /* Create an empty sub navigation */
144
+ $sub_nav[] = array();
145
+
146
+ /* Set up navigation */
147
+ parent::setup_nav($main_nav, $sub_nav);
148
+
149
+ /* Set up individual screens for each nav/sub nav */
150
+ if($enabled['image']){
151
+ bp_core_new_nav_item(array(
152
+ 'name' => __(BP_MEDIA_IMAGES_LABEL, BP_MEDIA_TXT_DOMAIN),
153
+ 'slug' => BP_MEDIA_IMAGES_SLUG,
154
+ 'screen_function' => array($bp_media_image, 'screen'),
155
+ ));
156
+
157
+
158
+
159
+ bp_core_new_subnav_item(array(
160
+ 'name' => 'View',
161
+ /* Display name for the nav item(It won't be shown anywhere) */
162
+ 'slug' => BP_MEDIA_IMAGES_ENTRY_SLUG,
163
+ /* URL slug for the nav item */
164
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG,
165
+ /* URL slug of the parent nav item */
166
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
167
+ . BP_MEDIA_IMAGES_SLUG),
168
+ /* URL of the parent item */
169
+ 'position' => 90,
170
+ /* Index of where this nav item should be positioned */
171
+ 'screen_function' => array($bp_media_image, 'screen'),
172
+ /* The name of the function to run when clicked */
173
+ ));
174
+
175
+ bp_core_new_subnav_item(array(
176
+ 'name' => 'Edit',
177
+ /* Display name for the nav item(It won't be shown anywhere) */
178
+ 'slug' => BP_MEDIA_IMAGES_EDIT_SLUG,
179
+ /* URL slug for the nav item */
180
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG,
181
+ /* URL slug of the parent nav item */
182
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
183
+ . BP_MEDIA_IMAGES_SLUG),
184
+ /* URL of the parent item */
185
+ 'position' => 90,
186
+ /* Index of where this nav item should be positioned */
187
+ 'screen_function' => array($bp_media_image, 'edit_screen'),
188
+ /* The name of the function to run when clicked */
189
+ ));
190
+
191
+ bp_core_new_subnav_item(array(
192
+ 'name' => 'Delete',
193
+ /* Display name for the nav item(It won't be shown anywhere) */
194
+ 'slug' => BP_MEDIA_DELETE_SLUG,
195
+ /* URL slug for the nav item */
196
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG,
197
+ /* URL slug of the parent nav item */
198
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
199
+ . BP_MEDIA_IMAGES_SLUG),
200
+ /* URL of the parent item */
201
+ 'position' => 90,
202
+ /* Index of where this nav item should be positioned */
203
+ 'screen_function' => array($bp_media_image, 'screen'),
204
+ /* The name of the function to run when clicked */
205
+ ));
206
+
207
+ bp_core_new_subnav_item(array(
208
+ 'name' => 'Page',
209
+ /* Display name for the nav item(It won't be shown anywhere) */
210
+ 'slug' => 'page',
211
+ /* URL slug for the nav item */
212
+ 'parent_slug' => BP_MEDIA_IMAGES_SLUG,
213
+ /* URL slug of the parent nav item */
214
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
215
+ . BP_MEDIA_IMAGES_SLUG),
216
+ /* URL of the parent item */
217
+ 'position' => 90,
218
+ /* Index of where this nav item should be positioned */
219
+ 'screen_function' => array($bp_media_image, 'screen'),
220
+ /* The name of the function to run when clicked */
221
+ ));
222
+ }
223
+
224
+ if($enabled['video']){
225
+ bp_core_new_nav_item(array(
226
+ 'name' => __(BP_MEDIA_VIDEOS_LABEL, BP_MEDIA_TXT_DOMAIN),
227
+ 'slug' => BP_MEDIA_VIDEOS_SLUG,
228
+ 'screen_function' => array($bp_media_video, 'screen')
229
+ ));
230
+
231
+ bp_core_new_subnav_item(array(
232
+ 'name' => 'Watch',
233
+ /* Display name for the nav item(It won't be shown anywhere) */
234
+ 'slug' => BP_MEDIA_VIDEOS_ENTRY_SLUG,
235
+ /* URL slug for the nav item */
236
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG,
237
+ /* URL slug of the parent nav item */
238
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
239
+ . BP_MEDIA_VIDEOS_SLUG),
240
+ /* URL of the parent item */
241
+ 'position' => 90,
242
+ /* Index of where this nav item should be positioned */
243
+ 'screen_function' => array($bp_media_video, 'screen'),
244
+ /* The name of the function to run when clicked */
245
+ ));
246
+
247
+ bp_core_new_subnav_item(array(
248
+ 'name' => 'Edit',
249
+ /* Display name for the nav item(It won't be shown anywhere) */
250
+ 'slug' => BP_MEDIA_VIDEOS_EDIT_SLUG,
251
+ /* URL slug for the nav item */
252
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG,
253
+ /* URL slug of the parent nav item */
254
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
255
+ . BP_MEDIA_VIDEOS_SLUG),
256
+ /* URL of the parent item */
257
+ 'position' => 90,
258
+ /* Index of where this nav item should be positioned */
259
+ 'screen_function' => array($bp_media_video, 'edit_screen'),
260
+ /* The name of the function to run when clicked */
261
+ ));
262
+
263
+ bp_core_new_subnav_item(array(
264
+ 'name' => 'Delete',
265
+ /* Display name for the nav item(It won't be shown anywhere) */
266
+ 'slug' => BP_MEDIA_DELETE_SLUG,
267
+ /* URL slug for the nav item */
268
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG,
269
+ /* URL slug of the parent nav item */
270
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
271
+ . BP_MEDIA_VIDEOS_SLUG),
272
+ /* URL of the parent item */
273
+ 'position' => 90,
274
+ /* Index of where this nav item should be positioned */
275
+ 'screen_function' => array($bp_media_video, 'screen'),
276
+ /* The name of the function to run when clicked */
277
+ ));
278
+
279
+ bp_core_new_subnav_item(array(
280
+ 'name' => 'Page',
281
+ /* Display name for the nav item(It won't be shown anywhere) */
282
+ 'slug' => 'page',
283
+ /* URL slug for the nav item */
284
+ 'parent_slug' => BP_MEDIA_VIDEOS_SLUG,
285
+ /* URL slug of the parent nav item */
286
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
287
+ . BP_MEDIA_VIDEOS_SLUG),
288
+ /* URL of the parent item */
289
+ 'position' => 90,
290
+ /* Index of where this nav item should be positioned */
291
+ 'screen_function' => array($bp_media_video, 'screen'),
292
+ /* The name of the function to run when clicked */
293
+ ));
294
+ }
295
+
296
+ if($enabled['audio']){
297
+ bp_core_new_nav_item(array(
298
+ 'name' => __(BP_MEDIA_AUDIO_LABEL, BP_MEDIA_TXT_DOMAIN),
299
+ 'slug' => BP_MEDIA_AUDIO_SLUG,
300
+ 'screen_function' => array($bp_media_audio, 'screen')
301
+ ));
302
+
303
+ bp_core_new_subnav_item(array(
304
+ 'name' => 'Listen',
305
+ /* Display name for the nav item(It won't be shown anywhere) */
306
+ 'slug' => BP_MEDIA_AUDIO_ENTRY_SLUG,
307
+ /* URL slug for the nav item */
308
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG,
309
+ /* URL slug of the parent nav item */
310
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
311
+ . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
312
+ 'position' => 90,
313
+ /* Index of where this nav item should be positioned */
314
+ 'screen_function' => array($bp_media_audio, 'screen'),
315
+ /* The name of the function to run when clicked */
316
+ ));
317
+
318
+ bp_core_new_subnav_item(array(
319
+ 'name' => 'Edit',
320
+ /* Display name for the nav item(It won't be shown anywhere) */
321
+ 'slug' => BP_MEDIA_AUDIO_EDIT_SLUG,
322
+ /* URL slug for the nav item */
323
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG,
324
+ /* URL slug of the parent nav item */
325
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
326
+ . BP_MEDIA_AUDIO_SLUG),
327
+ /* URL of the parent item */
328
+ 'position' => 90,
329
+ /* Index of where this nav item should be positioned */
330
+ 'screen_function' => array($bp_media_audio, 'edit_screen'),
331
+ /* The name of the function to run when clicked */
332
+ ));
333
+
334
+ bp_core_new_subnav_item(array(
335
+ 'name' => 'Delete',
336
+ /* Display name for the nav item(It won't be shown anywhere) */
337
+ 'slug' => BP_MEDIA_DELETE_SLUG,
338
+ /* URL slug for the nav item */
339
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG,
340
+ /* URL slug of the parent nav item */
341
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
342
+ . BP_MEDIA_AUDIO_SLUG),
343
+ /* URL of the parent item */
344
+ 'position' => 90,
345
+ /* Index of where this nav item should be positioned */
346
+ 'screen_function' => array($bp_media_audio, 'screen'),
347
+ /* The name of the function to run when clicked */
348
+ ));
349
+
350
+ bp_core_new_subnav_item(array(
351
+ 'name' => 'Page',
352
+ /* Display name for the nav item(It won't be shown anywhere) */
353
+ 'slug' => 'page',
354
+ /* URL slug for the nav item */
355
+ 'parent_slug' => BP_MEDIA_AUDIO_SLUG,
356
+ /* URL slug of the parent nav item */
357
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
358
+ . BP_MEDIA_AUDIO_SLUG), /* URL of the parent item */
359
+ 'position' => 90,
360
+ /* Index of where this nav item should be positioned */
361
+ 'screen_function' => array($bp_media_audio, 'screen'),
362
+ /* The name of the function to run when clicked */
363
+ ));
364
+ }
365
+
366
+ bp_core_new_nav_item(array(
367
+ 'name' => __(BP_MEDIA_ALBUMS_LABEL, BP_MEDIA_TXT_DOMAIN),
368
+ 'slug' => BP_MEDIA_ALBUMS_SLUG,
369
+ 'screen_function' => array($bp_media_album, 'screen'),
370
+ ));
371
+
372
+ bp_core_new_subnav_item(array(
373
+ 'name' => 'View',
374
+ /* Display name for the nav item(It won't be shown anywhere) */
375
+ 'slug' => BP_MEDIA_ALBUMS_ENTRY_SLUG,
376
+ /* URL slug for the nav item */
377
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG,
378
+ /* URL slug of the parent nav item */
379
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
380
+ . BP_MEDIA_ALBUMS_SLUG),
381
+ /* URL of the parent item */
382
+ 'position' => 90,
383
+ /* Index of where this nav item should be positioned */
384
+ 'screen_function' => array($bp_media_album, 'screen'),
385
+ /* The name of the function to run when clicked */
386
+ ));
387
+
388
+ bp_core_new_subnav_item(array(
389
+ 'name' => 'Edit',
390
+ /* Display name for the nav item(It won't be shown anywhere) */
391
+ 'slug' => BP_MEDIA_ALBUMS_EDIT_SLUG,
392
+ /* URL slug for the nav item */
393
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG,
394
+ /* URL slug of the parent nav item */
395
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
396
+ . BP_MEDIA_ALBUMS_SLUG),
397
+ /* URL of the parent item */
398
+ 'position' => 90,
399
+ /* Index of where this nav item should be positioned */
400
+ 'screen_function' => array($bp_media_album, 'edit_screen'),
401
+ /* The name of the function to run when clicked */
402
+ ));
403
+
404
+ bp_core_new_subnav_item(array(
405
+ 'name' => 'Delete',
406
+ /* Display name for the nav item(It won't be shown anywhere) */
407
+ 'slug' => BP_MEDIA_DELETE_SLUG,
408
+ /* URL slug for the nav item */
409
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG,
410
+ /* URL slug of the parent nav item */
411
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
412
+ . BP_MEDIA_ALBUMS_SLUG),
413
+ /* URL of the parent item */
414
+ 'position' => 90,
415
+ /* Index of where this nav item should be positioned */
416
+ 'screen_function' => array($bp_media_album, 'screen'),
417
+ /* The name of the function to run when clicked */
418
+ ));
419
+
420
+ bp_core_new_subnav_item(array(
421
+ 'name' => 'Page',
422
+ /* Display name for the nav item(It won't be shown anywhere) */
423
+ 'slug' => 'page',
424
+ /* URL slug for the nav item */
425
+ 'parent_slug' => BP_MEDIA_ALBUMS_SLUG,
426
+ /* URL slug of the parent nav item */
427
+ 'parent_url' => trailingslashit(bp_loggedin_user_domain()
428
+ . BP_MEDIA_ALBUMS_SLUG),
429
+ /* URL of the parent item */
430
+ 'position' => 90,
431
+ /* Index of where this nav item should be positioned */
432
+ 'screen_function' => array($bp_media_album, 'screen'),
433
+ /* The name of the function to run when clicked */
434
+ ));
435
+ bp_core_new_nav_item(array(
436
+ 'name' => __(BP_MEDIA_UPLOAD_LABEL, BP_MEDIA_TXT_DOMAIN),
437
+ 'slug' => BP_MEDIA_UPLOAD_SLUG,
438
+ 'screen_function' => array($bp_media_upload, 'upload_screen'),
439
+ 'user_has_access' => bp_is_my_profile()
440
+ ));
441
+ }
442
+
443
+ /**
444
+ * Register Custom Post Types required by BuddyPress Media
445
+ */
446
+ function register_post_types() {
447
+
448
+ /* Set up Album labels */
449
+ $album_labels = array(
450
+ 'name' => __('Albums',
451
+ BP_MEDIA_TXT_DOMAIN),
452
+ 'singular_name' => __('Album',
453
+ BP_MEDIA_TXT_DOMAIN),
454
+ 'add_new' => __('Create',
455
+ BP_MEDIA_TXT_DOMAIN),
456
+ 'add_new_item' => __('Create Album',
457
+ BP_MEDIA_TXT_DOMAIN),
458
+ 'edit_item' => __('Edit Album',
459
+ BP_MEDIA_TXT_DOMAIN),
460
+ 'new_item' => __('New Album',
461
+ BP_MEDIA_TXT_DOMAIN),
462
+ 'all_items' => __('All Albums',
463
+ BP_MEDIA_TXT_DOMAIN),
464
+ 'view_item' => __('View Album',
465
+ BP_MEDIA_TXT_DOMAIN),
466
+ 'search_items' => __('Search Albums',
467
+ BP_MEDIA_TXT_DOMAIN),
468
+ 'not_found' => __('No album found',
469
+ BP_MEDIA_TXT_DOMAIN),
470
+ 'not_found_in_trash' => __('No album found in Trash',
471
+ BP_MEDIA_TXT_DOMAIN),
472
+ 'parent_item_colon' => '',
473
+ 'menu_name' => __('Albums',
474
+ BP_MEDIA_TXT_DOMAIN)
475
+ );
476
+
477
+ /* Set up Album post type arguments */
478
+ $album_args = array(
479
+ 'labels' => $album_labels,
480
+ 'public' => true,
481
+ 'publicly_queryable' => true,
482
+ 'show_ui' => false,
483
+ 'show_in_menu' => false,
484
+ 'query_var' => true,
485
+ 'capability_type' => 'post',
486