Нет описания

bbpress.php 2.0KB

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