Version Description
- Fixes automatic count update.
- Fixes other bugs in Privacy Update.
Download this release
Release Info
Developer | saurabhshukla |
Plugin | rtMedia for WordPress, BuddyPress and bbPress |
Version | 2.6.6 |
Comparing to | |
See all releases |
Code changes from version 2.6.5 to 2.6.6
- app/admin/BPMediaAdmin.php +9 -7
- app/assets/css/main.css +1 -0
- app/helper/BPMediaSettings.php +3 -2
- app/helper/BPMediaSupport.php +57 -1
- app/main/BuddyPressMedia.php +632 -633
- app/main/group/BPMediaGroupAction.php +46 -0
- app/main/group/BPMediaGroupsExtension.php +8 -8
- app/main/includes/BPMediaActions.php +24 -42
- app/main/includes/BPMediaHostWordpress.php +3 -3
- app/main/privacy/BPMediaPrivacy.php +30 -19
- app/main/privacy/BPMediaPrivacySettings.php +13 -15
- app/main/profile/BPMediaAlbum.php +14 -0
- app/main/profile/BPMediaAlbumScreen.php +3 -1
- app/main/profile/BPMediaUploadScreen.php +1 -1
- app/main/query/BPMediaQuery.php +7 -3
- index.php +1 -1
- readme.txt +5 -2
app/admin/BPMediaAdmin.php
CHANGED
@@ -14,16 +14,17 @@ if (!class_exists('BPMediaAdmin')) {
|
|
14 |
|
15 |
public $bp_media_upgrade;
|
16 |
public $bp_media_settings;
|
|
|
17 |
public $bp_media_feed;
|
18 |
|
19 |
public function __construct() {
|
20 |
add_action('init',array($this, 'video_transcoding_survey_response'));
|
21 |
$bp_media_feed = new BPMediaFeed();
|
22 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
23 |
-
$bp_media_support = new BPMediaSupport();
|
24 |
-
add_action('wp_ajax_bp_media_select_request', array($bp_media_support, 'get_form'), 1);
|
25 |
add_action('wp_ajax_bp_media_cancel_request', create_function('', 'do_settings_sections("bp-media-support"); die();'), 1);
|
26 |
-
add_action('wp_ajax_bp_media_submit_request', array($bp_media_support, 'submit_request'), 1);
|
27 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
28 |
add_action('wp_ajax_bp_media_linkback', array($this, 'linkback'), 1);
|
29 |
add_action('wp_ajax_bp_media_convert_videos_form', array($this, 'convert_videos_mailchimp_send'), 1);
|
@@ -51,12 +52,12 @@ if (!class_exists('BPMediaAdmin')) {
|
|
51 |
*/
|
52 |
public function ui($hook) {
|
53 |
$admin_ajax = admin_url('admin-ajax.php');
|
54 |
-
wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js', '',
|
55 |
wp_localize_script('bp-media-admin', 'bp_media_admin_ajax', $admin_ajax);
|
56 |
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
|
57 |
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
58 |
) . '#privacy_enabled');
|
59 |
-
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '',
|
60 |
}
|
61 |
|
62 |
/**
|
@@ -162,6 +163,7 @@ if (!class_exists('BPMediaAdmin')) {
|
|
162 |
</div>
|
163 |
</div><!-- .metabox-holder -->
|
164 |
</div><!-- .bp-media-admin --><?php
|
|
|
165 |
}
|
166 |
|
167 |
/**
|
@@ -227,7 +229,7 @@ if (!class_exists('BPMediaAdmin')) {
|
|
227 |
'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
|
228 |
'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
|
229 |
);
|
230 |
-
|
231 |
if ( bp_get_option('bp-media-survey', true) ) {
|
232 |
$tabs[] = array(
|
233 |
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-convert-videos'), 'admin.php')),
|
@@ -392,7 +394,7 @@ if (!class_exists('BPMediaAdmin')) {
|
|
392 |
echo 'Thank you for your time.';
|
393 |
die;
|
394 |
}
|
395 |
-
|
396 |
public function video_transcoding_survey_response(){
|
397 |
if ( isset($_GET['survey-done']) && ($_GET['survey-done'] == md5('survey-done')) ) {
|
398 |
bp_update_option('bp-media-survey', 0);
|
14 |
|
15 |
public $bp_media_upgrade;
|
16 |
public $bp_media_settings;
|
17 |
+
public $bp_media_support;
|
18 |
public $bp_media_feed;
|
19 |
|
20 |
public function __construct() {
|
21 |
add_action('init',array($this, 'video_transcoding_survey_response'));
|
22 |
$bp_media_feed = new BPMediaFeed();
|
23 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
24 |
+
$this->bp_media_support = new BPMediaSupport();
|
25 |
+
add_action('wp_ajax_bp_media_select_request', array($this->bp_media_support, 'get_form'), 1);
|
26 |
add_action('wp_ajax_bp_media_cancel_request', create_function('', 'do_settings_sections("bp-media-support"); die();'), 1);
|
27 |
+
add_action('wp_ajax_bp_media_submit_request', array($this->bp_media_support, 'submit_request'), 1);
|
28 |
add_action('wp_ajax_bp_media_fetch_feed', array($bp_media_feed, 'fetch_feed'), 1);
|
29 |
add_action('wp_ajax_bp_media_linkback', array($this, 'linkback'), 1);
|
30 |
add_action('wp_ajax_bp_media_convert_videos_form', array($this, 'convert_videos_mailchimp_send'), 1);
|
52 |
*/
|
53 |
public function ui($hook) {
|
54 |
$admin_ajax = admin_url('admin-ajax.php');
|
55 |
+
wp_enqueue_script('bp-media-admin', BP_MEDIA_URL . 'app/assets/js/admin.js', '', BP_MEDIA_VERSION);
|
56 |
wp_localize_script('bp-media-admin', 'bp_media_admin_ajax', $admin_ajax);
|
57 |
wp_localize_script('bp-media-admin', 'settings_url', add_query_arg(
|
58 |
array('page' => 'bp-media-settings'), (is_multisite() ? network_admin_url('admin.php') : admin_url('admin.php'))
|
59 |
) . '#privacy_enabled');
|
60 |
+
wp_enqueue_style('bp-media-admin', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION);
|
61 |
}
|
62 |
|
63 |
/**
|
163 |
</div>
|
164 |
</div><!-- .metabox-holder -->
|
165 |
</div><!-- .bp-media-admin --><?php
|
166 |
+
do_action( 'bp_media_admin_page_append', $page );
|
167 |
}
|
168 |
|
169 |
/**
|
229 |
'name' => __('Support', BP_MEDIA_TXT_DOMAIN),
|
230 |
'class' => ($tab == 'bp-media-support') ? $active_class : $idle_class . ' last_tab'
|
231 |
);
|
232 |
+
|
233 |
if ( bp_get_option('bp-media-survey', true) ) {
|
234 |
$tabs[] = array(
|
235 |
'href' => bp_get_admin_url(add_query_arg(array('page' => 'bp-media-convert-videos'), 'admin.php')),
|
394 |
echo 'Thank you for your time.';
|
395 |
die;
|
396 |
}
|
397 |
+
|
398 |
public function video_transcoding_survey_response(){
|
399 |
if ( isset($_GET['survey-done']) && ($_GET['survey-done'] == md5('survey-done')) ) {
|
400 |
bp_update_option('bp-media-survey', 0);
|
app/assets/css/main.css
CHANGED
@@ -105,6 +105,7 @@ li #bp-media-uploaded-files{left: 0;position: absolute;top: 155px;}
|
|
105 |
#adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
|
106 |
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
|
107 |
#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%;}
|
|
|
108 |
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
|
109 |
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
|
110 |
.metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left 4px no-repeat; padding-left: 26px;}
|
105 |
#adminmenu li.current.toplevel_page_bp-media-settings .wp-menu-image a{background-position: center 1px;}
|
106 |
#adminmenu li.toplevel_page_bp-media-settings .wp-menu-image a img{display:none;}
|
107 |
#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%;}
|
108 |
+
#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;}
|
109 |
.nav-tab-wrapper a#bp-media{background:url('../img/bpm-icon-32.png') transparent no-repeat; padding-left:32px;}
|
110 |
.nav-tab-wrapper a#bp-media:hover,.nav-tab-wrapper a#bp-media.nav-tab-active{background-position:left -32px;}
|
111 |
.metabox-holder .postbox#latest-news .inside ul li{background: transparent url('../img/rtCamp-bullet.png') left 4px no-repeat; padding-left: 26px;}
|
app/helper/BPMediaSettings.php
CHANGED
@@ -29,7 +29,7 @@ if (!class_exists('BPMediaSettings')) {
|
|
29 |
* @global BPMediaAddon $bp_media_addon
|
30 |
*/
|
31 |
public function settings() {
|
32 |
-
global $bp_media_addon;
|
33 |
add_settings_section('bpm-media-type', __('Activate BuddyPress Media', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
|
34 |
// add_settings_field('bpm-admin-profile', __('User profiles', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-media-type', array(
|
35 |
// 'setting' => 'bp_media_options',
|
@@ -72,6 +72,7 @@ if (!class_exists('BPMediaSettings')) {
|
|
72 |
'option' => 'download_enabled',
|
73 |
'desc' => __('Display download button under media', BP_MEDIA_TXT_DOMAIN)
|
74 |
));
|
|
|
75 |
if (BPMediaPrivacy::is_installed()) {
|
76 |
add_settings_section('bpm-privacy', __('Privacy', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
|
77 |
add_settings_field('bpm-privacy-enabled', __('Enable Privacy', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-privacy', array(
|
@@ -188,7 +189,7 @@ if (!class_exists('BPMediaSettings')) {
|
|
188 |
}
|
189 |
delete_site_option('bpm-settings-saved');
|
190 |
}
|
191 |
-
|
192 |
/**
|
193 |
* Sanitizes the settings
|
194 |
*/
|
29 |
* @global BPMediaAddon $bp_media_addon
|
30 |
*/
|
31 |
public function settings() {
|
32 |
+
global $bp_media, $bp_media_addon;
|
33 |
add_settings_section('bpm-media-type', __('Activate BuddyPress Media', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
|
34 |
// add_settings_field('bpm-admin-profile', __('User profiles', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-media-type', array(
|
35 |
// 'setting' => 'bp_media_options',
|
72 |
'option' => 'download_enabled',
|
73 |
'desc' => __('Display download button under media', BP_MEDIA_TXT_DOMAIN)
|
74 |
));
|
75 |
+
|
76 |
if (BPMediaPrivacy::is_installed()) {
|
77 |
add_settings_section('bpm-privacy', __('Privacy', BP_MEDIA_TXT_DOMAIN), '', 'bp-media-settings');
|
78 |
add_settings_field('bpm-privacy-enabled', __('Enable Privacy', BP_MEDIA_TXT_DOMAIN), array($this, 'checkbox'), 'bp-media-settings', 'bpm-privacy', array(
|
189 |
}
|
190 |
delete_site_option('bpm-settings-saved');
|
191 |
}
|
192 |
+
|
193 |
/**
|
194 |
* Sanitizes the settings
|
195 |
*/
|
app/helper/BPMediaSupport.php
CHANGED
@@ -10,7 +10,63 @@ if (!class_exists('BPMediaSupport')) {
|
|
10 |
class BPMediaSupport {
|
11 |
|
12 |
public function __construct() {
|
13 |
-
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
/**
|
10 |
class BPMediaSupport {
|
11 |
|
12 |
public function __construct() {
|
13 |
+
add_action('bp_media_admin_page_append', array($this, 'debug_info'));
|
14 |
+
}
|
15 |
+
|
16 |
+
public function debug_info($page) {
|
17 |
+
if ('bp-media-support' == $page) {
|
18 |
+
global $wpdb, $wp_version, $bp;
|
19 |
+
?>
|
20 |
+
<div id="debug-info">
|
21 |
+
<h3><?php _e('Debug Info', BP_MEDIA_TXT_DOMAIN); ?></h3>
|
22 |
+
<table class="form-table">
|
23 |
+
<tbody>
|
24 |
+
<tr valign="top">
|
25 |
+
<th scope="row">PHP</th>
|
26 |
+
<td><?php echo PHP_VERSION; ?></td>
|
27 |
+
</tr>
|
28 |
+
<tr valign="top">
|
29 |
+
<th scope="row">MYSQL</th>
|
30 |
+
<td><?php echo $wpdb->db_version(); ?></td>
|
31 |
+
</tr>
|
32 |
+
<tr valign="top">
|
33 |
+
<th scope="row">WordPress</th>
|
34 |
+
<td><?php echo $wp_version; ?></td>
|
35 |
+
</tr>
|
36 |
+
<tr valign="top">
|
37 |
+
<th scope="row">BuddyPress</th>
|
38 |
+
<td><?php echo $bp->version; ?></td>
|
39 |
+
</tr>
|
40 |
+
<tr valign="top">
|
41 |
+
<th scope="row">BuddyPress Media</th>
|
42 |
+
<td><?php echo BP_MEDIA_VERSION; ?></td>
|
43 |
+
</tr>
|
44 |
+
<tr valign="top">
|
45 |
+
<th scope="row">OS</th>
|
46 |
+
<td><?php echo PHP_OS; ?></td>
|
47 |
+
</tr>
|
48 |
+
<tr valign="top">
|
49 |
+
<th scope="row">Imagick</th><?php
|
50 |
+
if (extension_loaded('imagick')) {
|
51 |
+
$imagick = Imagick::getVersion();
|
52 |
+
} else {
|
53 |
+
$imagick['versionString'] = 'Not Installed';
|
54 |
+
} ?>
|
55 |
+
<td><?php echo $imagick['versionString']; ?></td>
|
56 |
+
</tr>
|
57 |
+
<tr valign="top">
|
58 |
+
<th scope="row">GD</th><?php
|
59 |
+
if (extension_loaded('gd')) {
|
60 |
+
$gd = gd_info();
|
61 |
+
} else {
|
62 |
+
$gd['GD Version'] = 'Not Installed';
|
63 |
+
} ?>
|
64 |
+
<td><?php echo $gd['GD Version']; ?></td>
|
65 |
+
</tr>
|
66 |
+
</tbody>
|
67 |
+
</table>
|
68 |
+
</div><?php
|
69 |
+
}
|
70 |
}
|
71 |
|
72 |
/**
|
app/main/BuddyPressMedia.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
/**
|
4 |
* Don't load this file directly!
|
5 |
*/
|
6 |
-
if (
|
7 |
-
|
8 |
|
9 |
/**
|
10 |
* BuddyPress Media
|
@@ -20,657 +20,656 @@ if ( ! defined( 'ABSPATH' ) )
|
|
20 |
*/
|
21 |
class BuddyPressMedia {
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
<p><strong>' . __(
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
<p>'
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
<a href="%s" target="_blank">BuddyPress</a>
|
159 |
must be installed first.', $this->text_domain
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
</div>';
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
/* Current Version. */
|
200 |
-
if ( ! defined( 'BP_MEDIA_VERSION' ) )
|
201 |
-
define( 'BP_MEDIA_VERSION', '2.4' );
|
202 |
-
|
203 |
-
/* Required Version */
|
204 |
-
if ( ! defined( 'BP_MEDIA_REQUIRED_BP' ) )
|
205 |
-
define( 'BP_MEDIA_REQUIRED_BP', '1.6.2' );
|
206 |
-
|
207 |
-
/* Database Version */
|
208 |
-
if ( ! defined( 'BP_MEDIA_DB_VERSION' ) )
|
209 |
-
define( 'BP_MEDIA_DB_VERSION', '2.1' );
|
210 |
|
211 |
-
|
|
|
|
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
if ( ! defined( 'BP_MEDIA_IMAGES_VIEW_SLUG' ) )
|
230 |
-
define( 'BP_MEDIA_IMAGES_VIEW_SLUG', 'view' );
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
/* Videos slug */
|
236 |
-
if ( ! defined( 'BP_MEDIA_VIDEOS_SLUG' ) )
|
237 |
-
define( 'BP_MEDIA_VIDEOS_SLUG', 'videos' );
|
238 |
-
|
239 |
-
if ( ! defined( 'BP_MEDIA_VIDEOS_VIEW_SLUG' ) )
|
240 |
-
define( 'BP_MEDIA_VIDEOS_VIEW_SLUG', 'watch' );
|
241 |
-
|
242 |
-
if ( ! defined( 'BP_MEDIA_VIDEOS_EDIT_SLUG' ) )
|
243 |
-
define( 'BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit' );
|
244 |
-
|
245 |
-
/* Audio slug */
|
246 |
-
if ( ! defined( 'BP_MEDIA_AUDIO_SLUG' ) )
|
247 |
-
define( 'BP_MEDIA_AUDIO_SLUG', 'music' );
|
248 |
-
|
249 |
-
if ( ! defined( 'BP_MEDIA_AUDIO_VIEW_SLUG' ) )
|
250 |
-
define( 'BP_MEDIA_AUDIO_VIEW_SLUG', 'listen' );
|
251 |
-
|
252 |
-
if ( ! defined( 'BP_MEDIA_AUDIO_EDIT_SLUG' ) )
|
253 |
-
define( 'BP_MEDIA_AUDIO_EDIT_SLUG', 'edit' );
|
254 |
-
|
255 |
-
/* Albums slug */
|
256 |
-
if ( ! defined( 'BP_MEDIA_ALBUMS_SLUG' ) )
|
257 |
-
define( 'BP_MEDIA_ALBUMS_SLUG', 'albums' );
|
258 |
-
|
259 |
-
if ( ! defined( 'BP_MEDIA_ALBUMS_VIEW_SLUG' ) )
|
260 |
-
define( 'BP_MEDIA_ALBUMS_VIEW_SLUG', 'list' );
|
261 |
-
|
262 |
-
if ( ! defined( 'BP_MEDIA_ALBUMS_EDIT_SLUG' ) )
|
263 |
-
define( 'BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit' );
|
264 |
-
|
265 |
-
/* Settings slug */
|
266 |
-
if ( ! defined( 'BP_MEDIA_USER_SETTINGS_SLUG' ) )
|
267 |
-
define( 'BP_MEDIA_USER_SETTINGS_SLUG', 'privacy' );
|
268 |
-
|
269 |
-
/* UI Labels loaded via text domain, can be translated */
|
270 |
-
if ( ! defined( 'BP_MEDIA_LABEL' ) )
|
271 |
-
define( 'BP_MEDIA_LABEL', __( 'Media',
|
272 |
-
$this->text_domain ) );
|
273 |
-
|
274 |
-
if ( ! defined( 'BP_MEDIA_LABEL_SINGULAR' ) )
|
275 |
-
define( 'BP_MEDIA_LABEL_SINGULAR', __( 'Media',
|
276 |
-
$this->text_domain ) );
|
277 |
-
if ( ! defined( 'BP_MEDIA_USER_SETTINGS_LABEL' ) )
|
278 |
-
define( 'BP_MEDIA_USER_SETTINGS_LABEL', __( 'Privacy',
|
279 |
-
$this->text_domain ) );
|
280 |
-
|
281 |
-
if ( ! defined( 'BP_MEDIA_IMAGES_LABEL' ) )
|
282 |
-
define( 'BP_MEDIA_IMAGES_LABEL', __( 'Photos', $this->text_domain ) );
|
283 |
-
|
284 |
-
if ( ! defined( 'BP_MEDIA_IMAGES_LABEL_SINGULAR' ) )
|
285 |
-
define( 'BP_MEDIA_IMAGES_LABEL_SINGULAR', __( 'Photo', $this->text_domain ) );
|
286 |
-
|
287 |
-
if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL' ) )
|
288 |
-
define( 'BP_MEDIA_VIDEOS_LABEL', __( 'Videos', $this->text_domain ) );
|
289 |
-
|
290 |
-
if ( ! defined( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR' ) )
|
291 |
-
define( 'BP_MEDIA_VIDEOS_LABEL_SINGULAR', __( 'Video', $this->text_domain ) );
|
292 |
-
|
293 |
-
if ( ! defined( 'BP_MEDIA_AUDIO_LABEL' ) )
|
294 |
-
define( 'BP_MEDIA_AUDIO_LABEL', __( 'Music', $this->text_domain ) );
|
295 |
-
|
296 |
-
if ( ! defined( 'BP_MEDIA_AUDIO_LABEL_SINGULAR' ) )
|
297 |
-
define( 'BP_MEDIA_AUDIO_LABEL_SINGULAR', __( 'Music', $this->text_domain ) );
|
298 |
-
|
299 |
-
if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL' ) )
|
300 |
-
define( 'BP_MEDIA_ALBUMS_LABEL', __( 'Albums', $this->text_domain ) );
|
301 |
-
|
302 |
-
if ( ! defined( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR' ) )
|
303 |
-
define( 'BP_MEDIA_ALBUMS_LABEL_SINGULAR', __( 'Album', $this->text_domain ) );
|
304 |
-
|
305 |
-
if ( ! defined( 'BP_MEDIAUPLOAD_LABEL' ) )
|
306 |
-
define( 'BP_MEDIA_UPLOAD_LABEL', __( 'Upload', $this->text_domain ) );
|
307 |
-
|
308 |
-
/* Support Email constant */
|
309 |
-
if ( ! defined( 'BP_MEDIA_SUPPORT_EMAIL' ) )
|
310 |
-
define( 'BP_MEDIA_SUPPORT_EMAIL', $this->support_email );
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Hooks the plugin into BuddyPress via 'bp_include' action.
|
315 |
-
* Initialises the plugin's functionalities, options,
|
316 |
-
* loads media for Profiles and Groups.
|
317 |
-
* Creates Admin panels
|
318 |
-
* Loads accessory functions
|
319 |
-
*
|
320 |
-
* @global BPMediaAdmin $bp_media_admin
|
321 |
-
*/
|
322 |
-
function init() {
|
323 |
-
|
324 |
-
/**
|
325 |
-
* Load options/settings
|
326 |
-
*/
|
327 |
-
$this->get_option();
|
328 |
-
|
329 |
-
if ( defined( 'BP_VERSION' ) &&
|
330 |
-
version_compare( BP_VERSION, BP_MEDIA_REQUIRED_BP, '>=' ) ) {
|
331 |
-
/**
|
332 |
-
* Add a settings link to the Plugin list screen
|
333 |
-
*/
|
334 |
-
add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
|
335 |
-
/**
|
336 |
-
* Load BuddyPress Media for profiles
|
337 |
-
*/
|
338 |
-
$this->loader = new BPMediaLoader();
|
339 |
-
/**
|
340 |
-
* Load BuddyPress Media for groups
|
341 |
-
*/
|
342 |
-
if ( array_key_exists( 'enable_on_group', $this->options ) ) {
|
343 |
-
if ( $this->options[ 'enable_on_group' ] ) {
|
344 |
-
$this->group_loader = new BPMediaGroupLoader();
|
345 |
-
}
|
346 |
-
}
|
347 |
-
|
348 |
-
|
349 |
-
/**
|
350 |
-
* Load accessory functions
|
351 |
-
*/
|
352 |
// new BPMediaActivity();
|
353 |
-
|
354 |
// 'activity' => false,
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
'The BuddyPress version installed is an
|
496 |
older version and is not supported,
|
497 |
please update BuddyPress to use
|
498 |
BuddyPress Media Plugin.
|
499 |
<a class="alignright" href="%1$s">X</a>', $this->text_domain
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
Please install latest version of BuddyPress
|
510 |
to use BuddyPress Media plugin.
|
511 |
<a class="alignright" href="%1$s">X</a>', $this->text_domain
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
post_parent={$album[
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
|
|
|
|
|
|
674 |
|
675 |
}
|
676 |
|
3 |
/**
|
4 |
* Don't load this file directly!
|
5 |
*/
|
6 |
+
if (!defined('ABSPATH'))
|
7 |
+
exit;
|
8 |
|
9 |
/**
|
10 |
* BuddyPress Media
|
20 |
*/
|
21 |
class BuddyPressMedia {
|
22 |
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
* @var string The text domain for loading translations
|
26 |
+
*/
|
27 |
+
public $text_domain = 'buddypress-media';
|
28 |
+
|
29 |
+
/**
|
30 |
+
*
|
31 |
+
* @var array BuddyPress Media settings
|
32 |
+
*/
|
33 |
+
public $options = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
*
|
37 |
+
* @var string Email address the admin support form should send to
|
38 |
+
*/
|
39 |
+
public $support_email = 'support@rtcamp.com';
|
40 |
+
|
41 |
+
/**
|
42 |
+
*
|
43 |
+
* @var string Support forum url
|
44 |
+
*/
|
45 |
+
public $support_url = 'http://rtcamp.com/support/forum/buddypress-media/';
|
46 |
+
|
47 |
+
/**
|
48 |
+
*
|
49 |
+
* @var object/array The query that fetches media (photos, video and audio)
|
50 |
+
*/
|
51 |
+
public $query;
|
52 |
+
|
53 |
+
/**
|
54 |
+
*
|
55 |
+
* @var object/array The query that fetches albums
|
56 |
+
*/
|
57 |
+
public $albums_query;
|
58 |
+
|
59 |
+
/**
|
60 |
+
*
|
61 |
+
* @var int Count
|
62 |
+
*/
|
63 |
+
public $count = null;
|
64 |
+
|
65 |
+
/**
|
66 |
+
*
|
67 |
+
* @var int Number of media items to show in one view.
|
68 |
+
*/
|
69 |
+
public $posts_per_page = 10;
|
70 |
+
|
71 |
+
/**
|
72 |
+
*
|
73 |
+
* @var array The types of activity BuddyPress Media creates
|
74 |
+
*/
|
75 |
+
public $activity_types = array(
|
76 |
+
'media_upload',
|
77 |
+
'album_updated',
|
78 |
+
'album_created'
|
79 |
+
);
|
80 |
+
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* @var array A cache for activities that are hidden by BuddyPress Media
|
84 |
+
*/
|
85 |
+
public $hidden_activity_cache = array();
|
86 |
+
|
87 |
+
/**
|
88 |
+
*
|
89 |
+
* @var type
|
90 |
+
*/
|
91 |
+
public $loader;
|
92 |
+
|
93 |
+
/**
|
94 |
+
*
|
95 |
+
* @var type
|
96 |
+
*/
|
97 |
+
public $group_loader;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Constructs the class
|
101 |
+
* Defines constants and excerpt lengths, initiates admin notices,
|
102 |
+
* loads and initiates the plugin, loads translations.
|
103 |
+
* Initialises media counter
|
104 |
+
*
|
105 |
+
* @global int $bp_media_counter Media counter
|
106 |
+
*/
|
107 |
+
public function __construct() {
|
108 |
+
/**
|
109 |
+
* Define constants
|
110 |
+
*/
|
111 |
+
$this->constants();
|
112 |
+
/**
|
113 |
+
* Define excerpt lengths
|
114 |
+
*/
|
115 |
+
$this->excerpt_lengths();
|
116 |
+
/**
|
117 |
+
* Add admin notice for BuddyPress dependance
|
118 |
+
*/
|
119 |
+
add_action('admin_notices', array($this, 'bp_exists'));
|
120 |
+
/**
|
121 |
+
* Activate the plugin!
|
122 |
+
*/
|
123 |
+
register_activation_hook(__FILE__, array($this, 'activate'));
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Hook it to BuddyPress
|
127 |
+
*/
|
128 |
+
add_action('bp_include', array($this, 'init'));
|
129 |
+
/**
|
130 |
+
* Add the widget
|
131 |
+
*/
|
132 |
+
add_action('widgets_init', array($this, 'widgets_init'), 1);
|
133 |
+
/**
|
134 |
+
* Load translations
|
135 |
+
*/
|
136 |
+
add_action('plugins_loaded', array($this, 'load_translation'));
|
137 |
+
/**
|
138 |
+
* Initialise media counter
|
139 |
+
*/
|
140 |
+
global $bp_media_counter;
|
141 |
+
$bp_media_counter = 0;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Checks if BuddyPress is installed!
|
146 |
+
*/
|
147 |
+
public function bp_exists() {
|
148 |
+
if (!class_exists('BuddyPress')) {
|
149 |
+
echo '<div class="error">
|
150 |
<p><strong>' . __(
|
151 |
+
'BuddyPress is not installed.', $this->text_domain
|
152 |
+
)
|
153 |
+
. '</strong></p>
|
154 |
<p>'
|
155 |
+
. sprintf(
|
156 |
+
__(
|
157 |
+
'To use BuddyPress Media,
|
158 |
<a href="%s" target="_blank">BuddyPress</a>
|
159 |
must be installed first.', $this->text_domain
|
160 |
+
), 'http://wordpress.org/extend/plugins/buddypress/'
|
161 |
+
)
|
162 |
+
. '</p>
|
163 |
</div>';
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Populates $options with saved settings
|
169 |
+
*/
|
170 |
+
public function get_option() {
|
171 |
+
$options = bp_get_option('bp_media_options', false);
|
172 |
+
if (!$options) {
|
173 |
+
$options = array(
|
174 |
+
'enable_on_group' => 1,
|
175 |
+
'videos_enabled' => 1,
|
176 |
+
'audio_enabled' => 1,
|
177 |
+
'images_enabled' => 1,
|
178 |
+
'download_enabled' => 1,
|
179 |
+
'show_admin_menu' => 1
|
180 |
+
);
|
181 |
+
bp_update_option('bp_media_options', $options);
|
182 |
+
}
|
183 |
+
$this->options = $options;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Defines all the constants if undefined. Can be overridden by
|
188 |
+
* defining them elsewhere, say wp-config.php
|
189 |
+
*/
|
190 |
+
public function constants() {
|
191 |
+
/* Text domain */
|
192 |
+
if (!defined('BP_MEDIA_TXT_DOMAIN'))
|
193 |
+
define('BP_MEDIA_TXT_DOMAIN', $this->text_domain);
|
194 |
+
|
195 |
+
/* If the plugin is installed. */
|
196 |
+
if (!defined('BP_MEDIA_IS_INSTALLED'))
|
197 |
+
define('BP_MEDIA_IS_INSTALLED', 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
/* Current Version. */
|
200 |
+
if (!defined('BP_MEDIA_VERSION'))
|
201 |
+
define('BP_MEDIA_VERSION', BuddyPressMedia::plugin_get_version());
|
202 |
|
203 |
+
/* Required Version */
|
204 |
+
if (!defined('BP_MEDIA_REQUIRED_BP'))
|
205 |
+
define('BP_MEDIA_REQUIRED_BP', '1.6.2');
|
206 |
|
207 |
+
/* Database Version */
|
208 |
+
if (!defined('BP_MEDIA_DB_VERSION'))
|
209 |
+
define('BP_MEDIA_DB_VERSION', '2.1');
|
210 |
|
211 |
+
/* Slug Constants for building urls */
|
212 |
+
|
213 |
+
/* Media slug */
|
214 |
+
if (!defined('BP_MEDIA_SLUG'))
|
215 |
+
define('BP_MEDIA_SLUG', 'media');
|
216 |
+
|
217 |
+
/* Upload slug */
|
218 |
+
if (!defined('BP_MEDIA_UPLOAD_SLUG'))
|
219 |
+
define('BP_MEDIA_UPLOAD_SLUG', 'upload');
|
220 |
+
|
221 |
+
/* Delete slug */
|
222 |
+
if (!defined('BP_MEDIA_DELETE_SLUG'))
|
223 |
+
define('BP_MEDIA_DELETE_SLUG', 'delete');
|
224 |
+
|
225 |
+
/* Photos slug */
|
226 |
+
if (!defined('BP_MEDIA_IMAGES_SLUG'))
|
227 |
+
define('BP_MEDIA_IMAGES_SLUG', 'photos');
|
228 |
+
|
229 |
+
if (!defined('BP_MEDIA_IMAGES_VIEW_SLUG'))
|
230 |
+
define('BP_MEDIA_IMAGES_VIEW_SLUG', 'view');
|
231 |
+
|
232 |
+
if (!defined('BP_MEDIA_IMAGES_EDIT_SLUG'))
|
233 |
+
define('BP_MEDIA_IMAGES_EDIT_SLUG', 'edit');
|
234 |
+
|
235 |
+
/* Videos slug */
|
236 |
+
if (!defined('BP_MEDIA_VIDEOS_SLUG'))
|
237 |
+
define('BP_MEDIA_VIDEOS_SLUG', 'videos');
|
238 |
+
|
239 |
+
if (!defined('BP_MEDIA_VIDEOS_VIEW_SLUG'))
|
240 |
+
define('BP_MEDIA_VIDEOS_VIEW_SLUG', 'watch');
|
241 |
+
|
242 |
+
if (!defined('BP_MEDIA_VIDEOS_EDIT_SLUG'))
|
243 |
+
define('BP_MEDIA_VIDEOS_EDIT_SLUG', 'edit');
|
244 |
+
|
245 |
+
/* Audio slug */
|
246 |
+
if (!defined('BP_MEDIA_AUDIO_SLUG'))
|
247 |
+
define('BP_MEDIA_AUDIO_SLUG', 'music');
|
248 |
+
|
249 |
+
if (!defined('BP_MEDIA_AUDIO_VIEW_SLUG'))
|
250 |
+
define('BP_MEDIA_AUDIO_VIEW_SLUG', 'listen');
|
251 |
+
|
252 |
+
if (!defined('BP_MEDIA_AUDIO_EDIT_SLUG'))
|
253 |
+
define('BP_MEDIA_AUDIO_EDIT_SLUG', 'edit');
|
254 |
+
|
255 |
+
/* Albums slug */
|
256 |
+
if (!defined('BP_MEDIA_ALBUMS_SLUG'))
|
257 |
+
define('BP_MEDIA_ALBUMS_SLUG', 'albums');
|
258 |
+
|
259 |
+
if (!defined('BP_MEDIA_ALBUMS_VIEW_SLUG'))
|
260 |
+
define('BP_MEDIA_ALBUMS_VIEW_SLUG', 'list');
|
261 |
+
|
262 |
+
if (!defined('BP_MEDIA_ALBUMS_EDIT_SLUG'))
|
263 |
+
define('BP_MEDIA_ALBUMS_EDIT_SLUG', 'edit');
|
264 |
+
|
265 |
+
/* Settings slug */
|
266 |
+
if (!defined('BP_MEDIA_USER_SETTINGS_SLUG'))
|
267 |
+
define('BP_MEDIA_USER_SETTINGS_SLUG', 'privacy');
|
268 |
+
|
269 |
+
/* UI Labels loaded via text domain, can be translated */
|
270 |
+
if (!defined('BP_MEDIA_LABEL'))
|
271 |
+
define('BP_MEDIA_LABEL', __('Media', $this->text_domain));
|
272 |
+
|
273 |
+
if (!defined('BP_MEDIA_LABEL_SINGULAR'))
|
274 |
+
define('BP_MEDIA_LABEL_SINGULAR', __('Media', $this->text_domain));
|
275 |
+
if (!defined('BP_MEDIA_USER_SETTINGS_LABEL'))
|
276 |
+
define('BP_MEDIA_USER_SETTINGS_LABEL', __('Privacy', $this->text_domain));
|
277 |
+
|
278 |
+
if (!defined('BP_MEDIA_IMAGES_LABEL'))
|
279 |
+
define('BP_MEDIA_IMAGES_LABEL', __('Photos', $this->text_domain));
|
280 |
+
|
281 |
+
if (!defined('BP_MEDIA_IMAGES_LABEL_SINGULAR'))
|
282 |
+
define('BP_MEDIA_IMAGES_LABEL_SINGULAR', __('Photo', $this->text_domain));
|
283 |
+
|
284 |
+
if (!defined('BP_MEDIA_VIDEOS_LABEL'))
|
285 |
+
define('BP_MEDIA_VIDEOS_LABEL', __('Videos', $this->text_domain));
|
286 |
+
|
287 |
+
if (!defined('BP_MEDIA_VIDEOS_LABEL_SINGULAR'))
|
288 |
+
define('BP_MEDIA_VIDEOS_LABEL_SINGULAR', __('Video', $this->text_domain));
|
289 |
+
|
290 |
+
if (!defined('BP_MEDIA_AUDIO_LABEL'))
|
291 |
+
define('BP_MEDIA_AUDIO_LABEL', __('Music', $this->text_domain));
|
292 |
+
|
293 |
+
if (!defined('BP_MEDIA_AUDIO_LABEL_SINGULAR'))
|
294 |
+
define('BP_MEDIA_AUDIO_LABEL_SINGULAR', __('Music', $this->text_domain));
|
295 |
+
|
296 |
+
if (!defined('BP_MEDIA_ALBUMS_LABEL'))
|
297 |
+
define('BP_MEDIA_ALBUMS_LABEL', __('Albums', $this->text_domain));
|
298 |
+
|
299 |
+
if (!defined('BP_MEDIA_ALBUMS_LABEL_SINGULAR'))
|
300 |
+
define('BP_MEDIA_ALBUMS_LABEL_SINGULAR', __('Album', $this->text_domain));
|
301 |
+
|
302 |
+
if (!defined('BP_MEDIAUPLOAD_LABEL'))
|
303 |
+
define('BP_MEDIA_UPLOAD_LABEL', __('Upload', $this->text_domain));
|
304 |
+
|
305 |
+
/* Support Email constant */
|
306 |
+
if (!defined('BP_MEDIA_SUPPORT_EMAIL'))
|
307 |
+
define('BP_MEDIA_SUPPORT_EMAIL', $this->support_email);
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Hooks the plugin into BuddyPress via 'bp_include' action.
|
312 |
+
* Initialises the plugin's functionalities, options,
|
313 |
+
* loads media for Profiles and Groups.
|
314 |
+
* Creates Admin panels
|
315 |
+
* Loads accessory functions
|
316 |
+
*
|
317 |
+
* @global BPMediaAdmin $bp_media_admin
|
318 |
+
*/
|
319 |
+
function init() {
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Load options/settings
|
323 |
+
*/
|
324 |
+
$this->get_option();
|
325 |
+
|
326 |
+
if (defined('BP_VERSION') &&
|
327 |
+
version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '>=')) {
|
328 |
+
/**
|
329 |
+
* Add a settings link to the Plugin list screen
|
330 |
+
*/
|
331 |
+
add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
|
332 |
+
/**
|
333 |
+
* Load BuddyPress Media for profiles
|
334 |
+
*/
|
335 |
+
$this->loader = new BPMediaLoader();
|
336 |
+
/**
|
337 |
+
* Load BuddyPress Media for groups
|
338 |
+
*/
|
339 |
+
if (array_key_exists('enable_on_group', $this->options)) {
|
340 |
+
if ($this->options['enable_on_group']) {
|
341 |
+
$this->group_loader = new BPMediaGroupLoader();
|
342 |
+
}
|
343 |
+
}
|
344 |
|
|
|
|
|
345 |
|
346 |
+
/**
|
347 |
+
* Load accessory functions
|
348 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
// new BPMediaActivity();
|
350 |
+
$class_construct = array(
|
351 |
// 'activity' => false,
|
352 |
+
'filters' => false,
|
353 |
+
'actions' => false,
|
354 |
+
'function' => false,
|
355 |
+
'privacy' => false,
|
356 |
+
);
|
357 |
+
$class_construct = apply_filters('bpmedia_class_construct', $class_construct);
|
358 |
+
|
359 |
+
foreach ($class_construct as $classname => $global_scope) {
|
360 |
+
$class = 'BPMedia' . ucfirst($classname);
|
361 |
+
if (class_exists($class)) {
|
362 |
+
if ($global_scope == true) {
|
363 |
+
global ${'bp_media_' . $classname};
|
364 |
+
${'bp_media_' . $classname} = new $class();
|
365 |
+
} else {
|
366 |
+
new $class();
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Add admin notices
|
374 |
+
*/
|
375 |
+
add_action('admin_notices', array($this, 'admin_notice'));
|
376 |
+
/**
|
377 |
+
* Initialise Admin Panels
|
378 |
+
*/
|
379 |
+
global $bp_media_admin;
|
380 |
+
$bp_media_admin = new BPMediaAdmin();
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Loads translations
|
385 |
+
*/
|
386 |
+
static function load_translation() {
|
387 |
+
load_plugin_textdomain(BP_MEDIA_TXT_DOMAIN, false, basename(BP_MEDIA_PATH) . '/languages/');
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Add a settings link to the BuddyPress Media entry
|
392 |
+
* in the list of active plugins screen
|
393 |
+
*
|
394 |
+
* @param array $links
|
395 |
+
* @param string $file
|
396 |
+
* @return array
|
397 |
+
*/
|
398 |
+
function settings_link($links, $file) {
|
399 |
+
/* create link */
|
400 |
+
$plugin_name = plugin_basename(BP_MEDIA_PATH . 'index.php');
|
401 |
+
$admin_link = $this->get_admin_url(
|
402 |
+
add_query_arg(
|
403 |
+
array(
|
404 |
+
'page' => 'bp-media-settings'), 'admin.php'
|
405 |
+
)
|
406 |
+
);
|
407 |
+
if ($file == $plugin_name) {
|
408 |
+
array_unshift(
|
409 |
+
$links, sprintf(
|
410 |
+
'<a href="%s">%s</a>', $admin_link, __('Settings', $this->text_domain)
|
411 |
+
)
|
412 |
+
);
|
413 |
+
}
|
414 |
+
return $links;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Default media sizes
|
419 |
+
*
|
420 |
+
* @return array
|
421 |
+
*/
|
422 |
+
function media_sizes() {
|
423 |
+
$def_sizes = array(
|
424 |
+
'activity_image' => array(
|
425 |
+
'width' => 320,
|
426 |
+
'height' => 240
|
427 |
+
),
|
428 |
+
'activity_video' => array(
|
429 |
+
'width' => 320,
|
430 |
+
'height' => 240
|
431 |
+
),
|
432 |
+
'activity_audio' => array(
|
433 |
+
'width' => 320,
|
434 |
+
),
|
435 |
+
'single_image' => array(
|
436 |
+
'width' => 800,
|
437 |
+
'height' => 0
|
438 |
+
),
|
439 |
+
'single_video' => array(
|
440 |
+
'width' => 640,
|
441 |
+
'height' => 480
|
442 |
+
),
|
443 |
+
'single_audio' => array(
|
444 |
+
'width' => 640,
|
445 |
+
),
|
446 |
+
);
|
447 |
+
|
448 |
+
/** Can be filtered by a theme or an extension/plugin */
|
449 |
+
return apply_filters('bpmedia_media_sizes', $def_sizes);
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Defines default length of strings and excerpts displayed in activities
|
454 |
+
* and media tabs
|
455 |
+
*
|
456 |
+
* @global array $bp_media_default_excerpts
|
457 |
+
*/
|
458 |
+
function excerpt_lengths() {
|
459 |
+
global $bp_media_default_excerpts;
|
460 |
+
$def_excerpt = array(
|
461 |
+
'single_entry_title' => 100,
|
462 |
+
'single_entry_description' => 500,
|
463 |
+
'activity_entry_title' => 50,
|
464 |
+
'activity_entry_description' => 500
|
465 |
+
);
|
466 |
+
|
467 |
+
$bp_media_default_excerpts = apply_filters(
|
468 |
+
'bpmedia_excerpt_lengths', $def_excerpt
|
469 |
+
);
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Admin notices for dependencies and compatibility
|
474 |
+
*
|
475 |
+
* @global object/array $current_user
|
476 |
+
*/
|
477 |
+
public function admin_notice() {
|
478 |
+
global $current_user;
|
479 |
+
$user_id = $current_user->ID;
|
480 |
+
if (isset($_GET['bp_media_nag_ignore'])
|
481 |
+
&& '0' == $_GET['bp_media_nag_ignore']) {
|
482 |
+
add_user_meta($user_id, 'bp_media_ignore_notice', 'true', true);
|
483 |
+
}
|
484 |
+
/* Check that the user hasn't already clicked to ignore the message */
|
485 |
+
if (!get_user_meta($user_id, 'bp_media_ignore_notice')) {
|
486 |
+
if (defined('BP_VERSION')) {
|
487 |
+
if (version_compare(BP_VERSION, BP_MEDIA_REQUIRED_BP, '<')) {
|
488 |
+
echo '<div class="error"><p>';
|
489 |
+
printf(
|
490 |
+
__(
|
491 |
+
'The BuddyPress version installed is an
|
|
|
492 |
older version and is not supported,
|
493 |
please update BuddyPress to use
|
494 |
BuddyPress Media Plugin.
|
495 |
<a class="alignright" href="%1$s">X</a>', $this->text_domain
|
496 |
+
), '?bp_media_nag_ignore=0'
|
497 |
+
);
|
498 |
+
echo "</p></div>";
|
499 |
+
}
|
500 |
+
} else {
|
501 |
+
echo '<div class="error"><p>';
|
502 |
+
printf(
|
503 |
+
__(
|
504 |
+
'You have not installed BuddyPress.
|
505 |
Please install latest version of BuddyPress
|
506 |
to use BuddyPress Media plugin.
|
507 |
<a class="alignright" href="%1$s">X</a>', $this->text_domain
|
508 |
+
), '?bp_media_nag_ignore=0'
|
509 |
+
);
|
510 |
+
echo "</p></div>";
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Plugin activation, checks for old database and updates it.
|
517 |
+
*
|
518 |
+
*/
|
519 |
+
public function activate() {
|
520 |
+
$bpmquery = new WP_Query(
|
521 |
+
array(
|
522 |
+
'post_type' => 'bp_media',
|
523 |
+
'posts_per_page' => 1
|
524 |
+
)
|
525 |
+
);
|
526 |
+
if ($bpmquery->found_posts > 0) {
|
527 |
+
update_site_option('bp_media_db_version', '1.0');
|
528 |
+
} else {
|
529 |
+
switch (get_site_option('bp_media_db_version', false, false)) {
|
530 |
+
case '2.0':
|
531 |
+
break;
|
532 |
+
default:
|
533 |
+
update_site_option(
|
534 |
+
'bp_media_db_version', BP_MEDIA_DB_VERSION
|
535 |
+
);
|
536 |
+
}
|
537 |
+
}
|
538 |
+
|
539 |
+
BPMediaPrivacy::install();
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Provides the right admin url to work with
|
544 |
+
*
|
545 |
+
* @param string $path
|
546 |
+
* @param string $scheme
|
547 |
+
* @return string The proper admin url for single/multisite installs
|
548 |
+
*/
|
549 |
+
function get_admin_url($path = '', $scheme = 'admin') {
|
550 |
+
|
551 |
+
// Links belong in network admin
|
552 |
+
if (is_multisite())
|
553 |
+
$url = network_admin_url($path, $scheme);
|
554 |
+
|
555 |
+
// Links belong in site admin
|
556 |
+
else
|
557 |
+
$url = admin_url($path, $scheme);
|
558 |
+
|
559 |
+
return $url;
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Registers and activates the BuddyPress Media Widgets
|
564 |
+
*/
|
565 |
+
function widgets_init() {
|
566 |
+
register_widget('BPMediaWidget');
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
*
|
571 |
+
*/
|
572 |
+
function enabled() {
|
573 |
+
$options = $this->options;
|
574 |
+
$enabled = array(
|
575 |
+
'image' => false,
|
576 |
+
'video' => false,
|
577 |
+
'audio' => false,
|
578 |
+
'album' => true,
|
579 |
+
'upload' => true
|
580 |
+
);
|
581 |
+
if (array_key_exists('images_enabled', $options)) {
|
582 |
+
if ($options['images_enabled'] == 1) {
|
583 |
+
$enabled['image'] = true;
|
584 |
+
}
|
585 |
+
}
|
586 |
+
if (array_key_exists('videos_enabled', $options)) {
|
587 |
+
if ($options['videos_enabled'] == 1) {
|
588 |
+
$enabled['video'] = true;
|
589 |
+
}
|
590 |
+
}
|
591 |
+
if (array_key_exists('audio_enabled', $options)) {
|
592 |
+
if ($options['audio_enabled'] == 1) {
|
593 |
+
$enabled['audio'] = true;
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
+
return $enabled;
|
598 |
+
}
|
599 |
+
|
600 |
+
function default_count() {
|
601 |
+
$count = $this->posts_per_page;
|
602 |
+
if (array_key_exists('default_count', $this->options)) {
|
603 |
+
$count = $this->options['default_count'];
|
604 |
+
}
|
605 |
+
return (!$count) ? 10 : $count;
|
606 |
+
}
|
607 |
+
|
608 |
+
function default_tab() {
|
609 |
+
$enabled = $this->enabled();
|
610 |
+
unset($enabled['upload']);
|
611 |
+
unset($enabled['album']);
|
612 |
+
foreach ($enabled as $tab => $value) {
|
613 |
+
if ($value == true) {
|
614 |
+
return $tab;
|
615 |
+
}
|
616 |
+
}
|
617 |
+
}
|
618 |
+
|
619 |
+
function defaults_tab() {
|
620 |
+
$defaults_tab = $this->default_tab();
|
621 |
+
if ($defaults_tab != 'audio') {
|
622 |
+
$defaults_tab .= 's';
|
623 |
+
}
|
624 |
+
return $defaults_tab;
|
625 |
+
}
|
626 |
+
|
627 |
+
/*
|
628 |
+
static function get_wall_album( $group_id = false ) {
|
629 |
+
global $wpdb;
|
630 |
+
$group_id = ( ! $group_id) ? '1' : $group_id;
|
631 |
+
$album_name = __( 'Wall Posts', BP_MEDclaIA_TXT_DOMAIN );
|
632 |
+
$query = "SELECT ID FROM {$wpdb->prefix}posts ps LEFT JOIN
|
633 |
+
{$wpdb->prefix}postmeta pm ON ps.ID= pm.post_id WHERE ps.post_title
|
634 |
+
LIKE '{$album_name}' AND ps.post_type='bp_media_album' AND
|
635 |
+
pm.meta_key='bp-media-key' AND pm.meta_value ='{$group_id}'";
|
636 |
+
$wall_albums = $wpdb->get_results( $query, ARRAY_A );
|
637 |
+
if ( count( $wall_albums ) > 1 ) {
|
638 |
+
return BuddyPressMedia::merge_duplicate_wall_albums( $wall_albums );
|
639 |
+
} elseif($wall_albums) {
|
640 |
+
return $wall_albums[ 0 ][ 'ID' ];
|
641 |
+
}
|
642 |
+
}
|
643 |
+
*
|
644 |
+
*/
|
645 |
+
|
646 |
+
static function merge_duplicate_wall_albums($wall_albums) {
|
647 |
+
global $wpdb;
|
648 |
+
$album_id = $wall_albums[0]['ID'];
|
649 |
+
unset($wall_albums[0]);
|
650 |
+
foreach ($wall_albums as $album) {
|
651 |
+
$query = "SELECT ID FROM {$wpdb->prefix}posts WHERE
|
652 |
+
post_parent={$album['ID']} AND post_type='attachment'";
|
653 |
+
$media = $wpdb->get_results($query, ARRAY_A);
|
654 |
+
foreach ($media as $file) {
|
655 |
+
$wpdb->update(
|
656 |
+
$wpdb->prefix . 'posts', array(
|
657 |
+
' post_parent' => $album_id
|
658 |
+
), array('ID' => $file['ID']), array('%d'), array('%d')
|
659 |
+
);
|
660 |
+
}
|
661 |
+
|
662 |
+
wp_delete_post($album['ID'], true);
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
static function plugin_get_version($path=NULL) {
|
667 |
+
require_once(ABSPATH.'wp-admin/includes/plugin.php');
|
668 |
+
$path = ($path) ? $path : BP_MEDIA_PATH.'index.php';
|
669 |
+
$plugin_data = get_plugin_data($path);
|
670 |
+
$plugin_version = $plugin_data['Version'];
|
671 |
+
return $plugin_version;
|
672 |
+
}
|
673 |
|
674 |
}
|
675 |
|
app/main/group/BPMediaGroupAction.php
CHANGED
@@ -6,7 +6,53 @@
|
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class BPMediaGroupAction {
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
static function filter_entries(){
|
11 |
global $bp_media;
|
12 |
$enabled = $bp_media->enabled();
|
6 |
* @author faishal
|
7 |
*/
|
8 |
class BPMediaGroupAction {
|
9 |
+
static function bp_media_groups_set_query() {
|
10 |
+
global $bp, $bp_media, $bp_media_query, $bp_media_posts_per_page;
|
11 |
+
$enabled = $bp_media->enabled();
|
12 |
+
$default_tab = $bp_media->default_tab();
|
13 |
+
$defaults_tab= $default_tab;
|
14 |
+
if($default_tab!='audio') $defaults_tab.='s';
|
15 |
|
16 |
+
if (isset($bp->current_action) && $bp->current_action == BP_MEDIA_SLUG) {
|
17 |
+
$current_tab = constant('BP_MEDIA_'.strtoupper($defaults_tab).'_SLUG');
|
18 |
+
if (isset($bp->action_variables[0])) {
|
19 |
+
$current_tab = $bp->action_variables[0];
|
20 |
+
}
|
21 |
+
if ($current_tab) {
|
22 |
+
switch ($current_tab) {
|
23 |
+
case BP_MEDIA_IMAGES_SLUG:
|
24 |
+
$type = 'image';
|
25 |
+
break;
|
26 |
+
case BP_MEDIA_AUDIO_SLUG:
|
27 |
+
$type = 'audio';
|
28 |
+
break;
|
29 |
+
case BP_MEDIA_VIDEOS_SLUG:
|
30 |
+
$type = 'video';
|
31 |
+
break;
|
32 |
+
default :
|
33 |
+
$type = null;
|
34 |
+
}
|
35 |
+
if (bp_action_variable(1) == 'page' && is_numeric(bp_action_variable(2))) {
|
36 |
+
$paged = bp_action_variable(2);
|
37 |
+
} else {
|
38 |
+
$paged = 1;
|
39 |
+
}
|
40 |
+
if ($type) {
|
41 |
+
$args = array(
|
42 |
+
'post_type' => 'attachment',
|
43 |
+
'post_status' => 'any',
|
44 |
+
'post_mime_type' => $type,
|
45 |
+
'meta_key' => 'bp-media-key',
|
46 |
+
'meta_value' => -bp_get_current_group_id(),
|
47 |
+
'meta_compare' => '=',
|
48 |
+
'paged' => $paged,
|
49 |
+
'posts_per_page' => $bp_media_posts_per_page
|
50 |
+
);
|
51 |
+
$bp_media_query = new WP_Query($args);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
static function filter_entries(){
|
57 |
global $bp_media;
|
58 |
$enabled = $bp_media->enabled();
|
app/main/group/BPMediaGroupsExtension.php
CHANGED
@@ -16,7 +16,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
16 |
*/
|
17 |
|
18 |
/**
|
19 |
-
*
|
20 |
* @global type $bp
|
21 |
*/
|
22 |
function __construct() {
|
@@ -28,7 +28,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
*
|
32 |
* @global type $bp_media
|
33 |
* @return boolean
|
34 |
*/
|
@@ -59,7 +59,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
*
|
63 |
* @global type $bp
|
64 |
*/
|
65 |
function create_screen_save() {
|
@@ -73,7 +73,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
* @global type $bp_media
|
78 |
* @return boolean
|
79 |
*/
|
@@ -107,7 +107,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
-
*
|
111 |
* @global type $bp
|
112 |
* @global type $bp_media
|
113 |
* @return boolean
|
@@ -141,7 +141,7 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
141 |
*/
|
142 |
|
143 |
/**
|
144 |
-
*
|
145 |
* @global type $bp_media
|
146 |
*/
|
147 |
function widget_display() {
|
@@ -159,9 +159,9 @@ if (class_exists('BP_Group_Extension')) :// Recommended, to prevent problems dur
|
|
159 |
|
160 |
}
|
161 |
|
162 |
-
|
163 |
|
164 |
-
|
|
|
165 |
|
166 |
|
167 |
endif; // class_exists( 'BP_Group_Extension' )
|
16 |
*/
|
17 |
|
18 |
/**
|
19 |
+
*
|
20 |
* @global type $bp
|
21 |
*/
|
22 |
function __construct() {
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
*
|
32 |
* @global type $bp_media
|
33 |
* @return boolean
|
34 |
*/
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
*
|
63 |
* @global type $bp
|
64 |
*/
|
65 |
function create_screen_save() {
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
+
*
|
77 |
* @global type $bp_media
|
78 |
* @return boolean
|
79 |
*/
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
+
*
|
111 |
* @global type $bp
|
112 |
* @global type $bp_media
|
113 |
* @return boolean
|
141 |
*/
|
142 |
|
143 |
/**
|
144 |
+
*
|
145 |
* @global type $bp_media
|
146 |
*/
|
147 |
function widget_display() {
|
159 |
|
160 |
}
|
161 |
|
|
|
162 |
|
163 |
+
|
164 |
+
|
165 |
|
166 |
|
167 |
endif; // class_exists( 'BP_Group_Extension' )
|
app/main/includes/BPMediaActions.php
CHANGED
@@ -20,11 +20,11 @@ class BPMediaActions {
|
|
20 |
add_action( 'bp_activity_entry_meta', array( $this, 'action_buttons' ) );
|
21 |
add_action( 'bp_media_before_delete_media', 'BPMediaActions::delete_media_handler' );
|
22 |
add_action( 'bp_media_after_add_album', array( $this, 'album_create_activity' ) );
|
23 |
-
add_action( 'bp_media_after_add_album', array( $this, 'update_count' )
|
24 |
add_action( 'bp_media_album_updated', 'BPMediaActions::album_activity_update' );
|
25 |
-
add_action( 'bp_media_album_updated', array( $this, 'update_count' )
|
26 |
-
add_action( 'bp_media_after_edit_album', array( $this, 'update_count' )
|
27 |
-
add_action( 'bp_media_after_delete_album', array( $this, 'update_count' )
|
28 |
add_action( 'bp_media_after_delete_media', array( $this, 'album_activity_sync' ) );
|
29 |
add_action( 'bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4 );
|
30 |
add_action( 'wp_ajax_bp_media_load_more', array( $this, 'load_more' ) );
|
@@ -32,10 +32,10 @@ class BPMediaActions {
|
|
32 |
add_action( 'wp_ajax_bp_media_set_album_cover', array( $this, 'set_album_cover' ) );
|
33 |
add_action( 'delete_attachment', array( $this, 'delete_attachment_handler' ) );
|
34 |
add_action( 'wp_ajax_bp_media_add_album', array( $this, 'add_album' ) );
|
35 |
-
add_action( 'bp_media_after_privacy_install', array( $this, 'update_count' ) );
|
36 |
-
add_action( '
|
37 |
-
add_action( 'bp_media_after_update_media', array( $this, 'update_count' )
|
38 |
-
add_action( 'bp_media_after_delete_media', array( $this, 'update_count' )
|
39 |
$linkback = bp_get_option( 'bp_media_add_linkback', false );
|
40 |
if ( $linkback )
|
41 |
add_action( 'bp_footer', array( $this, 'footer' ) );
|
@@ -151,8 +151,8 @@ class BPMediaActions {
|
|
151 |
function enqueue_scripts_styles() {
|
152 |
|
153 |
wp_enqueue_script( 'jquery-ui-tabs' );
|
154 |
-
wp_enqueue_script( 'bp-media-mejs', BP_MEDIA_URL . 'lib/media-element/mediaelement-and-player.min.js', '',
|
155 |
-
wp_enqueue_script( 'bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js', '',
|
156 |
|
157 |
global $bp;
|
158 |
$cur_group_id = NULL;
|
@@ -169,8 +169,8 @@ class BPMediaActions {
|
|
169 |
);
|
170 |
|
171 |
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
172 |
-
wp_enqueue_style( 'bp-media-mecss', BP_MEDIA_URL . 'lib/media-element/mediaelementplayer.min.css', '',
|
173 |
-
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '',
|
174 |
}
|
175 |
|
176 |
/**
|
@@ -352,39 +352,20 @@ class BPMediaActions {
|
|
352 |
}
|
353 |
$count = bp_get_user_meta( $user, 'bp_media_count', true );
|
354 |
if ( ! $count ) {
|
355 |
-
$bp_media_count = array(
|
|
|
|
|
|
|
|
|
|
|
356 |
bp_update_user_meta( $user, 'bp_media_count', $bp_media_count );
|
357 |
-
$bp_media_count = bp_get_user_meta( $user, 'bp_media_count', true );
|
358 |
} else {
|
359 |
$total = array(
|
360 |
-
0 => array(
|
361 |
'images' => 0,
|
362 |
'videos' => 0,
|
363 |
'audio' => 0,
|
364 |
'albums' => 0,
|
365 |
'total' => 0
|
366 |
-
),
|
367 |
-
2 => array(
|
368 |
-
'images' => 0,
|
369 |
-
'videos' => 0,
|
370 |
-
'audio' => 0,
|
371 |
-
'albums' => 0,
|
372 |
-
'total' => 0
|
373 |
-
),
|
374 |
-
4 => array(
|
375 |
-
'images' => 0,
|
376 |
-
'videos' => 0,
|
377 |
-
'audio' => 0,
|
378 |
-
'albums' => 0,
|
379 |
-
'total' => 0
|
380 |
-
),
|
381 |
-
6 => array(
|
382 |
-
'images' => 0,
|
383 |
-
'videos' => 0,
|
384 |
-
'audio' => 0,
|
385 |
-
'albums' => 0,
|
386 |
-
'total' => 0
|
387 |
-
),
|
388 |
);
|
389 |
$total_count = 0;
|
390 |
if ( isset( $count ) && is_array( $count ) && count( $count ) > 0 ) {
|
@@ -423,7 +404,8 @@ class BPMediaActions {
|
|
423 |
return true;
|
424 |
}
|
425 |
|
426 |
-
public function update_count() {
|
|
|
427 |
global $bp;
|
428 |
$user_id = $bp->loggedin_user->id;
|
429 |
global $wpdb;
|
@@ -447,7 +429,7 @@ class BPMediaActions {
|
|
447 |
if ( ! is_array( $result ) )
|
448 |
return false;
|
449 |
foreach ( $result as $level => $obj ) {
|
450 |
-
$formatted[ $level ] = array(
|
451 |
'image' => $obj->Images,
|
452 |
'video' => $obj->Videos,
|
453 |
'audio' => $obj->Audio,
|
@@ -492,7 +474,7 @@ class BPMediaActions {
|
|
492 |
'multi_selection' => true,
|
493 |
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
494 |
);
|
495 |
-
wp_enqueue_script( 'bp-media-activity-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-activity-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ),
|
496 |
wp_localize_script( 'bp-media-activity-uploader', 'bp_media_uploader_params', $params );
|
497 |
wp_localize_script( 'bp-media-activity-uploader', 'activity_ajax_url', admin_url( 'admin-ajax.php' ) );
|
498 |
} elseif ( in_array( bp_current_action(), array( BP_MEDIA_IMAGES_SLUG, BP_MEDIA_VIDEOS_SLUG, BP_MEDIA_AUDIO_SLUG, BP_MEDIA_SLUG, BP_MEDIA_ALBUMS_SLUG ) ) ) {
|
@@ -512,10 +494,10 @@ class BPMediaActions {
|
|
512 |
'multi_selection' => true,
|
513 |
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
514 |
);
|
515 |
-
wp_enqueue_script( 'bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ),
|
516 |
wp_localize_script( 'bp-media-uploader', 'bp_media_uploader_params', $params );
|
517 |
}
|
518 |
-
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '',
|
519 |
}
|
520 |
|
521 |
//This is used only on the uploads page so its added as action in the screens function of upload page.
|
20 |
add_action( 'bp_activity_entry_meta', array( $this, 'action_buttons' ) );
|
21 |
add_action( 'bp_media_before_delete_media', 'BPMediaActions::delete_media_handler' );
|
22 |
add_action( 'bp_media_after_add_album', array( $this, 'album_create_activity' ) );
|
23 |
+
add_action( 'bp_media_after_add_album', array( $this, 'update_count' ) ,999 );
|
24 |
add_action( 'bp_media_album_updated', 'BPMediaActions::album_activity_update' );
|
25 |
+
add_action( 'bp_media_album_updated', array( $this, 'update_count' ) ,999 );
|
26 |
+
add_action( 'bp_media_after_edit_album', array( $this, 'update_count' ) ,999 );
|
27 |
+
add_action( 'bp_media_after_delete_album', array( $this, 'update_count' ) ,999 );
|
28 |
add_action( 'bp_media_after_delete_media', array( $this, 'album_activity_sync' ) );
|
29 |
add_action( 'bp_media_after_add_media', 'BPMediaActions::activity_create_after_add_media', 10, 4 );
|
30 |
add_action( 'wp_ajax_bp_media_load_more', array( $this, 'load_more' ) );
|
32 |
add_action( 'wp_ajax_bp_media_set_album_cover', array( $this, 'set_album_cover' ) );
|
33 |
add_action( 'delete_attachment', array( $this, 'delete_attachment_handler' ) );
|
34 |
add_action( 'wp_ajax_bp_media_add_album', array( $this, 'add_album' ) );
|
35 |
+
add_action( 'bp_media_after_privacy_install', array( $this, 'update_count' ) ,999 );
|
36 |
+
add_action( 'bp_media_after_add_media', array( $this, 'update_count' ) ,999 );
|
37 |
+
add_action( 'bp_media_after_update_media', array( $this, 'update_count' ) ,999 );
|
38 |
+
add_action( 'bp_media_after_delete_media', array( $this, 'update_count' ) ,999);
|
39 |
$linkback = bp_get_option( 'bp_media_add_linkback', false );
|
40 |
if ( $linkback )
|
41 |
add_action( 'bp_footer', array( $this, 'footer' ) );
|
151 |
function enqueue_scripts_styles() {
|
152 |
|
153 |
wp_enqueue_script( 'jquery-ui-tabs' );
|
154 |
+
wp_enqueue_script( 'bp-media-mejs', BP_MEDIA_URL . 'lib/media-element/mediaelement-and-player.min.js', '', BP_MEDIA_VERSION );
|
155 |
+
wp_enqueue_script( 'bp-media-default', BP_MEDIA_URL . 'app/assets/js/main.js', '', BP_MEDIA_VERSION );
|
156 |
|
157 |
global $bp;
|
158 |
$cur_group_id = NULL;
|
169 |
);
|
170 |
|
171 |
wp_localize_script( 'bp-media-default', 'bp_media_vars', $bp_media_vars );
|
172 |
+
wp_enqueue_style( 'bp-media-mecss', BP_MEDIA_URL . 'lib/media-element/mediaelementplayer.min.css', '', BP_MEDIA_VERSION );
|
173 |
+
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION );
|
174 |
}
|
175 |
|
176 |
/**
|
352 |
}
|
353 |
$count = bp_get_user_meta( $user, 'bp_media_count', true );
|
354 |
if ( ! $count ) {
|
355 |
+
$bp_media_count = array(
|
356 |
+
0=>array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ),
|
357 |
+
2=>array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ),
|
358 |
+
4=>array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ),
|
359 |
+
6=>array('images' => 0, 'videos' => 0, 'audio' => 0, 'albums' => 0 ),
|
360 |
+
);
|
361 |
bp_update_user_meta( $user, 'bp_media_count', $bp_media_count );
|
|
|
362 |
} else {
|
363 |
$total = array(
|
|
|
364 |
'images' => 0,
|
365 |
'videos' => 0,
|
366 |
'audio' => 0,
|
367 |
'albums' => 0,
|
368 |
'total' => 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
);
|
370 |
$total_count = 0;
|
371 |
if ( isset( $count ) && is_array( $count ) && count( $count ) > 0 ) {
|
404 |
return true;
|
405 |
}
|
406 |
|
407 |
+
public function update_count($object) {
|
408 |
+
|
409 |
global $bp;
|
410 |
$user_id = $bp->loggedin_user->id;
|
411 |
global $wpdb;
|
429 |
if ( ! is_array( $result ) )
|
430 |
return false;
|
431 |
foreach ( $result as $level => $obj ) {
|
432 |
+
$formatted[ $level*2 ] = array(
|
433 |
'image' => $obj->Images,
|
434 |
'video' => $obj->Videos,
|
435 |
'audio' => $obj->Audio,
|
474 |
'multi_selection' => true,
|
475 |
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
476 |
);
|
477 |
+
wp_enqueue_script( 'bp-media-activity-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-activity-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ), BP_MEDIA_VERSION );
|
478 |
wp_localize_script( 'bp-media-activity-uploader', 'bp_media_uploader_params', $params );
|
479 |
wp_localize_script( 'bp-media-activity-uploader', 'activity_ajax_url', admin_url( 'admin-ajax.php' ) );
|
480 |
} elseif ( in_array( bp_current_action(), array( BP_MEDIA_IMAGES_SLUG, BP_MEDIA_VIDEOS_SLUG, BP_MEDIA_AUDIO_SLUG, BP_MEDIA_SLUG, BP_MEDIA_ALBUMS_SLUG ) ) ) {
|
494 |
'multi_selection' => true,
|
495 |
'multipart_params' => apply_filters( 'bp_media_multipart_params_filter', array( 'action' => 'wp_handle_upload' ) )
|
496 |
);
|
497 |
+
wp_enqueue_script( 'bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array( 'plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers' ), BP_MEDIA_VERSION );
|
498 |
wp_localize_script( 'bp-media-uploader', 'bp_media_uploader_params', $params );
|
499 |
}
|
500 |
+
wp_enqueue_style( 'bp-media-default', BP_MEDIA_URL . 'app/assets/css/main.css', '', BP_MEDIA_VERSION );
|
501 |
}
|
502 |
|
503 |
//This is used only on the uploads page so its added as action in the screens function of upload page.
|
app/main/includes/BPMediaHostWordpress.php
CHANGED
@@ -242,7 +242,6 @@ class BPMediaHostWordpress {
|
|
242 |
update_post_meta( $attachment_id, 'bp-media-key', (-$group ) );
|
243 |
}
|
244 |
do_action( 'bp_media_after_add_media', $this, $is_multiple, $is_activity, $group );
|
245 |
-
do_action( 'bp_media_no_object_after_add_media', $this->id, $this->type );
|
246 |
return $attachment_id;
|
247 |
}
|
248 |
|
@@ -596,7 +595,7 @@ class BPMediaHostWordpress {
|
|
596 |
$post[ 'post_author' ] = $args[ 'owner' ];
|
597 |
$result = wp_update_post( $post );
|
598 |
$this->init( $this->id );
|
599 |
-
do_action( 'bp_media_after_update_media', $this
|
600 |
return $result;
|
601 |
}
|
602 |
|
@@ -840,7 +839,8 @@ class BPMediaHostWordpress {
|
|
840 |
* @return boolean
|
841 |
*/
|
842 |
protected function set_permalinks() {
|
843 |
-
|
|
|
844 |
if ( $this->group_id > 0 ) {
|
845 |
$current_group = new BP_Groups_Group( $this->group_id );
|
846 |
$pre_url = bp_get_group_permalink( $current_group );
|
242 |
update_post_meta( $attachment_id, 'bp-media-key', (-$group ) );
|
243 |
}
|
244 |
do_action( 'bp_media_after_add_media', $this, $is_multiple, $is_activity, $group );
|
|
|
245 |
return $attachment_id;
|
246 |
}
|
247 |
|
595 |
$post[ 'post_author' ] = $args[ 'owner' ];
|
596 |
$result = wp_update_post( $post );
|
597 |
$this->init( $this->id );
|
598 |
+
do_action( 'bp_media_after_update_media', $this );
|
599 |
return $result;
|
600 |
}
|
601 |
|
839 |
* @return boolean
|
840 |
*/
|
841 |
protected function set_permalinks() {
|
842 |
+
|
843 |
+
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
844 |
if ( $this->group_id > 0 ) {
|
845 |
$current_group = new BP_Groups_Group( $this->group_id );
|
846 |
$pre_url = bp_get_group_permalink( $current_group );
|
app/main/privacy/BPMediaPrivacy.php
CHANGED
@@ -18,8 +18,10 @@ class BPMediaPrivacy {
|
|
18 |
*
|
19 |
*/
|
20 |
function __construct() {
|
21 |
-
add_action( 'bp_media_after_update_media', array( $this, '
|
22 |
-
add_action( '
|
|
|
|
|
23 |
add_action( 'wp_ajax_bp_media_privacy_install', 'BPMediaPrivacy::install' );
|
24 |
add_action( 'wp_ajax_bp_media_privacy_redirect', array( $this, 'set_option_redirect' ) );
|
25 |
add_action( 'bp_has_activities', array( $this, 'activity' ), 10, 2 );
|
@@ -74,6 +76,10 @@ class BPMediaPrivacy {
|
|
74 |
return $installed;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
77 |
static function get_site_default() {
|
78 |
global $bp_media;
|
79 |
$site_privacy = false;
|
@@ -125,7 +131,7 @@ class BPMediaPrivacy {
|
|
125 |
if ( BPMediaPrivacy::is_enabled() == false )
|
126 |
return;
|
127 |
global $bp_media_current_entry;
|
128 |
-
$privacy_level =
|
129 |
BPMediaPrivacy::ui_html( $privacy_level );
|
130 |
}
|
131 |
|
@@ -150,15 +156,8 @@ class BPMediaPrivacy {
|
|
150 |
<?php
|
151 |
}
|
152 |
|
153 |
-
function save_privacy( $object_id, $type ) {
|
154 |
|
155 |
-
$level = isset( $_POST[ 'bp_media_privacy' ] ) ? $_POST[ 'bp_media_privacy' ] : false;
|
156 |
-
if ( ! $level ) {
|
157 |
-
$level = BPMediaPrivacy::default_privacy();
|
158 |
-
}
|
159 |
-
if(!$level){
|
160 |
-
$level = '0';
|
161 |
-
}
|
162 |
$this->save( $level, $object_id );
|
163 |
if ( $type == 'album' ) {
|
164 |
$args = array(
|
@@ -176,18 +175,30 @@ class BPMediaPrivacy {
|
|
176 |
}
|
177 |
}
|
178 |
|
179 |
-
function
|
|
|
180 |
|
181 |
-
if ( !
|
182 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
|
|
184 |
|
185 |
-
|
|
|
|
|
186 |
}
|
187 |
|
188 |
-
|
189 |
if ( $object_id == false )
|
190 |
return false;
|
|
|
|
|
191 |
|
192 |
$level = apply_filters( 'bp_media_save_privacy', $level );
|
193 |
|
@@ -240,9 +251,9 @@ class BPMediaPrivacy {
|
|
240 |
return;
|
241 |
if ( $object_id == false )
|
242 |
return;
|
243 |
-
$privacy =
|
244 |
$parent = get_post_field( 'post_parent', $object_id, 'raw' );
|
245 |
-
$parent_privacy =
|
246 |
|
247 |
if ( $privacy === false ) {
|
248 |
if ( $parent_privacy !== false ) {
|
@@ -254,6 +265,7 @@ class BPMediaPrivacy {
|
|
254 |
return $privacy;
|
255 |
}
|
256 |
|
|
|
257 |
static function current_access() {
|
258 |
global $bp;
|
259 |
$current_privacy = 0;
|
@@ -265,7 +277,7 @@ class BPMediaPrivacy {
|
|
265 |
}
|
266 |
if ( isset( $bp->displayed_user->id ) )
|
267 |
if ( ! (bp_is_my_profile()) ) {
|
268 |
-
if ( bp_is_active('groups') &&
|
269 |
if ( bp_get_current_group_id() == 0 ) {
|
270 |
$is_friend = friends_check_friendship_status( $bp->loggedin_user->id, $bp->displayed_user->id );
|
271 |
if ( $is_friend == 'is_friend' ) {
|
@@ -326,6 +338,5 @@ class BPMediaPrivacy {
|
|
326 |
}
|
327 |
die( $page );
|
328 |
}
|
329 |
-
|
330 |
}
|
331 |
?>
|
18 |
*
|
19 |
*/
|
20 |
function __construct() {
|
21 |
+
add_action( 'bp_media_after_update_media', array( $this, 'save_privacy_by_object' ),99 );
|
22 |
+
add_action( 'bp_media_after_add_media', array( $this, 'save_privacy_by_object' ),99 );
|
23 |
+
add_action( 'bp_media_after_add_album', array( $this, 'save_privacy_by_object' ),99 );
|
24 |
+
add_action( 'bp_media_after_edit_album', array( $this, 'save_privacy_by_object' ),99 );
|
25 |
add_action( 'wp_ajax_bp_media_privacy_install', 'BPMediaPrivacy::install' );
|
26 |
add_action( 'wp_ajax_bp_media_privacy_redirect', array( $this, 'set_option_redirect' ) );
|
27 |
add_action( 'bp_has_activities', array( $this, 'activity' ), 10, 2 );
|
76 |
return $installed;
|
77 |
}
|
78 |
|
79 |
+
static function get_privacy($id){
|
80 |
+
return get_post_meta( $id, 'bp_media_privacy', TRUE );
|
81 |
+
}
|
82 |
+
|
83 |
static function get_site_default() {
|
84 |
global $bp_media;
|
85 |
$site_privacy = false;
|
131 |
if ( BPMediaPrivacy::is_enabled() == false )
|
132 |
return;
|
133 |
global $bp_media_current_entry;
|
134 |
+
$privacy_level = BPMediaPrivacy::get_privacy( $bp_media_current_entry->get_id());
|
135 |
BPMediaPrivacy::ui_html( $privacy_level );
|
136 |
}
|
137 |
|
156 |
<?php
|
157 |
}
|
158 |
|
159 |
+
function save_privacy( $level, $object_id, $type ) {
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
$this->save( $level, $object_id );
|
162 |
if ( $type == 'album' ) {
|
163 |
$args = array(
|
175 |
}
|
176 |
}
|
177 |
|
178 |
+
function save_privacy_by_object( $object ) {
|
179 |
+
$level = isset( $_POST[ 'bp_media_privacy' ] ) ? $_POST[ 'bp_media_privacy' ] : false;
|
180 |
|
181 |
+
if ( ! is_object( $object ) ) {
|
182 |
return false;
|
183 |
+
}
|
184 |
+
if($level==false){
|
185 |
+
if($object->get_type()!='album'){
|
186 |
+
$album_id = $object->get_album_id();
|
187 |
+
$level = BPMediaPrivacy::get_privacy($album_id);
|
188 |
+
}
|
189 |
|
190 |
+
}
|
191 |
|
192 |
+
$media_id = $object->get_id();
|
193 |
+
$type = $object->get_type();
|
194 |
+
return $this->save_privacy( $level, $media_id, $type );
|
195 |
}
|
196 |
|
197 |
+
function save( $level = 0, $object_id = false ) {
|
198 |
if ( $object_id == false )
|
199 |
return false;
|
200 |
+
if ( ! array_key_exists( $level, BPMediaPrivacy::get_settings() ) )
|
201 |
+
$level = 0;
|
202 |
|
203 |
$level = apply_filters( 'bp_media_save_privacy', $level );
|
204 |
|
251 |
return;
|
252 |
if ( $object_id == false )
|
253 |
return;
|
254 |
+
$privacy = BPMediaPrivacy::get_privacy( $object_id);
|
255 |
$parent = get_post_field( 'post_parent', $object_id, 'raw' );
|
256 |
+
$parent_privacy = BPMediaPrivacy::get_privacy( $parent );
|
257 |
|
258 |
if ( $privacy === false ) {
|
259 |
if ( $parent_privacy !== false ) {
|
265 |
return $privacy;
|
266 |
}
|
267 |
|
268 |
+
|
269 |
static function current_access() {
|
270 |
global $bp;
|
271 |
$current_privacy = 0;
|
277 |
}
|
278 |
if ( isset( $bp->displayed_user->id ) )
|
279 |
if ( ! (bp_is_my_profile()) ) {
|
280 |
+
if ( bp_is_active( 'groups' ) && class_exists( 'BP_Group_Extension' ) ) {
|
281 |
if ( bp_get_current_group_id() == 0 ) {
|
282 |
$is_friend = friends_check_friendship_status( $bp->loggedin_user->id, $bp->displayed_user->id );
|
283 |
if ( $is_friend == 'is_friend' ) {
|
338 |
}
|
339 |
die( $page );
|
340 |
}
|
|
|
341 |
}
|
342 |
?>
|
app/main/privacy/BPMediaPrivacySettings.php
CHANGED
@@ -37,11 +37,12 @@ class BPMediaPrivacySettings {
|
|
37 |
$query =
|
38 |
"SELECT COUNT(*) as Finished
|
39 |
FROM
|
40 |
-
$wpdb->posts RIGHT JOIN $wpdb->postmeta
|
41 |
WHERE
|
42 |
-
|
43 |
-
(
|
44 |
-
|
|
|
45 |
}
|
46 |
|
47 |
function get_total_count(){
|
@@ -49,27 +50,23 @@ class BPMediaPrivacySettings {
|
|
49 |
$query =
|
50 |
"SELECT COUNT(*) as Total
|
51 |
FROM
|
52 |
-
$wpdb->posts RIGHT JOIN $wpdb->postmeta
|
53 |
WHERE
|
54 |
-
|
55 |
-
(
|
56 |
-
|
57 |
return $result;
|
58 |
}
|
59 |
|
60 |
-
function query(){
|
61 |
-
|
62 |
-
}
|
63 |
|
64 |
function init(){
|
65 |
$total = $this->get_total_count();
|
66 |
-
$total = $total[0];
|
67 |
$finished = $this->get_completed_count();
|
|
|
68 |
$finished = $finished[0];
|
69 |
|
70 |
-
|
71 |
echo '<div id="rtprivacyinstaller">';
|
72 |
-
|
73 |
foreach($total as $type=>$count){
|
74 |
echo '<div class="rtprivacytype" id="'.strtolower($type).'">';
|
75 |
echo '<strong>';
|
@@ -96,7 +93,8 @@ class BPMediaPrivacySettings {
|
|
96 |
_e('Start',BP_MEDIA_TXT_DOMAIN);
|
97 |
echo '</button>';
|
98 |
echo '</div>';
|
99 |
-
|
|
|
100 |
}
|
101 |
|
102 |
?>
|
37 |
$query =
|
38 |
"SELECT COUNT(*) as Finished
|
39 |
FROM
|
40 |
+
$wpdb->posts RIGHT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.id
|
41 |
WHERE
|
42 |
+
$wpdb->postmeta.meta_key = 'bp_media_privacy' AND
|
43 |
+
( $wpdb->posts.post_type LIKE 'attachment' OR $wpdb->posts.post_type LIKE 'bp_media_album')";
|
44 |
+
$result = $wpdb->get_results($query);
|
45 |
+
return $result;
|
46 |
}
|
47 |
|
48 |
function get_total_count(){
|
50 |
$query =
|
51 |
"SELECT COUNT(*) as Total
|
52 |
FROM
|
53 |
+
$wpdb->posts RIGHT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.id
|
54 |
WHERE
|
55 |
+
$wpdb->postmeta.meta_key = 'bp-media-key' AND
|
56 |
+
( $wpdb->posts.post_type LIKE 'attachment' OR $wpdb->posts.post_type LIKE 'bp_media_album')";
|
57 |
+
$result = $wpdb->get_results($query);
|
58 |
return $result;
|
59 |
}
|
60 |
|
|
|
|
|
|
|
61 |
|
62 |
function init(){
|
63 |
$total = $this->get_total_count();
|
|
|
64 |
$finished = $this->get_completed_count();
|
65 |
+
$total = $total[0];
|
66 |
$finished = $finished[0];
|
67 |
|
68 |
+
//(isset($total) && isset($finished) && is_array($total) && is_array($finished)){
|
69 |
echo '<div id="rtprivacyinstaller">';
|
|
|
70 |
foreach($total as $type=>$count){
|
71 |
echo '<div class="rtprivacytype" id="'.strtolower($type).'">';
|
72 |
echo '<strong>';
|
93 |
_e('Start',BP_MEDIA_TXT_DOMAIN);
|
94 |
echo '</button>';
|
95 |
echo '</div>';
|
96 |
+
}
|
97 |
+
//}
|
98 |
}
|
99 |
|
100 |
?>
|
app/main/profile/BPMediaAlbum.php
CHANGED
@@ -128,6 +128,7 @@ class BPMediaAlbum {
|
|
128 |
$this->thumbnail = '<img src ="' . BP_MEDIA_URL . 'app/assets/img/image_thumb.png">';
|
129 |
}
|
130 |
$this->filter_entries();
|
|
|
131 |
$this->media_entries = get_children(array(
|
132 |
'post_parent' => $this->id,
|
133 |
'post_type' => 'attachment',
|
@@ -311,6 +312,19 @@ class BPMediaAlbum {
|
|
311 |
function get_id() {
|
312 |
return $this->id;
|
313 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
/**
|
316 |
* Returns the url of the album
|
128 |
$this->thumbnail = '<img src ="' . BP_MEDIA_URL . 'app/assets/img/image_thumb.png">';
|
129 |
}
|
130 |
$this->filter_entries();
|
131 |
+
$this->type = 'album';
|
132 |
$this->media_entries = get_children(array(
|
133 |
'post_parent' => $this->id,
|
134 |
'post_type' => 'attachment',
|
312 |
function get_id() {
|
313 |
return $this->id;
|
314 |
}
|
315 |
+
/**
|
316 |
+
* Returns the id of the album
|
317 |
+
*
|
318 |
+
* @since BuddyPress Media 2.2
|
319 |
+
*/
|
320 |
+
|
321 |
+
/**
|
322 |
+
*
|
323 |
+
* @return type
|
324 |
+
*/
|
325 |
+
function get_type() {
|
326 |
+
return $this->type;
|
327 |
+
}
|
328 |
|
329 |
/**
|
330 |
* Returns the url of the album
|
app/main/profile/BPMediaAlbumScreen.php
CHANGED
@@ -193,7 +193,9 @@ class BPMediaAlbumScreen extends BPMediaScreen {
|
|
193 |
$paged = 1;
|
194 |
$this->filter_entries();
|
195 |
if($bp->current_component=='groups'){
|
196 |
-
|
|
|
|
|
197 |
}
|
198 |
if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
|
199 |
$query = new BPMediaQuery();
|
193 |
$paged = 1;
|
194 |
$this->filter_entries();
|
195 |
if($bp->current_component=='groups'){
|
196 |
+
$query = new BPMediaQuery();
|
197 |
+
$args = $query->init(false,$album_id,false,$paged);
|
198 |
+
$bp_media_query = new WP_Query($args);
|
199 |
}
|
200 |
if ($bp->current_action == BP_MEDIA_ALBUMS_SLUG) {
|
201 |
$query = new BPMediaQuery();
|
app/main/profile/BPMediaUploadScreen.php
CHANGED
@@ -58,7 +58,7 @@ class BPMediaUploadScreen extends BPMediaScreen {
|
|
58 |
'multi_selection' => true,
|
59 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
60 |
);
|
61 |
-
wp_enqueue_script('bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers'),
|
62 |
wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
|
63 |
wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/bp-media-style.css');
|
64 |
//wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
|
58 |
'multi_selection' => true,
|
59 |
'multipart_params' => apply_filters('bp_media_multipart_params_filter', array('action' => 'wp_handle_upload'))
|
60 |
);
|
61 |
+
wp_enqueue_script('bp-media-uploader', BP_MEDIA_URL . 'app/assets/js/bp-media-uploader.js', array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4', 'plupload-handlers'), BP_MEDIA_VERSION);
|
62 |
wp_localize_script('bp-media-uploader', 'bp_media_uploader_params', $params);
|
63 |
wp_enqueue_style('bp-media-default', BP_MEDIA_URL . 'app/assets/css/bp-media-style.css');
|
64 |
//wp_enqueue_style("wp-jquery-ui-dialog"); //Its not styling the Dialog box as it should so using different styling
|
app/main/query/BPMediaQuery.php
CHANGED
@@ -95,7 +95,11 @@ class BPMediaQuery {
|
|
95 |
if ( $count == false ) {
|
96 |
$count = $bp_media->default_count();
|
97 |
}
|
98 |
-
$
|
|
|
|
|
|
|
|
|
99 |
$args[ 'posts_per_page' ] = $limit_offset[ 0 ];
|
100 |
$args[ 'offset' ] = $limit_offset[ 1 ];
|
101 |
}
|
@@ -103,7 +107,7 @@ class BPMediaQuery {
|
|
103 |
return $args;
|
104 |
}
|
105 |
|
106 |
-
function get_limit_offset( $limit, $page ) {
|
107 |
global $bp;
|
108 |
$my_profile = false;
|
109 |
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
@@ -118,7 +122,7 @@ class BPMediaQuery {
|
|
118 |
$my_profile = true;
|
119 |
}
|
120 |
}
|
121 |
-
if ( $my_profile === true ) {
|
122 |
if ( $page > 1 ) {
|
123 |
$offset = $limit * ($page - 1) - 1;
|
124 |
} else {
|
95 |
if ( $count == false ) {
|
96 |
$count = $bp_media->default_count();
|
97 |
}
|
98 |
+
$is_album=false;
|
99 |
+
if($type=='album'){
|
100 |
+
$is_album = true;
|
101 |
+
}
|
102 |
+
$limit_offset = $this->get_limit_offset( $count, $this->prepare_pagination( $page ),$is_album );
|
103 |
$args[ 'posts_per_page' ] = $limit_offset[ 0 ];
|
104 |
$args[ 'offset' ] = $limit_offset[ 1 ];
|
105 |
}
|
107 |
return $args;
|
108 |
}
|
109 |
|
110 |
+
function get_limit_offset( $limit, $page,$album=false ) {
|
111 |
global $bp;
|
112 |
$my_profile = false;
|
113 |
if ( bp_is_active('groups') && class_exists( 'BP_Group_Extension' ) ) {
|
122 |
$my_profile = true;
|
123 |
}
|
124 |
}
|
125 |
+
if ( ($my_profile === true) && ($album==false) ) {
|
126 |
if ( $page > 1 ) {
|
127 |
$offset = $limit * ($page - 1) - 1;
|
128 |
} else {
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videosand audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
-
Version: 2.6.
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
3 |
Plugin Name: BuddyPress Media
|
4 |
Plugin URI: http://rtcamp.com/buddypress-media/
|
5 |
Description: This plugin adds missing media rich features like photos, videosand audios uploading to BuddyPress which are essential if you are building social network, seriously!
|
6 |
+
Version: 2.6.6
|
7 |
Author: rtCamp
|
8 |
Text Domain: buddypress-media
|
9 |
Author URI: http://rtcamp.com
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ License: GPLv2 or later
|
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.5
|
8 |
Tested up to: 3.5
|
9 |
-
Stable tag: 2.6.
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
@@ -117,10 +117,13 @@ Please visit [BuddyPress Media's Features page](http://rtcamp.com/buddypress-med
|
|
117 |
|
118 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
119 |
|
|
|
|
|
|
|
120 |
|
121 |
= 2.6.5 =
|
122 |
* Fixed all warnings and errors with 2.6 thanks to [dzapata79](http://wordpress.org/support/profile/dzapata79), [Scott](http://wordpress.org/support/profile/davidsons).
|
123 |
-
* Special thanks are due to [Stephan Oberlander](http://
|
124 |
|
125 |
= 2.6.4 =
|
126 |
* Improved group compatibility
|
6 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
7 |
Requires at least: 3.5
|
8 |
Tested up to: 3.5
|
9 |
+
Stable tag: 2.6.6
|
10 |
|
11 |
Adds Photos, Music, Videos & Albums to BuddyPress. Supports mobile devices (iPhone/iPad, etc) and automatic audio/video conversion.
|
12 |
|
117 |
|
118 |
Please visit [BuddyPress Media's Roadmap page](http://rtcamp.com/buddypress-media/roadmap/ "Visit BuddyPress Media's Features page") to get some details about future releases.
|
119 |
|
120 |
+
= 2.6.6 =
|
121 |
+
* Fixes automatic count update.
|
122 |
+
* Fixes other bugs in Privacy Update.
|
123 |
|
124 |
= 2.6.5 =
|
125 |
* Fixed all warnings and errors with 2.6 thanks to [dzapata79](http://wordpress.org/support/profile/dzapata79), [Scott](http://wordpress.org/support/profile/davidsons).
|
126 |
+
* Special thanks are due to [Stephan Oberlander](http://cg-creatives.com) who let us use his site for testing and reproducing the errors!
|
127 |
|
128 |
= 2.6.4 =
|
129 |
* Improved group compatibility
|