rtMedia for WordPress, BuddyPress and bbPress - Version 2.13.1

Version Description

  • Fixes bug in navigation
  • Fixes bug in admin menu
  • Resolves delete album issue (when activity is enabled)
  • Adds option to disable encoding
  • Translations Updated
Download this release

Release Info

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

Code changes from version 2.12.1 to 2.13.1

Files changed (54) hide show
  1. Screenshot1.png +0 -0
  2. Screenshot2.png +0 -0
  3. Screenshot3.png +0 -0
  4. Screenshot4.png +0 -0
  5. Screenshot5.png +0 -0
  6. Screenshot6.png +0 -0
  7. Screenshot7.png +0 -0
  8. Screenshot8.png +0 -0
  9. Screenshot9.png +0 -0
  10. Screenshots10.png +0 -0
  11. Screenshots11.png +0 -0
  12. app/admin/BPMediaAdmin.php +252 -251
  13. app/assets/css/main.css +28 -5
  14. app/assets/img/bpm-contest-banner.jpg +0 -0
  15. app/assets/js/admin.js +119 -0
  16. app/helper/BPMediaAddon.php +6 -1
  17. app/helper/BPMediaSettings.php +3 -34
  18. app/helper/rtProgress.php +6 -2
  19. app/main/BPMediaLoader.php +2 -2
  20. app/main/includes/BPMediaActions.php +16 -0
  21. app/main/includes/BPMediaFilters.php +8 -1
  22. app/main/includes/BPMediaHostWordpress.php +0 -1
  23. app/main/profile/BPMediaAlbumScreen.php +1 -1
  24. app/main/profile/BPMediaScreen.php +1 -1
  25. app/services/BPMediaEncoding.php +534 -0
  26. app/services/BPMediaEncodingTranscoder.php +146 -0
  27. index.php +2 -1
  28. languages/buddypress-media-ar_AR.mo +0 -0
  29. languages/buddypress-media-de_DE.mo +0 -0
  30. languages/buddypress-media-es_ES.mo +0 -0
  31. languages/buddypress-media-fa_IR.mo +0 -0
  32. languages/buddypress-media-fr_FR.mo +0 -0
  33. languages/buddypress-media-it_IT.mo +0 -0
  34. languages/buddypress-media-ja_JA.mo +0 -0
  35. languages/buddypress-media-nl_NL.mo +0 -0
  36. languages/buddypress-media-pl_PL.mo +0 -0
  37. languages/buddypress-media-pt_BR.mo +0 -0
  38. languages/buddypress-media-ro_RO.mo +0 -0
  39. languages/buddypress-media-sr_SR.mo +0 -0
  40. languages/buddypress-media.mo +0 -0
  41. languages/buddypress-media.po +890 -745
  42. readme.txt +16 -5
  43. screenshot-1.png +0 -0
  44. screenshot-10.png +0 -0
  45. screenshot-11.png +0 -0
  46. screenshot-12.png +0 -0
  47. screenshot-2.png +0 -0
  48. screenshot-3.png +0 -0
  49. screenshot-4.png +0 -0
  50. screenshot-5.png +0 -0
  51. screenshot-6.png +0 -0
  52. screenshot-7.png +0 -0
  53. screenshot-8.png +0 -0
  54. screenshot-9.png +0 -0
