/bp-blogs/bp-blogs-filters.php

  1. <?php 
  2. /** 
  3. * Filters related to the Blogs component. 
  4. * 
  5. * @package BuddyPress 
  6. * @subpackage BlogFilters 
  7. * @since 1.6.0 
  8. */ 
  9.  
  10. /** Display Filters **********************************************************/ 
  11.  
  12. add_filter( 'bp_get_blog_latest_post_title', 'wptexturize' ); 
  13. add_filter( 'bp_get_blog_latest_post_title', 'convert_chars' ); 
  14. add_filter( 'bp_get_blog_latest_post_title', 'trim' ); 
  15.  
  16. add_filter( 'bp_blog_latest_post_content', 'wptexturize' ); 
  17. add_filter( 'bp_blog_latest_post_content', 'convert_smilies' ); 
  18. add_filter( 'bp_blog_latest_post_content', 'convert_chars' ); 
  19. add_filter( 'bp_blog_latest_post_content', 'wpautop' ); 
  20. add_filter( 'bp_blog_latest_post_content', 'shortcode_unautop' ); 
  21. add_filter( 'bp_blog_latest_post_content', 'prepend_attachment' ); 
  22.  
  23. /** 
  24. * Ensure that the 'Create a new site' link at wp-admin/my-sites.php points to the BP blog signup. 
  25. * 
  26. * @since 1.6.0 
  27. * 
  28. * returned value. 
  29. * 
  30. * @param string $url The original URL (points to wp-signup.php by default). 
  31. * @return string The new URL. 
  32. */ 
  33. function bp_blogs_creation_location( $url ) { 
  34.  
  35. /** 
  36. * Filters the 'Create a new site' link URL. 
  37. * 
  38. * @since 1.6.0 
  39. * 
  40. * @param string $value URL for the 'Create a new site' signup page. 
  41. */ 
  42. return apply_filters( 'bp_blogs_creation_location', trailingslashit( bp_get_blogs_directory_permalink() . 'create' ), $url ); 
  43. add_filter( 'wp_signup_location', 'bp_blogs_creation_location' ); 
  44.  
  45. /** 
  46. * Only select comments by ID instead of all fields when using get_comments(). 
  47. * 
  48. * @since 2.1.0 
  49. * 
  50. * @see bp_blogs_update_post_activity_meta() 
  51. * 
  52. * @param array $retval Current SQL clauses in array format. 
  53. * @return array 
  54. */ 
  55. function bp_blogs_comments_clauses_select_by_id( $retval ) { 
  56. $retval['fields'] = 'comment_ID'; 
  57.  
  58. return $retval; 
  59.  
  60. /** 
  61. * Check whether the current activity about a post or a comment can be published. 
  62. * 
  63. * Abstracted from the deprecated `bp_blogs_record_post()`. 
  64. * 
  65. * @since 2.2.0 
  66. * 
  67. * @param bool $return Whether the post should be published. 
  68. * @param int $blog_id ID of the blog. 
  69. * @param int $post_id ID of the post. 
  70. * @param int $user_id ID of the post author. 
  71. * @return bool True to authorize the post to be published, otherwise false. 
  72. */ 
  73. function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) { 
  74. $bp = buddypress(); 
  75.  
  76. // If blog is not trackable, do not record the activity. 
  77. if ( ! bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) { 
  78. return false; 
  79.  
  80. /** 
  81. * Stop infinite loops with WordPress MU Sitewide Tags. 
  82. * That plugin changed the way its settings were stored at some point. Thus the dual check. 
  83. */ 
  84. $sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' ); 
  85. if ( ! empty( $sitewide_tags_blog_settings ) ) { 
  86. $st_options = maybe_unserialize( $sitewide_tags_blog_settings ); 
  87. $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0; 
  88. } else { 
  89. $tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' ); 
  90. $tags_blog_id = intval( $tags_blog_id ); 
  91.  
  92. /** 
  93. * Filters whether or not BuddyPress should block sitewide tags activity. 
  94. * 
  95. * @since 2.2.0 
  96. * 
  97. * @param bool $value Current status of the sitewide tags activity. 
  98. */ 
  99. if ( (int) $blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) ) { 
  100. return false; 
  101.  
  102. /** 
  103. * Filters whether or not the current blog is public. 
  104. * 
  105. * @since 2.2.0 
  106. * 
  107. * @param int $value Value from the blog_public option for the current blog. 
  108. */ 
  109. $is_blog_public = apply_filters( 'bp_is_blog_public', (int) get_blog_option( $blog_id, 'blog_public' ) ); 
  110.  
  111. if ( 0 === $is_blog_public && is_multisite() ) { 
  112. return false; 
  113.  
  114. return $return; 
  115. add_filter( 'bp_activity_post_pre_publish', 'bp_blogs_post_pre_publish', 10, 4 ); 
  116. add_filter( 'bp_activity_post_pre_comment', 'bp_blogs_post_pre_publish', 10, 4 ); 
  117.  
  118. /** 
  119. * Registers our custom thumb size with WP's Site Icon feature. 
  120. * 
  121. * @since 2.7.0 
  122. * 
  123. * @param array $sizes Current array of custom site icon sizes. 
  124. * @return array 
  125. */ 
  126. function bp_blogs_register_custom_site_icon_size( $sizes ) { 
  127. $sizes[] = bp_core_avatar_thumb_width(); 
  128. return $sizes; 
  129. add_filter( 'site_icon_image_sizes', 'bp_blogs_register_custom_site_icon_size' ); 
.