PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
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 2.0.0 All 30 releases
← All changes | includes/features/bbpc_attachments/code/front.php +31 -30 1.3.2 → 2.5.0 View file →
@@ -40,9 +40,9 @@
40 40
41 41 public function load() {
42 42 add_action( 'wp_enqueue_scripts', [ $this, 'wp_enqueue_scripts' ] );
43 43
44 - add_action( 'bbp_theme_before_reply_form_submit_wrapper', [ $this, 'embed_form' ] );
44 + add_action( 'frmx_reply_attachments', [ $this, 'embed_form' ] );
45 45 add_action( 'bbp_theme_before_topic_form_submit_wrapper', [ $this, 'embed_form' ] );
46 46
47 47 add_action( 'bbp_edit_reply', [ $this, 'edit_reply' ], 10, 5 );
48 48 add_action( 'bbp_edit_topic', [ $this, 'edit_topic' ], 10, 4 );
@@ -51,9 +51,9 @@
51 51
52 52 add_filter( 'bbp_get_reply_content', [ $this, 'embed_attachments' ], 100, 2 );
53 53 add_filter( 'bbp_get_topic_content', [ $this, 'embed_attachments' ], 100, 2 );
54 54
55 - if ( bbpc_bba_o( 'is_attachment_icon' ) == 1 ) {
55 + if ( forumax_bba_o( 'is_attachment_icon' ) == 1 ) {
56 56 add_action( 'bbp_theme_before_topic_title', [ $this, 'show_attachments_icon' ] );
57 57 }
58 58
59 59 $this->register_scripts_and_styles();
@@ -71,11 +71,10 @@
71 71 return 'generic';
72 72 }
73 73
74 74 public function register_scripts_and_styles() {
75 - //TODO: Fix the constant for version
76 - wp_register_style( 'bbpc-attachments', BBPCATTACHMENT_URL . 'css/front.css', [], BBPC_VERSION );
77 - wp_register_script( 'bbpc-attachments', BBPCATTACHMENT_URL . 'js/front.js', [ 'jquery' ], BBPC_VERSION, true );
75 + wp_register_style( 'bbpc-attachments', BBPCATTACHMENT_URL . 'css/front.css', [], FORUMAX_VERSION );
76 + wp_register_script( 'bbpc-attachments', BBPCATTACHMENT_URL . 'js/front.js', [ 'jquery' ], FORUMAX_VERSION, true );
78 77 }
79 78
80 79 public function include_scripts_and_styles() {
81 80 wp_enqueue_style( 'bbpc-attachments' );
@@ -85,15 +84,15 @@
85 84 'bbpc-attachments',
86 85 'bbpcAttachmentsInit',
87 86 [
88 87 'max_files' => apply_filters( 'bbpc_bbpressattchment_allow_upload', BBPCATTCore::instance()->get_max_files(), bbp_get_forum_id() ),
89 - 'are_you_sure' => __( 'This operation is not reversible. Are you sure?', 'bbp-core' ),
88 + 'are_you_sure' => __( 'This operation is not reversible. Are you sure?', 'forumax' ),
90 89 ]
91 90 );
92 91 }
93 92
94 93 public function wp_enqueue_scripts() {
95 - if ( bbpc_is_bbpress() ) {
94 + if ( forumax_is_bbpress() ) {
96 95 $this->include_scripts_and_styles();
97 96 }
98 97 }
99 98
@@ -241,19 +240,20 @@
241 240 }
242 241
243 242 public function show_attachments_icon() {
244 243 $topic_id = bbp_get_topic_id();
245 - $count = bbpc_topic_attachments_count( $topic_id, true );
244 + $count = forumax_topic_attachments_count( $topic_id, true );
246 245
247 246 if ( $count > 0 ) {
248 - echo '<span class="bbp-attachments-count" title="' . $count . ' ' . _n( 'attachment', 'attachments', $count, 'bbp-core' ) . '"></span>';
247 + echo '<span class="bbp-attachments-count" aria-hidden="true" title="' . esc_attr( $count . ' ' . _n( 'attachment', 'attachments', $count, 'forumax' ) ) . '"></span>';
249 248 }
249 +
250 250 }
251 251
252 252 public function embed_attachments( $content, $id ) {
253 253 global $user_ID;
254 254
255 - $attachments = bbpc_get_post_attachments( $id );
255 + $attachments = forumax_get_post_attachments( $id );
256 256
257 257 $post = get_post( $id );
258 258 $author_id = $post->post_author;
259 259
@@ -258,14 +258,15 @@
258 258 $author_id = $post->post_author;
259 259
260 260 if ( ! empty( $attachments ) ) {
261 261 $content .= '<div class="bbp-attachments">';
262 - $content .= '<h6>' . __( 'Attachments', 'bbp-core' ) . ':</h6>';
262 + $content .= '<h6>' . __( 'Attachments', 'forumax' ) . ':</h6>';
263 263
264 264 $_download = ' download';
265 265
266 266 if ( ! is_user_logged_in() && BBPCATTCore::instance()->is_hidden_from_visitors() ) {
267 - $content .= sprintf( __( "You must be <a href='%s'>logged in</a> to view attached files.", 'bbp-core' ), wp_login_url( get_permalink() ) );
267 + /* translators: %s: Login URL */
268 + $content .= sprintf( __( "You must be <a href='%s'>logged in</a> to view attached files.", 'forumax' ), wp_login_url( get_permalink() ) );
268 269 } else {
269 270 $listing = '<ol';
270 271 $thumbnails = '<ol';
271 272
@@ -283,11 +284,11 @@
283 284 $url = add_query_arg( 'att_id', $attachment->ID, $url );
284 285 $url = add_query_arg( 'bbp_id', $id, $url );
285 286
286 287 $allow = 'no';
287 - if ( bbpc_is_user_admin() ) {
288 + if ( forumax_is_user_admin() ) {
288 289 $allow = 'delete';
289 - } elseif ( bbpc_is_user_moderator() ) {
290 + } elseif ( forumax_is_user_moderator() ) {
290 291 $allow = 'delete';
291 292 } elseif ( $author_id == $user_ID ) {
292 293 $allow = false;
293 294 }
@@ -292,13 +293,13 @@
292 293 $allow = false;
293 294 }
294 295
295 296 if ( $allow == 'delete' || $allow == 'both' ) {
296 - $actions[] = '<a class="d4p-bba-action-delete" href="' . esc_url( add_query_arg( 'd4pbbaction', 'delete', $url ) ) . '">' . __( 'delete', 'bbp-core' ) . '</a>';
297 + $actions[] = '<a class="d4p-bba-action-delete" href="' . esc_url( add_query_arg( 'd4pbbaction', 'delete', $url ) ) . '">' . __( 'delete', 'forumax' ) . '</a>';
297 298 }
298 299
299 300 if ( $allow == 'detach' || $allow == 'both' ) {
300 - $actions[] = '<a class="d4p-bba-action-detach" href="' . esc_url( add_query_arg( 'd4pbbaction', 'detach', $url ) ) . '">' . __( 'detach', 'bbp-core' ) . '</a>';
301 + $actions[] = '<a class="d4p-bba-action-detach" href="' . esc_url( add_query_arg( 'd4pbbaction', 'detach', $url ) ) . '">' . __( 'detach', 'forumax' ) . '</a>';
301 302 }
302 303
303 304 if ( count( $actions ) > 0 ) {
304 305 $actions = ' <span class="d4p-bba-actions">[' . join( ' | ', $actions ) . ']</span>';
@@ -315,23 +316,23 @@
315 316 $a_title = $filename;
316 317 $caption = false;
317 318
318 319 $is_lighbox = '';
319 - if ( bbpc_is_premium() ) {
320 - $is_lighbox = bbpc_get_opt( 'image_link_type' ) == 'lightbox' ? ' bbpc-lightbox' : '';
321 - $_download = bbpc_get_opt( 'image_link_type' ) == 'lightbox' ? '' : $_download;
320 + if ( forumax_is_premium() ) {
321 + $is_lighbox = forumax_get_opt( 'image_link_type' ) == 'lightbox' ? ' bbpc-lightbox' : '';
322 + $_download = forumax_get_opt( 'image_link_type' ) == 'lightbox' ? '' : $_download;
322 323 }
323 324
324 325 $img = false;
325 - if ( bbpc_get_opt( 'attachment_image_x', false ) && bbpc_get_opt( 'attachment_image_y', false ) ) {
326 + if ( forumax_get_opt( 'attachment_image_x', false ) && forumax_get_opt( 'attachment_image_y', false ) ) {
326 327 $html = wp_get_attachment_image( $attachment->ID, 'bbpc-attachment-thumb' );
327 328
328 329 if ( $html != '' ) {
329 330 $img = true;
330 331
331 - $class_li = 'bbp-atthumb';
332 + $class_li = forumax_bba_o( 'is_file_type_icon' ) == 1 ? 'bbp-atthumb bbp-atticon bbp-atticon-' . $this->icon( $ext ) : 'bbp-atthumb';
332 333
333 - $caption = bbpc_bba_o( 'image_thumbnail_caption' ) == 1;
334 + $caption = forumax_bba_o( 'image_thumbnail_caption' ) == 1;
334 335 }
335 336 }
336 337
337 338 $item = '<li id="bbpcore-attach_' . $attachment->ID . '" class="bbpcore-attach bbpcore-attachment-' . $ext . ' ' . $class_li . '">';
@@ -337,15 +338,15 @@
337 338 $item = '<li id="bbpcore-attach_' . $attachment->ID . '" class="bbpcore-attach bbpcore-attachment-' . $ext . ' ' . $class_li . '">';
338 339
339 340 if ( $html == '' ) {
340 341 $html = $filename;
341 - $class_li = 'bbp-atticon bbp-atticon-' . $this->icon( $ext );
342 + $class_li = forumax_bba_o( 'is_file_type_icon' ) == 1 ? 'bbp-atticon bbp-atticon-' . $this->icon( $ext ) : '';
342 343 }
343 344
344 345 if ( $img ) {
345 346
346 347 if ( $caption ) {
347 - $item .= '<div style="width: ' . bbpc_bba_o( 'attachment_image_x' ) . 'px" class="wp-caption">';
348 + $item .= '<div style="width: ' . forumax_bba_o( 'attachment_image_x' ) . 'px" class="wp-caption">';
348 349 }
349 350
350 351 $item .= '<a class="' . $class_a . $is_lighbox . '" href="' . $file_url . '" title="' . $a_title .'" '. $_download .'>' . $html . '</a>';
351 352
@@ -384,14 +385,14 @@
384 385
385 386 $content .= '</div>';
386 387 }
387 388
388 - if ( bbpc_is_user_admin() || bbpc_is_user_moderator() ) {
389 + if ( forumax_is_user_admin() || forumax_is_user_moderator() ) {
389 390 $errors = get_post_meta( $id, '_bbp_attachment_upload_error' );
390 391
391 392 if ( ! empty( $errors ) ) {
392 393 $content .= '<div class="bbp-attachments-errors">';
393 - $content .= '<h6>' . __( 'Upload Errors', 'bbp-core' ) . ':</h6>';
394 + $content .= '<h6>' . __( 'Upload Errors', 'forumax' ) . ':</h6>';
394 395 $content .= '<ol';
395 396
396 397 $class_li = 'bbp-file-error';
397 398
@@ -401,9 +402,9 @@
401 402 $content .= '>';
402 403
403 404 foreach ( $errors as $error ) {
404 405 $content .= '<li class="' . $class_li . '"><span role="presentation" class="' . $class_li . '"></span> ';
405 - $content .= '<div class="d4p-bbp-att-wrapper"><strong>' . esc_html( $error['file'] ) . '</strong>: ' . __( $error['message'], 'bbp-core' ) . '</div></li>';
406 + $content .= '<div class="d4p-bbp-att-wrapper"><strong>' . esc_html( $error['file'] ) . '</strong>: ' . esc_html( $error['message'] ) . '</div></li>';
406 407 }
407 408
408 409 $content .= '</ol></div>';
409 410 }
@@ -412,19 +413,19 @@
412 413 return $content;
413 414 }
414 415
415 416 public function embed_form() {
416 - $can_upload = apply_filters( 'bbpc_bbpressattchment_allow_upload', BBPCATTCore::instance()->is_user_allowed(), bbpc_get_forum_id() );
417 + $can_upload = apply_filters( 'bbpc_bbpressattchment_allow_upload', BBPCATTCore::instance()->is_user_allowed(), forumax_get_forum_id() );
417 418 if ( ! $can_upload ) {
418 419 return;
419 420 }
420 421
421 - $is_enabled = apply_filters( 'bbpc_bbpressattchment_forum_enabled', BBPCATTCore::instance()->enabled_for_forum(), bbpc_get_forum_id() );
422 + $is_enabled = apply_filters( 'bbpc_bbpressattchment_forum_enabled', BBPCATTCore::instance()->enabled_for_forum(), forumax_get_forum_id() );
422 423 if ( ! $is_enabled ) {
423 424 return;
424 425 }
425 426
426 - $file_size = apply_filters( 'bbpc_bbpressattchment_max_file_size', BBPCATTCore::instance()->get_file_size(), bbpc_get_forum_id() );
427 + $file_size = apply_filters( 'bbpc_bbpressattchment_max_file_size', BBPCATTCore::instance()->get_file_size(), forumax_get_forum_id() );
427 428
428 429 include BBPCATTACHMENTS_PATH . 'forms/uploader.php';
429 430 }
430 431 }