Screenshot1.png DELETED
Binary file
Screenshot2.png DELETED
Binary file
Screenshot3.png DELETED
Binary file
Screenshot4.png DELETED
Binary file
Screenshot5.png DELETED
Binary file
Screenshot6.png DELETED
Binary file
Screenshot7.png DELETED
Binary file
Screenshot8.png DELETED
Binary file
Screenshot9.png DELETED
Binary file
Screenshots10.png DELETED
Binary file
Screenshots11.png DELETED
Binary file
app/admin/BPMediaAdmin.php CHANGED
@@ -14,6 +14,7 @@ if (!class_exists('BPMediaAdmin')) {
14
15
public $bp_media_upgrade;
16
public $bp_media_settings;
17
public $bp_media_support;
18
public $bp_media_feed;
19
@@ -41,13 +42,14 @@ if (!class_exists('BPMediaAdmin')) {
41
add_filter('plugin_row_meta', array($this, 'plugin_meta_premium_addon_link'), 1, 4);
42
if (is_admin()) {
43
add_action('admin_enqueue_scripts', array($this, 'ui'));
44
- add_action(bp_core_admin_hook(), array($this, 'menu'));
45
if (current_user_can('manage_options'))
46
add_action('bp_admin_tabs', array($this, 'tab'));
47
if (is_multisite())
48
add_action('network_admin_edit_bp_media', array($this, 'save_multisite_options'));
49
}
50
$this->bp_media_settings = new BPMediaSettings();
51
}
52
53
/**
@@ -62,11 +64,15 @@ if (!class_exists('BPMediaAdmin')) {
62
*/
63
public function ui($hook) {
64
$admin_ajax = admin_url('admin-ajax.php');
65
- wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js', '', BP_MEDIA_VERSION);
66
wp_localize_script('bp-media-admin', 'bp_media_admin_ajax', $admin_ajax);
67
$bp_media_admin_strings = array(
68
'no_refresh' => __('Please do not refresh this page.', 'buddypress-media'),
69
- 'something_went_wrong' => __('Something went wronng. Please <a href onclick="location.reload();">refresh</a> page.', 'buddypress-media')
70
);
71
wp_localize_script('bp-media-admin', 'bp_media_admin_strings', $bp_media_admin_strings);
72
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
@@ -76,6 +82,7 @@ if (!class_exists('BPMediaAdmin')) {
76
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
77
));
78
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION);
79
}
80
81
/**
@@ -87,16 +94,11 @@ if (!class_exists('BPMediaAdmin')) {
87
global $wpdb;
88
add_menu_page(__('BuddyPress Media Component', 'buddypress-media'), __('BuddyPress Media', 'buddypress-media'), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
89
add_submenu_page('bp-media-settings', __('BuddyPress Media Settings', 'buddypress-media'), __('Settings', 'buddypress-media'), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
90
- if (!BPMediaPrivacy::is_installed()) {
91
- add_submenu_page('bp-media-settings', __('BuddyPress Media Database Update', 'buddypress-media'), __('Update Database', 'buddypress-media'), 'manage_options', 'bp-media-privacy', array($this, 'privacy_page'));
92
- }
93
-
94
- add_submenu_page('bp-media-settings', __('Importer', 'buddypress-media'), __('Importer', 'buddypress-media'), 'manage_options', 'bp-media-importer', array($this, 'bp_importer_page'));
95
-
96
add_submenu_page('bp-media-settings', __('BuddyPress Media Addons', 'buddypress-media'), __('Addons', 'buddypress-media'), 'manage_options', 'bp-media-addons', array($this, 'addons_page'));
97
add_submenu_page('bp-media-settings', __('BuddyPress Media Support', 'buddypress-media'), __('Support ', 'buddypress-media'), 'manage_options', 'bp-media-support', array($this, 'support_page'));
98
- if (bp_get_option('bp-media-survey', true)) {
99
- add_submenu_page('bp-media-settings', __('BuddyPress Media Convert Videos', 'buddypress-media'), __('Convert Videos', 'buddypress-media'), 'manage_options', 'bp-media-convert-videos', array($this, 'convert_videos_page'));
100
}
101
}
102
@@ -169,130 +171,124 @@ if (!class_exists('BPMediaAdmin')) {
169
<?php
170
$settings_url = ( is_multisite() ) ? network_admin_url('edit.php?action=' . $option_group) : 'options.php';
171
?>
172
- <form id="bp_media_settings_form" name="bp_media_settings_form" action="<?php echo $settings_url; ?>" method="post" enctype="multipart/form-data">
173
- <div class="bp-media-metabox-holder"><?php
174
- if ($option_group) {
175
settings_fields($option_group);
176
do_settings_sections($page);
177
submit_button();
178
- } else {
179
- do_settings_sections($page);
180
}
181
?>
182
- <div class="rt-link alignright"><?php _e('By', 'buddypress-media'); ?> <a href="http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media" title="<?php _e('Empowering The Web With WordPress', 'buddypress-media'); ?>"><img src="<?php echo BP_MEDIA_URL; ?>app/assets/img/rtcamp-logo.png"></a></div>
183
- </div>
184
185
- </form>
186
</div><!-- .bp-media-settings-boxes -->
187
<div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
188
<?php $this->admin_sidebar(); ?>
189
</div>
190
</div><!-- .metabox-holder -->
191
</div><!-- .bp-media-admin --><?php
192
- do_action('bp_media_admin_page_append', $page);
193
- }
194
-
195
- /**
196
- * Adds a tab for Media settings in the BuddyPress settings page
197
- *
198
- * @global type $bp_media
199
- */
200
- public function tab() {
201
-
202
- $tabs_html = '';
203
- $idle_class = 'nav-tab';
204
- $active_class = 'nav-tab nav-tab-active';
205
- $tabs = array();
206
-
207
- // Check to see which tab we are on
208
- $tab = $this->get_current_tab();
209
- /* BuddyPress Media */
210
- $tabs[] = array(
211
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
212
- 'title' => __('BuddyPress Media', 'buddypress-media'),
213
- 'name' => __('BuddyPress Media', 'buddypress-media'),
214
- 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
215
- );
216
-
217
-
218
- foreach ($tabs as $tab) {
219
- $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
220
- }
221
- echo $tabs_html;
222
- }
223
-
224
- /**
225
- * Adds a sub tabs to the BuddyPress Media settings page
226
- *
227
- * @global type $bp_media
228
- */
229
- public function sub_tabs() {
230
- $tabs_html = '';
231
- $idle_class = 'nav-tab';
232
- $active_class = 'nav-tab nav-tab-active';
233
- $tabs = array();
234
-
235
- // Check to see which tab we are on
236
- $tab = $this->get_current_tab();
237
- /* BuddyPress Media */
238
- $tabs[] = array(
239
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
240
- 'title' => __('BuddyPress Media Settings', 'buddypress-media'),
241
- 'name' => __('Settings', 'buddypress-media'),
242
- 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
243
- );
244
-
245
- $tabs[] = array(
246
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
247
- 'title' => __('BuddyPress Media Addons', 'buddypress-media'),
248
- 'name' => __('Addons', 'buddypress-media'),
249
- 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
250
- );
251
-
252
- $tabs[] = array(
253
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
254
- 'title' => __('BuddyPress Media Support', 'buddypress-media'),
255
- 'name' => __('Support', 'buddypress-media'),
256
- 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
257
- );
258
-
259
- if (bp_get_option('bp-media-survey', true)) {
260
- $tabs[] = array(
261
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-convert-videos'), 'admin.php')),
262
- 'title' => __('BuddyPress Media Covert Videos', 'buddypress-media'),
263
- 'name' => __('Convert Videos', 'buddypress-media'),
264
- 'class' => ($tab == 'bp-media-convert-videos') ? $active_class : $idle_class . ' last_tab'
265
- );
266
- }
267
268
- $tabs[] = array(
269
- 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-importer'), 'admin.php')),
270
- 'title' => __('Importer', 'buddypress-media'),
271
- 'name' => __('Importer', 'buddypress-media'),
272
- 'class' => ($tab == 'bp-media-importer') ? $active_class : $idle_class
273
- );
274
275
- $tabs = apply_filters('bp_media_add_sub_tabs', $tabs, $tab);
276
- foreach ($tabs as $tab) {
277
- $tabs_html.= '<a title="' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . ' ' . sanitize_title($tab['name']) . '">' . $tab['name'] . '</a>';
278
- }
279
- echo $tabs_html;
280
- }
281
282
- /*
283
- * Updates the media count of all users.
284
- */
285
286
- /**
287
- *
288
- * @global type $wpdb
289
- * @return boolean
290
- */
291
- public function update_count() {
292
- global $wpdb;
293
294
- $query =
295
- "SELECT
296
p.post_author,pmp.meta_value,
297
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
298
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
@@ -306,89 +302,93 @@ if (!class_exists('BPMediaAdmin')) {
306
pmp.meta_key = 'bp_media_privacy' AND
307
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
308
GROUP BY p.post_author,pmp.meta_value order by p.post_author";
309
- $result = $wpdb->get_results($query);
310
- if (!is_array($result))
311
- return false;
312
- $formatted = array();
313
- foreach ($result as $obj) {
314
- $formatted[$obj->post_author][$obj->meta_value] = array(
315
- 'image' => $obj->Images,
316
- 'video' => $obj->Videos,
317
- 'audio' => $obj->Audio,
318
- 'album' => $obj->Albums,
319
- );
320
- }
321
-
322
- foreach ($formatted as $user => $obj) {
323
- bp_update_user_meta($user, 'bp_media_count', $obj);
324
- }
325
- return true;
326
- }
327
-
328
- /* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
329
-
330
- /**
331
- *
332
- * @global type $bp_media_admin
333
- */
334
- public function save_multisite_options() {
335
- global $bp_media_admin;
336
- if (isset($_POST['refresh-count'])) {
337
- $bp_media_admin->update_count();
338
- }
339
- do_action('bp_media_sanitize_settings', $_POST);
340
341
- if (isset($_POST['bp_media_options'])) {
342
- bp_update_option('bp_media_options', $_POST['bp_media_options']);
343
//
344
// // redirect to settings page in network
345
- wp_redirect(
346
- add_query_arg(
347
- array('page' => 'bp-media-settings', 'updated' => 'true'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
348
- )
349
- );
350
- exit;
351
- }
352
- }
353
-
354
- /* Admin Sidebar */
355
-
356
- /**
357
- *
358
- * @global type $bp_media
359
- */
360
- public function admin_sidebar() {
361
- $current_user = wp_get_current_user();
362
363
- $message = sprintf(__('I use @buddypressmedia http://goo.gl/8Upmv on %s', 'buddypress-media'), home_url());
364
- $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', 'buddypress-media') . '</label>
365
<a href="http://twitter.com/home/?status=' . $message . '" class="button button-tweet" target= "_blank">' . __('Tweet', 'buddypress-media') . '</a>
366
<a href="http://wordpress.org/support/view/plugin-reviews/buddypress-media?rate=5#postform" class="button button-rating" target= "_blank">' . __('Rate on WordPress.org', 'buddypress-media') . '</a>';
367
- new BPMediaAdminWidget('spread-the-word', __('Spread the Word', 'buddypress-media'), $addons);
368
-
369
- $donate = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
370
- <!-- Identify your business so that you can collect the payments. -->
371
- <input type="hidden" name="business"
372
- value="paypal@rtcamp.com">
373
- <!-- Specify a Donate button. -->
374
- <input type="hidden" name="cmd" value="_donations">
375
- <!-- Specify details about the contribution -->
376
- <input type="hidden" name="item_name" value="BuddyPress Media">
377
- <label><b>' . __('USD', 'buddypress-media') . '</b></label>
378
- <input type="text" name="amount" size="3">
379
- <input type="hidden" name="currency_code" value="USD">
380
- <!-- Display the payment button. -->
381
- <input type="hidden" name="cpp_header_image" value="' . BP_MEDIA_URL . 'app/assets/img/rtcamp-logo.png">
382
- <input type="image" id="rt-donate-button" name="submit" border="0"
383
- src="' . BP_MEDIA_URL . 'app/assets/img/paypal-donate-button.png"
384
- alt="PayPal - The safer, easier way to pay online">
385
- </form><br />
386
- <center><b>' . __('OR', 'buddypress-media') . '</b></center><br />
387
- <center>' . __('Use <a href="https://rtcamp.com/store/product-category/buddypress/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">premium add-ons</a> starting from $9', 'buddypress-media') . '</center>';
388
- ;
389
- new BPMediaAdminWidget('donate', __('Donate', 'buddypress-media'), $donate);
390
-
391
- $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>
392
<div class="mc-field-group">
393
<input type="email" value="' . $current_user->user_email . '" name="EMAIL" placeholder="Email" class="required email" id="mce-EMAIL">
394
<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">
@@ -404,81 +404,82 @@ if (!class_exists('BPMediaAdmin')) {
404
<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', 'buddypress-media') . '" class="bp-media-twitter bp-media-social">' . __('Twitter', 'buddypress-media') . '</a></li>
405
<li><a href="' . sprintf('%s', 'http://feeds.feedburner.com/rtcamp/') . '" title="' . __('Subscribe to our feeds', 'buddypress-media') . '" class="bp-media-rss bp-media-social">' . __('RSS Feed', 'buddypress-media') . '</a></li>
406
</ul>';
407
- new BPMediaAdminWidget('branding', __('Subscribe', 'buddypress-media'), $branding);
408
409
- $news = '<img src ="' . admin_url('/images/wpspin_light.gif') . '" /> Loading...';
410
- new BPMediaAdminWidget('latest-news', __('Latest News', 'buddypress-media'), $news);
411
- }
412
413
- public function linkback() {
414
- if (isset($_POST['linkback']) && $_POST['linkback']) {
415
- return bp_update_option('bp_media_add_linkback', true);
416
- } else {
417
- return bp_update_option('bp_media_add_linkback', false);
418
- }
419
- die;
420
- }
421
422
- public function convert_videos_mailchimp_send() {
423
- if ($_POST['interested'] == 'Yes' && !empty($_POST['choice'])) {
424
- wp_remote_get(add_query_arg(array('bp-media-convert-videos-form' => 1, 'choice' => $_POST['choice'], 'url' => urlencode($_POST['url']), 'email' => $_POST['email']), 'http://rtcamp.com/'));
425
- } else {
426
- bp_update_option('bp-media-survey', 0);
427
- }
428
- echo 'Thank you for your time.';
429
- die;
430
- }
431
432
- public function video_transcoding_survey_response() {
433
- if (isset($_GET['survey-done']) && ($_GET['survey-done'] == md5('survey-done'))) {
434
- bp_update_option('bp-media-survey', 0);
435
- }
436
- }
437
438
- public function plugin_meta_premium_addon_link($plugin_meta, $plugin_file, $plugin_data, $status) {
439
- if (plugin_basename(BP_MEDIA_PATH . 'index.php') == $plugin_file)
440
- $plugin_meta[] = '<a href="https://rtcamp.com/store/product-category/buddypress/?utm_source=dashboard&#038;utm_medium=plugin&#038;utm_campaign=buddypress-media" title="Premium Add-ons">Premium Add-ons</a>';
441
- return $plugin_meta;
442
- }
443
444
- public function upload_filetypes_error() {
445
- global $bp_media;
446
- $upload_filetypes = get_site_option('upload_filetypes', 'jpg jpeg png gif');
447
- $upload_filetypes = explode(' ', $upload_filetypes);
448
- $flag = false;
449
- if (isset($bp_media->options['images_enabled']) && $bp_media->options['images_enabled']) {
450
- $not_supported_image = array_diff(array('jpg', 'jpeg', 'png', 'gif'), $upload_filetypes);
451
- if (!empty($not_supported_image)) {
452
- echo '<div class="error upload-filetype-network-settings-error">
453
<p>
454
' . sprintf(__('You have images enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of %s. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), implode(', ', $not_supported_image), network_admin_url('settings.php#upload_filetypes')) . '
455
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
456
</p>
457
</div>';
458
- $flag = true;
459
- }
460
- }
461
- if (isset($bp_media->options['videos_enabled']) && $bp_media->options['videos_enabled']) {
462
- if (!in_array('mp4', $upload_filetypes)) {
463
- echo '<div class="error upload-filetype-network-settings-error">
464
<p>
465
' . sprintf(__('You have video enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of mp4. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), network_admin_url('settings.php#upload_filetypes')) . '
466
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
467
</p>
468
</div>';
469
- $flag = true;
470
- }
471
- }
472
- if (isset($bp_media->options['audio_enabled']) && $bp_media->options['audio_enabled']) {
473
- if (!in_array('mp3', $upload_filetypes)) {
474
- echo '<div class="error upload-filetype-network-settings-error"><p>' . sprintf(__('You have audio enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of mp3. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), network_admin_url('settings.php#upload_filetypes')) . '
475
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
476
</p>
477
</div>';
478
- $flag = true;
479
- }
480
- }
481
- if ($flag) {
482
?>
483
<script type="text/javascript">
484
jQuery('.upload-filetype-network-settings-error').on('click','.update-network-settings-upload-filetypes', function(){
14
15
public $bp_media_upgrade;
16
public $bp_media_settings;
17
+ public $bp_media_encoding;
18
public $bp_media_support;
19
public $bp_media_feed;
20
42
add_filter('plugin_row_meta', array($this, 'plugin_meta_premium_addon_link'), 1, 4);
43
if (is_admin()) {
44
add_action('admin_enqueue_scripts', array($this, 'ui'));
45
+ add_action(bp_core_admin_hook(), array($this, 'menu'),9);
46
if (current_user_can('manage_options'))
47
add_action('bp_admin_tabs', array($this, 'tab'));
48
if (is_multisite())
49
add_action('network_admin_edit_bp_media', array($this, 'save_multisite_options'));
50
}
51
$this->bp_media_settings = new BPMediaSettings();
52
+ $this->bp_media_encoding = new BPMediaEncoding();
53
}
54
55
/**
64
*/
65
public function ui($hook) {
66
$admin_ajax = admin_url('admin-ajax.php');
67
+
68
+ wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js', array('jquery-ui-dialog'), BP_MEDIA_VERSION);
69
wp_localize_script('bp-media-admin', 'bp_media_admin_ajax', $admin_ajax);
70
+ wp_localize_script('bp-media-admin', 'bp_media_admin_url', admin_url());
71
$bp_media_admin_strings = array(
72
'no_refresh' => __('Please do not refresh this page.', 'buddypress-media'),
73
+ 'something_went_wrong' => __('Something went wronng. Please <a href onclick="location.reload();">refresh</a> page.', 'buddypress-media'),
74
+ 'are_you_sure' => __('This will subscribe you to the free plan.', 'buddypress-media'),
75
+ 'disable_encoding' => __('Are you sure you want to disable the encoding service? Make sure you note your api key before diabling it incase you want to activate it in future.', 'buddypress-media')
76
);
77
wp_localize_script('bp-media-admin', 'bp_media_admin_strings', $bp_media_admin_strings);
78
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
82
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
83
));
84
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION);
85
+ wp_enqueue_style('wp-jquery-ui-dialog');
86
}
87
88
/**
94
global $wpdb;
95
add_menu_page(__('BuddyPress Media Component', 'buddypress-media'), __('BuddyPress Media', 'buddypress-media'), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
96
add_submenu_page('bp-media-settings', __('BuddyPress Media Settings', 'buddypress-media'), __('Settings', 'buddypress-media'), 'manage_options', 'bp-media-settings', array($this, 'settings_page'));
97
add_submenu_page('bp-media-settings', __('BuddyPress Media Addons', 'buddypress-media'), __('Addons', 'buddypress-media'), 'manage_options', 'bp-media-addons', array($this, 'addons_page'));
98
add_submenu_page('bp-media-settings', __('BuddyPress Media Support', 'buddypress-media'), __('Support ', 'buddypress-media'), 'manage_options', 'bp-media-support', array($this, 'support_page'));
99
+ add_submenu_page('bp-media-settings', __('Importer', 'buddypress-media'), __('Importer', 'buddypress-media'), 'manage_options', 'bp-media-importer', array($this, 'bp_importer_page'));
100
+ if (!BPMediaPrivacy::is_installed()) {
101
+ add_submenu_page('bp-media-settings', __('BuddyPress Media Database Update', 'buddypress-media'), __('Update Database', 'buddypress-media'), 'manage_options', 'bp-media-privacy', array($this, 'privacy_page'));
102
}
103
}
104
171
<?php
172
$settings_url = ( is_multisite() ) ? network_admin_url('edit.php?action=' . $option_group) : 'options.php';
173
?>
174
+ <?php if ($option_group) { ?>
175
+ <form id="bp_media_settings_form" name="bp_media_settings_form" action="<?php echo $settings_url; ?>" method="post" enctype="multipart/form-data">
176
+ <div class="bp-media-metabox-holder"><?php
177
settings_fields($option_group);
178
do_settings_sections($page);
179
submit_button();
180
+ ?><div class="rt-link alignright"><?php _e('By', 'buddypress-media'); ?> <a href="http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media" title="<?php _e('Empowering The Web With WordPress', 'buddypress-media'); ?>"><img src="<?php echo BP_MEDIA_URL; ?>app/assets/img/rtcamp-logo.png"></a></div>
181
+ </div>
182
+ </form><?php } else {
183
+ ?>
184
+ <div class="bp-media-metabox-holder"><?php do_settings_sections($page); ?>
185
+ <div class="rt-link alignright"><?php _e('By', 'buddypress-media'); ?> <a href="http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media" title="<?php _e('Empowering The Web With WordPress', 'buddypress-media'); ?>"><img src="<?php echo BP_MEDIA_URL; ?>app/assets/img/rtcamp-logo.png"></a></div>
186
+ </div><?php
187
}
188
?>
189
190
+
191
</div><!-- .bp-media-settings-boxes -->
192
<div class="metabox-fixed metabox-holder alignright bp-media-metabox-holder">
193
<?php $this->admin_sidebar(); ?>
194
</div>
195
</div><!-- .metabox-holder -->
196
</div><!-- .bp-media-admin --><?php
197
+ do_action('bp_media_admin_page_append', $page);
198
+ }
199
200
+ /**
201
+ * Adds a tab for Media settings in the BuddyPress settings page
202
+ *
203
+ * @global type $bp_media
204
+ */
205
+ public function tab() {
206
+
207
+ $tabs_html = '';
208
+ $idle_class = 'nav-tab';
209
+ $active_class = 'nav-tab nav-tab-active';
210
+ $tabs = array();
211
+
212
+ // Check to see which tab we are on
213
+ $tab = $this->get_current_tab();
214
+ /* BuddyPress Media */
215
+ $tabs[] = array(
216
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
217
+ 'title' => __('BuddyPress Media', 'buddypress-media'),
218
+ 'name' => __('BuddyPress Media', 'buddypress-media'),
219
+ 'class' => ($tab == 'bp-media-settings' || $tab == 'bp-media-addons' || $tab == 'bp-media-support') ? $active_class : $idle_class
220
+ );
221
+
222
+
223
+ foreach ($tabs as $tab) {
224
+ $tabs_html.= '<a id="bp-media" title= "' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . '">' . $tab['name'] . '</a>';
225
+ }
226
+ echo $tabs_html;
227
+ }
228
229
+ /**
230
+ * Adds a sub tabs to the BuddyPress Media settings page
231
+ *
232
+ * @global type $bp_media
233
+ */
234
+ public function sub_tabs() {
235
+ $tabs_html = '';
236
+ $idle_class = 'nav-tab';
237
+ $active_class = 'nav-tab nav-tab-active';
238
+ $tabs = array();
239
+
240
+ // Check to see which tab we are on
241
+ $tab = $this->get_current_tab();
242
+ /* BuddyPress Media */
243
+ $tabs[] = array(
244
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php')),
245
+ 'title' => __('BuddyPress Media Settings', 'buddypress-media'),
246
+ 'name' => __('Settings', 'buddypress-media'),
247
+ 'class' => ($tab == 'bp-media-settings') ? $active_class : $idle_class . ' first_tab'
248
+ );
249
+
250
+ $tabs[] = array(
251
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-addons'), 'admin.php')),
252
+ 'title' => __('BuddyPress Media Addons', 'buddypress-media'),
253
+ 'name' => __('Addons', 'buddypress-media'),
254
+ 'class' => ($tab == 'bp-media-addons') ? $active_class : $idle_class
255
+ );
256
+
257
+ $tabs[] = array(
258
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php')),
259
+ 'title' => __('BuddyPress Media Support', 'buddypress-media'),
260
+ 'name' => __('Support', 'buddypress-media'),
261
+ 'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
262
+ );
263
+
264
+ $tabs[] = array(
265
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-importer'), 'admin.php')),
266
+ 'title' => __('Importer', 'buddypress-media'),
267
+ 'name' => __('Importer', 'buddypress-media'),
268
+ 'class' => ($tab == 'bp-media-importer') ? $active_class : $idle_class
269
+ );
270
+
271
+ $tabs = apply_filters('bp_media_add_sub_tabs', $tabs, $tab);
272
+ foreach ($tabs as $tab) {
273
+ $tabs_html.= '<a title="' . $tab['title'] . '" href="' . $tab['href'] . '" class="' . $tab['class'] . ' ' . sanitize_title($tab['name']) . '">' . $tab['name'] . '</a>';
274
+ }
275
+ echo $tabs_html;
276
+ }
277
278
+ /*
279
+ * Updates the media count of all users.
280
+ */
281
282
+ /**
283
+ *
284
+ * @global type $wpdb
285
+ * @return boolean
286
+ */
287
+ public function update_count() {
288
+ global $wpdb;
289
290
+ $query =
291
+ "SELECT
292
p.post_author,pmp.meta_value,
293
SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
294
SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
302
pmp.meta_key = 'bp_media_privacy' AND
303
( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
304
GROUP BY p.post_author,pmp.meta_value order by p.post_author";
305
+ $result = $wpdb->get_results($query);
306
+ if (!is_array($result))
307
+ return false;
308
+ $formatted = array();
309
+ foreach ($result as $obj) {
310
+ $formatted[$obj->post_author][$obj->meta_value] = array(
311
+ 'image' => $obj->Images,
312
+ 'video' => $obj->Videos,
313
+ 'audio' => $obj->Audio,
314
+ 'album' => $obj->Albums,
315
+ );
316
+ }
317
+
318
+ foreach ($formatted as $user => $obj) {
319
+ bp_update_user_meta($user, 'bp_media_count', $obj);
320
+ }
321
+ return true;
322
+ }
323
324
+ /* Multisite Save Options - http://wordpress.stackexchange.com/questions/64968/settings-api-in-multisite-missing-update-message#answer-72503 */
325
+
326
+ /**
327
+ *
328
+ * @global type $bp_media_admin
329
+ */
330
+ public function save_multisite_options() {
331
+ global $bp_media_admin;
332
+ if (isset($_POST['refresh-count'])) {
333
+ $bp_media_admin->update_count();
334
+ }
335
+ do_action('bp_media_sanitize_settings', $_POST);
336
+
337
+ if (isset($_POST['bp_media_options'])) {
338
+ bp_update_option('bp_media_options', $_POST['bp_media_options']);
339
//
340
// // redirect to settings page in network
341
+ wp_redirect(
342
+ add_query_arg(
343
+ array('page' => 'bp-media-settings', 'updated' => 'true'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
344
+ )
345
+ );
346
+ exit;
347
+ }
348
+ }
349
350
+ /* Admin Sidebar */
351
+
352
+ /**
353
+ *
354
+ * @global type $bp_media
355
+ */
356
+ public function admin_sidebar() {
357
+ do_action('bp_media_before_default_admin_widgets');
358
+ $current_user = wp_get_current_user();
359
+ echo '<p><a target="_blank" href="http://rtcamp.com/news/buddypress-media-review-contest/?utm_source=dashboard&#038;utm_medium=plugin&#038;utm_campaign=buddypress-media"><img src="'.BP_MEDIA_URL.'app/assets/img/bpm-contest-banner.jpg" alt="BuddyPress Media Review Contest" /></a></p>';
360
+ // $contest = '<a target="_blank" href="http://rtcamp.com/news/buddypress-media-review-contest/?utm_source=dashboard&#038;utm_medium=plugin&#038;utm_campaign=buddypress-media"><img src="'.BP_MEDIA_URL.'app/assets/img/bpm-contest-banner.jpg" alt="BuddyPress Media Review Contest" /></a>';
361
+ // new BPMediaAdminWidget('bpm-contest', __('', 'buddypress-media'), $contest);
362
+
363
+ $message = sprintf(__('I use @buddypressmedia http://goo.gl/8Upmv on %s', 'buddypress-media'), home_url());
364
+ $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', 'buddypress-media') . '</label>
365
<a href="http://twitter.com/home/?status=' . $message . '" class="button button-tweet" target= "_blank">' . __('Tweet', 'buddypress-media') . '</a>
366
<a href="http://wordpress.org/support/view/plugin-reviews/buddypress-media?rate=5#postform" class="button button-rating" target= "_blank">' . __('Rate on WordPress.org', 'buddypress-media') . '</a>';
367
+ new BPMediaAdminWidget('spread-the-word', __('Spread the Word', 'buddypress-media'), $addons);
368
+
369
+ // $donate = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
370
+ // <!-- Identify your business so that you can collect the payments. -->
371
+ // <input type="hidden" name="business"
372
+ // value="paypal@rtcamp.com">
373
+ // <!-- Specify a Donate button. -->
374
+ // <input type="hidden" name="cmd" value="_donations">
375
+ // <!-- Specify details about the contribution -->
376
+ // <input type="hidden" name="item_name" value="BuddyPress Media">
377
+ // <label><b>' . __('USD', 'buddypress-media') . '</b></label>
378
+ // <input type="text" name="amount" size="3">
379
+ // <input type="hidden" name="currency_code" value="USD">
380
+ // <!-- Display the payment button. -->
381
+ // <input type="hidden" name="cpp_header_image" value="' . BP_MEDIA_URL . 'app/assets/img/rtcamp-logo.png">
382
+ // <input type="image" id="rt-donate-button" name="submit" border="0"
383
+ // src="' . BP_MEDIA_URL . 'app/assets/img/paypal-donate-button.png"
384
+ // alt="PayPal - The safer, easier way to pay online">
385
+ // </form><br />
386
+ // <center><b>' . __('OR', 'buddypress-media') . '</b></center><br />
387
+ // <center>' . __('Use <a href="https://rtcamp.com/store/product-category/buddypress/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">premium add-ons</a> starting from $9', 'buddypress-media') . '</center>';
388
+ // ;
389
+ // new BPMediaAdminWidget('donate', __('Donate', 'buddypress-media'), $donate);
390
+
391
+ $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>
392
<div class="mc-field-group">
393
<input type="email" value="' . $current_user->user_email . '" name="EMAIL" placeholder="Email" class="required email" id="mce-EMAIL">
394
<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">
404
<li><a href="' . sprintf('%s', 'https://twitter.com/rtcamp/') . '" title="' . __('Follow us on Twitter', 'buddypress-media') . '" class="bp-media-twitter bp-media-social">' . __('Twitter', 'buddypress-media') . '</a></li>
405
<li><a href="' . sprintf('%s', 'http://feeds.feedburner.com/rtcamp/') . '" title="' . __('Subscribe to our feeds', 'buddypress-media') . '" class="bp-media-rss bp-media-social">' . __('RSS Feed', 'buddypress-media') . '</a></li>
406
</ul>';
407
+ new BPMediaAdminWidget('branding', __('Subscribe', 'buddypress-media'), $branding);
408
409
+ $news = '<img src ="' . admin_url('/images/wpspin_light.gif') . '" /> Loading...';
410
+ new BPMediaAdminWidget('latest-news', __('Latest News', 'buddypress-media'), $news);
411
+ do_action('bp_media_after_default_admin_widgets');
412
+ }
413
414
+ public function linkback() {
415
+ if (isset($_POST['linkback']) && $_POST['linkback']) {
416
+ return bp_update_option('bp_media_add_linkback', true);
417
+ } else {
418
+ return bp_update_option('bp_media_add_linkback', false);
419
+ }
420
+ die;
421
+ }
422
423
+ public function convert_videos_mailchimp_send() {
424
+ if ($_POST['interested'] == 'Yes' && !empty($_POST['choice'])) {
425
+ wp_remote_get(add_query_arg(array('bp-media-convert-videos-form' => 1, 'choice' => $_POST['choice'], 'url' => urlencode($_POST['url']), 'email' => $_POST['email']), 'http://rtcamp.com/'));
426
+ } else {
427
+ bp_update_option('bp-media-survey', 0);
428
+ }
429
+ echo 'Thank you for your time.';
430
+ die;
431
+ }
432
433
+ public function video_transcoding_survey_response() {
434
+ if (isset($_GET['survey-done']) && ($_GET['survey-done'] == md5('survey-done'))) {
435
+ bp_update_option('bp-media-survey', 0);
436
+ }
437
+ }
438
439
+ public function plugin_meta_premium_addon_link($plugin_meta, $plugin_file, $plugin_data, $status) {
440
+ if (plugin_basename(BP_MEDIA_PATH . 'index.php') == $plugin_file)
441
+ $plugin_meta[] = '<a href="https://rtcamp.com/store/product-category/buddypress/?utm_source=dashboard&#038;utm_medium=plugin&#038;utm_campaign=buddypress-media" title="Premium Add-ons">Premium Add-ons</a>';
442
+ return $plugin_meta;
443
+ }
444
445
+ public function upload_filetypes_error() {
446
+ global $bp_media;
447
+ $upload_filetypes = get_site_option('upload_filetypes', 'jpg jpeg png gif');
448
+ $upload_filetypes = explode(' ', $upload_filetypes);
449
+ $flag = false;
450
+ if (isset($bp_media->options['images_enabled']) && $bp_media->options['images_enabled']) {
451
+ $not_supported_image = array_diff(array('jpg', 'jpeg', 'png', 'gif'), $upload_filetypes);
452
+ if (!empty($not_supported_image)) {
453
+ echo '<div class="error upload-filetype-network-settings-error">
454
<p>
455
' . sprintf(__('You have images enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of %s. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), implode(', ', $not_supported_image), network_admin_url('settings.php#upload_filetypes')) . '
456
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
457
</p>
458
</div>';
459
+ $flag = true;
460
+ }
461
+ }
462
+ if (isset($bp_media->options['videos_enabled']) && $bp_media->options['videos_enabled']) {
463
+ if (!in_array('mp4', $upload_filetypes)) {
464
+ echo '<div class="error upload-filetype-network-settings-error">
465
<p>
466
' . sprintf(__('You have video enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of mp4. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), network_admin_url('settings.php#upload_filetypes')) . '
467
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
468
</p>
469
</div>';
470
+ $flag = true;
471
+ }
472
+ }
473
+ if (isset($bp_media->options['audio_enabled']) && $bp_media->options['audio_enabled']) {
474
+ if (!in_array('mp3', $upload_filetypes)) {
475
+ echo '<div class="error upload-filetype-network-settings-error"><p>' . sprintf(__('You have audio enabled on BuddyPress Media but your network allowed filetypes does not allow uploading of mp3. Click <a href="%s">here</a> to change your settings manually.', 'buddypress-media'), network_admin_url('settings.php#upload_filetypes')) . '
476
<br /><strong>' . __('Recommended', 'buddypress-media') . ':</strong> <input type="button" class="button update-network-settings-upload-filetypes" class="button" value="' . __('Update Network Settings Automatically', 'buddypress-media') . '"> <img style="display:none;" src="' . admin_url('images/wpspin_light.gif') . '" />
477
</p>
478
</div>';
479
+ $flag = true;
480
+ }
481
+ }
482
+ if ($flag) {
483
?>
484
<script type="text/javascript">
485
jQuery('.upload-filetype-network-settings-error').on('click','.update-network-settings-upload-filetypes', function(){
app/assets/css/main.css CHANGED
@@ -1,8 +1,8 @@
1
/*
2
* Default stylesheet for BuddyPress Media
3
*/
4
- #wpbody-content div.metabox-fixed{width: 280px;margin-right: -300px;float: right;}
5
- #wpbody-content div.wrap.bp-media-admin .columns-2{margin-right:300px;padding-top: 0;margin-top: 15px;width: 600px}
6
#wpbody-content .bp-media-settings-tabs{margin-bottom: 0; }
7
#wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
8
#wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
@@ -23,11 +23,12 @@
23
#adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
24
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
25
#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%;}
26
- #debug-info{border:1px solid #CCC; overflow: hidden; padding: 10px; margin-top: 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: 588px;}
27
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
28
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -96px;}
29
- .metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/bpm-icon-32.png') -5px 0px no-repeat; padding-left: 32px;}
30
- .metabox-holder .postbox#latest-news .inside ul li:hover{background-position-y: -96px;}
31
#branding #logo{text-align:center;padding: 10px 0;display:block;}
32
ul#social{display:block;text-align:center;margin:0;clear: both;}
33
#branding #mc-embedded-subscribe-form{float: left;width: 100%;}
@@ -51,6 +52,22 @@ ul#social li{display:inline;}
51
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.convert-videos{background-position-y:-214px;}
52
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.insta{background-position-y:-244px;}
53
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.watermark{background-position-y:-274px;}
54
/* Addons page Styling */
55
56
a.toplevel_page_bp-media-settings div.wp-menu-image{
@@ -209,6 +226,10 @@ img.bp-media-donation-image{display:block;margin: 10px auto;}
209
border-radius: 10px;
210
}
211
212
213
.bp_media_content img{max-width:100%;}
214
.bp_media_content .mejs-poster img{max-width: 100%;}
@@ -483,6 +504,8 @@ float:left;
483
display:none;
484
}
485
486
@media (min-width: 981px) and (max-width: 1096px) {
487
li #bp-media-upload-ui #drag-drop-area{padding: 10px 0;}
488
/* li #bp-media-upload-ui .drag-drop-inside{margin: 0 auto;}*/
1
/*
2
* Default stylesheet for BuddyPress Media
3
*/
4
+ #wpbody-content div.metabox-fixed{width: 300px;margin-right: -320px;float: right;}
5
+ #wpbody-content div.wrap.bp-media-admin .columns-2{margin-right:320px;padding-top: 0;margin-top: 15px;width: 620px}
6
#wpbody-content .bp-media-settings-tabs{margin-bottom: 0; }
7
#wpbody-content .bp-media-settings-tabs .media-nav-tab{margin: 0 10px; text-decoration: underline; text-transform: capitalize}
8
#wpbody-content .bp-media-settings-tabs .media-nav-tab.media-nav-tab-active{font-weight: bold}
23
#adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
24
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
25
#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%;}
26
+ #debug-info{clear:left;border:1px solid #CCC; overflow: hidden; padding: 10px; margin-top: 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: 588px;}
27
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
28
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -96px;}
29
+ .metabox-holder .postbox#latest-news .inside ul li{list-style: disc inside;}
30
+ /*.metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/bpm-icon-32.png') -5px 0px no-repeat; padding-left: 32px;}*/
31
+ /*.metabox-holder .postbox#latest-news .inside ul li:hover{background-position-y: -96px;}*/
32
#branding #logo{text-align:center;padding: 10px 0;display:block;}
33
ul#social{display:block;text-align:center;margin:0;clear: both;}
34
#branding #mc-embedded-subscribe-form{float: left;width: 100%;}
52
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.convert-videos{background-position-y:-214px;}
53
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.insta{background-position-y:-244px;}
54
.wrap.bp-media-admin .bp-media-settings-tabs a.nav-tab.watermark{background-position-y:-274px;}
55
+
56
+ #bpm-unsubscribe-dialog { display: none; }
57
+ #bpm-unsubscribe-dialog p { margin: 10px; }
58
+
59
+ table.bp-media-encoding-table td, table.bp-media-encoding-table th {
60
+ border-left-color: #fff;
61
+ border-right-color: #dfdfdf;
62
+ border-width: 1px;
63
+ vertical-align: middle;
64
+ text-align: center;
65
+ font-family: sans-serif;
66
+ }
67
+ table.bp-media-encoding-table th {
68
+ font-weight: bold;
69
+ }
70
+
71
/* Addons page Styling */
72
73
a.toplevel_page_bp-media-settings div.wp-menu-image{
226
border-radius: 10px;
227
}
228
229
+ .encoding-used,
230
+ .encoding-remaining { display: inline-block; width: 10px; height: 10px; margin-right: 5px;}
231
+ .encoding-used { background : #fb6003; }
232
+ .encoding-remaining { background: #444; }
233
234
.bp_media_content img{max-width:100%;}
235
.bp_media_content .mejs-poster img{max-width: 100%;}
504
display:none;
505
}
506
507
+ #adminmenu li#toplevel_page_bp-media-settings a.toplevel_page_bp-media-settings { font-size: 12px; }
508
+
509
@media (min-width: 981px) and (max-width: 1096px) {
510
li #bp-media-upload-ui #drag-drop-area{padding: 10px 0;}
511
/* li #bp-media-upload-ui .drag-drop-inside{margin: 0 auto;}*/
app/assets/img/bpm-contest-banner.jpg ADDED
Binary file
app/assets/js/admin.js CHANGED
@@ -71,6 +71,112 @@ jQuery(document).ready(function(){
71
});
72
});
73
74
function fireRequest(data) {
75
return jQuery.post(ajaxurl, data, function(response){
76
if(response != 0){
@@ -350,6 +456,19 @@ jQuery(document).ready(function(){
350
$bpalbum.parent().after('<p>'+bp_media_admin_strings.something_went_wrong+'</p>');
351
});
352
});
353
354
355
});
71
});
72
});
73
74
+ jQuery('#encoding-try-now-form').on('click','.encoding-try-now',function(e){
75
+ e.preventDefault();
76
+ if(confirm(bp_media_admin_strings.are_you_sure)){
77
+ jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+bp_media_admin_url+'images/wpspin_light.gif" />')
78
+ var data = {
79
+ action: 'bp_media_free_encoding_subscribe'
80
+ };
81
+
82
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
83
+ jQuery.getJSON(ajaxurl, data, function(response) {
84
+ if(response.error===undefined && response.apikey){
85
+ document.location.href = document.URL+'&apikey='+response.apikey;
86
+ }else{
87
+ jQuery('.encoding-try-now').next().remove();
88
+ jQuery('#settings-error-encoding-error').remove();
89
+ jQuery('h2:first').after('<div class="error" id="settings-error-encoding-error"><p>'+response.error+'</p></div>');
90
+ }
91
+ });
92
+ }
93
+ });
94
+
95
+ jQuery('.bp-media-encoding').on('click','#api-key-submit',function(e){
96
+ e.preventDefault();
97
+ jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+bp_media_admin_url+'images/wpspin_light.gif" />')
98
+ var data = {
99
+ action: 'bp_media_enter_api_key',
100
+ apikey: jQuery('#new-api-key').val()
101
+ };
102
+
103
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
104
+ jQuery.getJSON(ajaxurl, data, function(response) {
105
+ if(response.error===undefined && response.apikey){
106
+ document.location.href = document.URL+'&update=true&apikey='+response.apikey;
107
+ }else{
108
+ jQuery('#settings-error-api-key-error').remove();
109
+ jQuery('h2:first').after('<div class="error" id="settings-error-api-key-error"><p>'+response.error+'</p></div>');
110
+ }
111
+ });
112
+ });
113
+
114
+ jQuery('.bp-media-encoding').on('click','#disable-encoding',function(e){
115
+ e.preventDefault();
116
+ if ( confirm(bp_media_admin_strings.disable_encoding )) {
117
+ jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+bp_media_admin_url+'images/wpspin_light.gif" />')
118
+ var data = {
119
+ action: 'bp_media_disable_encoding'
120
+ };
121
+
122
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
123
+ jQuery.post(ajaxurl, data, function(response) {
124
+ if(response){
125
+ jQuery('settings-error-encoding-disabled').remove();
126
+ jQuery('h2:first').after('<div class="updated" id="settings-encoding-successfully-disabled"><p>'+response+'</p></div>');
127
+ jQuery('#bp-media-encoding-usage').remove();
128
+ jQuery('#disable-encoding').next().remove();
129
+ jQuery('#disable-encoding').remove();
130
+ jQuery('#new-api-key').val('');
131
+ }else{
132
+ jQuery('#settings-error-encoding-disabled').remove();
133
+ jQuery('h2:first').after('<div class="error" id="settings-error-encoding-disabled"><p>'+bp_media_admin_strings.something_went_wrong+'</p></div>');
134
+ }
135
+ });
136
+ }
137
+ });
138
+
139
+ jQuery('.bp-media-encoding-table').on('click','.bpm-unsubscribe',function(e){
140
+ e.preventDefault();
141
+ // var note=prompt(bp_media_admin_strings.reason_for_unsubscribe);
142
+ jQuery( "#bpm-unsubscribe-dialog" ).dialog({
143
+ dialogClass: "wp-dialog",
144
+ modal: true,
145
+ buttons: {
146
+ Unsubscribe : function() {
147
+ jQuery( this ).dialog( "close" );
148
+ jQuery('.bpm-unsubscribe').after('<img style="margin: 0 0 0 10px" src="'+bp_media_admin_url+'images/wpspin_light.gif" />')
149
+ var data = {
150
+ action: 'bp_media_unsubscribe_encoding_service',
151
+ note: jQuery('#bpm-unsubscribe-note').val(),
152
+ plan: jQuery('.bpm-unsubscribe').attr('data-plan'),
153
+ price: jQuery('.bpm-unsubscribe').attr('data-price')
154
+ };
155
+
156
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
157
+ jQuery.getJSON(ajaxurl, data, function(response) {
158
+ if(response.error===undefined && response.updated){
159
+ jQuery('.bpm-unsubscribe').next().remove();
160
+ jQuery('.bpm-unsubscribe').after(response.form);
161
+ jQuery('.bpm-unsubscribe').remove();
162
+ jQuery('#settings-unsubscribed-successfully').remove();
163
+ jQuery('#settings-unsubscribe-error').remove();
164
+ jQuery('h2:first').after('<div class="updated" id="settings-unsubscribed-successfully"><p>'+response.updated+'</p></div>');
165
+ window.location.hash = '#settings-unsubscribed-successfully';
166
+ }else{
167
+ jQuery('.bpm-unsubscribe').next().remove();
168
+ jQuery('#settings-unsubscribed-successfully').remove();
169
+ jQuery('#settings-unsubscribe-error').remove();
170
+ jQuery('h2:first').after('<div class="error" id="settings-unsubscribe-error"><p>'+response.error+'</p></div>');
171
+ window.location.hash = '#settings-unsubscribe-error';
172
+ }
173
+ });
174
+ }
175
+ }
176
+ });
177
+
178
+ });
179
+
180
function fireRequest(data) {
181
return jQuery.post(ajaxurl, data, function(response){
182
if(response != 0){
456
$bpalbum.parent().after('<p>'+bp_media_admin_strings.something_went_wrong+'</p>');
457
});
458
});
459
+
460
+ jQuery('.updated').on('click','.bpm-hide-encoding-notice',function(){
461
+ jQuery(this).after('<img style="margin: 0 0 0 10px" src="'+bp_media_admin_url+'images/wpspin_light.gif" />');
462
+ var data ={
463
+ action: 'bp_media_hide_encoding_notice'
464
+ }
465
+ jQuery.post(ajaxurl,data,function(response){
466
+ if ( response ) {
467
+ jQuery('.bpm-hide-encoding-notice').closest('.updated').remove();
468
+ }
469
+ });
470
+ });
471
472
473
});
474
+
app/helper/BPMediaAddon.php CHANGED
@@ -67,8 +67,13 @@ if (!class_exists('BPMediaAddon')) {
67
)
68
);
69
$addons = apply_filters('bp_media_addons', $addons);
70
- foreach ($addons as $addon) {
71
$this->addon($addon);
72
}
73
}
74
67
)
68
);
69
$addons = apply_filters('bp_media_addons', $addons);
70
+ foreach ($addons as $key => $addon) {
71
$this->addon($addon);
72
+ if ( $key == 1 ) {
73
+ echo '<h3>';
74
+ _e('BuddyPress Media Addons for Audio/Video');
75
+ echo '</h3>';
76
+ }
77
}
78
}
79
app/helper/BPMediaSettings.php CHANGED
@@ -204,8 +204,8 @@ if (!class_exists('BPMediaSettings')) {
204
));
205
206
$bp_media_addon = new BPMediaAddon();
207
- add_settings_section('bpm-addons', __('BuddyPress Media Addons for Audio/Video Conversion', 'buddypress-media'), array($bp_media_addon, 'get_addons'), 'bp-media-addons');
208
-
209
add_settings_section('bpm-support', __('Support', 'buddypress-media'), array($this, 'bp_media_support_intro'), 'bp-media-support');
210
211
if (!BPMediaPrivacy::is_installed()) {
@@ -216,40 +216,9 @@ if (!class_exists('BPMediaSettings')) {
216
217
$bp_media_album_importer = new BPMediaAlbumimporter();
218
add_settings_section('bpm-bp-album-importer', __('BP-Album Importer', 'buddypress-media'), array($bp_media_album_importer, 'ui'), 'bp-media-importer');
219
-
220
- add_settings_section('bpm-convert-videos', '', array($this, 'convert_videos_form'), 'bp-media-convert-videos');
221
-
222
register_setting('bp_media', 'bp_media_options', array($this, 'sanitize'));
223
}
224
225
- public function convert_videos_form() {
226
- global $current_user;
227
- get_currentuserinfo();
228
- ?>
229
- <div id="video-transcoding-main-container">
230
- <h2>Survey</h2>
231
- <p class="para-blockquote">We are planning an encoding service where you can convert videos without having to install/configure anything on your server.</p>
232
- <h3>Would you be interested?</h3>
233
- <label><input class="interested" name="interested" type="radio" value="Yes" required="required" /> Yes</label>&nbsp;&nbsp;&nbsp;
234
- <label><input class="not-interested" name="interested" type="radio" value="No" required="required" /> No</label>
235
- <div class="interested-container hidden">
236
- <p class="para-blockquote">Glad to see your interest.<br />
237
- Please provide a little more information to help us plan this service better.</p>
238
- <label><h3>Email</h3> <input class="email" type="email" name="email" size="35" value="<?php echo $current_user->user_email; ?>" placeholder="Email" /></label>
239
-
240
- <h3>How would you use this feature?</h3>
241
- <ul>
242
- <li><label><input class="choice-free" type="radio" name="choice" value="Free" /> Free-only. I will use free-encoding quota only.</label></li>
243
- <li><label><input type="radio" name="choice" value="$9" /> I am ready to pay $9 per month for generous encoding quota.</label></li>
244
- <li><label><input type="radio" name="choice" value="$99" /> I am ready to pay $99 per month for unlimited video encoding!</label></li>
245
- </div>
246
- <input class="url" type="hidden" name="url" value="<?php echo home_url(); ?>" />
247
- <br />
248
- <br />
249
- <input class="button button-primary video-transcoding-survey" type="submit" value="Submit" />
250
- </div><?php
251
- }
252
-
253
public function network_notices() {
254
$flag = 1;
255
if (get_site_option('bpm-media-enable', false)) {
@@ -637,7 +606,7 @@ if (!class_exists('BPMediaSettings')) {
637
echo '<p>' . __('If your site has some issues due to BuddyPress Media and you want one on one support then you can create a support topic on the <a target="_blank" href="http://rtcamp.com/groups/buddypress-media/forum/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">rtCamp Support Forum</a>.', 'buddypress-media') . '</p>';
638
echo '<p>' . __('If you have any suggestions, enhancements or bug reports, then you can open a new issue on <a target="_blank" href="https://github.com/rtCamp/buddypress-media/issues/new">GitHub</a>.', 'buddypress-media') . '</p>';
639
}
640
-
641
}
642
643
}
204
));
205
206
$bp_media_addon = new BPMediaAddon();
207
+ add_settings_section('bpm-addons', __('BuddyPress Media Addons for Photos', 'buddypress-media'), array($bp_media_addon, 'get_addons'), 'bp-media-addons');
208
+
209
add_settings_section('bpm-support', __('Support', 'buddypress-media'), array($this, 'bp_media_support_intro'), 'bp-media-support');
210
211
if (!BPMediaPrivacy::is_installed()) {
216
217
$bp_media_album_importer = new BPMediaAlbumimporter();
218
add_settings_section('bpm-bp-album-importer', __('BP-Album Importer', 'buddypress-media'), array($bp_media_album_importer, 'ui'), 'bp-media-importer');
219
register_setting('bp_media', 'bp_media_options', array($this, 'sanitize'));
220
}
221
222
public function network_notices() {
223
$flag = 1;
224
if (get_site_option('bpm-media-enable', false)) {
606
echo '<p>' . __('If your site has some issues due to BuddyPress Media and you want one on one support then you can create a support topic on the <a target="_blank" href="http://rtcamp.com/groups/buddypress-media/forum/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media">rtCamp Support Forum</a>.', 'buddypress-media') . '</p>';
607
echo '<p>' . __('If you have any suggestions, enhancements or bug reports, then you can open a new issue on <a target="_blank" href="https://github.com/rtCamp/buddypress-media/issues/new">GitHub</a>.', 'buddypress-media') . '</p>';
608
}
609
+
610
}
611
612
}
app/helper/rtProgress.php CHANGED
@@ -19,12 +19,16 @@ class rtProgress {
19
20
}
21
22
- function progress_ui($progress){
23
- echo '
24
<div id="rtprogressbar">
25
<div style="width:'.$progress.'%"></div>
26
</div>
27
';
28
}
29
30
function progress($progress,$total){
19
20
}
21
22
+ function progress_ui($progress, $echo = true){
23
+ $progress_ui = '
24
<div id="rtprogressbar">
25
<div style="width:'.$progress.'%"></div>
26
</div>
27
';
28
+ if ( $echo )
29
+ echo $progress_ui;
30
+ else
31
+ return $progress_ui;
32
}
33
34
function progress($progress,$total){
app/main/BPMediaLoader.php CHANGED
@@ -80,7 +80,7 @@ class BPMediaLoader {
80
case BP_MEDIA_VIDEOS_SLUG:
81
case BP_MEDIA_AUDIO_SLUG:
82
case BP_MEDIA_ALBUMS_SLUG:
83
- $bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
84
'name' => $nav_item['name'],
85
'link' => (
86
isset($bp->displayed_user->domain) ?
@@ -103,7 +103,7 @@ class BPMediaLoader {
103
unset($bp->bp_nav[$key]);
104
break;
105
case BP_MEDIA_UPLOAD_SLUG:
106
- $bp->bp_options_nav[BP_MEDIA_SLUG][] = array(
107
'name' => $nav_item['name'],
108
'link' => (
109
isset($bp->displayed_user->domain) ?
80
case BP_MEDIA_VIDEOS_SLUG:
81
case BP_MEDIA_AUDIO_SLUG:
82
case BP_MEDIA_ALBUMS_SLUG:
83
+ $bp->bp_options_nav[BP_MEDIA_SLUG][$nav_item['slug']] = array(
84
'name' => $nav_item['name'],
85
'link' => (
86
isset($bp->displayed_user->domain) ?
103
unset($bp->bp_nav[$key]);
104
break;
105
case BP_MEDIA_UPLOAD_SLUG:
106
+ $bp->bp_options_nav[BP_MEDIA_SLUG][$nav_item['slug']] = array(
107
'name' => $nav_item['name'],
108
'link' => (
109
isset($bp->displayed_user->domain) ?
app/main/includes/BPMediaActions.php CHANGED
@@ -30,6 +30,7 @@ class BPMediaActions {
30
add_action('bp_media_after_delete_album', array($this, 'update_count'), 999);
31
add_action('bp_media_after_delete_media', array($this, 'album_activity_sync'));
32
add_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4);
33
add_action('wp_ajax_bp_media_load_more', array($this, 'load_more'));
34
add_action('wp_ajax_nopriv_bp_media_load_more', array($this, 'load_more'));
35
add_action('wp_ajax_bp_media_load_more_sc', array($this, 'load_more_sc'));
@@ -1190,6 +1191,21 @@ class BPMediaActions {
1190
wp_reset_query();
1191
return $markup;
1192
}
1193
1194
}
1195
?>
30
add_action('bp_media_after_delete_album', array($this, 'update_count'), 999);
31
add_action('bp_media_after_delete_media', array($this, 'album_activity_sync'));
32
add_action('bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4);
33
+ add_action('bp_activity_posted_update', array($this, 'activity_update'), '', 3);
34
add_action('wp_ajax_bp_media_load_more', array($this, 'load_more'));
35
add_action('wp_ajax_nopriv_bp_media_load_more', array($this, 'load_more'));
36
add_action('wp_ajax_bp_media_load_more_sc', array($this, 'load_more_sc'));
1191
wp_reset_query();
1192
return $markup;
1193
}
1194
+
1195
+ public function activity_update($content, $user_id, $activity_id) {
1196
+ $content = stripslashes($content);
1197
+ $activity_json = json_decode($content, true);
1198
+ $activity_media = json_decode($activity_json['media'], true);
1199
+ if (isset($activity_media)) {
1200
+ if (!is_array($activity_media)) {
1201
+ $activity_media[] = $activity_media;
1202
+ }
1203
+ $media_ids = null;
1204
+ foreach ($activity_media as $media_id) {
1205
+ update_post_meta($media_id, 'bp-media-activity-upload-id', $activity_id);
1206
+ }
1207
+ }
1208
+ }
1209
1210
}
1211
?>
app/main/includes/BPMediaFilters.php CHANGED
@@ -328,7 +328,6 @@ class BPMediaFilters {
328
'title' => __('Settings', 'buddypress-media'),
329
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php'))
330
);
331
-
332
333
// Addons
334
$bp_media_admin_nav[] = array(
@@ -345,6 +344,14 @@ class BPMediaFilters {
345
'title' => __('Support', 'buddypress-media'),
346
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php'))
347
);
348
349
$bp_media_admin_nav = apply_filters('bp_media_add_admin_bar_item', $bp_media_admin_nav);
350
328
'title' => __('Settings', 'buddypress-media'),
329
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-settings'), 'admin.php'))
330
);
331
332
// Addons
333
$bp_media_admin_nav[] = array(
344
'title' => __('Support', 'buddypress-media'),
345
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-support'), 'admin.php'))
346
);
347
+
348
+ // Importer
349
+ $bp_media_admin_nav[] = array(
350
+ 'parent' => 'bp-media-menu',
351
+ 'id' => 'bp-media-importer',
352
+ 'title' => __('Importer', 'buddypress-media'),
353
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-importer'), 'admin.php'))
354
+ );
355
356
$bp_media_admin_nav = apply_filters('bp_media_add_admin_bar_item', $bp_media_admin_nav);
357
app/main/includes/BPMediaHostWordpress.php CHANGED
@@ -117,7 +117,6 @@ class BPMediaHostWordpress {
117
function insert_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false, $is_activity = false, $files = false, $author_id = false, $album_name = false) {
118
do_action('bp_media_before_add_media');
119
120
- global $bp, $wpdb, $bp_media;
121
include_once(ABSPATH . 'wp-admin/includes/file.php');
122
include_once(ABSPATH . 'wp-admin/includes/image.php');
123
117
function insert_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false, $is_activity = false, $files = false, $author_id = false, $album_name = false) {
118
do_action('bp_media_before_add_media');
119
120
include_once(ABSPATH . 'wp-admin/includes/file.php');
121
include_once(ABSPATH . 'wp-admin/includes/image.php');
122
app/main/profile/BPMediaAlbumScreen.php CHANGED
@@ -43,7 +43,7 @@ class BPMediaAlbumScreen extends BPMediaScreen {
43
$this->page_not_exist();
44
}
45
$media_actions = new BPMediaActions();
46
- if ($media_actions->default_user_album() != $bp->action_variables[1])
47
$this->entry_delete();
48
else
49
$this->page_not_exist();
43
$this->page_not_exist();
44
}
45
$media_actions = new BPMediaActions();
46
+ if ($media_actions->default_user_album() != $bp->action_variables[1])
47
$this->entry_delete();
48
else
49
$this->page_not_exist();
app/main/profile/BPMediaScreen.php CHANGED
@@ -425,7 +425,7 @@ class BPMediaScreen {
425
$activity_id ));
426
}
427
428
- if ( 'album' == $bp_media_current_entry->get_type()){
429
$delete_handler = new BPMediaAlbum($post_id);
430
$delete_handler->delete_album();
431
} else {
425
$activity_id ));
426
}
427
428
+ if ( !bp_is_active('activity') && 'album' == $bp_media_current_entry->get_type()){
429
$delete_handler = new BPMediaAlbum($post_id);
430
$delete_handler->delete_album();
431
} else {
app/services/BPMediaEncoding.php ADDED
@@ -0,0 +1,534 @@
1
+ <?php
2
+
3
+ /**
4
+ * Description of BPMediaEncoding
5
+ *
6
+ * @author Joshua Abenazer <joshua.abenazer@rtcamp.com>
7
+ */
8
+ class BPMediaEncoding {
9
+
10
+ protected $api_url = 'http://api.rtcamp.com/';
11
+ protected $sandbox_testing = 0;
12
+ protected $merchant_id = 'paypal@rtcamp.com';
13
+
14
+ public function __construct() {
15
+ $this->api_key = bp_get_option('bp-media-encoding-api-key');
16
+ if (is_admin()) {
17
+ add_action(bp_core_admin_hook(), array($this, 'menu'));
18
+ add_action('admin_init', array($this, 'encoding_settings'));
19
+ add_filter('bp_media_add_sub_tabs', array($this, 'encoding_tab'), '', 2);
20
+ if ($this->api_key)
21
+ add_action('bp_media_before_default_admin_widgets', array($this, 'usage_widget'));
22
+ }
23
+ add_action('admin_init', array($this, 'save_api_key'), 1);
24
+ add_filter('bp_media_add_admin_bar_item', array($this, 'admin_bar_menu'));
25
+ if ($this->api_key) {
26
+ $usage_info = bp_get_option('bp-media-encoding-usage');
27
+ if ($usage_info) {
28
+ if (isset($usage_info[$this->api_key]->status) && $usage_info[$this->api_key]->status) {
29
+ if (isset($usage_info[$this->api_key]->remaining) && $usage_info[$this->api_key]->remaining > 0) {
30
+ if ($usage_info[$this->api_key]->remaining < 524288000 && !bp_get_option('bp-media-encoding-usage-limit-mail'))
31
+ $this->nearing_usage_limit($usage_info);
32
+ elseif ($usage_info[$this->api_key]->remaining > 524288000 && bp_get_option('bp-media-encoding-usage-limit-mail'))
33
+ bp_update_option('bp-media-encoding-usage-limit-mail', 0);
34
+ if (!class_exists('BPMediaFFMPEG') && !class_exists('BPMediaKaltura'))
35
+ add_filter('bp_media_transcoder', array($this, 'transcoder'), 10, 2);
36
+ $blacklist = array('localhost', '127.0.0.1');
37
+ if (!in_array($_SERVER['HTTP_HOST'], $blacklist)) {
38
+ add_filter('bp_media_plupload_files_filter', array($this, 'allowed_types'));
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ if (!bp_get_option('bpmedia_encoding_service_notice') && current_user_can('administrator')) {
45
+ if (is_multisite()) {
46
+ add_action('network_admin_notices', array($this, 'encoding_service_notice'));
47
+ }
48
+ add_action('admin_notices', array($this, 'encoding_service_notice'));
49
+ }
50
+ add_action('bp_init', array($this, 'handle_callback'), 20);
51
+ add_action('wp_ajax_bp_media_free_encoding_subscribe', array($this, 'free_encoding_subscribe'));
52
+ add_action('wp_ajax_bp_media_unsubscribe_encoding_service', array($this, 'unsubscribe_encoding'));
53
+ add_action('wp_ajax_bp_media_hide_encoding_notice', array($this, 'hide_encoding_notice'), 1);
54
+ add_action('wp_ajax_bp_media_enter_api_key', array($this, 'enter_api_key'), 1);
55
+ add_action('wp_ajax_bp_media_disable_encoding', array($this, 'disable_encoding'), 1);
56
+ }
57
+
58
+ function transcoder($class, $type) {
59
+ switch ($type) {
60
+ case 'video':
61
+ case 'audio':
62
+ $blacklist = array('localhost', '127.0.0.1');
63
+ if (in_array($_SERVER['HTTP_HOST'], $blacklist)) {
64
+ return $class;
65
+ }
66
+
67
+ if (isset($_FILES['bp_media_file'])) {
68
+ $ext = end(explode(".", $_FILES['bp_media_file']["name"]));
69
+ if (in_array($_FILES['bp_media_file']['type'], array('audio/mp3', 'video/mp4')) || in_array($ext, array('mp3', 'mp4'))) {
70
+ return $class;
71
+ }
72
+ }
73
+ return 'BPMediaEncodingTranscoder';
74
+ default:
75
+ return $class;
76
+ }
77
+ }
78
+
79
+ public function menu() {
80
+ add_submenu_page('bp-media-settings', __('BuddyPress Media Audio/Video Encoding Service', 'buddypress-media'), __('Audio/Video Encoding', 'buddypress-media'), 'manage_options', 'bp-media-encoding', array($this, 'encoding_page'));
81
+ global $submenu;
82
+ $menu = $submenu['bp-media-settings'];
83
+ $encoding_menu = array_pop($menu);
84
+ $submenu['bp-media-settings'] = array_merge(array_slice($menu, 0, 1), array($encoding_menu), array_slice($menu, 1));
85
+ }
86
+
87
+ /**
88
+ * Render the BuddyPress Media Encoding page
89
+ */
90
+ public function encoding_page() {
91
+ global $bp_media_admin;
92
+ $bp_media_admin->render_page('bp-media-encoding');
93
+ }
94
+
95
+ public function encoding_settings() {
96
+ add_settings_section('bpm-encoding', __('Audio/Video Encoding Service', 'buddypress-media'), array($this, 'encoding_service_intro'), 'bp-media-encoding');
97
+ }
98
+
99
+ public function encoding_tab($tabs, $tab) {
100
+ $idle_class = 'nav-tab';
101
+ $active_class = 'nav-tab nav-tab-active';
102
+ $encoding_tab = array(
103
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-encoding'), 'admin.php')),
104
+ 'title' => __('BuddyPress Media Audio/Video Encoding Service', 'buddypress-media'),
105
+ 'name' => __('Audio/Video Encoding', 'buddypress-media'),
106
+ 'class' => ($tab == 'bp-media-encoding') ? $active_class : $idle_class . ' last_tab'
107
+ );
108
+ $reordered_tabs = NULL;
109
+ foreach ($tabs as $key => $tab) {
110
+ if ($key == 1)
111
+ $reordered_tabs[] = $encoding_tab;
112
+ $reordered_tabs[] = $tab;
113
+ }
114
+
115
+ return $reordered_tabs;
116
+ }
117
+
118
+ public function admin_bar_menu($bp_media_admin_nav) {
119
+ // Encoding Service
120
+ $admin_nav = array(
121
+ 'parent' => 'bp-media-menu',
122
+ 'id' => 'bp-media-encoding',
123
+ 'title' => __('Audio/Video Encoding', 'buddypress-media'),
124
+ 'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-encoding'), 'admin.php'))
125
+ );
126
+ $reordered_admin_nav = NULL;
127
+ foreach ($bp_media_admin_nav as $key => $nav) {
128
+ if ($key == 2)
129
+ $reordered_admin_nav[] = $admin_nav;
130
+ $reordered_admin_nav[] = $nav;
131
+ }
132
+ return $reordered_admin_nav;
133
+ }
134
+
135
+ public function is_valid_key($key) {
136
+ $validate_url = trailingslashit($this->api_url) . 'api/validate/' . $key;
137
+ $validation_page = wp_remote_get($validate_url, array('timeout' => 20));
138
+ if (!is_wp_error($validation_page)) {
139
+ $validation_info = json_decode($validation_page['body']);
140
+ $status = $validation_info->status;
141
+ } else {
142
+ $status = false;
143
+ }
144
+ return $status;
145
+ }
146
+
147
+ public function update_usage($key) {
148
+ $usage_url = trailingslashit($this->api_url) . 'api/usage/' . $key;
149
+ $usage_page = wp_remote_get($usage_url, array('timeout' => 20));
150
+ if (!is_wp_error($usage_page))
151
+ $usage_info = json_decode($usage_page['body']);
152
+ else
153
+ $usage_info = NULL;
154
+ bp_update_option('bp-media-encoding-usage', array($key => $usage_info));
155
+ return $usage_info;
156
+ }
157
+
158
+ public function nearing_usage_limit($usage_details) {
159
+ $subject = __('BuddyPress Media Encoding: Nearing quota limit.', 'buddypress-media');
160
+ $message = __('<p>You are nearing the quota limit for your BuddyPress Media encoding service.</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'buddypress-media');
161
+ $users = get_users(array('role' => 'administrator'));
162
+ if ($users) {
163
+ foreach ($users as $user)
164
+ $admin_email_ids[] = $user->user_email;
165
+ add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
166
+ wp_mail($admin_email_ids, $subject, sprintf($message, size_format($usage_details[$this->api_key]->used, 2), size_format($usage_details[$this->api_key]->remaining, 2), size_format($usage_details[$this->api_key]->total, 2)));
167
+ }
168
+ bp_update_option('bp-media-encoding-usage-limit-mail', 1);
169
+ }
170
+
171
+ public function usage_quota_over() {
172
+ $usage_details = bp_get_option('bp-media-encoding-usage');
173
+ if (!$usage_details[$this->api_key]->remaining) {
174
+ $subject = __('BuddyPress Media Encoding: Usage quota over.', 'buddypress-media');
175
+ $message = __('<p>Your usage quota is over. Upgrade your plan</p><p>Following are the details:</p><p><strong>Used:</strong> %s</p><p><strong>Remaining</strong>: %s</p><p><strong>Total:</strong> %s</p>', 'buddypress-media');
176
+ $users = get_users(array('role' => 'administrator'));
177
+ if ($users) {
178
+ foreach ($users as $user)
179
+ $admin_email_ids[] = $user->user_email;
180
+ add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
181
+ wp_mail($admin_email_ids, $subject, sprintf($message, size_format($usage_details[$this->api_key]->used, 2), 0, size_format($usage_details[$this->api_key]->total, 2)));
182
+ }
183
+ bp_update_option('bp-media-encoding-usage-limit-mail', 1);
184
+ }
185
+ }
186
+
187
+ public function save_api_key() {
188
+ if (isset($_GET['api_key_updated']) && $_GET['api_key_updated']) {
189
+ if (is_multisite()) {
190
+ add_action('network_admin_notices', array($this, 'successfully_subscribed_notice'));
191
+ }
192
+ add_action('admin_notices', array($this, 'successfully_subscribed_notice'));
193
+ }
194
+ if (isset($_GET['apikey']) && is_admin() && isset($_GET['page']) && ($_GET['page'] == 'bp-media-encoding') && $this->is_valid_key($_GET['apikey'])) {
195
+ if ($this->api_key && !(isset($_GET['update']) && $_GET['update'])) {
196
+ $unsubscribe_url = trailingslashit($this->api_url) . 'api/cancel/' . $this->api_key;
197
+ wp_remote_post($unsubscribe_url, array('timeout' => 120, 'body' => array('note' => 'Direct URL Input (API Key: ' . $_GET['apikey'] . ')')));
198
+ }
199
+ bp_update_option('bp-media-encoding-api-key', $_GET['apikey']);
200
+ $usage_info = $this->update_usage($_GET['apikey']);
201
+ $return_page = add_query_arg(array('page' => 'bp-media-encoding', 'api_key_updated' => $usage_info->plan->name), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php')));
202
+ wp_safe_redirect($return_page);
203
+ }
204
+ }
205
+
206
+ public function allowed_types($types) {
207
+ // $this->update_usage($this->api_key);
208
+ $types = array(); //Allow all types of file to be uploded
209
+ return $types;
210
+ }
211
+
212
+ public function encoding_service_notice() {
213
+ $link = add_query_arg(
214
+ array('page' => 'bp-media-encoding'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
215
+ )
216
+ ?>
217
+ <div class="updated">
218
+ <p><?php printf(__('We have launched a new Audio/Video encoding service for BuddyPress Media. You can <a href="%s">activate it for free</a>.', 'buddypress-media'), $link); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="bpm-hide-encoding-notice button-secondary" type="button" ><?php _e('Hide Message', 'buddypress-media') ?></button></p>
219
+ </div><?php
220
+ }
221
+
222
+ public function successfully_subscribed_notice() {
223
+ ?>
224
+ <div class="updated">
225
+ <p><?php printf(__('You have successfully subscribed for the <strong>%s</strong> plan', 'buddypress-media'), $_GET['api_key_updated']); ?></p>
226
+ </div><?php
227
+ }
228
+
229
+ public function encoding_subscription_form($name = 'No Name', $price = '0', $force = false) {
230
+ if ($this->api_key)
231
+ $this->update_usage($this->api_key);
232
+ $action = $this->sandbox_testing ? 'https://sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
233
+ $return_page = add_query_arg(array('page' => 'bp-media-encoding'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php')));
234
+
235
+ $usage_details = bp_get_option('bp-media-encoding-usage');
236
+ if (isset($usage_details[$this->api_key]->plan->name) && (strtolower($usage_details[$this->api_key]->plan->name) == strtolower($name)) && $usage_details[$this->api_key]->sub_status && !$force) {
237
+ $form = '<button data-plan="' . $name . '" data-price="' . $price . '" type="submit" class="button bpm-unsubscribe">' . __('Unsubscribe', 'buddypress-media') . '</button>';
238
+ $form .= '<div id="bpm-unsubscribe-dialog" title="Unsubscribe">
239
+ <p>Just to improve our service we would like to know the reason for you to leave us.</p>
240
+ <p><textarea rows="3" cols="36" id="bpm-unsubscribe-note"></textarea></p>
241
+ </div>';
242
+ } else {
243
+ $form = '<form method="post" action="' . $action . '" class="paypal-button" target="_top">
244
+ <input type="hidden" name="button" value="subscribe">
245
+ <input type="hidden" name="item_name" value="' . ucfirst($name) . '">
246
+
247
+ <input type="hidden" name="currency_code" value="USD">
248
+
249
+
250
+ <input type="hidden" name="a3" value="' . $price . '">
251
+ <input type="hidden" name="p3" value="1">
252
+ <input type="hidden" name="t3" value="M">
253
+
254
+ <input type="hidden" name="cmd" value="_xclick-subscriptions">
255
+
256
+ <!-- Merchant ID -->
257
+ <input type="hidden" name="business" value="' . $this->merchant_id . '">
258
+
259
+
260
+ <input type="hidden" name="custom" value="' . $return_page . '">
261
+
262
+ <!-- Flag to no shipping -->
263
+ <input type="hidden" name="no_shipping" value="1">
264
+
265
+ <input type="hidden" name="notify_url" value="' . trailingslashit($this->api_url) . 'subscribe/paypal">
266
+
267
+ <!-- Flag to post payment return url -->
268
+ <input type="hidden" name="return" value="' . trailingslashit($this->api_url) . 'payment/process">
269
+
270
+
271
+ <!-- Flag to post payment data to given return url -->
272
+ <input type="hidden" name="rm" value="2">
273
+
274
+ <input type="hidden" name="src" value="1">
275
+ <input type="hidden" name="sra" value="1">
276
+
277
+ <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_SM.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">
278
+ </form>';
279
+ }
280
+ return $form;
281
+ }
282
+
283
+ public function usage_widget() {
284
+ $usage_details = bp_get_option('bp-media-encoding-usage');
285
+ $content = '';
286
+ if ($usage_details && isset($usage_details[$this->api_key]->status) && $usage_details[$this->api_key]->status) {
287
+ if (isset($usage_details[$this->api_key]->plan->name))
288
+ $content .= '<p><strong>' . __('Current Plan', 'buddypress-media') . ':</strong> ' . $usage_details[$this->api_key]->plan->name . ($usage_details[$this->api_key]->sub_status ? '' : ' (' . __('Unsubscribed', 'buddypress-media') . ')') . '</p>';
289
+ if (isset($usage_details[$this->api_key]->used))
290
+ $content .= '<p><span class="encoding-used"></span><strong>' . __('Used', 'buddypress-media') . ':</strong> ' . (($used_size = size_format($usage_details[$this->api_key]->used, 2)) ? $used_size : '0MB') . '</p>';
291
+ if (isset($usage_details[$this->api_key]->remaining))
292
+ $content .= '<p><span class="encoding-remaining"></span><strong>' . __('Remaining', 'buddypress-media') . ':</strong> ' . (($remaining_size = size_format($usage_details[$this->api_key]->remaining, 2)) ? $remaining_size : '0MB') . '</p>';
293
+ if (isset($usage_details[$this->api_key]->total))
294
+ $content .= '<p><strong>' . __('Total', 'buddypress-media') . ':</strong> ' . size_format($usage_details[$this->api_key]->total, 2) . '</p>';
295
+ $usage = new rtProgress();
296
+ $content .= $usage->progress_ui($usage->progress($usage_details[$this->api_key]->used, $usage_details[$this->api_key]->total), false);
297
+ if ($usage_details[$this->api_key]->remaining <= 0)
298
+ $content .= '<div class="error below-h2"><p>' . __('Your usage limit has been reached. Upgrade your plan.', 'buddypress-media') . '</p></div>';
299
+ } else {
300
+ $content .= '<div class="error below-h2"><p>' . __('Your API key is not valid or is expired.', 'buddypress-media') . '</p></div>';
301
+ }
302
+ new BPMediaAdminWidget('bp-media-encoding-usage', __('Encoding Usage', 'buddypress-media'), $content);
303
+ }
304
+
305
+ public function encoding_service_intro() {
306
+ ?>
307
+ <p><?php _e('BuddyPress Media team has started offering an audio/video encoding service.', 'buddypress-media'); ?></p>
308
+ <p>
309
+ <label for="new-api-key"><?php _e('Enter API KEY', 'buddypress-media'); ?></label>
310
+ <input id="new-api-key" type="text" name="new-api-key" value="<?php echo $this->api_key; ?>" size="60" />
311
+ <input type="submit" id="api-key-submit" name="api-key-submit" value="Submit" class="button-primary" />
312
+ <?php if ($this->api_key) { ?><br /><br /><input type="submit" id="disable-encoding" name="disable-encoding" value="Disable Encoding" class="button-secondary" /><?php } ?>
313
+ </p>
314
+ <table class="bp-media-encoding-table widefat fixed" cellspacing="0">
315
+ <tbody>
316
+ <!-- Results table headers -->
317
+ <thead>
318
+ <tr>
319
+ <th><?php _e('Feature\Plan', 'buddypress-media'); ?></th>
320
+ <th><?php _e('Free', 'buddypress-media'); ?></th>
321
+ <th><?php _e('Silver', 'buddypress-media'); ?></th>
322
+ <th><?php _e('Gold', 'buddypress-media'); ?></th>
323
+ <th><?php _e('Platinum', 'buddypress-media'); ?></th>
324
+ </tr>
325
+ </thead>
326
+ <tr>
327
+ <th><?php _e('File Size Limit', 'buddypress-media'); ?></th>
328
+ <td>20MB</td>
329
+ <td>2GB</td>
330
+ <td>2GB</td>
331
+ <td>2GB</td>
332
+ </tr>
333
+ <tr>
334
+ <th><?php _e('Bandwidth (monthly)', 'buddypress-media'); ?></th>
335
+ <td>1GB</td>
336
+ <td>100GB</td>
337
+ <td>1TB</td>
338
+ <td>10TB</td>
339
+ </tr>
340
+ <tr>
341
+ <th><?php _e('Overage Bandwidth', 'buddypress-media'); ?></th>
342
+ <td><?php _e('Not Available', 'buddypress-media'); ?></td>
343
+ <td>$0.10 per GB</td>
344
+ <td>$0.08 per GB</td>
345
+ <td>$0.05 per GB</td>
346
+ </tr>
347
+ <tr>
348
+ <th><?php _e('Amazon S3 Support', 'buddypress-media'); ?></th>
349
+ <td><?php _e('Not Available', 'buddypress-media'); ?></td>
350
+ <td colspan="3" class="column-posts"><?php _e('Coming Soon', 'buddypress-media'); ?></td>
351
+ </tr>
352
+ <tr>
353
+ <th><?php _e('HD Profile', 'buddypress-media'); ?></th>
354
+ <td><?php _e('Not Available', 'buddypress-media'); ?></td>
355
+ <td colspan="3" class="column-posts"><?php _e('Coming Soon', 'buddypress-media'); ?></td>
356
+ </tr>
357
+ <tr>
358
+ <th><?php _e('Webcam Recording', 'buddypress-media'); ?></th>
359
+ <td colspan="4" class="column-posts"><?php _e('Coming Soon', 'buddypress-media'); ?></td>
360
+ </tr>
361
+ <tr>
362
+ <th><?php _e('Pricing', 'buddypress-media'); ?></th>
363
+ <td><?php _e('Free', 'buddypress-media'); ?></td>
364
+ <td><?php _e('$9/month', 'buddypress-media'); ?></td>
365
+ <td><?php _e('$99/month', 'buddypress-media'); ?></td>
366
+ <td><?php _e('$999/month', 'buddypress-media'); ?></td>
367
+ </tr>
368
+ <tr>
369
+ <th></th>
370
+ <td><?php
371
+ $usage_details = bp_get_option('bp-media-encoding-usage');
372
+ if (isset($usage_details[$this->api_key]->plan->name) && (strtolower($usage_details[$this->api_key]->plan->name) == 'free')) {
373
+ echo '<button disabled="disabled" type="submit" class="encoding-try-now button button-primary">' . __('Current Plan', 'buddypress-media') . '</button>';
374
+ } else {
375
+ ?>
376
+ <form id="encoding-try-now-form" method="get" action="">
377
+ <button type="submit" class="encoding-try-now button button-primary"><?php _e('Try Now', 'buddypress-media'); ?></button>
378
+ </form><?php }
379
+ ?>
380
+ </td>
381
+ <td><?php echo $this->encoding_subscription_form('silver', 9.0) ?></td>
382
+ <td><?php echo $this->encoding_subscription_form('gold', 99.0) ?></td>
383
+ <td><?php echo $this->encoding_subscription_form('platinum', 999.0) ?></td>
384
+ </tr>
385
+ </tbody>
386
+ </table><br /><?php
387
+ }
388
+
389
+ /**
390
+ * Function to handle the callback request by the FFMPEG encoding server
391
+ *
392
+ * @since 1.0
393
+ */
394
+ public function handle_callback() {
395
+ if (isset($_GET['job_id']) && isset($_GET['download_url'])) {
396
+ $flag = false;
397
+ global $wpdb, $bp_media_counter;
398
+ $query_string =
399
+ "SELECT $wpdb->postmeta.post_id
400
+ FROM $wpdb->postmeta
401
+ WHERE $wpdb->postmeta.meta_key = 'bp-media-encoding-job-id'
402
+ AND $wpdb->postmeta.meta_value='" . $_GET['job_id'] . "' ORDER BY post_id";
403
+ $result = $wpdb->get_results($query_string);
404
+ if (is_array($result) && count($result) > 0) {
405
+ $attachment_id = $result[0]->post_id;
406
+ $download_url = urldecode($_GET['download_url']);
407
+ $new_wp_attached_file_pathinfo = pathinfo($download_url);
408
+ $post_mime_type = $new_wp_attached_file_pathinfo['extension'] == 'mp4' ? 'video/mp4' : 'audio/mp3';
409
+ try {
410
+ $file_bits = file_get_contents($download_url);
411
+ } catch (Exception $e) {
412
+ $flag = $e->getMessage();
413
+ error_log($flag);
414
+ }
415
+ if ($file_bits) {
416
+ unlink(get_attached_file($attachment_id));
417
+ $upload_info = wp_upload_bits($new_wp_attached_file_pathinfo['basename'], null, $file_bits);
418
+ $wpdb->update($wpdb->posts, array('guid' => $upload_info['url'], 'post_mime_type' => $post_mime_type), array('ID' => $attachment_id));
419
+ $old_wp_attached_file = get_post_meta($attachment_id, '_wp_attached_file', true);
420
+ $old_wp_attached_file_pathinfo = pathinfo($old_wp_attached_file);
421
+ update_post_meta($attachment_id, '_wp_attached_file', str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $old_wp_attached_file));
422
+ $media_entry = new BPMediaHostWordpress($attachment_id);
423
+ $activity_content = str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $media_entry->get_media_activity_content());
424
+ $wpdb->update($wpdb->prefix . 'bp_activity', array('content' => $activity_content), array('id' => get_post_meta($attachment_id, 'bp_media_child_activity', true)));
425
+ // Check if uplaod is through activity upload
426
+ $activity_id = get_post_meta($attachment_id, 'bp-media-activity-upload-id', true);
427
+ if ($activity_id) {
428
+ $content = $wpdb->get_var("SELECT content FROM {$wpdb->prefix}bp_activity WHERE id = $activity_id");
429
+ $activity_content = str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $content);
430
+ $wpdb->update($wpdb->prefix . 'bp_activity', array('content' => $activity_content), array('id' => $activity_id));
431
+ }
432
+ } else {
433
+ $flag = __('Could not read file.', 'buddypress-media');
434
+ error_log($flag);
435
+ }
436
+ } else {
437
+ $flag = __('Something went wrong. The required attachment id does not exists. It must have been deleted.', 'buddypress-media');
438
+ error_log($flag);
439
+ }
440
+
441
+
442
+ $this->update_usage($this->api_key);
443
+
444
+ if (isset($_SERVER['REMOTE_ADDR']) && ($_SERVER['REMOTE_ADDR'] == '4.30.110.155')) {
445
+ $mail = true;
446
+ } else {
447
+ $mail = false;
448
+ }
449
+
450
+ if ($flag && $mail) {
451
+ $download_link = add_query_arg(array('job_id' => $_GET['job_id'], 'download_url' => $_GET['download_url']), home_url());
452
+ $subject = __('BuddyPress Media Encoding: Download Failed', 'buddypress-media');
453
+ $message = sprintf(__('<p><a href="%s">Media</a> was successfully encoded but there was an error while downloading:</p>
454
+ <p><code>%s</code></p>
455
+ <p>You can <a href="%s">retry the download</a>.</p>', 'buddypress-media'), get_edit_post_link($attachment_id), $flag, $download_link);
456
+ $users = get_users(array('role' => 'administrator'));
457
+ if ($users) {
458
+ foreach ($users as $user)
459
+ $admin_email_ids[] = $user->user_email;
460
+ add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
461
+ wp_mail($admin_email_ids, $subject, $message);
462
+ }
463
+ _e($flag);
464
+ } elseif ($flag) {
465
+ _e($flag);
466
+ } else {
467
+ _e("Done", 'buddypress-media');
468
+ }
469
+ die();
470
+ }
471
+ }
472
+
473
+ public function free_encoding_subscribe() {
474
+ $email = bp_get_option('admin_email');
475
+ $usage_details = bp_get_option('bp-media-encoding-usage');
476
+ if (isset($usage_details[$this->api_key]->plan->name) && (strtolower($usage_details[$this->api_key]->plan->name) == 'free')) {
477
+ echo json_encode(array('error' => 'Your free subscription is already activated.'));
478
+ } else {
479
+ $free_subscription_url = add_query_arg(array('email' => urlencode($email)), trailingslashit($this->api_url) . 'api/free/');
480
+ if ($this->api_key) {
481
+ $free_subscription_url = add_query_arg(array('email' => urlencode($email), 'apikey' => $this->api_key), $free_subscription_url);
482
+ }
483
+ $free_subscribe_page = wp_remote_get($free_subscription_url, array('timeout' => 120));
484
+ if (!is_wp_error($free_subscribe_page) && (!isset($free_subscribe_page['headers']['status']) || (isset($free_subscribe_page['headers']['status']) && ($free_subscribe_page['headers']['status'] == 200)))) {
485
+ $subscription_info = json_decode($free_subscribe_page['body']);
486
+ if (isset($subscription_info->status) && $subscription_info->status) {
487
+ echo json_encode(array('apikey' => $subscription_info->apikey));
488
+ } else {
489
+ echo json_encode(array('error' => $subscription_info->message));
490
+ }
491
+ } else {
492
+ echo json_encode(array('error' => 'Something went wrong please try again.'));
493
+ }
494
+ }
495
+ die();
496
+ }
497
+
498
+ public function hide_encoding_notice() {
499
+ bp_update_option('bpmedia_encoding_service_notice', true);
500
+ echo true;
501
+ die();
502
+ }
503
+
504
+ public function unsubscribe_encoding() {
505
+ $unsubscribe_url = trailingslashit($this->api_url) . 'api/cancel/' . $this->api_key;
506
+ $unsubscribe_page = wp_remote_post($unsubscribe_url, array('timeout' => 120, 'body' => array('note' => $_GET['note'])));
507
+ if (!is_wp_error($unsubscribe_page) && (!isset($unsubscribe_page['headers']['status']) || (isset($unsubscribe_page['headers']['status']) && ($unsubscribe_page['headers']['status'] == 200)))) {
508
+ $subscription_info = json_decode($unsubscribe_page['body']);
509
+ if (isset($subscription_info->status) && $subscription_info->status) {
510
+ echo json_encode(array('updated' => __('Your subscription was cancelled successfully', 'buddypress-media'), 'form' => $this->encoding_subscription_form($_GET['plan'], $_GET['price'])));
511
+ }
512
+ } else {
513
+ echo json_encode(array('error' => __('Something went wrong please try again.', 'buddypress-media')));
514
+ }
515
+ die();
516
+ }
517
+
518
+ public function enter_api_key() {
519
+ if (isset($_GET['apikey'])) {
520
+ echo json_encode(array('apikey' => $_GET['apikey']));
521
+ } else {
522
+ echo json_encode(array('error' => __('Please enter the api key.', 'buddypress-media')));
523
+ }
524
+ die();
525
+ }
526
+
527
+ public function disable_encoding() {
528
+ bp_update_option('bp-media-encoding-api-key', '');
529
+ _e('Encoding disabled successfully.', 'buddypress-media');
530
+ die();
531
+ }
532
+
533
+ }
534
+ ?>
app/services/BPMediaEncodingTranscoder.php ADDED
@@ -0,0 +1,146 @@
1
+ <?php
2
+
3
+ /**
4
+ * Class extends the add_media functionality of BPMediaHostWordpress to send
5
+ * the file to the rtCamp Transcoding server instead of making it as attachment.
6
+ */
7
+ class BPMediaEncodingTranscoder extends BPMediaHostWordpress {
8
+
9
+
10
+ public function insert_media($name, $description, $album_id = 0, $group = 0, $is_multiple = false, $is_activity = false, $files = false, $author_id = false, $album_name = false) {
11
+ do_action('bp_media_before_add_media');
12
+ include_once(ABSPATH . 'wp-admin/includes/file.php');
13
+ include_once(ABSPATH . 'wp-admin/includes/image.php');
14
+ global $bp_media_admin;
15
+
16
+ if (!$author_id)
17
+ $author_id = get_current_user_id();
18
+
19
+ $post_id = $this->check_and_create_album($album_id, $group, $author_id, $album_name);
20
+ if (!$files) {
21
+ $files = $parent_fallback_files = $_FILES['bp_media_file'];
22
+ $file = wp_handle_upload($files);
23
+ } else {
24
+ $parent_fallback_files = $files;
25
+ $ext = end(explode(".", $files["name"]));
26
+ if ( in_array($files['type'],array('audio/mp3','video/mp4') ) || in_array($ext, array('mp3','mp4'))){
27
+ return parent::insert_media($name, $description, $album_id, $group, $is_multiple, $is_activity, $parent_fallback_files, $author_id, $album_name);
28
+ }
29
+ $file = wp_handle_sideload($files, array('test_form' => false));
30
+ }
31
+
32
+ $parent_fallback_files['tmp_name'] = $file['file'];
33
+
34
+ if (isset($file['error']) || $file === null) {
35
+ throw new Exception(__('Error Uploading File', 'buddypress-media'));
36
+ }
37
+
38
+ $type = $file['type'];
39
+ if (!preg_match('/video|audio/i', $type, $result)) {
40
+ throw new Exception(__('Upload file type not supported', BP_MEDIA_FFMPEG_TXT_DOMAIN));
41
+ }
42
+
43
+ $attachment = array();
44
+ $url = $file['url'];
45
+ $file = $file['file'];
46
+ $title = $name;
47
+ $content = $description;
48
+
49
+ $api_key = bp_get_option('bp-media-encoding-api-key');
50
+
51
+ $query_args = array('url' => urlencode($url),
52
+ 'callbackurl' => urlencode(home_url()),
53
+ 'force' => 0,
54
+ 'size' => filesize($file),
55
+ 'formats' => ($result[0] == 'video')?'mp4':'mp3');
56
+ $encoding_url = 'http://api.rtcamp.com/job/new/';
57
+
58
+ $upload_url = add_query_arg($query_args, $encoding_url . $api_key);
59
+ $upload_page = wp_remote_get($upload_url,array('timeout'=>20));
60
+ if (!is_wp_error($upload_page) && (!isset($upload_page['headers']['status']) || (isset($upload_page['headers']['status']) && ($upload_page['headers']['status'] == 200)))) {
61
+ $upload_info = json_decode($upload_page['body']);
62
+ if (isset($upload_info->status) && $upload_info->status && isset($upload_info->job_id)&&$upload_info->job_id) {
63
+ $job_id = $upload_info->job_id;
64
+ } else {
65
+ $bp_media_admin->bp_media_encoding->update_usage($bp_media_admin->bp_media_encoding->api_key);
66
+ $bp_media_admin->bp_media_encoding->usage_quota_over();
67
+ remove_filter('bp_media_plupload_files_filter', array($bp_media_admin->bp_media_encoding, 'allowed_types'));
68
+ return parent::insert_media($name, $description, $album_id, $group, $is_multiple, $is_activity, $parent_fallback_files, $author_id, $album_name);
69
+ }
70
+ }
71
+
72
+ $attachment = array(
73
+ 'post_mime_type' => $type,
74
+ 'guid' => $url,
75
+ 'post_title' => $title,
76
+ 'post_content' => $content,
77
+ 'post_parent' => $post_id,
78
+ );
79
+
80
+ $attachment_id = wp_insert_attachment($attachment, $file, $post_id);
81
+ if (!is_wp_error($attachment_id)) {
82
+ update_post_meta($attachment_id, 'bp-media-encoding-job-id', $job_id);
83
+ add_filter('intermediate_image_sizes', array($this, 'bp_media_image_sizes'), 99);
84
+ wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file));
85
+ } else {
86
+ unlink($file);
87
+ throw new Exception(__('Error creating attachment for the media file, please try again', 'buddypress-media'));
88
+ }
89
+ $this->id = $attachment_id;
90
+ $this->name = $name;
91
+ $this->description = $description;
92
+ $this->type = $result[0];
93
+ $this->owner = $author_id;
94
+ $this->album_id = $post_id;
95
+ $this->group_id = $group;
96
+ $this->set_permalinks();
97
+ if ($group == 0) {
98
+ update_post_meta($attachment_id, 'bp-media-key', $author_id);
99
+ } else {
100
+ update_post_meta($attachment_id, 'bp-media-key', (-$group));
101
+ }
102
+
103
+ $bp_media_admin->bp_media_encoding->update_usage($bp_media_admin->bp_media_encoding->api_key);
104
+ // update_post_meta( $attachment_id, 'bp_media_privacy', 6 );
105
+ // $this->pre_update_count();
106
+ do_action('bp_media_after_add_media', $this, $is_multiple, $is_activity, $group);
107
+ return $attachment_id;
108
+ }
109
+
110
+ function pre_update_count() {
111
+ global $bp;
112
+ $user_id = $bp->loggedin_user->id;
113
+ global $wpdb;
114
+ $formatted = array();
115
+ $query =
116
+ "SELECT
117
+ SUM(CASE WHEN post_mime_type LIKE 'image%' THEN 1 ELSE 0 END) as Images,
118
+ SUM(CASE WHEN post_mime_type LIKE 'audio%' THEN 1 ELSE 0 END) as Audio,
119
+ SUM(CASE WHEN post_mime_type LIKE 'video%' THEN 1 ELSE 0 END) as Videos,
120
+ SUM(CASE WHEN post_type LIKE 'bp_media_album' THEN 1 ELSE 0 END) as Albums
121
+ FROM
122
+ $wpdb->posts p inner join $wpdb->postmeta pm on pm.post_id = p.id INNER JOIN $wpdb->postmeta pmp
123
+ on pmp.post_id = p.id WHERE
124
+ p.post_author = $user_id AND
125
+ pm.meta_key = 'bp-media-key' AND
126
+ pm.meta_value > 0 AND
127
+ pmp.meta_key = 'bp_media_privacy' AND
128
+ ( post_mime_type LIKE 'image%' OR post_mime_type LIKE 'audio%' OR post_mime_type LIKE 'video%' OR post_type LIKE 'bp_media_album')
129
+ GROUP BY pmp.meta_value";
130
+ $result = $wpdb->get_results($query);
131
+ if (!is_array($result))
132
+ return false;
133
+ foreach ($result as $level => $obj) {
134
+ $formatted[$level * 2] = array(
135
+ 'image' => $obj->Images,
136
+ 'video' => $obj->Videos,
137
+ 'audio' => $obj->Audio,
138
+ 'album' => $obj->Albums,
139
+ );
140
+ }
141
+ bp_update_user_meta($user_id, 'bp_media_count', $formatted);
142
+ }
143
+
144
+ }
145
+
146
+ ?>
index.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: BuddyPress Media
4
Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
5
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
6
- Version: 2.12.1
7
Author: rtCamp
8
Text Domain: buddypress-media
9
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
@@ -43,6 +43,7 @@ if ( ! defined( 'BP_MEDIA_URL' ) ){
43
*/
44
function buddypress_media_autoloader( $class_name ) {
45
$rtlibpath = array(
46
'app/helper/' . $class_name . '.php',
47
'app/admin/' . $class_name . '.php',
48
'app/main/' . $class_name . '.php',
3
Plugin Name: BuddyPress Media
4
Plugin URI: http://rtcamp.com/buddypress-media/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
5
Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously!
6
+ Version: 2.13.1
7
Author: rtCamp
8
Text Domain: buddypress-media
9
Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
43
*/
44
function buddypress_media_autoloader( $class_name ) {
45
$rtlibpath = array(
46
+ 'app/services/' . $class_name . '.php',
47
'app/helper/' . $class_name . '.php',
48
'app/admin/' . $class_name . '.php',
49
'app/main/' . $class_name . '.php',
languages/buddypress-media-ar_AR.mo CHANGED
Binary file
languages/buddypress-media-de_DE.mo CHANGED
Binary file
languages/buddypress-media-es_ES.mo CHANGED
Binary file
languages/buddypress-media-fa_IR.mo CHANGED
Binary file
languages/buddypress-media-fr_FR.mo CHANGED
Binary file
languages/buddypress-media-it_IT.mo CHANGED
Binary file
languages/buddypress-media-ja_JA.mo CHANGED
Binary file
languages/buddypress-media-nl_NL.mo CHANGED
Binary file
languages/buddypress-media-pl_PL.mo CHANGED
Binary file
languages/buddypress-media-pt_BR.mo CHANGED
Binary file
languages/buddypress-media-ro_RO.mo CHANGED
Binary file
languages/buddypress-media-sr_SR.mo CHANGED
Binary file
languages/buddypress-media.mo CHANGED
Binary file
languages/buddypress-media.po CHANGED
@@ -2,9 +2,9 @@ msgid ""
2
msgstr ""
3
"Project-Id-Version: BuddyPress Media\n"
4
"Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-05-06 17:23+0530\n"
6
- "PO-Revision-Date: 2013-05-06 17:23+0530\n"
7
- "Last-Translator: Saurabh Shukla <saurabh.shukla@rtcamp.com>\n"
8
"Language-Team: rtCamp <info@rtcamp.com>\n"
9
"Language: en_IN\n"
10
"MIME-Version: 1.0\n"
@@ -15,6 +15,174 @@ msgstr ""
15
"X-Generator: Poedit 1.5.4\n"
16
"X-Poedit-SearchPath-0: .\n"
17