[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
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 } 44 add_filter( 'wp_signup_location', 'bp_blogs_creation_location' ); 45 46 /** 47 * Only select comments by ID instead of all fields when using get_comments(). 48 * 49 * @since 2.1.0 50 * 51 * @see bp_blogs_update_post_activity_meta() 52 * 53 * @param array $retval Current SQL clauses in array format. 54 * @return array 55 */ 56 function bp_blogs_comments_clauses_select_by_id( $retval ) { 57 $retval['fields'] = 'comment_ID'; 58 59 return $retval; 60 } 61 62 /** 63 * Check whether the current activity about a post or a comment can be published. 64 * 65 * Abstracted from the deprecated `bp_blogs_record_post()`. 66 * 67 * @since 2.2.0 68 * 69 * @param bool $return Whether the post should be published. 70 * @param int $blog_id ID of the blog. 71 * @param int $post_id ID of the post. 72 * @param int $user_id ID of the post author. 73 * @return bool True to authorize the post to be published, otherwise false. 74 */ 75 function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) { 76 $bp = buddypress(); 77 78 // If blog is not trackable, do not record the activity. 79 if ( ! bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) { 80 return false; 81 } 82 83 /* 84 * Stop infinite loops with WordPress MU Sitewide Tags. 85 * That plugin changed the way its settings were stored at some point. Thus the dual check. 86 */ 87 $sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' ); 88 if ( ! empty( $sitewide_tags_blog_settings ) ) { 89 $st_options = maybe_unserialize( $sitewide_tags_blog_settings ); 90 $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0; 91 } else { 92 $tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' ); 93 $tags_blog_id = intval( $tags_blog_id ); 94 } 95 96 /** 97 * Filters whether or not BuddyPress should block sitewide tags activity. 98 * 99 * @since 2.2.0 100 * 101 * @param bool $value Current status of the sitewide tags activity. 102 */ 103 if ( (int) $blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) ) { 104 return false; 105 } 106 107 /** 108 * Filters whether or not the current blog is public. 109 * 110 * @since 2.2.0 111 * 112 * @param int $value Value from the blog_public option for the current blog. 113 */ 114 $is_blog_public = apply_filters( 'bp_is_blog_public', (int) get_blog_option( $blog_id, 'blog_public' ) ); 115 116 if ( 0 === $is_blog_public && is_multisite() ) { 117 return false; 118 } 119 120 return $return; 121 } 122 add_filter( 'bp_activity_post_pre_publish', 'bp_blogs_post_pre_publish', 10, 4 ); 123 add_filter( 'bp_activity_post_pre_comment', 'bp_blogs_post_pre_publish', 10, 4 ); 124 125 /** 126 * Registers our custom thumb size with WP's Site Icon feature. 127 * 128 * @since 2.7.0 129 * 130 * @param array $sizes Current array of custom site icon sizes. 131 * @return array 132 */ 133 function bp_blogs_register_custom_site_icon_size( $sizes ) { 134 $sizes[] = bp_core_avatar_thumb_width(); 135 return $sizes; 136 } 137 add_filter( 'site_icon_image_sizes', 'bp_blogs_register_custom_site_icon_size' ); 138 139 /** 140 * Use the mystery blog avatar for blogs. 141 * 142 * @since 7.0.0 143 * 144 * @param string $avatar Current avatar src. 145 * @param array $params Avatar params. 146 * @return string 147 */ 148 function bp_blogs_default_avatar( $avatar, $params ) { 149 if ( isset( $params['object'] ) && 'blog' === $params['object'] ) { 150 if ( isset( $params['type'] ) && 'thumb' === $params['type'] ) { 151 $file = 'mystery-blog-50.png'; 152 } else { 153 $file = 'mystery-blog.png'; 154 } 155 156 $avatar = buddypress()->plugin_url . "bp-core/images/$file"; 157 } 158 159 return $avatar; 160 } 161 add_filter( 'bp_core_default_avatar', 'bp_blogs_default_avatar', 10, 2 ); 162 add_filter( 'bp_core_avatar_default_thumb', 'bp_blogs_default_avatar', 10, 2 ); 163 164 /** 165 * Filters the column name during blog metadata queries. 166 * 167 * This filters 'sanitize_key', which is used during various core metadata 168 * API functions: {@link https://core.trac.wordpress.org/browser/branches/4.9/src/wp-includes/meta.php?lines=47,160,324}. 169 * Due to how we are passing our meta type, we need to ensure that the correct 170 * DB column is referenced during blogmeta queries. 171 * 172 * @since 4.0.0 173 * 174 * @see bp_blogs_delete_blogmeta() 175 * @see bp_blogs_get_blogmeta() 176 * @see bp_blogs_update_blogmeta() 177 * @see bp_blogs_add_blogmeta() 178 * 179 * @param string $retval 180 * 181 * @return string 182 */ 183 function bp_blogs_filter_meta_column_name( $retval ) { 184 if ( 'bp_blog_id' === $retval ) { 185 $retval = 'blog_id'; 186 } 187 return $retval; 188 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 26 01:01:04 2024 | Cross-referenced by PHPXref 0.7.1 |