Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | n/a |
0 / 0 |
|
| jetpack_bbpress_compat | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
30 | |||
| jetpack_sharing_bbpress | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Compatibility functions for bbpress. |
| 4 | * |
| 5 | * Only added if bbpress is active via function_exists( 'bbpress' ) in 3rd-party.php. |
| 6 | * |
| 7 | * @package automattic/jetpack |
| 8 | */ |
| 9 | |
| 10 | use Automattic\Jetpack\Image_CDN\Image_CDN; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit( 0 ); |
| 14 | } |
| 15 | |
| 16 | // Priority 11 needed to ensure sharing_display is loaded. |
| 17 | add_action( 'init', 'jetpack_bbpress_compat', 11 ); |
| 18 | |
| 19 | /** |
| 20 | * Adds Jetpack + bbPress Compatibility filters. |
| 21 | * |
| 22 | * @author Brandon Kraft |
| 23 | * @since 3.7.1 |
| 24 | */ |
| 25 | function jetpack_bbpress_compat() { |
| 26 | /** |
| 27 | * Add compatibility layer for REST API. |
| 28 | * |
| 29 | * @since 8.5.0 Moved from root-level file and check_rest_api_compat() |
| 30 | */ |
| 31 | require_once __DIR__ . '/class-jetpack-bbpress-rest-api.php'; |
| 32 | Jetpack_BbPress_REST_API::instance(); |
| 33 | |
| 34 | // Adds sharing buttons to bbPress items. |
| 35 | if ( function_exists( 'sharing_display' ) ) { |
| 36 | add_filter( 'bbp_get_topic_content', 'sharing_display', 19 ); |
| 37 | add_action( 'bbp_template_after_single_forum', 'jetpack_sharing_bbpress' ); |
| 38 | add_action( 'bbp_template_after_single_topic', 'jetpack_sharing_bbpress' ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Enable Markdown support for bbpress post types. |
| 43 | * |
| 44 | * @author Brandon Kraft |
| 45 | * @since 6.0.0 |
| 46 | */ |
| 47 | if ( function_exists( 'bbp_get_topic_post_type' ) ) { |
| 48 | add_post_type_support( bbp_get_topic_post_type(), 'wpcom-markdown' ); |
| 49 | add_post_type_support( bbp_get_reply_post_type(), 'wpcom-markdown' ); |
| 50 | add_post_type_support( bbp_get_forum_post_type(), 'wpcom-markdown' ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Use Photon for all images in Topics and replies. |
| 55 | * |
| 56 | * @since 4.9.0 |
| 57 | */ |
| 58 | if ( class_exists( Image_CDN::class ) && Image_CDN::is_enabled() ) { |
| 59 | add_filter( 'bbp_get_topic_content', array( Image_CDN::class, 'filter_the_content' ), 999999 ); |
| 60 | add_filter( 'bbp_get_reply_content', array( Image_CDN::class, 'filter_the_content' ), 999999 ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Display Jetpack "Sharing" buttons on bbPress 2.x forums/ topics/ lead topics/ replies. |
| 66 | * |
| 67 | * Determination if the sharing buttons should display on the post type is handled within sharing_display(). |
| 68 | * |
| 69 | * @author David Decker |
| 70 | * @since 3.7.0 |
| 71 | */ |
| 72 | function jetpack_sharing_bbpress() { |
| 73 | sharing_display( null, true ); |
| 74 | } |