PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.1
Forumax – AI Powered Advanced Community Forum Plugin v2.5.1
2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 All 31 releases
← All changes | includes/features/bbpc_attachments/code/class.php +20 -13 1.4.0 → 2.5.1 View file →
@@ -84,18 +84,23 @@
84 84 }
85 85
86 86 public function delete_attachments() {
87 87 if ( isset( $_GET['d4pbbaction'] ) ) {
88 - $nonce = wp_verify_nonce( $_GET['_wpnonce'], 'd4p-bbpress-attachments' );
88 + $nonce = isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'd4p-bbpress-attachments' );
89 + $post = isset( $_GET['bbp_id'] ) ? get_post( intval( $_GET['bbp_id'] ) ) : null;
89 90
90 - if ( $nonce ) {
91 + if ( $nonce && $post && isset( $_GET['att_id'] ) ) {
91 92 global $user_ID;
92 93
93 - $action = $_GET['d4pbbaction'];
94 + $action = sanitize_key( wp_unslash( $_GET['d4pbbaction'] ) );
94 95 $att_id = intval( $_GET['att_id'] );
95 - $bbp_id = intval( $_GET['bbp_id'] );
96 + $bbp_id = (int) $post->ID;
96 97
97 - $post = get_post( $bbp_id );
98 + // Only act on an attachment of this topic/reply, never any media ID.
99 + if ( 'attachment' !== get_post_type( $att_id ) || (int) wp_get_post_parent_id( $att_id ) !== $bbp_id ) {
100 + return;
101 + }
102 +
98 103 $author_ID = $post->post_author;
99 104
100 105 $file = get_attached_file( $att_id );
101 106 $file = pathinfo( $file, PATHINFO_BASENAME );
@@ -100,11 +105,11 @@
100 105 $file = get_attached_file( $att_id );
101 106 $file = pathinfo( $file, PATHINFO_BASENAME );
102 107
103 108 $allow = 'no';
104 - if ( bbpc_is_user_admin() ) {
109 + if ( forumax_is_user_admin() ) {
105 110 $allow = 'delete';
106 - } elseif ( bbpc_is_user_moderator() ) {
111 + } elseif ( forumax_is_user_moderator() ) {
107 112 $allow = 'delete';
108 113 } elseif ( $author_ID == $user_ID ) {
109 114 $allow = false;
110 115 }
@@ -145,13 +150,13 @@
145 150 }
146 151 }
147 152
148 153 public function delete_post( $id ) {
149 - if ( bbpc_has_bbpress() ) {
154 + if ( forumax_has_bbpress() ) {
150 155 if ( bbp_is_reply( $id ) || bbp_is_topic( $id ) ) {
151 156 //TODO: Add conditions in pro
152 157 // if ( $this->o['delete_attachments'] == 'delete' ) {
153 - // $files = bbpc_get_post_attachments( $id );
158 + // $files = forumax_get_post_attachments( $id );
154 159
155 160 // if ( is_array( $files ) && ! empty( $files ) ) {
156 161 // foreach ( $files as $file ) {
157 162 // wp_delete_attachment( $file->ID );
@@ -180,9 +185,9 @@
180 185
181 186 public function get_file_size( $global_only = false, $forum_id = 0 ) {
182 187 $forum_id = $forum_id == 0 ? bbp_get_forum_id() : $forum_id;
183 188
184 - if ( ! class_exists( 'BBPCorePro' ) ){
189 + if ( ! class_exists( 'Forumax_Pro' ) ){
185 190 $value = 512;
186 191 // $value = (int) $this->o['max_file_size'] ?? 512;
187 192 }else{
188 193 $value = $this->o['max_file_size'] ?? 512;
@@ -200,9 +205,9 @@
200 205 }
201 206
202 207 public function get_max_files( $global_only = false, $forum_id = 0 ) {
203 208 $forum_id = $forum_id == 0 ? bbp_get_forum_id() : $forum_id;
204 - if( ! class_exists( 'BBPCorePro' ) ){
209 + if( ! class_exists( 'Forumax_Pro' ) ){
205 210 $value = 4;
206 211 }else{
207 212 $value = $this->o['max_file_uploads'] ?? 4;
208 213 }
@@ -262,9 +267,9 @@
262 267 return apply_filters( 'bbpc_bbpressattchment_is_hidden_from_visitors', $value == 1 );
263 268 }
264 269
265 270 public function topic_attachment_deletion($topic_id){
266 - if( class_exists( 'BBPCorePro' ) ){
271 + if( class_exists( 'Forumax_Pro' ) ){
267 272 $topic_deletion = $this->o['is_attachment_deletion'] ?? '';
268 273
269 274 if( $topic_deletion == 1 && get_post_type($topic_id) == bbp_get_topic_post_type() ) {
270 275 $topic_attachments = get_attached_media( '', $topic_id );
@@ -276,9 +281,9 @@
276 281 }
277 282
278 283 public function reply_attachment_deletion($reply_id){
279 284
280 - if( class_exists( 'BBPCorePro' ) ){
285 + if( class_exists( 'Forumax_Pro' ) ){
281 286 $reply_deletion = $this->o['is_attachment_deletion'] ?? '';
282 287
283 288 if( $reply_deletion == 1 && get_post_type($reply_id) == bbp_get_reply_post_type() ) {
284 289 $replies_attachments = get_attached_media( '', $reply_id );
@@ -289,4 +294,6 @@
289 294 }
290 295 }
291 296 }
292 297 }
298 +
299 +