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