| @@ -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.min.css', [], BBPC_VERSION ); | |
| 77 | - wp_register_script( 'bbpc-attachments', BBPCATTACHMENT_URL . 'js/front.min.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,33 +240,33 @@ | ||
| 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 | |
| 260 | - $opt = get_option( 'bbp_core_settings' ); | |
| 261 | - | |
| 262 | 260 | if ( ! empty( $attachments ) ) { |
| 263 | 261 | $content .= '<div class="bbp-attachments">'; |
| 264 | - $content .= '<h6>' . __( 'Attachments', 'bbp-core' ) . ':</h6>'; | |
| 262 | + $content .= '<h6>' . __( 'Attachments', 'forumax' ) . ':</h6>'; | |
| 265 | 263 | |
| 266 | - $_download = ' download'; | |
| 264 | + $_download = ' download'; | |
| 267 | 265 | |
| 268 | 266 | if ( ! is_user_logged_in() && BBPCATTCore::instance()->is_hidden_from_visitors() ) { |
| 269 | - $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() ) ); | |
| 270 | 269 | } else { |
| 271 | 270 | $listing = '<ol'; |
| 272 | 271 | $thumbnails = '<ol'; |
| 273 | 272 | |
| @@ -285,11 +284,11 @@ | ||
| 285 | 284 | $url = add_query_arg( 'att_id', $attachment->ID, $url ); |
| 286 | 285 | $url = add_query_arg( 'bbp_id', $id, $url ); |
| 287 | 286 | |
| 288 | 287 | $allow = 'no'; |
| 289 | - if ( bbpc_is_user_admin() ) { | |
| 288 | + if ( forumax_is_user_admin() ) { | |
| 290 | 289 | $allow = 'delete'; |
| 291 | - } elseif ( bbpc_is_user_moderator() ) { | |
| 290 | + } elseif ( forumax_is_user_moderator() ) { | |
| 292 | 291 | $allow = 'delete'; |
| 293 | 292 | } elseif ( $author_id == $user_ID ) { |
| 294 | 293 | $allow = false; |
| 295 | 294 | } |
| @@ -294,13 +293,13 @@ | ||
| 294 | 293 | $allow = false; |
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | if ( $allow == 'delete' || $allow == 'both' ) { |
| 298 | - $actions[] = '<a class="d4p-bba-action-delete" href="' . 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>'; | |
| 299 | 298 | } |
| 300 | - | |
| 299 | + | |
| 301 | 300 | if ( $allow == 'detach' || $allow == 'both' ) { |
| 302 | - $actions[] = '<a class="d4p-bba-action-detach" href="' . 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>'; | |
| 303 | 302 | } |
| 304 | 303 | |
| 305 | 304 | if ( count( $actions ) > 0 ) { |
| 306 | 305 | $actions = ' <span class="d4p-bba-actions">[' . join( ' | ', $actions ) . ']</span>'; |
| @@ -316,18 +315,24 @@ | ||
| 316 | 315 | $html = $class_li = $class_a = $rel_a = ''; |
| 317 | 316 | $a_title = $filename; |
| 318 | 317 | $caption = false; |
| 319 | 318 | |
| 319 | + $is_lighbox = ''; | |
| 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; | |
| 323 | + } | |
| 324 | + | |
| 320 | 325 | $img = false; |
| 321 | - if ( ( $opt['attachment_image_x'] ?? false ) && ( $opt['attachment_image_y'] ?? false ) ) { | |
| 326 | + if ( forumax_get_opt( 'attachment_image_x', false ) && forumax_get_opt( 'attachment_image_y', false ) ) { | |
| 322 | 327 | $html = wp_get_attachment_image( $attachment->ID, 'bbpc-attachment-thumb' ); |
| 323 | 328 | |
| 324 | 329 | if ( $html != '' ) { |
| 325 | 330 | $img = true; |
| 326 | 331 | |
| 327 | - $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'; | |
| 328 | 333 | |
| 329 | - $caption = bbpc_bba_o( 'image_thumbnail_caption' ) == 1; | |
| 334 | + $caption = forumax_bba_o( 'image_thumbnail_caption' ) == 1; | |
| 330 | 335 | } |
| 331 | 336 | } |
| 332 | 337 | |
| 333 | 338 | $item = '<li id="bbpcore-attach_' . $attachment->ID . '" class="bbpcore-attach bbpcore-attachment-' . $ext . ' ' . $class_li . '">'; |
| @@ -333,26 +338,27 @@ | ||
| 333 | 338 | $item = '<li id="bbpcore-attach_' . $attachment->ID . '" class="bbpcore-attach bbpcore-attachment-' . $ext . ' ' . $class_li . '">'; |
| 334 | 339 | |
| 335 | 340 | if ( $html == '' ) { |
| 336 | 341 | $html = $filename; |
| 337 | - $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 ) : ''; | |
| 338 | 343 | } |
| 339 | 344 | |
| 340 | 345 | if ( $img ) { |
| 346 | + | |
| 341 | 347 | if ( $caption ) { |
| 342 | - $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">'; | |
| 343 | 349 | } |
| 344 | 350 | |
| 345 | - $item .= '<a class="' . $class_a . '" href="' . $file_url . '" title="' . $a_title . '">' . $html . '</a>'; | |
| 351 | + $item .= '<a class="' . $class_a . $is_lighbox . '" href="' . $file_url . '" title="' . $a_title .'" '. $_download .'>' . $html . '</a>'; | |
| 346 | 352 | |
| 347 | 353 | if ( $caption ) { |
| 348 | - $a_title = '<a href="' . $file_url . '"' . $_download . '>' . $a_title . '</a>'; | |
| 354 | + $a_title = '<a class="' . $is_lighbox . '" href="' . $file_url . '"' . $_download . '>' . $a_title . '</a>'; | |
| 349 | 355 | |
| 350 | 356 | $item .= '<p class="wp-caption-text">' . $a_title . '<br/>' . $actions . '</p></div>'; |
| 351 | 357 | } |
| 352 | 358 | } else { |
| 353 | 359 | $item .= '<span role="presentation" class="' . $class_li . '"></span> '; |
| 354 | - $item .= '<div class="d4p-bbp-att-wrapper"><a class="' . $class_a . '"' . $rel_a . $_download . ' href="' . $file_url . '" title="' . $a_title . '">' . $html . '</a>' . $actions . '</div>'; | |
| 360 | + $item .= '<div class="d4p-bbp-att-wrapper"><a class="' . $class_a . $is_lighbox . '"' . $rel_a . $_download . ' href="' . $file_url . '" title="' . $a_title . '">' . $html . '</a>' . $actions . '</div>'; | |
| 355 | 361 | } |
| 356 | 362 | |
| 357 | 363 | $item .= '</li>'; |
| 358 | 364 | |
| @@ -379,14 +385,14 @@ | ||
| 379 | 385 | |
| 380 | 386 | $content .= '</div>'; |
| 381 | 387 | } |
| 382 | 388 | |
| 383 | - if ( bbpc_is_user_admin() || bbpc_is_user_moderator() ) { | |
| 389 | + if ( forumax_is_user_admin() || forumax_is_user_moderator() ) { | |
| 384 | 390 | $errors = get_post_meta( $id, '_bbp_attachment_upload_error' ); |
| 385 | 391 | |
| 386 | 392 | if ( ! empty( $errors ) ) { |
| 387 | 393 | $content .= '<div class="bbp-attachments-errors">'; |
| 388 | - $content .= '<h6>' . __( 'Upload Errors', 'bbp-core' ) . ':</h6>'; | |
| 394 | + $content .= '<h6>' . __( 'Upload Errors', 'forumax' ) . ':</h6>'; | |
| 389 | 395 | $content .= '<ol'; |
| 390 | 396 | |
| 391 | 397 | $class_li = 'bbp-file-error'; |
| 392 | 398 | |
| @@ -396,9 +402,9 @@ | ||
| 396 | 402 | $content .= '>'; |
| 397 | 403 | |
| 398 | 404 | foreach ( $errors as $error ) { |
| 399 | 405 | $content .= '<li class="' . $class_li . '"><span role="presentation" class="' . $class_li . '"></span> '; |
| 400 | - $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>'; | |
| 401 | 407 | } |
| 402 | 408 | |
| 403 | 409 | $content .= '</ol></div>'; |
| 404 | 410 | } |
| @@ -407,19 +413,19 @@ | ||
| 407 | 413 | return $content; |
| 408 | 414 | } |
| 409 | 415 | |
| 410 | 416 | public function embed_form() { |
| 411 | - $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() ); | |
| 412 | 418 | if ( ! $can_upload ) { |
| 413 | 419 | return; |
| 414 | 420 | } |
| 415 | 421 | |
| 416 | - $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() ); | |
| 417 | 423 | if ( ! $is_enabled ) { |
| 418 | 424 | return; |
| 419 | 425 | } |
| 420 | 426 | |
| 421 | - $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() ); | |
| 422 | 428 | |
| 423 | 429 | include BBPCATTACHMENTS_PATH . 'forms/uploader.php'; |
| 424 | 430 | } |
| 425 | 431 | } |